WordPress – How to load a plugin(LiveChat) after the theme

Load LiveChat on a specific or single site on multisite wordpress or any plugin you want

The following tip is a custom solution for wordpress LiveChat. By default live chat loads on every page and every website on a multisite wordpress installation. After wrapping the language check the in the LiveChat initiator file I found that the value was not available to the plugins php file. So I moved the LiveChat initiator code into a function and added the action
add_action( 'after_setup_theme', 'function_name' );

After adding this action I got the desired value for the $_GET[‘lang’] language check.
Following code may help someone that I used on LiveChat Plugin -> livechat.php

add_action( 'after_setup_theme', 'load_live_chat_last' );
function load_live_chat_last (){
 if ($_GET['lang'] == 'en-us') {
  if (is_admin()) {
   require_once(dirname(__FILE__).'/plugin_files/LiveChatAdmin.class.php');
   LiveChatAdmin::get_instance();
  }
  else {
   require_once(dirname(__FILE__).'/plugin_files/LiveChat.class.php');
   LiveChat::get_instance();
  }
 }
}

You can also load LiveChat plugin on a specific or single page by adding url path check as below,

function load_live_chat_last (){
 if ($_GET['lang'] == 'en-us') {
  if($_SERVER['REQUEST_URI'] == "/support/") {
   if (is_admin()) {
    require_once(dirname(__FILE__).'/plugin_files/LiveChatAdmin.class.php');
     LiveChatAdmin::get_instance();
   }
   else {
    require_once(dirname(__FILE__).'/plugin_files/LiveChat.class.php');
    LiveChat::get_instance();
   }
  }
 }
}