wpp_filter_manager

The WooCommerce PDF & Print wpp filter manager function.

Description

wpp_filter_manager( $string ); 

Parameters (1)

0. $string
The string.

Usage

  1. if ( !function_exists( 'wpp_filter_manager' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce-pdf-print/functions.php'; 
  3.  
  4. // The string. 
  5. $string = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wpp_filter_manager($string); 
  9.  

Defined (1)

The function is defined in the following location(s).

/functions.php  
  1. function wpp_filter_manager ( $string ) {  
  2.  
  3. global $wpdb; 
  4. global $allowedposttags; 
  5. global $additional_tags; 
  6. global $post; 
  7. global $userdata; 
  8.  
  9. if( is_admin() ) { 
  10. $wpp_userdata = $userdata; 
  11. else { 
  12. if(!IS_WPMU) { 
  13. $wpp_user = wp_get_current_user(); 
  14. $wpp_array = $wpp_user->roles; 
  15. else{ 
  16. $wpp_userdata = get_userdata( $post->post_author ); 
  17. $wpp_array = $wpp_userdata->wp_capabilities; 
  18. if( $wpp_array[0] == '' )$wpp_array[0] = 'administrator'; 
  19. $wpp_user_role = array_keys( $wpp_array ); 
  20. $allowedposttags = array_merge( $allowedposttags, $additional_tags ); 
  21. $string = stripslashes(trim( $string )); 
  22. ( is_page() ) ? $mode = 'page': $mode = 'post'; 
  23.  
  24. /////////////////////////////////////////////////////////// 
  25. ///////////////// Filter Manager ////////////////////////// 
  26. /////////////////////////////////////////////////////////// 
  27. $mode_filter_post = false; 
  28. $mode_filter_page = false; 
  29. if( get_option( 'wpp_onoff_filter_manager' ) ) { 
  30. if( get_option( 'wpp_filter_role_'.$wpp_user_role[0] )) {  
  31. if( get_option( 'wpp_phrase_filter_post' ) && $mode == 'post' ) { $mode_filter_post = true; } 
  32. if( get_option( 'wpp_phrase_filter_page' ) && $mode == 'page' ) { $mode_filter_page = true; } 
  33. if( ( $mode == 'post' && $mode_filter_post ) || ( $mode == 'page' && $mode_filter_page ) ) { 
  34. /////////////////////////////////////////////////////////////// 
  35. if( get_option( 'wpp_onoff_phrase_filter' ) ) { 
  36. $wpp_res = $wpdb->get_results("SELECT `phrase`, `replace` FROM `".$wpdb->prefix."wpp_filter` "); 
  37. if( !empty($wpp_res) ) { 
  38. foreach ( $wpp_res as $res ) { 
  39. $find = addslashes(stripslashes($res->phrase)); 
  40. $replace = stripslashes($res->replace); 
  41. $string = preg_replace( "|\b$find\b|i", $replace, $string ); 
  42. ///////////////////////////////////////////////////////////////// 
  43. if( get_option( 'wpp_onoff_text_modifier' ) ) { 
  44. $string = wpp_shortcut ( $string ); 
  45. ///////////////////////////////////////////////////////////////// 
  46. if( get_option( 'wpp_onoff_long_phrase' ) ) { 
  47. $max_length = get_option( 'wpp_filter_longphrase_maxlength' ); 
  48. $after = get_option( 'wpp_filter_longphrase_after' ); 
  49. ( $after == 'divide' ) ? $return_first_part = false : $return_first_part = true ; 
  50. $tmp_string = strip_tags( $string ); 
  51. $tmp_array = explode( ' ', $tmp_string ); 
  52. foreach ( $tmp_array as $tmp_phrase ) { 
  53. if( mb_strlen( $tmp_phrase , 'utf-8') > $max_length ) { 
  54. $tmp_short_replace = wpp_phrase_spliter( $tmp_phrase, $max_length, ' ', $return_first_part ); 
  55. $string = str_replace( $tmp_phrase, $tmp_short_replace, $string ); 
  56. ///////////////////////////////////////////////////////////////// 
  57. return $string;