选项卡
注意:文章自定义字段和设置页面都支持选项卡样式,但是分类字段由于代码结构限制没法实现。效果图如下。
文章自定义字段
1. 自定义面板中的配置变量增加一个'tab'=>true。
2. 利用'type' => 'open'和'type' => 'close'组合来确定选项卡。
范例:
- $meta_conf = array(
- 'title' => 'Meta box example',
- 'id'=>'example_box',
- 'page'=>array('page','post'),
- 'context'=>'normal',
- 'priority'=>'low',
- 'tab'=>true,
- );
- $ashu_meta = array();
- $ashu_meta[] = array(
- 'name' => 'Tab1 Begain',
- 'id' => 'tab1_open',
- 'type' => 'open'
- );
- $ashu_meta[] = array(
- 'name' => 'Input Example',
- 'id' => 'text_example',
- 'desc' => 'A text input example, Default content:"Hello ashuwp."',
- 'std' => 'Hello ashuwp.',
- 'type' => 'text'
- );
- $ashu_meta[] = array(
- 'name' => 'Tab1 Close',
- 'type' => 'close'
- );
- $ashu_meta[] = array(
- 'name' => 'Tab2 Begain',
- 'id' => 'tab2_open',
- 'type' => 'open'
- );
- $ashu_meta[] = array(
- 'name' => 'Input Example2',
- 'id' => 'text_example2',
- 'desc' => 'A text input example, Default content:"Hello ashuwp."',
- 'std' => 'Hello ashuwp.',
- 'type' => 'text'
- );
- $ashu_meta[] = array(
- 'name' => 'Texearea Example',
- 'id' => 'textarea_example',
- 'desc' => 'A textarea example, Default content:"Default content."',
- 'std' => 'Default content.',
- 'type' => 'textarea'
- );
- $ashu_meta[] = array(
- 'name' => 'Tab2 Close',
- 'type' => 'close'
- );
- $tab_box = new ashuwp_postmeta_feild($ashu_meta, $meta_conf);
设置页面
范例:
- $page_info = array(
- 'full_name' => 'General Options',
- 'optionname'=>'general',
- 'child'=>false,
- 'filename' => 'generalpage',
- 'tab'=>true
- );
- $ashu_options = array();
- $ashu_options[] = array(
- 'name' => 'Tab1 Begain',
- 'id' => 'tab1_open',
- 'type' => 'open'
- );
- $ashu_options[] = array(
- 'name' => 'Input Example',
- 'id' => 'text_example',
- 'desc' => 'A text input example, Default content:"Hello ashuwp."',
- 'std' => 'Hello ashuwp.',
- 'type' => 'text'
- );
- $ashu_options[] = array(
- 'name' => 'Tab1 Close',
- 'type' => 'close'
- );
- $ashu_options[] = array(
- 'name' => 'Tab2 Begain',
- 'id' => 'tab2_open',
- 'type' => 'open'
- );
- $ashu_options[] = array(
- 'name' => 'Input Example2',
- 'id' => 'text_example2',
- 'desc' => 'A text input example, Default content:"Hello ashuwp."',
- 'std' => 'Hello ashuwp.',
- 'type' => 'text'
- );
- $ashu_options[] = array(
- 'name' => 'Texearea Example',
- 'id' => 'textarea_example',
- 'desc' => 'A textarea example, Default content:"Default content."',
- 'std' => 'Default content.',
- 'type' => 'textarea'
- );
- $ashu_options[] = array(
- 'name' => 'Tab2 Close',
- 'type' => 'close'
- );
- $option_page = new ashuwp_options_feild($ashu_options, $page_info);
其它:
'type' => 'open' 和'type' => 'close'应该成对组合,不能嵌套。