WP_Customize_Custom_CSS_Setting::validate() – Validate a received value for being valid CSS.

You appear to be a bot. Output may be restricted

Description

Validate a received value for being valid CSS.

Checks for imbalanced braces, brackets, and comments. Notifications are rendered when the customizer state is saved.

Usage

$true|WP_Error = WP_Customize_Custom_CSS_Setting::validate( $value );

Parameters

$value
( string ) required – CSS to validate.

Returns

true|WP_Error True if the input was validated, otherwise WP_Error.

Source

File name: wordpress/wp-includes/customize/class-wp-customize-custom-css-setting.php


Lines:

1 to 16 of 16
  public function validate( $value ) {
    // Restores the more descriptive, specific name for use within this method.
    $css = $value;

    $validity = new WP_Error();

    if ( preg_match( '#</?\w+#', $css ) ) {
      $validity->add( 'illegal_markup', __( 'Markup is not allowed in CSS.' ) );
    }

    if ( ! $validity->has_errors() ) {
      $validity = parent::validate( $css );
    }
    return $validity;
  }
 

 View on GitHub View on Trac