Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
afragen committed Feb 2, 2025
2 parents 4f1dff0 + 0a9c581 commit 1da3735
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 9 deletions.
7 changes: 7 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
#### [unreleased]

#### 12.11.0 / 2025-02-02
* update Additions to add additional listings
* more updates for possibly passing `null`
* update `REST_API::get_api_data`
* update `Theme` to add `theme_uri` to update transient
* update to pass complete data for multiple uses of `gu_additions` hook

#### 12.10.1 / 2025-01-30
* fix issue with release asset
* add guard to `Add-Ons`
Expand Down
4 changes: 3 additions & 1 deletion git-updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Plugin Name: Git Updater
* Plugin URI: https://git-updater.com
* Description: A plugin to automatically update GitHub hosted plugins, themes, and language packs. Additional API plugins available for Bitbucket, GitLab, Gitea, and Gist.
* Version: 12.10.1
* Version: 12.11.0
* Author: Andy Fragen
* License: MIT
* Domain Path: /languages
Expand Down Expand Up @@ -68,6 +68,8 @@ static function ( $listing, $repos, $type ) {
$config = get_site_option( 'git_updater_additions', [] );
$additions = new Additions();
$additions->register( $config, $repos, $type );
$additions->add_to_git_updater = array_merge( (array) $additions->add_to_git_updater, (array) $listing );

return $additions->add_to_git_updater;
},
10,
Expand Down
4 changes: 2 additions & 2 deletions src/Git_Updater/API/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -505,11 +505,11 @@ protected function set_file_info( $response ) {
$this->type->transient = $response;
$this->type->remote_version = ! empty( $response['Version'] ) ? strtolower( $response['Version'] ) : $this->type->remote_version;
$this->type->requires_php = ! empty( $response['RequiresPHP'] ) ? $response['RequiresPHP'] : false;
$this->type->requires = ! empty( $response['RequiresWP'] ) ? $response['RequiresWP'] : null;
$this->type->requires = ! empty( $response['RequiresWP'] ) ? $response['RequiresWP'] : false;
$this->type->requires = ! empty( $response['Requires'] ) ? $response['Requires'] : $this->type->requires;
$this->type->dot_org = $response['dot_org'];
$this->type->primary_branch = ! empty( $response['PrimaryBranch'] ) ? $response['PrimaryBranch'] : $this->type->primary_branch;
$this->type->update_uri = ! empty( $response['UpdateURI'] ) ? $response['UpdateURI'] : null;
$this->type->update_uri = ! empty( $response['UpdateURI'] ) ? $response['UpdateURI'] : '';
$this->type->requires_plugins = ! empty( $response['RequiresPlugins'] ) ? explode( ',', $response['RequiresPlugins'] ) : [];
if ( ! isset( $this->type->name ) ) {
$this->type->name = $response['Name'];
Expand Down
29 changes: 28 additions & 1 deletion src/Git_Updater/Additions/Additions.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
* @uses \Fragen\Singleton
*/
class Additions {
use \Fragen\Git_Updater\Traits\GU_Trait;

/**
* Holds array of plugin/theme headers to add to Git Updater.
*
Expand All @@ -46,7 +48,6 @@ public function register( $config, $repos, $type ) {
}

$this->add_headers( $config, $repos, $type );
$this->add_source( $config );

return true;
}
Expand Down Expand Up @@ -127,4 +128,30 @@ public function add_source( $config ) {
update_site_option( 'git_updater_additions', $config );
}
}

/**
* Remove duplicate $options to unique values.
* Caches created in Fragen\Git_Updater\Federation::load_additions().
*
* @param array $options Array of Additions options.
*
* @return array
*/
public function deduplicate( $options ) {
$list_plugin_addons = $this->get_repo_cache( 'git_updater_repository_add_plugin' );
$list_plugin_addons = ! empty( $list_plugin_addons['git_updater_repository_add_plugin'] ) ? $list_plugin_addons['git_updater_repository_add_plugin'] : [];

$list_theme_addons = $this->get_repo_cache( 'git_updater_repository_add_theme' );
$list_theme_addons = ! empty( $list_theme_addons['git_updater_repository_add_theme'] ) ? $list_theme_addons['git_updater_repository_add_theme'] : [];

$options = array_merge( $options, $list_plugin_addons, $list_theme_addons );
foreach ( array_keys( $options ) as $key ) {
unset( $options[ $key ]['source'] );
$options[ $key ]['release_asset'] = ! empty( $options[ $key ]['release_asset'] ) ? true : false;
ksort( $options[ $key ] );
}
$options = array_map( 'unserialize', array_unique( array_map( 'serialize', $options ) ) );

return $options;
}
}
3 changes: 2 additions & 1 deletion src/Git_Updater/Additions/Repo_List_Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ public function __construct( $options ) {
$option['uri'] = $option['uri'] ?: null;
$option['primary_branch'] = ! empty( $option['primary_branch'] ) ? $option['primary_branch'] : 'master';
$option['release_asset'] = ! empty( $option['release_asset'] ) ? '<span class="dashicons dashicons-yes"></span>' : false;
$options[ $key ] = $option;

$options[ $key ] = $option;
}
self::$options = (array) $options;

Expand Down
9 changes: 5 additions & 4 deletions src/Git_Updater/Additions/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,15 @@ public function add_admin_page( $tab, $action ) {
$this->additions_page_init();

if ( 'git_updater_additions' === $tab ) {
$action = add_query_arg(
$action = add_query_arg(
[
'page' => 'git-updater',
'tab' => $tab,
],
$action
);
( new Repo_List_Table( self::$options_additions ) )->render_list_table();
$options = ( new Additions() )->deduplicate( self::$options_additions );
( new Repo_List_Table( $options ) )->render_list_table();
?>
<form class="settings" method="post" action="<?php echo esc_attr( $action ); ?>">
<?php
Expand Down Expand Up @@ -266,8 +267,8 @@ public function sanitize( $input ) {
foreach ( (array) $input as $key => $value ) {
$new_input[0][ $key ] = 'uri' === $key ? untrailingslashit( esc_url_raw( trim( $value ) ) ) : sanitize_text_field( $value );
}
$new_input[0]['ID'] = md5( $new_input[0]['slug'] );
$new_input[0]['source'] = md5( home_url() );
$new_input[0]['primary_branch'] = ! empty( $new_input[0]['primary_branch'] ) ? $new_input[0]['primary_branch'] : 'master';
$new_input[0]['ID'] = md5( $new_input[0]['slug'] );

return $new_input;
}
Expand Down
1 change: 1 addition & 0 deletions src/Git_Updater/REST/REST_API.php
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@ public function get_api_data( \WP_REST_Request $request ) {
'slug' => $repo_data->slug,
'git' => $repo_data->git,
'type' => $repo_data->type,
'url' => $repo_data->uri,
'is_private' => $repo_data->is_private,
'dot_org' => $repo_data->dot_org,
'release_asset' => $repo_data->release_asset,
Expand Down
1 change: 1 addition & 0 deletions src/Git_Updater/Theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ function ( $key ) use ( $theme ) {
$git_theme['type'] = 'theme';
$git_theme['git'] = $repo_parts['git_server'];
$git_theme['uri'] = "{$header['base_uri']}/{$header['owner_repo']}";
$git_theme['theme_uri'] = $header['owner_repo'];
$git_theme['enterprise'] = $header['enterprise_uri'];
$git_theme['enterprise_api'] = $header['enterprise_api'];
$git_theme['owner'] = $header['owner'];
Expand Down

0 comments on commit 1da3735

Please sign in to comment.