Example #1
0
    public static function render()
    {
        $current_wpid = MainWPUtility::get_current_wpid();
        if (!MainWPUtility::ctype_digit($current_wpid)) {
            return;
        }
        $website = MainWPDB::Instance()->getWebsiteById($current_wpid, true);
        ?>
        <div id="mainwp-notes-area">
            <div id="mainwp-notes-note" style="padding-bottom: 1em;">
                <?php 
        if ($website->note == '') {
            echo "No Saved Notes";
        } else {
            echo $website->note;
        }
        ?>
            </div>
            <div style="text-align: center; border-top: 1px Solid #f4f4f4; padding-top: 1em;">
                <a href="#" class="mainwp_notes_show_all button button-primary" id="mainwp_notes_<?php 
        echo $website->id;
        ?>
"><?php 
        _e('Edit Notes', 'mainwp');
        ?>
</a>
            </div>
        </div>
    <?php 
    }
    public static function renderSites()
    {
        $globalView = true;
        $current_wpid = MainWPUtility::get_current_wpid();
        if ($current_wpid) {
            $sql = MainWPDB::Instance()->getSQLWebsiteById($current_wpid);
            $globalView = false;
        } else {
            $sql = MainWPDB::Instance()->getSQLWebsitesForCurrentUser();
        }
        $websites = MainWPDB::Instance()->query($sql);
        if (!$websites) {
            return;
        }
        $userExtension = MainWPDB::Instance()->getUserExtension();
        $total_themesIgnored = $total_pluginsIgnored = 0;
        if ($globalView) {
            $decodedIgnoredPlugins = json_decode($userExtension->ignored_plugins, true);
            $decodedIgnoredThemes = json_decode($userExtension->ignored_themes, true);
            $total_pluginsIgnored = is_array($decodedIgnoredPlugins) ? count($decodedIgnoredPlugins) : 0;
            $total_themesIgnored = is_array($decodedIgnoredThemes) ? count($decodedIgnoredThemes) : 0;
        }
        $globalIgnoredPluginConflicts = json_decode($userExtension->ignored_pluginConflicts, true);
        if (!is_array($globalIgnoredPluginConflicts)) {
            $globalIgnoredPluginConflicts = array();
        }
        $globalIgnoredThemeConflicts = json_decode($userExtension->ignored_themeConflicts, true);
        if (!is_array($globalIgnoredThemeConflicts)) {
            $globalIgnoredThemeConflicts = array();
        }
        $total_wp_upgrades = 0;
        $total_plugin_upgrades = 0;
        $total_theme_upgrades = 0;
        $total_sync_errors = 0;
        $total_uptodate = 0;
        $total_offline = 0;
        $total_conflict = 0;
        $allPlugins = array();
        $pluginsInfo = array();
        $allThemes = array();
        $themesInfo = array();
        @MainWPDB::data_seek($websites, 0);
        $currentSite = null;
        $pluginsIgnored_perSites = $themesIgnored_perSites = array();
        while ($websites && ($website = @MainWPDB::fetch_object($websites))) {
            if (!$globalView) {
                $currentSite = $website;
            }
            $wp_upgrades = json_decode(MainWPDB::Instance()->getWebsiteOption($website, 'wp_upgrades'), true);
            if ($website->is_ignoreCoreUpdates) {
                $wp_upgrades = array();
            }
            if (is_array($wp_upgrades) && count($wp_upgrades) > 0) {
                $total_wp_upgrades++;
            }
            $plugin_upgrades = json_decode($website->plugin_upgrades, true);
            if ($website->is_ignorePluginUpdates) {
                $plugin_upgrades = array();
            }
            $theme_upgrades = json_decode($website->theme_upgrades, true);
            if ($website->is_ignoreThemeUpdates) {
                $theme_upgrades = array();
            }
            $decodedPremiumUpgrades = json_decode(MainWPDB::Instance()->getWebsiteOption($website, 'premium_upgrades'), true);
            if (is_array($decodedPremiumUpgrades)) {
                foreach ($decodedPremiumUpgrades as $crrSlug => $premiumUpgrade) {
                    $premiumUpgrade['premium'] = true;
                    if ($premiumUpgrade['type'] == 'plugin') {
                        if (!is_array($plugin_upgrades)) {
                            $plugin_upgrades = array();
                        }
                        if (!$website->is_ignorePluginUpdates) {
                            $plugin_upgrades[$crrSlug] = $premiumUpgrade;
                        }
                    } else {
                        if ($premiumUpgrade['type'] == 'theme') {
                            if (!is_array($theme_upgrades)) {
                                $theme_upgrades = array();
                            }
                            if (!$website->is_ignoreThemeUpdates) {
                                $theme_upgrades[$crrSlug] = $premiumUpgrade;
                            }
                        }
                    }
                }
            }
            if (is_array($plugin_upgrades)) {
                $ignored_plugins = json_decode($website->ignored_plugins, true);
                if (is_array($ignored_plugins)) {
                    $plugin_upgrades = array_diff_key($plugin_upgrades, $ignored_plugins);
                }
                $ignored_plugins = json_decode($userExtension->ignored_plugins, true);
                if (is_array($ignored_plugins)) {
                    $plugin_upgrades = array_diff_key($plugin_upgrades, $ignored_plugins);
                }
                $total_plugin_upgrades += count($plugin_upgrades);
            }
            if (is_array($theme_upgrades)) {
                $ignored_themes = json_decode($website->ignored_themes, true);
                if (is_array($ignored_themes)) {
                    $theme_upgrades = array_diff_key($theme_upgrades, $ignored_themes);
                }
                $ignored_themes = json_decode($userExtension->ignored_themes, true);
                if (is_array($ignored_themes)) {
                    $theme_upgrades = array_diff_key($theme_upgrades, $ignored_themes);
                }
                $total_theme_upgrades += count($theme_upgrades);
            }
            $ignored_plugins = json_decode($website->ignored_plugins, true);
            $ignored_themes = json_decode($website->ignored_themes, true);
            if (is_array($ignored_plugins)) {
                $ignored_plugins = array_filter($ignored_plugins);
                $pluginsIgnored_perSites = array_merge($pluginsIgnored_perSites, $ignored_plugins);
            }
            if (is_array($ignored_themes)) {
                $ignored_themes = array_filter($ignored_themes);
                $themesIgnored_perSites = array_merge($themesIgnored_perSites, $ignored_themes);
            }
            if ($userExtension->site_view == 0) {
                //Keep track of all the plugins & themes
                if (is_array($plugin_upgrades)) {
                    foreach ($plugin_upgrades as $slug => $plugin_upgrade) {
                        if (!isset($allPlugins[$slug])) {
                            $allPlugins[$slug] = 1;
                        } else {
                            $allPlugins[$slug]++;
                        }
                        $pluginsInfo[$slug] = array('name' => $plugin_upgrade['Name'], 'slug' => $plugin_upgrade['update']['slug'], 'premium' => isset($plugin_upgrade['premium']) ? $plugin_upgrade['premium'] : 0);
                    }
                }
                ksort($allPlugins);
                if (is_array($theme_upgrades)) {
                    foreach ($theme_upgrades as $slug => $theme_upgrade) {
                        if (!isset($allThemes[$slug])) {
                            $allThemes[$slug] = 1;
                        } else {
                            $allThemes[$slug]++;
                        }
                        $themesInfo[$slug] = array('name' => $theme_upgrade['Name'], 'premium' => isset($theme_upgrade['premium']) ? $theme_upgrade['premium'] : 0);
                    }
                }
                ksort($allThemes);
            }
            if ($website->sync_errors != '') {
                $total_sync_errors++;
            }
            if ($website->uptodate == 1) {
                $total_uptodate++;
            }
            if ($website->offline_check_result == -1) {
                $total_offline++;
            }
            $pluginConflicts = json_decode($website->pluginConflicts, true);
            $themeConflicts = json_decode($website->themeConflicts, true);
            $ignoredPluginConflicts = json_decode($website->ignored_pluginConflicts, true);
            if (!is_array($ignoredPluginConflicts)) {
                $ignoredPluginConflicts = array();
            }
            $ignoredThemeConflicts = json_decode($website->ignored_themeConflicts, true);
            if (!is_array($ignoredThemeConflicts)) {
                $ignoredThemeConflicts = array();
            }
            $isConflict = false;
            if (count($pluginConflicts) > 0) {
                foreach ($pluginConflicts as $pluginConflict) {
                    if (!in_array($pluginConflict, $ignoredPluginConflicts) && !in_array($pluginConflict, $globalIgnoredPluginConflicts)) {
                        $isConflict = true;
                    }
                }
            }
            if (!$isConflict && count($themeConflicts) > 0) {
                foreach ($themeConflicts as $themeConflict) {
                    if (!in_array($themeConflict, $ignoredThemeConflicts) && !in_array($themeConflict, $globalIgnoredThemeConflicts)) {
                        $isConflict = true;
                    }
                }
            }
            if ($isConflict) {
                $total_conflict++;
            }
        }
        $errorsDismissed = get_user_option('mainwp_syncerrors_dismissed');
        ?>
    <div class="clear">
        <div id="mainwp-right-now-message" class="mainwp-right-now-error" <?php 
        if ($total_sync_errors <= 0 || $globalView && $errorsDismissed) {
            echo ' style="display: none;"';
        }
        ?>
>
            <p>
                <?php 
        if ($globalView) {
            ?>
                        <span id="mainwp-right-now-message-content"><?php 
            echo $total_sync_errors;
            ?>
 <?php 
            echo _n('Site Timed Out / Errored', 'Sites Timed Out / Errored', $total_sync_errors, 'mainwp');
            ?>
 (There was an error syncing some of your sites. <a href="http://docs.mainwp.com/sync-error/">Please check this help doc for possible solutions.</a>)</span><span style="float: right;"><a href="#" id="mainwp-right-now-message-dismiss"><i class="fa fa-times-circle"></i> <?php 
            _e('Dismiss', 'mainwp');
            ?>
</a></span>
                <?php 
        } else {
            ?>
                    <span id="mainwp-right-now-message-content"><a href="<?php 
            echo admin_url('admin.php?page=managesites&dashboard=' . $currentSite->id);
            ?>
"><?php 
            echo stripslashes($currentSite->name);
            ?>
</a> <?php 
            _e('Timed Out / Errored', 'mainwp');
            ?>
 (There was an error syncing some of your sites. <a href="http://docs.mainwp.com/sync-error/">Please check this help doc for possible solutions.</a>)</span>
                <?php 
        }
        ?>
            </p>
        </div>
    </div>
    <?php 
        $total_pluginsIgnored += count($pluginsIgnored_perSites);
        $total_themesIgnored += count($themesIgnored_perSites);
        //WP Upgrades part:
        $total_upgrades = $total_wp_upgrades + $total_plugin_upgrades + $total_theme_upgrades;
        ?>
    
    <div class="clear">
        <div class="mainwp-row-top">
            <span class="mainwp-left-col"><span class="mainwp-rightnow-number"><?php 
        echo $total_upgrades;
        ?>
</span> <?php 
        _e('Upgrade', 'mainwp');
        if (count($total_upgrades) > 1) {
            ?>
s<?php 
        }
        ?>
 <?php 
        _e('available', 'mainwp');
        ?>
</span>
            <span class="mainwp-mid-col">&nbsp;</span>
            <?php 
        if (mainwp_current_user_can("dashboard", "update_wordpress") && mainwp_current_user_can("dashboard", "update_plugins") && mainwp_current_user_can("dashboard", "update_themes")) {
            ?>
            <span class="mainwp-right-col"><?php 
            if ($total_upgrades == 0) {
                ?>
<a class="button" disabled="disabled"><?php 
                _e('Upgrade Everything', 'mainwp');
                ?>
</a><?php 
            } else {
                ?>
<a href="#" onClick="return rightnow_global_upgrade_all();" class="mainwp-upgrade-button button"><?php 
                _e('Upgrade Everything', 'mainwp');
                ?>
</a><?php 
            }
            ?>
</span>
            <?php 
        }
        ?>
        </div>
    </div>
    <div class="clear">        
        <div class="mainwp-row">
            <span class="mainwp-left-col"><span class="mainwp-rightnow-number"><?php 
        echo $total_wp_upgrades;
        ?>
</span> <?php 
        _e('WordPress upgrade', 'mainwp');
        if (count($total_wp_upgrades) > 1) {
            ?>
s<?php 
        }
        ?>
 <?php 
        _e('available', 'mainwp');
        ?>
</span>
            <span class="mainwp-mid-col">&nbsp;</span>
            <span class="mainwp-right-col">
                <a href="#" id="mainwp_upgrades_show" onClick="return rightnow_show('upgrades');"><i class="fa fa-eye-slash"></i> <?php 
        _e('Show', 'mainwp');
        ?>
</a>
                <?php 
        if (mainwp_current_user_can("dashboard", "update_wordpress")) {
            if ($total_wp_upgrades > 0) {
                ?>
                    &nbsp; <a href="#" onClick="return rightnow_wordpress_global_upgrade_all();" class="button-primary"><?php 
                echo _n('Upgrade', 'Upgrade All', $total_wp_upgrades, 'mainwp');
                ?>
</a>
                        <?php 
            } else {
                ?>
                    &nbsp; <a class="button" disabled="disabled"><?php 
                _e('No Upgrades', 'mainwp');
                ?>
</a> <?php 
            }
            ?>
 
                <?php 
        }
        ?>
            </span>
        </div>
        <div id="wp_upgrades" style="display: none">
            <?php 
        @MainWPDB::data_seek($websites, 0);
        while ($websites && ($website = @MainWPDB::fetch_object($websites))) {
            if ($website->is_ignoreCoreUpdates) {
                continue;
            }
            $wp_upgrades = json_decode(MainWPDB::Instance()->getWebsiteOption($website, 'wp_upgrades'), true);
            if (count($wp_upgrades) == 0 && $website->sync_errors == '') {
                continue;
            }
            ?>
                <div class="mainwp-row mainwp_wordpress_upgrade" site_id="<?php 
            echo $website->id;
            ?>
" site_name="<?php 
            echo rawurlencode($website->name);
            ?>
" updated="<?php 
            echo count($wp_upgrades) > 0 ? '0' : '1';
            ?>
">
                    <span class="mainwp-left-col"><a href="<?php 
            echo admin_url('admin.php?page=managesites&dashboard=' . $website->id);
            ?>
"><?php 
            echo stripslashes($website->name);
            ?>
</a><input type="hidden" id="wp_upgraded_<?php 
            echo $website->id;
            ?>
" value="<?php 
            if (count($wp_upgrades) > 0) {
                echo '0';
            } else {
                echo '1';
            }
            ?>
"/></span>
                    <span class="mainwp-mid-col wordpressInfo" id="wp_upgrade_<?php 
            echo $website->id;
            ?>
"><?php 
            if (count($wp_upgrades) > 0) {
                echo $wp_upgrades['current'] . " to " . $wp_upgrades['new'];
            } else {
                if ($website->sync_errors != '') {
                    echo __('Site Error - No update Information available', 'mainwp');
                } else {
                    echo __("Hooray, No Updates Available!", 'mainwp');
                }
            }
            ?>
</span>
                    <span class="mainwp-right-col wordpressAction"><div id="wp_upgradebuttons_<?php 
            echo $website->id;
            ?>
">
                        <?php 
            if (mainwp_current_user_can("dashboard", "update_wordpress")) {
                if (count($wp_upgrades) > 0) {
                    ?>
                                    <a href="#" class="mainwp-upgrade-button button" onClick="rightnow_upgrade(<?php 
                    echo $website->id;
                    ?>
)"><?php 
                    _e('Upgrade', 'mainwp');
                    ?>
</a>
                                <?php 
                }
            }
            ?>
   
                        &nbsp; <a href="<?php 
            echo $website->url;
            ?>
" target="_blank" class="mainwp-open-button button" ><?php 
            _e('Open', 'mainwp');
            ?>
</a></div></span>
                </div>
            <?php 
        }
        ?>
        </div>
    </div>

    <?php 
        //WP plugin upgrades!
        ?>
    <div class="clear">
        <div class="mainwp-row">
            <span class="mainwp-left-col"><span class="mainwp-rightnow-number"><?php 
        echo $total_plugin_upgrades;
        ?>
 </span> <?php 
        _e('Plugin upgrade', 'mainwp');
        if ($total_plugin_upgrades > 1) {
            ?>
s<?php 
        }
        ?>
 <?php 
        _e('available', 'mainwp');
        ?>
</span>
            <span class="mainwp-mid-col"><a href="<?php 
        echo admin_url('admin.php?page=PluginsIgnore');
        ?>
"><?php 
        _e('Ignored', 'mainwp');
        ?>
 (<?php 
        echo $total_pluginsIgnored;
        ?>
)</a></span>            
            <span class="mainwp-right-col"><a href="#" id="mainwp_plugin_upgrades_show" onClick="return rightnow_show('plugin_upgrades');"><i class="fa fa-eye-slash"></i> <?php 
        _e('Show', 'mainwp');
        ?>
</a> <?php 
        if (mainwp_current_user_can("dashboard", "update_plugins")) {
            if ($total_plugin_upgrades > 0 && $userExtension->site_view == 1) {
                ?>
&nbsp; <a href="#" onClick="return rightnow_plugins_global_upgrade_all();" class="button-primary"><?php 
                echo _n('Upgrade', 'Upgrade All', $total_plugin_upgrades, 'mainwp');
                ?>
</a><?php 
            } else {
                if ($total_plugin_upgrades > 0 && $userExtension->site_view == 0) {
                    ?>
&nbsp; <a href="#" onClick="return rightnow_plugins_global_upgrade_all();" class="button-primary"><?php 
                    echo _n('Upgrade', 'Upgrade All', $total_plugin_upgrades, 'mainwp');
                    ?>
</a><?php 
                } else {
                    ?>
 &nbsp; <a class="button" disabled="disabled"><?php 
                    _e('No Upgrades', 'mainwp');
                    ?>
</a> <?php 
                }
            }
        }
        ?>
</span>
            
        </div>
        <div id="wp_plugin_upgrades" style="display: none">
            <?php 
        if ($userExtension->site_view == 1) {
            @MainWPDB::data_seek($websites, 0);
            while ($websites && ($website = @MainWPDB::fetch_object($websites))) {
                if ($website->is_ignorePluginUpdates) {
                    continue;
                }
                $plugin_upgrades = json_decode($website->plugin_upgrades, true);
                $decodedPremiumUpgrades = json_decode(MainWPDB::Instance()->getWebsiteOption($website, 'premium_upgrades'), true);
                if (is_array($decodedPremiumUpgrades)) {
                    foreach ($decodedPremiumUpgrades as $crrSlug => $premiumUpgrade) {
                        $premiumUpgrade['premium'] = true;
                        if ($premiumUpgrade['type'] == 'plugin') {
                            if (!is_array($plugin_upgrades)) {
                                $plugin_upgrades = array();
                            }
                            $plugin_upgrades[$crrSlug] = $premiumUpgrade;
                        }
                    }
                }
                $ignored_plugins = json_decode($website->ignored_plugins, true);
                if (is_array($ignored_plugins)) {
                    $plugin_upgrades = array_diff_key($plugin_upgrades, $ignored_plugins);
                }
                $ignored_plugins = json_decode($userExtension->ignored_plugins, true);
                if (is_array($ignored_plugins)) {
                    $plugin_upgrades = array_diff_key($plugin_upgrades, $ignored_plugins);
                }
                if ($globalView) {
                    ?>
                <div class="mainwp-row">
                    <span class="mainwp-left-col"><a href="<?php 
                    echo admin_url('admin.php?page=managesites&dashboard=' . $website->id);
                    ?>
"><?php 
                    echo stripslashes($website->name);
                    ?>
</a><input type="hidden" id="wp_upgraded_plugin_<?php 
                    echo $website->id;
                    ?>
" value="<?php 
                    if (count($plugin_upgrades) > 0) {
                        echo '0';
                    } else {
                        echo '1';
                    }
                    ?>
"/></span>
                    <span class="mainwp-mid-col" id="wp_upgrade_plugin_<?php 
                    echo $website->id;
                    ?>
">
                        <?php 
                    if (count($plugin_upgrades) > 0) {
                        ?>
                            <a href="#" id="mainwp_plugin_upgrades_<?php 
                        echo $website->id;
                        ?>
_show" onClick="return rightnow_show('plugin_upgrades_<?php 
                        echo $website->id;
                        ?>
', true);"><?php 
                        echo count($plugin_upgrades);
                        ?>
 <?php 
                        _e('Upgrade', 'mainwp');
                        echo count($plugin_upgrades) > 1 ? 's' : '';
                        ?>
</a>
                        <?php 
                    } else {
                        if ($website->sync_errors != '') {
                            echo __('Site Error - No update Information available', 'mainwp');
                        } else {
                            echo __("Hooray, No Updates Available!", 'mainwp');
                        }
                    }
                    ?>
                    </span>
                    <span class="mainwp-right-col"><div id="wp_upgradebuttons_plugin_<?php 
                    echo $website->id;
                    ?>
">
                        <?php 
                    if (mainwp_current_user_can("dashboard", "update_plugins")) {
                        if (count($plugin_upgrades) > 0) {
                            ?>
                                    <a href="#" class="mainwp-upgrade-button button" onClick="return rightnow_upgrade_plugin_all(<?php 
                            echo $website->id;
                            ?>
)"><?php 
                            echo _n('Upgrade', 'Upgrade All', count($plugin_upgrades), 'mainwp');
                            ?>
</a> &nbsp;                                 
                            <?php 
                        }
                        ?>
                        <?php 
                    }
                    ?>
                            <a href="<?php 
                    echo $website->url;
                    ?>
" target="_blank" class="mainwp-open-button button"><?php 
                    _e('Open', 'mainwp');
                    ?>
</a>
                    </div></span>
                </div>
                <?php 
                }
                ?>
                <div id="wp_plugin_upgrades_<?php 
                echo $website->id;
                ?>
" site_id="<?php 
                echo $website->id;
                ?>
" site_name="<?php 
                echo rawurlencode($website->name);
                ?>
" <?php 
                if ($globalView) {
                    ?>
style="display: none"<?php 
                }
                ?>
>
                    <?php 
                foreach ($plugin_upgrades as $plugin_name => $plugin_upgrade) {
                    $plugin_name = urlencode($plugin_name);
                    ?>
                        <div class="mainwp-row" plugin_slug="<?php 
                    echo $plugin_name;
                    ?>
" premium="<?php 
                    echo isset($plugin_upgrade['premium']) ? $plugin_upgrade['premium'] : 0 ? 1 : 0;
                    ?>
" updated="0">
                                <span class="mainwp-left-col">
                                    <?php 
                    if ($globalView) {
                        ?>
&nbsp;&nbsp;&nbsp;<?php 
                    }
                    ?>
<a href="<?php 
                    echo admin_url() . 'plugin-install.php?tab=plugin-information&plugin=' . $plugin_upgrade['update']['slug'] . '&url=' . (isset($plugin_upgrade['PluginURI']) ? rawurlencode($plugin_upgrade['PluginURI']) : '') . '&name=' . rawurlencode($plugin_upgrade['Name']) . '&TB_iframe=true&width=640&height=477';
                    ?>
" target="_blank"
                                                                                        class="thickbox" title="More information about <?php 
                    echo $plugin_upgrade['Name'];
                    ?>
"><?php 
                    echo $plugin_upgrade['Name'];
                    ?>
</a><input type="hidden" id="wp_upgraded_plugin_<?php 
                    echo $website->id;
                    ?>
_<?php 
                    echo $plugin_name;
                    ?>
" value="0"/></span>
                                <span class="mainwp-mid-col pluginsInfo" id="wp_upgrade_plugin_<?php 
                    echo $website->id;
                    ?>
_<?php 
                    echo $plugin_name;
                    ?>
"><?php 
                    echo $plugin_upgrade['Version'];
                    ?>
 to <?php 
                    echo $plugin_upgrade['update']['new_version'];
                    ?>
</span>
                                <span class="mainwp-right-col pluginsAction">
                                    <div id="wp_upgradebuttons_plugin_<?php 
                    echo $website->id;
                    ?>
_<?php 
                    echo $plugin_name;
                    ?>
">
                                    <?php 
                    if (mainwp_current_user_can("dashboard", "ignore_unignore_updates")) {
                        ?>
                                        <a href="#" onClick="return rightnow_plugins_ignore_detail('<?php 
                        echo $plugin_name;
                        ?>
', '<?php 
                        echo urlencode($plugin_upgrade['Name']);
                        ?>
', <?php 
                        echo $website->id;
                        ?>
)" class="button"><?php 
                        _e('Ignore', 'mainwp');
                        ?>
</a> 
                                    <?php 
                    }
                    ?>
                                    <?php 
                    if (mainwp_current_user_can("dashboard", "update_plugins")) {
                        ?>
                                         &nbsp;<a href="#" class="mainwp-upgrade-button button" onClick="return rightnow_upgrade_plugin(<?php 
                        echo $website->id;
                        ?>
, '<?php 
                        echo $plugin_name;
                        ?>
')"><?php 
                        _e('Upgrade', 'mainwp');
                        ?>
</a>
                                    <?php 
                    }
                    ?>
                                    </div>
                                </span>
                        </div>
                    <?php 
                }
                ?>
                </div>
                <?php 
            }
        } else {
            foreach ($allPlugins as $slug => $cnt) {
                $plugin_name = urlencode($slug);
                if ($globalView) {
                    ?>
                    <div class="mainwp-row">
                        <span class="mainwp-left-col">
                            <a href="<?php 
                    echo admin_url() . 'plugin-install.php?tab=plugin-information&plugin=' . $pluginsInfo[$slug]['slug'] . '&url=' . (isset($plugin_upgrade['PluginURI']) ? rawurlencode($plugin_upgrade['PluginURI']) : '') . '&name=' . rawurlencode($plugin_upgrade['Name']) . '&TB_iframe=true&width=640&height=477';
                    ?>
" target="_blank"
                                                                                                                        class="thickbox" title="More information about <?php 
                    echo $pluginsInfo[$slug]['name'];
                    ?>
">
                                <?php 
                    echo $pluginsInfo[$slug]['name'];
                    ?>
                            </a>
                        </span>
                        <span class="mainwp-mid-col">
                            <a href="#" onClick="return rightnow_plugins_detail('<?php 
                    echo $plugin_name;
                    ?>
');">
                                <?php 
                    echo $cnt;
                    ?>
 <?php 
                    _e('Upgrade', 'mainwp');
                    echo $cnt > 1 ? 's' : '';
                    ?>
                            </a>
                        </span>
                        <span class="mainwp-right-col">
                            <?php 
                    if (mainwp_current_user_can("dashboard", "ignore_unignore_updates")) {
                        ?>
                                <a href="#" class="button" onClick="return rightnow_plugins_ignore_all('<?php 
                        echo $plugin_name;
                        ?>
', '<?php 
                        echo urlencode($pluginsInfo[$slug]['name']);
                        ?>
')"><?php 
                        _e('Ignore Globally', 'mainwp');
                        ?>
</a>
                            <?php 
                    }
                    ?>
                            <?php 
                    if (mainwp_current_user_can("dashboard", "update_plugins")) {
                        ?>
                                &nbsp; <?php 
                        if ($cnt > 0) {
                            ?>
<a href="#" class="mainwp-upgrade-button button" onClick="return rightnow_plugins_upgrade_all('<?php 
                            echo $plugin_name;
                            ?>
', '<?php 
                            echo urlencode($pluginsInfo[$slug]['name']);
                            ?>
')"><?php 
                            echo _n('Upgrade', 'Upgrade All', $cnt, 'mainwp');
                            ?>
</a><?php 
                        } else {
                            ?>
 &nbsp; <a class="button" disabled="disabled"><?php 
                            _e('No Upgrades', 'mainwp');
                            ?>
</a> <?php 
                        }
                        ?>
                            
                            <?php 
                    }
                    ?>
                            
                        </span>
                    </div>
                    <?php 
                }
                ?>
                    <div plugin_slug="<?php 
                echo $plugin_name;
                ?>
" plugin_name="<?php 
                echo urlencode($pluginsInfo[$slug]['name']);
                ?>
" premium="<?php 
                echo $pluginsInfo[$slug]['premium'] ? 1 : 0;
                ?>
" <?php 
                if ($globalView) {
                    ?>
style="display: none"<?php 
                }
                ?>
>
                        <?php 
                @MainWPDB::data_seek($websites, 0);
                while ($websites && ($website = @MainWPDB::fetch_object($websites))) {
                    if ($website->is_ignorePluginUpdates) {
                        continue;
                    }
                    $plugin_upgrades = json_decode($website->plugin_upgrades, true);
                    $decodedPremiumUpgrades = json_decode(MainWPDB::Instance()->getWebsiteOption($website, 'premium_upgrades'), true);
                    if (is_array($decodedPremiumUpgrades)) {
                        foreach ($decodedPremiumUpgrades as $crrSlug => $premiumUpgrade) {
                            $premiumUpgrade['premium'] = true;
                            if ($premiumUpgrade['type'] == 'plugin') {
                                if (!is_array($plugin_upgrades)) {
                                    $plugin_upgrades = array();
                                }
                                $plugin_upgrades[$crrSlug] = $premiumUpgrade;
                            }
                        }
                    }
                    $ignored_plugins = json_decode($website->ignored_plugins, true);
                    if (is_array($ignored_plugins)) {
                        $plugin_upgrades = array_diff_key($plugin_upgrades, $ignored_plugins);
                    }
                    if (!isset($plugin_upgrades[$slug])) {
                        continue;
                    }
                    $plugin_upgrade = $plugin_upgrades[$slug];
                    ?>
                            <div class="mainwp-row" site_id="<?php 
                    echo $website->id;
                    ?>
" site_name="<?php 
                    echo rawurlencode($website->name);
                    ?>
" updated="0">
                                <span class="mainwp-left-col">
                                    <?php 
                    if ($globalView) {
                        ?>
                                    &nbsp;&nbsp;&nbsp;<a href="<?php 
                        echo admin_url('admin.php?page=managesites&dashboard=' . $website->id);
                        ?>
"><?php 
                        echo stripslashes($website->name);
                        ?>
</a>
                                    <?php 
                    } else {
                        ?>
                                        <a href="<?php 
                        echo admin_url() . 'plugin-install.php?tab=plugin-information&plugin=' . $pluginsInfo[$slug]['slug'] . '&TB_iframe=true&width=640&height=477';
                        ?>
" target="_blank"
                                                                                                                                    class="thickbox" title="More information about <?php 
                        echo $pluginsInfo[$slug]['name'];
                        ?>
">
                                            <?php 
                        echo $pluginsInfo[$slug]['name'];
                        ?>
                                        </a>
                                    <?php 
                    }
                    ?>
                                </span>
                                <span class="mainwp-mid-col pluginsInfo"><?php 
                    echo $plugin_upgrade['Version'];
                    ?>
 to <?php 
                    echo $plugin_upgrade['update']['new_version'];
                    ?>
</span>
                                <span class="mainwp-right-col pluginsAction">
                                    <?php 
                    if (mainwp_current_user_can("dashboard", "ignore_unignore_updates")) {
                        ?>
                                    <a href="#" class="button" onClick="return rightnow_plugins_ignore_detail('<?php 
                        echo $plugin_name;
                        ?>
', '<?php 
                        echo urlencode($plugin_upgrade['Name']);
                        ?>
', <?php 
                        echo $website->id;
                        ?>
)"><?php 
                        _e('Ignore', 'mainwp');
                        ?>
</a> 
                                    <?php 
                    }
                    ?>
                                    <?php 
                    if (mainwp_current_user_can("dashboard", "update_plugins")) {
                        ?>
                                    &nbsp; <a href="#" class="mainwp-upgrade-button button" onClick="return rightnow_plugins_upgrade('<?php 
                        echo $plugin_name;
                        ?>
', <?php 
                        echo $website->id;
                        ?>
)"><?php 
                        _e('Upgrade', 'mainwp');
                        ?>
</a>
                                    <?php 
                    }
                    ?>
                                </span>
                            </div>
                        <?php 
                }
                ?>
                    </div>
                    <?php 
            }
        }
        ?>
        </div>
    </div>
    
    <?php 
        //WP theme upgrades!
        ?>
    
    <div class="clear">
        <div class="mainwp-row">
            <span class="mainwp-left-col"><span class="mainwp-rightnow-number"><?php 
        echo $total_theme_upgrades;
        ?>
 </span> <?php 
        _e('Theme upgrade', 'mainwp');
        if ($total_theme_upgrades > 1) {
            ?>
s<?php 
        }
        ?>
 <?php 
        _e('available', 'mainwp');
        ?>
</span>
            <span class="mainwp-mid-col"><a href="<?php 
        echo admin_url('admin.php?page=ThemesIgnore');
        ?>
"><?php 
        _e('Ignored', 'mainwp');
        ?>
 (<?php 
        echo $total_themesIgnored;
        ?>
)</a></span>            
            <span class="mainwp-right-col"><a href="#" id="mainwp_theme_upgrades_show" onClick="return rightnow_show('theme_upgrades');"><i class="fa fa-eye-slash"></i> <?php 
        _e('Show', 'mainwp');
        ?>
</a> 
                <?php 
        if (mainwp_current_user_can("dashboard", "update_themes")) {
            ?>
                    <?php 
            if ($total_theme_upgrades > 0 && $userExtension->site_view == 1) {
                ?>
&nbsp; <a href="#" onClick="return rightnow_themes_global_upgrade_all();" class="button-primary"><?php 
                echo _n('Upgrade', 'Upgrade All', $total_theme_upgrades, 'mainwp');
                ?>
</a><?php 
            } else {
                if ($total_theme_upgrades > 0 && $userExtension->site_view == 0) {
                    ?>
&nbsp; <a href="#" onClick="return rightnow_themes_global_upgrade_all();" class="button-primary"><?php 
                    echo _n('Upgrade', 'Upgrade All', $total_theme_upgrades, 'mainwp');
                    ?>
</a><?php 
                } else {
                    ?>
 &nbsp; <a class="button" disabled="disabled"><?php 
                    _e('No Upgrades', 'mainwp');
                    ?>
</a> <?php 
                }
            }
            ?>
                <?php 
        }
        ?>
            </span>
                
        </div>
        <div id="wp_theme_upgrades" style="display: none">
            <?php 
        if ($userExtension->site_view == 1) {
            @MainWPDB::data_seek($websites, 0);
            while ($websites && ($website = @MainWPDB::fetch_object($websites))) {
                if ($website->is_ignoreThemeUpdates) {
                    continue;
                }
                $theme_upgrades = json_decode($website->theme_upgrades, true);
                $decodedPremiumUpgrades = json_decode(MainWPDB::Instance()->getWebsiteOption($website, 'premium_upgrades'), true);
                if (is_array($decodedPremiumUpgrades)) {
                    foreach ($decodedPremiumUpgrades as $crrSlug => $premiumUpgrade) {
                        $premiumUpgrade['premium'] = true;
                        if ($premiumUpgrade['type'] == 'theme') {
                            if (!is_array($theme_upgrades)) {
                                $theme_upgrades = array();
                            }
                            $theme_upgrades[$crrSlug] = $premiumUpgrade;
                        }
                    }
                }
                $ignored_themes = json_decode($website->ignored_themes, true);
                if (is_array($ignored_themes)) {
                    $theme_upgrades = array_diff_key($theme_upgrades, $ignored_themes);
                }
                $ignored_themes = json_decode($userExtension->ignored_themes, true);
                if (is_array($ignored_themes)) {
                    $theme_upgrades = array_diff_key($theme_upgrades, $ignored_themes);
                }
                if ($globalView) {
                    ?>
                <div class="mainwp-row">
                    <span class="mainwp-left-col"><a href="<?php 
                    echo admin_url('admin.php?page=managesites&dashboard=' . $website->id);
                    ?>
"><?php 
                    echo stripslashes($website->name);
                    ?>
</a><input type="hidden" id="wp_upgraded_theme_<?php 
                    echo $website->id;
                    ?>
" value="<?php 
                    if (count($theme_upgrades) > 0) {
                        echo '0';
                    } else {
                        echo '1';
                    }
                    ?>
"/></span>
                    <span class="mainwp-mid-col" id="wp_upgrade_theme_<?php 
                    echo $website->id;
                    ?>
">
                        <?php 
                    if (count($theme_upgrades) > 0) {
                        ?>
                            <a href="#" id="mainwp_theme_upgrades_<?php 
                        echo $website->id;
                        ?>
_show" onClick="return rightnow_show('theme_upgrades_<?php 
                        echo $website->id;
                        ?>
', true);"><?php 
                        echo count($theme_upgrades);
                        ?>
 <?php 
                        _e('Upgrade', 'mainwp');
                        echo count($theme_upgrades) > 1 ? 's' : '';
                        ?>
</a>
                        <?php 
                    } else {
                        if ($website->sync_errors != '') {
                            echo __('Site Error - No update Information available', 'mainwp');
                        } else {
                            echo __("Hooray, No Updates Available!", 'mainwp');
                        }
                    }
                    ?>
                    </span>
                    <span class="mainwp-right-col">
                        <div id="wp_upgradebuttons_theme_<?php 
                    echo $website->id;
                    ?>
"> 
                        <?php 
                    if (mainwp_current_user_can("dashboard", "update_themes")) {
                        ?>
                        <?php 
                        if (count($theme_upgrades) > 0) {
                            ?>
 
                            <a href="#" class="mainwp-upgrade-button button" onClick="return rightnow_upgrade_theme_all(<?php 
                            echo $website->id;
                            ?>
)"><?php 
                            echo _n('Upgrade', 'Upgrade All', count($theme_upgrades), 'mainwp');
                            ?>
</a> &nbsp; 
                                <?php 
                        }
                        ?>
                        <?php 
                    }
                    ?>
                            <a href="<?php 
                    echo $website->url;
                    ?>
" target="_blank" class="mainwp-open-button button"><?php 
                    _e('Open', 'mainwp');
                    ?>
</a>
                        </div>
                    </span>
                </div>
                <?php 
                }
                ?>
                <div id="wp_theme_upgrades_<?php 
                echo $website->id;
                ?>
" site_id="<?php 
                echo $website->id;
                ?>
" site_name="<?php 
                echo rawurlencode($website->name);
                ?>
" <?php 
                if ($globalView) {
                    ?>
style="display: none"<?php 
                }
                ?>
>
                    <?php 
                foreach ($theme_upgrades as $theme_name => $theme_upgrade) {
                    $theme_name = urlencode($theme_name);
                    ?>
                        <div class="mainwp-row" theme_slug="<?php 
                    echo $theme_name;
                    ?>
"  theme_name="<?php 
                    echo urlencode($themesInfo[$slug]['name']);
                    ?>
" premium="<?php 
                    echo $themesInfo[$slug]['premium'] ? 1 : 0;
                    ?>
" updated="0">
                            <span class="mainwp-left-col"><?php 
                    if ($globalView) {
                        ?>
&nbsp;&nbsp;&nbsp;<?php 
                    }
                    echo $theme_upgrade['Name'];
                    ?>
<input type="hidden" id="wp_upgraded_theme_<?php 
                    echo $website->id;
                    ?>
_<?php 
                    echo $theme_name;
                    ?>
" value="0"/></span>
                            <span class="mainwp-mid-col pluginsInfo" id="wp_upgrade_theme_<?php 
                    echo $website->id;
                    ?>
_<?php 
                    echo $theme_name;
                    ?>
"><?php 
                    echo $theme_upgrade['Version'];
                    ?>
 to <?php 
                    echo $theme_upgrade['update']['new_version'];
                    ?>
</span>
                            <span class="mainwp-right-col pluginsAction">
                                <div id="wp_upgradebuttons_theme_<?php 
                    echo $website->id;
                    ?>
_<?php 
                    echo $theme_name;
                    ?>
">
                                    <?php 
                    if (mainwp_current_user_can("dashboard", "ignore_unignore_updates")) {
                        ?>
                                    <a href="#" class="button" onClick="return rightnow_themes_ignore_detail('<?php 
                        echo $theme_name;
                        ?>
', '<?php 
                        echo urlencode($theme_upgrade['Name']);
                        ?>
', <?php 
                        echo $website->id;
                        ?>
)"><?php 
                        _e('Ignore', 'mainwp');
                        ?>
</a>
                                     <?php 
                    }
                    ?>
                                    <?php 
                    if (mainwp_current_user_can("dashboard", "update_themes")) {
                        ?>
                                    &nbsp; <a href="#" class="mainwp-upgrade-button button" onClick="rightnow_upgrade_theme(<?php 
                        echo $website->id;
                        ?>
, '<?php 
                        echo $theme_name;
                        ?>
')"><?php 
                        _e('Upgrade', 'mainwp');
                        ?>
</a> 
                                    <?php 
                    }
                    ?>
                                </div>
                            </span>
                        </div>
                    <?php 
                }
                ?>
                </div>
                <?php 
            }
        } else {
            foreach ($allThemes as $slug => $cnt) {
                $theme_name = urlencode($slug);
                if ($globalView) {
                    ?>
                    <div class="mainwp-row">
                        <span class="mainwp-left-col">
                            <?php 
                    echo $themesInfo[$slug]['name'];
                    ?>
                        </span>
                        <span class="mainwp-mid-col">
                            <a href="#" onClick="return rightnow_themes_detail('<?php 
                    echo $theme_name;
                    ?>
');">
                                <?php 
                    echo $cnt;
                    ?>
 <?php 
                    _e('Upgrade', 'mainwp');
                    echo $cnt > 1 ? 's' : '';
                    ?>
                            </a>
                        </span>
                        <span class="mainwp-right-col">
                            <?php 
                    if (mainwp_current_user_can("dashboard", "ignore_unignore_updates")) {
                        ?>
                            <a href="#" class="button" onClick="return rightnow_themes_ignore_all('<?php 
                        echo $theme_name;
                        ?>
', '<?php 
                        echo urlencode($themesInfo[$slug]['name']);
                        ?>
')"><?php 
                        _e('Ignore Globally', 'mainwp');
                        ?>
</a>
                            <?php 
                    }
                    ?>
                            <?php 
                    if (mainwp_current_user_can("dashboard", "update_themes")) {
                        ?>
                            &nbsp; <?php 
                        if ($cnt > 0) {
                            ?>
<a href="#" class="mainwp-upgrade-button button" onClick="return rightnow_themes_upgrade_all('<?php 
                            echo $theme_name;
                            ?>
', '<?php 
                            echo urlencode($themesInfo[$slug]['name']);
                            ?>
')"><?php 
                            echo _n('Upgrade', 'Upgrade All', $cnt, 'mainwp');
                            ?>
</a><?php 
                        } else {
                            ?>
 &nbsp; <a class="button" disabled="disabled"><?php 
                            _e('No Upgrades', 'mainwp');
                            ?>
</a> <?php 
                        }
                        ?>
                            <?php 
                    }
                    ?>
                        </span>
                    </div>
                    <?php 
                }
                ?>
                    <div theme_slug="<?php 
                echo $theme_name;
                ?>
"  theme_name="<?php 
                echo urlencode($themesInfo[$slug]['name']);
                ?>
" premium="<?php 
                echo $themesInfo[$slug]['premium'] ? 1 : 0;
                ?>
" <?php 
                if ($globalView) {
                    ?>
style="display: none"<?php 
                }
                ?>
>
                        <?php 
                @MainWPDB::data_seek($websites, 0);
                while ($websites && ($website = @MainWPDB::fetch_object($websites))) {
                    if ($website->is_ignoreThemeUpdates) {
                        continue;
                    }
                    $theme_upgrades = json_decode($website->theme_upgrades, true);
                    $decodedPremiumUpgrades = json_decode(MainWPDB::Instance()->getWebsiteOption($website, 'premium_upgrades'), true);
                    if (is_array($decodedPremiumUpgrades)) {
                        foreach ($decodedPremiumUpgrades as $crrSlug => $premiumUpgrade) {
                            $premiumUpgrade['premium'] = true;
                            if ($premiumUpgrade['type'] == 'theme') {
                                if (!is_array($theme_upgrades)) {
                                    $theme_upgrades = array();
                                }
                                $theme_upgrades[$crrSlug] = $premiumUpgrade;
                            }
                        }
                    }
                    $ignored_themes = json_decode($website->ignored_themes, true);
                    if (is_array($ignored_themes)) {
                        $theme_upgrades = array_diff_key($theme_upgrades, $ignored_themes);
                    }
                    if (!isset($theme_upgrades[$slug])) {
                        continue;
                    }
                    $theme_upgrade = $theme_upgrades[$slug];
                    ?>
                            <div class="mainwp-row" site_id="<?php 
                    echo $website->id;
                    ?>
" site_name="<?php 
                    echo rawurlencode($website->name);
                    ?>
" updated="0">
                                <span class="mainwp-left-col">
                                    <?php 
                    if ($globalView) {
                        ?>
                                    &nbsp;&nbsp;&nbsp;<a href="<?php 
                        echo admin_url('admin.php?page=managesites&dashboard=' . $website->id);
                        ?>
"><?php 
                        echo stripslashes($website->name);
                        ?>
</a>
                                    <?php 
                    } else {
                        echo $themesInfo[$slug]['name'];
                    }
                    ?>
</span>
                                <span class="mainwp-mid-col pluginsInfo"><?php 
                    echo $theme_upgrade['Version'];
                    ?>
 to <?php 
                    echo $theme_upgrade['update']['new_version'];
                    ?>
</span>
                                <span class="mainwp-right-col pluginsAction">
                                    <?php 
                    if (mainwp_current_user_can("dashboard", "ignore_unignore_updates")) {
                        ?>
                                    <a href="#" class="button" onClick="return rightnow_themes_ignore_detail('<?php 
                        echo $theme_name;
                        ?>
', '<?php 
                        echo urlencode($theme_upgrade['Name']);
                        ?>
', <?php 
                        echo $website->id;
                        ?>
)"><?php 
                        _e('Ignore', 'mainwp');
                        ?>
</a>
                                     <?php 
                    }
                    ?>
                                    <?php 
                    if (mainwp_current_user_can("dashboard", "update_themes")) {
                        ?>
                                    &nbsp; <a href="#" class="mainwp-upgrade-button button" onClick="return rightnow_themes_upgrade('<?php 
                        echo $theme_name;
                        ?>
', <?php 
                        echo $website->id;
                        ?>
)"><?php 
                        _e('Upgrade', 'mainwp');
                        ?>
</a>
                                    <?php 
                    }
                    ?>
                                </span>
                            </div>
                        <?php 
                }
                ?>
                    </div>
                    <?php 
            }
        }
        ?>
        </div>
    </div>
    
    <?php 
        //Sync errors!
        if ($total_sync_errors > 0) {
            ?>
        <div class="clear">
            <div class="mainwp-row">
                <span class="mainwp-left-col"><span class="mainwp-rightnow-number"><?php 
            echo $total_sync_errors;
            ?>
</span> Error<?php 
            if ($total_sync_errors > 1) {
                ?>
s<?php 
            }
            ?>
</span>
                <span class="mainwp-mid-col">&nbsp;</span>
                <span class="mainwp-right-col"><a href="#" id="mainwp_errors_show" onClick="return rightnow_show('errors');"><i class="fa fa-eye-slash"></i> <?php 
            _e('Show', 'mainwp');
            ?>
</a></span>
            </div>
            <div id="wp_errors" style="display: none">
                <?php 
            @MainWPDB::data_seek($websites, 0);
            while ($websites && ($website = @MainWPDB::fetch_object($websites))) {
                if ($website->sync_errors == '') {
                    continue;
                }
                ?>
                <div class="mainwp-row">
                    <span class="mainwp-left-col"><a href="<?php 
                echo admin_url('admin.php?page=managesites&dashboard=' . $website->id);
                ?>
"><?php 
                echo stripslashes($website->name);
                ?>
</a></span>
                    <span class="mainwp-mid-col"><?php 
                echo $website->sync_errors;
                ?>
</span>
                    <span class="mainwp-right-col"><a href="#" class="mainwp_rightnow_site_reconnect" siteid="<?php 
                echo $website->id;
                ?>
"><?php 
                _e('Reconnect', 'mainwp');
                ?>
</a> | <a href="<?php 
                echo $website->url;
                ?>
" target="_blank"><?php 
                _e('Open', 'mainwp');
                ?>
</a></span>
                </div>
                <?php 
            }
            ?>
            </div>
        </div>
        <?php 
        }
        ?>

    <?php 
        //Good - some are up to date!
        if ($total_uptodate > 0) {
            ?>
        <div class="clear">
            <div class="mainwp-row">
                <span class="mainwp-left-col"><span class="mainwp-rightnow-number"><?php 
            echo $total_uptodate;
            ?>
</span> <?php 
            _e('Up to date', 'mainwp');
            ?>
</span>
                <span class="mainwp-mid-col">&nbsp;</span>
                <span class="mainwp-right-col"><a href="#" id="mainwp_uptodate_show" onClick="return rightnow_show('uptodate');"><i class="fa fa-eye-slash"></i> <?php 
            _e('Show', 'mainwp');
            ?>
</a></span>
            </div>
            <div id="wp_uptodate" style="display: none">
                <?php 
            @MainWPDB::data_seek($websites, 0);
            while ($websites && ($website = @MainWPDB::fetch_object($websites))) {
                if ($website->uptodate != 1) {
                    continue;
                }
                ?>
                <div class="mainwp-row">
                    <span class="mainwp-left-col"><a href="<?php 
                echo admin_url('admin.php?page=managesites&dashboard=' . $website->id);
                ?>
"><?php 
                echo stripslashes($website->name);
                ?>
</a></span>
                    <span class="mainwp-mid-col">&nbsp;</span>
                    <span class="mainwp-right-col"><a href="<?php 
                echo $website->url;
                ?>
" target="_blank"><?php 
                _e('Open', 'mainwp');
                ?>
</a></span>
                </div>
                <?php 
            }
            ?>
            </div>
        </div>
        <?php 
        }
        ?>
    
        <?php 
        @MainWPDB::data_seek($websites, 0);
        $site_ids = array();
        while ($websites && ($website = @MainWPDB::fetch_object($websites))) {
            $site_ids[] = $website->id;
        }
        do_action('mainwp_rightnow_widget_bottom', $site_ids, $globalView);
        ?>
        <div class="clear">
            <div class="mainwp-row">
                <span class="mainwp-left-col"><span class="mainwp-rightnow-number">
                    <img class="down-img" style="margin-bottom: -3px;" title="<?php 
        echo $total_sync_errors > 0 ? 'Site Disconnected' : ($total_conflict > 0 ? 'Plugin or Theme Conflict Found' : ($total_offline > 0 ? 'Site is Offline' : 'Site is Online'));
        ?>
" alt="<?php 
        echo $total_sync_errors > 0 ? 'Sync errors' : ($total_conflict > 0 ? 'Conflict Found' : ($total_offline > 0 ? 'Site Down' : 'Site Up'));
        ?>
" src="<?php 
        echo plugins_url('images/' . ($total_sync_errors > 0 ? 'disconnected' : ($total_conflict > 0 ? 'conflict' : ($total_offline > 0 ? 'down' : 'up'))) . '.png', dirname(__FILE__));
        ?>
" /></span> <span style="font-size: 18px !important;"><?php 
        _e('Status', 'mainwp');
        ?>
</span></span>
                <span class="mainwp-mid-col">&nbsp;</span>
                <span class="mainwp-right-col"><a href="#" id="mainwp_status_show" onClick="return rightnow_show('status');"><i class="fa fa-eye-slash"></i> <?php 
        _e('Show', 'mainwp');
        ?>
</a></span>
            </div>
            <div id="wp_status" style="display: none">
                <?php 
        //Loop 3 times, first we show the conflicts, then we show the down sites, then we show the up sites
        $SYNCERRORS = 0;
        $CONFLICTS = 1;
        $DOWN = 2;
        $UP = 3;
        for ($j = 0; $j <= 3; $j++) {
            @MainWPDB::data_seek($websites, 0);
            while ($websites && ($website = @MainWPDB::fetch_object($websites))) {
                $pluginConflicts = json_decode($website->pluginConflicts, true);
                $themeConflicts = json_decode($website->themeConflicts, true);
                $ignoredPluginConflicts = json_decode($website->ignored_pluginConflicts, true);
                if (!is_array($ignoredPluginConflicts)) {
                    $ignoredPluginConflicts = array();
                }
                $ignoredThemeConflicts = json_decode($website->ignored_themeConflicts, true);
                if (!is_array($ignoredThemeConflicts)) {
                    $ignoredThemeConflicts = array();
                }
                $hasSyncErrors = $website->sync_errors != '';
                $isConflict = false;
                if (!$hasSyncErrors) {
                    if (count($pluginConflicts) > 0) {
                        foreach ($pluginConflicts as $pluginConflict) {
                            if (!in_array($pluginConflict, $ignoredPluginConflicts) && !in_array($pluginConflict, $globalIgnoredPluginConflicts)) {
                                $isConflict = true;
                            }
                        }
                    }
                    if (!$isConflict && count($themeConflicts) > 0) {
                        foreach ($themeConflicts as $themeConflict) {
                            if (!in_array($themeConflict, $ignoredThemeConflicts) && !in_array($themeConflict, $globalIgnoredThemeConflicts)) {
                                $isConflict = true;
                            }
                        }
                    }
                }
                $isDown = !$hasSyncErrors && !$isConflict && $website->offline_check_result == -1;
                $isUp = !$hasSyncErrors && !$isConflict && !$isDown;
                if ($j == $SYNCERRORS && !$hasSyncErrors) {
                    continue;
                }
                if ($j == $CONFLICTS && !$isConflict) {
                    continue;
                }
                if ($j == $DOWN && !$isDown) {
                    continue;
                }
                if ($j == $UP && !$isUp) {
                    continue;
                }
                ?>
                    <div class="mainwp-row">
                        <span class="mainwp-left-col"><a href="<?php 
                echo admin_url('admin.php?page=managesites&dashboard=' . $website->id);
                ?>
"><?php 
                echo stripslashes($website->name);
                ?>
</a></span>
                        <span class="mainwp-mid-col">&nbsp;
                            <?php 
                if ($isConflict) {
                    ?>
<span class="mainwp_status_conflict"><?php 
                    _e('Conflict Found', 'mainwp');
                    ?>
</span> <?php 
                }
                ?>
                        </span>
                        <span class="mainwp-right-col">
                            <?php 
                if ($hasSyncErrors) {
                    ?>
                                    <div style="position: absolute; padding-right: 10px; right: 50px;"><a href="#" class="mainwp_rightnow_site_reconnect" siteid="<?php 
                    echo $website->id;
                    ?>
"><?php 
                    _e('Reconnect', 'mainwp');
                    ?>
</a><br /></div> <img class="down-img" title="Site Disconnected" alt="Sync Errors" src="<?php 
                    echo plugins_url('images/disconnected.png', dirname(__FILE__));
                    ?>
" />
                                    <?php 
                } else {
                    if ($isConflict) {
                        ?>
                                    <img class="down-img" title="Plugin or Theme Conflict Found" alt="Conflict Found" src="<?php 
                        echo plugins_url('images/conflict.png', dirname(__FILE__));
                        ?>
" />
                                    <?php 
                    } else {
                        if ($isDown) {
                            ?>
                                    <img class="down-img" title="Site is Offline" alt="Site Down" src="<?php 
                            echo plugins_url('images/down.png', dirname(__FILE__));
                            ?>
" />
                                    <?php 
                        } else {
                            ?>
                                    <img class="down-img" title="Site is Online" alt="Site Up" src="<?php 
                            echo plugins_url('images/up.png', dirname(__FILE__));
                            ?>
" />
                                    <?php 
                        }
                    }
                }
                ?>
                        </span>
                    </div>
                    <?php 
            }
        }
        ?>
            </div>
        </div>   
    
    <div class="clear"></div>

    <div id="rightnow-upgrade-status-box" title="Upgrade" style="display: none; text-align: center">
        <div id="rightnow-upgrade-status-progress"></div>
        <span id="rightnow-upgrade-status-current">0</span> / <span id="rightnow-upgrade-status-total"></span> <?php 
        _e('upgraded', 'mainwp');
        ?>
        <div style="height: 160px; overflow: auto; margin-top: 20px; margin-bottom: 10px; text-align: left">
            <table style="width: 100%" id="rightnow-upgrade-list">
            </table>
        </div>
        <input id="rightnow-upgrade-status-close" type="button" name="Close" value="<?php 
        _e('Close', 'mainwp');
        ?>
" class="button" />
    </div>

    <div id="rightnow-backup-box" title="Full backup required" style="display: none; text-align: center">
        <div style="height: 190px; overflow: auto; margin-top: 20px; margin-bottom: 10px; text-align: left" id="rightnow-backup-content">
        </div>
        <input id="rightnow-backup-all" type="button" name="Backup All" value="<?php 
        _e('Backup All', 'mainwp');
        ?>
" class="button-primary" />
        <input id="rightnow-backup-ignore" type="button" name="Ignore" value="<?php 
        _e('Ignore', 'mainwp');
        ?>
" class="button" />
    </div>

    <div id="rightnow-backupnow-box" title="Full backup" style="display: none; text-align: center">
        <div style="height: 190px; overflow: auto; margin-top: 20px; margin-bottom: 10px; text-align: left" id="rightnow-backupnow-content">
        </div>
        <input id="rightnow-backupnow-close" type="button" name="Ignore" value="<?php 
        _e('Cancel', 'mainwp');
        ?>
" class="button" />
    </div>

    <?php 
        @MainWPDB::free_result($websites);
    }
    public static function renderSites($renew, $pExit = true)
    {
        $current_wpid = MainWPUtility::get_current_wpid();
        if ($current_wpid) {
            $sql = MainWPDB::Instance()->getSQLWebsiteById($current_wpid);
        } else {
            $sql = MainWPDB::Instance()->getSQLWebsitesForCurrentUser();
        }
        $websites = MainWPDB::Instance()->query($sql);
        $allPosts = array();
        if ($websites) {
            while ($websites && ($website = @MainWPDB::fetch_object($websites))) {
                if ($website->recent_posts == '') {
                    continue;
                }
                $posts = json_decode($website->recent_posts, 1);
                if (count($posts) == 0) {
                    continue;
                }
                foreach ($posts as $post) {
                    $post['website'] = (object) array('id' => $website->id, 'url' => $website->url);
                    $allPosts[] = $post;
                }
            }
            @MainWPDB::free_result($websites);
        }
        $recent_posts_published = MainWPUtility::getSubArrayHaving($allPosts, 'status', 'publish');
        $recent_posts_published = MainWPUtility::sortmulti($recent_posts_published, 'dts', 'desc');
        $recent_posts_draft = MainWPUtility::getSubArrayHaving($allPosts, 'status', 'draft');
        $recent_posts_draft = MainWPUtility::sortmulti($recent_posts_draft, 'dts', 'desc');
        $recent_posts_pending = MainWPUtility::getSubArrayHaving($allPosts, 'status', 'pending');
        $recent_posts_pending = MainWPUtility::sortmulti($recent_posts_pending, 'dts', 'desc');
        $recent_posts_trash = MainWPUtility::getSubArrayHaving($allPosts, 'status', 'trash');
        $recent_posts_trash = MainWPUtility::sortmulti($recent_posts_trash, 'dts', 'desc');
        ?>
        <div class="clear">
            <a href="<?php 
        echo admin_url('admin.php?page=PostBulkAdd&select=' . ($current_wpid ? $current_wpid : 'all'));
        ?>
" class="button-primary" style="float: right"><?php 
        _e('Add New', 'mainwp');
        ?>
</a>
            <a class="mainwp_action left mainwp_action_down recent_posts_published_lnk" href="#"><?php 
        _e('Published', 'mainwp');
        ?>
 (<?php 
        echo count($recent_posts_published);
        ?>
)</a><a class="mainwp_action mid recent_posts_draft_lnk" href="#" ><?php 
        _e('Draft', 'mainwp');
        ?>
 (<?php 
        echo count($recent_posts_draft);
        ?>
)</a><a class="mainwp_action mid recent_posts_pending_lnk" href="#"><?php 
        _e('Pending', 'mainwp');
        ?>
 (<?php 
        echo count($recent_posts_pending);
        ?>
)</a><a class="mainwp_action right recent_posts_trash_lnk" href="#"><?php 
        _e('Trash', 'mainwp');
        ?>
 (<?php 
        echo count($recent_posts_trash);
        ?>
)</a><br/><br/>
            <div class="recent_posts_published">
                <?php 
        for ($i = 0; $i < count($recent_posts_published) && $i < 5; $i++) {
            if (!isset($recent_posts_published[$i]['title']) || $recent_posts_published[$i]['title'] == '') {
                $recent_posts_published[$i]['title'] = '(No Title)';
            }
            if (isset($recent_posts_published[$i]['dts'])) {
                if (!stristr($recent_posts_published[$i]['dts'], '-')) {
                    $recent_posts_published[$i]['dts'] = MainWPUtility::formatTimestamp(MainWPUtility::getTimestamp($recent_posts_published[$i]['dts']));
                }
            }
            ?>
                <div class="mainwp-row mainwp-recent">
                    <input class="postId" type="hidden" name="id" value="<?php 
            echo $recent_posts_published[$i]['id'];
            ?>
"/>
                    <input class="websiteId" type="hidden" name="id" value="<?php 
            echo $recent_posts_published[$i]['website']->id;
            ?>
"/>
                    <span class="mainwp-left-col" style="width: 60% !important;  margin-right: 1em;"><a href="<?php 
            echo $recent_posts_published[$i]['website']->url;
            ?>
?p=<?php 
            echo $recent_posts_published[$i]['id'];
            ?>
" target="_blank"><?php 
            echo htmlentities($recent_posts_published[$i]['title'], ENT_COMPAT | ENT_HTML401, "UTF-8");
            ?>
</a></span>
                    <span class="mainwp-mid-col">
                            <a href="<?php 
            echo admin_url('admin.php?page=CommentBulkManage&siteid=' . $recent_posts_published[$i]['website']->id . '&postid=' . $recent_posts_published[$i]['id']);
            ?>
" title="<?php 
            echo $recent_posts_published[$i]['comment_count'];
            ?>
" class="post-com-count" style="display: inline-block !important;">
                                <span class="comment-count"><?php 
            echo $recent_posts_published[$i]['comment_count'];
            ?>
</span>
                            </a>
                    </span>
                    <span class="mainwp-right-col"><a href="<?php 
            echo $recent_posts_published[$i]['website']->url;
            ?>
" target="_blank"><i class="fa fa-external-link"></i> <?php 
            echo MainWPUtility::getNiceURL($recent_posts_published[$i]['website']->url);
            ?>
</a> <br/><?php 
            echo $recent_posts_published[$i]['dts'];
            ?>
</span>

                    <div style="clear: left;"></div>
                    <div class="mainwp-row-actions"><a href="#" class="mainwp-post-unpublish"><?php 
            _e('Unpublish', 'mainwp');
            ?>
</a> | <a href="admin.php?page=SiteOpen&websiteid=<?php 
            echo $recent_posts_published[$i]['website']->id;
            ?>
&location=<?php 
            echo base64_encode('post.php?action=editpost&post=' . $recent_posts_published[$i]['id'] . '&action=edit');
            ?>
" title="Edit this post"><?php 
            _e('Edit', 'mainwp');
            ?>
</a> | <a href="#" class="mainwp-post-trash"><?php 
            _e('Trash', 'mainwp');
            ?>
</a>| <a href="<?php 
            echo $recent_posts_published[$i]['website']->url . (substr($recent_posts_published[$i]['website']->url, -1) != '/' ? '/' : '') . '?p=' . $recent_posts_published[$i]['id'];
            ?>
" target="_blank" title="View '<?php 
            echo $recent_posts_published[$i]['title'];
            ?>
'" rel="permalink"><?php 
            _e('View', 'mainwp');
            ?>
</a> | <a href="admin.php?page=PostBulkManage" class="mainwp-post-viewall"><?php 
            _e('View All', 'mainwp');
            ?>
</a></div>
                    <div class="mainwp-row-actions-working"><i class="fa fa-spinner fa-pulse"></i> <?php 
            _e('Please wait', 'mainwp');
            ?>
                    <div>&nbsp;</div>
                    </div>
                </div>
                <?php 
        }
        ?>
            </div>

            <div class="recent_posts_draft" style="display: none">
                <?php 
        for ($i = 0; $i < count($recent_posts_draft) && $i < 5; $i++) {
            if (!isset($recent_posts_draft[$i]['title']) || $recent_posts_draft[$i]['title'] == '') {
                $recent_posts_draft[$i]['title'] = '(No Title)';
            }
            if (isset($recent_posts_draft[$i]['dts'])) {
                if (!stristr($recent_posts_draft[$i]['dts'], '-')) {
                    $recent_posts_draft[$i]['dts'] = MainWPUtility::formatTimestamp(MainWPUtility::getTimestamp($recent_posts_draft[$i]['dts']));
                }
            }
            ?>
                <div class="mainwp-row mainwp-recent">
                    <input class="postId" type="hidden" name="id" value="<?php 
            echo $recent_posts_draft[$i]['id'];
            ?>
"/>
                    <input class="websiteId" type="hidden" name="id" value="<?php 
            echo $recent_posts_draft[$i]['website']->id;
            ?>
"/>
                    <span class="mainwp-left-col" style="width: 60% !important;  margin-right: 1em;"><a href="<?php 
            echo $recent_posts_draft[$i]['website']->url;
            ?>
?p=<?php 
            echo $recent_posts_draft[$i]['id'];
            ?>
" target="_blank"><?php 
            echo htmlentities($recent_posts_draft[$i]['title'], ENT_COMPAT | ENT_HTML401, "UTF-8");
            ?>
</a></span>
                    <span class="mainwp-mid-col">
                            <a href="<?php 
            echo admin_url('admin.php?page=CommentBulkManage&siteid=' . $recent_posts_draft[$i]['website']->id . '&postid=' . $recent_posts_draft[$i]['id']);
            ?>
" title="<?php 
            echo $recent_posts_draft[$i]['comment_count'];
            ?>
" class="post-com-count" style="display: inline-block !important;">
                                <span class="comment-count"><?php 
            echo $recent_posts_draft[$i]['comment_count'];
            ?>
</span>
                            </a>
                    </span>
                    <span class="mainwp-right-col"><?php 
            echo MainWPUtility::getNiceURL($recent_posts_draft[$i]['website']->url);
            ?>
 <br/><?php 
            echo $recent_posts_draft[$i]['dts'];
            ?>
</span>

                    <div style="clear: left;"></div>
                    <div class="mainwp-row-actions"><a href="#" class="mainwp-post-publish"><?php 
            _e('Publish', 'mainwp');
            ?>
</a> | <a href="admin.php?page=SiteOpen&websiteid=<?php 
            echo $recent_posts_draft[$i]['website']->id;
            ?>
&location=<?php 
            echo base64_encode('post.php?action=editpost&post=' . $recent_posts_draft[$i]['id'] . '&action=edit');
            ?>
" title="Edit this post"><?php 
            _e('Edit', 'mainwp');
            ?>
</a> | <a href="#" class="mainwp-post-trash"><?php 
            _e('Trash', 'mainwp');
            ?>
</a> | <a href="admin.php?page=PostBulkManage" class="mainwp-post-viewall"><?php 
            _e('View All', 'mainwp');
            ?>
</a></div>
                    <div class="mainwp-row-actions-working"><i class="fa fa-spinner fa-pulse"></i> <?php 
            _e('Please wait', 'mainwp');
            ?>
                    </div>
                    <div>&nbsp;</div>
                </div>
                <?php 
        }
        ?>
            </div>

            <div class="recent_posts_pending" style="display: none">
                <?php 
        for ($i = 0; $i < count($recent_posts_pending) && $i < 5; $i++) {
            if (!isset($recent_posts_pending[$i]['title']) || $recent_posts_pending[$i]['title'] == '') {
                $recent_posts_pending[$i]['title'] = '(No Title)';
            }
            if (isset($recent_posts_pending[$i]['dts'])) {
                if (!stristr($recent_posts_pending[$i]['dts'], '-')) {
                    $recent_posts_pending[$i]['dts'] = MainWPUtility::formatTimestamp(MainWPUtility::getTimestamp($recent_posts_pending[$i]['dts']));
                }
            }
            ?>
                <div class="mainwp-row mainwp-recent">
                    <input class="postId" type="hidden" name="id" value="<?php 
            echo $recent_posts_pending[$i]['id'];
            ?>
"/>
                    <input class="websiteId" type="hidden" name="id" value="<?php 
            echo $recent_posts_pending[$i]['website']->id;
            ?>
"/>
                    <span class="mainwp-left-col" style="width: 60% !important;  margin-right: 1em;"><a href="<?php 
            echo $recent_posts_pending[$i]['website']->url;
            ?>
?p=<?php 
            echo $recent_posts_pending[$i]['id'];
            ?>
" target="_blank"><?php 
            echo htmlentities($recent_posts_pending[$i]['title'], ENT_COMPAT | ENT_HTML401, "UTF-8");
            ?>
</a></span>
                    <span class="mainwp-mid-col">
                            <a href="<?php 
            echo admin_url('admin.php?page=CommentBulkManage&siteid=' . $recent_posts_pending[$i]['website']->id . '&postid=' . $recent_posts_pending[$i]['id']);
            ?>
" title="<?php 
            echo $recent_posts_pending[$i]['comment_count'];
            ?>
" class="post-com-count" style="display: inline-block !important;">
                                <span class="comment-count"><?php 
            echo $recent_posts_pending[$i]['comment_count'];
            ?>
</span>
                            </a>
                    </span>
                    <span class="mainwp-right-col"><?php 
            echo MainWPUtility::getNiceURL($recent_posts_pending[$i]['website']->url);
            ?>
 <br/><?php 
            echo $recent_posts_pending[$i]['dts'];
            ?>
</span>

                    <div style="clear: left;"></div>
                    <div class="mainwp-row-actions"><a href="#" class="mainwp-post-publish"><?php 
            _e('Publish', 'mainwp');
            ?>
</a> | <a href="admin.php?page=SiteOpen&websiteid=<?php 
            echo $recent_posts_pending[$i]['website']->id;
            ?>
&location=<?php 
            echo base64_encode('post.php?action=editpost&post=' . $recent_posts_pending[$i]['id'] . '&action=edit');
            ?>
" title="Edit this post"><?php 
            _e('Edit', 'mainwp');
            ?>
</a> | <a href="#" class="mainwp-post-trash"><?php 
            _e('Trash', 'mainwp');
            ?>
</a> | <a href="admin.php?page=PostBulkManage" class="mainwp-post-viewall"><?php 
            _e('View All', 'mainwp');
            ?>
</a></div>
                    <div class="mainwp-row-actions-working"><i class="fa fa-spinner fa-pulse"></i> <?php 
            _e('Please wait', 'mainwp');
            ?>
                    </div>
                    <div>&nbsp;</div>
                </div>
                <?php 
        }
        ?>
            </div>
            <div class="recent_posts_trash" style="display: none">
                <?php 
        for ($i = 0; $i < count($recent_posts_trash) && $i < 5; $i++) {
            if (!isset($recent_posts_trash[$i]['title']) || $recent_posts_trash[$i]['title'] == '') {
                $recent_posts_trash[$i]['title'] = '(No Title)';
            }
            if (isset($recent_posts_trash[$i]['dts'])) {
                if (!stristr($recent_posts_trash[$i]['dts'], '-')) {
                    $recent_posts_trash[$i]['dts'] = MainWPUtility::formatTimestamp(MainWPUtility::getTimestamp($recent_posts_trash[$i]['dts']));
                }
            }
            ?>
                <div class="mainwp-row mainwp-recent">
                    <input class="postId" type="hidden" name="id" value="<?php 
            echo $recent_posts_trash[$i]['id'];
            ?>
"/>
                    <input class="websiteId" type="hidden" name="id" value="<?php 
            echo $recent_posts_trash[$i]['website']->id;
            ?>
"/>
                    <span class="mainwp-left-col" style="width: 60% !important;  margin-right: 1em;"><?php 
            echo htmlentities($recent_posts_trash[$i]['title'], ENT_COMPAT | ENT_HTML401, "UTF-8");
            ?>
</span>
                    <span class="mainwp-mid-col">
                            <a href="<?php 
            echo admin_url('admin.php?page=CommentBulkManage&siteid=' . $recent_posts_trash[$i]['website']->id . '&postid=' . $recent_posts_trash[$i]['id']);
            ?>
" title="<?php 
            echo $recent_posts_trash[$i]['comment_count'];
            ?>
" class="post-com-count" style="display: inline-block !important;">
                                <span class="comment-count"><?php 
            echo $recent_posts_trash[$i]['comment_count'];
            ?>
</span>
                            </a>
                    </span>
                    <span class="mainwp-right-col"><?php 
            echo MainWPUtility::getNiceURL($recent_posts_trash[$i]['website']->url);
            ?>
 <br/><?php 
            echo $recent_posts_trash[$i]['dts'];
            ?>
</span>

                    <div style="clear: left;"></div>
                    <div class="mainwp-row-actions"><a href="#" class="mainwp-post-restore"><?php 
            _e('Restore', 'mainwp');
            ?>
</a> | <a href="#" class="mainwp-post-delete delete" style="color: red;"><?php 
            _e('Delete Permanently', 'mainwp');
            ?>
</a></div>
                    <div class="mainwp-row-actions-working"><i class="fa fa-spinner fa-pulse"></i> <?php 
            _e('Please wait', 'mainwp');
            ?>
                    </div>
                    <div>&nbsp;</div>
                </div>
                <?php 
        }
        ?>
            </div>
        </div>
    <div class="clear"></div>
    <?php 
        if ($pExit == true) {
            exit;
        }
    }
Example #4
0
    function update_footer()
    {
        if (!self::isMainWPPages()) {
            return;
        }
        $current_wpid = MainWPUtility::get_current_wpid();
        if ($current_wpid) {
            $website = MainWPDB::Instance()->getWebsiteById($current_wpid);
            $websites = array($website);
        } else {
            $websites = MainWPDB::Instance()->query(MainWPDB::Instance()->getSQLWebsitesForCurrentUser(false, null, 'wp_sync.dtsSync DESC, wp.url ASC'));
        }
        ob_start();
        $cntr = 0;
        if (is_array($websites)) {
            for ($i = 0; $i < count($websites); $i++) {
                $website = $websites[$i];
                if ($website->sync_errors == '') {
                    $cntr++;
                    echo '<input type="hidden" name="dashboard_wp_ids[]" class="dashboard_wp_id" value="' . $website->id . '" />';
                }
            }
        } else {
            if ($websites !== false) {
                while ($website = @MainWPDB::fetch_object($websites)) {
                    if ($website->sync_errors == '') {
                        $cntr++;
                        echo '<input type="hidden" name="dashboard_wp_ids[]" class="dashboard_wp_id" value="' . $website->id . '" />';
                    }
                }
            }
        }
        ?>
        <div id="refresh-status-box" title="Syncing Websites" style="display: none; text-align: center">
            <div id="refresh-status-progress"></div>
            <span id="refresh-status-current">0</span> / <span id="refresh-status-total"><?php 
        echo $cntr;
        ?>
</span> <span id="refresh-status-text"><?php 
        _e('synced', 'mainwp');
        ?>
</span>
            <div style="height: 160px; overflow: auto; margin-top: 20px; margin-bottom: 10px; text-align: left" id="refresh-status-content">
                <table style="width: 100%">
                <?php 
        if (is_array($websites)) {
            for ($i = 0; $i < count($websites); $i++) {
                $website = $websites[$i];
                if ($website->sync_errors == '') {
                    echo '<tr><td>' . MainWPUtility::getNiceURL($website->url) . '</td><td style="width: 80px"><span class="refresh-status-wp" niceurl="' . MainWPUtility::getNiceURL($website->url) . '" siteid="' . $website->id . '">PENDING</span></td></tr>';
                } else {
                    echo '<tr class="mainwp_wp_offline"><td>' . MainWPUtility::getNiceURL($website->url) . '</td><td style="width: 80px"><span class="refresh-status-wp" niceurl="' . MainWPUtility::getNiceURL($website->url) . '" siteid="' . $website->id . '">DISCONNECTED</span></td></tr>';
                }
            }
        } else {
            @MainWPDB::data_seek($websites, 0);
            while ($website = @MainWPDB::fetch_object($websites)) {
                if ($website->sync_errors == '') {
                    echo '<tr><td>' . MainWPUtility::getNiceURL($website->url) . '</td><td style="width: 80px"><span class="refresh-status-wp" niceurl="' . MainWPUtility::getNiceURL($website->url) . '" siteid="' . $website->id . '">PENDING</span></td></tr>';
                } else {
                    echo '<tr class="mainwp_wp_offline"><td>' . MainWPUtility::getNiceURL($website->url) . '</td><td style="width: 80px"><span class="refresh-status-wp" niceurl="' . MainWPUtility::getNiceURL($website->url) . '" siteid="' . $website->id . '">DISCONNECTED</span></td></tr>';
                }
            }
        }
        ?>
                </table>
            </div>
            <input id="refresh-status-close" type="button" name="Close" value="Close" class="button" />
        </div>
    <?php 
        if (!self::isHideFooter()) {
            self::sites_fly_menu();
            self::add_new_links();
        }
        $newOutput = ob_get_clean();
        $output = "";
        if (!self::isHideFooter()) {
            $output .= '<a href="javascript:void(0)" id="dashboard_refresh" title="Sync Data" class="mainwp-left-margin-2 mainwp-green"><i class="fa fa-refresh fa-2x"></i></a> <a id="mainwp-add-new-button" class="mainwp-blue mainwp-left-margin-2" title="Add New" href="javascript:void(0)"><i class="fa fa-plus fa-2x"></i></a> <a class="mainwp-red mainwp-left-margin-2" title="Get MainWP Extensions" href="https://extensions.mainwp.com" target="_blank"><i class="fa fa-shopping-cart fa-2x"></i></a> <a class="mainwp-white mainwp-left-margin-2" title="Get Support" href="http://support.mainwp.com" target="_blank"><i class="fa fa-life-ring fa-2x"></i></a>' . '<a href="https://www.facebook.com/mainwp" class="mainwp-link-clean mainwp-left-margin-2" style="color: #3B5998;" target="_blank"><i class="fa fa-facebook-square fa-2x"></i></a> ' . ' <a href="https://twitter.com/mymainwp" class="mainwp-link-clean" target="_blank" style="color: #4099FF;"><i class="fa fa-twitter-square fa-2x"></i></a>.';
        }
        return $output . $newOutput;
    }
    public static function renderWidget($renew, $pExit = true)
    {
        $current_wpid = MainWPUtility::get_current_wpid();
        if (empty($current_wpid)) {
            return;
        }
        $sql = MainWPDB::Instance()->getSQLWebsiteById($current_wpid);
        $websites = MainWPDB::Instance()->query($sql);
        $allPlugins = array();
        if ($websites) {
            $website = @MainWPDB::fetch_object($websites);
            if ($website && $website->plugins != '') {
                $plugins = json_decode($website->plugins, 1);
                if (is_array($plugins) && count($plugins) != 0) {
                    foreach ($plugins as $plugin) {
                        $allPlugins[] = $plugin;
                    }
                }
            }
            @MainWPDB::free_result($websites);
        }
        $actived_plugins = MainWPUtility::getSubArrayHaving($allPlugins, 'active', 1);
        $actived_plugins = MainWPUtility::sortmulti($actived_plugins, 'name', 'desc');
        $inactive_plugins = MainWPUtility::getSubArrayHaving($allPlugins, 'active', 0);
        $inactive_plugins = MainWPUtility::sortmulti($inactive_plugins, 'name', 'desc');
        ?>
        <div class="clear">            
            <a class="mainwp_action left mainwp_action_down plugins_actived_lnk" href="#"><?php 
        _e('Active', 'mainwp');
        ?>
 (<?php 
        echo count($actived_plugins);
        ?>
)</a><a class="mainwp_action mid plugins_inactive_lnk right" href="#" ><?php 
        _e('Inactive', 'mainwp');
        ?>
 (<?php 
        echo count($inactive_plugins);
        ?>
)</a><br/><br/>
            <div class="mainwp_plugins_active">
                <?php 
        for ($i = 0; $i < count($actived_plugins); $i++) {
            ?>
                <div class="mainwp-row mainwp-active">
                    <input class="pluginSlug" type="hidden" name="slug" value="<?php 
            echo $actived_plugins[$i]['slug'];
            ?>
"/>
                    <input class="websiteId" type="hidden" name="id" value="<?php 
            echo $website->id;
            ?>
"/>
                    <span class="mainwp-left-col">						
                            <a href="<?php 
            echo admin_url() . 'plugin-install.php?tab=plugin-information&plugin=' . dirname($actived_plugins[$i]['slug']) . '&TB_iframe=true&width=640&height=477';
            ?>
" target="_blank"
                                                                                                                class="thickbox" title="More information about <?php 
            echo $actived_plugins[$i]['name'];
            ?>
">
                        <?php 
            echo $actived_plugins[$i]['name'];
            ?>
                    </a><?php 
            echo " " . $actived_plugins[$i]['version'];
            ?>
 
					</span>					       
                    <div class="mainwp-right-col pluginsAction">
                        <?php 
            if (mainwp_current_user_can("dashboard", "activate_deactivate_plugins")) {
                ?>
                            <a href="#" class="mainwp-plugin-deactivate"><i class="fa fa-toggle-off"></i> <?php 
                _e('Deactivate', 'mainwp');
                ?>
</a>
                        <?php 
            }
            ?>
                    </div>                    
                    <div style="clear: left;"></div>
                    <div class="mainwp-row-actions-working"><i class="fa fa-spinner fa-pulse"></i> <?php 
            _e('Please wait', 'mainwp');
            ?>
</div>                    
                    <div>&nbsp;</div>
                </div>
                <?php 
        }
        ?>
            </div>

            <div class="mainwp_plugins_inactive" style="display: none">
                <?php 
        for ($i = 0; $i < count($inactive_plugins); $i++) {
            ?>
                <div class="mainwp-row mainwp-inactive">
                    <input class="pluginSlug" type="hidden" name="slug" value="<?php 
            echo $inactive_plugins[$i]['slug'];
            ?>
"/>
                    <input class="websiteId" type="hidden" name="id" value="<?php 
            echo $website->id;
            ?>
"/>
                    <span class="mainwp-left-col">
                    <a href="<?php 
            echo admin_url() . 'plugin-install.php?tab=plugin-information&plugin=' . dirname($inactive_plugins[$i]['slug']) . '&TB_iframe=true&width=640&height=477';
            ?>
" target="_blank"
                                                                                                                                                                                                                    class="thickbox" title="More information about <?php 
            echo $inactive_plugins[$i]['name'];
            ?>
">
                                    <?php 
            echo $inactive_plugins[$i]['name'];
            ?>
                            </a><?php 
            echo " " . $inactive_plugins[$i]['version'];
            ?>
 							
                    </span>                                       
                    <div class="mainwp-right-col pluginsAction">
                        <?php 
            if (mainwp_current_user_can("dashboard", "activate_deactivate_plugins")) {
                ?>
                        <a href="#" class="mainwp-plugin-activate"><i class="fa fa-toggle-on"></i> <?php 
                _e('Activate', 'mainwp');
                ?>
</a> | 
                        <?php 
            }
            ?>
                        <?php 
            if (mainwp_current_user_can("dashboard", "delete_plugins")) {
                ?>
                        <a href="#" class="mainwp-plugin-delete mainwp-red"><i class="fa fa-trash"></i> <?php 
                _e('Delete', 'mainwp');
                ?>
</a>
                        <?php 
            }
            ?>
                    </div>
                        <div style="clear: left;"></div>
                    <div class="mainwp-row-actions-working"><i class="fa fa-spinner fa-pulse"></i> <?php 
            _e('Please wait', 'mainwp');
            ?>
</div>                    
                        <div>&nbsp;</div>
                </div>
                <?php 
        }
        ?>
            </div>
        </div>
    <div class="clear"></div>
    <?php 
        if ($pExit == true) {
            exit;
        }
    }
Example #6
0
 public static function renderMetabox()
 {
     $website = MainWPUtility::get_current_wpid();
     if (!$website) {
         return;
     }
     $website = MainWPDB::Instance()->getWebsiteById($website);
     MainWPManageSitesView::showSEOWidget($website);
 }
    public static function renderMetabox()
    {
        $website = MainWPUtility::get_current_wpid();
        if (!$website) {
            return;
        }
        $website = MainWPDB::Instance()->getWebsiteById($website);
        MainWPManageSites::showBackups($website);
        ?>
        <?php 
        if (mainwp_current_user_can("dashboard", "execute_backups")) {
            ?>
        <hr />
        <div style="text-align: center;"><a href="<?php 
            echo admin_url('admin.php?page=managesites&backupid=' . $website->id);
            ?>
" class="button-primary"><?php 
            _e('Backup Now', 'mainwp');
            ?>
</a></div>
        <?php 
        }
        ?>
        <?php 
    }
Example #8
0
    public static function renderDashboardBody($websites, $pDashboard, $pScreenLayout)
    {
        $opts = get_option("mainwp_opts_showhide_sections", false);
        $hide_shortcuts = is_array($opts) && isset($opts['welcome_shortcuts']) && $opts['welcome_shortcuts'] == 'hide' ? true : false;
        ?>
    <form action="admin-post.php" method="post">
        <?php 
        wp_nonce_field('mainwp_tab-general');
        ?>
        <?php 
        wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
        ?>
        <?php 
        wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
        ?>
        <input type="hidden" name="action" value="save_howto_testPages_general"/>
            <div id="mainwp-welocme-bar" class="welcome-panel" style="padding-left: 2em;">
            <table id="mainwp-refresh-bar" width="100%">
                <tbody><tr><td>
                <div id="mainwp-welocme-bar-top">
                    <span style="float:right;">
                    <a style="font-size: 18px;" class="button-hero button mainwp-upgrade-button" id="dashboard_refresh" title="<?php 
        echo MainWPRightNow::renderLastUpdate();
        ?>
"><?php 
        _e('<i class="fa fa-refresh"></i> Sync Data', 'mainwp');
        ?>
</a>
                    <a style="font-size: 18px;" class="button-hero button-primary button" target="_blank" href="https://extensions.mainwp.com"><?php 
        _e('<i class="fa fa-cart-plus"></i> Get New Extensions', 'mainwp');
        ?>
</a>
                    </span>
                    <?php 
        $current_wp_id = MainWPUtility::get_current_wpid();
        $website = null;
        if (!empty($current_wp_id)) {
            $website = $websites[0];
        }
        $imgfavi = "";
        if ($website !== null) {
            if (get_option('mainwp_use_favicon', 1) == 1) {
                $favi = MainWPDB::Instance()->getWebsiteOption($website, 'favi_icon', "");
                $favi_url = MainWPUtility::get_favico_url($favi, $website);
                $imgfavi = '<img src="' . $favi_url . '" width="16" height="16" style="vertical-align:middle;"/>&nbsp;';
            }
        }
        if (time() - ($website == null ? MainWPDB::Instance()->getFirstSyncedSite() : $website->dtsSync) > 60 * 60 * 24) {
            ?>
<h3><i class="fa fa-flag"></i> <?php 
            _e('Your MainWP Dashboard has not been synced for 24 hours!', 'mainwp');
            ?>
</h3>
                <p class="about-description"><?php 
            _e('Click the Sync Data button to get the latest data from child sites.', 'mainwp');
            ?>
</p>
                    <?php 
        } else {
            ?>
                    <h3><?php 
            echo $website == null ? __('Welcome to Your MainWP Dashboard!', 'mainwp') : sprintf(__('Welcome to %s Dashboard!', 'mainwp'), stripslashes($website->name));
            ?>
</h3>
                    <p class="about-description"><?php 
            echo $website == null ? __('Manage your WordPress sites with ease.', 'mainwp') : sprintf(__('This information is only for %s%s', 'mainwp'), $imgfavi, MainWPUtility::getNiceURL($website->url, true));
            ?>
</p>
                    <?php 
        }
        ?>
                </div>
                <br/>
                <span style="float: right; margin-right: 1em;"><a id="mainwp-link-showhide-welcome-shortcuts" status="<?php 
        echo $hide_shortcuts ? "hide" : "show";
        ?>
" href="#"><?php 
        echo $hide_shortcuts ? __('Show Shortcuts', 'mainwp') : __('Hide Shortcuts', 'mainwp');
        ?>
</a></span>
                <div id="mainwp-welcome-bar-shotcuts" style="clear: both;<?php 
        echo $hide_shortcuts ? "display: none;" : "";
        ?>
" > 
                    <div class="welcome-panel-column">
                        <h4><?php 
        _e('Get Started', 'mainwp');
        ?>
</h4>
                        <ul>
                            <li><a href="<?php 
        echo get_admin_url();
        ?>
admin.php?page=managesites&do=new"><i class="fa fa-globe"></i> <?php 
        _e('Add New Site', 'mainwp');
        ?>
</a></li>
                            <li><a href="<?php 
        echo get_admin_url();
        ?>
admin.php?page=ManageGroups"><i class="fa fa-globe"></i> <?php 
        _e('Create Child Site Groups', 'mainwp');
        ?>
</a></li>
                            <li><a href="<?php 
        echo get_admin_url();
        ?>
admin.php?page=ManageBackupsAddNew"><i class="fa fa-hdd-o"></i> <?php 
        _e('Schedule Backups', 'mainwp');
        ?>
</a></li>
                            <li><a href="<?php 
        echo get_admin_url();
        ?>
admin.php?page=Settings"><i class="fa fa-cogs"></i> <?php 
        _e('Check MainWP Settings', 'mainwp');
        ?>
</a></li>
                            
                        </ul>
                    </div>
                    <div class="welcome-panel-column">
                        <h4><?php 
        _e('Next Steps', 'mainwp');
        ?>
</h4>
                        <ul>
                            <li><a href="<?php 
        echo get_admin_url();
        ?>
admin.php?page=PostBulkAdd"><i class="fa fa-file-text"></i> <?php 
        _e('Add Post to Child Site(s)', 'mainwp');
        ?>
</a></li>
                            <li><a href="<?php 
        echo get_admin_url();
        ?>
admin.php?page=PageBulkAdd"><i class="fa fa-file"></i> <?php 
        _e('Add Page to Child Site(s)', 'mainwp');
        ?>
</a></li>
                            <li><a href="<?php 
        echo get_admin_url();
        ?>
admin.php?page=PluginsInstall"><i class="fa fa-plug"></i> <?php 
        _e('Add Plugin to Child Site(s)', 'mainwp');
        ?>
</a></li>
                            <li><a href="<?php 
        echo get_admin_url();
        ?>
admin.php?page=ThemesInstall"><i class="fa fa-paint-brush"></i> <?php 
        _e('Add Theme to Child Site(s)', 'mainwp');
        ?>
</a></li>
                        </ul>
                    </div>
                    <div class="welcome-panel-column welcome-panel-last">
                        <h4><?php 
        _e('More Actions', 'mainwp');
        ?>
</h4>
                        <ul>
                            <li><a href="<?php 
        echo get_admin_url();
        ?>
admin.php?page=managesites&do=test"><i class="fa fa-globe"></i> <?php 
        _e('Test Connection', 'mainwp');
        ?>
</a></li>
                            <li><a href="<?php 
        echo get_admin_url();
        ?>
admin.php?page=Extensions"><i class="fa fa-plug"></i> <?php 
        _e('Manage Extensions', 'mainwp');
        ?>
</a></li>
                            <li><a href="<?php 
        echo get_admin_url();
        ?>
admin.php?page=ServerInformation"><i class="fa fa-server"></i> <?php 
        _e('Check MainWP Requirements', 'mainwp');
        ?>
</a></li>
                            <li><a href="<?php 
        echo get_admin_url();
        ?>
admin.php?page=DashboardOptions"><i class="fa fa-cogs"></i> <?php 
        _e('Set Your Preferences', 'mainwp');
        ?>
</a></li>
                        </ul>
                    </div>
                </div>
            <div id="dashboard_refresh_statusextra" style="display: none"> <i class="fa fa-spinner fa-pulse"></i> </div>
            </div>
            <div id="mainwp_dashboard_refresh_status"></div>
            </td></tr></tbody>
         </table>
        </div>
        <div id="mainwp_main_errors" class="mainwp_error"></div>
    </form>

    <?php 
        if (empty($current_wp_id) && MainWPTwitter::enabledTwitterMessages()) {
            $filter = array('upgrade_everything', 'upgrade_all_wp_core', 'upgrade_all_plugins', 'upgrade_all_themes');
            foreach ($filter as $what) {
                $twitters = MainWPTwitter::getTwitterNotice($what);
                if (is_array($twitters)) {
                    foreach ($twitters as $timeid => $twit_mess) {
                        if (!empty($twit_mess)) {
                            $sendText = MainWPTwitter::getTwitToSend($what, $timeid);
                            ?>
                            <div class="mainwp-tips mainwp_info-box-blue twitter"><span class="mainwp-tip" twit-what="<?php 
                            echo $what;
                            ?>
" twit-id="<?php 
                            echo $timeid;
                            ?>
"><?php 
                            echo $twit_mess;
                            ?>
</span>&nbsp;<?php 
                            MainWPTwitter::genTwitterButton($sendText);
                            ?>
<span><a href="#" class="mainwp-dismiss-twit" ><i class="fa fa-times-circle"></i> <?php 
                            _e('Dismiss', 'mainwp');
                            ?>
</a></span></div>
                        <?php 
                        }
                    }
                }
            }
            ?>
    <?php 
        }
        ?>
       
                                
    <div id="dashboard-widgets-wrap">

    <?php 
        require_once ABSPATH . 'wp-admin/includes/dashboard.php';
        wp_dashboard();
        ?>

    <div class="clear"></div>
    </div><!-- dashboard-widgets-wrap -->
    <?php 
    }
Example #9
0
    public static function render()
    {
        $current_wpid = MainWPUtility::get_current_wpid();
        if (!MainWPUtility::ctype_digit($current_wpid)) {
            return;
        }
        $website = MainWPDB::Instance()->getWebsiteById($current_wpid, true);
        ?>
    <div class="mainwp-row-top">
        <div style="display: inline-block; width: 100px;"><?php 
        _e('Groups:', 'mainwp');
        ?>
</div>
        <?php 
        echo $website->groups == '' ? 'None' : $website->groups;
        ?>
    </div>
    <div class="mainwp-row">
        <div style="display: inline-block; width: 100px;"><?php 
        _e('Notes:', 'mainwp');
        ?>
</div>
        <a href="#" class="mainwp_notes_show_all" id="mainwp_notes_<?php 
        echo $website->id;
        ?>
"><i class="fa fa-pencil"></i> <?php 
        _e('Open Notes', 'mainwp');
        ?>
</a><img src="<?php 
        echo plugins_url('images/notes.png', dirname(__FILE__));
        ?>
" class="mainwp_notes_img" id="mainwp_notes_img_<?php 
        echo $website->id;
        ?>
" <?php 
        if ($website->note == '') {
            echo 'style="display: none;"';
        }
        ?>
 />
    </div>
    <span style="display: none"
          id="mainwp_notes_<?php 
        echo $website->id;
        ?>
_note"><?php 
        echo $website->note;
        ?>
</span>
    <div class="mainwp-row">
        <div style="display: inline-block; width: 100px;"><?php 
        _e('Go to:', 'mainwp');
        ?>
</div>
        <a href="admin.php?page=SiteOpen&newWindow=yes&websiteid=<?php 
        echo $website->id;
        ?>
" target="_blank"><i class="fa fa-external-link"></i> <?php 
        _e('WP Admin', 'mainwp');
        ?>
</a> | <a target="_blank" href="<?php 
        echo $website->url;
        ?>
"><i class="fa fa-external-link"></i> <?php 
        _e('Front Page', 'mainwp');
        ?>
</a>
    </div>
    <div class="mainwp-row">
        <div style="display: inline-block; width: 100px;"><?php 
        _e('Child Site:', 'mainwp');
        ?>
</div>
        <a href="admin.php?page=managesites&id=<?php 
        echo $website->id;
        ?>
"><i class="fa fa-pencil-square-o"></i> <?php 
        _e('Edit', 'mainwp');
        ?>
</a> | <a target="_blank" href="admin.php?page=managesites&scanid=<?php 
        echo $website->id;
        ?>
"><i class="fa fa-shield"></i> <?php 
        _e('Security Scan', 'mainwp');
        ?>
</a>
    </div>

    <?php 
        do_action("mainwp_shortcuts_widget", $website);
        ?>
    <div id="mainwp_notes_overlay" class="mainwp_overlay"></div>
    <div id="mainwp_notes" class="mainwp_popup">
        <a id="mainwp_notes_closeX" class="mainwp_closeX" style="display: inline; "></a>

        <div id="mainwp_notes_title" class="mainwp_popup_title"><a href="<?php 
        echo admin_url('admin.php?page=managesites&dashboard=' . $website->id);
        ?>
"><?php 
        echo stripslashes($website->name);
        ?>
</a></div>
        <div id="mainwp_notes_content">
            <textarea style="width: 580px !important; height: 300px;"
                      id="mainwp_notes_note"></textarea>
        </div>
        <div><em>Allowed HTML Tags: &lt;p&gt;, &lt;strong&gt;, &lt;em&gt;, &lt;br/&gt;, &lt;hr/&gt;, &lt;a&gt; </em></div><br/>
        <form>
            <div style="float: right" id="mainwp_notes_status"></div>
            <input type="button" class="button cont button-primary" id="mainwp_notes_save" value="<?php 
        _e('Save Note', 'mainwp');
        ?>
"/>
            <input type="button" class="button cont" id="mainwp_notes_cancel" value="<?php 
        _e('Close', 'mainwp');
        ?>
"/>
            <input type="hidden" id="mainwp_notes_websiteid" value=""/>
        </form>
    </div>
    <?php 
    }
Example #10
0
    public static function renderDashboardBody($websites, $pDashboard, $pScreenLayout)
    {
        ?>
    <form action="admin-post.php" method="post">
        <?php 
        wp_nonce_field('mainwp_tab-general');
        ?>
        <?php 
        wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
        ?>
        <?php 
        wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
        ?>
        <input type="hidden" name="action" value="save_howto_testPages_general"/>
        <div class="postbox" style="padding-top: 1em;">
            <table id="mainwp-refresh-bar" width="100%">
                <tbody><tr>
                    <?php 
        $current_wp_id = MainWPUtility::get_current_wpid();
        $website = null;
        if (!empty($current_wp_id)) {
            $website = $websites[0];
        }
        $imgfavi = "";
        if ($website !== null) {
            if (get_option('mainwp_use_favicon', 1) == 1) {
                $favi = MainWPDB::Instance()->getWebsiteOption($website, 'favi_icon', "");
                $favi_url = MainWPUtility::get_favico_url($favi, $website);
                $imgfavi = '<img src="' . $favi_url . '" width="16" height="16" style="vertical-align:middle;"/>&nbsp;';
            }
        }
        if (time() - ($website == null ? MainWPDB::Instance()->getFirstSyncedSite() : $website->dtsSync) > 60 * 60 * 24) {
            ?>
                <td id="mainwp-welcome-bar" width="47%" style="padding-left: 1em;">
                    <span class="mainwp-reminder"><?php 
            _e('Your MainWP Dashboard has not been synced for 24 hours! Click the Sync Data button to get the latest data from child sites.', 'mainwp');
            ?>
</span><br/>
                </td>
                    <?php 
        } else {
            ?>
                <td id="mainwp-welcome-bar" width="47%" style="padding-left: 1em;">
                    <span style="font-size: 24px"><?php 
            echo $website == null ? __('Welcome to Your MainWP Dashboard!', 'mainwp') : sprintf(__('Welcome to %s Dashboard!', 'mainwp'), stripslashes($website->name));
            ?>
</span><br/>
                    <span style="font-style: italic; font-size: 14px;"><?php 
            echo $website == null ? __('Manage your WordPress sites with ease.', 'mainwp') : sprintf(__('This information is only for %s%s', 'mainwp'), $imgfavi, MainWPUtility::getNiceURL($website->url, true));
            ?>
</span>
                </td>
                    <?php 
        }
        ?>
                <td id="mainwp-refresh-bar-buttons">
                <a class="button-hero button mainwp-upgrade-button" id="dashboard_refresh" title="<?php 
        echo MainWPRightNow::renderLastUpdate();
        ?>
"><?php 
        _e('<i class="fa fa-refresh"></i> Sync Data', 'mainwp');
        ?>
</a>
                <a class="button-hero button-primary button mainwp-addsite-button" href="admin.php?page=managesites&do=new"><?php 
        _e('<i class="fa fa-plus"></i> Add New Site', 'mainwp');
        ?>
</a>
                <a class="button-hero button-primary button mainwp-button-red" target="_blank" href="https://extensions.mainwp.com"><?php 
        _e('<i class="fa fa-cart-plus"></i> Get New Extensions', 'mainwp');
        ?>
</a>
                </td>
            <div id="dashboard_refresh_statusextra" style="display: none"> <i class="fa fa-spinner fa-pulse"></i> </div>
                </tr></tbody>
            </table>
            <div id="mainwp_dashboard_refresh_status"></div>
        </div>
        <div id="mainwp_main_errors" class="mainwp_error"></div>
    </form>

    <div id="dashboard-widgets-wrap">

    <?php 
        require_once ABSPATH . 'wp-admin/includes/dashboard.php';
        wp_dashboard();
        ?>

    <div class="clear"></div>
    </div><!-- dashboard-widgets-wrap -->
    <?php 
    }
Example #11
0
 public static function hookGetDashboardSites($pluginFile, $key)
 {
     if (!self::hookVerify($pluginFile, $key)) {
         return null;
     }
     $current_wpid = MainWPUtility::get_current_wpid();
     if ($current_wpid) {
         $sql = MainWPDB::Instance()->getSQLWebsiteById($current_wpid);
     } else {
         $sql = MainWPDB::Instance()->getSQLWebsitesForCurrentUser();
     }
     return MainWPDB::Instance()->query($sql);
 }
    public static function renderWidget($renew, $pExit = true)
    {
        $current_wpid = MainWPUtility::get_current_wpid();
        if (empty($current_wpid)) {
            return;
        }
        $sql = MainWPDB::Instance()->getSQLWebsiteById($current_wpid);
        $websites = MainWPDB::Instance()->query($sql);
        $allPlugins = array();
        if ($websites) {
            $website = @MainWPDB::fetch_object($websites);
            if ($website && $website->plugins != '') {
                $plugins = json_decode($website->plugins, 1);
                if (is_array($plugins) && count($plugins) != 0) {
                    foreach ($plugins as $plugin) {
                        $allPlugins[] = $plugin;
                    }
                }
            }
            @MainWPDB::free_result($websites);
        }
        $actived_plugins = MainWPUtility::getSubArrayHaving($allPlugins, 'active', 1);
        $actived_plugins = MainWPUtility::sortmulti($actived_plugins, 'name', 'desc');
        $inactive_plugins = MainWPUtility::getSubArrayHaving($allPlugins, 'active', 0);
        $inactive_plugins = MainWPUtility::sortmulti($inactive_plugins, 'name', 'desc');
        $plugins_outdate = array();
        if (count($allPlugins) > 0 && $website) {
            $plugins_outdate = json_decode(MainWPDB::Instance()->getWebsiteOption($website, 'plugins_outdate_info'), true);
            if (!is_array($plugins_outdate)) {
                $plugins_outdate = array();
            }
            $pluginsOutdateDismissed = json_decode(MainWPDB::Instance()->getWebsiteOption($website, 'plugins_outdate_dismissed'), true);
            if (is_array($pluginsOutdateDismissed)) {
                $plugins_outdate = array_diff_key($plugins_outdate, $pluginsOutdateDismissed);
            }
            $userExtension = MainWPDB::Instance()->getUserExtension();
            $decodedDismissedPlugins = json_decode($userExtension->dismissed_plugins, true);
            if (is_array($decodedDismissedPlugins)) {
                $plugins_outdate = array_diff_key($plugins_outdate, $decodedDismissedPlugins);
            }
        }
        ?>
        <div class="clear mwp_plugintheme_widget">            
            <a class="mainwp_action left mainwp_action_down plugins_actived_lnk" href="#"><?php 
        _e('Active', 'mainwp');
        ?>
 (<?php 
        echo count($actived_plugins);
        ?>
)</a><a class="mainwp_action mid plugins_inactive_lnk right" href="#" ><?php 
        _e('Inactive', 'mainwp');
        ?>
 (<?php 
        echo count($inactive_plugins);
        ?>
)</a><br/><br/>
            <div class="mainwp_plugins_active">
                <?php 
        $str_format = __(" | Last Updated %s Days Ago", "mainwp");
        for ($i = 0; $i < count($actived_plugins); $i++) {
            $outdate_notice = "";
            $slug = $actived_plugins[$i]['slug'];
            if (isset($plugins_outdate[$slug])) {
                $plugin_outdate = $plugins_outdate[$slug];
                $now = new \DateTime();
                $last_updated = $plugin_outdate['last_updated'];
                $plugin_last_updated_date = new \DateTime('@' . $last_updated);
                $diff_in_days = $now->diff($plugin_last_updated_date)->format('%a');
                $outdate_notice = sprintf($str_format, $diff_in_days);
            }
            ?>
                <div class="mainwp-row mainwp-active">
                    <input class="pluginSlug" type="hidden" name="slug" value="<?php 
            echo $actived_plugins[$i]['slug'];
            ?>
"/>
                    <input class="websiteId" type="hidden" name="id" value="<?php 
            echo $website->id;
            ?>
"/>
                    <span class="mainwp-left-col">						
                            <a href="<?php 
            echo admin_url() . 'plugin-install.php?tab=plugin-information&plugin=' . dirname($actived_plugins[$i]['slug']) . '&TB_iframe=true&width=640&height=477';
            ?>
" target="_blank"
                                                                                                                class="thickbox" title="More information about <?php 
            echo $actived_plugins[$i]['name'];
            ?>
">
                        <?php 
            echo $actived_plugins[$i]['name'];
            ?>
                    </a><?php 
            echo " " . $actived_plugins[$i]['version'];
            ?>
 <?php 
            echo $outdate_notice;
            ?>
					</span>					       
                    <div class="mainwp-right-col pluginsAction">
                        <?php 
            if (mainwp_current_user_can("dashboard", "activate_deactivate_plugins")) {
                ?>
                            <a href="#" class="mainwp-plugin-deactivate"><i class="fa fa-toggle-off"></i> <?php 
                _e('Deactivate', 'mainwp');
                ?>
</a>
                        <?php 
            }
            ?>
                    </div>                    
                    <div style="clear: left;"></div>
                    <div class="mainwp-row-actions-working"><i class="fa fa-spinner fa-pulse"></i> <?php 
            _e('Please wait', 'mainwp');
            ?>
</div>                    
                    <div>&nbsp;</div>
                </div>
                <?php 
        }
        ?>
            </div>

            <div class="mainwp_plugins_inactive" style="display: none">
                <?php 
        for ($i = 0; $i < count($inactive_plugins); $i++) {
            $outdate_notice = "";
            $slug = $inactive_plugins[$i]['slug'];
            if (isset($plugins_outdate[$slug])) {
                $plugin_outdate = $plugins_outdate[$slug];
                $now = new \DateTime();
                $last_updated = $plugin_outdate['last_updated'];
                $plugin_last_updated_date = new \DateTime('@' . $last_updated);
                $diff_in_days = $now->diff($plugin_last_updated_date)->format('%a');
                $outdate_notice = sprintf($str_format, $diff_in_days);
            }
            ?>
                <div class="mainwp-row mainwp-inactive">
                    <input class="pluginSlug" type="hidden" name="slug" value="<?php 
            echo $inactive_plugins[$i]['slug'];
            ?>
"/>
                    <input class="websiteId" type="hidden" name="id" value="<?php 
            echo $website->id;
            ?>
"/>
                    <span class="mainwp-left-col">
                    <a href="<?php 
            echo admin_url() . 'plugin-install.php?tab=plugin-information&plugin=' . dirname($inactive_plugins[$i]['slug']) . '&TB_iframe=true&width=640&height=477';
            ?>
" target="_blank"
                                                                                                                                                                                                                    class="thickbox" title="More information about <?php 
            echo $inactive_plugins[$i]['name'];
            ?>
">
                                    <?php 
            echo $inactive_plugins[$i]['name'];
            ?>
                            </a><?php 
            echo " " . $inactive_plugins[$i]['version'];
            ?>
 <?php 
            echo $outdate_notice;
            ?>
							
                    </span>                                       
                    <div class="mainwp-right-col pluginsAction">
                        <?php 
            if (mainwp_current_user_can("dashboard", "activate_deactivate_plugins")) {
                ?>
                        <a href="#" class="mainwp-plugin-activate"><i class="fa fa-toggle-on"></i> <?php 
                _e('Activate', 'mainwp');
                ?>
</a> | 
                        <?php 
            }
            ?>
                        <?php 
            if (mainwp_current_user_can("dashboard", "delete_plugins")) {
                ?>
                        <a href="#" class="mainwp-plugin-delete mainwp-red"><i class="fa fa-trash"></i> <?php 
                _e('Delete', 'mainwp');
                ?>
</a>
                        <?php 
            }
            ?>
                    </div>
                        <div style="clear: left;"></div>
                    <div class="mainwp-row-actions-working"><i class="fa fa-spinner fa-pulse"></i> <?php 
            _e('Please wait', 'mainwp');
            ?>
</div>                    
                        <div>&nbsp;</div>
                </div>
                <?php 
        }
        ?>
            </div>
        </div>
    <div class="clear"></div>
    <?php 
        if ($pExit == true) {
            exit;
        }
    }
    public static function renderSites()
    {
        $current_wpid = MainWPUtility::get_current_wpid();
        if ($current_wpid) {
            $sql = MainWPDB::Instance()->getSQLWebsiteById($current_wpid);
        } else {
            $sql = MainWPDB::Instance()->getSQLWebsitesForCurrentUser();
        }
        $websites = MainWPDB::Instance()->query($sql);
        if (!$websites) {
            return;
        }
        $total_securityIssues = 0;
        @MainWPDB::data_seek($websites, 0);
        while ($websites && ($website = @MainWPDB::fetch_object($websites))) {
            if (MainWPUtility::ctype_digit($website->securityIssues)) {
                $total_securityIssues += $website->securityIssues;
            }
        }
        //We found some with security issues!
        if ($total_securityIssues > 0) {
            ?>
        <div class="clear">
            <div class="mainwp-row-top darkred">
                <span class="mainwp-left-col"><span class="mainwp-rightnow-number"><?php 
            echo $total_securityIssues;
            ?>
</span> <?php 
            _e('Security issue', 'mainwp');
            echo $total_securityIssues > 1 ? 's' : '';
            ?>
</span>
                <span class="mainwp-mid-col">&nbsp;</span>
                <span class="mainwp-right-col"><a href="#" id="mainwp_securityissues_show" onClick="return rightnow_show('securityissues');"><?php 
            _e('Show All', 'mainwp');
            ?>
</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" class="securityIssues_dashboard_allFixAll button-primary" value="<?php 
            _e('Fix All', 'mainwp');
            ?>
"/></span>
            </div>
            <div id="wp_securityissues" style="display: none">
                <?php 
            @MainWPDB::data_seek($websites, 0);
            while ($websites && ($website = @MainWPDB::fetch_object($websites))) {
                if (!MainWPUtility::ctype_digit($website->securityIssues) || $website->securityIssues == 0) {
                    continue;
                }
                ?>
                <div class="mainwp-row" siteid="<?php 
                echo $website->id;
                ?>
">
                    <span class="mainwp-left-col"><a href="admin.php?page=managesites&scanid=<?php 
                echo $website->id;
                ?>
"><?php 
                echo stripslashes($website->name);
                ?>
</a></span>
                    <span class="mainwp-mid-col"><span class="<?php 
                echo $website->securityIssues > 0 ? 'darkred' : 'mainwp_ga_plus';
                ?>
"><span class="mainwp-rightnow-number"><?php 
                echo $website->securityIssues;
                ?>
</span> Issue<?php 
                echo $website->securityIssues > 1 ? 's' : '';
                ?>
</span></span>
                    <span class="mainwp-right-col"><?php 
                if ($website->securityIssues == 0) {
                    ?>
                            <input type="button" class="securityIssues_dashboard_unfixAll button" value="<?php 
                    _e('Unfix All', 'mainwp');
                    ?>
"/>
                        <?php 
                } else {
                    ?>
                            <input type="button" class="securityIssues_dashboard_fixAll button-primary" value="<?php 
                    _e('Fix All', 'mainwp');
                    ?>
"/>
                        <?php 
                }
                ?>
                        <i class="fa fa-spinner fa-pulse img-loader" style="display: none;"></i>
                    </span>
                </div>
                <?php 
            }
            ?>
            </div>
        </div>
        <?php 
        }
    }
    public static function renderWidget($renew, $pExit = true)
    {
        $current_wpid = MainWPUtility::get_current_wpid();
        if (empty($current_wpid)) {
            return;
        }
        $sql = MainWPDB::Instance()->getSQLWebsiteById($current_wpid);
        $websites = MainWPDB::Instance()->query($sql);
        $allThemes = array();
        if ($websites) {
            $website = @MainWPDB::fetch_object($websites);
            if ($website && $website->themes != '') {
                $themes = json_decode($website->themes, 1);
                if (is_array($themes) && count($themes) != 0) {
                    foreach ($themes as $theme) {
                        $allThemes[] = $theme;
                    }
                }
            }
            @MainWPDB::free_result($websites);
        }
        $actived_themes = MainWPUtility::getSubArrayHaving($allThemes, 'active', 1);
        $actived_themes = MainWPUtility::sortmulti($actived_themes, 'name', 'desc');
        $inactive_themes = MainWPUtility::getSubArrayHaving($allThemes, 'active', 0);
        $inactive_themes = MainWPUtility::sortmulti($inactive_themes, 'name', 'desc');
        ?>
        <div class="clear">            
            <a class="mainwp_action left mainwp_action_down themes_actived_lnk" href="#"><?php 
        _e('Active', 'mainwp');
        ?>
 (<?php 
        echo count($actived_themes);
        ?>
)</a><a class="mainwp_action mid themes_inactive_lnk right" href="#" ><?php 
        _e('Inactive', 'mainwp');
        ?>
 (<?php 
        echo count($inactive_themes);
        ?>
)</a><br/><br/>
            <div class="mainwp_themes_active">
                <?php 
        for ($i = 0; $i < count($actived_themes); $i++) {
            ?>
                <div class="mainwp-row mainwp-active">
                    <input class="themeName" type="hidden" name="name" value="<?php 
            echo $actived_themes[$i]['name'];
            ?>
"/>
                    <input class="websiteId" type="hidden" name="id" value="<?php 
            echo $website->id;
            ?>
"/>
                    <span class="mainwp-left-col">												
                            <?php 
            echo $actived_themes[$i]['name'] . " " . $actived_themes[$i]['version'];
            ?>
                            
                    </span>					       
                </div>
                <?php 
        }
        ?>
            </div>

            <div class="mainwp_themes_inactive" style="display: none">
                <?php 
        for ($i = 0; $i < count($inactive_themes); $i++) {
            ?>
                <div class="mainwp-row mainwp-inactive">
                    <input class="themeName" type="hidden" name="name" value="<?php 
            echo $inactive_themes[$i]['name'];
            ?>
"/>
                    <input class="websiteId" type="hidden" name="id" value="<?php 
            echo $website->id;
            ?>
"/>
                    <span class="mainwp-left-col">					
                        <?php 
            echo $inactive_themes[$i]['name'] . " " . $inactive_themes[$i]['version'];
            ?>
							
                    </span>                    
                    <div class="mainwp-right-col themesAction">
                        <?php 
            if (mainwp_current_user_can("dashboard", "activate_themes")) {
                ?>
                        <a href="#" class="mainwp-theme-activate"><i class="fa fa-toggle-on"></i> <?php 
                _e('Activate', 'mainwp');
                ?>
</a> |
                        <?php 
            }
            ?>
                        <?php 
            if (mainwp_current_user_can("dashboard", "delete_themes")) {
                ?>
                        <a href="#" class="mainwp-theme-delete mainwp-red"><i class="fa fa-trash"></i> <?php 
                _e('Delete', 'mainwp');
                ?>
</a>
                        <?php 
            }
            ?>
                    </div>
                    <div style="clear: left;"></div>
                    <div class="mainwp-row-actions-working"><i class="fa fa-spinner fa-pulse"></i> <?php 
            _e('Please wait', 'mainwp');
            ?>
</div>
                    <div>&nbsp;</div>
                </div>
                <?php 
        }
        ?>
            </div>
        </div>
    <div class="clear"></div>
    <?php 
        if ($pExit == true) {
            exit;
        }
    }