Fragen\GitHub_Updater\Rest_Update::update_theme PHP Метод

update_theme() публичный Метод

Update a single theme.
public update_theme ( string $theme_slug, string $tag = 'master' )
$theme_slug string
$tag string
    public function update_theme($theme_slug, $tag = 'master')
    {
        $theme = null;
        foreach ((array) Theme::instance()->get_theme_configs() as $config_entry) {
            if ($config_entry->repo === $theme_slug) {
                $theme = $config_entry;
                break;
            }
        }
        if (!$theme) {
            throw new \Exception('Theme not found or not updatable with GitHub Updater: ' . $theme_slug);
        }
        $this->get_remote_repo_meta($theme);
        $updates_transient = get_site_transient('update_themes');
        $update = array('theme' => $theme->repo, 'new_version' => null, 'url' => $theme->uri, 'package' => $this->repo_api->construct_download_link(false, $tag));
        $updates_transient->response[$theme->repo] = $update;
        set_site_transient('update_themes', $updates_transient);
        $upgrader = new \Theme_Upgrader($this->upgrader_skin);
        $upgrader->upgrade($theme->repo);
    }