配置文件

敬告:

配置文件中,所有id请避免post\page\post_title等等,以免冲突。

文章自定义字段

范例:

  1. /*****Post Meta Box********/
  2. $meta_conf = array(
  3.   'title' => 'Meta box example',
  4.   'id'=>'example_box',
  5.   'page'=>array('page','post'),
  6.   'context'=>'normal',
  7.   'priority'=>'low'
  8. );
  9. $ashu_meta = array();
  10. $ashu_meta[] = array(
  11.   'name' => 'Input Example',
  12.   'id'   => 'text_example',
  13.   'desc' => 'A text input example, Default content:"Hello ashuwp."',
  14.   'std'  => 'Hello ashuwp.',
  15.   'type' => 'text'
  16. );
  17. //Add more
  18. $new_box = new ashuwp_postmeta_feild($ashu_meta$meta_conf);

$meta_conf配置项的说明:

title - 自定义面板的标题

id - 自定义面板的id。敬告:请确配置文件中所有id都不相同,同时避免post\page\title等词。

page - 数组,用于确定面板在哪些文章类型页面显示,支持自定义文章类型。

可参考add_meta_box函数的参数。

 

分类自定义字段

范例:

  1. /*****taxonomy feild ******/
  2. $ashu_feild = array();
  3. $taxonomy_cof = array('category','post_tag');
  4. $ashu_feild[] = array(
  5.   'name'      => 'Text Example',
  6.   'id'        => 'text_example',
  7.   'desc'      => 'description or notice.Default content:Default content',
  8.   'std'       => 'Default content',
  9.   'edit_only' => false,
  10.   "type"      => "text"
  11. );
  12. //Add more...
  13. $ashuwp_termmeta_feild = new ashuwp_termmeta_feild($ashu_feild$taxonomy_cof);

$taxonomy_cof 的说明

值为数组,用于确定在哪些分类法页面显示,支持自定义分类法。

设置页面

范例:

  1. /**
  2. *
  3. *Optinos page
  4. *
  5. **/
  6. /**General options**/
  7. $page_info = array(
  8.   'full_name' => 'General Options',
  9.   'optionname'=>'general',
  10.   'child'=>false,
  11.   //'parent_slug'=>'',
  12.   'filename' => 'generalpage'
  13. );
  14. $ashu_options = array();
  15. $ashu_options[] = array(
  16.   'name' => 'Input Example',
  17.   'id'   => '_id_text',
  18.   'desc' => 'description or notice',
  19.   'std'  => 'Default content',
  20.   'type' => 'text'
  21. );
  22. //Add more...
  23. $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参数有用。