i'm building mobile plugin wordpress , add possibility deactivate plugins non-mobile compatible.
i've found code has help'd isn't quite need.
debug_filter("/^woocommerce/i"); function debug_filter($regex_filter_action_to_match = "//"){ global $wp_filter; $hook=$wp_filter; ksort($hook); echo "<pre style='background-color:white;'>"; foreach($hook $tag => $priority){ //check regex match of hook name if ( !preg_match($regex_filter_action_to_match, $tag) ) continue; echo "<br /><strong>$tag</strong><br />"; ksort($priority); foreach($priority $priority => $function){ echo " $priority \n"; foreach($function $name => $properties) { echo "\t$name "; if ( function_exists($name) ){ $func = new reflectionfunction($name); $filename = $func->getfilename(); $start_line = $func->getstartline() - 1; // it's - 1, otherwise wont function() block $path_info = pathinfo($filename); print_r($func); echo "<em style='font-size:90%;opacity:0.5;' title='{$filename}'> {$path_info[filename]}.{$path_info[extension]}: line {$start_line}</em>"; } echo "<br />"; remove_filter( $tag, $name, $priority); //remove_action( 'init', array( 'jetpack_likes', 'action_init' ) ); } } } echo '</pre>'; return; }
has managed build or know of class deactivate plugins using remove_filter & remove_action.
thanks help.
- dave
this have come with. may not perfect seems work.
wp_remove_filter("/^woocommerce/i"); function wp_remove_filter($regex_filter_action_to_match = "//"){ global $wp_filter, $wp_actions ; $hook=$wp_filter; ksort($hook); echo "<pre style='background-color:white;'>"; foreach($hook $tag => $priority){ if ( !preg_match($regex_filter_action_to_match, $tag) ) continue; ksort($priority); foreach($priority $priority => $function){ foreach($function $name => $properties) { if ( function_exists($name) ){ $func = new reflectionfunction($name); $filename = $func->getfilename(); $start_line = $func->getstartline() - 1; // it's - 1, otherwise wont function() block $path_info = pathinfo($filename); if($priority ==""): remove_action( $tag, $name); else: remove_action( $tag, $name, $priority); endif; }else{ if($priority ==""): remove_filter( $tag, $name); else: remove_filter( $tag, $name, $priority); endif; } //remove_action( 'init', array( 'jetpack_likes', 'action_init' ) ); } } } echo '</pre>'; return; }
Comments
Post a Comment