Fix identation

This commit is contained in:
IanDelMar 2018-11-19 00:43:14 +01:00
parent c8274df833
commit b653d6f2ce
1 changed files with 59 additions and 40 deletions

View File

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