コード例 #1
0
ファイル: Plugin.php プロジェクト: rovak73/sinfronterasdoc
 /**
  * Constructor.
  */
 public function __construct()
 {
     /*
      * Get details of git sourced plugins.
      */
     $this->config = $this->get_plugin_meta();
     if (empty($this->config)) {
         return false;
     }
     if (isset($_GET['force-check'])) {
         $this->delete_all_transients('plugins');
     }
     foreach ((array) $this->config as $plugin) {
         switch ($plugin->type) {
             case 'github_plugin':
                 $repo_api = new GitHub_API($plugin);
                 break;
             case 'bitbucket_plugin':
                 $repo_api = new Bitbucket_API($plugin);
                 break;
             case 'gitlab_plugin':
                 $repo_api = new GitLab_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);
             }
             $repo_api->get_remote_readme();
             $plugin->download_link = $repo_api->construct_download_link();
         }
         /*
          * Update plugin transient with rollback (branch switching) data.
          */
         if (!empty($_GET['rollback']) && (isset($_GET['plugin']) && $_GET['plugin'] === $plugin->slug)) {
             $this->tag = $_GET['rollback'];
             $updates_transient = get_site_transient('update_plugins');
             $rollback = array('slug' => $plugin->repo, 'plugin' => $plugin->slug, 'new_version' => $this->tag, 'url' => $plugin->uri, 'package' => $repo_api->construct_download_link(false, $this->tag));
             $updates_transient->response[$plugin->slug] = (object) $rollback;
             set_site_transient('update_plugins', $updates_transient);
         }
         add_action("after_plugin_row_{$plugin->slug}", array(&$this, 'wp_plugin_update_row'), 15, 3);
     }
     $this->make_force_check_transient('plugins');
     add_filter('plugin_row_meta', array(&$this, 'plugin_row_meta'), 10, 2);
     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('Fragen\\GitHub_Updater\\API', 'http_request_args'), 10, 2);
     Settings::$ghu_plugins = $this->config;
 }
コード例 #2
0
ファイル: API.php プロジェクト: rovak73/sinfronterasdoc
 /**
  * Return API url.
  *
  * @param string $endpoint
  *
  * @return string
  */
 private function _get_api_url($endpoint)
 {
     $type = $this->return_repo_type();
     $segments = array('owner' => $this->type->owner, 'repo' => $this->type->repo);
     /*
      * Add or filter the available segments that are used to replace placeholders.
      *
      * @param array $segments list of segments.
      */
     $segments = apply_filters('github_updater_api_segments', $segments);
     foreach ($segments as $segment => $value) {
         $endpoint = str_replace('/:' . sanitize_key($segment), '/' . sanitize_text_field($value), $endpoint);
     }
     switch ($type['repo']) {
         case 'github':
             $endpoint = GitHub_API::add_endpoints($this, $endpoint);
             if ($this->type->enterprise) {
                 return $endpoint;
             }
             break;
         case 'gitlab':
             $endpoint = GitLab_API::add_endpoints($this, $endpoint);
             if ($this->type->enterprise) {
                 return $endpoint;
             }
             break;
         default:
     }
     return $type['base_uri'] . $endpoint;
 }
コード例 #3
0
ファイル: API.php プロジェクト: afragen/github-updater
 /**
  * Return API url.
  *
  * @access private
  *
  * @param string $endpoint
  *
  * @return string $endpoint
  */
 private function get_api_url($endpoint)
 {
     $type = $this->return_repo_type();
     $segments = array('owner' => $this->type->owner, 'repo' => $this->type->repo);
     foreach ($segments as $segment => $value) {
         $endpoint = str_replace('/:' . sanitize_key($segment), '/' . sanitize_text_field($value), $endpoint);
     }
     switch ($type['repo']) {
         case 'github':
             $api = new GitHub_API($type['type']);
             $endpoint = $api->add_endpoints($this, $endpoint);
             if ($this->type->enterprise_api) {
                 return $endpoint;
             }
             break;
         case 'gitlab':
             $api = new GitLab_API($type['type']);
             $endpoint = $api->add_endpoints($this, $endpoint);
             if ($this->type->enterprise_api) {
                 return $endpoint;
             }
             break;
         default:
     }
     return $type['base_uri'] . $endpoint;
 }
コード例 #4
0
ファイル: Theme.php プロジェクト: jewel-theme/github-updater
 /**
  * Constructor.
  */
 public function __construct()
 {
     /*
      * Get details of git 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_API($theme);
                 break;
             case 'bitbucket_theme':
                 $repo_api = new Bitbucket_API($theme);
                 break;
             case 'gitlab_theme':
                 $repo_api = new GitLab_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();
             $changelog = $this->get_changelog_filename($theme->type);
             if ($changelog) {
                 $repo_api->get_remote_changes($changelog);
             }
             $theme->download_link = $repo_api->construct_download_link();
         }
         /*
          * Update theme transient with rollback data.
          */
         if (!empty($_GET['rollback']) && (isset($_GET['theme']) && $_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, false));
             $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('Fragen\\GitHub_Updater\\API', 'http_request_args'), 10, 2);
     if (!is_multisite()) {
         add_filter('wp_prepare_themes_for_js', array(&$this, 'customize_theme_update_html'));
     }
     Settings::$ghu_themes = $this->config;
 }