diff --git a/README.md b/README.md index 0bdf09f..574a08b 100644 --- a/README.md +++ b/README.md @@ -7,13 +7,13 @@ Add 2 PHP functions for WP Filter API, it's allow to remove filter/action on hoo ## Remove filters with method name only -`remove_filters_with_method_name( $hook_name = '', $method_name = '', $priority = 0 );` +`remove_filters_with_method_name( $hook_name = '', $method_name = '', $priority = 10 );` Allow to remove method for an hook when, it's a class method used and class don't have global for instanciation ! ## Remove filters with class and method name - `remove_filters_for_anonymous_class( $hook_name = '', $class_name ='', $method_name = '', $priority = 0 );` + `remove_filters_for_anonymous_class( $hook_name = '', $class_name ='', $method_name = '', $priority = 10 );` Allow to remove method for an hook when, it's a class method used and class don't have global for instanciation, but you know the class name :) @@ -25,7 +25,7 @@ Allow to remove method for an hook when, it's a class method used and class don' // First sample class MyClassA { function __construct() { - add_action( 'wp_footer', array( $this, 'my_action' ), 10 ); + add_action( 'wp_footer', array( $this, 'my_action' ) ); } function my_action() { print '

' . __class__ . ' - ' . __function__ . '

'; @@ -36,7 +36,7 @@ new MyClassA(); // Second sample class MyClassB { function __construct() { - add_action( 'wp_footer', array( $this, 'my_action' ), 10 ); + add_action( 'wp_footer', array( $this, 'my_action' ) ); } function my_action() { print '

' . __class__ . ' - ' . __function__ . '

'; @@ -55,7 +55,7 @@ The right way to load class is : `$my_class_b = new MyClassB();` This first method, `remove_filters_with_method_name();`, is fairly aggressive because it removes all filters that have the name "my_action", whatever the class. ```php -remove_filters_with_method_name( 'wp_footer', 'my_action', 10 ); +remove_filters_with_method_name( 'wp_footer', 'my_action' ); ``` This call will remove the 2 filters for classes MyClassA and MyClassB. @@ -65,11 +65,11 @@ This call will remove the 2 filters for classes MyClassA and MyClassB. The second method, `remove_filters_for_anonymous_class();`, is more accurate because it is necessary to specify both the name of the method but also the name of the PHP class. ```php -remove_filters_for_anonymous_class( 'wp_footer', 'MyClassB', my_action', 10 ); +remove_filters_for_anonymous_class( 'wp_footer', 'MyClassB', 'my_action' ); ``` This call will only remove the filter for the class MyClassB. ## Tips -The priority argument of the two functions is important, you must use the same priority as the hook you want to remove ! \ No newline at end of file +The priority argument of the two functions is important, you must use the same priority as the hook you want to remove ! diff --git a/wp-filters-extras.php b/wp-filters-extras.php index 60263b1..7361d12 100644 --- a/wp-filters-extras.php +++ b/wp-filters-extras.php @@ -26,7 +26,7 @@ /** * Allow to remove method for an hook when, it's a class method used and class don't have global for instanciation ! */ -function remove_filters_with_method_name( $hook_name = '', $method_name = '', $priority = 0 ) { +function remove_filters_with_method_name( $hook_name = '', $method_name = '', $priority = 10 ) { global $wp_filter; // Take only filters on right hook name and priority @@ -51,7 +51,7 @@ function remove_filters_with_method_name( $hook_name = '', $method_name = '', $p /** * Allow to remove method for an hook when, it's a class method used and class don't have variable, but you know the class name :) */ -function remove_filters_for_anonymous_class( $hook_name = '', $class_name ='', $method_name = '', $priority = 0 ) { +function remove_filters_for_anonymous_class( $hook_name = '', $class_name ='', $method_name = '', $priority = 10 ) { global $wp_filter; // Take only filters on right hook name and priority @@ -71,4 +71,4 @@ function remove_filters_for_anonymous_class( $hook_name = '', $class_name ='', $ } return false; -} \ No newline at end of file +}