当前位置: 首页 » 其他资源 » wordpress主题后台设置选项页完整下载

wordpress主题后台设置选项页完整下载

零分其他资源1,4682024-02-14 13:05

功能全,自定义强,可以方便随时增加/删除设置选项,后台数据仅插入一条wp_options表数据。

wordpress主题后台设置选项

文件:options.php 、CSS.css

后台设置预览:

功能可自定义修改代码设置

/**
 * 零分博客:https://www.32xp.com
 * 主题设置
 *****/
$shortname = "Eson_";    //主题简写,必须是英文、数字、下划线组合 
$ImgType=array("logo","favicon","encipher_qrcode","avatar","qrcode","banner");
$options = array(
    array(
        "name"=>"Tab1",
        "title"=>"综合设置",
        "data"=>array(
            array(
                "id"=>"logo",
                "input"=>"input",
                "rows"=>1,
                "label"=>"网站logo",
                "placeholder"=>"上传/输入logo图片地址"
            ),
            array(
                "id"=>"favicon",
                "input"=>"input",
                "rows"=>1,
                "label"=>"网站图标",
                "placeholder"=>"上传/输入logo图片地址"
            ),
			array(
                "id"=>"avatar",
                "input"=>"input",
                "rows"=>1,
                "label"=>"头像",
                "placeholder"=>"gravatar头像经常被墙,还是自己上传一张吧"
            ),
			array(
                "id"=>"qrcode",
                "input"=>"input",
                "rows"=>1,
                "label"=>"二维码",
                "placeholder"=>"二维码"
            ),
			array(
                "id"=>"banner",
                "input"=>"input",
                "rows"=>1,
                "label"=>"网站banner",
                "placeholder"=>"网站banner图片"
            ),
			array(
                "id"=>"hotso",
                "input"=>"input",
                "rows"=>2,
                "label"=>"热门搜索",
                "placeholder"=>"搜索框下面的热门搜索词,','隔开",
            ),
            array(
                "id"=>"keywords",
                "input"=>"input",
                "rows"=>"1",
                "label"=>"网站关键词",
                "placeholder"=>"设置网站关键词(Meta Keywords),用‘,’隔开",
            ),
			array(
                "id"=>"description",
                "input"=>"textarea",
                "rows"=>2,
                "label"=>"网站描述",
                "placeholder"=>"网站描述(Meta Description),针对搜索引擎设置的网页描述。",
            ),
			array(
                "id"=>"state",
                "input"=>"textarea",
                "rows"=>2,
                "label"=>"版权声明",
                "placeholder"=>"网站底部版权声明",
            ),
			array(
                "id"=>"icp",
                "input"=>"input",
                "rows"=>1,
                "label"=>"网站备案号",
                "placeholder"=>"网站备案号",
            ),
			array(
                "id"=>"stats",
                "input"=>"textarea",
                "rows"=>3,
                "label"=>"统计代码",
                "placeholder"=>"网站统计代码",
            ),
        )
    ),
    array(
        "name"=>"Tab2",
        "title"=>"轮播图设置",
        "data"=>array(
            array(
                "id"=>"swiper",
                "list"=>array(
					"state"=>"on",
					"list"=>array(
						array(
						"img"=>"",
						"url"=>"",
						"title"=>""
						)
					)
				)
            )
		)
    ),
	array(
		"name"=>"Tab3",
		"title"=>"文章加密器",
		"data"=>array(
			array(
				"id"=>"encipher_title",
				"input"=>"input",
				"rows"=>1,
				"label"=>"提示",
				"placeholder"=>"加密文章提示文本"
			),
			array(
				"id"=>"encipher_qrcode",
				"input"=>"input",
				"rows"=>1,
				"label"=>"二维码",
				"placeholder"=>"公众号二维码"
			),
			array(
				"id"=>"encipher_content",
				"input"=>"textarea",
				"rows"=>3,
				"label"=>"引导文本",
				"placeholder"=>"引导扫码文本,加密函数在functions.php,使用短代码/简码方式,主题使用[p][/p]来加密内容,这里设置自定义提示、引导文本"
			),
		)
	),
    array(
        "name"=>"Tab4",
        "title"=>"广告设置",
        "data"=>array(
            array(
                "id"=>"adlist",
                "rows"=>3,
				"list"=>array(
					"ad"=>array(
						"code"=>'',
						"state"=>'',
						"label"=>"边栏广告",
						"placeholder"=>"设置边栏广告,大小:500x500"
					),
					"ad1"=>array(
						"code"=>'',
						"state"=>'',
						"label"=>"底部广告",
						"placeholder"=>"设置边栏广告,大小:500x500"
					),
				),
                
                
            )
        )
    )
);

1、数组方式添加/删除后台设置选项,只需要通过自定义增加修改数组即可修改后台设置选项!

2、wordpress数据表wp_options,只增加一条json数据:

3、提取提取一次:json_decode(get_option( $myset )),$myset是设置前缀+Setting,默认设置的是Eson,$myset写“Esong_Setting”,后面用json数组方式去取每一条数据,示例:

$myset=json_decode(get_option( "Esong_Setting"));
$logo=$myset->logo;
...

4、取出的广告、焦点图等一些是取出数组,需要循环,广告可设置ID直接取出,如取边栏广告

$myset=json_decode(get_option( "Esong_Setting"));
$ad=$myset->adlist->ad->code;

判断广告是否开启

$state=$myset->adlist->ad->state;
if(isset($state) && !empty($state)){
//开启
}else{
//未开启
}

取焦点图:

判断焦点图是否开启

$state=$myset->swiper->state;
if(isset($state) && !empty($state)){
//开启
}else{
//未开启
}

焦点图数组:

$swiper=$myset->swiper->list;

需要循环取出图片、链接及标题

foreach($swiper as $key=>list){
list->img;//图片
list->url;//链接
list->title;//标题
}

自定义字段名:$shortname = “Eson_”;字段名开头

$ImgType=array(“logo”,”favicon”,”encipher_qrcode”,”avatar”,”qrcode”,”banner”);

设置图片类型的ID,只有设置了ID,右边才会出现上传图片按钮

下载:付费下载

END
零分站龄17年资深站长
一个喜欢折腾,却又折腾不出像样东西的,不会PHP的PHP程序员!
2517
文章
13
分类
3818
标签
3
友链
onlinelovesky317355746vipsever@vip.qq.com