Skip to content

Instantly share code, notes, and snippets.

@seothemes
Last active April 16, 2019 15:05
Show Gist options
  • Save seothemes/020490fd2715967f05fccfdf98c829db to your computer and use it in GitHub Desktop.
Save seothemes/020490fd2715967f05fccfdf98c829db to your computer and use it in GitHub Desktop.
Demo of Genesis theme settings in the Customizer
<?php
// Add color scheme support for demo.
add_theme_support( 'genesis-style-selector', array(
'dark' => 'Dark',
'light' => 'Light',
) );
add_action( 'customize_register', 'genesis_demo_customizer_settings', 20 );
/**
* Move Genesis theme settings to Customizer.
*
* @param object $wp_customize WP Customize object.
* @return void
*/
function genesis_demo_customizer_settings( $wp_customize ) {
global $wp_customize;
// Add theme settings panel.
$wp_customize->add_panel( 'genesis_theme_settings', array(
'priority' => 158,
'capability' => 'edit_theme_options',
'theme_supports' => '',
'title' => __('Theme Settings', 'mytheme'),
'description' => __('Several settings pertaining my theme', 'mytheme'),
) );
// Move existing.
$wp_customize->get_section( 'genesis_color_scheme' )->panel = 'genesis_theme_settings';
$wp_customize->get_section( 'genesis_layout' )->panel = 'genesis_theme_settings';
$wp_customize->get_section( 'genesis_breadcrumbs' )->panel = 'genesis_theme_settings';
$wp_customize->get_section( 'genesis_comments' )->panel = 'genesis_theme_settings';
$wp_customize->get_section( 'genesis_archives' )->panel = 'genesis_theme_settings';
// Reorder existing.
$wp_customize->get_section( 'genesis_color_scheme' )->priority = 9;
$wp_customize->get_section( 'genesis_layout' )->priority = 3;
$wp_customize->get_section( 'genesis_breadcrumbs' )->priority = 5;
$wp_customize->get_section( 'genesis_comments' )->priority = 6;
$wp_customize->get_section( 'genesis_archives' )->priority = 7;
// Add theme settings sections.
$wp_customize->add_section( 'information', array(
'title' => 'Information',
'panel' => 'genesis_theme_settings',
'priority' => 1,
) );
$wp_customize->add_section( 'custom_feeds', array(
'title' => 'Custom Feeds',
'panel' => 'genesis_theme_settings',
'priority' => 2,
) );
$wp_customize->add_section( 'navigation', array(
'title' => 'Navigation',
'panel' => 'genesis_theme_settings',
'priority' => 4,
) );
$wp_customize->add_section( 'blog_page', array(
'title' => 'Blog Page',
'panel' => 'genesis_theme_settings',
'priority' => 8,
) );
$wp_customize->add_section( 'scripts', array(
'title' => 'Scripts',
'panel' => 'genesis_theme_settings',
'priority' => 10,
) );
// Add theme settings settings.
$wp_customize->add_setting( 'information' );
$wp_customize->add_setting( 'custom_feeds' );
$wp_customize->add_setting( 'navigation' );
$wp_customize->add_setting( 'blog_page' );
$wp_customize->add_setting( 'scripts' );
// Add theme settings controls.
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize,
'information',
array(
'label' => 'Information',
'settings' => 'information',
'section' => 'information',
)
) );
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize,
'custom_feeds',
array(
'label' => 'Custom Feeds',
'settings' => 'custom_feeds',
'section' => 'custom_feeds',
)
) );
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize,
'navigation',
array(
'label' => 'Navigation',
'settings' => 'navigation',
'section' => 'navigation',
)
) );
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize,
'blog_page',
array(
'label' => 'Blog Page',
'settings' => 'blog_page',
'section' => 'blog_page',
)
) );
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize,
'scripts',
array(
'label' => 'Scripts',
'settings' => 'scripts',
'section' => 'scripts',
)
) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment