-
-
Save joeyyax/898da5ee2c6c6e42aa7e to your computer and use it in GitHub Desktop.
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 | |
// | |
// Original | |
// | |
class Plugin_Class { | |
public function __construct() { | |
add_action( 'my_action', array( $this, 'action_method' ), 10 ); | |
} | |
public function action_method() { | |
echo "<p>I'm in a class!<p>"; | |
} | |
} | |
$pluginClass = new Plugin_Class(); | |
// output | |
do_action( 'my_action' ); | |
// | |
// Modified action | |
// | |
remove_action( 'my_action', array( $pluginClass, 'action_method' ), 10); // unload class action | |
// add new action | |
add_action( 'my_action', function() { | |
echo "<p>I'm the replacement!</p>"; | |
} ); | |
// output with modification | |
do_action( 'my_action' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment