diff --git a/CHANGELOG.md b/CHANGELOG.md index 15d5e083..85e7c8e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog for TGM Plugin Activation library +## 2.5.2 (2015-07-15) +* Hot Fix: fixes potential `Fatal error: Call to protected TGM_Plugin_Activation::__construct()` error and other compatibility issues when both TGMPA 2.5+ as well as TGMPA 2.3.6- would be loaded by different themes and plugins. + +Take note: We do **NOT** support 2.3.6 anymore and **_highly_** discourage its use. Any themes and plugins still using TGMPA 2.3.6 or less should upgrade as soon as possible. All the same, the end-user should not be confronted with white screens because of it, so this hot fix should prevent just that. + ## 2.5.1 (2015-07-13) * Hot Fix: fixes potential `Fatal error: Call to undefined method TGM_Utils::validate_bool()` errors caused by a conflict with the Soliloquy plugin. diff --git a/README.md b/README.md index b54310b7..1f795d0a 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ **Lead Developers:** [Thomas Griffin](https://github.com/thomasgriffin) ([@jthomasgriffin](https://twitter.com/jthomasgriffin)), [Gary Jones](https://github.com/GaryJones) ([@GaryJ](https://twitter.com/GaryJ)), [Juliette Reinders Folmer](https://github.com/jrfnl) ([@jrf_nl](https://twitter.com/jrf_nl)) -**Version:** 2.5.1 +**Version:** 2.5.2 **Requires at least:** 3.7.0 **Tested up to:** 4.2.0 diff --git a/class-tgm-plugin-activation.php b/class-tgm-plugin-activation.php index 46d10c75..ee6eb730 100755 --- a/class-tgm-plugin-activation.php +++ b/class-tgm-plugin-activation.php @@ -8,7 +8,7 @@ * or theme author for support. * * @package TGM-Plugin-Activation - * @version 2.5.1 + * @version 2.5.2 * @link http://tgmpluginactivation.com/ * @author Thomas Griffin, Gary Jones, Juliette Reinders Folmer * @copyright Copyright (c) 2011, Thomas Griffin @@ -18,7 +18,7 @@ * Plugin Name: TGM Plugin Activation * Plugin URI: * Description: Plugin installation and activation for WordPress themes. - * Version: 2.5.1 + * Version: 2.5.2 * Author: Thomas Griffin, Gary Jones, Juliette Reinders Folmer * Author URI: http://tgmpluginactivation.com/ * Text Domain: tgmpa @@ -66,7 +66,7 @@ class TGM_Plugin_Activation { * * @const string Version number. */ - const TGMPA_VERSION = '2.5.1'; + const TGMPA_VERSION = '2.5.2'; /** * Regular expression to test if a URL is a WP plugin repo URL. @@ -149,7 +149,7 @@ class TGM_Plugin_Activation { * * @var string */ - public $menu = 'tgmpa-install-plugins'; + protected $menu = 'tgmpa-install-plugins'; /** * Parent menu file slug. @@ -256,11 +256,15 @@ class TGM_Plugin_Activation { * Adds a reference of this object to $instance, populates default strings, * does the tgmpa_init action hook, and hooks in the interactions to init. * + * @internal This method should be `protected`, but as too many TGMPA implementations + * haven't upgraded beyond v2.3.6 yet, this gives backward compatibility issues. + * Reverted back to public for the time being. + * * @since 1.0.0 * * @see TGM_Plugin_Activation::init() */ - protected function __construct() { + public function __construct() { // Set the current WordPress version. $this->wp_version = $GLOBALS['wp_version']; @@ -271,6 +275,34 @@ protected function __construct() { add_action( 'init', array( $this, 'init' ) ); } + /** + * Magic method to (not) set protected properties from outside of this class. + * + * @internal hackedihack... There is a serious bug in v2.3.2 - 2.3.6 where the `menu` property + * is being assigned rather than tested in a conditional, effectively rendering it useless. + * This 'hack' prevents this from happening. + * + * @see https://github.com/TGMPA/TGM-Plugin-Activation/blob/2.3.6/tgm-plugin-activation/class-tgm-plugin-activation.php#L1593 + * + * @param string $name Name of an inaccessible property. + * @param mixed $value Value to assign to the property. + * @return void Silently fail to set the property when this is tried from outside of this class context. + * (Inside this class context, the __set() method if not used as there is direct access.) + */ + public function __set( $name, $value ) { + return; + } + + /** + * Magic method to get the value of a protected property outside of this class context. + * + * @param string $name Name of an inaccessible property. + * @return mixed The property value. + */ + public function __get( $name ) { + return $this->{$name}; + } + /** * Initialise the interactions between this class and WordPress. * @@ -1900,6 +1932,21 @@ function tgmpa( $plugins, $config = array() ) { } if ( ! empty( $config ) && is_array( $config ) ) { + // Send out notices for deprecated arguments passed. + if ( isset( $config['notices'] ) ) { + _deprecated_argument( __FUNCTION__, '2.2.0', 'The `notices` config parameter was renamed to `has_notices` in TGMPA 2.2.0. Please adjust your configuration.' ); + if ( ! isset( $config['has_notices'] ) ) { + $config['has_notices'] = $config['notices']; + } + } + + if ( isset( $config['parent_menu_slug'] ) ) { + _deprecated_argument( __FUNCTION__, '2.4.0', 'The `parent_menu_slug` config parameter was removed in TGMPA 2.4.0. In TGMPA 2.5.0 an alternative was (re-)introduced. Please adjust your configuration. For more information visit the website: http://tgmpluginactivation.com/configuration/#h-configuration-options.' ); + } + if ( isset( $config['parent_url_slug'] ) ) { + _deprecated_argument( __FUNCTION__, '2.4.0', 'The `parent_url_slug` config parameter was removed in TGMPA 2.4.0. In TGMPA 2.5.0 an alternative was (re-)introduced. Please adjust your configuration. For more information visit the website: http://tgmpluginactivation.com/configuration/#h-configuration-options.' ); + } + call_user_func( array( $instance, 'config' ), $config ); } } @@ -2697,9 +2744,9 @@ public function process_bulk_actions() { } unset( $slug, $name, $source ); - // Create a new instance of TGM_Bulk_Installer. - $installer = new TGM_Bulk_Installer( - new TGM_Bulk_Installer_Skin( + // Create a new instance of TGMPA_Bulk_Installer. + $installer = new TGMPA_Bulk_Installer( + new TGMPA_Bulk_Installer_Skin( array( 'url' => esc_url_raw( $this->tgmpa->get_tgmpa_url() ), 'nonce' => 'bulk-' . $this->_args['plural'], @@ -2846,6 +2893,24 @@ protected function _get_plugin_data_from_name( $name, $data = 'slug' ) { } } + +if ( ! class_exists( 'TGM_Bulk_Installer' ) ) { + + /** + * Hack: Prevent TGMPA v2.4.1- bulk installer class from being loaded if 2.4.1- is loaded after 2.5+. + */ + class TGM_Bulk_Installer { + } +} +if ( ! class_exists( 'TGM_Bulk_Installer_Skin' ) ) { + + /** + * Hack: Prevent TGMPA v2.4.1- bulk installer skin class from being loaded if 2.4.1- is loaded after 2.5+. + */ + class TGM_Bulk_Installer_Skin { + } +} + /** * The WP_Upgrader file isn't always available. If it isn't available, * we load it here. @@ -2862,6 +2927,11 @@ protected function _get_plugin_data_from_name( $name, $data = 'slug' ) { * Load bulk installer */ function tgmpa_load_bulk_installer() { + // Silently fail if 2.5+ is loaded *after* an older version. + if ( ! isset( $GLOBALS['tgmpa'] ) ) { + return; + } + // Get TGMPA class instance. $tgmpa_instance = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) ); @@ -2870,7 +2940,7 @@ function tgmpa_load_bulk_installer() { require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; } - if ( ! class_exists( 'TGM_Bulk_Installer' ) ) { + if ( ! class_exists( 'TGMPA_Bulk_Installer' ) ) { /** * Installer class to handle bulk plugin installations. @@ -2881,12 +2951,14 @@ function tgmpa_load_bulk_installer() { * @since 2.2.0 * * @internal Since 2.5.0 the class is an extension of Plugin_Upgrader rather than WP_Upgrader + * @internal Since 2.5.2 the class has been renamed from TGM_Bulk_Installer to TGMPA_Bulk_Installer. + * This was done to prevent backward compatibility issues with v2.3.6. * * @package TGM-Plugin-Activation * @author Thomas Griffin * @author Gary Jones */ - class TGM_Bulk_Installer extends Plugin_Upgrader { + class TGMPA_Bulk_Installer extends Plugin_Upgrader { /** * Holds result of bulk plugin installation. * @@ -3192,7 +3264,7 @@ public function auto_activate( $bool ) { } } - if ( ! class_exists( 'TGM_Bulk_Installer_Skin' ) ) { + if ( ! class_exists( 'TGMPA_Bulk_Installer_Skin' ) ) { /** * Installer skin to set strings for the bulk plugin installations.. @@ -3202,13 +3274,17 @@ public function auto_activate( $bool ) { * * @since 2.2.0 * + * @internal Since 2.5.2 the class has been renamed from TGM_Bulk_Installer_Skin to + * TGMPA_Bulk_Installer_Skin. + * This was done to prevent backward compatibility issues with v2.3.6. + * * @see https://core.trac.wordpress.org/browser/trunk/src/wp-admin/includes/class-wp-upgrader-skins.php * * @package TGM-Plugin-Activation * @author Thomas Griffin * @author Gary Jones */ - class TGM_Bulk_Installer_Skin extends Bulk_Upgrader_Skin { + class TGMPA_Bulk_Installer_Skin extends Bulk_Upgrader_Skin { /** * Holds plugin info for each individual plugin installation. * diff --git a/example.php b/example.php index 10e3b73f..064a6aab 100755 --- a/example.php +++ b/example.php @@ -10,7 +10,7 @@ * * @package TGM-Plugin-Activation * @subpackage Example - * @version 2.5.1 + * @version 2.5.2 * @author Thomas Griffin, Gary Jones, Juliette Reinders Folmer * @copyright Copyright (c) 2011, Thomas Griffin * @license http://opensource.org/licenses/gpl-2.0.php GPL v2 or later