Skip to content

Commit

Permalink
Merge pull request #508 from TGMPA/issue-442
Browse files Browse the repository at this point in the history
Prevent updating plugins which are not installed.
  • Loading branch information
GaryJones committed Jan 5, 2016
2 parents 01212ae + bf19622 commit 735d71b
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion class-tgm-plugin-activation.php
Original file line number Diff line number Diff line change
Expand Up @@ -1712,6 +1712,23 @@ public function can_plugin_update( $slug ) {
return true;
}

/**
* Check to see if the plugin is 'updatetable', i.e. installed, with an update available
* and no WP version requirements blocking it.
*
* @since 2.x.x
*
* @param string $slug Plugin slug.
* @return bool True if OK to proceed with update, false otherwise.
*/
public function is_plugin_updatetable( $slug ) {
if ( ! $this->is_plugin_installed( $slug ) ) {
return false;
} else {
return ( $this->does_plugin_have_update( $slug ) && $this->can_plugin_update( $slug ) );
}
}

/**
* Check if a plugin can be activated, i.e. is not currently active and meets the minimum
* plugin version requirements set in TGMPA (if any).
Expand Down Expand Up @@ -2688,7 +2705,7 @@ public function process_bulk_actions() {
}

// For updates: make sure this is a plugin we *can* update (update available and WP version ok).
if ( 'update' === $install_type && ( $this->tgmpa->is_plugin_installed( $slug ) && ( false === $this->tgmpa->does_plugin_have_update( $slug ) || ! $this->tgmpa->can_plugin_update( $slug ) ) ) ) {
if ( 'update' === $install_type && false === $this->tgmpa->is_plugin_updatetable( $slug ) ) {
unset( $plugins_to_install[ $key ] );
}
}
Expand Down

0 comments on commit 735d71b

Please sign in to comment.