Better sanitization of options in the Customizer, other fixes

This commit is contained in:
Braad
2015-04-30 14:49:46 -07:00
parent 335594dbd2
commit c8667ce065
3 changed files with 59 additions and 57 deletions
+1 -1
View File
@@ -36,7 +36,7 @@ function trestle_settings_defaults() {
'logo_url_mobile' => '',
'favicon_url' => '',
'nav_primary_location' => 'full',
'custom_nav_extras_text' => '',
'search_in_nav' => '',
'read_more_text' => __( 'Read More »', 'trestle' ),
'revisions_number' => 3,
'footer_widgets_number' => 3,
+7 -5
View File
@@ -79,6 +79,7 @@ function trestle_customizer_controls( $wp_customize ) {
'type' => 'option',
'transport' => 'postMessage',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'esc_url_raw',
)
);
$wp_customize->add_control(
@@ -101,6 +102,7 @@ function trestle_customizer_controls( $wp_customize ) {
'type' => 'option',
'transport' => 'postMessage',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'esc_url_raw',
)
);
$wp_customize->add_control(
@@ -123,6 +125,7 @@ function trestle_customizer_controls( $wp_customize ) {
'type' => 'option',
'transport' => 'postMessage',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'esc_url_raw',
)
);
$wp_customize->add_control(
@@ -163,9 +166,9 @@ function trestle_customizer_controls( $wp_customize ) {
// Primary nav extras.
$wp_customize->add_setting(
'trestle-settings[custom_nav_extras_text]',
'trestle-settings[search_in_nav]',
array(
'default' => genesis_get_option( 'custom_nav_extras_text', 'trestle-settings' ),
'default' => genesis_get_option( 'search_in_nav', 'trestle-settings' ),
'type' => 'option',
'transport' => 'postMessage',
'capability' => 'edit_theme_options',
@@ -175,7 +178,7 @@ function trestle_customizer_controls( $wp_customize ) {
'trestle_custom_nav_extras_text_control',
array(
'section' => 'trestle_settings_section',
'settings' => 'trestle-settings[custom_nav_extras_text]',
'settings' => 'trestle-settings[search_in_nav]',
'label' => __( 'Add search to mobile navigation', 'trestle' ),
'type' => 'checkbox',
)
@@ -268,9 +271,8 @@ function trestle_customizer_controls( $wp_customize ) {
$wp_customize->add_setting(
'trestle-settings[link_icons_title]',
array(
'default' => genesis_get_option( 'link_icons_title', 'trestle-settings' ),
'default' => '',
'type' => 'option',
'capability' => 'edit_theme_options',
)
);
$wp_customize->add_control(
+1 -1
View File
@@ -233,7 +233,7 @@ add_filter( 'wp_nav_menu_items', 'trestle_custom_nav_extras', 10, 2 );
*/
function trestle_custom_nav_extras( $nav_items, stdClass $menu_args ) {
if ( 'primary' == $menu_args->theme_location && genesis_get_option( 'custom_nav_extras_text', 'trestle-settings' ) ) {
if ( 'primary' == $menu_args->theme_location && genesis_get_option( 'search_in_nav', 'trestle-settings' ) ) {
return $nav_items . '<li class="right custom">' . get_search_form( false ) . '</li>';
}