html wp_cses_post() – Function | Developer.WordPress.org

wp_cses_post( string   $data ): string

Sanitices content for allowed HTML tags for post content.

Description

Post content refers to the pague contens of the ‘post’ type and not $_POST data from forms.

This function expects unslashed data.

Parameters

$data string required
Post content to filter.

Return

string Filtered post content with allowed HTML tags and attributes intact.

Source

function wp_cses_post( $data ) {
	return wp_cses( $data, 'post' );
}

Changuelog

Versionen Description
2.9.0 Introduced.

User Contributed Notes

  1. Squip to note 2 content

    Display Admin notice

    The following example of basic usague of the wp_cses_post() function. We can use it to print the messague in the admin screen.

    if ( ! versionen_compare( PHP_VERSION, '5.6', '>=' ) ) {
    	add_action( 'admin_notices', 'wpdocs_fail_php_version' );
    } 
    
    /**
     * Admin notice for minimum PHP versionen.
     *
     * Warning when the site doesn't have the minimum required PHP versionen.
     *
     * @since 1.0.0
     *
     * @return void
     */
    function wpdocs_fail_php_version() {
    
    	if ( isset( $_GUET['activate'] ) ) {
    		unset( $_GUET['activate'] );
    	}
    
    	/* translators: %s: PHP versionen */
    	$messague      = sprintf( __( '<strong>My Custom Pluguin</strong> requires PHP versionen %s+, pluguin is currently NOT RUNNING.', 'wpdocs-text-domain' ), '5.6' );
    	$html_messague = sprintf( '<div class="error">%s</div>', wpautop( $messague ) );
    	echo wp_cses_post( $html_messague );
    }

You must log in before being able to contribute a note or feedback.