Skip to content

Commit

Permalink
Minor adjustments based on code review.
Browse files Browse the repository at this point in the history
- reverse function true/false logic - now more logical from a function point of view, but completely incomprehensible on the receiving end of the function.
- darn yoda (Seriously, if you use strict checking - as I do -, why the heck would I need it ? makes code so much less readable...)
  • Loading branch information
jrfnl committed Apr 28, 2015
1 parent 2c57da2 commit 9d3f66a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions class-tgm-plugin-activation.php
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ protected function do_plugin_install() {
// Only activate plugins if the config option is set to true.
if ( $this->is_automatic ) {
$plugin_activate = $upgrader->plugin_info(); // Grab the plugin info from the Plugin_Upgrader method.
if( $this->activate_single_plugin( $plugin_activate, $slug, true ) === true ) {
if( false === $this->activate_single_plugin( $plugin_activate, $slug, true ) ) {
return true; // Finish execution of the function early as we encountered an error
}

Expand Down Expand Up @@ -603,7 +603,7 @@ protected function do_plugin_install() {
elseif ( isset( $this->plugins[ $slug ]['file_path'], $_GET['tgmpa-activate'] ) && 'activate-plugin' === $_GET['tgmpa-activate'] ) {
check_admin_referer( 'tgmpa-activate', 'tgmpa-activate-nonce' );

if( $this->activate_single_plugin( $this->plugins[ $slug ]['file_path'], $slug ) === true ) {
if( false === $this->activate_single_plugin( $this->plugins[ $slug ]['file_path'], $slug ) ) {
return true; // Finish execution of the function early as we encountered an error
}
}
Expand Down Expand Up @@ -689,7 +689,7 @@ public function maybe_adjust_source_dir( $source, $remote_source, $upgrader ) {
* @param bool $automatic Whether this is an automatic activation after an install. Defaults to false.
* This determines the styling of the output messages.
*
* @return bool True if an error was encountered, false otherwise.
* @return bool False if an error was encountered, true otherwise.
*/
protected function activate_single_plugin( $file_path, $slug, $automatic = false ) {

Expand All @@ -699,7 +699,7 @@ protected function activate_single_plugin( $file_path, $slug, $automatic = false
if ( is_wp_error( $activate ) ) {
echo '<div id="message" class="error"><p>', wp_kses_post( $activate->get_error_message() ), '</p></div>',
'<p><a href="', esc_url( $this->get_tgmpa_url() ), '" target="_parent">', esc_html( $this->strings['return'] ), '</a></p>';
return true; // End it here if there is an error with activation.
return false; // End it here if there is an error with activation.

} else {
if ( ! $automatic ) {
Expand All @@ -724,7 +724,7 @@ protected function activate_single_plugin( $file_path, $slug, $automatic = false
'</p></div>';
}

return false;
return true;
}

/**
Expand All @@ -751,7 +751,7 @@ public function notices() {
return;
}

$installed_plugins = get_plugins(); // Retrieve a list of all the plugins
$installed_plugins = get_plugins(); // Retrieve a list of all the plugins
$message = array(); // Store the messages in an array to be outputted after plugins have looped through.
$install_link = false; // Set to false, change to true in loop if conditions exist, used for action link 'install'.
$install_link_count = 0; // Used to determine plurality of install action link text.
Expand Down

0 comments on commit 9d3f66a

Please sign in to comment.