diff --git a/inc/customizer.php b/inc/customizer.php index 6729d77..c774f43 100644 --- a/inc/customizer.php +++ b/inc/customizer.php @@ -37,12 +37,15 @@ if ( ! function_exists( 'understrap_theme_customize_register' ) ) { function understrap_theme_customize_register( $wp_customize ) { // Theme layout settings. - $wp_customize->add_section( 'understrap_theme_layout_options', array( - 'title' => __( 'Theme Layout Settings', 'understrap' ), - 'capability' => 'edit_theme_options', - 'description' => __( 'Container width and sidebar defaults', 'understrap' ), - 'priority' => 160, - ) ); + $wp_customize->add_section( + 'understrap_theme_layout_options', + array( + 'title' => __( 'Theme Layout Settings', 'understrap' ), + 'capability' => 'edit_theme_options', + 'description' => __( 'Container width and sidebar defaults', 'understrap' ), + 'priority' => 160, + ) + ); /** * Select sanitization function @@ -51,30 +54,34 @@ if ( ! function_exists( 'understrap_theme_customize_register' ) ) { * @param WP_Customize_Setting $setting Setting instance. * @return string Sanitized slug if it is a valid choice; otherwise, the setting default. */ - function understrap_theme_slug_sanitize_select( $input, $setting ){ + function understrap_theme_slug_sanitize_select( $input, $setting ) { - // Ensure input is a slug (lowercase alphanumeric characters, dashes and underscores are allowed only). - $input = sanitize_key( $input ); + // Ensure input is a slug (lowercase alphanumeric characters, dashes and underscores are allowed only). + $input = sanitize_key( $input ); - // Get the list of possible select options. - $choices = $setting->manager->get_control( $setting->id )->choices; + // Get the list of possible select options. + $choices = $setting->manager->get_control( $setting->id )->choices; - // If the input is a valid key, return it; otherwise, return the default. - return ( array_key_exists( $input, $choices ) ? $input : $setting->default ); + // If the input is a valid key, return it; otherwise, return the default. + return ( array_key_exists( $input, $choices ) ? $input : $setting->default ); - } + } - $wp_customize->add_setting( 'understrap_container_type', array( - 'default' => 'container', - 'type' => 'theme_mod', - 'sanitize_callback' => 'understrap_theme_slug_sanitize_select', - 'capability' => 'edit_theme_options', - ) ); + $wp_customize->add_setting( + 'understrap_container_type', + array( + 'default' => 'container', + 'type' => 'theme_mod', + 'sanitize_callback' => 'understrap_theme_slug_sanitize_select', + 'capability' => 'edit_theme_options', + ) + ); $wp_customize->add_control( new WP_Customize_Control( $wp_customize, - 'understrap_container_type', array( + 'understrap_container_type', + array( 'label' => __( 'Container Width', 'understrap' ), 'description' => __( 'Choose between Bootstrap\'s container and container-fluid', 'understrap' ), 'section' => 'understrap_theme_layout_options', @@ -86,35 +93,43 @@ if ( ! function_exists( 'understrap_theme_customize_register' ) ) { ), 'priority' => '10', ) - ) ); + ) + ); - $wp_customize->add_setting( 'understrap_sidebar_position', array( - 'default' => 'right', - 'type' => 'theme_mod', - 'sanitize_callback' => 'sanitize_text_field', - 'capability' => 'edit_theme_options', - ) ); + $wp_customize->add_setting( + 'understrap_sidebar_position', + array( + 'default' => 'right', + 'type' => 'theme_mod', + 'sanitize_callback' => 'sanitize_text_field', + 'capability' => 'edit_theme_options', + ) + ); $wp_customize->add_control( new WP_Customize_Control( $wp_customize, - 'understrap_sidebar_position', array( - 'label' => __( 'Sidebar Positioning', 'understrap' ), - 'description' => __( 'Set sidebar\'s default position. Can either be: right, left, both or none. Note: this can be overridden on individual pages.', - 'understrap' ), - 'section' => 'understrap_theme_layout_options', - 'settings' => 'understrap_sidebar_position', - 'type' => 'select', + 'understrap_sidebar_position', + array( + 'label' => __( 'Sidebar Positioning', 'understrap' ), + 'description' => __( + 'Set sidebar\'s default position. Can either be: right, left, both or none. Note: this can be overridden on individual pages.', + 'understrap' + ), + 'section' => 'understrap_theme_layout_options', + 'settings' => 'understrap_sidebar_position', + 'type' => 'select', 'sanitize_callback' => 'understrap_theme_slug_sanitize_select', - 'choices' => array( + 'choices' => array( 'right' => __( 'Right sidebar', 'understrap' ), 'left' => __( 'Left sidebar', 'understrap' ), 'both' => __( 'Left & Right sidebars', 'understrap' ), 'none' => __( 'No sidebar', 'understrap' ), ), - 'priority' => '20', + 'priority' => '20', ) - ) ); + ) + ); } } // endif function_exists( 'understrap_theme_customize_register' ). add_action( 'customize_register', 'understrap_theme_customize_register' ); @@ -127,8 +142,12 @@ if ( ! function_exists( 'understrap_customize_preview_js' ) ) { * Setup JS integration for live previewing. */ function understrap_customize_preview_js() { - wp_enqueue_script( 'understrap_customizer', get_template_directory_uri() . '/js/customizer.js', - array( 'customize-preview' ), '20130508', true + wp_enqueue_script( + 'understrap_customizer', + get_template_directory_uri() . '/js/customizer.js', + array( 'customize-preview' ), + '20130508', + true ); } }