WordPress desactivate plugins on mobile

I’m building a mobile plugin for WordPress and I would like to add the possibility to deactivate plugins that are non-mobile compatible.

I’ve found some code that has help’d but isn’t quite what I need.

Read More
 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 as $tag => $priority){

  //check for a 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 as $priority => $function){
  echo " $priority n";
      foreach($function as $name => $properties) {


          echo "t$name  ";

            if ( function_exists($name) ){
                $func = new ReflectionFunction($name);
                $filename = $func->getFileName();
                $start_line = $func->getStartLine() - 1; // it's actually - 1, otherwise you wont get the 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 anyone managed to build or know of a Class that will deactivate plugins using remove_filter & remove_action.

Thanks for all your help.

  • Dave

Related posts

1 comment

  1. This is what I have come up with. It may not be perfect but it seems to 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 as $tag => $priority){
    
         if ( !preg_match($regex_filter_action_to_match, $tag) ) continue;
    
      ksort($priority);
      foreach($priority as $priority => $function){
    
          foreach($function as $name => $properties) {
    
                if ( function_exists($name) ){
                    $func = new ReflectionFunction($name);
                    $filename = $func->getFileName();
                    $start_line = $func->getStartLine() - 1; // it's actually - 1, otherwise you wont get the 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 are closed.