Advertisement
Guest User

Untitled

a guest
Apr 25th, 2019
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. // Add Shortcode
  2. function clean_html_shortcode( $atts , $content = null ) {
  3. global $allowedposttags;
  4.  
  5. if ( isset( $content, $allowedposttags ) && is_array( $allowedposttags ) ) {
  6. /**
  7. * Allowed attributes
  8. *
  9. * @var array
  10. */
  11. $allowed_html = array(
  12. 'a' => array( 'href' => true ),
  13. 'img' => array( 'src' => true ),
  14. );
  15. /**
  16. * Get all tags and define without any attributes
  17. */
  18. foreach ( $allowedposttags as $tag_name => $attrs ) {
  19. if ( ! isset( $allowed_html[ $tag_name ] ) ) {
  20. $allowed_html[ $tag_name ] = array();
  21. }
  22. }
  23. return wp_kses( $content, $allowed_html );
  24. }
  25. }
  26. add_shortcode( 'clean_html', 'clean_html_shortcode' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement