Unable to retrieve data from multiple Wordpress websites on same server
I am trying to retrieve data from multiple client Wordpress websites on a single php page. So I can monitor all these websites without going through each one.
I am able to display data from one single website. Like this, I am listing all plugin installed on one Wordpress.
?php
require( './domain1/wp-blog-header.php' );
if ( ! function_exists( 'get_plugins' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$plugins = get_plugins();
echo 'h1 ' . get_bloginfo( 'name' ) . '/h1';
foreach ( $plugins as $plugin ) {
echo $plugin['Name'] . 'br /';
}
?
This works fine as I want. But when I try to do this for multiple website, it does not work but shows data from first website multiple times.
?php
$websites = array( 'domain1', 'domain2', 'domain3', 'domain4', 'domain5', 'domain6' );
foreach ( $websites as $website ) {
$file = './' . $website . '/wp-blog-header.php';
require( $file );
if ( ! function_exists( 'get_plugins' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$plugins = get_plugins();
echo 'h1 ' . get_bloginfo( 'name' ) . '/h1';
foreach ( $plugins as $plugin ) {
echo $plugin['Name'] . 'br /';
}
}
?
Why it's only showing details from first domain only? What am I doing wrong? Can someone help me with this.
Thanks.
Topic get-plugin-data customization Wordpress
Category Web