Skip to content

Commit

Permalink
display git source repos in sub-tab
Browse files Browse the repository at this point in the history
  • Loading branch information
afragen committed Oct 7, 2016
1 parent 4bd662c commit e815f0a
Showing 1 changed file with 37 additions and 2 deletions.
39 changes: 37 additions & 2 deletions src/GitHub_Updater/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ public function create_admin_page() {
break;
case 'github':
do_settings_sections( 'github_updater_github_install_settings' );
$this->display_ghu_repos( 'github' );
echo '<div style="display:none;">';
do_settings_sections( 'github_updater_install_settings' );
do_settings_sections( 'github_updater_bitbucket_install_settings' );
Expand All @@ -243,6 +244,7 @@ public function create_admin_page() {
break;
case 'bitbucket':
do_settings_sections( 'github_updater_bitbucket_install_settings' );
$this->display_ghu_repos( 'bitbucket' );
echo '<div style="display:none;">';
do_settings_sections( 'github_updater_install_settings' );
do_settings_sections( 'github_updater_github_install_settings' );
Expand All @@ -251,6 +253,7 @@ public function create_admin_page() {
break;
case 'gitlab':
do_settings_sections( 'github_updater_gitlab_install_settings' );
$this->display_ghu_repos( 'gitlab' );
echo '<div style="display:none;">';
do_settings_sections( 'github_updater_install_settings' );
do_settings_sections( 'github_updater_github_install_settings' );
Expand Down Expand Up @@ -455,15 +458,15 @@ public function page_init() {
if ( ! parent::$auth_required['github_private'] ) {
add_settings_section(
null,
esc_html__( 'Private repositories are not installed or are still cached.', 'github-updater' ),
esc_html__( 'Private repositories are not installed, are cached, or are using your personal access token.', 'github-updater' ),
array(),
'github_updater_github_install_settings'
);
}
if ( ! parent::$auth_required['bitbucket_private'] ) {
add_settings_section(
null,
esc_html__( 'Private repositories are not installed or are still cached.', 'github-updater' ),
esc_html__( 'Private repositories are not installed or are cached.', 'github-updater' ),
array(),
'github_updater_bitbucket_install_settings'
);
Expand Down Expand Up @@ -936,4 +939,36 @@ public function plugin_action_links( $links ) {
return array_merge( $links, $link );
}

/**
* Write out listing of installed plugins and themes using GitHub Updater.
*
* @param $type
*/
private function display_ghu_repos( $type ) {
$plugins = Plugin::instance()->get_plugin_configs();
$themes = Theme::instance()->get_theme_configs();
$repos = array_merge( $plugins, $themes );

$type_repos = array_filter( $repos, function( $e ) use ( $type ) {
return false !== stristr( $e->type, $type );
} );

$display_data = array_map( function( $e ) {
return $e = array(
'type' => $e->type,
'repo' => $e->repo,
'name' => $e->name,
);
}, $type_repos );

printf( '<h4>' . esc_html__( 'Installed Plugins and Themes', 'github-updater' ) . '</h4>' );
foreach ( $display_data as $data ) {
$dashicon = '<span class="dashicons dashicons-admin-plugins"></span>&nbsp;';
if ( false !== strpos( $data['type'], 'theme' ) ) {
$dashicon = '<span class="dashicons dashicons-admin-appearance"></span>&nbsp;';
}
printf( '<p>' . $dashicon . ' ' . $data['name'] . '</p>' );
}
}

}

0 comments on commit e815f0a

Please sign in to comment.