Skip to content

Instantly share code, notes, and snippets.

@kirasiris
Created July 25, 2019 19:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kirasiris/8026a06ef71005085fe64f744347e18c to your computer and use it in GitHub Desktop.
Save kirasiris/8026a06ef71005085fe64f744347e18c to your computer and use it in GitHub Desktop.
WordPress Custom Theme Selector and Custom Container Selector
<?php
function wpb_customize_register($wp_customize){
/*
*
* SHOWCASE THEME SELECTOR
*
*/
$wp_customize->add_setting('theme_selector', array(
'default' => _x('bootstrap', 'kevinurielfonsecav2'),
'type' => 'theme_mod'
));
$wp_customize->add_control( new WP_Customize_Control($wp_customize, 'theme_selector', array(
'label' => __( 'Select Theme Name', 'kevinurielfonsecav2' ), //Admin-visible name of the control
'description' => __( 'Using this option you can change the theme colors' ),
'priority' => 90, //Determines the order this control appears in for the specified section
'section' => 'title_tagline', //ID of the section this control should render in (can be one of yours, or a WordPress default section)
'type' => 'select',
'choices' => array(
'bootstrap' => 'Default',
'cerulean' => 'Cerulean',
'cosmo' => 'Cosmo',
'cyborg' => 'Cyborg',
'darkly' => 'Darkly',
'flatly' => 'Flatly',
'journal' => 'Journal',
'litera' => 'Litera',
'lumen' => 'Lumen',
'lux' => 'Lux'
)
)));
/*
*
* SHOWCASE THEME CONTAINER SELECTOR
*
*/
$wp_customize->add_setting('theme_container', array(
'default' => _x('container', 'kevinurielfonsecav2'),
'type' => 'theme_mod'
));
$wp_customize->add_control( new WP_Customize_Control($wp_customize, 'theme_container', array(
'label' => __( 'Select Theme Container', 'kevinurielfonsecav2' ), //Admin-visible name of the control
'description' => __( 'Using this option you can change the theme container' ),
'priority' => 90, //Determines the order this control appears in for the specified section
'section' => 'title_tagline', //ID of the section this control should render in (can be one of yours, or a WordPress default section)
'type' => 'select',
'choices' => array(
'container' => 'Container',
'container-fluid' => 'Container Fluid',
)
)));
// end of customizer function //
}
add_action('customize_register', 'wpb_customize_register');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment