我的版本变量似乎没有在我的排队函数中应用(下面的代码片段)。
//version number
$version = \'1.0.0\';
function frontend_styles($version) {
wp_enqueue_style(
\'frontend_styles\', //reference
get_stylesheet_directory_uri() . \'/assets/css/app.min.css\', //source
array(), //dependenices
$version, //version number
\'all\' //media type (\'all\', \'screen\', \'handheld\', \'print\')
);
}
是否有方法设置可应用于所有样式的全局版本号?
编辑:下面是实际的源代码。
//version number
$version = \'1.0.0\';
//remove jquery scripts
function remove_jquery() {
wp_deregister_script(\'jquery\');
wp_deregister_script(\'jquery-core\');
wp_deregister_script(\'jquery-migrate\');
}
//remove embed scripts
function remove_embed() {
wp_deregister_script(\'wp-embed\');
}
//site styles
function frontend_styles() {
global $version;
wp_enqueue_style(
\'frontend_styles\', //reference
get_stylesheet_directory_uri() . \'/assets/css/app.min.css\', //source
array(), //dependenices
$version, //version number
\'all\' //media type (\'all\', \'screen\', \'handheld\', \'print\')
);
}
//admin_styles
function backend_styles() {
global $version;
wp_enqueue_style(
\'backend_styles\', //reference
get_stylesheet_directory_uri() . \'/assets/css/admin.min.css\', //source
array(), //dependenices
$version, //version number
\'all\' //media type (\'all\', \'screen\', \'handheld\', \'print\')
);
}
//site scripts
function frontend_scripts() {
global $version;
wp_enqueue_script(
\'frontend_scripts\', //reference
get_stylesheet_directory_uri() . \'/assets/js/app.min.js\', //source
array(), //dependencies
$version, //version number
true //load in footer
);
//pass sylsheet uri to javascript variable in app.js
$translation_array = array(
\'get_stylesheet_directory_uri\' => get_stylesheet_directory_uri() . \'/\',
\'home_url\' => home_url(\'/\')
);
wp_localize_script(\'frontend_scripts\', \'php\', $translation_array);
}
//admin scripts
function backend_scripts() {
global $version;
wp_enqueue_script(
\'backend_scripts\', //reference
get_stylesheet_directory_uri() . \'/assets/js/admin.min.js\', //source
array(), //dependencies
$version, //version number
true //load in footer
);
}