Created
May 5, 2015 04:36
Example of how to add and remove filters (or actions) within a YOURLS plugin class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Example of how to add and remove filters (or actions) within a plugin class | |
*/ | |
class Add_Remove_Filter { | |
function __construct() { | |
yourls_add_filter( 'ozh', array( $this, 'do_something' ) ); | |
} | |
function check(){ | |
var_dump( yourls_has_filter( 'ozh' ) ); | |
var_dump( yourls_has_filter( 'ozh', array( $this, 'do_something' ) ) ); | |
} | |
function remove() { | |
var_dump( yourls_remove_filter( 'ozh', array( $this, 'do_something' ) ) ); | |
} | |
function do_something( $value ) { | |
// do something | |
} | |
} | |
$ozh = new Add_Remove_Filter; | |
$ozh->check(); | |
// boolean true | |
// int 10 | |
$ozh->remove(); | |
// boolean true | |
$ozh->check(); | |
// boolean false | |
// boolean false | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment