Advertisement
SMSabuj

metabox-and-options.php

Apr 6th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.20 KB | None | 0 0
  1. <?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access pages directly.
  2.  
  3. function factorian_theme_metabox($options ){
  4.     $options = array(); // remove old options
  5.      
  6.         // -----------------------------------------
  7.         // Page Metabox Options                    -
  8.         // -----------------------------------------
  9.         $options[]    = array(
  10.           'id'        => 'factorian_page_options',
  11.           'title'     => 'Page Options',
  12.           'post_type' => 'page',
  13.           'context'   => 'normal',
  14.           'priority'  => 'high',
  15.           'sections'  => array(
  16.  
  17.             // begin: a section
  18.             array(
  19.               'name'  => 'factorian_page_options_meta',
  20.               'icon'  => 'fa fa-cog',
  21.  
  22.               // begin: fields
  23.               'fields' => array(
  24.  
  25.                 // begin: a field
  26.                 array(
  27.                   'id'    => 'enable_title',
  28.                   'type'  => 'switcher',
  29.                   'title' => 'Enable Title',
  30.                   'default' => true,
  31.                   'desc' => esc_html__('If you want to enable title, select yes','factorian-rrf'),
  32.                 ),
  33.                     array(
  34.                       'id'    => 'enable_content',
  35.                       'type'  => 'switcher',
  36.                       'title' => 'Enable content',
  37.                       'default' => false,
  38.                       'desc' => esc_html__('If you want to enable Content, select yes','factorian-rrf'),
  39.                     )
  40.               ), // end: fields
  41.             ), // end: a section
  42.           ),
  43.         );  
  44.    
  45.         // -----------------------------------------
  46.         // Factorian Slide Options                    -
  47.         // -----------------------------------------
  48.         $options[]    = array(
  49.           'id'        => 'factorian_slide_options',
  50.           'title'     => 'Slide Options',
  51.           'post_type' => 'slide',
  52.           'context'   => 'normal',
  53.           'priority'  => 'high',
  54.           'sections'  => array(
  55.  
  56.             // begin: a section
  57.             array(
  58.               'name'  => 'factorian_slide_options_meta',
  59.  
  60.               // begin: fields
  61.               'fields' => array(
  62.  
  63.                    array(
  64.                       'id'              => 'buttons',
  65.                       'type'            => 'group',
  66.                       'title'           => 'Slide Buttons',
  67.                       'button_title'    => 'Add New',
  68.                       'accordion_title' => 'Add New Button',
  69.                       'fields'          => array(
  70.                             array(
  71.                               'id'    => 'type',
  72.                               'type'  => 'select',
  73.                               'title' => 'Select Button',
  74.                               'desc' => 'Select Button Type',
  75.                               'options'    => array(
  76.                                     'bordered'    => 'Borderd Button',
  77.                                     'filled'     => 'Filled Button',
  78.                                     'boxed'   => 'Boxed Button',
  79.                                   ),
  80.                                 ),
  81.                             array(
  82.                               'id'    => 'text',
  83.                               'type'  => 'text',
  84.                               'title' => 'Button Text',
  85.                               'desc' => 'Type Button Text',
  86.                               'default' => 'Get free consultation',
  87.                             ),
  88.                             array(
  89.                               'id'    => 'link_type',
  90.                               'type'  => 'select',
  91.                               'title' => 'Link Type',
  92.                               'desc' => 'Select Link Type',
  93.                               'options'    => array(
  94.                                     '1'    => 'WordPress page',
  95.                                     '2'     => 'External link',
  96.                                   ),
  97.                                 ),
  98.                                 array(
  99.                                   'id'    => 'link_to_page',
  100.                                   'type'  => 'select',
  101.                                   'title' => 'Select Page',
  102.                                   'desc' => 'Select a Page',
  103.                                   'options'    => 'page',
  104.                                   'dependency'   => array( 'link_type', '==', '1' ),
  105.                               ),
  106.                                 array(
  107.                                   'id'    => 'link_to_expernal',
  108.                                   'type'  => 'text',
  109.                                   'title' => 'Type URL',
  110.                                   'desc' => 'Type a valid URL',
  111.                                   'dependency'   => array( 'link_type', '==', '2' ),
  112.                               ),
  113.                           ),
  114.                         ),
  115.                
  116.                 array(
  117.                   'id'    => 'enable_overlay',
  118.                   'type'  => 'switcher',
  119.                   'default' => true,
  120.                   'title' => 'Enable Overlay!',
  121.                   'desc' => 'Select Overlay Type',
  122.                 ),
  123.                   array(
  124.                       'id'    => 'overlay_percentage', // this is must be unique
  125.                       'type'  => 'text',
  126.                       'default' => .5,
  127.                       'title' => 'Overlay percentage',
  128.                       'desc' => 'Type Overlay percentage in Floating Number. Max value is 1.',
  129.                       'dependency'   => array( 'enable_overlay', '==', 'true' ),
  130.                     ),
  131.                       array(
  132.                           'id'    => 'overlay_color',
  133.                           'type'  => 'color_picker',
  134.                           'default' => '#181a1f',
  135.                           'title' => 'Overlay Color ',
  136.                           'desc' => 'Select Overlay Color ',
  137.                           'dependency'   => array( 'enable_overlay', '==', 'true' ),
  138.                         ),
  139.  
  140.  
  141.  
  142.               ), // end: fields
  143.             ), // end: a section
  144.           ),
  145.         );
  146.  
  147.   return $options;
  148. }
  149. add_filter( 'cs_metabox_options', 'factorian_theme_metabox' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement