2016-11-07 83 views
1

我使用现代部落的“活动日历”插件。我在用ajax get语句加载的php文件的开始处有以下代码。“活动日历”插件由现代部落在WordPress的不工作

if (!function_exists('tribe_create_event')) { 
    echo "function does not exist"; 
     return; 
} 

这是ajax调用。

jQuery.get("http://allthingsbahai.net/wp-content/themes/accelerate-child/insertdate.php", 
        {gregdate: gregdate, badidate: badidate}, 
        function(result, status) { 
         alert(status); 
         alert(result); 
         //alert(result.badidate); 
         //alert(result.gregdate); 
        }    
      ); 

它以成功状态返回,结果“功能不存在”。我对此感到困惑。日历工作正常,通过WordPress管理界面接受输入,并正确显示。 我很难过。

+0

tribe_create_event函数是否存在? – madalinivascu

+0

它是“事件日历”界面的一部分。 [链接到文档](https://theeventscalendar.com/plugin/the-events-calendar/page/2/) [链接到更多文档](https://theeventscalendar.com/function/tribe_create_event/) 该插件已安装并激活,所以我不知道它为什么不起作用。 –

+0

为什么不使用优先方式通过wp_ajax动作在wordpress中调用ajax? – madalinivascu

回答

0

您直接致电文件http://allthingsbahai.net/wp-content/themes/accelerate-child/insertdate.php。该文件可能无法加载其他文件。直接调用文件被WP和其他插件通过以下代码中止。

if (! defined('ABSPATH')) { 
    exit; 
} 

您必须通过使用操作来关注AJAX的WP方式,然后转到Codex以获取更多详细信息。 https://codex.wordpress.org/AJAX_in_Plugins

+0

通过函数和add_action解决了它('wp_ajax_insert_dates','insert_dates');和 add_action('wp_ajax_nopriv_insert_dates','insert_dates'); 如何让评论中的“代码”标签有效? –