Advertisement
phpface

Filter the post content and allow only specific attributes as defined.

May 26th, 2023 (edited)
1,085
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.56 KB | None | 1 0
  1. /**
  2.  *
  3.  * Filter the post content and allow only specific attributes as defined.
  4.  *
  5.  * @param string $content
  6.  *
  7.  */
  8. add_filter( 'the_content', function( $content ){
  9.  
  10.     if( is_singular( 'video' ) && is_main_query() ){
  11.  
  12.         return wp_kses( $content, array(
  13.             'br'        =>  array(),
  14.             'em'        =>  array(),
  15.             'strong'    =>  array(),
  16.             'p'         =>  array(),
  17.             'img'       =>  array(
  18.                 'src'   =>  array(),
  19.                 'alt'   =>  array()
  20.             )
  21.         ) );
  22.  
  23.     }
  24.  
  25.     return $content;
  26. }, 10, 1 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement