WP_Theme_JSON::remove_insecure_settings( array $input ): array

In this article

Processes a setting node and returns the same node without the insecure settings.

Parameters

$inputarrayrequired
Node to process.

Return

array

Source

}

/**
 * Removes the preset values whose slug is equal to any of given slugs.
 *
 * @since 5.9.0
 *
 * @param array $node  The node with the presets to validate.
 * @param array $slugs The slugs that should not be overridden.
 * @return array The new node.
 */
protected static function filter_slugs( $node, $slugs ) {
	if ( empty( $slugs ) ) {
		return $node;
	}

	$new_node = array();
	foreach ( $node as $value ) {
		if ( isset( $value['slug'] ) && ! in_array( $value['slug'], $slugs, true ) ) {
			$new_node[] = $value;
		}
	}

	return $new_node;
}

/**
 * Removes insecure data from theme.json.
 *
 * @since 5.9.0
 * @since 6.3.2 Preserves global styles block variations when securing styles.
 *
 * @param array $theme_json Structure to sanitize.
 * @return array Sanitized structure.
 */
public static function remove_insecure_properties( $theme_json ) {
	$sanitized = array();

	$theme_json = WP_Theme_JSON_Schema::migrate( $theme_json );

	$valid_block_names   = array_keys( static::get_blocks_metadata() );
	$valid_element_names = array_keys( static::ELEMENTS );
	$valid_variations    = array();
	foreach ( self::get_blocks_metadata() as $block_name => $block_meta ) {
		if ( ! isset( $block_meta['styleVariations'] ) ) {
			continue;
		}
		$valid_variations[ $block_name ] = array_keys( $block_meta['styleVariations'] );
	}

	$theme_json = static::sanitize( $theme_json, $valid_block_names, $valid_element_names, $valid_variations );

Changelog

VersionDescription
5.9.0Introduced.

User Contributed Notes

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