/**
  * Constructor.
  *
  * @since 2.1.0
  *
  * @param string $type
  */
 public function __construct($type)
 {
     $this->type = $type;
     self::$hours = 4;
     if (!empty($this->type->timeout)) {
         self::$hours = (double) $this->type->timeout;
     }
     add_filter('http_request_args', array($this, 'maybe_authenticate_http'), 10, 2);
 }
Exemplo n.º 2
0
 /**
  * Constructor.
  */
 public function __construct()
 {
     // This MUST come before we get details about the themes so the headers are correctly retrieved
     GitHub_Updater_GitHub_API::add_headers();
     GitHub_Updater_BitBucket_API::add_headers();
     // Get details of GitHub-sourced themes
     $this->config = $this->get_theme_meta();
     if (empty($this->config)) {
         return false;
     }
     if (isset($_GET['force-check']) && '1' === $_GET['force-check']) {
         $this->delete_all_transients('themes');
     }
     foreach ((array) $this->config as $theme) {
         switch ($theme->type) {
             case 'github_theme':
                 $repo_api = new GitHub_Updater_GitHub_API($theme);
                 break;
             case 'bitbucket_theme':
                 $repo_api = new GitHub_Updater_BitBucket_API($theme);
                 break;
         }
         $this->{$theme->type} = $theme;
         $this->set_defaults($theme->type);
         if ($repo_api->get_remote_info('style.css')) {
             $repo_api->get_repo_meta();
             $repo_api->get_remote_tag();
             $repo_api->get_remote_changes('CHANGES.md');
             $theme->download_link = $repo_api->construct_download_link();
         }
         // Update theme transient with rollback data
         if (!empty($_GET['rollback']) && $_GET['theme'] === $theme->repo) {
             $this->tag = $_GET['rollback'];
             $updates_transient = get_site_transient('update_themes');
             $rollback = array('new_version' => $this->tag, 'url' => $theme->uri, 'package' => $repo_api->construct_download_link($this->tag));
             $updates_transient->response[$theme->repo] = $rollback;
             set_site_transient('update_themes', $updates_transient);
         }
         // Remove WordPress update row in theme row, only in multisite
         // Add update row to theme row, only in multisite for WP < 3.8
         if (is_multisite() || get_bloginfo('version') < 3.8) {
             add_action('after_theme_row', array($this, 'remove_after_theme_row'), 10, 2);
             if (!$this->tag) {
                 add_action("after_theme_row_{$theme->repo}", array($this, 'wp_theme_update_row'), 10, 2);
             }
         }
     }
     $this->make_force_check_transient('themes');
     $update = array('do-core-reinstall', 'do-core-upgrade');
     if (empty($_GET['action']) || !in_array($_GET['action'], $update, true)) {
         add_filter('pre_set_site_transient_update_themes', array($this, 'pre_set_site_transient_update_themes'));
     }
     add_filter('themes_api', array($this, 'themes_api'), 99, 3);
     add_filter('upgrader_source_selection', array($this, 'upgrader_source_selection'), 10, 3);
     add_filter('http_request_args', array($this, 'no_ssl_http_request_args'), 10, 2);
     if (!is_multisite()) {
         add_filter('wp_prepare_themes_for_js', array($this, 'customize_theme_update_html'));
     }
 }
 /**
  * Constructor.
  *
  * @since 1.0.0
  *
  * @param array $config
  */
 public function __construct()
 {
     // This MUST come before we get details about the plugins so the headers are correctly retrieved
     add_filter('extra_plugin_headers', array($this, 'add_plugin_headers'));
     // Get details of GitHub-sourced plugins
     $this->config = $this->get_plugin_meta();
     if (empty($this->config)) {
         return false;
     }
     foreach ((array) $this->config as $plugin) {
         switch ($plugin->type) {
             case 'github_plugin':
                 $repo_api = new GitHub_Updater_GitHub_API($plugin);
                 break;
             case 'bitbucket_plugin':
                 $repo_api = new GitHub_Updater_BitBucket_API($plugin);
                 break;
         }
         $this->{$plugin->type} = $plugin;
         $this->set_defaults($plugin->type);
         if ($repo_api->get_remote_info(basename($plugin->slug))) {
             $repo_api->get_repo_meta();
             $repo_api->get_remote_tag();
             $repo_api->get_remote_changes('CHANGES.md');
             $plugin->download_link = $repo_api->construct_download_link();
         }
     }
     add_filter('pre_set_site_transient_update_plugins', array($this, 'pre_set_site_transient_update_plugins'));
     add_filter('plugins_api', array($this, 'plugins_api'), 99, 3);
     add_filter('upgrader_source_selection', array($this, 'upgrader_source_selection'), 10, 3);
     add_filter('http_request_args', array($this, 'no_ssl_http_request_args'), 10, 2);
 }
Exemplo n.º 4
0
 /**
  * Constructor.
  */
 public function __construct()
 {
     // This MUST come before we get details about the plugins so the headers are correctly retrieved
     GitHub_Updater_GitHub_API::add_headers();
     // Get details of GitHub-sourced plugins
     $this->config = $this->get_plugin_meta();
     if (empty($this->config)) {
         return false;
     }
     if (isset($_GET['force-check']) && '1' === $_GET['force-check']) {
         $this->delete_all_transients('plugins');
     }
     foreach ((array) $this->config as $plugin) {
         switch ($plugin->type) {
             case 'github_plugin':
                 $repo_api = new GitHub_Updater_GitHub_API($plugin);
                 break;
             case 'bitbucket_plugin':
                 $repo_api = new GitHub_Updater_BitBucket_API($plugin);
                 break;
         }
         $this->{$plugin->type} = $plugin;
         $this->set_defaults($plugin->type);
         if ($repo_api->get_remote_info(basename($plugin->slug))) {
             $repo_api->get_repo_meta();
             $repo_api->get_remote_tag();
             $changelog = $this->get_changelog_filename($plugin->type);
             if ($changelog) {
                 $repo_api->get_remote_changes($changelog);
             }
             $plugin->download_link = $repo_api->construct_download_link();
         }
     }
     $this->make_force_check_transient('plugins');
     add_filter('pre_set_site_transient_update_plugins', array($this, 'pre_set_site_transient_update_plugins'));
     add_filter('plugins_api', array($this, 'plugins_api'), 99, 3);
     add_filter('upgrader_source_selection', array($this, 'upgrader_source_selection'), 10, 3);
     add_filter('http_request_args', array($this, 'no_ssl_http_request_args'), 10, 2);
     GitHub_Updater_Settings::$ghu_plugins = $this->config;
 }