update_custom_css_data WordPress Filter Hook

The update_custom_css_data hook is used to update the Custom CSS data for a particular Wordpress site. This hook is triggered when the Custom CSS data is updated in the Wordpress admin panel.

apply_filters( 'update_custom_css_data', array $data, array $args ) #

Filters the css (post_content) and preprocessed (post_content_filtered) args for a custom_css post being updated.


Description

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 );

Top ↑

Parameters

$data

(array)Custom CSS data.

  • 'css'
    (string) CSS stored in post_content.
  • 'preprocessed'
    (string) Pre-processed CSS stored in post_content_filtered. Normally empty string.

$args

(array)The args passed into wp_update_custom_css_post() merged with defaults.

  • 'css'
    (string) The original CSS passed in to be updated.
  • 'preprocessed'
    (string) The original preprocessed CSS passed in to be updated.
  • 'stylesheet'
    (string) The stylesheet (theme) being updated.


Top ↑

Source

File: wp-includes/theme.php

View on Trac



Top ↑

Changelog

Changelog
VersionDescription
4.7.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.

Show More