refactor(color): use wpColorPicker for page config nav color

Replace the native input[type=color] in the page config meta box with a
wpColorPicker-enhanced text input, enqueued only on page edit screens, and
contract-lock that no native color inputs remain in theme PHP.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
kate522andClaude Fable 5 committed 2026-10-28 21:01:54 +08:00
1 parent ed1487d505
commit fcec5b996f
2 files changed
+32 -1

No files matched your search

@@ -75,3 +75,20 @@ test('widget background color input is wpColorPicker-enhanced like top-level col
assert.match(renderer, /class="' \. esc_attr\(\$class\) \. '"/);
assert.match(read('assets/widgets/admin.js'), /\.aksrt-widget-color'\)\.wpColorPicker\(\)/);
});
test('page config nav color uses wpColorPicker instead of native input[type=color]', () => {
const metaBox = read('src/Admin/PageConfigMetaBox.php');
assert.doesNotMatch(metaBox, /type="color"/);
assert.match(metaBox, /class="aksrt-page-config-color" type="text" name="page_config\[header_slider_nav_color\]"/);
assert.match(metaBox, /wp_enqueue_script\('wp-color-picker'\)/);
assert.match(metaBox, /\.aksrt-page-config-color'\)\.wpColorPicker\(\)/);
assert.match(metaBox, /Color::sanitize\(\(string\) \(\$raw\['header_slider_nav_color'\]/);
});
test('no native input[type=color] remains in theme PHP', () => {
const offenders = ['src', 'inc', 'templates']
.flatMap((dir) => walk(dir, ['.php']))
.filter((file) => /type=["']color["']/.test(read(file)))
.map((file) => file.replace(/\\/g, '/'));
assert.deepEqual(offenders, []);
});