admin管理员组文章数量:1302867
I created a plugin that uses ajax the problem is that the plugin requests are loaded on the whole site and not only on the plugin page I need to call the function only on the plugin page
plugin main code
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
define("Importer",plugin_basename(__FILE__));
define("PLUGIN_DIR",__DIR__);
require_once PLUGIN_DIR."/vendor/autoload.php";
if(is_admin()){
$moviewp = new \App\Bootstrap();
}
debug error every time I do something on the site using ajax
call_user_func_array() expects parameter 1 to be a valid callback, class 'App\Bootstrap' does not have a method 'process_moviewp_like' in C:\xampp\htdocs\clean\wp-includes\class-wp-hook.php on line 287
how do i exclude site ajax requests and separate them from the plugin?
I created a plugin that uses ajax the problem is that the plugin requests are loaded on the whole site and not only on the plugin page I need to call the function only on the plugin page
plugin main code
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
define("Importer",plugin_basename(__FILE__));
define("PLUGIN_DIR",__DIR__);
require_once PLUGIN_DIR."/vendor/autoload.php";
if(is_admin()){
$moviewp = new \App\Bootstrap();
}
debug error every time I do something on the site using ajax
call_user_func_array() expects parameter 1 to be a valid callback, class 'App\Bootstrap' does not have a method 'process_moviewp_like' in C:\xampp\htdocs\clean\wp-includes\class-wp-hook.php on line 287
how do i exclude site ajax requests and separate them from the plugin?
Share Improve this question asked Feb 18, 2021 at 16:42 Vincenzo PiromalliVincenzo Piromalli 1989 bronze badges1 Answer
Reset to default 1You can check for WordPress's DOING_AJAX
constant:
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
return;
}
...or use the related wp_doing_ajax()
function:
if ( wp_doing_ajax() ) {
return;
}
However, I'd also double-check to make sure that App\Bootstrap
has a method named process_moviewp_like
as well, because that error doesn't look like something that would be limited to AJAX.
本文标签: don39t call ajax if not plugin page
版权声明:本文标题:don't call ajax if not plugin page 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741740645a2395267.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论