Advertisement
helgatheviki

Conditionally Change Textarea Sanitation in Options Framewor

Mar 21st, 2012
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.00 KB | None | 0 0
  1. /*
  2.  * Conditionally Change Textarea Sanitation in Options Framework Plugin
  3.  * essentially removes sanitization from textarea that was setup with id = "example_textarea"
  4.  * to be placed in your theme's functions.php
  5.  */
  6.  
  7. // @ remove the default sanitize filter and replace with our own
  8. //   the key turned out to be passing the second variable $option to the new filter
  9. add_action('init','kia_remove_sanitize_textarea');
  10.  
  11. function kia_remove_sanitize_textarea(){
  12.     remove_filter( 'of_sanitize_textarea', 'of_sanitize_textarea' );
  13.     add_filter( 'of_sanitize_textarea', 'kia_sanitize_textarea', 10, 2 );
  14. }
  15.  
  16. // @ new textarea sanitization filter
  17. function kia_sanitize_textarea($input, $option){
  18.  
  19.     // if this option is the one we want to allow all tags on, we return the input unchanged
  20.     if( $option['id'] == "example_textarea" ) {
  21.         // you sure you don't want to sanitize this?
  22.         $output = $input;
  23.     } else {
  24.         global $allowedposttags;
  25.         $output = wp_kses( $input, $allowedposttags);
  26.     }
  27.     return $output;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement