Cp_Plgn_Drctry_GitHub

Trait to get Plugins from the CP API.

Description

Sets Git Token header if available Gets vetted orgs Gets orgs and users repos as set in Options Gets repos data Gets repos readmes Gets repos developers data Maps data to a CP Dir Compatible object

Tags
author

Beda Schmid beda@tukutoi.com

Table of Contents

build_git_plugin_object()  : object
Build a CP APi compatible object of repository data.
build_git_plugins_objects()  : array<string|int, mixed>
Build a CP APi compatible array of objects of repository data.
get_gh_pages()  : int
Get all pages of the results found.
get_git_dev_info()  : array<string|int, mixed>
Get developer info from Github.
get_git_plugins()  : mixed
Get all Git Plugins Public function.
get_git_release_data()  : array<string|int, mixed>
Get Release Data from GitHub
get_git_repos()  : array<string|int, mixed>
Get Plugins stored on Git.
get_readme_data()  : string
Get readme data
get_readme_name()  : string
Get the "name" of the plugin - assumed to be first text following a '# ' in the readme.
set_auth()  : mixed
If available, get GitHub Auth Token.

Methods

build_git_plugin_object()

Build a CP APi compatible object of repository data.

private build_git_plugin_object(array<string|int, mixed> $repo_object, array<string|int, mixed> $_data) : object
Parameters
$repo_object
(array<string|int, mixed>) The repositories found by the query.
$_data
(array<string|int, mixed>) Array placeholder to cache remote Developer.
Return
(object) $git_plugins An object of Repo data.

build_git_plugins_objects()

Build a CP APi compatible array of objects of repository data.

private build_git_plugins_objects(array<string|int, mixed> $repos, array<string|int, mixed> $_data) : array<string|int, mixed>
Parameters
$repos
(array<string|int, mixed>) The repositories found by the query.
$_data
(array<string|int, mixed>) Array placeholder to cache remote Developer.
Return
(array<string|int, mixed>) $git_plugins An array of repository data Objects.

get_gh_pages()

Get all pages of the results found.

private get_gh_pages(array<string|int, mixed> $response) : int
Parameters
$response
(array<string|int, mixed>) the WP Remote Get Response.
Return
(int) $last_page The last (amount of) page found.

get_git_dev_info()

Get developer info from Github.

private get_git_dev_info(string $login, string $type) : array<string|int, mixed>
Parameters
$login
(string) The Github "slug".
$type
(string) The Github domain type.
Return
(array<string|int, mixed>) $dev_array A CP API Compatible "developer" array.

get_git_release_data()

Get Release Data from GitHub

private get_git_release_data(string $release_url, string $repo_name, string $owner) : array<string|int, mixed>
Parameters
$release_url
(string) The Github API Releases URL.
$repo_name
(string) The repository Name.
$owner
(string) The name of the repo owner.
Return
(array<string|int, mixed>) $release_data A CP API Compatible "release" data array.

get_git_repos()

Get Plugins stored on Git.

private get_git_repos(string $url, string $name, string $domain) : array<string|int, mixed>
Description

Currently only supports TukuToi Org.

Parameters
$url
(string) The URL to get remote response from.
$name
(string) The name of the repository.
$domain
(string) the type of repository (org or name).
Return
(array<string|int, mixed>) $git_plugins A CP API Compatible array of plugin data.

get_readme_data()

Get readme data

private get_readme_data(string $item, string $login, string $branch) : string
Description

Readme can be: README.md readme.md README.txt readme.txt

Parameters
$item
(string) The repository slug/name.
$login
(string) The repo owner name.
$branch
(string) The default branch of the repository.
Tags
since
1.3.0
Return
(string) $readme The Readme Content.

get_readme_name()

Get the "name" of the plugin - assumed to be first text following a '# ' in the readme.

private get_readme_name(string $item, string $login, string $branch) : string
Parameters
$item
(string) The repository slug/name.
$login
(string) The repo owner name.
$branch
(string) The default branch of the repository.
Tags
since
1.3.0
Return
(string) $title The "name" of this plugin.

Search results