Skip to content

Commit

Permalink
Branch_Switcher to Branch
Browse files Browse the repository at this point in the history
  • Loading branch information
afragen committed Apr 14, 2021
1 parent fff2d5c commit 0ed00ee
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 18 deletions.
1 change: 0 additions & 1 deletion src/Git_Updater/API/GitHub_API.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
namespace Fragen\Git_Updater\API;

use Fragen\Singleton;
use Fragen\Git_Updater\Branch;

/*
* Exit if called directly.
Expand Down
3 changes: 2 additions & 1 deletion src/Git_Updater/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Fragen\Git_Updater\Traits\GU_Trait;
use Fragen\Git_Updater\Traits\Basic_Auth_Loader;
use Fragen\Git_Updater\API\Language_Pack_API;
use Fragen\Git_Updater\PRO\Branch;
use Fragen\Git_Updater\PRO\Language_Pack;

/*
Expand Down Expand Up @@ -466,7 +467,7 @@ public function upgrader_source_selection( $source, $remote_source, $upgrader, $
}

if ( $this->is_pro_running() ) {
Singleton::get_instance( 'Fragen\Git_Updater\PRO\Branch_Switcher', $this )->set_branch_on_switch( $slug );
( new Branch() )->set_branch_on_switch( $slug );

/*
* Remote install source.
Expand Down
6 changes: 3 additions & 3 deletions src/Git_Updater/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

use Fragen\Singleton;
use Fragen\Git_Updater\Traits\GU_Trait;
use Fragen\Git_Updater\PRO\Branch_Switcher;
use Fragen\Git_Updater\PRO\Branch;

/*
* Exit if called directly.
Expand Down Expand Up @@ -255,7 +255,7 @@ public function get_remote_plugin_meta() {
&& ( ! is_multisite() || is_network_admin() )
&& $this->is_pro_running()
) {
add_action( "after_plugin_row_{$plugin->file}", [ new Branch_Switcher(), 'plugin_branch_switcher' ], 15, 3 );
add_action( "after_plugin_row_{$plugin->file}", [ new Branch(), 'plugin_branch_switcher' ], 15, 3 );
}
}

Expand Down Expand Up @@ -414,7 +414,7 @@ public function update_site_transient( $transient ) {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
if ( isset( $_GET['plugin'], $_GET['rollback'] ) && $plugin->file === $_GET['plugin']
) {
$transient->response[ $plugin->file ] = ( new Branch_Switcher() )->set_rollback_transient( 'plugin', $plugin );
$transient->response[ $plugin->file ] = ( new Branch() )->set_rollback_transient( 'plugin', $plugin );
}
}
if ( property_exists( $transient, 'response' ) ) {
Expand Down
14 changes: 5 additions & 9 deletions src/Git_Updater/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,17 +256,13 @@ public function create_admin_page() {
$tab = isset( $_GET['tab'] ) ? sanitize_file_name( wp_unslash( $_GET['tab'] ) ) : 'git_updater_settings';
$subtab = isset( $_GET['subtab'] ) ? sanitize_file_name( wp_unslash( $_GET['subtab'] ) ) : 'git_updater';
// phpcs:enable
$logo = plugins_url( basename( dirname( __DIR__, 2 ) ) . '/assets/GitHub_Updater_logo_small.png' ); ?>
$logo = plugins_url( basename( dirname( __DIR__, 2 ) ) . '/assets/GitHub_Updater_logo_small.png' );
$label = $this->is_pro_running() ? __( 'Git Updater PRO', 'git-updater' ) : __( 'Git Updater', 'git-updater' );
?>
<div class="wrap git-updater-settings">
<h1>
<a href="https://github.com/afragen/git-updater" target="_blank"><img src="<?php esc_attr_e( $logo ); ?>" alt="Git Updater logo" /></a><br>
<?php
if ( $this->is_pro_running() ) {
esc_html_e( 'Git Updater PRO', 'git-updater' );
} else {
esc_html_e( 'Git Updater', 'git-updater' );
}
?>
<?php echo esc_html( $label ); ?>
</h1>
<?php ( new Messages() )->show_upsell(); ?>
<?php $this->options_tabs(); ?>
Expand Down Expand Up @@ -543,7 +539,7 @@ function ( $e ) use ( &$gu_unset_keys, $gu_tokens, &$reset_keys ) {
$key = array_search( $e, $gu_unset_keys, true );
$repo = str_replace( 'current_branch_', '', $key );
if ( array_key_exists( $key, $gu_unset_keys )
&& false !== strpos( $key, 'current_branch' )
&& false !== strpos( $key, 'current_branch' )
) {
unset( $gu_unset_keys[ $key ] );
}
Expand Down
8 changes: 4 additions & 4 deletions src/Git_Updater/Theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

use Fragen\Singleton;
use Fragen\Git_Updater\Traits\GU_Trait;
use Fragen\Git_Updater\PRO\Branch_Switcher;
use Fragen\Git_Updater\PRO\Branch;

/*
* Exit if called directly.
Expand Down Expand Up @@ -245,7 +245,7 @@ public function get_remote_theme_meta() {
if ( ! $this->tag ) {
add_action( "after_theme_row_{$theme->slug}", [ $this, 'wp_theme_update_row' ], 10, 2 );
if ( $this->is_pro_running() ) {
add_action( "after_theme_row_{$theme->slug}", [ new Branch_Switcher(), 'multisite_branch_switcher' ], 15, 2 );
add_action( "after_theme_row_{$theme->slug}", [ new Branch(), 'multisite_branch_switcher' ], 15, 2 );
}
}
}
Expand Down Expand Up @@ -452,7 +452,7 @@ public function customize_theme_update_html( $prepared_themes ) {
$prepared_themes[ $theme->slug ]['description'] .= $this->append_theme_actions_content( $theme );
}
if ( $this->is_pro_running() ) {
$prepared_themes[ $theme->slug ]['description'] .= ( new Branch_Switcher() )->single_install_switcher( $theme );
$prepared_themes[ $theme->slug ]['description'] .= ( new Branch() )->single_install_switcher( $theme );
}
}

Expand Down Expand Up @@ -618,7 +618,7 @@ public function update_site_transient( $transient ) {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
if ( isset( $_GET['theme'], $_GET['rollback'] ) && $theme->slug === $_GET['theme']
) {
$transient->response[ $theme->slug ] = ( new Branch_Switcher() )->set_rollback_transient( 'theme', $theme );
$transient->response[ $theme->slug ] = ( new Branch() )->set_rollback_transient( 'theme', $theme );
}
}
if ( property_exists( $transient, 'response' ) ) {
Expand Down

0 comments on commit 0ed00ee

Please sign in to comment.