Skip to content

Instantly share code, notes, and snippets.

@joeyyax joeyyax/remove_action.php Secret
Created Feb 4, 2015

Embed
What would you like to do?
<?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
You can’t perform that action at this time.