From bf196223af8e37680757cabeff8fe086ae662b2d Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 5 Jan 2016 15:17:45 +0100 Subject: [PATCH] Prevent updating plugins which are not installed. Fixes #442 --- class-tgm-plugin-activation.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/class-tgm-plugin-activation.php b/class-tgm-plugin-activation.php index 0f90d143..89f18cb4 100755 --- a/class-tgm-plugin-activation.php +++ b/class-tgm-plugin-activation.php @@ -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). @@ -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 ] ); } }