Skip to content

Testing: Entity actions and fields with the Gutenberg trunk pin - #14515

Closed
jorgefilipecosta wants to merge 6 commits into
WordPress:trunkfrom
jorgefilipecosta:test/entity-actions-view-config-gb-trunk
Closed

jorgefilipecosta wants to merge 6 commits into
WordPress:trunkfrom
jorgefilipecosta:test/entity-actions-view-config-gb-trunk

Conversation

@jorgefilipecosta

@jorgefilipecosta jorgefilipecosta commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

Trac tickets: https://core.trac.wordpress.org/ticket/66343, https://core.trac.wordpress.org/ticket/66229

This PR combines two backport PRs and a Gutenberg pin update, so they can be tested together. It's for testing only, each piece is reviewed and committed in its own PR.

This PR:

Some notes:

Testing Instructions

  1. Check out this branch and run npm run build:dev. The Gutenberg files are already committed.
  2. Open wp-admin/site-editor.php?p=%2Fpage. Verify the list shows the page fields and the actions menu of a page works: rename, trash, restore and permanently delete. Do the same in the templates and patterns screens.
  3. Open a post in the post editor and verify the fields and the actions menu in the inspector. Verify in the Network panel that the editor made no request to /wp/v2/entity-actions, which is preloaded.
  4. Add the plugin below to wp-content/mu-plugins/. Verify "Copy title" and "Show details…" appear in the page list row menu, in the bulk bar (only "Copy title", which supports bulk) and in the post editor actions menu, and that both run.
  5. Run npm run test:php -- --group entity-actions,entity-fields. Only the two text domain tests should fail.
Demo plugin: demo-entity-actions.php
<?php
/**
 * Plugin Name: Demo entity actions
 * Description: Registers two actions on posts and pages through the entity actions API.
 *
 * The PHP declares the serializable part of each action. The script module in
 * demo-entity-actions/actions.js provides the JavaScript parts, keyed by action id.
 */

add_action(
	'init',
	static function () {
		wp_register_script_module(
			'demo-entity-actions',
			plugins_url( 'demo-entity-actions/actions.js', __FILE__ ),
			array(),
			'1.0.1'
		);
	}
);

add_action(
	'wp_entity_actions_api_init',
	static function () {
		$actions = array(
			array(
				'id'           => 'demo-copy-title',
				'label'        => 'Copy title',
				'supportsBulk' => true,
			),
			array(
				'id'          => 'demo-details',
				'label'       => 'Show details…',
				'modalHeader' => 'Demo details',
			),
		);

		foreach ( array( 'post', 'page' ) as $post_type ) {
			wp_register_entity_actions( 'demo-entity-actions', 'postType', $post_type, $actions, 'demo-entity-actions' );
		}
	}
);
Demo plugin: demo-entity-actions/actions.js
/**
 * The JavaScript parts of the demo actions, keyed by the ids registered in PHP.
 */
const { createElement: el } = window.wp.element;
const {
	Button,
	__experimentalHStack: HStack,
	__experimentalVStack: VStack,
} = window.wp.components;

const getTitle = ( item ) =>
	( typeof item.title === 'string'
		? item.title
		: item.title?.raw ?? item.title?.rendered ) || `#${ item.id }`;

export default {
	'demo-copy-title': {
		callback: async ( items, { registry, onActionPerformed } ) => {
			const titles = items.map( getTitle ).join( '\n' );
			try {
				await window.navigator.clipboard.writeText( titles );
			} catch ( error ) {
				// The clipboard may be unavailable; the notice still shows the titles.
			}
			registry
				.dispatch( 'core/notices' )
				.createSuccessNotice( `Copied: ${ titles }`, {
					type: 'snackbar',
				} );
			onActionPerformed?.( items );
		},
	},
	'demo-details': {
		isEligible: ( item ) => item.status !== 'trash',
		RenderModal: ( { items, closeModal } ) =>
			el(
				VStack,
				{ spacing: 4 },
				el(
					'ul',
					null,
					items.map( ( item ) =>
						el(
							'li',
							{ key: item.id },
							`${ getTitle( item ) } — id ${ item.id }, ${ item.status }`
						)
					)
				),
				el(
					HStack,
					{ justify: 'flex-end' },
					el(
						Button,
						{ variant: 'primary', onClick: closeModal },
						'Close'
					)
				)
			),
	},
};

Use of AI Tools

AI assistance: Yes
Used for: combining the branches, updating the pin, and drafting this description; reviewed and edited by me.


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

jorgefilipecosta and others added 6 commits October 19, 2026 20:24
Loads `register_core_entity_actions()` from the `core-actions` package, which registers the actions of posts, pages, patterns and template parts through the entity actions API at priority 0, so a plugin can unregister or replace them. The build copies its PHP files to `wp-includes/build/scripts/core-actions/`.
The post editor also preloads the actions of the post type it edits.

Synced from WordPress/gutenberg#84660.

See #66343.
…ludes them.

The core actions are copied from the Gutenberg build, so their tests are skipped while the pinned build does not include them.

See #66343.
Copies the PHP of the `core-fields` package from the Gutenberg build and loads it, so WordPress registers its own fields through the entity fields API: the default fields every post type derives from its supports, and the field collections of pages, templates, template parts, patterns, attachments, navigation menus, and the site.

Synced from WordPress/gutenberg#84696.

See #66229.
Ports the REST controller tests of WordPress/gutenberg#84696: the fields route exposes the default fields of pages and the fields of patterns, with the script modules of their collections and the `core` origin.

See #66229.
…udes them.

The core fields are copied from the Gutenberg build, so their tests are skipped while the pinned build does not include them.

See #66229.
…d fields together.

Points the Gutenberg pin to a trunk build that includes the core entity actions and fields, and adds the files that build copies over.

For testing only, the pin update belongs to its own PR.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jorgefilipecosta
jorgefilipecosta force-pushed the test/entity-actions-view-config-gb-trunk branch from 0122fa2 to 309a24c Compare October 19, 2026 19:26
@jorgefilipecosta jorgefilipecosta changed the title Testing: Entity actions and view configs with the Gutenberg trunk pin Testing: Entity actions and fields with the Gutenberg trunk pin Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant