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,
+57 -55
View File
@@ -51,10 +51,10 @@ function trestle_customizer_controls( $wp_customize ) {
$wp_customize->add_setting(
'trestle-settings[layout]',
array(
'default' => genesis_get_option( 'layout', 'trestle-settings' ),
'type' => 'option',
'transport' => 'postMessage',
'capability' => 'edit_theme_options',
'default' => genesis_get_option( 'layout', 'trestle-settings' ),
'type' => 'option',
'transport' => 'postMessage',
'capability' => 'edit_theme_options',
)
);
$wp_customize->add_control(
@@ -75,10 +75,11 @@ function trestle_customizer_controls( $wp_customize ) {
$wp_customize->add_setting(
'trestle-settings[logo_url]',
array(
'default' => genesis_get_option( 'logo_url', 'trestle-settings' ),
'type' => 'option',
'transport' => 'postMessage',
'capability' => 'edit_theme_options',
'default' => genesis_get_option( 'logo_url', 'trestle-settings' ),
'type' => 'option',
'transport' => 'postMessage',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'esc_url_raw',
)
);
$wp_customize->add_control(
@@ -97,10 +98,11 @@ function trestle_customizer_controls( $wp_customize ) {
$wp_customize->add_setting(
'trestle-settings[logo_url_mobile]',
array(
'default' => genesis_get_option( 'logo_url_mobile', 'trestle-settings' ),
'type' => 'option',
'transport' => 'postMessage',
'capability' => 'edit_theme_options',
'default' => genesis_get_option( 'logo_url_mobile', 'trestle-settings' ),
'type' => 'option',
'transport' => 'postMessage',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'esc_url_raw',
)
);
$wp_customize->add_control(
@@ -119,10 +121,11 @@ function trestle_customizer_controls( $wp_customize ) {
$wp_customize->add_setting(
'trestle-settings[favicon_url]',
array(
'default' => genesis_get_option( 'favicon_url', 'trestle-settings' ),
'type' => 'option',
'transport' => 'postMessage',
'capability' => 'edit_theme_options',
'default' => genesis_get_option( 'favicon_url', 'trestle-settings' ),
'type' => 'option',
'transport' => 'postMessage',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'esc_url_raw',
)
);
$wp_customize->add_control(
@@ -141,10 +144,10 @@ function trestle_customizer_controls( $wp_customize ) {
$wp_customize->add_setting(
'trestle-settings[nav_primary_location]',
array(
'default' => genesis_get_option( 'nav_primary_location', 'trestle-settings' ),
'type' => 'option',
'transport' => 'postMessage',
'capability' => 'edit_theme_options',
'default' => genesis_get_option( 'nav_primary_location', 'trestle-settings' ),
'type' => 'option',
'transport' => 'postMessage',
'capability' => 'edit_theme_options',
)
);
$wp_customize->add_control(
@@ -155,27 +158,27 @@ function trestle_customizer_controls( $wp_customize ) {
'label' => __( 'Menu style', 'trestle' ),
'type' => 'select',
'choices' => array(
'full' => __( 'Full Width', 'trestle' ),
'header' => __( 'Header Right', 'trestle' ),
'full' => __( 'Full Width', 'trestle' ),
'header' => __( 'Header Right', 'trestle' ),
)
)
);
// 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' ),
'type' => 'option',
'transport' => 'postMessage',
'capability' => 'edit_theme_options',
'default' => genesis_get_option( 'search_in_nav', 'trestle-settings' ),
'type' => 'option',
'transport' => 'postMessage',
'capability' => 'edit_theme_options',
)
);
$wp_customize->add_control(
'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',
)
@@ -205,10 +208,10 @@ function trestle_customizer_controls( $wp_customize ) {
$wp_customize->add_setting(
'trestle-settings[revisions_number]',
array(
'default' => genesis_get_option( 'revisions_number', 'trestle-settings' ),
'type' => 'option',
'transport' => 'postMessage',
'capability' => 'edit_theme_options',
'default' => genesis_get_option( 'revisions_number', 'trestle-settings' ),
'type' => 'option',
'transport' => 'postMessage',
'capability' => 'edit_theme_options',
)
);
$wp_customize->add_control(
@@ -239,10 +242,10 @@ function trestle_customizer_controls( $wp_customize ) {
$wp_customize->add_setting(
'trestle-settings[footer_widgets_number]',
array(
'default' => genesis_get_option( 'footer_widgets_number', 'trestle-settings' ),
'type' => 'option',
'transport' => 'postMessage',
'capability' => 'edit_theme_options',
'default' => genesis_get_option( 'footer_widgets_number', 'trestle-settings' ),
'type' => 'option',
'transport' => 'postMessage',
'capability' => 'edit_theme_options',
)
);
$wp_customize->add_control(
@@ -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' ),
'type' => 'option',
'capability' => 'edit_theme_options',
'default' => '',
'type' => 'option',
)
);
$wp_customize->add_control(
@@ -287,10 +289,10 @@ function trestle_customizer_controls( $wp_customize ) {
$wp_customize->add_setting(
'trestle-settings[external_link_icons]',
array(
'default' => genesis_get_option( 'external_link_icons', 'trestle-settings' ),
'type' => 'option',
'transport' => 'postMessage',
'capability' => 'edit_theme_options',
'default' => genesis_get_option( 'external_link_icons', 'trestle-settings' ),
'type' => 'option',
'transport' => 'postMessage',
'capability' => 'edit_theme_options',
)
);
$wp_customize->add_control(
@@ -307,10 +309,10 @@ function trestle_customizer_controls( $wp_customize ) {
$wp_customize->add_setting(
'trestle-settings[email_link_icons]',
array(
'default' => genesis_get_option( 'email_link_icons', 'trestle-settings' ),
'type' => 'option',
'transport' => 'postMessage',
'capability' => 'edit_theme_options',
'default' => genesis_get_option( 'email_link_icons', 'trestle-settings' ),
'type' => 'option',
'transport' => 'postMessage',
'capability' => 'edit_theme_options',
)
);
$wp_customize->add_control(
@@ -327,10 +329,10 @@ function trestle_customizer_controls( $wp_customize ) {
$wp_customize->add_setting(
'trestle-settings[pdf_link_icons]',
array(
'default' => genesis_get_option( 'pdf_link_icons', 'trestle-settings' ),
'type' => 'option',
'transport' => 'postMessage',
'capability' => 'edit_theme_options',
'default' => genesis_get_option( 'pdf_link_icons', 'trestle-settings' ),
'type' => 'option',
'transport' => 'postMessage',
'capability' => 'edit_theme_options',
)
);
$wp_customize->add_control(
@@ -347,10 +349,10 @@ function trestle_customizer_controls( $wp_customize ) {
$wp_customize->add_setting(
'trestle-settings[doc_link_icons]',
array(
'default' => genesis_get_option( 'doc_link_icons', 'trestle-settings' ),
'type' => 'option',
'transport' => 'postMessage',
'capability' => 'edit_theme_options',
'default' => genesis_get_option( 'doc_link_icons', 'trestle-settings' ),
'type' => 'option',
'transport' => 'postMessage',
'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>';
}