Skip to content

Instantly share code, notes, and snippets.

@humayunahmed8
Last active September 14, 2018 11:18
Show Gist options
  • Save humayunahmed8/710517640e2f4e5417476735dd81dde7 to your computer and use it in GitHub Desktop.
Save humayunahmed8/710517640e2f4e5417476735dd81dde7 to your computer and use it in GitHub Desktop.
Metabox and Slide Options for Custom Shortcode Slider.
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access pages directly.
function stock_theme_page_metabox($options){
$options = array(); // remove old options
// -----------------------------------------
// Slide Options -
// -----------------------------------------
$options[] = array(
'id' => 'stock_slide_options',
'title' => 'Slide Options',
'post_type' => 'slide',
'context' => 'normal',
'priority' => 'high',
'sections' => array(
// begin: a section
array(
'name' => 'stock_page_options_meta',
// begin: fields
'fields' => array(
array(
'id' => 'buttons',
'type' => 'group',
'title' => 'Slide buttons',
'button_title' => 'Add New',
'accordion_title' => 'Add New bu tton',
'fields' => array(
array(
'id' => 'type',
'type' => 'select',
'title' => 'Button type',
'desc' => 'Select button type',
'options' => array(
'bordered' => 'Bordered button',
'filled' => 'Filled Button',
),
),
array(
'id' => 'text',
'type' => 'text',
'title' => 'Button text',
'desc' => 'Type button text',
'default' => 'Get a free consultation',
),
array(
'id' => 'link_type',
'type' => 'select',
'title' => 'Link type',
'options' => array(
'1' => 'WordPress Page',
'2' => 'External Link',
),
),
array(
'id' => 'link_to_page',
'type' => 'select',
'title' => 'Type Page',
'options' => 'page',
'dependency' => array( 'link_type', '==', '1' ),
),
array(
'id' => 'link_to_external',
'type' => 'text',
'title' => 'Type URL',
'dependency' => array( 'link_type', '==', '2' ),
),
),
),
array(
'id' => 'enable_overlay',
'type' => 'switcher',
'default' => true,
'title' => 'Enable Overlay?',
),
array(
'id' => 'overlay_opacity',
'type' => 'text',
'default' => '.7',
'title' => 'Overlay Percentage',
'desc' => 'Type overlay percentage in floating value, Max value is 1',
'dependency' => array( 'enable_overlay', '==', 'true' ),
),
array(
'id' => 'overlay_color',
'type' => 'color_picker',
'default' => '#181A1F',
'title' => 'Overlay Color',
'desc' => 'Select overlay color',
'dependency' => array( 'enable_overlay', '==', 'true' ),
),
), // end: fields
) // end: a section
),
);
return $options;
}
add_filter( 'cs_metabox_options', 'stock_theme_page_metabox' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment