Wordpress Enqueuing Script返回500错误

时间:2017-03-29 22:09:08

标签: wordpress http-status-code-500

我正在我的文件functions.php中注册和排队脚本 我有一个白页和一个控制台错误500

add_action( 'ninja_forms_insert_sub', 'ninja_forms_coregistration', 4 );
function ninja_forms_coregistration($sub_id){
    global $ninja_forms_processing;
    if( isset($ninja_forms_processing) && $ninja_forms_processing->data  AND  @$ninja_forms_processing->data['form']['sub_id'] ){
        $form = $ninja_forms_processing->data['form'] ;

        if($ninja_forms_processing->data['form_ID'] == 3){
            wp_enqueue_script('reworldmedia-ninja-forms-allianz-scripts', get_template_directory_uri().'/assets/javascripts/ninja-forms-allianz.js');
        }
        coregistration_send( $form, $ninja_forms_processing );
    }
}

这是我的js文件内容:

jQuery(document).ready( function(){ 
    $(".ninja-forms-cont .ninja-forms-form").submit( function() {
        send_GA( "click-submit-form-allianz","submit","click sur allianz form" );
        return false;
    }); 
});

2 个答案:

答案 0 :(得分:0)

您需要先注册脚本,然后将其排队。

为此,请更改:

wp_enqueue_script('reworldmedia-ninja-forms-allianz-scripts', get_template_directory_uri().'/assets/javascripts/ninja-forms-allianz.js');

以下内容:

wp_register_script('reworldmedia-ninja-forms-allianz-scripts',      
get_template_directory_uri().'/assets/javascripts/ninja-forms-allianz.js');
wp_enqueue_style('reworldmedia-ninja-forms-allianz-scripts')

答案 1 :(得分:0)

您没有收到真正的错误消息。尝试在functions.php文件上启用调试。将其添加到funuctions.php页面的顶部。

<?php

// Turn off all error reporting
error_reporting(0);

// Report simple running errors
error_reporting(E_ERROR | E_WARNING | E_PARSE);

// Reporting E_NOTICE can be good too (to report uninitialized
// variables or catch variable name misspellings ...)
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);

// Report all errors except E_NOTICE
error_reporting(E_ALL & ~E_NOTICE);

// Report all PHP errors (see changelog)
error_reporting(E_ALL);

// Report all PHP errors
error_reporting(-1);

// Same as error_reporting(E_ALL);
ini_set('error_reporting', E_ALL);

?>