📢 Introducing Fathom Extension for MainWP: Track All Child Site Stats from One Dashboard.

Useful Code Snippets for WordPress 6.2

Code Snippets - WordPress 6.2

Heads up: This page may include affiliate links. Read the full disclosure.

WordPress 6.2, the next major release of WordPress core, is scheduled for March 28th.

WordPress 6.2 - Useful Code Snippets

The new version of WordPress comes with many feature improvements and enhancements, but you may not want to use them.

Here are some code snippets to disable certain features:

1) To disable the new Openverse category from showing in the new media tab in the block editor, you can use this code snippet.

function( $settings ) {
$settings['enableOpenverseMediaCategory'] = false;return $settings;

Let’s discuss

2) There is a new filter wp_save_post_revision_revisions_before_deletion which can be used to delete all but the oldest post revision on posts.

function( $revisions, $post_id ) {
$original_revision = get_transient( 'original_revision_for_post_' . $post_id );
if ( $original_revision ) {
// Always remove the oldest revision from the array of revisions to potentially delete.
unset( $revisions[ $original_revision ] );
} else {
// Set the oldest revision in a transient, so we can verify that it is always ignored.
$original_revision = array_key_first( $revisions );
set_transient( 'original_revision_for_post_' . $post_id, $original_revision );
return $revisions;

Let’s discuss

3) A block inspector tabs feature was added to the WordPress 6.2 release but using the filter it can be disabled using a code snippet.

function my_plugin_disable_tabs_by_default( $settings ) {
$settings['blockInspectorTabs'] = array( 'default' => false );
return $settings;
add_filter('block_editor_settings_all', 'my_plugin_disable_tabs_by_default');

Let’s discuss

MainWP has an easy-to-use code snippets extension that can save and execute code snippets on all connected Child Sites.

The field guide is worth reviewing to get an overview of what’s coming in the latest release.

It is always recommended to test major WordPress core updates on a staging site using the beta and release candidate versions.

Before updating the live site, you should always test out major WordPress core releases on a staging site. Here are a few reasons why:

To avoid potential conflicts: A major WordPress release often introduces new features, updates, and changes to the codebase, which can potentially conflict with your website’s existing themes, plugins, or custom code. Testing the update on a staging site helps you identify and resolve any conflicts before the update is made live, preventing any unexpected downtime or errors on your live site.

To ensure compatibility: A staging site allows you to test your website’s compatibility with the new WordPress version and any themes and plugins you use. This can help you identify any compatibility issues before the update is made live, allowing you to fix them before any potential problems arise.

To ensure site functionality: A major WordPress release can impact the functionality of your site, and testing it on a staging site can help you identify and fix any issues before going live. This ensures your site functions as intended without negatively affecting your user experience.

To reduce risk: Testing major WordPress core releases on a staging site reduces the risk of something going wrong on your live site. It lets you identify and fix any issues beforehand, preventing downtime, data loss, or other potentially costly problems.

Overall, testing major WordPress core releases on a staging site first is a best practice that can help you ensure your website’s stability, compatibility, and functionality while reducing the risk of any negative impact on your live site.

Useful Links

Looking for something?

Privacy laws apply to businesses that collect personal information. Since no personal information is collected by the MainWP plugins, no privacy laws apply to the MainWP plugins. This includes GDPR, UK DPA 2018, PIPEDA, Australia Privacy Act 1988, LGPD, PIPL, and other privacy laws.
Donata Stroink-Skillrud
Donata Stroink-Skillrud
President of Agency Attorneys

Your Download Is Just One Click Away

…or just download the plugin.

By entering your email, you agree to our Terms of Service and Privacy Policy.