示例#1
0
 public static function performSearch()
 {
     MainWP_Install_Bulk::performSearch(MainWP_Themes::getClassName(), 'Themes');
 }
示例#2
0
 public function __construct($mainwp_plugin_file)
 {
     MainWP_System::$instance = $this;
     $this->update();
     $this->plugin_slug = plugin_basename($mainwp_plugin_file);
     list($t1, $t2) = explode('/', $this->plugin_slug);
     $this->slug = str_replace('.php', '', $t2);
     if (is_admin()) {
         include_once ABSPATH . 'wp-admin' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'plugin.php';
         //Version information from wordpress
         $pluginData = get_plugin_data($mainwp_plugin_file);
         $this->current_version = $pluginData['Version'];
         $currentVersion = get_option('mainwp_plugin_version');
         if (version_compare($currentVersion, $this->current_version, '<')) {
             update_option('mainwp_reset_user_tips', array());
             MainWP_Utility::update_option('mainwp_reset_user_cookies', array());
             //delete_option('mainwp_api_sslVerifyCertificate');
         }
         MainWP_Utility::update_option('mainwp_plugin_version', $this->current_version);
     }
     if (!defined('MAINWP_VERSION')) {
         define('MAINWP_VERSION', $this->current_version);
     }
     if (get_option('mainwp_upgradeVersionInfo') != '' && get_option('mainwp_upgradeVersionInfo') != null) {
         $this->upgradeVersionInfo = unserialize(get_option('mainwp_upgradeVersionInfo'));
     } else {
         $this->upgradeVersionInfo = null;
     }
     $this->handleSettingsPost();
     $ssl_api_verifyhost = get_option('mainwp_api_sslVerifyCertificate') === false || get_option('mainwp_api_sslVerifyCertificate') == 1 ? 1 : 0;
     if ($ssl_api_verifyhost == 0) {
         add_filter('http_request_args', array(MainWP_Extensions::getClassName(), 'noSSLFilterExtensionUpgrade'), 99, 2);
     }
     MainWP_Extensions::init();
     add_action('in_plugin_update_message-' . $this->plugin_slug, array($this, 'in_plugin_update_message'), 10, 2);
     add_action('init', array(&$this, 'localization'));
     // define the alternative API for updating checking
     add_filter('site_transient_update_plugins', array(&$this, 'check_update_custom'));
     // Define the alternative response for information checking
     add_filter('pre_set_site_transient_update_plugins', array(&$this, 'pre_check_update_custom'));
     add_filter('plugins_api', array(&$this, 'check_info'), 10, 3);
     $this->metaboxes = new MainWP_Meta_Boxes();
     MainWP_Main::get();
     //init main dashboard
     MainWP_Manage_Sites::init();
     new MainWP_Hooks();
     //Init the hooks
     //Change menu & widgets
     add_action('admin_menu', array(&$this, 'new_menus'));
     //Change footer
     add_filter('update_footer', array(&$this, 'update_footer'), 15);
     //Add js
     add_action('admin_head', array(&$this, 'admin_head'));
     add_action('admin_enqueue_scripts', array(&$this, 'admin_enqueue_styles'));
     add_action('admin_enqueue_scripts', array(&$this, 'admin_enqueue_scripts'));
     //Add body class
     add_action('admin_body_class', array(&$this, 'admin_body_class'));
     //Handle the bulkpost
     add_action('publish_bulkpost', array(&$this, 'publish_bulkpost'));
     add_action('save_post', array(&$this, 'save_bulkpost'));
     add_action('save_post', array(&$this, 'save_bulkpage'));
     add_action('add_meta_boxes_bulkpost', array('MainWP_Post', 'addStickyOption'));
     //Handle the bulkpage
     add_action('publish_bulkpage', array(&$this, 'publish_bulkpage'));
     //Add meta boxes for the bulkpost
     add_action('admin_init', array(&$this, 'admin_init'));
     //Create the post types for bulkpost/...
     add_action('init', array(&$this, 'create_post_type'));
     add_action('init', array(&$this, 'parse_init'));
     add_action('init', array(&$this, 'init'), 9999);
     add_action('admin_init', array($this, 'admin_redirects'));
     //Remove the pages from the menu which I use in AJAX
     add_action('admin_menu', array(&$this, 'admin_menu'));
     add_action('admin_menu', array(&$this, 'remove_wp_menus'));
     //Add custom error messages
     add_filter('post_updated_messages', array(&$this, 'post_updated_messages'));
     add_action('login_form', array(&$this, 'login_form'));
     add_action('admin_print_styles', array(&$this, 'admin_print_styles'));
     add_filter('admin_footer', array($this, 'admin_footer'));
     MainWP_Install_Bulk::init();
     do_action('mainwp_cronload_action');
     //Cron every 5 minutes
     add_action('mainwp_cronstats_action', array($this, 'mainwp_cronstats_action'));
     add_action('mainwp_cronbackups_action', array($this, 'mainwp_cronbackups_action'));
     add_action('mainwp_cronbackups_continue_action', array($this, 'mainwp_cronbackups_continue_action'));
     add_action('mainwp_cronupdatescheck_action', array($this, 'mainwp_cronupdatescheck_action'));
     add_action('mainwp_cronpingchilds_action', array($this, 'mainwp_cronpingchilds_action'));
     add_filter('cron_schedules', array('MainWP_Utility', 'getCronSchedules'));
     $useWPCron = get_option('mainwp_wp_cron') === false || get_option('mainwp_wp_cron') == 1;
     //todo: remove in next version
     if (($sched = wp_next_scheduled('mainwp_cronofflinecheck_action')) != false) {
         wp_unschedule_event($sched, 'mainwp_cronofflinecheck_action');
     }
     if (($sched = wp_next_scheduled('mainwp_cronstats_action')) == false) {
         if ($useWPCron) {
             wp_schedule_event(time(), 'hourly', 'mainwp_cronstats_action');
         }
     } else {
         if (!$useWPCron) {
             wp_unschedule_event($sched, 'mainwp_cronstats_action');
         }
     }
     if (($sched = wp_next_scheduled('mainwp_cronbackups_action')) == false) {
         if ($useWPCron) {
             wp_schedule_event(time(), 'hourly', 'mainwp_cronbackups_action');
         }
     } else {
         if (!$useWPCron) {
             wp_unschedule_event($sched, 'mainwp_cronbackups_action');
         }
     }
     if (($sched = wp_next_scheduled('mainwp_cronbackups_continue_action')) == false) {
         if ($useWPCron) {
             wp_schedule_event(time(), '5minutely', 'mainwp_cronbackups_continue_action');
         }
     } else {
         if (!$useWPCron) {
             wp_unschedule_event($sched, 'mainwp_cronbackups_continue_action');
         }
     }
     if (($sched = wp_next_scheduled('mainwp_cronremotedestinationcheck_action')) != false) {
         wp_unschedule_event($sched, 'mainwp_cronremotedestinationcheck_action');
     }
     if (($sched = wp_next_scheduled('mainwp_cronpingchilds_action')) == false) {
         if ($useWPCron) {
             wp_schedule_event(time(), 'daily', 'mainwp_cronpingchilds_action');
         }
     } else {
         if (!$useWPCron) {
             wp_unschedule_event($sched, 'mainwp_cronpingchilds_action');
         }
     }
     if (($sched = wp_next_scheduled('mainwp_cronupdatescheck_action')) == false) {
         if ($useWPCron) {
             wp_schedule_event(time(), 'minutely', 'mainwp_cronupdatescheck_action');
         }
     } else {
         if (!$useWPCron) {
             wp_unschedule_event($sched, 'mainwp_cronupdatescheck_action');
         }
     }
     add_action('admin_notices', array(&$this, 'admin_notices'));
     add_filter('mainwp-activated-check', array(&$this, 'activated_check'));
     add_filter('mainwp-activated-sub-check', array(&$this, 'activated_sub_check'));
     add_filter('mainwp-extension-enabled-check', array(MainWP_Extensions::getClassName(), 'isExtensionEnabled'));
     /**
      * This hook allows you to get a list of sites via the 'mainwp-getsites' filter.
      * @link http://codex.mainwp.com/#mainwp-getsites
      *
      * @see \MainWP_Extensions::hookGetSites
      */
     add_filter('mainwp-getsites', array(MainWP_Extensions::getClassName(), 'hookGetSites'), 10, 4);
     add_filter('mainwp-getdbsites', array(MainWP_Extensions::getClassName(), 'hookGetDBSites'), 10, 5);
     /**
      * This hook allows you to get a information about groups via the 'mainwp-getgroups' filter.
      * @link http://codex.mainwp.com/#mainwp-getgroups
      *
      * @see \MainWP_Extensions::hookGetGroups
      */
     add_filter('mainwp-getgroups', array(MainWP_Extensions::getClassName(), 'hookGetGroups'), 10, 4);
     add_action('mainwp_fetchurlsauthed', array(&$this, 'filter_fetchUrlsAuthed'), 10, 7);
     add_filter('mainwp_fetchurlauthed', array(&$this, 'filter_fetchUrlAuthed'), 10, 5);
     add_filter('mainwp_getdashboardsites', array(MainWP_Extensions::getClassName(), 'hookGetDashboardSites'), 10, 7);
     add_filter('mainwp-manager-getextensions', array(MainWP_Extensions::getClassName(), 'hookManagerGetExtensions'));
     add_action('mainwp_bulkpost_metabox_handle', array($this, 'hookBulkPostMetaboxHandle'));
     add_action('mainwp_bulkpage_metabox_handle', array($this, 'hookBulkPageMetaboxHandle'));
     $this->posthandler = new MainWP_Post_Handler();
     do_action('mainwp-activated');
     MainWP_Post::init();
     MainWP_Settings::init();
     MainWP_Manage_Backups::init();
     MainWP_User::init();
     MainWP_Page::init();
     MainWP_Themes::init();
     MainWP_Plugins::init();
     MainWP_Right_Now::init();
     MainWP_Setup_Wizard::init();
     if (defined('WP_CLI') && WP_CLI) {
         MainWP_WP_CLI_Command::init();
     }
     //WP-Cron
     if (defined('DOING_CRON') && DOING_CRON) {
         if (isset($_GET['mainwp_run']) && !empty($_GET['mainwp_run'])) {
             add_action('init', array($this, 'cron_active'), PHP_INT_MAX);
         }
     }
 }
示例#3
0
    public static function renderPluginsTable($favoritesCallback = '')
    {
        global $tab;
        if (!mainwp_current_user_can("dashboard", "install_plugins")) {
            mainwp_do_not_have_permissions(__('install plugins', 'mainwp'));
            return;
        }
        ?>
		<a href="#" id="MainWPInstallBulkNavSearch" class="mainwp_action left <?php 
        echo $tab !== 'upload' ? 'mainwp_action_down' : '';
        ?>
" ><?php 
        _e('Search', 'mainwp');
        ?>
</a><a href="#" id="MainWPInstallBulkNavUpload" class="mainwp_action <?php 
        echo $tab === 'upload' ? 'mainwp_action_down' : '';
        ?>
 right upload" ><?php 
        _e('Upload', 'mainwp');
        ?>
</a>
		<br class="clear" /><br />

		<div class="mainwp_config_box_left" style="width: calc(100% - 290px);">
			<div class="error below-h2" style="display: none;" id="ajax-error-zone"></div>
			<div class="mainwp-upload-plugin">
				<?php 
        MainWP_Install_Bulk::renderUpload('Plugins');
        ?>
			</div>
			<div class="mainwp-browse-plugins hide-if-upload">
				<?php 
        self::$pluginsTable->views();
        ?>
				<form id="plugin-filter" method="post">
					<?php 
        self::$pluginsTable->display();
        ?>
				</form>
			</div>
			<div style="clear: both;"></div>
		</div>

		<script type="text/javascript">
			//mainwp_install_set_install_links();
		</script>

		<?php 
        MainWP_UI::select_sites_box(__("Step 2: Select Sites", 'mainwp'), 'checkbox', true, true, 'mainwp_select_sites_box_right');
        ?>

		<div class="mainwp_config_box_right">
			<div class="postbox">
				<h3 class="mainwp_box_title"><i class="fa fa-cog"></i> <?php 
        _e('Step 3: Installation Options', 'mainwp');
        ?>
</h3>
				<div class="inside">
					<input type="checkbox" value="1" checked id="chk_activate_plugin" /> <label for="chk_activate_plugin"><?php 
        _e('Activate Plugin After Installation', 'mainwp');
        ?>
</label><br/>
					<input type="checkbox" value="2" checked id="chk_overwrite" /> <label for="chk_overwrite"><?php 
        _e('Overwrite Existing Plugin, if already installed', 'mainwp');
        ?>
</label>
				</div>
			</div>
			<input type="button" value="<?php 
        _e("Complete Installation", 'mainwp');
        ?>
" class="button-primary button button-hero button-right hide-if-upload" id="mainwp_plugin_bulk_install_btn" name="bulk-install">
			<input type="button" value="<?php 
        _e('Complete Installation', 'mainwp');
        ?>
" class="button-primary button button-hero button-right show-if-upload" onClick="mainwp_upload_bulk('plugins');">
		</div>
		<div style="clear: both;"></div>

		<?php 
        if (!empty($favoritesCallback)) {
            ?>
			<script type="text/javascript">
				jQuery(document).ready(function () {
					<?php 
            echo $favoritesCallback . '()';
            ?>
				});
			</script>
			<?php 
        }
    }
 function mainwp_cleanbulkuploadplugintheme()
 {
     $this->secure_request('mainwp_cleanbulkuploadplugintheme');
     MainWP_Install_Bulk::cleanUpload();
 }
 public static function performUpload()
 {
     MainWP_Utility::endSession();
     //Fetch info..
     $post_data = array('url' => json_encode(explode('||', $_POST['urls'])), 'type' => $_POST['type']);
     if ($_POST['activatePlugin'] == 'true') {
         $post_data['activatePlugin'] = 'yes';
     }
     if ($_POST['overwrite'] == 'true') {
         $post_data['overwrite'] = true;
     }
     $output = new stdClass();
     $output->ok = array();
     $output->errors = array();
     $websites = array(MainWP_DB::Instance()->getWebsiteById($_POST['siteId']));
     MainWP_Utility::fetchUrlsAuthed($websites, 'installplugintheme', $post_data, array(MainWP_Install_Bulk::getClassName(), 'InstallPluginTheme_handler'), $output);
     die(json_encode($output));
 }