只是好奇——AJAX操作是否可以连接到wp
钩子
例如:
add_action( \'wp\', array( \'MyAjaxRegistrarClass\', \'ajax_registrar\' ) );
// MyAjaxRegistrarClass
class MyAjaxRegistrarClass{
public static function ajax_registrar() {
MyAnotherClass::fn_register_ajax();
//Call fn_register_ajax of other classes here
}
}//Class Ends here
// MyAnotherClass
class MyAnotherClass {
public static function fn_register_ajax() {
add_action( \'wp_ajax_testing_ajax\', array(__CLASS__, \'testing_ajax\' ) );
}
public static function testing_ajax() {
echo \'Success!\'.__FUNCTION__.\' was called from \'.__CLASS__;
die();
}
}
有指针吗?当然,Ajax挂钩有很多选项。只是想知道这是否可以做到。