We are hosting multiple websites on a single server where I want to load all websites plugin on an external PHP file. I'm reading all websites Url and hosting directory path from host config file. And running PHP foreach
where I'm passing require(wp-load.php) for each website but its loading only first websites and the plugin list shows is for first website only. I'm fetching plugins from get_plugins() function.
This is for AWS server and using PHP, MySql.
class Plugininfo{
function EachSiteData($home_url,$abspath){
if (is_file($abspath."/wordpress/wp-load.php")){
define( 'WP_USE_THEMES', false );
require_once($abspath."/wordpress/wp-load.php"); //Here it load only first website I tried to echo home url but it shows only first websites url.
if ( ! function_exists( 'get_plugins' ) ) {
$pluginfile_path= $abspath.'/wordpress/wp-admin/includes/plugin.php';
require_once $pluginfile_path;
}
$all_plugins=array();
$all_plugins = get_plugins();
foreach($all_plugins as $url => $plugins){
//Code to list all websites // currently its showing for first website
}
} //close function
}//close class
$server; //Is an array where I'm storing website's url in key and host path in value.
foreach ($servers as $key => $value) { //Creating object for each website
$PlugininfoObject= new Plugininfo();
$eachsite_data=$PlugininfoObject->EachSiteData($key,$value);
$PlugininfoObject->DatabaseOperations($eachsite_data[0],$eachsite_data[1]);
$PlugininfoObject->destroy();
unset($PlugininfoObject);
}
//Problem is it is loading only first website not which are present in last foreach loop.
Expected result: It will load all wordpress and give all websites plugin list with their status. All websites are on single server only.