safecss_filter_attr_allow_css
Filter HookDescription
Filters the check for unsafe CSS in `safecss_filter_attr`. Enables developers to determine whether a section of CSS should be allowed or discarded. By default, the value will be false if the part contains \ ( & } = or comments. Return true to allow the CSS part to be included in the output.Hook Information
File Location |
wp-includes/kses.php
View on GitHub
|
Hook Type | Filter |
Line Number | 2683 |
Hook Parameters
Type | Name | Description |
---|---|---|
bool
|
$allow_css
|
Whether the CSS in the test string is considered safe. |
string
|
$css_test_string
|
The CSS string to test. |
Usage Examples
Basic Usage
<?php
// Hook into safecss_filter_attr_allow_css
add_filter('safecss_filter_attr_allow_css', 'my_custom_filter', 10, 2);
function my_custom_filter($allow_css, $css_test_string) {
// Your custom filtering logic here
return $allow_css;
}
Source Code Context
wp-includes/kses.php:2683
- How this hook is used in WordPress core
<?php
2678 * @since 5.5.0
2679 *
2680 * @param bool $allow_css Whether the CSS in the test string is considered safe.
2681 * @param string $css_test_string The CSS string to test.
2682 */
2683 $allow_css = apply_filters( 'safecss_filter_attr_allow_css', $allow_css, $css_test_string );
2684
2685 // Only add the CSS part if it passes the regex check.
2686 if ( $allow_css ) {
2687 if ( '' !== $css ) {
2688 $css .= ';';
PHP Documentation
<?php
/**
* Filters the check for unsafe CSS in `safecss_filter_attr`.
*
* Enables developers to determine whether a section of CSS should be allowed or discarded.
* By default, the value will be false if the part contains \ ( & } = or comments.
* Return true to allow the CSS part to be included in the output.
*
* @since 5.5.0
*
* @param bool $allow_css Whether the CSS in the test string is considered safe.
* @param string $css_test_string The CSS string to test.
*/
Quick Info
- Hook Type: Filter
- Parameters: 2
- File: wp-includes/kses.php
Related Hooks
Related hooks will be displayed here in future updates.