doutai1509 2019-04-18 12:40
浏览 33

无法在外部php文件上加载多个WordPress网站

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.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图
    • ¥15 关于大棚监测的pcb板设计
    • ¥15 stm32开发clion时遇到的编译问题
    • ¥15 lna设计 源简并电感型共源放大器
    • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
    • ¥15 Vue3地图和异步函数使用
    • ¥15 C++ yoloV5改写遇到的问题
    • ¥20 win11修改中文用户名路径
    • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入