Create New Item
×
Item Type
File
Folder
Item Name
×
Search file in folder and subfolders...
File Manager
/
wp-content
/
plugins
/
gplvault-updater
/
includes
/
upgrader
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?php if (!class_exists('WP_Upgrader', false)) { include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; } class GPLVault_Plugin_Upgrader extends Plugin_Upgrader { public function upgrade_strings() { parent::upgrade_strings(); $this->strings['downloading_package'] = __('Downloading the GPLVault plugin upgrade package…', 'gplvault'); } public function install_strings() { parent::install_strings(); $this->strings['downloading_package'] = __('Downloading the GPLVault plugin install package…', 'gplvault'); } public function download_package($package, $check_signatures = false, $hook_extra = array()) { if (!preg_match('!^(http|https|ftp)://!i', $package) && file_exists($package)) { return $package; } if (empty($package)) { return new WP_Error('no_package', $this->strings['no_package']); } $this->skin->feedback('downloading_package', $package); $timeout = apply_filters('gv_download_timeout', 500); $download_file = download_url($package, (int) $timeout, $check_signatures); if (is_wp_error($download_file) && !$download_file->get_error_data('softfail-filename')) { return new WP_Error('download_failed', $this->strings['download_failed'], $download_file->get_error_message()); } return $download_file; } public function install($package, $args = array()) { $defaults = array('clear_update_cache' => true); $parsed_args = wp_parse_args($args, $defaults); $this->init(); $this->install_strings(); add_filter('upgrader_source_selection', array($this, 'check_package')); if ($parsed_args['clear_update_cache']) { add_action('upgrader_process_complete', 'wp_clean_plugins_cache', 9, 0); } $this->run(array('package' => $package, 'destination' => WP_PLUGIN_DIR, 'clear_destination' => true, 'clear_working' => true, 'hook_extra' => array('type' => 'plugin', 'action' => 'install'))); remove_action('upgrader_process_complete', 'wp_clean_plugins_cache', 9); remove_filter('upgrader_source_selection', array($this, 'check_package')); if (!$this->result || is_wp_error($this->result)) { return $this->result; } wp_clean_plugins_cache($parsed_args['clear_update_cache']); return true; } public function bulk_upgrade($plugins, $args = array()) { remove_all_actions('upgrader_process_complete'); $defaults = array('clear_update_cache' => true); $parsed_args = wp_parse_args($args, $defaults); $this->init(); $this->bulk = true; $this->upgrade_strings(); $current = get_site_transient('gv_plugin_updates'); add_filter('upgrader_clear_destination', array($this, 'delete_old_plugin'), 10, 4); $this->skin->header(); $res = $this->fs_connect(array(WP_CONTENT_DIR, WP_PLUGIN_DIR)); if (!$res) { $this->skin->footer(); return false; } $this->skin->bulk_header(); $maintenance = is_multisite() && !empty($plugins); foreach ($plugins as $plugin) { $maintenance = $maintenance || is_plugin_active($plugin) && isset($current->response[$plugin]); } if ($maintenance) { $this->maintenance_mode(true); } $results = array(); $this->update_count = count($plugins); $this->update_current = 0; foreach ($plugins as $plugin) { $this->update_current++; $this->skin->plugin_info = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin, false, true); if (!isset($current->response[$plugin])) { $this->skin->set_result('up_to_date'); $this->skin->before(); $this->skin->feedback('up_to_date'); $this->skin->after(); $results[$plugin] = true; continue; } $r = $current->response[$plugin]; $this->skin->plugin_active = is_plugin_active($plugin); $package = gv_api_manager()->download(array('product_id' => $r->id)); if (!is_wp_error($package)) { $r->package = $package; } $result = $this->run(array('package' => $r->package, 'destination' => WP_PLUGIN_DIR, 'clear_destination' => true, 'clear_working' => true, 'is_multi' => true, 'hook_extra' => array('plugin' => $plugin))); $results[$plugin] = $this->result; if (false === $result) { break; } } $this->maintenance_mode(false); do_action('gv_upgrader_process_complete', $this, array('action' => 'update', 'type' => 'plugin', 'bulk' => true, 'plugins' => $plugins)); $this->skin->bulk_footer(); $this->skin->footer(); remove_filter('upgrader_clear_destination', array($this, 'delete_old_plugin')); foreach ($results as $plugin => $result) { if (!$result || is_wp_error($result)) { continue; } } return $results; } }