dimanche 1 mars 2015

Object oriented programming, add_action in constructor not firing


I am trying to write a class that adds an action to the save_post hook, but the post_updated function never gets called. I tried some variations, but it never gets called. Am I doing something wrong?



class automatic_forwarder {
function __construct() {
add_action( 'save_post', array( $this, 'post_updated' ) );
}

function post_updated() {
echo "Working";
}
}




Aucun commentaire:

Enregistrer un commentaire