コード例 #1
0
ファイル: request-handler.php プロジェクト: AndyA/River
 public function __construct()
 {
     $this->show_errors();
     if (empty($_POST['request'])) {
         return;
     }
     $request = $_POST['request'];
     if (defined('DOING_AJAX') && DOING_AJAX || get_magic_quotes_gpc()) {
         $request = stripslashes($request);
     }
     $request = json_decode($request, true);
     if (!is_array($request)) {
         return;
     }
     $GLOBALS['ithemes_sync_request_handler'] = $this;
     add_action('ithemes-sync-add-log', array($this, 'add_log'), 10, 2);
     add_action('shutdown', array($this, 'handle_error'));
     add_action('ithemes_sync_verbs_registered', array($this, 'handle_request'));
     require_once $GLOBALS['ithemes_sync_path'] . '/api.php';
     require_once $GLOBALS['ithemes_sync_path'] . '/functions.php';
     require_once $GLOBALS['ithemes_sync_path'] . '/settings.php';
     $this->options = $GLOBALS['ithemes-sync-settings']->get_options();
     $this->parse_request($request);
     Ithemes_Sync_Functions::set_time_limit(60);
     $this->set_is_admin_to_true();
     $this->set_current_user_to_admin();
     $this->set_full_user_capabilities();
     $this->disable_ext_object_cache();
     $this->disable_2fa_verification();
 }
コード例 #2
0
ファイル: do-update.php プロジェクト: jimlongo56/rdiv
 private function do_bulk_upgrade($packages, $type)
 {
     if (!in_array($type, array('plugin', 'theme'))) {
         return new WP_Error('unrecognized-bulk-upgrade-type', "An unrecognized type ({$type}) was passed to do_bulk_upgrade().");
     }
     Ithemes_Sync_Functions::set_time_limit(300);
     $original_versions = array();
     foreach ($packages as $package) {
         if ('plugin' === $type) {
             $file_data = Ithemes_Sync_Functions::get_file_data(WP_PLUGIN_DIR . "/{$package}");
         } else {
             $file_data = Ithemes_Sync_Functions::get_file_data(WP_CONTENT_DIR . "/themes/{$package}/style.css");
         }
         $original_versions[$package] = $file_data['version'];
     }
     require_once ABSPATH . 'wp-admin/includes/file.php';
     require_once ABSPATH . 'wp-admin/includes/plugin.php';
     require_once ABSPATH . 'wp-admin/includes/misc.php';
     if ('plugin' === $type) {
         $upgrader = new Plugin_Upgrader($this->skin);
         $result = $upgrader->bulk_upgrade($packages);
         Ithemes_Sync_Functions::refresh_plugin_updates();
     } else {
         $upgrader = new Theme_Upgrader($this->skin);
         $result = $upgrader->bulk_upgrade($packages);
         Ithemes_Sync_Functions::refresh_theme_updates();
     }
     if (is_wp_error($result)) {
         return array('errors' => array($result->get_error_code() => $result->get_error_message()));
     } else {
         if (false === $result) {
             if ('plugin' === $type) {
                 $result = $upgrader->fs_connect(array(WP_CONTENT_DIR, WP_PLUGIN_DIR));
             } else {
                 $result = $upgrader->fs_connect(array(WP_CONTENT_DIR));
             }
             if (is_wp_error($result)) {
                 return array('errors' => array($result->get_error_code() => $result->get_error_message()));
             } else {
                 return array('errors' => array('non-connected-filesystem' => 'Unable to update due to a non-connected filesystem.'));
             }
         }
     }
     $update_details = Ithemes_Sync_Functions::get_update_details(array('verbose' => true));
     $response = array();
     $update_index = "{$type}s";
     foreach ($result as $package => $info) {
         if (false === $info) {
             $response[$package]['errors']['non-connected-filesystem'] = 'Unable to update due to a non-connected filesystem.';
         } else {
             if (is_wp_error($info)) {
                 $response[$package]['errors'][$info->get_error_code()] = $info->get_error_message();
             } else {
                 $response[$package]['wordpress_response'] = $info;
                 if ('plugin' === $type) {
                     $file_data = Ithemes_Sync_Functions::get_file_data(WP_PLUGIN_DIR . "/{$package}");
                 } else {
                     $file_data = Ithemes_Sync_Functions::get_file_data(WP_CONTENT_DIR . "/themes/{$package}/style.css");
                 }
                 $response[$package]['current_version'] = $file_data['version'];
                 if (isset($original_versions[$package])) {
                     $response[$package]['original_version'] = $original_versions[$package];
                 }
                 if (isset($update_details[$update_index][$package])) {
                     if ('plugin' === $type && isset($update_details[$update_index][$package]->new_version)) {
                         $response[$package]['current_update_version'] = $update_details[$update_index][$package]->new_version;
                     } else {
                         if ('theme' === $type && isset($update_details[$update_index][$package]['new_version'])) {
                             $response[$package]['current_update_version'] = $update_details[$update_index][$package]['new_version'];
                         }
                     }
                 }
                 if (isset($this->original_update_details[$update_index][$package])) {
                     if ('plugin' === $type && isset($this->original_update_details[$update_index][$package]->new_version)) {
                         $response[$package]['original_update_version'] = $this->original_update_details[$update_index][$package]->new_version;
                     } else {
                         if ('theme' === $type && isset($this->original_update_details[$update_index][$package]['new_version'])) {
                             $response[$package]['original_update_version'] = $this->original_update_details[$update_index][$package]['new_version'];
                         }
                     }
                 }
                 if ('plugin' === $type) {
                     $removed_old_update_data = $GLOBALS['ithemes_sync_request_handler']->remove_old_update_plugins_data($package);
                     if (!is_null($removed_old_update_data)) {
                         $response[$package]['removed_old_update_data'] = $removed_old_update_data;
                     }
                 }
                 if (!isset($response[$package]['original_update_version'])) {
                     $response[$package]['errors']['no-update'] = 'No update was available.';
                 } else {
                     if (version_compare($response[$package]['current_version'], $response[$package]['original_update_version'], '>=')) {
                         $response[$package]['success'] = 1;
                         if (isset($response[$package]['current_update_version'])) {
                             if (version_compare($response[$package]['current_version'], $response[$package]['current_update_version'], '>=')) {
                                 $response[$package]['errors']['old-update-remains-available'] = 'The original update is still listed despite the update working properly.';
                             } else {
                                 $response[$package]['errors']['new-update-available'] = 'An update is available.';
                             }
                         }
                     } else {
                         $response[$package]['errors']['unknown-error'] = 'An unknown error prevented the update from completing successfully.';
                     }
                 }
             }
         }
     }
     return $response;
 }
コード例 #3
0
ファイル: manage-plugins.php プロジェクト: jimlongo56/rdiv
 private function install_plugins($plugins)
 {
     require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
     require_once ABSPATH . 'wp-admin/includes/file.php';
     require_once ABSPATH . 'wp-admin/includes/plugin.php';
     require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
     require_once dirname(dirname(__FILE__)) . '/upgrader-skin.php';
     $upgrader = new Plugin_Upgrader(new Ithemes_Sync_Upgrader_Skin());
     $results = array();
     foreach ((array) $plugins as $plugin) {
         Ithemes_Sync_Functions::set_time_limit(300);
         if (preg_match('{^(http|https|ftp)://}i', $plugin)) {
             $result = $upgrader->install($plugin);
         } else {
             $api = plugins_api('plugin_information', array('slug' => $plugin, 'fields' => array('sections' => false)));
             if (is_wp_error($api)) {
                 $result = $api;
             } else {
                 $result = $upgrader->install($api->download_link);
             }
         }
         if (is_wp_error($result)) {
             $results[$plugin]['error'] = array('error_code' => $result->get_error_code(), 'error_details' => $result->get_error_message());
         } else {
             $results[$plugin] = array('result' => $result, 'slug' => $upgrader->plugin_info());
             if (true === $result) {
                 $results[$plugin]['success'] = true;
             }
         }
     }
     Ithemes_Sync_Functions::refresh_plugin_updates();
     return $results;
 }
コード例 #4
0
ファイル: manage-themes.php プロジェクト: AndyA/River
 private function install_themes($themes)
 {
     require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
     require_once ABSPATH . 'wp-admin/includes/file.php';
     require_once ABSPATH . 'wp-admin/includes/plugin.php';
     require_once ABSPATH . 'wp-admin/includes/theme.php';
     require_once $GLOBALS['ithemes_sync_path'] . '/upgrader-skin.php';
     $upgrader = new Theme_Upgrader(new Ithemes_Sync_Upgrader_Skin());
     $results = array();
     foreach ((array) $themes as $theme) {
         Ithemes_Sync_Functions::set_time_limit(300);
         if (preg_match('{^(http|https|ftp)://}i', $theme)) {
             $result = $upgrader->install($theme);
         } else {
             $api = themes_api('theme_information', array('slug' => $theme, 'fields' => array('sections' => false, 'tags' => false)));
             if (is_wp_error($api)) {
                 $result = $api;
             } else {
                 $result = $upgrader->install($api->download_link);
             }
         }
         if (is_wp_error($result)) {
             $results[$theme]['error'] = array('error_code' => $result->get_error_code(), 'error_details' => $result->get_error_message());
         } else {
             $results[$theme]['result'] = $result;
             $theme_info = $upgrader->theme_info();
             $results[$theme]['name'] = $theme_info->get('Name');
             $results[$theme]['version'] = $theme_info->get('Version');
             if (is_object($theme_info) && is_callable(array($theme_info, 'get_stylesheet'))) {
                 $results[$theme]['slug'] = basename($theme_info->get_stylesheet());
             } else {
                 if (isset($upgrader->result) && !empty($upgrader->result['destination_name'])) {
                     $results[$theme]['slug'] = $upgrader->result['destination_name'];
                 }
             }
             if (true === $result) {
                 $results[$theme]['success'] = true;
             }
         }
     }
     Ithemes_Sync_Functions::refresh_theme_updates();
     return $results;
 }