配置文件
敬告:
配置文件中,所有id请避免post\page\post_title等等,以免冲突。
文章自定义字段
范例:
- $meta_conf = array(
- 'title' => 'Meta box example',
- 'id'=>'example_box',
- 'page'=>array('page','post'),
- 'context'=>'normal',
- 'priority'=>'low'
- );
- $ashu_meta = array();
- $ashu_meta[] = array(
- 'name' => 'Input Example',
- 'id' => 'text_example',
- 'desc' => 'A text input example, Default content:"Hello ashuwp."',
- 'std' => 'Hello ashuwp.',
- 'type' => 'text'
- );
- $new_box = new ashuwp_postmeta_feild($ashu_meta, $meta_conf);
$meta_conf配置项的说明:
title - 自定义面板的标题
id - 自定义面板的id。敬告:请确配置文件中所有id都不相同,同时避免post\page\title等词。
page - 数组,用于确定面板在哪些文章类型页面显示,支持自定义文章类型。
可参考add_meta_box函数的参数。
分类自定义字段
范例:
- $ashu_feild = array();
- $taxonomy_cof = array('category','post_tag');
- $ashu_feild[] = array(
- 'name' => 'Text Example',
- 'id' => 'text_example',
- 'desc' => 'description or notice.Default content:Default content',
- 'std' => 'Default content',
- 'edit_only' => false,
- "type" => "text"
- );
- //Add more...
- $ashuwp_termmeta_feild = new ashuwp_termmeta_feild($ashu_feild, $taxonomy_cof);
$taxonomy_cof 的说明
值为数组,用于确定在哪些分类法页面显示,支持自定义分类法。
设置页面
范例:
- $page_info = array(
- 'full_name' => 'General Options',
- 'optionname'=>'general',
- 'child'=>false,
- //'parent_slug'=>'',
- 'filename' => 'generalpage'
- );
- $ashu_options = array();
- $ashu_options[] = array(
- 'name' => 'Input Example',
- 'id' => '_id_text',
- 'desc' => 'description or notice',
- 'std' => 'Default content',
- 'type' => 'text'
- );
- $option_page = new ashuwp_options_feild($ashu_options, $page_info);
$page_info的说明
full_name - 设置页面的标题。
optionname - 数据保存的名称,在获取数据的时候需要用到。
child - 是否为顶级页面,若设置为true,则必须设置parent_slug参数
parent_slug - 父级页面的名称,可以是使用本框架配置的页面filename的值,也可以是wordpress默认已经存在的页面,比如'parent_slug'=>'edit.php?post_type=product',设置页面将会出现在自定义文章类型product的下面。
filename - 出现在url中,对parent_slug参数有用。