WP_Theme_JSON::remove_insecure_styles( array $input ): array

In this article

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

Parameters

$inputarrayrequired
Node to process.

Return

array

Source

if ( isset( $input['css'] ) && current_user_can( 'edit_css' ) ) {
	$output = $input;
} else {
	$output = static::remove_insecure_styles( $input );
}

/*
 * Get a reference to element name from path.
 * $metadata['path'] = array( 'styles', 'elements', 'link' );
 */
$current_element = $metadata['path'][ count( $metadata['path'] ) - 1 ];

/*
 * $output is stripped of pseudo selectors. Re-add and process them
 * or insecure styles here.
 */
if ( isset( static::VALID_ELEMENT_PSEUDO_SELECTORS[ $current_element ] ) ) {
	foreach ( static::VALID_ELEMENT_PSEUDO_SELECTORS[ $current_element ] as $pseudo_selector ) {
		if ( isset( $input[ $pseudo_selector ] ) ) {
			$output[ $pseudo_selector ] = static::remove_insecure_styles( $input[ $pseudo_selector ] );
		}
	}
}

Changelog

VersionDescription
5.9.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.