Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
afragen committed Dec 18, 2024
2 parents 19c0943 + 7a885d0 commit e7da6a8
Show file tree
Hide file tree
Showing 23 changed files with 471 additions and 123 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ vendor/dealerdirect
vendor/squizlabs
vendor/wp-coding-standards
vendor/phpcsstandards
vendor/mcaskill
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#### [unreleased]

#### 12.7.2 / 2024-12-18
* update `freemius/wordpress-sdk`
* use `mcaskill/composer-exclude-files` to exclude autoloading `start.php` from Freemius, issues arise
* update `REST_API::get_api_data()` to always get current release asset redirect as appropriate

#### 12.7.1 / 2024-12-02
* use `get_file_date()` to return plugin version
* fix `API::get_dot_org_data()` to work with WPE mirror
Expand Down
13 changes: 10 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,21 @@
"afragen/wordpress-plugin-readme-parser": "dev-master",
"afragen/singleton": "dev-master",
"afragen/wp-dependency-installer": "^4",
"freemius/wordpress-sdk": "^2.6"
"freemius/wordpress-sdk": "^2"
},
"require-dev": {
"wp-coding-standards/wpcs": "^3.0.0"
"wp-coding-standards/wpcs": "^3.0.0",
"mcaskill/composer-exclude-files": "^4.0"
},
"extra": {
"exclude-from-files": [
"freemius/wordpress-sdk/start.php"
]
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
"dealerdirect/phpcodesniffer-composer-installer": true,
"mcaskill/composer-exclude-files": true
}
},
"autoload": {
Expand Down
89 changes: 73 additions & 16 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions 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.7.1
* Version: 12.7.2
* Author: Andy Fragen
* License: MIT
* Domain Path: /languages
Expand Down Expand Up @@ -41,7 +41,7 @@
if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) {
// Avoids a redeclaration error for move_dir() from Shim.php.
require_once ABSPATH . 'wp-admin/includes/file.php';
require __DIR__ . '/vendor/autoload.php';
require_once __DIR__ . '/vendor/autoload.php';
}

// Check for composer autoloader.
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 @@ -346,7 +346,7 @@ protected function get_dot_org_data() {
/**
* Filter hook to set an API domain for updating.
*
* @since 12.x.0
* @since 12.6.0
* @param string Default is 'api.wordpress.org'.
*/
$api_domain = apply_filters( 'gu_api_domain', 'api.wordpress.org' );
Expand Down Expand Up @@ -581,7 +581,7 @@ public function set_readme_info( $readme ) {
*
* @return string|bool|\stdClass Release asset URI from AWS.
*/
protected function get_release_asset_redirect( $asset, $aws = false ) {
public function get_release_asset_redirect( $asset, $aws = false ) {
$rest = false;
if ( ! $asset ) {
return false;
Expand Down
24 changes: 10 additions & 14 deletions src/Git_Updater/REST/REST_API.php
Original file line number Diff line number Diff line change
Expand Up @@ -359,24 +359,16 @@ public function get_api_data( \WP_REST_Request $request ) {
if ( false === $download && true === $download ) {
return (object) [ 'error' => 'The REST request likely has an invalid query argument. It requires a boolean for `download`.' ];
}
$repo_cache = $this->get_repo_cache( $slug );
$gu_plugins = Singleton::get_instance( 'Fragen\Git_Updater\Plugin', $this )->get_plugin_configs();
$gu_themes = Singleton::get_instance( 'Fragen\Git_Updater\Theme', $this )->get_theme_configs();
$gu_repos = array_merge( $gu_plugins, $gu_themes );

$type = array_key_exists( $slug, $gu_plugins ) ? 'plugin' : 'theme';

if ( 'theme' === $type && ! \array_key_exists( $slug, $gu_themes ) ) {
return (object) [ 'error' => 'Specified theme does not exist.' ];
}

if ( 'plugin' === $type && ! \array_key_exists( $slug, $gu_plugins ) ) {
return (object) [ 'error' => 'Specified plugin does not exist.' ];
if ( ! array_key_exists( $slug, $gu_repos ) ) {
return (object) [ 'error' => 'Specified repo does not exist.' ];
}

add_filter( 'gu_disable_wpcron', '__return_false' );
$repo_data = 'plugin' === $type
? Singleton::get_instance( 'Fragen\Git_Updater\Base', $this )->get_remote_repo_meta( $gu_plugins[ $slug ] )
: Singleton::get_instance( 'Fragen\Git_Updater\Base', $this )->get_remote_repo_meta( $gu_themes[ $slug ] );
$repo_data = Singleton::get_instance( 'Fragen\Git_Updater\Base', $this )->get_remote_repo_meta( $gu_repos[ $slug ] );

if ( ! is_object( $repo_data ) ) {
return (object) [ 'error' => 'API data response is incorrect.' ];
Expand All @@ -388,6 +380,7 @@ public function get_api_data( \WP_REST_Request $request ) {
'git' => $repo_data->git,
'type' => $repo_data->type,
'is_private' => $repo_data->is_private,
'release_asset' => $repo_data->release_asset,
'version' => $repo_data->remote_version,
'author' => $repo_data->author,
'contributors' => $repo_data->contributors,
Expand All @@ -410,7 +403,9 @@ public function get_api_data( \WP_REST_Request $request ) {
'external' => 'xxx',
];

if ( $repo_api_data['is_private'] || in_array( $repo_api_data['git'], [ 'gitlab', 'gitea' ], true )
$repo_cache = $this->get_repo_cache( $slug );

if ( $repo_api_data['download_link'] && $repo_api_data['is_private'] || in_array( $repo_api_data['git'], [ 'gitlab', 'gitea' ], true )
) {
$repo_api_data['auth_header'] = Singleton::get_instance( 'Fragen\Git_Updater\API\API', $this )->add_auth_header( [], $repo_api_data['download_link'] );
$repo_api_data['auth_header'] = Singleton::get_instance( 'Fragen\Git_Updater\API\API', $this )->unset_release_asset_auth( $repo_api_data['auth_header'], $repo_api_data['download_link'] );
Expand All @@ -420,7 +415,8 @@ public function get_api_data( \WP_REST_Request $request ) {
if ( isset( $repo_cache['release_asset_redirect'] ) ) {
$repo_api_data['download_link'] = $repo_cache['release_asset_redirect'];
} elseif ( $repo_cache['release_asset'] ) {
$repo_api_data['download_link'] = $repo_cache['release_asset'];
$_REQUEST['override'] = true;
$repo_api_data['download_link'] = Singleton::get_instance( 'Fragen\Git_Updater\API\API', $this )->get_release_asset_redirect( $repo_cache['release_asset'], true );
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Git_Updater/Traits/Basic_Auth_Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private function get_credentials( $url ) {
/**
* Filter hook to set an API domain for updating.
*
* @since 12.x.0
* @since 12.6.0
* @param string Default is 'api.wordpress.org'.
*/
$api_domain = apply_filters( 'gu_api_domain', 'api.wordpress.org' );
Expand Down
2 changes: 1 addition & 1 deletion src/Git_Updater/Traits/GU_Trait.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ final public function override_dot_org( $type, $repo ) {
/**
* Filter hook to completely ignore any updates from dot org when using Git Updater.
*
* @since 12.x.0
* @since 12.6.0
* @param bool Default is false. Do not ignore updates from dot org.
*/
return ! $dot_org_master || $override || apply_filters( 'gu_ignore_dot_org', false );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,19 +365,17 @@ protected function parse_readme_contents( $contents ) {
while ( ( $line = array_shift( $contents ) ) !== null ) {
$trimmed = trim( $line );
if ( empty( $trimmed ) ) {
$this->short_description .= "\n";
continue;
}
if ( ( '=' === $trimmed[0] && isset( $trimmed[1] ) && '=' === $trimmed[1] ) ||
( '#' === $trimmed[0] && isset( $trimmed[1] ) && '#' === $trimmed[1] )
) {

// Stop after any Markdown heading.
array_unshift( $contents, $line );
break;
}

$this->short_description .= $line . "\n";
$this->short_description .= $line . ' ';
}
$this->short_description = trim( $this->short_description );

Expand Down
11 changes: 7 additions & 4 deletions vendor/composer/InstalledVersions.php
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ private static function getInstalled()
}

$installed = array();
$copiedLocalDir = false;

if (self::$canGetVendors) {
foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
Expand All @@ -330,9 +331,11 @@ private static function getInstalled()
} elseif (is_file($vendorDir.'/composer/installed.php')) {
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
$required = require $vendorDir.'/composer/installed.php';
$installed[] = self::$installedByVendor[$vendorDir] = $required;
if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
self::$installed = $installed[count($installed) - 1];
self::$installedByVendor[$vendorDir] = $required;
$installed[] = $required;
if (strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
self::$installed = $required;
$copiedLocalDir = true;
}
}
}
Expand All @@ -350,7 +353,7 @@ private static function getInstalled()
}
}

if (self::$installed !== array()) {
if (self::$installed !== array() && !$copiedLocalDir) {
$installed[] = self::$installed;
}

Expand Down
10 changes: 10 additions & 0 deletions vendor/composer/autoload_files.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

// autoload_files.php @generated by Composer

$vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);

return array(
'8d50dc88e56bace65e1e72f6017983ed' => $vendorDir . '/freemius/wordpress-sdk/start.php',
);
1 change: 1 addition & 0 deletions vendor/composer/autoload_psr4.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@

return array(
'PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\' => array($vendorDir . '/dealerdirect/phpcodesniffer-composer-installer/src'),
'McAskill\\Composer\\' => array($vendorDir . '/mcaskill/composer-exclude-files/src'),
'Fragen\\Git_Updater\\' => array($baseDir . '/src/Git_Updater'),
);
Loading

0 comments on commit e7da6a8

Please sign in to comment.