Fragen\GitHub_Updater\Theme::get_theme_meta PHP Метод

get_theme_meta() защищенный Метод

Populates variable array.
protected get_theme_meta ( ) : array
Результат array Indexed array of associative arrays of theme details.
    protected function get_theme_meta()
    {
        $git_themes = array();
        $themes = wp_get_themes(array('errors' => null));
        /**
         * Filter to add themes not containing appropriate header line.
         *
         * @since   5.4.0
         * @access  public
         *
         * @param   array $additions    Listing of themes to add.
         *                              Default null.
         * @param   array $themes       Listing of all themes.
         * @param         string        'theme'    Type being passed.
         */
        $additions = apply_filters('github_updater_additions', null, $themes, 'theme');
        foreach ((array) $themes as $theme) {
            $git_theme = array();
            $repo_uri = null;
            $repo_enterprise_uri = null;
            $repo_enterprise_api = null;
            $repo_languages = null;
            foreach ((array) self::$extra_headers as $value) {
                $repo_uri = $theme->get($value);
                /**
                 * Get $repo_uri from themes added to GitHub Updater via hook.
                 */
                foreach ((array) $additions as $addition) {
                    if ($theme->stylesheet === $addition['slug']) {
                        if (!empty($addition[$value])) {
                            $repo_uri = $addition[$value];
                            break;
                        }
                    }
                }
                if (empty($repo_uri) || false === stristr($value, 'Theme') && false === stristr($value, 'Languages')) {
                    continue;
                }
                $header_parts = explode(' ', $value);
                $repo_parts = $this->get_repo_parts($header_parts[0], 'theme');
                if ($repo_parts['bool']) {
                    $header = $this->parse_header_uri($repo_uri);
                    if ($theme->stylesheet !== $header['repo']) {
                        continue;
                    }
                }
                $self_hosted_parts = array_diff(array_keys(self::$extra_repo_headers), array('branch'));
                foreach ($self_hosted_parts as $part) {
                    $self_hosted = $theme->get($repo_parts[$part]);
                    if (!empty($self_hosted)) {
                        switch ($part) {
                            case 'languages':
                                $repo_languages = $self_hosted;
                                break;
                            case 'enterprise':
                            case 'gitlab_ce':
                                $repo_enterprise_uri = $self_hosted;
                                break;
                            case 'ci_job':
                                $repo_ci_job = $self_hosted;
                                break;
                        }
                    }
                }
                if (!empty($repo_enterprise_uri)) {
                    $repo_enterprise_uri = trim($repo_enterprise_uri, '/');
                    switch ($header_parts[0]) {
                        case 'GitHub':
                            $repo_enterprise_api = $repo_enterprise_uri . '/api/v3';
                            break;
                        case 'GitLab':
                            $repo_enterprise_api = $repo_enterprise_uri . '/api/v3';
                            break;
                    }
                }
                $git_theme['type'] = $repo_parts['type'];
                $git_theme['uri'] = $repo_parts['base_uri'] . $header['owner_repo'];
                $git_theme['enterprise'] = $repo_enterprise_uri;
                $git_theme['enterprise_api'] = $repo_enterprise_api;
                $git_theme['owner'] = $header['owner'];
                $git_theme['repo'] = $header['repo'];
                $git_theme['extended_repo'] = $header['repo'];
                $git_theme['name'] = $theme->get('Name');
                $git_theme['theme_uri'] = $theme->get('ThemeURI');
                $git_theme['author'] = $theme->get('Author');
                $git_theme['local_version'] = strtolower($theme->get('Version'));
                $git_theme['sections']['description'] = $theme->get('Description');
                $git_theme['local_path'] = get_theme_root() . '/' . $git_theme['repo'] . '/';
                $git_theme['local_path_extended'] = null;
                $git_theme['branch'] = $theme->get($repo_parts['branch']);
                $git_theme['branch'] = !empty($git_theme['branch']) ? $git_theme['branch'] : 'master';
                $git_theme['languages'] = !empty($repo_languages) ? $repo_languages : null;
                $git_theme['ci_job'] = !empty($repo_ci_job) ? $repo_ci_job : null;
                $git_theme['release_asset'] = true == $theme->get('Release Asset') ? true : false;
                break;
            }
            /*
             * Exit if not git hosted theme.
             */
            if (empty($git_theme)) {
                continue;
            }
            $git_themes[$git_theme['repo']] = (object) $git_theme;
        }
        return $git_themes;
    }