MainWP Customisations

MainWP Customisations

The beauty of open source lies in the fact that code is open and can always be tweaked, modified, and customized to your needs. The ability to customize 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.

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 PHP section of the MainWP Custom Dashboard Extension:

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!

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 elements 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

Add the following code snippet in the CSS section of the MainWP Custom Dashboard Extension:

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

and the button is gone!

Get new extensions button removed

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 PHP section of the MainWP Custom Dashboard Extension:

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.

0 thoughts on “MainWP Customisations”

  1. Using example 3, how does one add a column showing the currently active theme for each child site?

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.