Advertisement
Guest User

Untitled

a guest
Oct 19th, 2018
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 11.15 KB | None | 0 0
  1. /**
  2.  * Adds METABOX hide and show
  3. **/
  4.  
  5. add_filter( 'rwmb_meta_boxes', 'sage_register_meta_boxes' );
  6. /**
  7.  * Register meta boxes
  8.  *
  9.  * @param array $meta_boxes
  10.  *
  11.  * @return array
  12.  */
  13. function sage_register_meta_boxes( $meta_boxes ) {
  14.     $prefix = 'rw_';
  15.  
  16.     //Home Metaboxes
  17.    
  18.     $meta_boxes[] = array(
  19.         'title'  => 'Template - Home',
  20.         'pages'  => array( 'page' ),
  21.         // Show this meta box for posts matched below conditions
  22.         'show'   => array(
  23.             // With all conditions below, use this logical operator to combine them. Default is 'OR'. Case insensitive. Optional.
  24.             'relation'    => 'OR',
  25.             // List of page templates (used for page only). Array. Optional.
  26.             'template'    => array( 'page-home.php' ),
  27.             // List of post formats. Array. Case insensitive. Optional.
  28.             'post_format' => array(),
  29.             // List of categories IDs or names (NOT slugs). Array. Case sensitive. Optional.
  30.             'category'    => array(),
  31.             // Custom taxonomy. Optional.
  32.             // Format: 'taxonomy' => list of term IDs or names (NOT slugs). Array. Case sensitive. Optional.
  33.             'location'    => array(),
  34.             'os'          => array(),
  35.             // Check if page is a child page
  36.             'is_child' => true
  37.         ),
  38.         'fields' => array(
  39.             //Fields are broken into groups below
  40.             array(
  41.                 'name' => 'Hero',
  42.                 'id'   => 'home__hero',
  43.                 'type' => 'group',
  44.                 //List of fields
  45.                 'fields' => array(    
  46.                     array(
  47.                         'name' => __( 'H4', 'textdomain' ),
  48.                         'id'   => $prefix . 'hometemp-hero-h4',
  49.                         'type' => 'text',
  50.                     ),
  51.                     array(
  52.                         'name' => __( 'H1', 'textdomain' ),
  53.                         'id'   => $prefix . 'hometemp-hero-h1',
  54.                         'type' => 'text',
  55.                     ),
  56.                     array(
  57.                         'name' => __( 'Paragraph', 'textdomain' ),
  58.                         'id'   => $prefix . 'hometemp-hero-p',
  59.                         'type' => 'textarea',
  60.                     ),
  61.                     array(
  62.                         'name' => __( 'Button URL', 'textdomain' ),
  63.                         'id'   => $prefix . 'hometemp-hero-btn-url',
  64.                         'type' => 'url',
  65.                     ),
  66.                     array(
  67.                         'name' => __( 'Background URL (≥1200px)', 'textdomain' ),
  68.                         'id'   => $prefix . 'hometemp-hero-bg-1200',
  69.                         'type' => 'file_advanced',
  70.                     ),
  71.                     array(
  72.                         'name' => __( 'Background URL (<768px)', 'textdomain' ),
  73.                         'id'   => $prefix . 'hometemp-hero-bg-768',
  74.                         'type' => 'file_advanced',
  75.                     ),
  76.                 ),
  77.             ),
  78.             array(
  79.                 'name' => 'Offerings',
  80.                 'id'   => 'home__offering',
  81.                 'type' => 'group',
  82.                 //List of fields
  83.                 'fields' => array(  
  84.                     array(
  85.                         'name' => __( 'H2', 'textdomain' ),
  86.                         'id'   => $prefix . 'hometemp-offering-h2',
  87.                         'type' => 'text',
  88.                     ),
  89.                     array(
  90.                         'name' => __( 'Paragraph', 'textdomain' ),
  91.                         'id'   => $prefix . 'hometemp-offering-p',
  92.                         'type' => 'text',
  93.                     ),
  94.                     array(
  95.                         'name' => __( 'Box 1 Icon', 'textdomain' ),
  96.                         'id'   => $prefix . 'hometemp-offering-b1icon',
  97.                         'type' => 'file_advanced',
  98.                     ),
  99.                     array(
  100.                         'name' => __( 'Box 1 H4', 'textdomain' ),
  101.                         'id'   => $prefix . 'hometemp-offering-b1h4',
  102.                         'type' => 'text',
  103.                     ),
  104.                     array(
  105.                         'name' => __( 'Box 1 URL', 'textdomain' ),
  106.                         'id'   => $prefix . 'hometemp-offering-b1url',
  107.                         'type' => 'url',
  108.                     ),
  109.                     array(
  110.                         'name' => __( 'Box 1 Paragraph', 'textdomain' ),
  111.                         'id'   => $prefix . 'hometemp-offering-b1p',
  112.                         'type' => 'textarea',
  113.                     ),
  114.                     array(
  115.                         'name' => __( 'Box 2 Icon', 'textdomain' ),
  116.                         'id'   => $prefix . 'hometemp-offering-b2icon',
  117.                         'type' => 'file_advanced',
  118.                     ),
  119.                     array(
  120.                         'name' => __( 'Box 2 H4', 'textdomain' ),
  121.                         'id'   => $prefix . 'hometemp-offering-b2h4',
  122.                         'type' => 'text',
  123.                     ),
  124.                     array(
  125.                         'name' => __( 'Box 2 URL', 'textdomain' ),
  126.                         'id'   => $prefix . 'hometemp-offering-b2url',
  127.                         'type' => 'url',
  128.                     ),
  129.                     array(
  130.                         'name' => __( 'Box 2 Paragraph', 'textdomain' ),
  131.                         'id'   => $prefix . 'hometemp-offering-b2p',
  132.                         'type' => 'textarea',
  133.                     ),
  134.                     array(
  135.                         'name' => __( 'Box 3 Icon', 'textdomain' ),
  136.                         'id'   => $prefix . 'hometemp-offering-b3icon',
  137.                         'type' => 'file_advanced',
  138.                     ),
  139.                     array(
  140.                         'name' => __( 'Box 3 H4', 'textdomain' ),
  141.                         'id'   => $prefix . 'hometemp-offering-b3h4',
  142.                         'type' => 'text',
  143.                     ),
  144.                     array(
  145.                         'name' => __( 'Box 3 URL', 'textdomain' ),
  146.                         'id'   => $prefix . 'hometemp-offering-b3url',
  147.                         'type' => 'url',
  148.                     ),
  149.                     array(
  150.                         'name' => __( 'Box 3 Paragraph', 'textdomain' ),
  151.                         'id'   => $prefix . 'hometemp-offering-b3p',
  152.                         'type' => 'textarea',
  153.                     ),
  154.                     array(
  155.                         'name' => __( 'Box 4 Icon', 'textdomain' ),
  156.                         'id'   => $prefix . 'hometemp-offering-b4icon',
  157.                         'type' => 'file_advanced',
  158.                     ),
  159.                     array(
  160.                         'name' => __( 'Box 4 H4', 'textdomain' ),
  161.                         'id'   => $prefix . 'hometemp-offering-b4h4',
  162.                         'type' => 'text',
  163.                     ),
  164.                     array(
  165.                         'name' => __( 'Box 4 URL', 'textdomain' ),
  166.                         'id'   => $prefix . 'hometemp-offering-b4url',
  167.                         'type' => 'url',
  168.                     ),
  169.                     array(
  170.                         'name' => __( 'Box 4 Paragraph', 'textdomain' ),
  171.                         'id'   => $prefix . 'hometemp-offering-b4p',
  172.                         'type' => 'textarea',
  173.                     ),
  174.                 ),
  175.             ),
  176.             array(
  177.                 'name' => 'Featured Insights',
  178.                 'id'   => 'home__finsights',
  179.                 'type' => 'group',
  180.                 //List of fields
  181.                 'fields' => array(
  182.                     array(
  183.                         'name'        => __( 'Featured Insight #1', 'sage_' ),
  184.                         'id'          => $prefix . 'hometemp-feat1',
  185.                         'type'        => 'post',
  186.                         // 'clone'       => true,
  187.                         // 'multiple'    => true,
  188.                         // Post type: string (for single post type) or array (for multiple post types)
  189.                         'post_type'   => array( 'post', 'media-assets' ),
  190.                         // Default selected value (post ID)
  191.                         'std'         => 1,
  192.                         // Field type, either 'select' or 'select_advanced' (default)
  193.                         'field_type'  => 'select_advanced',
  194.                         // Placeholder
  195.                         'placeholder' => __( 'Select An Article', 'sage_' ),
  196.                         // Query arguments (optional). No settings means get all published posts
  197.                         // @see https://codex.wordpress.org/Class_Reference/WP_Query
  198.                         'query_args'  => array(
  199.                            'post_status'    => 'publish',
  200.                            'posts_per_page' => - 1,
  201.                         ),
  202.                     ),
  203.                     array(
  204.                         'name'        => __( 'Featured Insight #2', 'sage_' ),
  205.                         'id'          => $prefix . 'hometemp-feat2',
  206.                         'type'        => 'post',
  207.                         // 'clone'       => true,
  208.                         // 'multiple'    => true,
  209.                         // Post type: string (for single post type) or array (for multiple post types)
  210.                         'post_type'   => array( 'post', 'media-assets' ),
  211.                         // Default selected value (post ID)
  212.                         'std'         => 1,
  213.                         // Field type, either 'select' or 'select_advanced' (default)
  214.                         'field_type'  => 'select_advanced',
  215.                         // Placeholder
  216.                         'placeholder' => __( 'Select An Article', 'sage_' ),
  217.                         // Query arguments (optional). No settings means get all published posts
  218.                         // @see https://codex.wordpress.org/Class_Reference/WP_Query
  219.                         'query_args'  => array(
  220.                            'post_status'    => 'publish',
  221.                            'posts_per_page' => - 1,
  222.                         ),
  223.                     ),
  224.                 ),
  225.             ),
  226.             array(
  227.                 'name' => 'Featured Video',
  228.                 'id'   => 'home__fvideo',
  229.                 'type' => 'group',
  230.                 //List of fields
  231.                 'fields' => array(
  232.                     array(
  233.                         'id'          => $prefix . 'hometemp-fvideo',
  234.                         'name'  => __( 'Video Embed', 'sage_' ),
  235.                         'type'  => 'oembed',
  236.                         // Allow to clone? Default is false
  237.                         'clone' => false,
  238.                         // Input size
  239.                         'size'  => 30,
  240.                     ),
  241.                     array(
  242.                         'name' => __( 'H4', 'textdomain' ),
  243.                         'id'   => $prefix . 'hometemp-fvideo-b4h4',
  244.                         'type' => 'text',
  245.                     ),
  246.                     array(
  247.                         'name' => __( 'Paragraph', 'textdomain' ),
  248.                         'id'   => $prefix . 'hometemp-offering-b4p',
  249.                         'type' => 'textarea',
  250.                     ),
  251.                     array(
  252.                         'name' => __( 'Button URL', 'textdomain' ),
  253.                         'id'   => $prefix . 'hometemp-offering-b4url',
  254.                         'type' => 'url',
  255.                     ),
  256.                 ),
  257.             ),
  258.         ),
  259.     );
  260.     return $meta_boxes;
  261. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement