wp/wp-includes/customize/class-wp-customize-custom-css-setting.php
changeset 19 3d72ae0968f4
parent 18 be944660c56a
equal deleted inserted replaced
18:be944660c56a 19:3d72ae0968f4
   143 
   143 
   144 		return $value;
   144 		return $value;
   145 	}
   145 	}
   146 
   146 
   147 	/**
   147 	/**
   148 	 * Validate CSS.
   148 	 * Validate a received value for being valid CSS.
   149 	 *
   149 	 *
   150 	 * Checks for imbalanced braces, brackets, and comments.
   150 	 * Checks for imbalanced braces, brackets, and comments.
   151 	 * Notifications are rendered when the customizer state is saved.
   151 	 * Notifications are rendered when the customizer state is saved.
   152 	 *
   152 	 *
   153 	 * @since 4.7.0
   153 	 * @since 4.7.0
   154 	 * @since 4.9.0 Checking for balanced characters has been moved client-side via linting in code editor.
   154 	 * @since 4.9.0 Checking for balanced characters has been moved client-side via linting in code editor.
   155 	 *
   155 	 * @since 5.9.0 Renamed `$css` to `$value` for PHP 8 named parameter support.
   156 	 * @param string $css The input string.
   156 	 *
       
   157 	 * @param string $value CSS to validate.
   157 	 * @return true|WP_Error True if the input was validated, otherwise WP_Error.
   158 	 * @return true|WP_Error True if the input was validated, otherwise WP_Error.
   158 	 */
   159 	 */
   159 	public function validate( $css ) {
   160 	public function validate( $value ) {
       
   161 		// Restores the more descriptive, specific name for use within this method.
       
   162 		$css = $value;
       
   163 
   160 		$validity = new WP_Error();
   164 		$validity = new WP_Error();
   161 
   165 
   162 		if ( preg_match( '#</?\w+#', $css ) ) {
   166 		if ( preg_match( '#</?\w+#', $css ) ) {
   163 			$validity->add( 'illegal_markup', __( 'Markup is not allowed in CSS.' ) );
   167 			$validity->add( 'illegal_markup', __( 'Markup is not allowed in CSS.' ) );
   164 		}
   168 		}
   171 
   175 
   172 	/**
   176 	/**
   173 	 * Store the CSS setting value in the custom_css custom post type for the stylesheet.
   177 	 * Store the CSS setting value in the custom_css custom post type for the stylesheet.
   174 	 *
   178 	 *
   175 	 * @since 4.7.0
   179 	 * @since 4.7.0
   176 	 *
   180 	 * @since 5.9.0 Renamed `$css` to `$value` for PHP 8 named parameter support.
   177 	 * @param string $css The input value.
   181 	 *
       
   182 	 * @param string $value CSS to update.
   178 	 * @return int|false The post ID or false if the value could not be saved.
   183 	 * @return int|false The post ID or false if the value could not be saved.
   179 	 */
   184 	 */
   180 	public function update( $css ) {
   185 	public function update( $value ) {
       
   186 		// Restores the more descriptive, specific name for use within this method.
       
   187 		$css = $value;
       
   188 
   181 		if ( empty( $css ) ) {
   189 		if ( empty( $css ) ) {
   182 			$css = '';
   190 			$css = '';
   183 		}
   191 		}
   184 
   192 
   185 		$r = wp_update_custom_css_post(
   193 		$r = wp_update_custom_css_post(