选项卡

注意:文章自定义字段和设置页面都支持选项卡样式,但是分类字段由于代码结构限制没法实现。效果图如下。tabs

文章自定义字段

1.  自定义面板中的配置变量增加一个'tab'=>true。

2. 利用'type' => 'open'和'type' => 'close'组合来确定选项卡。

范例:

  1. /*****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.   'tab'=>true, //Look here
  9. );
  10. $ashu_meta = array();
  11. $ashu_meta[] = array(
  12.   'name' => 'Tab1 Begain',
  13.   'id'   => 'tab1_open',
  14.   'type' => 'open' //Look here
  15. );
  16. $ashu_meta[] = array(
  17.   'name' => 'Input Example',
  18.   'id'   => 'text_example',
  19.   'desc' => 'A text input example, Default content:"Hello ashuwp."',
  20.   'std'  => 'Hello ashuwp.',
  21.   'type' => 'text'
  22. );
  23. $ashu_meta[] = array(
  24.   'name' => 'Tab1 Close',
  25.   'type' => 'close' //Look here
  26. );
  27. $ashu_meta[] = array(
  28.   'name' => 'Tab2 Begain',
  29.   'id'   => 'tab2_open',
  30.   'type' => 'open' //Look here
  31. );
  32. $ashu_meta[] = array(
  33.   'name' => 'Input Example2',
  34.   'id'   => 'text_example2',
  35.   'desc' => 'A text input example, Default content:"Hello ashuwp."',
  36.   'std'  => 'Hello ashuwp.',
  37.   'type' => 'text'
  38. );
  39. $ashu_meta[] = array(
  40.   'name' => 'Texearea Example',
  41.   'id'   => 'textarea_example',
  42.   'desc' => 'A textarea example, Default content:"Default content."',
  43.   'std'  => 'Default content.',
  44.   'type' => 'textarea'
  45. );
  46. $ashu_meta[] = array(
  47.   'name' => 'Tab2 Close',
  48.   'type' => 'close' //Look here
  49. );
  50. $tab_box = new ashuwp_postmeta_feild($ashu_meta$meta_conf);

设置页面

范例:

  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.   'filename' => 'generalpage',
  12.   'tab'=>true //Look here
  13. );
  14. $ashu_options = array();
  15. $ashu_options[] = array(
  16.   'name' => 'Tab1 Begain',
  17.   'id'   => 'tab1_open',
  18.   'type' => 'open' //Look here
  19. );
  20. $ashu_options[] = array(
  21.   'name' => 'Input Example',
  22.   'id'   => 'text_example',
  23.   'desc' => 'A text input example, Default content:"Hello ashuwp."',
  24.   'std'  => 'Hello ashuwp.',
  25.   'type' => 'text'
  26. );
  27. $ashu_options[] = array(
  28.   'name' => 'Tab1 Close',
  29.   'type' => 'close' //Look here
  30. );
  31. $ashu_options[] = array(
  32.   'name' => 'Tab2 Begain',
  33.   'id'   => 'tab2_open',
  34.   'type' => 'open' //Look here
  35. );
  36. $ashu_options[] = array(
  37.   'name' => 'Input Example2',
  38.   'id'   => 'text_example2',
  39.   'desc' => 'A text input example, Default content:"Hello ashuwp."',
  40.   'std'  => 'Hello ashuwp.',
  41.   'type' => 'text'
  42. );
  43. $ashu_options[] = array(
  44.   'name' => 'Texearea Example',
  45.   'id'   => 'textarea_example',
  46.   'desc' => 'A textarea example, Default content:"Default content."',
  47.   'std'  => 'Default content.',
  48.   'type' => 'textarea'
  49. );
  50. $ashu_options[] = array(
  51.   'name' => 'Tab2 Close',
  52.   'type' => 'close' //Look here
  53. );
  54. $option_page = new ashuwp_options_feild($ashu_options$page_info);

其它:

'type' => 'open' 和'type' => 'close'应该成对组合,不能嵌套。