Php 插件中未加载wp_排队_脚本
我有一个为WordPress制作的简单插件,我无法导入一个简单的测试javascript。我迷路了Php 插件中未加载wp_排队_脚本,php,wordpress,plugins,Php,Wordpress,Plugins,我有一个为WordPress制作的简单插件,我无法导入一个简单的测试javascript。我迷路了 defined( 'ABSPATH' ) or die( 'Hey, what are you doing here? Silly Human. Scripts are for grown ups'); if (!function_exists('add_action') ) { echo "Hey, you can\t access this file, you silly human
defined( 'ABSPATH' ) or die( 'Hey, what are you doing here? Silly Human. Scripts are for grown ups');
if (!function_exists('add_action') ) {
echo "Hey, you can\t access this file, you silly human.";
exit;
}
class SimplePlugin {
public function __construct($arg) {
add_action( 'wp_enqueue_scripts', array($this, 'test1') );
}
function activate() {
}
function deactivate() {
}
function uninstall() {
}
public function test1() {
wp_deregister_script('my-plugin');
wp_register_script( 'my-plugin', plugin_dir_url( __FILE__ ) . 'test.js' );
wp_enqueue_script( 'my-plugin');
}
}
if (class_exists( 'MySweetEddPlugin') ) {
$MySweetEddPlugin = new MySweetEddPlugin(''); //We now run all things in construct
}
//Activate
register_activation_hook(__FILE__, array($MySweetEddPlugin, 'activate'));
//Deactivate
register_activation_hook(__FILE__, array($MySweetEddPlugin, 'deactivate'));
类名在我的文件中更为唯一,在您建议之前,可能缺少/额外的斜杠。我试过有斜杠和没有斜杠,试过完全写出来,这是最精巧的东西。它将显示文件包含了不正确的url,但从未包含正确的url。如果我只是说
wp_register_script( 'my-plugin', '/test.js' );
它将包括该js文件(不存在的js文件)。但是,如果它是正确的,它将不包括它。好像它阻止我包含正确的文件?WordPress插件缺少什么吗 好的,我解决了。正是插件Fast Velocity Minify导致它不包含该文件。当我停用它时,文件立即出现。当我重新激活该文件时,该文件仍保留在那里,但是,在我停用并重新激活插件之前,我对该文件所做的任何更新都不会显示出来。一如往常,只要我在这里发帖,我就明白了 好的,我解决了。正是插件Fast Velocity Minify导致它不包含该文件。当我停用它时,文件立即出现。当我重新激活该文件时,该文件仍保留在那里,但是,在我停用并重新激活插件之前,我对该文件所做的任何更新都不会显示出来。一如往常,只要我在这里发帖,我就明白了