Skip to content
armanazij.com

WordPress 7.2 for plugin developers: what breaks beyond the Secrets API

WordPress 7.2 RC1 is out. SVG admin icons, /random/ URLs, admin assets without concatenation and Interactivity API removals: what changes, what breaks, and how to support 7.1 and 7.2 from one codebase.

Rejaul Alom Khan (Arman Azij), Laravel and WordPress developer in Dhaka, Bangladesh Arman Azij 7 min read
WordPress 7.2 for plugin developers: what breaks beyond the Secrets API, by Rejaul Alom Khan (Arman Azij)

The release behind the headline

Most coverage of WordPress 7.2 leads with Ipsum, the new default theme, and with the Secrets API, which I covered in a separate post. But the changes most likely to break a plugin in December are quieter ones in wp-admin and in the Interactivity API. Release candidate 1 shipped on November 17, RC2 is scheduled for November 24, RC3 for December 1, and the final release for December 8. RC1 also brought the hard string freeze, so this is the window where plugin authors test, not where they find out from support tickets.

As a Core contributor with props in every release from 6.6 to 7.1, I read the dev notes as a checklist. Here is mine for 7.2: what changed, what breaks, and how to support both 7.1 and 7.2 from one codebase.

Admin menu and admin bar icons are SVG now

The icons in the admin sidebar and the admin bar are no longer Dashicons font glyphs. They are inline SVGs from a new core-admin icon collection.

For plugin authors there is a new option. add_menu_page() and the menu_icon argument of register_post_type() accept a namespaced icon name such as 'core-admin/pin', alongside the old Dashicons classes, image URLs, base64 SVGs and none. WP_Admin_Bar::add_node() gets a new icon argument for the same names. You can register your own icons with wp_register_icon_collection() and wp_register_icon(). An unregistered name renders no icon, and with WP_DEBUG on it triggers _doing_it_wrong().

Backward compatibility is careful. A Dashicon in menu_icon that has a matching core-admin icon is rendered as the SVG automatically, and other values render as before. What breaks is CSS:

  • Rules that color, hide or replace icons through ::before on the menu or admin bar no longer reach an SVG. Target the element too, for example div.wp-menu-image svg or .ab-icon.
  • Selectors that target an icon by its Dashicon class, such as .dashicons-admin-post::before, stop matching. Use the menu item ID or the .menu-icon-* class.
  • Code that looks for the empty <span class="ab-icon"> in admin bar titles will not find it. In 7.2 only the WordPress logo node keeps it.
  • Admin color schemes that color icons only through ::before need to color the element as well.

The dev note gives a clean pattern for supporting both versions, using wp_is_valid_icon_name() as the feature check:

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/receipt' : 'dashicons-text'
);

For admin bar nodes, pass both the old Dashicon span in the title and the new icon argument. 7.2 hides the empty span and renders the SVG, older versions ignore the unknown argument and show the Dashicon.

/random/ is a real URL now

WordPress 7.2 adds random content URLs. With pretty permalinks, /random/ redirects to a random published post, and the same works per archive: /random/category/{slug}/, /random/tag/{slug}/, /random/author/{username}/, and /random/{post-type-slug}/. The base is translatable and can be changed on the Permalinks screen.

Custom post types join in through a new randomable argument on register_post_type(). It defaults to true when the type is publicly queryable and has an archive. Posts are randomable, pages and attachments are not. If your plugin has a public post type with an archive that should never be served at random, opt out:

register_post_type( 'musicals', array(
    'public'      => true,
    'has_archive' => true,
    'randomable'  => false,
) );

The random request runs through the normal main query, so existing pre_get_posts callbacks apply. To adjust only random requests, use wp_is_random_content_query():

add_action( 'pre_get_posts', static function ( WP_Query $query ) {
    if ( wp_is_random_content_query( $query ) ) {
        $query->set( 'category__not_in', array( 525600 ) );
    }
} );

A site can switch the whole feature off with a filter. The dev note names it wp_enable_random_content_redirect; the November developer roundup spells it differently. Check the name against RC1 before you ship code that depends on it. Two things worth testing on your own sites: membership or paywall plugins that protect content in a template_redirect callback, and any existing page whose slug is random.

Admin scripts and styles are no longer concatenated

For years wp-admin bundled core scripts and styles through load-scripts.php and load-styles.php. In 7.2 admin and login assets load individually, and WordPress prefetches what the next screen is likely to need. Both loader files are deprecated and no longer requested.

This is a performance change, but it can break plugins that link to those loader files directly, that hook into concatenation, or that assume a core script has already printed in the <head>. Some scripts that printed in the head now print in the footer. If your admin code runs inline and expects a core global to exist, declare a proper dependency with wp_enqueue_script() instead of relying on load order.

Interactivity API: one safety change, three removals

Block developers using the Interactivity API have the most concrete work in this release.

The data-wp-html directive sets an element's inner HTML from the store, and in 7.2 it only renders values explicitly marked with asDangerousHTML() from @wordpress/interactivity. Plain strings empty the element and log a warning when SCRIPT_DEBUG is on. On the server, wp_interactivity_as_dangerous_html() does the same for state set with wp_interactivity_state(). Neither function sanitizes anything. The marker exists so that trusting HTML is a deliberate act in your code, not an accident of which property a directive reads.

The router store gains state.navigating, truthy while a client-side navigation is running, and state.initiator, the router region that started it. They replace state.navigation.hasStarted and hasFinished, which still work but are deprecated.

Three previously deprecated behaviours are now gone:

  • Unique directive IDs with two hyphens. data-wp-watch--log is skipped; it needs three hyphens: data-wp-watch---log.
  • Negating a function reference such as !actions.isEmpty. Use derived state and negate that.
  • data-wp-ignore. Elements that used it are now hydrated.

The dev note suggests grepping your blocks, for example:

grep -rnE 'data-wp-(watch|init|run)--[^-]' .

The smaller dev notes worth a look

  • Media: client-side uploads in the Media Library and modal, and wp_send_document_isolation_policy_header() replaces a deprecated cross-origin isolation helper.
  • REST API: the comments endpoint's status parameter is now an array, and a new rest_allowed_cors_methods filter.
  • jQuery: 7.2 ships jQuery Migrate 3.6.0 as part of the preparation for jQuery 4. Watch the console for migrate warnings in old admin code.
  • theme.json: text inputs gain :required, :user-valid, :user-invalid, :focus, :focus-visible and ::placeholder states.
  • Sanitization: wp_kses() has moved to the HTML API in trunk. If your plugin sanitizes HTML and then compares the result to the input, test it.

A testing checklist for this week

  • Install RC1 on a staging copy with wp core update --version=7.2-RC1, the Beta Tester plugin, or Playground.
  • Open every admin screen your plugin adds, with your own color scheme and with a custom admin color scheme, and look for missing or wrongly colored icons.
  • Search your CSS for ::before rules on menu and admin bar icons, and your PHP for load-scripts.php or load-styles.php.
  • Run the Interactivity API grep above and check every data-wp-html binding.
  • Visit /random/ and /random/{your-post-type}/ with your plugin active, logged in and logged out.
  • Watch the browser console on admin screens for jQuery Migrate warnings.

Takeaways

  • RC1 is out; RC2 is November 24 and the final release is December 8. Test now.
  • Admin icons are SVG. Fix ::before CSS and feature-detect with wp_is_valid_icon_name().
  • /random/ exists. Set randomable => false on post types that should not appear there, and test access-control plugins.
  • Admin assets are no longer concatenated. Declare script dependencies instead of relying on head order.
  • Interactivity API blocks need asDangerousHTML() for data-wp-html and three hyphens in unique directive IDs.
Tags: #WordPress #WordPress Core #Plugin development

More articles

All posts
Abilities and MCP: making your WordPress plugin callable by AI agents, by Rejaul Alom Khan (Arman Azij)

6 min read

Abilities and MCP: making your WordPress plugin callable by AI agents

The Abilities API has been in WordPress Core since 6.9, and the MCP Adapter is now a WordPress.org plugin. How to register typed, permission-checked abilities, expose them over REST and MCP, and keep AI clients safely limited.

  • #WordPress
  • #AI
  • #Security
Rejaul Alom Khan (Arman Azij), Laravel and WordPress developer in Dhaka, Bangladesh

Let’s talk

Arman Azij