Posted on

MainWP Customisations

MainWP Customisations

The beauty of open source lies in the fact that code is open and can always be tweaked, modified, and customised to your needs. The ability to customise an open-source project (in this case your MainWP Dashboard) is one of its greatest benefits. An open code base of the plugin allows you to reshape and re-outfit the plugin at any time.

MainWP Customisations Plugin

The MainWP Customisations plugin is designed to contain your custom code snippets for your MainWP Dashboard. By adding custom snippets to this plugin, you can easily extend your MainWP Dashboard functionality or change the way it looks.

It will help you to keep all your changes in one location and independent of the other components. This will enable you to safely update your MainWP Dashboard plugin and theme on your MainWP Dashboard site without of worry of losing your modifications as well as deactivating your custom code if needed for troubleshooting.

How to Use the MainWP Customisations Plugin

This plugin doesn’t actually do anything on its own. It is just a convenient way for you to store your own MainWP Dashboard customisations.

Using the MainWP Customisations plugin is very simple. Once installed and activated, all you need to do is to add your custom code to appropriate file in the plugin:

  • Add any CSS code to /wp-content/plugins/mainwp-customisations/custom/mainwp-custom-style.css
  • Add any PHP code to /wp-content/plugins/maiwnp-customisations/custom/functions.php
  • Add any jQuery code to /wp-content/plugins/maiwnp-customisations/custom/mainwp-custom-js.js

To upload your custom code, you can use your favorite FTP client or the WP Plugin Editor.

Usage Example 1 – Simple MainWP Customisation

In this example, I will show you how you can easily rename the MainWP admin menu header and reflect your own company title in your centralized WordPress management Dashboard. Basically, instead of having the “MainWP” in the WP Admin Menu:

MainWP Admin Menu Header

add the following code snippet in the functions.php file in the MainWP Customisations plugin:

add_action( 'admin_head', 'mycustom_menu_admin_head' );
function mycustom_menu_admin_head() {
    global $menu;
    foreach($menu as &$item) {
        if ($item[2] == 'mainwp_tab') {
            $item[0] = 'Demo Header';
            break;
        }
    }
}

and you will have your custom header:

Click here to get this code snippet!

Usage Example 2 – Cosmetic Updates

In this example, let’s make some style updates to see how you can easily customize your MainWP Dashboard to your needs. First, let’s remove some element that you don’t need and you feel that it’s just crowding the interface. Hm, let’s say that you already have all MainWP Extensions so you don’t need the “Get the new extensions” button on the Overview page:

Remove the Get new extensions button

Simply add this CSS code to the mainwp-custom-style.css file in the MainWP Customisations plugin:

#mainwp-welocme-bar a.button-primary {
    display: none;
}

and the button is gone!

Get new extensions button removed

Usage Example 3 – Custom Column in the Sites table

Let’s try to make one more complex custom update. In this example, I will show you how to create a custom column in the Sites table and show child site WP version in it. First, let’s create the column by inserting the following code snippet in the functions.php file in the MainWP Customisations plugin:

add_filter( 'mainwp-sitestable-getcolumns', 'mycustom_sites_table_column', 10 );
function mycustom_sites_table_column( $cols ) {
     $cols['wpversion'] = 'WP Version';
     return $cols;
}

This code will create the WP Version column. After that, we need to show the actual version number for each child site. This, we will accomplish by adding this code snippet to the file right after the previously added one:

add_filter( 'mainwp-sitestable-item', 'mycustom_sitestable_item', 10 );
function mycustom_sitestable_item( $item ) {
     $options = apply_filters( 'mainwp_getwebsiteoptions', array(), $item['id'], 'site_info' );
     $website_info = json_decode( $options, true );
     if ( is_array( $website_info ) && isset( $website_info['wpversion' ] ) ) {
          $item[ 'wpversion' ] = $website_info[ 'wpversion' ];
     } else {
          $item[ 'wpversion' ] = '';
     }
     return $item;
}

That’s it! See how it looks:

WP Version Column

Click here to get this code snippet!

Remember the possibilities are endless. By using the provided hooks, you will be able to tailor your MainWP Dashboard to your needs. Of course, it requires some coding skills, but there is also the MainWP Codex as a functions reference to help you get started.

Get MainWP News and Notifications

Bogdan Rapaic on FacebookBogdan Rapaic on Twitter
Bogdan Rapaic
Lead Designer and Support at MainWP
Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.