update_custom_css_data
Filter HookDescription
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. } }
Hook Information
File Location |
wp-includes/theme.php
View on GitHub
|
Hook Type | Filter |
Line Number | 2122 |
Hook Parameters
Type | Name | Description |
---|---|---|
array
|
$data
|
{ Custom CSS data. |
array
|
$args
|
{ The args passed into `wp_update_custom_css_post()` merged with defaults. |
Usage Examples
Basic Usage
<?php
// Hook into update_custom_css_data
add_filter('update_custom_css_data', 'my_custom_filter', 10, 2);
function my_custom_filter($data, $args) {
// Your custom filtering logic here
return $data;
}
Source Code Context
wp-includes/theme.php:2122
- How this hook is used in WordPress core
<?php
2117 * @type string $css The original CSS passed in to be updated.
2118 * @type string $preprocessed The original preprocessed CSS passed in to be updated.
2119 * @type string $stylesheet The stylesheet (theme) being updated.
2120 * }
2121 */
2122 $data = apply_filters( 'update_custom_css_data', $data, array_merge( $args, compact( 'css' ) ) );
2123
2124 $post_data = array(
2125 'post_title' => $args['stylesheet'],
2126 'post_name' => sanitize_title( $args['stylesheet'] ),
2127 'post_type' => 'custom_css',
PHP Documentation
<?php
/**
* 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:
*
* <code>
* 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 );
* </code>
*
* @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.
* }
*/
Quick Info
- Hook Type: Filter
- Parameters: 2
- File: wp-includes/theme.php
Related Hooks
Related hooks will be displayed here in future updates.