如果你想挂接多个动作,你必须调用add_action
多次。然而,这并不难。让我们以您的插件类为例:
class WPSE6526_getStatic // Always prefix your plugin with something unique, like your name. Here I used the question number
{
var $_renderTasksOn = array( \'wp_insert_post\', \'wp_insert_comment\', ... );
function WPSE6526_getStatic()
{
// The constructor of this class, which will hook up everything
// This is the \'trick\' to this question: a loop on your list and `add_action` for each item
foreach ( $this->_renderTasksOn as $hookname ) {
add_action( $hookname, array( &$this, \'getStatic\' ) );
}
}
function getStatic()
{
// Your code
}
}
add_action( \'plugins_loaded\', \'wpse6526_getStatic_init\' );
function wpse6526_getStatic_init()
{
$GLOBALS[\'wpse6526_getStatic_instance\'] = new WPSE6526_getStatic();
}