“活动日历”;现代部落在Wordpress插件不工作


"The Events Calendar" plugin by Modern Tribe in Wordpress not working

我使用的是Modern Tribe的" the Events Calendar"插件。我在一个php文件的开头有以下代码,该文件是用ajax get语句加载的。

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);
                    }            
            );

返回成功状态,结果为"function does not exist"。在这一点上我很困惑。日历工作正常,通过wordpress管理界面接受条目,并正确显示。我一头雾水。

您正在直接调用文件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