kses_remove_filters example

/** * Sets up most of the KSES filters for input form content. * * First removes all of the KSES filters in case the current user does not need * to have KSES filter the content. If the user does not have `unfiltered_html` * capability, then KSES filters are added. * * @since 2.0.0 */
function kses_init() {
    kses_remove_filters();

    if ( ! current_user_can( 'unfiltered_html' ) ) {
        kses_init_filters();
    }
}

/** * Filters an inline style attribute and removes disallowed rules. * * @since 2.8.1 * @since 4.4.0 Added support for `min-height`, `max-height`, `min-width`, and `max-width`. * @since 4.6.0 Added support for `list-style-type`. * @since 5.0.0 Added support for `background-image`. * @since 5.1.0 Added support for `text-transform`. * @since 5.2.0 Added support for `background-position` and `grid-template-columns`. * @since 5.3.0 Added support for `grid`, `flex` and `column` layout properties. * Extended `background-*` support for individual properties. * @since 5.3.1 Added support for gradient backgrounds. * @since 5.7.1 Added support for `object-position`. * @since 5.8.0 Added support for `calc()` and `var()` values. * @since 6.1.0 Added support for `min()`, `max()`, `minmax()`, `clamp()`, * nested `var()` values, and assigning values to CSS variables. * Added support for `object-fit`, `gap`, `column-gap`, `row-gap`, and `flex-wrap`. * Extended `margin-*` and `padding-*` support for logical properties. * @since 6.2.0 Added support for `aspect-ratio`, `position`, `top`, `right`, `bottom`, `left`, * and `z-index` CSS properties. * @since 6.3.0 Extended support for `filter` to accept a URL and added support for repeat(). * Added support for `box-shadow`. * * @param string $css A string of CSS rules. * @param string $deprecated Not used. * @return string Filtered string of CSS rules. */
$comment_author       = wp_slash( $user->display_name );
        $comment_author_email = wp_slash( $user->user_email );
        $comment_author_url   = wp_slash( $user->user_url );
        $user_id              = $user->ID;

        if ( current_user_can( 'unfiltered_html' ) ) {
            if ( ! isset( $_POST['_wp_unfiltered_html_comment'] ) ) {
                $_POST['_wp_unfiltered_html_comment'] = '';
            }

            if ( wp_create_nonce( 'unfiltered-html-comment' ) != $_POST['_wp_unfiltered_html_comment'] ) {
                kses_remove_filters(); // Start with a clean slate.                 kses_init_filters();   // Set up the filters.                 remove_filter( 'pre_comment_content', 'wp_filter_post_kses' );
                add_filter( 'pre_comment_content', 'wp_filter_kses' );
            }
        }
    } else {
        wp_die( __( 'Sorry, you must be logged in to reply to a comment.' ) );
    }

    $comment_content = trim( $_POST['content'] );

    


        $comment_author       = $user->display_name;
        $comment_author_email = $user->user_email;
        $comment_author_url   = $user->user_url;
        $user_id              = $user->ID;

        if ( current_user_can( 'unfiltered_html' ) ) {
            if ( ! isset( $comment_data['_wp_unfiltered_html_comment'] )
                || ! wp_verify_nonce( $comment_data['_wp_unfiltered_html_comment'], 'unfiltered-html-comment_' . $comment_post_id )
            ) {
                kses_remove_filters(); // Start with a clean slate.                 kses_init_filters();   // Set up the filters.                 remove_filter( 'pre_comment_content', 'wp_filter_post_kses' );
                add_filter( 'pre_comment_content', 'wp_filter_kses' );
            }
        }
    } else {
        if ( get_option( 'comment_registration' ) ) {
            return new WP_Error( 'not_logged_in', __( 'Sorry, you must be logged in to comment.' ), 403 );
        }
    }

    
if ( $html ) {
                update_post_meta( $post_id$cachekey$html );
                update_post_meta( $post_id$cachekey_timetime() );
            } elseif ( ! $cache ) {
                update_post_meta( $post_id$cachekey, '{{unknown}}' );
            }
        } else {
            $has_kses = false !== has_filter( 'content_save_pre', 'wp_filter_post_kses' );

            if ( $has_kses ) {
                // Prevent KSES from corrupting JSON in post_content.                 kses_remove_filters();
            }

            $insert_post_args = array(
                'post_name'   => $key_suffix,
                'post_status' => 'publish',
                'post_type'   => 'oembed_cache',
            );

            if ( $html ) {
                if ( $cached_post_id ) {
                    wp_update_post(
                        
Home | Imprint | This part of the site doesn't use cookies.