From 9464a4aa1afad0e1e6a154343300b8899f318b3f Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Wed, 4 Dec 2013 21:33:11 +0000 Subject: [PATCH] Twenty Fourteen: sanitize the values of Featured Content layout option, props kwight. Fixes #26408. Built from https://develop.svn.wordpress.org/trunk@26636 git-svn-id: http://core.svn.wordpress.org/trunk@26526 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../themes/twentyfourteen/inc/customizer.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/wp-content/themes/twentyfourteen/inc/customizer.php b/wp-content/themes/twentyfourteen/inc/customizer.php index 1631117207..a9b316e55e 100644 --- a/wp-content/themes/twentyfourteen/inc/customizer.php +++ b/wp-content/themes/twentyfourteen/inc/customizer.php @@ -47,7 +47,8 @@ function twentyfourteen_customize_register( $wp_customize ) { // Add the featured content layout setting and control. $wp_customize->add_setting( 'featured_content_layout', array( - 'default' => 'grid', + 'default' => 'grid', + 'sanitize_callback' => 'twentyfourteen_sanitize_layout', ) ); $wp_customize->add_control( 'featured_content_layout', array( @@ -62,6 +63,21 @@ function twentyfourteen_customize_register( $wp_customize ) { } add_action( 'customize_register', 'twentyfourteen_customize_register' ); +/** + * Sanitize the Featured Content layout value. + * + * @since Twenty Fourteen 1.0 + * + * @param string $layout Layout type. + * @return string Filtered layout type (grid|slider). + */ +function twentyfourteen_sanitize_layout( $layout ) { + if ( ! in_array( $layout, array( 'grid', 'slider' ) ) ) + $layout = 'grid'; + + return $layout; +} + /** * Bind JS handlers to make Theme Customizer preview reload changes asynchronously. *