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:
chrnxandClaude Opus 5 committed 2026-08-15 14:58:19 -05:00
1 parent 7c0eb51dcc
commit 77dc2ee33b
12 files changed
+6 -362

No files matched your search

-34
View File
@@ -541,40 +541,6 @@ footer a {
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 {
display: block;
}
-111
View File
@@ -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 };
} );