我创建了一个类实例,并在add_action
, 移动到创建实例的下方:
if ( ! function_exists(\'add_action\') ) {
header(\'Status: 403 Forbidden\');
header(\'HTTP/1.1 403 Forbidden\');
}
if ( ! class_exists(\'My_Authentication\') ) {
class My_Authentication {
public function setup() {
add_action(\'wp_login\', array(&$this, \'no_auth_allowed\') );
add_action(\'wp_logout\', array(&$this, \'no_auth_allowed\') );
}
public function no_auth_allowed() {
wp_die(\'no authentication for you!\');
}
}
$my_auth = new My_Authentication;
}
add_action(\'plugins_loaded\', array($my_auth, \'setup\') );