refactor: drop the featured-project picker in favour of the project list
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
12 files changed
+6
-362
No files matched your search
@@ -541,40 +541,6 @@ footer a {
|
|||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.chrnx-selected-work__list {
|
|
||||||
display: grid;
|
|
||||||
gap: 0;
|
|
||||||
grid-template-columns: 1fr;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
border-top: 1px solid var(--chrnx-line);
|
|
||||||
list-style: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.chrnx-selected-work__item {
|
|
||||||
padding-block: 1.25rem;
|
|
||||||
border-bottom: 1px solid var(--chrnx-line);
|
|
||||||
}
|
|
||||||
|
|
||||||
.chrnx-selected-work__title {
|
|
||||||
margin: 0;
|
|
||||||
overflow-wrap: anywhere;
|
|
||||||
}
|
|
||||||
|
|
||||||
.chrnx-selected-work__title a {
|
|
||||||
color: inherit;
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.chrnx-selected-work__title a:hover {
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
|
||||||
|
|
||||||
.chrnx-selected-work__empty {
|
|
||||||
margin: 0;
|
|
||||||
color: var(--chrnx-muted);
|
|
||||||
}
|
|
||||||
|
|
||||||
.chrnx-responsive-portrait {
|
.chrnx-responsive-portrait {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,111 +0,0 @@
|
|||||||
( function ( factory ) {
|
|
||||||
if ( typeof module === 'object' && module.exports ) {
|
|
||||||
module.exports = factory();
|
|
||||||
} else {
|
|
||||||
factory().initialize( window.wp );
|
|
||||||
}
|
|
||||||
} )( function () {
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
function getTranslator( wp ) {
|
|
||||||
return wp.i18n && typeof wp.i18n.__ === 'function'
|
|
||||||
? wp.i18n.__
|
|
||||||
: function ( text ) {
|
|
||||||
return text;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateMeta( editPost, currentMeta, key, value ) {
|
|
||||||
if ( typeof editPost !== 'function' ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
editPost( { meta: { ...( currentMeta || {} ), [ key ]: value } } );
|
|
||||||
}
|
|
||||||
|
|
||||||
function hasRequiredGlobals( wp ) {
|
|
||||||
return Boolean(
|
|
||||||
wp &&
|
|
||||||
wp.components &&
|
|
||||||
wp.components.ToggleControl &&
|
|
||||||
wp.data &&
|
|
||||||
typeof wp.data.useDispatch === 'function' &&
|
|
||||||
typeof wp.data.useSelect === 'function' &&
|
|
||||||
wp.editPost &&
|
|
||||||
wp.editPost.PluginDocumentSettingPanel &&
|
|
||||||
wp.element &&
|
|
||||||
typeof wp.element.createElement === 'function' &&
|
|
||||||
wp.plugins &&
|
|
||||||
typeof wp.plugins.registerPlugin === 'function',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function initialize( wp ) {
|
|
||||||
if ( ! hasRequiredGlobals( wp ) ) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const __ = getTranslator( wp );
|
|
||||||
|
|
||||||
function ProjectPanel() {
|
|
||||||
const editorState = wp.data.useSelect( function ( select ) {
|
|
||||||
if ( typeof select !== 'function' ) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const currentEditor = select( 'core/editor' );
|
|
||||||
const core = select( 'core' );
|
|
||||||
if (
|
|
||||||
! currentEditor ||
|
|
||||||
typeof currentEditor.getCurrentPostType !== 'function' ||
|
|
||||||
typeof currentEditor.getEditedPostAttribute !== 'function' ||
|
|
||||||
! core ||
|
|
||||||
typeof core.getEntityRecord !== 'function'
|
|
||||||
) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const topicIds = currentEditor.getEditedPostAttribute( 'topic' );
|
|
||||||
return {
|
|
||||||
meta: currentEditor.getEditedPostAttribute( 'meta' ) || {},
|
|
||||||
postType: currentEditor.getCurrentPostType(),
|
|
||||||
topic:
|
|
||||||
Array.isArray( topicIds ) && topicIds.length === 1
|
|
||||||
? core.getEntityRecord( 'taxonomy', 'chrnx_topic', topicIds[ 0 ] )
|
|
||||||
: null,
|
|
||||||
};
|
|
||||||
}, [] );
|
|
||||||
const editorDispatch = wp.data.useDispatch( 'core/editor' );
|
|
||||||
if ( ! editorState || editorState.postType !== 'post' || ! editorDispatch?.editPost ) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ! editorState.topic || editorState.topic.slug !== 'projects' ) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const meta = editorState.meta;
|
|
||||||
|
|
||||||
return wp.element.createElement(
|
|
||||||
wp.editPost.PluginDocumentSettingPanel,
|
|
||||||
{ name: 'chrnx-project', title: __( 'Project', 'chrnx' ) },
|
|
||||||
wp.element.createElement( wp.components.ToggleControl, {
|
|
||||||
label: __( 'Show in Selected work', 'chrnx' ),
|
|
||||||
help: __(
|
|
||||||
'Selected work lists these first, then fills the rest with the most recent projects.',
|
|
||||||
'chrnx',
|
|
||||||
),
|
|
||||||
checked: Boolean( meta.chrnx_project_featured ),
|
|
||||||
onChange( value ) {
|
|
||||||
updateMeta( editorDispatch.editPost, meta, 'chrnx_project_featured', Boolean( value ) );
|
|
||||||
},
|
|
||||||
} ),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
wp.plugins.registerPlugin( 'chrnx-project-meta', { render: ProjectPanel } );
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return { initialize, updateMeta };
|
|
||||||
} );
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
{
|
|
||||||
"$schema": "https://schemas.wp.org/trunk/block.json",
|
|
||||||
"apiVersion": 3,
|
|
||||||
"name": "chrnx/selected-work",
|
|
||||||
"version": "0.4.4",
|
|
||||||
"title": "Selected Work",
|
|
||||||
"category": "theme",
|
|
||||||
"description": "Hand-picked projects first, then the most recent ones.",
|
|
||||||
"textdomain": "chrnx",
|
|
||||||
"attributes": {
|
|
||||||
"limit": { "type": "integer", "default": 3, "minimum": 1, "maximum": 12 },
|
|
||||||
"headingLevel": { "type": "integer", "default": 3, "enum": [2, 3, 4, 5, 6] }
|
|
||||||
},
|
|
||||||
"supports": { "html": false },
|
|
||||||
"render": "file:./render.php"
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Selected Work block render.
|
|
||||||
*
|
|
||||||
* @package CHRNX
|
|
||||||
*/
|
|
||||||
|
|
||||||
$chrnx_limit = isset( $attributes['limit'] ) ? min( 12, max( 1, absint( $attributes['limit'] ) ) ) : 3;
|
|
||||||
$chrnx_heading = chrnx_get_heading_level( $attributes['headingLevel'] ?? 3, 3 );
|
|
||||||
$chrnx_ids = chrnx_get_selected_project_ids( $chrnx_limit );
|
|
||||||
?>
|
|
||||||
<div <?php echo get_block_wrapper_attributes( array( 'class' => 'chrnx-selected-work' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>>
|
|
||||||
<?php if ( empty( $chrnx_ids ) ) : ?>
|
|
||||||
<p class="chrnx-selected-work__empty"><?php echo esc_html__( 'No projects published yet.', 'chrnx' ); ?></p>
|
|
||||||
<?php else : ?>
|
|
||||||
<ul class="chrnx-selected-work__list">
|
|
||||||
<?php foreach ( $chrnx_ids as $chrnx_project_id ) : ?>
|
|
||||||
<li class="chrnx-selected-work__item">
|
|
||||||
<h<?php echo esc_attr( $chrnx_heading ); ?> class="chrnx-selected-work__title">
|
|
||||||
<a href="<?php echo esc_url( get_permalink( $chrnx_project_id ) ); ?>"><?php echo esc_html( get_the_title( $chrnx_project_id ) ); ?></a>
|
|
||||||
</h<?php echo esc_attr( $chrnx_heading ); ?>>
|
|
||||||
</li>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</ul>
|
|
||||||
<?php endif; ?>
|
|
||||||
</div>
|
|
||||||
+1
-1
@@ -232,7 +232,7 @@ function chrnx_get_editorial_card_markup( $post_id, $heading_level = 3, $class_n
|
|||||||
|
|
||||||
/** Register all block metadata directories that exist. */
|
/** Register all block metadata directories that exist. */
|
||||||
function chrnx_register_editorial_blocks() {
|
function chrnx_register_editorial_blocks() {
|
||||||
$blocks = array( 'featured-stories', 'journal-stream', 'latest-podcast', 'podcast-meta', 'topic-hero', 'related-posts', 'subscribe-cta', 'theme-toggle', 'site-brand', 'mobile-menu-toggle', 'footer-content', 'header-tools', 'reading-time', 'journal-link', 'selected-work', 'release-list', 'release-detail', 'track-meta', 'subscribe-form', 'show-links', 'project-list', 'project-detail' );
|
$blocks = array( 'featured-stories', 'journal-stream', 'latest-podcast', 'podcast-meta', 'topic-hero', 'related-posts', 'subscribe-cta', 'theme-toggle', 'site-brand', 'mobile-menu-toggle', 'footer-content', 'header-tools', 'reading-time', 'journal-link', 'release-list', 'release-detail', 'track-meta', 'subscribe-form', 'show-links', 'project-list', 'project-detail' );
|
||||||
foreach ( $blocks as $block ) {
|
foreach ( $blocks as $block ) {
|
||||||
$name = 'chrnx/' . $block;
|
$name = 'chrnx/' . $block;
|
||||||
if ( WP_Block_Type_Registry::get_instance()->is_registered( $name ) ) {
|
if ( WP_Block_Type_Registry::get_instance()->is_registered( $name ) ) {
|
||||||
|
|||||||
@@ -45,14 +45,6 @@ function chrnx_enqueue_editor_assets() {
|
|||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
wp_enqueue_script(
|
|
||||||
'chrnx-editor-project',
|
|
||||||
get_theme_file_uri( 'assets/js/editor-project.js' ),
|
|
||||||
array( 'wp-components', 'wp-core-data', 'wp-data', 'wp-edit-post', 'wp-element', 'wp-i18n', 'wp-plugins' ),
|
|
||||||
CHRNX_VERSION,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
|
|
||||||
wp_enqueue_script(
|
wp_enqueue_script(
|
||||||
'chrnx-editor-track',
|
'chrnx-editor-track',
|
||||||
get_theme_file_uri( 'assets/js/editor-track.js' ),
|
get_theme_file_uri( 'assets/js/editor-track.js' ),
|
||||||
@@ -63,7 +55,6 @@ function chrnx_enqueue_editor_assets() {
|
|||||||
|
|
||||||
wp_set_script_translations( 'chrnx-editor-taxonomies', 'chrnx', get_theme_file_path( 'languages' ) );
|
wp_set_script_translations( 'chrnx-editor-taxonomies', 'chrnx', get_theme_file_path( 'languages' ) );
|
||||||
wp_set_script_translations( 'chrnx-editor-podcast', 'chrnx', get_theme_file_path( 'languages' ) );
|
wp_set_script_translations( 'chrnx-editor-podcast', 'chrnx', get_theme_file_path( 'languages' ) );
|
||||||
wp_set_script_translations( 'chrnx-editor-project', 'chrnx', get_theme_file_path( 'languages' ) );
|
|
||||||
wp_set_script_translations( 'chrnx-editor-track', 'chrnx', get_theme_file_path( 'languages' ) );
|
wp_set_script_translations( 'chrnx-editor-track', 'chrnx', get_theme_file_path( 'languages' ) );
|
||||||
}
|
}
|
||||||
add_action( 'enqueue_block_editor_assets', 'chrnx_enqueue_editor_assets' );
|
add_action( 'enqueue_block_editor_assets', 'chrnx_enqueue_editor_assets' );
|
||||||
@@ -262,59 +262,6 @@ function chrnx_get_featured_story_ids( int $limit = 3 ): array {
|
|||||||
return $selected;
|
return $selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Select projects for the Selected work stage: hand-picked first, then recent.
|
|
||||||
*
|
|
||||||
* Sticky already belongs to the home featured stories, so the editorial choice
|
|
||||||
* lives in its own per-post flag instead of competing for the same signal.
|
|
||||||
*
|
|
||||||
* @param int $limit Maximum projects, bounded to 12.
|
|
||||||
* @return int[] Selected project post IDs.
|
|
||||||
*/
|
|
||||||
function chrnx_get_selected_project_ids( int $limit = 3 ): array {
|
|
||||||
$limit = min( 12, max( 0, $limit ) );
|
|
||||||
if ( 0 === $limit ) {
|
|
||||||
return array();
|
|
||||||
}
|
|
||||||
|
|
||||||
$topic_query = array(
|
|
||||||
array(
|
|
||||||
'taxonomy' => 'chrnx_topic',
|
|
||||||
'field' => 'slug',
|
|
||||||
'terms' => 'projects',
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
$selected = chrnx_get_eligible_editorial_post_ids(
|
|
||||||
array(
|
|
||||||
'posts_per_page' => $limit,
|
|
||||||
'tax_query' => $topic_query,
|
|
||||||
'meta_query' => array(
|
|
||||||
array(
|
|
||||||
'key' => 'chrnx_project_featured',
|
|
||||||
'value' => '1',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
$remaining = $limit - count( $selected );
|
|
||||||
if ( $remaining > 0 ) {
|
|
||||||
$selected = array_merge(
|
|
||||||
$selected,
|
|
||||||
chrnx_get_eligible_editorial_post_ids(
|
|
||||||
array(
|
|
||||||
'posts_per_page' => $remaining,
|
|
||||||
'post__not_in' => $selected,
|
|
||||||
'tax_query' => $topic_query,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $selected;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate a request taxonomy slug against an existing editorial term.
|
* Validate a request taxonomy slug against an existing editorial term.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -140,12 +140,9 @@ foreach ( $chrnx_seed_posts as $chrnx_seed_index => $chrnx_seed_post ) {
|
|||||||
wp_set_object_terms( $chrnx_seed_post_id, array(), 'chrnx_release', false );
|
wp_set_object_terms( $chrnx_seed_post_id, array(), 'chrnx_release', false );
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ( array( 'chrnx_episode_number', 'chrnx_episode_duration', 'canonical_episode_url', 'chrnx_project_featured' ) as $chrnx_seed_meta_key ) {
|
foreach ( array( 'chrnx_episode_number', 'chrnx_episode_duration', 'canonical_episode_url' ) as $chrnx_seed_meta_key ) {
|
||||||
delete_post_meta( $chrnx_seed_post_id, $chrnx_seed_meta_key );
|
delete_post_meta( $chrnx_seed_post_id, $chrnx_seed_meta_key );
|
||||||
}
|
}
|
||||||
if ( ! empty( $chrnx_seed_post['projectFeatured'] ) ) {
|
|
||||||
update_post_meta( $chrnx_seed_post_id, 'chrnx_project_featured', true );
|
|
||||||
}
|
|
||||||
delete_post_meta( $chrnx_seed_post_id, 'chrnx_track_number' );
|
delete_post_meta( $chrnx_seed_post_id, 'chrnx_track_number' );
|
||||||
if ( isset( $chrnx_seed_post['trackNumber'] ) ) {
|
if ( isset( $chrnx_seed_post['trackNumber'] ) ) {
|
||||||
update_post_meta( $chrnx_seed_post_id, 'chrnx_track_number', absint( $chrnx_seed_post['trackNumber'] ) );
|
update_post_meta( $chrnx_seed_post_id, 'chrnx_track_number', absint( $chrnx_seed_post['trackNumber'] ) );
|
||||||
|
|||||||
@@ -557,7 +557,7 @@ const immutableSurfaces = [
|
|||||||
'alter-ego-research-768.webp',
|
'alter-ego-research-768.webp',
|
||||||
'alter-ego-code-768.webp',
|
'alter-ego-code-768.webp',
|
||||||
],
|
],
|
||||||
// Project names come from chrnx/selected-work: picked projects newest-first,
|
// Project names come from the project list query: picked projects newest-first,
|
||||||
// then the most recent ones. This is the seeded order, not a frozen string.
|
// then the most recent ones. This is the seeded order, not a frozen string.
|
||||||
headings: [ 'Selected work', 'Ailed', 'Expressive Tea', 'Published research' ],
|
headings: [ 'Selected work', 'Ailed', 'Expressive Tea', 'Published research' ],
|
||||||
paragraphs: [],
|
paragraphs: [],
|
||||||
|
|||||||
@@ -1,102 +0,0 @@
|
|||||||
const modulePath = '../../assets/js/editor-project.js';
|
|
||||||
|
|
||||||
function flatten( node ) {
|
|
||||||
if ( ! node || typeof node !== 'object' ) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
return [ node ].concat( ( node.children || [] ).flatMap( flatten ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
function createWp( topicSlug = 'projects', meta = { unrelated: 'keep' } ) {
|
|
||||||
const editPost = jest.fn();
|
|
||||||
const registerPlugin = jest.fn();
|
|
||||||
const state = { meta, topic: [ 12 ] };
|
|
||||||
const wp = {
|
|
||||||
components: { ToggleControl: 'ToggleControl' },
|
|
||||||
i18n: { __: jest.fn( ( text ) => text ) },
|
|
||||||
data: {
|
|
||||||
select: ( store ) => {
|
|
||||||
if ( store === 'core/editor' ) {
|
|
||||||
return {
|
|
||||||
getCurrentPostType: () => 'post',
|
|
||||||
getEditedPostAttribute: ( key ) => state[ key ],
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
getEntityRecord: () => ( topicSlug ? { id: 12, slug: topicSlug } : undefined ),
|
|
||||||
};
|
|
||||||
},
|
|
||||||
dispatch: () => ( { editPost } ),
|
|
||||||
useDispatch: ( store ) => wp.data.dispatch( store ),
|
|
||||||
useSelect: ( mapper ) => mapper( wp.data.select ),
|
|
||||||
},
|
|
||||||
editPost: { PluginDocumentSettingPanel: 'PluginDocumentSettingPanel' },
|
|
||||||
element: {
|
|
||||||
createElement: ( type, props, ...children ) => ( { type, props: props || {}, children } ),
|
|
||||||
},
|
|
||||||
plugins: { registerPlugin },
|
|
||||||
};
|
|
||||||
return { wp, editPost, registerPlugin };
|
|
||||||
}
|
|
||||||
|
|
||||||
function renderPanel( context ) {
|
|
||||||
const { initialize } = require( modulePath );
|
|
||||||
expect( initialize( context.wp ) ).toBe( true );
|
|
||||||
const [ , plugin ] = context.registerPlugin.mock.calls[ 0 ];
|
|
||||||
return plugin.render();
|
|
||||||
}
|
|
||||||
|
|
||||||
describe( 'project editor panel', () => {
|
|
||||||
beforeEach( () => {
|
|
||||||
jest.resetModules();
|
|
||||||
} );
|
|
||||||
|
|
||||||
test( 'refuses to initialize without the required editor globals', () => {
|
|
||||||
const { initialize } = require( modulePath );
|
|
||||||
expect( initialize( undefined ) ).toBe( false );
|
|
||||||
expect( initialize( {} ) ).toBe( false );
|
|
||||||
} );
|
|
||||||
|
|
||||||
test( 'renders the Selected work toggle only for the projects topic', () => {
|
|
||||||
const context = createWp( 'projects' );
|
|
||||||
const toggles = flatten( renderPanel( context ) ).filter(
|
|
||||||
( node ) => node.type === 'ToggleControl',
|
|
||||||
);
|
|
||||||
expect( toggles ).toHaveLength( 1 );
|
|
||||||
expect( toggles[ 0 ].props.checked ).toBe( false );
|
|
||||||
} );
|
|
||||||
|
|
||||||
test.each( [ 'podcasts', 'code', null ] )( 'renders nothing for the %s topic', ( slug ) => {
|
|
||||||
expect( renderPanel( createWp( slug ) ) ).toBeNull();
|
|
||||||
} );
|
|
||||||
|
|
||||||
test( 'reflects an existing flag and preserves unrelated meta when toggling', () => {
|
|
||||||
const context = createWp( 'projects', { unrelated: 'keep', chrnx_project_featured: true } );
|
|
||||||
const toggle = flatten( renderPanel( context ) ).find(
|
|
||||||
( node ) => node.type === 'ToggleControl',
|
|
||||||
);
|
|
||||||
expect( toggle.props.checked ).toBe( true );
|
|
||||||
|
|
||||||
toggle.props.onChange( false );
|
|
||||||
expect( context.editPost ).toHaveBeenCalledWith( {
|
|
||||||
meta: { unrelated: 'keep', chrnx_project_featured: false },
|
|
||||||
} );
|
|
||||||
} );
|
|
||||||
|
|
||||||
test( 'coerces the toggle value to a boolean', () => {
|
|
||||||
const context = createWp( 'projects' );
|
|
||||||
const toggle = flatten( renderPanel( context ) ).find(
|
|
||||||
( node ) => node.type === 'ToggleControl',
|
|
||||||
);
|
|
||||||
|
|
||||||
toggle.props.onChange( 'yes' );
|
|
||||||
expect( context.editPost ).toHaveBeenCalledWith( {
|
|
||||||
meta: { unrelated: 'keep', chrnx_project_featured: true },
|
|
||||||
} );
|
|
||||||
} );
|
|
||||||
|
|
||||||
test( 'updateMeta ignores a missing dispatcher', () => {
|
|
||||||
const { updateMeta } = require( modulePath );
|
|
||||||
expect( () => updateMeta( undefined, {}, 'chrnx_project_featured', true ) ).not.toThrow();
|
|
||||||
} );
|
|
||||||
} );
|
|
||||||
@@ -45,7 +45,7 @@ class EditorAssetsTest extends WP_UnitTestCase {
|
|||||||
* Clear only the CHRNX editor script state.
|
* Clear only the CHRNX editor script state.
|
||||||
*/
|
*/
|
||||||
private function reset_editor_scripts() {
|
private function reset_editor_scripts() {
|
||||||
foreach ( array( 'chrnx-editor-taxonomies', 'chrnx-editor-podcast', 'chrnx-editor-project', 'chrnx-editor-track' ) as $handle ) {
|
foreach ( array( 'chrnx-editor-taxonomies', 'chrnx-editor-podcast', 'chrnx-editor-track' ) as $handle ) {
|
||||||
wp_dequeue_script( $handle );
|
wp_dequeue_script( $handle );
|
||||||
wp_deregister_script( $handle );
|
wp_deregister_script( $handle );
|
||||||
}
|
}
|
||||||
@@ -83,14 +83,13 @@ class EditorAssetsTest extends WP_UnitTestCase {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertSame( array( 'chrnx-editor-taxonomies', 'chrnx-editor-podcast', 'chrnx-editor-project', 'chrnx-editor-track' ), $handles );
|
$this->assertSame( array( 'chrnx-editor-taxonomies', 'chrnx-editor-podcast', 'chrnx-editor-track' ), $handles );
|
||||||
$expected_dependencies = array( 'wp-components', 'wp-core-data', 'wp-data', 'wp-edit-post', 'wp-element', 'wp-i18n', 'wp-plugins' );
|
$expected_dependencies = array( 'wp-components', 'wp-core-data', 'wp-data', 'wp-edit-post', 'wp-element', 'wp-i18n', 'wp-plugins' );
|
||||||
|
|
||||||
foreach (
|
foreach (
|
||||||
array(
|
array(
|
||||||
'chrnx-editor-taxonomies' => 'assets/js/editor-taxonomies.js',
|
'chrnx-editor-taxonomies' => 'assets/js/editor-taxonomies.js',
|
||||||
'chrnx-editor-podcast' => 'assets/js/editor-podcast.js',
|
'chrnx-editor-podcast' => 'assets/js/editor-podcast.js',
|
||||||
'chrnx-editor-project' => 'assets/js/editor-project.js',
|
|
||||||
) as $handle => $asset
|
) as $handle => $asset
|
||||||
) {
|
) {
|
||||||
$this->assertArrayHasKey( $handle, $scripts->registered );
|
$this->assertArrayHasKey( $handle, $scripts->registered );
|
||||||
@@ -123,7 +122,6 @@ class EditorAssetsTest extends WP_UnitTestCase {
|
|||||||
do_action( 'enqueue_block_editor_assets' );
|
do_action( 'enqueue_block_editor_assets' );
|
||||||
$this->assertFalse( wp_script_is( 'chrnx-editor-taxonomies', 'enqueued' ) );
|
$this->assertFalse( wp_script_is( 'chrnx-editor-taxonomies', 'enqueued' ) );
|
||||||
$this->assertFalse( wp_script_is( 'chrnx-editor-podcast', 'enqueued' ) );
|
$this->assertFalse( wp_script_is( 'chrnx-editor-podcast', 'enqueued' ) );
|
||||||
$this->assertFalse( wp_script_is( 'chrnx-editor-project', 'enqueued' ) );
|
|
||||||
$this->assertFalse( wp_script_is( 'chrnx-editor-track', 'enqueued' ) );
|
$this->assertFalse( wp_script_is( 'chrnx-editor-track', 'enqueued' ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ class PatternsTest extends WP_UnitTestCase {
|
|||||||
$contracts = array(
|
$contracts = array(
|
||||||
'home-projects' => array(
|
'home-projects' => array(
|
||||||
'heading' => 'Selected work',
|
'heading' => 'Selected work',
|
||||||
// The project names come from chrnx/selected-work now, not the pattern.
|
// The project names come from the project list query now, not the pattern.
|
||||||
'order' => array( 'Selected work' ),
|
'order' => array( 'Selected work' ),
|
||||||
'art' => 'alter-ego-code-768.webp',
|
'art' => 'alter-ego-code-768.webp',
|
||||||
'art_alt' => '',
|
'art_alt' => '',
|
||||||
|
|||||||
Reference in new issue
Block a user