Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/267.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从php插件将普通JavaScript文件排队_Php_Wordpress - Fatal编程技术网

从php插件将普通JavaScript文件排队

从php插件将普通JavaScript文件排队,php,wordpress,Php,Wordpress,我尝试了以下操作,但它使系统崩溃 <?php wp_register_script( 'support', 'js/big-support.js', ); wp_enqueue_script( 'support' ); /* */ ?> 首先,在WordPress中开发时启用调试 // wp-config.php define( 'WP_DEBUG', true ); define( 'WP_DEBUG_DISPLAY', true); 这将帮助您找到错误的

我尝试了以下操作,但它使系统崩溃

<?php

    wp_register_script( 'support', 'js/big-support.js', );
    wp_enqueue_script( 'support' );

/* */
?>

首先,在WordPress中开发时启用调试

// wp-config.php
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_DISPLAY', true); 
这将帮助您找到错误的原因

可能这条线就是问题所在。旧版本的php不允许在函数调用中拖尾

wp_register_script( 'support', 'js/big-support.js', );
                                               // ^  remove comma
其次,注册脚本时应使用钩子,如下所示:

add_action('wp_enqueue_scripts', 'SO_53028038_register_scripts');
function SO_53028038_register_scripts(){
     wp_enqueue_script('support', get_stylesheet_directory_uri() . '/js/big-support.js';          
}