修复了一些问题
This commit is contained in:
@@ -32,6 +32,7 @@
|
|||||||
!/tests/widget-system/asset-ledger-contract.test.cjs
|
!/tests/widget-system/asset-ledger-contract.test.cjs
|
||||||
!/tests/widget-system/financial-flow-contract.test.cjs
|
!/tests/widget-system/financial-flow-contract.test.cjs
|
||||||
!/tests/widget-system/pay-orders-filter-contract.test.cjs
|
!/tests/widget-system/pay-orders-filter-contract.test.cjs
|
||||||
|
!/tests/widget-system/front-submit-editor-contract.test.cjs
|
||||||
!/tests/asset-ledger/
|
!/tests/asset-ledger/
|
||||||
!/tests/asset-ledger/*.php
|
!/tests/asset-ledger/*.php
|
||||||
!/tests/visual/docker-compose.zibll.yml
|
!/tests/visual/docker-compose.zibll.yml
|
||||||
|
|||||||
@@ -39,6 +39,9 @@ if (!empty($_GET['edit']) && empty($ctx['edit_post'])) {
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// wp_editor() is rendered after get_header(); queue its runtime before wp_head.
|
||||||
|
wp_enqueue_editor();
|
||||||
|
|
||||||
// Assets.
|
// Assets.
|
||||||
$css = get_template_directory() . '/assets/css/frontend/pages/submit.css';
|
$css = get_template_directory() . '/assets/css/frontend/pages/submit.css';
|
||||||
if (file_exists($css)) {
|
if (file_exists($css)) {
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
const assert = require('node:assert/strict');
|
||||||
|
const fs = require('node:fs');
|
||||||
|
const path = require('node:path');
|
||||||
|
const test = require('node:test');
|
||||||
|
|
||||||
|
const root = path.resolve(__dirname, '..', '..');
|
||||||
|
const read = (file) => fs.readFileSync(path.join(root, file), 'utf8');
|
||||||
|
|
||||||
|
test('front submit enqueues the WordPress editor before wp_head is rendered', () => {
|
||||||
|
const source = read('templates/pages/page-submit.php');
|
||||||
|
const enqueueAt = source.indexOf('wp_enqueue_editor();');
|
||||||
|
const headerAt = source.indexOf('\nget_header();');
|
||||||
|
|
||||||
|
assert.notEqual(enqueueAt, -1, 'front submit must explicitly enqueue the editor runtime');
|
||||||
|
assert.notEqual(headerAt, -1, 'front submit must render the theme header');
|
||||||
|
assert.ok(enqueueAt < headerAt, 'editor assets must be queued before get_header()/wp_head');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('published post content reaches the front submit editor unchanged', () => {
|
||||||
|
const context = read('templates/parts/submit/context.php');
|
||||||
|
const editor = read('templates/parts/submit/editor-main.php');
|
||||||
|
|
||||||
|
assert.match(context, /\$current_content\s*=\s*\$edit_post\s*\?\s*\$edit_post->post_content\s*:\s*'';/);
|
||||||
|
assert.match(editor, /wp_editor\(\(string\) \$ctx\['current_content'\], 'post_content', \$editor_settings\);/);
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user