Which code snippets would be the most useful

Please let me know which code snippets for which plugins would be of the most use?


Hi, any chance you could share a snippet code to rearrange the order of Mainwp menu? Thanks

So change the menu item order in the MainWP dashboard site.

Yes this could be useful, as well as adding new menu item with custom link snippet.

1 Like

At the moment I’m looking for code snippets to add to a custom mu-plugin, that will be installed on all the sites I manage for clients. So I’m looking for snippets regarding security, updates, monitoring hosting environment etc.

I’m already blocking the admin email check and have removed the automatic updater options. I’ll continue my search.

These would be good ones to add to the mu-plugin.

add_filter( 'wp_lazy_loading_enabled', '__return_false' );
add_filter( 'wp_sitemaps_enabled', '__return_false' );
add_filter( 'plugins_auto_update_enabled', '__return_false' );
add_filter( 'themes_auto_update_enabled', '__return_false' );
add_filter( 'auto_plugin_update_send_email', '__return_false' );
add_filter( 'auto_theme_update_send_email', '__return_false' );
1 Like

Using a mu-plugin is a great idea. I would also add:

// Disable the site health dashboard widget
add_action(‘wp_dashboard_setup’, ‘remove_site_health_dashboard_widget’);
function remove_site_health_dashboard_widget()
remove_meta_box(‘dashboard_site_health’, ‘dashboard’, ‘normal’);

// Disable the URL field from the WordPress comment form on your child site.
add_filter(‘comment_form_field_url’, ‘__return_false’);`

// Disable checking of admin email
add_filter( ‘admin_email_check_interval’, ‘__return_false’ );

1 Like

Yep those are some handy code snippets as well.

@sebastian-moran - You mentioned a mu-plugin but how you set up one from MainWP and push it to the child?
Do you create your own plugin and then push it to all sites and edit the function when needed?

@wpexpert I’ve created one and uploaded it to all my clients with the File Uploader Extension to /wp-content/mu-plugins/. That makes it much easier (and faster when managing many sites) to add these code snippets to a new child.


Thanks, @josklever. We have more than 95 sites, do you have ever encountered any conflicts with other plugins?

Conflicts between other plugins and what? The mu-plugin? I only use it for snippets, that can be used on all (240) sites, like disabling the “auto update settings” from WP 5.5.

For more specific snippets you can create separate plugins and push them only to sites in a certain group.


Must-use plugins get loaded before plugins are loaded in WordPress.

1 Like

I didn’t know that! Thanks so less chance to have a conflict with a plugin then…

1 Like