Skip to content

Testing: Entity actions, fields, and view configs together - #14514

Closed
jorgefilipecosta wants to merge 7 commits into
WordPress:trunkfrom
jorgefilipecosta:test/entity-actions-fields-view-config
Closed

jorgefilipecosta wants to merge 7 commits into
WordPress:trunkfrom
jorgefilipecosta:test/entity-actions-fields-view-config

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/65981

This PR combines three 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 or /wp/v2/entity-fields, which are preloaded.
  4. Insert an image block, click "Edit image" in its toolbar, then open the Details tab. Verify it shows the attachment fields from the view config.
  5. 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.
  6. Run npm run test:php -- --group entity-fields,entity-actions,view-config. Verify they pass.
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, staging the demo plugin, 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.

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.
@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.

Comment thread package.json Outdated
},
"gutenberg": {
"sha": "954fe7f9e04631c41aec4552acd627a7203a2aad",
"sha": "61ddc552e11d158d4043e4788a99c249a13b5fbb",

@oandregal oandregal Oct 19, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 or /wp/v2/entity-fields, which are preloaded.

For these instructions to work, the gutenberg sha should be e18c3cafbe1dc2f370fdc4cb7a44811766ea177c.

Adds the view config of the `attachment` post type, whose form is the media editor form. It replaces the default post type form, so the media editor no longer shows only the date and author.

Synced from WordPress/gutenberg#84700.

See #66229.
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.
…ields, and view configs together.

Points the Gutenberg pin to a trunk build that includes the core entity actions, fields, and view configs, with their labels in the default text domain, and adds the files that build copies over.

For testing only, the pin update belongs to its own PR.
@jorgefilipecosta
jorgefilipecosta force-pushed the test/entity-actions-fields-view-config branch from 57adf34 to c7aafe4 Compare October 19, 2026 19:44
@github-actions

Copy link
Copy Markdown

A commit was made that fixes the Trac ticket referenced in the description of this pull request.

SVN changeset: 64566
GitHub commit: a9398d7

This PR will be closed, but please confirm the accuracy of this and reopen if there is more work to be done.

@github-actions github-actions Bot closed this 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.

2 participants