Advertisement
rdusnr

Untitled

Feb 24th, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.23 KB | None | 0 0
  1. <?php
  2. /**
  3. * Include and setup custom metaboxes and fields.
  4. *
  5. */
  6.  
  7. add_filter( 'cmb2_meta_boxes', 'kleo_define_metaboxes' );
  8. /**
  9. * Define the metabox and field configurations.
  10. *
  11. * @param array $meta_boxes
  12. * @return array
  13. */
  14. function kleo_define_metaboxes( array $meta_boxes ) {
  15.  
  16. // Start with an underscore to hide fields from custom fields list
  17. $prefix = '_kleo_';
  18.  
  19.  
  20. $meta_boxes['general_metabox'] = array(
  21. 'id' => 'general_metabox',
  22. 'title' => esc_html__( 'Theme General options', 'buddyapp' ),
  23. 'object_types' => array( 'post', 'page' , 'product' ), // Post type
  24. 'context' => 'normal',
  25. 'priority' => 'high',
  26. 'show_names' => true, // Show field names on the left
  27. // 'cmb_styles' => false, // false to disable the CMB stylesheet
  28. // 'closed' => true, // Keep the metabox closed by default
  29. 'fields' => array(
  30.  
  31. array(
  32. 'name' => esc_html__( 'Show page title section', 'buddyapp' ),
  33. 'desc' => esc_html__( 'If you want to show the page title section on your page','buddyapp'),
  34. 'id' => $prefix . 'page_title_enable',
  35. 'type' => 'select',
  36. 'options' => array(
  37. '' => 'Default',
  38. 'yes' => 'Yes',
  39. 'no' => 'No'
  40. ),
  41. 'value' => ''
  42. ),
  43. array(
  44. 'name' => esc_html__( 'Custom page background color','buddyapp'),
  45. 'desc' => esc_html__('A custom background color just for this page','buddyapp'),
  46. 'id' => $prefix . 'page_bg',
  47. 'type' => 'colorpicker',
  48. 'default' => ''
  49. ),
  50. array(
  51. 'name' => esc_html__( 'Custom page background','buddyapp'),
  52. 'desc' => esc_html__('A custom background image just for this page','buddyapp'),
  53. 'id' => $prefix . 'page_bg_image',
  54. 'type' => 'file',
  55. 'allow' => 'url',
  56. 'default' => '',
  57. ),
  58. ),
  59. );
  60.  
  61.  
  62. $meta_boxes['post_metabox'] = array(
  63. 'id' => 'post_metabox',
  64. 'title' => esc_html__( 'Theme Post options', 'buddyapp' ),
  65. 'object_types' => array( 'post' ), // Post type
  66. 'context' => 'normal',
  67. 'priority' => 'high',
  68. 'show_names' => true, // Show field names on the left
  69. // 'cmb_styles' => false, // false to disable the CMB stylesheet
  70. // 'closed' => true, // Keep the metabox closed by default
  71. 'fields' => array(
  72.  
  73. array(
  74. 'name' => 'Show media on post page',
  75. 'desc' => 'If you want to show post featured media on single page',
  76. 'id' => $prefix . 'post_media_status',
  77. 'type' => 'select',
  78. 'options' => array(
  79. '' => 'Default',
  80. 'yes' => 'Yes',
  81. 'no' => 'No'
  82. ),
  83. 'value' => ''
  84. ),
  85. array(
  86. 'name' => 'Gallery images',
  87. 'desc' => 'Used when you select the Gallery format.',
  88. 'id' => $prefix . 'slider',
  89. 'type' => 'file_list',
  90. 'preview_size' => array( 100, 100 ), // Default: array( 50, 50 )
  91. 'allow' => 'url'
  92. ),
  93. array(
  94. 'name' => 'Video oEmbed URL',
  95. 'desc' => wp_kses_data( __( 'Enter a youtube, twitter, or instagram URL. Supports services listed at <a target="_blank" href="http://codex.wordpress.org/Embeds">http://codex.wordpress.org/Embeds</a>.', 'buddyapp' ) ),
  96. 'id' => $prefix . 'embed',
  97. 'type' => 'oembed',
  98. ),
  99. ),
  100. );
  101.  
  102. $meta_boxes['post_layout'] = array(
  103. 'id' => 'post_layout',
  104. 'title' => esc_html__('Post Layout Settings', 'buddyapp'),
  105. 'object_types' => array( 'post', 'product' ), // Post type
  106. 'context' => 'side',
  107. 'priority' => 'default',
  108. 'show_names' => false, // Show field names on the left
  109. 'fields' => array(
  110. array(
  111. 'name' => esc_html__('Post Layout', 'buddyapp'),
  112. 'desc' => '',
  113. 'id' => $prefix . 'post_layout',
  114. 'type' => 'select',
  115. 'options' => array(
  116. 'default' => esc_html__('Default', 'buddyapp'),
  117. 'right' => esc_html__('Right Sidebar', 'buddyapp'),
  118. 'left' => esc_html__('Left sidebar', 'buddyapp'),
  119. 'full' => esc_html__('Full width, no sidebar', 'buddyapp'),
  120. ),
  121. 'value' => 'default'
  122. ),
  123.  
  124. ),
  125. );
  126.  
  127. $meta_boxes['header_settings'] = array(
  128. 'id' => 'header_settings',
  129. 'title' => esc_html__('Header Settings', 'buddyapp'),
  130. 'object_types' => array( 'post', 'product', 'page' ), // Post type
  131. 'context' => 'side',
  132. 'priority' => 'default',
  133. 'show_names' => true, // Show field names on the left
  134. 'fields' => array(
  135. array(
  136. 'name' => esc_html__('Sidemenu status', 'buddyapp'),
  137. 'desc' => '',
  138. 'id' => $prefix . 'header_sidemenu',
  139. 'type' => 'select',
  140. 'options' => array(
  141. 'default' => esc_html__('Default', 'buddyapp'),
  142. 'enabled' => esc_html__('Enabled', 'buddyapp'),
  143. 'disabled' => esc_html__('Disabled', 'buddyapp'),
  144. ),
  145. 'value' => 'default',
  146. 'desc' => esc_html__('Enabled/Disable the sidemenu', 'buddyapp')
  147. ),
  148.  
  149. ),
  150. );
  151.  
  152. return $meta_boxes;
  153. }
  154.  
  155.  
  156. add_action( 'init', 'kleo_initialize_meta_boxes' );
  157. /**
  158. * Initialize the metabox class.
  159. */
  160. function kleo_initialize_meta_boxes() {
  161. if ( file_exists( KLEO_DIR . '/metaboxes/init.php' ) ) {
  162. require_once KLEO_DIR . '/metaboxes/init.php';
  163. }
  164. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement