diff --git a/mainwp-example-extension.php b/mainwp-example-extension.php
index 848c95a..d0fa74a 100644
--- a/mainwp-example-extension.php
+++ b/mainwp-example-extension.php
@@ -6,17 +6,17 @@
Version: 1.0
Author: MainWP
Author URI: https://mainwp.com
-Icon URI:
+Icon URI:
*/
class MainWPExampleExtension
{
-
+
public function __construct()
{
add_action('init', array(&$this, 'init'));
add_action('admin_init', array(&$this, 'admin_init'));
}
-
+
public function init()
{
@@ -26,17 +26,17 @@ public function init()
* Create your extension page
*/
- public function renderPage() {
+ public static function renderPage() {
global $mainWPExampleExtensionActivator;
- // Fetch all child-sites
- $websites = apply_filters('mainwp-getsites', $mainWPExampleExtensionActivator->getChildFile(), $mainWPExampleExtensionActivator->getChildKey(), null);
-
+ // Fetch all child-sites
+ $websites = apply_filters('mainwp-getsites', $mainWPExampleExtensionActivator->getChildFile(), $mainWPExampleExtensionActivator->getChildKey(), null);
+
// Location to open on child site
- $location = "admin.php?page=mainwp_child_tab";
-
+ $location = "admin.php?page=mainwp_child_tab";
+
if (is_array($websites)) {
- ?>
+ ?>
@@ -54,71 +54,71 @@ public function renderPage() {
-
.
-
- " class="queue" target="_blank">.
+
+
-
+
-
+
-
+
- getChildFile(), $mainWPExampleExtensionActivator->getChildKey(), $websiteId);
+ $websiteId = $_GET['siteid'];
+ //fetch information of one child-site
+ $website = apply_filters('mainwp-getsites', $mainWPExampleExtensionActivator->getChildFile(), $mainWPExampleExtensionActivator->getChildKey(), $websiteId);
if ($website && is_array($website)) {
$website = current($website);
- }
+ }
if (!$website) {
echo "
ERROR: ". __('Child Site Not Found') ."
";
} else {
// Example to call function get_all_posts on child-plugin to get posts on child site
- $post_data = array(
+ $post_data = array(
'status' => 'publish',
'maxRecords' => 10
);
// hook to call the function get_all_posts
- $information = apply_filters('mainwp_fetchurlauthed', $mainWPExampleExtensionActivator->getChildFile(), $mainWPExampleExtensionActivator->getChildKey(), $websiteId, 'get_all_posts', $post_data);
-
+ $information = apply_filters('mainwp_fetchurlauthed', $mainWPExampleExtensionActivator->getChildFile(), $mainWPExampleExtensionActivator->getChildKey(), $websiteId, 'get_all_posts', $post_data);
+
if (is_array($information)) {
if (isset($information['error'])) {
echo "
ERROR: " . $information['error'] . "
";
- } else {
+ } else {
echo "
"._('List of posts: ')."
";
echo "
";
foreach($information as $post) {
echo "- ";
echo $post['title'];
- ?>
+ ?>
- ";
}
echo "
";
}
- }
+ }
}
- }
-
+ }
+
} else {
echo "Child Sites Not Found";
}
@@ -127,10 +127,10 @@ public function renderPage() {
childFile = __FILE__;
add_filter('mainwp-getextensions', array(&$this, 'get_this_extension'));
-
+
// This filter will return true if the main plugin is activated
$this->mainwpMainActivated = apply_filters('mainwp-activated-check', false);
@@ -170,8 +170,8 @@ public function __construct()
}
else
{
- //Because sometimes our main plugin is activated after the extension plugin is activated we also have a second step,
- //listening to the 'mainwp-activated' action. This action is triggered by MainWP after initialisation.
+ //Because sometimes our main plugin is activated after the extension plugin is activated we also have a second step,
+ //listening to the 'mainwp-activated' action. This action is triggered by MainWP after initialisation.
add_action('mainwp-activated', array(&$this, 'activate_this_plugin'));
}
add_action('admin_init', array(&$this, 'admin_init'));
@@ -184,9 +184,9 @@ function admin_init() {
delete_option('mainwp_example_extension_activated');
wp_redirect(admin_url('admin.php?page=Extensions'));
return;
- }
+ }
}
-
+
function get_this_extension($pArray)
{
$pArray[] = array('plugin' => __FILE__, 'api' => 'mainwp-example-extension', 'mainwp' => false, 'callback' => array(&$this, 'settings'));
@@ -195,7 +195,7 @@ function get_this_extension($pArray)
function settings()
{
- //The "mainwp-pageheader-extensions" action is used to render the tabs on the Extensions screen.
+ //The "mainwp-pageheader-extensions" action is used to render the tabs on the Extensions screen.
//It's used together with mainwp-pagefooter-extensions and mainwp-getextensions
do_action('mainwp-pageheader-extensions', __FILE__);
if ($this->childEnabled)
@@ -208,17 +208,17 @@ function settings()
}
do_action('mainwp-pagefooter-extensions', __FILE__);
}
-
- //The function "activate_this_plugin" is called when the main is initialized.
+
+ //The function "activate_this_plugin" is called when the main is initialized.
function activate_this_plugin()
{
//Checking if the MainWP plugin is enabled. This filter will return true if the main plugin is activated.
$this->mainwpMainActivated = apply_filters('mainwp-activated-check', $this->mainwpMainActivated);
-
- // The 'mainwp-extension-enabled-check' hook. If the plugin is not enabled this will return false,
- // if the plugin is enabled, an array will be returned containing a key.
+
+ // The 'mainwp-extension-enabled-check' hook. If the plugin is not enabled this will return false,
+ // if the plugin is enabled, an array will be returned containing a key.
// This key is used for some data requests to our main
- $this->childEnabled = apply_filters('mainwp-extension-enabled-check', __FILE__);
+ $this->childEnabled = apply_filters('mainwp-extension-enabled-check', __FILE__);
$this->childKey = $this->childEnabled['key'];