fix(runtime): use compatible WordPress jQuery

This commit is contained in:
2026-09-05 20:48:18 +08:00
parent d64c4cf1b4
commit 4a12de38cb
3 changed files with 9 additions and 9 deletions
+1 -3
View File
@@ -13,9 +13,7 @@ trait ScriptsPart1b {
$base_uri = get_template_directory_uri();
$version = AKSRT_VERSION;
// 本地运行时栈(与参考主题一致):jQuery 1.9.1 → Bootstrap → loader → main。
wp_deregister_script('jquery');
wp_register_script('jquery', $base_uri . '/assets/js/runtime/libs/jquery.min.js', [], '1.9.1', false);
// Keep WordPress's managed jQuery so core and plugin UI scripts share one compatible API.
wp_enqueue_script('jquery');
$public_filename = file_exists(get_template_directory() . '/assets/css/build/public.min.css')
? 'public.min.css'
@@ -37,16 +37,16 @@ const header = join([
'inc/helpers/aksrt-header-userbox.php',
]);
test('the public dependency graph is the single local runtime stack', () => {
assert.match(scripts, /wp_deregister_script\('jquery'\)/);
assert.match(scripts, /jquery\.min\.js'[\s\S]*?'1\.9\.1'/);
test('the public dependency graph uses WordPress jQuery with the local runtime stack', () => {
assert.match(scripts, /wp_enqueue_script\('jquery'\)/);
assert.doesNotMatch(scripts, /wp_deregister_script\('jquery'\)/);
assert.doesNotMatch(scripts, /jquery\.min\.js'[\s\S]*?'1\.9\.1'/);
assert.match(scripts, /bootstrap\.min\.css'[\s\S]*?'3\.4\.1'/);
assert.match(scripts, /fontawesome5'[\s\S]*?all\.min\.css'[\s\S]*?'5\.15\.4'/);
assert.match(scripts, /main\.min\.css/);
assert.match(scripts, /loader\.js'[\s\S]*?\['jquery', 'bootstrap'\]/);
assert.match(read('assets/js/runtime/loader.js'), /tbquire\(\['main'\]\)/);
for (const file of [
'assets/js/runtime/libs/jquery.min.js',
'assets/js/runtime/libs/bootstrap.min.js',
'assets/css/bootstrap.min.css',
'assets/fontawesome5/css/all.min.css',
@@ -40,10 +40,12 @@ test('published post content reaches the front submit editor unchanged', () => {
assert.match(editor, /wp_editor\(\(string\) \$ctx\['current_content'\], 'post_content', \$editor_settings\);/);
});
test('front submit uses the registered local jQuery runtime', () => {
test('front submit uses the WordPress-managed jQuery runtime', () => {
const source = read('src/Core/ScriptsPart1b.php');
assert.match(source, /wp_register_script\('jquery', \$base_uri \. '\/assets\/js\/runtime\/libs\/jquery\.min\.js', \[\], '1\.9\.1', false\)/);
assert.match(source, /wp_enqueue_script\('jquery'\)/);
assert.doesNotMatch(source, /wp_deregister_script\('jquery'\)/);
assert.doesNotMatch(source, /wp_register_script\('jquery'/);
assert.doesNotMatch(source, /jquery-migrate/);
const page = read('templates/pages/page-submit.php');