Filter hook 'update_custom_css_data'

in WP Core File wp-includes/theme.php at line 2122

Description

Filters the `css` (`post_content`) and `preprocessed` (`post_content_filtered`) args for a `custom_css` post being updated. This filter can be used by plugin that offer CSS pre-processors, to store the original pre-processed CSS in `post_content_filtered` and then store processed CSS in `post_content`. When used in this way, the `post_content_filtered` should be supplied as the setting value instead of `post_content` via a the `customize_value_custom_css` filter, for example: add_filter( 'customize_value_custom_css', function( $value, $setting ) { $post = wp_get_custom_css_post( $setting->stylesheet ); if ( $post && ! empty( $post->post_content_filtered ) ) { $css = $post->post_content_filtered; } return $css; }, 10, 2 ); Normally empty string. } }

Occurrences

Filename Line Number
wp-includes/theme.php 2122

Parameters

Type Name Description
array $data { Custom CSS data.
array $args { The args passed into `wp_update_custom_css_post()` merged with defaults.

PHP Doc

/**
	 * Filters the `css` (`post_content`) and `preprocessed` (`post_content_filtered`) args
	 * for a `custom_css` post being updated.
	 *
	 * This filter can be used by plugin that offer CSS pre-processors, to store the original
	 * pre-processed CSS in `post_content_filtered` and then store processed CSS in `post_content`.
	 * When used in this way, the `post_content_filtered` should be supplied as the setting value
	 * instead of `post_content` via a the `customize_value_custom_css` filter, for example:
	 *
	 * 
	 * add_filter( 'customize_value_custom_css', function( $value, $setting ) {
	 *     $post = wp_get_custom_css_post( $setting->stylesheet );
	 *     if ( $post && ! empty( $post->post_content_filtered ) ) {
	 *         $css = $post->post_content_filtered;
	 *     }
	 *     return $css;
	 * }, 10, 2 );
	 * 
	 *
	 * @since 4.7.0
	 * @param array $data {
	 *     Custom CSS data.
	 *
	 *     @type string $css          CSS stored in `post_content`.
	 *     @type string $preprocessed Pre-processed CSS stored in `post_content_filtered`.
	 *                                Normally empty string.
	 * }
	 * @param array $args {
	 *     The args passed into `wp_update_custom_css_post()` merged with defaults.
	 *
	 *     @type string $css          The original CSS passed in to be updated.
	 *     @type string $preprocessed The original preprocessed CSS passed in to be updated.
	 *     @type string $stylesheet   The stylesheet (theme) being updated.
	 * }
	 */