WP_Theme_JSON::remove_insecure_styles() WordPress Method

The WP_Theme_JSON::remove_insecure_styles() method is used to remove all insecure styles from a given theme. Insecure styles are those which can potentially be used to compromise the security of a WordPress site. This method should therefore be used with caution, and only when absolutely necessary.

WP_Theme_JSON::remove_insecure_styles( array $input ) #

Processes a style node and returns the same node without the insecure styles.


Parameters

$input

(array)(Required)Node to process.


Top ↑

Return

(array)


Top ↑

Source

File: wp-includes/class-wp-theme-json.php

	protected static function remove_insecure_styles( $input ) {
		$output       = array();
		$declarations = static::compute_style_properties( $input );

		foreach ( $declarations as $declaration ) {
			if ( static::is_safe_css_declaration( $declaration['name'], $declaration['value'] ) ) {
				$path = static::PROPERTIES_METADATA[ $declaration['name'] ];

				// Check the value isn't an array before adding so as to not
				// double up shorthand and longhand styles.
				$value = _wp_array_get( $input, $path, array() );
				if ( ! is_array( $value ) ) {
					_wp_array_set( $output, $path, $value );
				}
			}
		}
		return $output;
	}


Top ↑

Changelog

Changelog
VersionDescription
5.9.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.