Skip to content

Commit

Permalink
Merge pull request #449 from TGMPA/develop
Browse files Browse the repository at this point in the history
Release v2.5.2
  • Loading branch information
jrfnl committed Jul 16, 2015
2 parents 8fdaa77 + 3f3f4d0 commit ba41c10
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 14 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
100 changes: 88 additions & 12 deletions class-tgm-plugin-activation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -149,7 +149,7 @@ class TGM_Plugin_Activation {
*
* @var string
*/
public $menu = 'tgmpa-install-plugins';
protected $menu = 'tgmpa-install-plugins';

/**
* Parent menu file slug.
Expand Down Expand Up @@ -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'];

Expand All @@ -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.
*
Expand Down Expand Up @@ -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 );
}
}
Expand Down Expand Up @@ -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'],
Expand Down Expand Up @@ -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.
Expand All @@ -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' ) );

Expand All @@ -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.
Expand All @@ -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.
*
Expand Down Expand Up @@ -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..
Expand All @@ -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.
*
Expand Down
2 changes: 1 addition & 1 deletion example.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ba41c10

Please sign in to comment.