Home » WordPress 7.2: What’s New and Actually Useful for WordPress Developers?

WordPress 7.2: What’s New and Actually Useful for WordPress Developers?

Home » WordPress 7.2: What’s New and Actually Useful for WordPress Developers?

WordPress 7.2: What’s New and Actually Useful for WordPress Developers?

Are your plugins ready for the new release? Before you bump `Tested up to`, let’s check 🙂 More than 440 tickets. They promise nothing will break, but time will tell. So we look at what matters: what’s new for developers,…

WordPress 7.2: What’s New and Actually Useful for WordPress Developers?

Are your plugins ready for the new release? Before you bump `Tested up to`, let’s check 🙂

More than 440 tickets. They promise nothing will break, but time will tell. So we look at what matters: what’s new for developers, and where to check your own code.

What can we do?

  • Finally use SVG icons instead of Dashicons: your own admin bar and menu icons with a registered icon name.
  • Add a field to the editor sidebar with one API: the Entity Fields API. Register it once, and it shows up in the Inspector, Quick Edit and the Site Editor.
  • Add an action in the same places: the Entity Actions API.
  • Give a block a text shadow without CSS: textShadow in block.json and theme.json.
  • Style block states (hover, focus) from code: getStyleForState() / setStyleForState().
  • Render HTML reactively in the Interactivity API: data-wp-html.

What to check before December 8:

  • Dashicons → SVG: your CSS for menu and admin bar icons may stop working.
  • The editor sidebar now runs on DataForm: if your plugin edits its DOM directly, it will break.
  • Images are processed in the browser: plugins that hook into uploads and image sizes may see a different flow.
  • `@wordpress/components`: moved from Emotion to SCSS Modules, eight components deprecated until 7.4.
  • `__experimentalGroup` and `data-wp-ignore` are removed.
  • `NO_BACKSLASH_ESCAPES` is turned off: check your raw SQL.
  • Only then: Tested up to: 7.2.

1. SVG icons in the admin bar and menu

The long-awaited one. Core admin icons are now inline SVGs, and your plugin can use the same set.

TEXT
// Admin bar: the new `icon` argument.
add_action( 'admin_bar_menu', function ( WP_Admin_Bar $wp_admin_bar ) {
	$wp_admin_bar->add_node( array(
		'id'    => 'my-plugin-notes',
		'icon'  => 'core-admin/pin',
		'title' => __( 'Notes', 'my-plugin' ),
		'href'  => admin_url( 'admin.php?page=my-plugin-notes' ),
	) );
}, 100 );
TEXT
// Admin menu: a registered icon name, with a fallback for older WordPress.
add_menu_page(
	__( 'Notes', 'my-plugin' ),
	__( 'Notes', 'my-plugin' ),
	'manage_options',
	'my-plugin-notes',
	'my_plugin_render_notes',
	function_exists( 'wp_is_valid_icon_name' ) ? 'core-admin/pin' : 'dashicons-admin-post'
);

But: CSS that styles icons through ::before no longer reaches them, because the icon is now an <svg> element. Rules like #adminmenu div.wp-menu-image::before need to target div.wp-menu-image svg or .ab-icon instead. The SVG takes its color from currentColor.

2. Entity Fields API: one field, three screens

TEXT
add_action( 'init', function () {
	register_post_meta( 'page', 'demo_subtitle', array(
		'type'              => 'string',
		'single'            => true,
		'default'           => '',
		'show_in_rest'      => true,
		'sanitize_callback' => 'sanitize_text_field',
	) );

	wp_register_script_module( 'demo-page-field', plugins_url( 'fields.js', __FILE__ ) );
} );

add_action( 'wp_entity_fields_api_init', function () {
	wp_register_entity_fields(
		'demo-page-field', // Who registers the fields.
		'postType',
		'page',
		array(
			array(
				'id'    => 'demo_subtitle',
				'type'  => 'text',
				'label' => __( 'Subtitle', 'demo-page-field' ),
			),
		),
		'demo-page-field'  // Script module with the JS parts.
	);
} );
JAVASCRIPT
// fields.js
export default {
	demo_subtitle: {
		getValue: ( { item } ) => item.meta?.demo_subtitle ?? '',
		setValue: ( { value } ) => ( { meta: { demo_subtitle: value } } ),
	},
};

PHP describes the field (id, type, label). The script module says how to read and write the value.

But: a registered field is hidden by default. Add it to the screen and the form with the view config filter from 7.1:

TEXT
add_filter( 'get_entity_view_config_posttype_page', function ( $data ) {
	return $data->merge(
		array(
			'default_view' => array( 'fields' => array( 'demo_subtitle' ) ),
			'form'         => array( 'fields' => array( 'demo_subtitle' ) ),
		),
		1
	);
} );

3. Entity Actions API

Same pattern, for an action:

TEXT
add_action( 'wp_entity_actions_api_init', function () {
	wp_register_entity_actions(
		'demo-page-action',
		'postType',
		'page',
		array(
			array(
				'id'           => 'demo-copy-link',
				'label'        => __( 'Copy link', 'demo-page-action' ),
				'supportsBulk' => true,
			),
		),
		'demo-page-action'
	);
} );
JAVASCRIPT
// actions.js
export default {
	'demo-copy-link': {
		isEligible: ( item ) => item.status !== 'trash',
		callback: async ( items ) => {
			await window.navigator.clipboard.writeText(
				items.map( ( item ) => item.link ).join( '\n' )
			);
		},
	},
};

But: with supportsBulk, your callback gets an array of items, not one. Write it for many from the start.

4. Text shadow without CSS

block.json:

JSON
{
	"supports": {
		"typography": {
			"textShadow": true
		}
	}
}

theme.json:

JSON
{
	"version": 3,
	"settings": {
		"typography": {
			"textShadowPresets": [
				{
					"name": "Soft",
					"slug": "soft",
					"textShadow": "1px 1px 2px rgba(0, 0, 0, 0.3)"
				}
			]
		}
	}
}

Paragraph and Heading support it by default, with Light and Strong presets.

But: a preset is saved as a class (has-soft-text-shadow), not an inline style. Rename the slug, and existing content loses its shadow.

5. Block states from code

JAVASCRIPT
import { InspectorControls, getStyleForState, setStyleForState } from '@wordpress/block-editor';

// Read the style for the selected state (for example, hover).
const stateStyle = getStyleForState( attributes.style, selectedState ) || {};

// Controls in the new group.
<InspectorControls group="style-state">…</InspectorControls>

In PHP, breakpoints come from wp_get_viewport_media_queries() (defaults 480px and 782px), so your block uses the same ones as core.

But: this is a new API. Check the full example in the dev note before you build a whole control on it.

6. data-wp-html in the Interactivity API

JAVASCRIPT
import { asDangerousHTML, store } from '@wordpress/interactivity';

const { state } = store( 'myPlugin', {
	actions: {
		*loadPreview() {
			const response = yield fetch( state.previewUrl );
			const html = yield response.text();
			state.preview = asDangerousHTML( html );
		},
	},
} );
TEXT
<div data-wp-interactive="myPlugin">
	<button data-wp-on--click="actions.loadPreview">Show preview</button>
	<div data-wp-html="state.preview"></div>
</div>

On the server it’s wp_interactivity_as_dangerous_html( $html ).

But: the name says it all. These functions do not sanitize anything. Only pass HTML you trust, or run it through wp_kses_post() first.

What to check: the details

  • DataForm sidebar: anything that reaches into the sidebar DOM should move to the Entity Fields API above.
  • Client-side media: resizing and sub-sizes now happen in Chromium browsers (137+) on devices with more than 2 GB of memory; Firefox, Safari and weaker devices fall back to the server. Test your upload hooks in both.
  • Components: Animate, Divider, Elevation, ResponsiveWrapper, Scrollable, Surface, Tip, ZStack are deprecated, removal in 7.4. Code that relied on Emotion class names needs review.
  • Removed: __experimentalGroup on InspectorControls (use group); data-wp-ignore; two-hyphen directive IDs (data-wp-init--setup becomes data-wp-init---setup); negated function references in directives (use derived state instead).
  • REST: the comments endpoint status parameter is now an array.
  • Database: NO_BACKSLASH_ESCAPES is off on the connection. Hand-built SQL with backslashes should go through $wpdb->prepare().
  • `/random/`: a new endpoint redirects to a random post. If a site has a page with that slug, check it.

In short

  1. SVG icons: use registered icon names and move icon CSS from ::before to svg.
  2. Editor fields and actions: Entity Fields and Entity Actions APIs, not DOM hacks.
  3. textShadow and block states: less custom CSS in your blocks.
  4. data-wp-html: only with trusted HTML.
  5. Test on RC, then Tested up to: 7.2.

Full list of changes: WordPress 7.2 Field Guide. Also read: PHP 8.6 for WordPress developers.

Build WordPress the right way

Production-ready 4WP plugins with clean architecture — or a team that builds it with you.

Latest videos

All videos →

Learn by topic