From 932bc17d55272441361cd782e7211b4f557dadf6 Mon Sep 17 00:00:00 2001 From: noErrdev <dbongo0701@gmail.com> Date: Sat, 13 Oct 2018 11:12:43 +0200 Subject: [PATCH] fixed : prefixed TGMPA class with HU_ to fix potential collision with other plugins using the same class. see issue https://github.com/presscustomizr/customizr/issues/1603 --- .../admin/class-admin-update-notification.php | 4 +-- .../admin/class-tgm-plugin-activation.php | 30 +++++++++---------- functions/init-admin.php | 5 ++-- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/functions/admin/class-admin-update-notification.php b/functions/admin/class-admin-update-notification.php index 7bb046f..ba2298c 100644 --- a/functions/admin/class-admin-update-notification.php +++ b/functions/admin/class-admin-update-notification.php @@ -82,8 +82,8 @@ function hu_may_be_display_update_notice() { if ( ! $show_new_notice ) return; - - if ( ! hu_is_plugin_active('nimble-builder/nimble-builder.php') && class_exists('TGM_Plugin_Activation') && ! TGM_Plugin_Activation::get_instance()->hu_is_notice_dismissed() ) + //prefixed HU_Plugin_Activation because of the possible issue : https://github.com/presscustomizr/customizr/issues/1603 + if ( ! hu_is_plugin_active('nimble-builder/nimble-builder.php') && class_exists('HU_Plugin_Activation') && ! HU_Plugin_Activation::get_instance()->hu_is_notice_dismissed() ) return; ob_start(); diff --git a/functions/admin/class-tgm-plugin-activation.php b/functions/admin/class-tgm-plugin-activation.php index 1e1120e..3541c15 100644 --- a/functions/admin/class-tgm-plugin-activation.php +++ b/functions/admin/class-tgm-plugin-activation.php @@ -31,8 +31,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - -if ( ! class_exists( 'TGM_Plugin_Activation' ) ) { +//prefixed HU_Plugin_Activation because of the possible issue : https://github.com/presscustomizr/customizr/issues/1603 +if ( ! class_exists( 'HU_Plugin_Activation' ) ) { /** * Automatic plugin installation and activation library. @@ -47,7 +47,7 @@ * @author Thomas Griffin * @author Gary Jones */ - class TGM_Plugin_Activation { + class HU_Plugin_Activation { /** * TGMPA version number. * @@ -80,7 +80,7 @@ class TGM_Plugin_Activation { * * @since 1.0.0 * - * @var TGM_Plugin_Activation + * @var HU_Plugin_Activation */ public static $instance; @@ -250,7 +250,7 @@ class TGM_Plugin_Activation { * * @since 1.0.0 * - * @see TGM_Plugin_Activation::init() + * @see HU_Plugin_Activation::init() */ public function __construct() { // Set the current WordPress version. @@ -485,9 +485,9 @@ public function __get( $name ) { * * @since 2.0.0 * - * @see TGM_Plugin_Activation::admin_menu() - * @see TGM_Plugin_Activation::notices() - * @see TGM_Plugin_Activation::styles() + * @see HU_Plugin_Activation::admin_menu() + * @see HU_Plugin_Activation::notices() + * @see HU_Plugin_Activation::styles() */ public function init() { /** @@ -786,8 +786,8 @@ public function thickbox() { * * @since 1.0.0 * - * @see TGM_Plugin_Activation::init() - * @see TGM_Plugin_Activation::install_plugins_page() + * @see HU_Plugin_Activation::init() + * @see HU_Plugin_Activation::install_plugins_page() * * @return null Return early if user lacks capability to install a plugin. */ @@ -2209,7 +2209,7 @@ public function show_tgmpa_version() { * * @since 2.4.0 * - * @return \TGM_Plugin_Activation The TGM_Plugin_Activation object. + * @return \HU_Plugin_Activation The HU_Plugin_Activation object. */ public static function get_instance() { if ( ! isset( self::$instance ) && ! ( self::$instance instanceof self ) ) { @@ -2227,7 +2227,7 @@ public static function get_instance() { * @since 2.5.0 */ function load_tgm_plugin_activation() { - $GLOBALS['tgmpa'] = TGM_Plugin_Activation::get_instance(); + $GLOBALS['tgmpa'] = HU_Plugin_Activation::get_instance(); } } @@ -3216,15 +3216,15 @@ public function prepare_items() { * Retrieve plugin data, given the plugin name. * * @since 2.2.0 - * @deprecated 2.5.0 use {@see TGM_Plugin_Activation::_get_plugin_data_from_name()} instead. - * @see TGM_Plugin_Activation::_get_plugin_data_from_name() + * @deprecated 2.5.0 use {@see HU_Plugin_Activation::_get_plugin_data_from_name()} instead. + * @see HU_Plugin_Activation::_get_plugin_data_from_name() * * @param string $name Name of the plugin, as it was registered. * @param string $data Optional. Array key of plugin data to return. Default is slug. * @return string|boolean Plugin slug if found, false otherwise. */ protected function _get_plugin_data_from_name( $name, $data = 'slug' ) { - _deprecated_function( __FUNCTION__, 'TGMPA 2.5.0', 'TGM_Plugin_Activation::_get_plugin_data_from_name()' ); + _deprecated_function( __FUNCTION__, 'TGMPA 2.5.0', 'HU_Plugin_Activation::_get_plugin_data_from_name()' ); return $this->tgmpa->_get_plugin_data_from_name( $name, $data ); } diff --git a/functions/init-admin.php b/functions/init-admin.php index f457584..62287cc 100644 --- a/functions/init-admin.php +++ b/functions/init-admin.php @@ -50,8 +50,9 @@ function hu_admin_style() { /* ------------------------------------------------------------------------- */ if ( ( ! defined( 'HU_IS_PRO' ) || ! HU_IS_PRO ) && is_admin() && ! hu_is_customizing() && ! hu_is_plugin_active('nimble-builder/nimble-builder.php') ) { /** - * Include the TGM_Plugin_Activation class. + * Include the HU_Plugin_Activation class. */ + //prefixed HU_Plugin_Activation because of the possible issue : https://github.com/presscustomizr/customizr/issues/1603 load_template( get_template_directory() . '/functions/admin/class-tgm-plugin-activation.php' ); add_action( 'tgmpa_register', 'hu_register_required_plugins' ); } @@ -67,7 +68,7 @@ function hu_admin_style() { * arrays. * * This function is hooked into tgmpa_init, which is fired within the - * TGM_Plugin_Activation class constructor. + * HU_Plugin_Activation class constructor. */ function hu_register_required_plugins() {