Useful Must-Use Plugins For WP Developers

0
54

Do you want options to activate routinely and stay enabled in your web site? Then take into account including these to WordPress as an mu-plugin…even create your personal!

So, a must-use plugin (‘mu-plugin’) is rather like every other WordPress plugin, apart from the truth that when uploaded into the mu-plugins listing of the wp-content folder (i.e. /wp-content/mu-plugins it’s routinely activated and stays enabled in your WordPress set up.

Back within the early days (around version 3.0), WordPress launched a function referred to as Multisite (initially referred to as WordPress MU) to permit a number of websites to share and be managed by one WordPress set up, WordPress Multisite (or WPMU because it grew to become recognized) additionally launched the ‘mu-plugins’ listing, providing web site admins a straightforward solution to activate plugins by default on all blogs in a multisite community.

Although MU-plugins initially referred to ‘multi-user plugins’, they have been renamed to ‘must-use’ plugins.  Installed within the ‘mu-plugins’ listing of a WPMU set up, mu-plugins can now be used wherever you need a number of plugins to routinely activate and stay enabled, whether or not on one or a number of WordPress installations.

must-use plugin (‘mu-plugin’) is a plugin that, by default, is routinely activated and stays enabled when uploaded into the mu-plugins listing of the wp-content folder (i.e. /wp-content/mu-plugins. Once uploaded into this listing, WordPress will routinely know that this plugin have to be used on the set up.

Must-use plugins are loaded earlier than regular plugins and don’t present within the default record of plugins on the Plugins web page of wp-admin. They do, nonetheless, seem in a particular Must-Use part within the Plugin display screen’s record menu.

To change the default listing manually, you’ll need to outline two constants (WPMU_PLUGIN_DIR and WPMU_PLUGIN_URL) in wp-config.php:

outline('WPMU_PLUGIN_DIR', '/full/path/to/new/listing');
outline('WPMU_PLUGIN_URL', 'https://URL/to/new/listing');

Must-use plugins allow you to add options to the WordPress core that aren’t put in by default however that customers might have.

The documentation then goes on to record a lot of essential caveats to bear in mind:

Note: WordPress solely seems to be for PHP information proper contained in the mu-plugins listing, and (not like for regular plugins) not for information in subdirectories. You could need to create a proxy PHP loader file contained in the mu-plugins listing:

Mu-plugins ought to solely be used to do “one” easy motion. Calling complicated code on a regular basis may result in battle with different code or plugins and involving mu-plugins as suspected sources when troubleshooting conflicts can actually complicate issues.

Additionally, remember that, not like common plugins, you possibly can’t retailer an mu-plugin in a subdirectory of the mu-plugins listing. This signifies that you gained’t be capable to type your mu-plugins utilizing folders by default.

You might get round this by creating an mu-plugin to make WordPress routinely included mu-plugins saved in subdirectories, however as they don’t seem to be discovered by WordPress by default, they gained’t seem within the must-use plugins record, so that you gained’t be capable to see which must-use plugin is put in in subdirectories with out trying on the mu-plugins listing itself.

Follow the above tutorial to undergo the whole course of, or click on on a hyperlink under to go to one of many above steps:

Warning: We strongly advocate performing a whole backup of your web site earlier than altering issues or including code to server information in case something goes incorrect. Snapshot makes backing up and restoring WordPress websites a breeze! 

If you’re a WordPress developer or handle web sites in your staff or your purchasers, listed here are some helpful mu-plugins you possibly can create to increase your bag of tips:

If you handle web sites in your staff or your purchasers, or are the pinnacle developer of your enterprise, you could need to make WordPress customizations that solely you possibly can see, or cover buttons for all customers apart from you to make sure folks don’t click on the place they shouldn’t .

While you possibly can customise admin instruments utilizing a plugin like Branda, it’s also possible to do that simply utilizing code.

For this instance, let’s say that you’re the one superadmin of a web site and need to cover the toolbar for each person besides your self.

Just create a mu-plugin and add the next code and magnificence it utilizing CSS:

<?php
add_action( 'admin_footer', 'hideitems' );
operate hideitems() {
   if ( ! is_super_admin() ) {
      echo "<fashion>
         #wpadminbar {
            show: none !essential;
         }
      </fashion> ";
   }
}

2. Hide WordPress Top Menu And Create A Custom Logout Button

Here’s one other WordPress admin customization you are able to do in your purchasers.

Let’s say you need to cover or take away the highest bar in your consumer websites’ admin areas since you discover it’s inconvenient to have it show there or really feel that giving purchasers who don’t know a lot about WordPress entry to content material modification menus might result in them making inadvertent errors.

For instance, should you construct websites utilizing Elementor, your purchasers can entry Elementor’s theme customization choices straight from the highest menu bar.

Add new Elementor template in WordPress toolbar.
Users can add a brand new Elementor template of their WordPress toolbar.

Sticking with Elementor for this instance, you could resolve to cover this to keep away from issues and depart the theme customization path contained in the admin space at Templates > Theme Builder. Or you could resolve to take away it altogether, as a result of even should you disable choices from the admin bar, some customers should not perceive what it’s and why it shows on the entrance finish of their websites.

Hiding the highest bar could be very simple to do utilizing a plugin like Branda…simply go to Admin space > Admin bar after which uncheck the toolbar visibility for some customers.

The downside is, should you utterly disable this bar, customers gained’t be capable to logout from their admin. This not solely creates a safety difficulty, it’s additionally not handy if you wish to swap customers.

Fortunately, there’s a answer: Simply add this code as a mu-plugin to create a logout button:

<?php
add_action(
   'admin_menu',
   operate () {
      add_menu_page(
         'Logout',
         'Logout',
         'learn',
         'wp_custom_logout_menu',
         '__return_false',
         'dashicons-marker',
         1 // Here use 1 for putting menu on prime or PHP_MAX_INT to position it on the backside,
      );
   }
);

add_action(
   'admin_init',
   operate () {
      if ( isset( $_GET['page'] ) && $_GET['page'] == 'wp_custom_logout_menu' ) {
         wp_redirect( wp_logout_url() );
         exit();
      }
   }
);

This will redirect your person to the login web page after the logout course of.

3. Add CSS To WordPress Backend

How are you able to add CSS to the WordPress backend?

Once once more, you need to use a plugin like Branda, however you might additionally create an mu-plugin and paste the next code in your file:

<?php
add_action( 'admin_footer', 'my_admin_css' );
operate my_admin_css() {
   echo '<fashion>
      /*Put your CSS code right here*/
   </fashion>';
}

That’s it…simple and really helpful!

4. Remove All Styles From WordPress Content

Suppose you come throughout a web site the place all of the content material fashion is ready by HTML inside the WordPress content material.

This is form of a bummer, since nobody actually needs to switch the fashion of every web page when you possibly can simply do that utilizing CSS.

So, right here’s a workaround for this.

Create a mu-plugin, and add the next code:

add_filter(
   'the_content',
   operate ( $content material ) ')(.*?)("
);

Try it out!

5. Hide Elementor In WordPress Admin

Elementor is without doubt one of the in style and widely-used web page builders for WordPress. If you’re a net developer or webmaster, you could be utilizing Elementor to create and handle an internet site and its content material.

As simple as Elementor is, it nonetheless requires some information to make use of it and an inadvertent mistake by a person might make the positioning not possible to navigate.

So, if you’re the one one managing the web site and customers don’t must create pages in WordPress fairly often, you may need to cover Elementor choices from different backend customers. Making certain there isn’t a modification taking place to the backend with out your information gives you peace of thoughts and your prospects or backend customers may recognize having an easier interface to work with.

This tip works effectively on the next sorts of web sites:

  • eCommerce websites
  • Websites with customized posts varieties
  • Websites used primarily as a weblog to publish articles.

As acknowledged earlier, if finish customers must recurrently create WordPress pages, this won’t be just right for you as a result of they’ll want Elementor for this.

Before creating an mu-plugin, first you could cover Elementor within the menu. You can then cover the Elementor button on WordPress pages.

1. Hide Elementor within the menu

Install Branda after which:

  • Go to Admin space > Admin bar and conceal it in your finish customers. This manner they won’t be able to entry the Elementor builder from there.
  • Go to Dashboard > Admin menu > Customize after which cover the Elementor admin menu for everybody besides you (tip: use person roles for this as it’s simpler than doing it for each person).
  • Remember to additionally cover the “Templates” menu (that is in all probability essentially the most important factor to cover).

Note: We advocate that just one individual ought to be capable to entry the templates, particularly if utilizing these to construct your theme and utilizing CSS to manage each merchandise of your web site’s design. This prevents different customers from including CSS elsewhere (e.g. in builders, theme customizer, stylesheets, and many others.)…and with out commenting correctly when including code, e.g.

/* Header customization */
.header{
   margin-top: 10px;
}
/* END Header customization */

2. Hide the Elementor button on WordPress pages

The best solution to create or modify a web page with Elementor is solely to go to Pages > Create and click on on the Elementor button to vary it.

There can be a solution to cover this button if you do not need customers to entry Elementor in any respect.

To do that, it’s essential to customise user roles. If you’re the solely admin of the positioning, you possibly can cover the buttons for everybody besides you.

Note: You can use the earlier step to cover the Elementor templates solely (to maintain your theme protected) however nonetheless depart entry in Elementor to create and modify pages. This, nonetheless, could be dangerous, since when customers are on an Elementor web page, they will navigate to different parts just like the header or footer, or entry Elementor world settings that may have an effect on the positioning.

Once you have got achieved the above, the one factor left to do is create a mu-plugin and paste the next code to cover the button :

<?php
add_action( 'admin_footer', 'hideitems' );

operate hideitems() {
   if ( ! is_super_admin() ) {
      ?>
        <fashion>
            #elementor-switch-mode {
                show: none;
            }
        </fashion>
      <?php
   }
}

Enjoy!

6. Make Beehive Analytics Your WordPress Dashboard Home Page

If you aren’t an enormous fan of the WordPress admin web page (even should you can customise its widgets and conceal panels) or having your customers see this display screen each time they log into their WordPress dashboard…

WordPress Dashboard Screen
Look however don’t look…is that this what you need customers to see after they log in?

Why not present them a ravishing admin touchdown web page with helpful info like this?

Beehive Pro Analytics screen
Oooh…aaah…charts and stats…that’s a lot better!

Again, you need to use Branda to customise the admin panel and the left menu or cover/present menus relying on the person function. This is nice if you’re the one admin and need to show the minimal required menus for finish customers or add customized CSS.

If, nonetheless, all you need to do is redirect customers from the WordPress admin web page to a extra helpful web page just like the Beehive analytics web page, then merely create an mu-plugin and add this code:

<?php
operate wpmudev_redirect_page() {
   world $pagenow;
   if ( $pagenow == 'index.php' && ! wp_doing_ajax() && is_plugin_active( 'google-analytics-async/google-analytics-async.php' ) ) {

      wp_redirect( admin_url( '/admin.php?web page=beehive-google-analytics' ) );
      exit;
   }
}

add_action( 'admin_init', 'wpmudev_redirect_page' );

Enjoy!

Make WordPress Fly With MU-Plugins

Hopefully, now you realize all about Must-Use plugins: what they’re, when and when to not use them, and the way and the place to put in them on WordPress websites.

Check out our mu-plugins documentation, attempt creating and putting in some must-have plugins of your personal, and should you expertise any points or want knowledgeable assist, contact our assist staff…we’re accessible 24/7 to reply any WordPress questions you have got!

Contributors

This article was written in collaboration with:

Incensy

Antoine –  Incensy.  I’m passionate by net tradition and digital options. I’ve been working on this space for 11 years now. Always on the lookout for the most effective options to assist my prospects overcome digital challenges and develop their enterprise on-line. My imaginative and prescient of digital success: Get a world technique, apply it with detailed precision, and at all times maintain bettering.

***

Note: We don’t settle for articles from exterior sources. WPMU DEV members, nonetheless, could contribute concepts and ideas for tutorials and articles on our weblog by way of the Blog XChange.

Source link