Skip to content

Commit ba41c10

Browse files
committed
Merge pull request #449 from TGMPA/develop
Release v2.5.2
2 parents 8fdaa77 + 3f3f4d0 commit ba41c10

File tree

4 files changed

+95
-14
lines changed

4 files changed

+95
-14
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog for TGM Plugin Activation library
22

3+
## 2.5.2 (2015-07-15)
4+
* 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.
5+
6+
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.
7+
38
## 2.5.1 (2015-07-13)
49

510
* Hot Fix: fixes potential `Fatal error: Call to undefined method TGM_Utils::validate_bool()` errors caused by a conflict with the Soliloquy plugin.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
**Lead Developers:**
88
[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))
9-
**Version:** 2.5.1
9+
**Version:** 2.5.2
1010
**Requires at least:** 3.7.0
1111
**Tested up to:** 4.2.0
1212

class-tgm-plugin-activation.php

Lines changed: 88 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* or theme author for support.
99
*
1010
* @package TGM-Plugin-Activation
11-
* @version 2.5.1
11+
* @version 2.5.2
1212
* @link http://tgmpluginactivation.com/
1313
* @author Thomas Griffin, Gary Jones, Juliette Reinders Folmer
1414
* @copyright Copyright (c) 2011, Thomas Griffin
@@ -18,7 +18,7 @@
1818
* Plugin Name: TGM Plugin Activation
1919
* Plugin URI:
2020
* Description: Plugin installation and activation for WordPress themes.
21-
* Version: 2.5.1
21+
* Version: 2.5.2
2222
* Author: Thomas Griffin, Gary Jones, Juliette Reinders Folmer
2323
* Author URI: http://tgmpluginactivation.com/
2424
* Text Domain: tgmpa
@@ -66,7 +66,7 @@ class TGM_Plugin_Activation {
6666
*
6767
* @const string Version number.
6868
*/
69-
const TGMPA_VERSION = '2.5.1';
69+
const TGMPA_VERSION = '2.5.2';
7070

7171
/**
7272
* Regular expression to test if a URL is a WP plugin repo URL.
@@ -149,7 +149,7 @@ class TGM_Plugin_Activation {
149149
*
150150
* @var string
151151
*/
152-
public $menu = 'tgmpa-install-plugins';
152+
protected $menu = 'tgmpa-install-plugins';
153153

154154
/**
155155
* Parent menu file slug.
@@ -256,11 +256,15 @@ class TGM_Plugin_Activation {
256256
* Adds a reference of this object to $instance, populates default strings,
257257
* does the tgmpa_init action hook, and hooks in the interactions to init.
258258
*
259+
* @internal This method should be `protected`, but as too many TGMPA implementations
260+
* haven't upgraded beyond v2.3.6 yet, this gives backward compatibility issues.
261+
* Reverted back to public for the time being.
262+
*
259263
* @since 1.0.0
260264
*
261265
* @see TGM_Plugin_Activation::init()
262266
*/
263-
protected function __construct() {
267+
public function __construct() {
264268
// Set the current WordPress version.
265269
$this->wp_version = $GLOBALS['wp_version'];
266270

@@ -271,6 +275,34 @@ protected function __construct() {
271275
add_action( 'init', array( $this, 'init' ) );
272276
}
273277

278+
/**
279+
* Magic method to (not) set protected properties from outside of this class.
280+
*
281+
* @internal hackedihack... There is a serious bug in v2.3.2 - 2.3.6 where the `menu` property
282+
* is being assigned rather than tested in a conditional, effectively rendering it useless.
283+
* This 'hack' prevents this from happening.
284+
*
285+
* @see https://github.com/TGMPA/TGM-Plugin-Activation/blob/2.3.6/tgm-plugin-activation/class-tgm-plugin-activation.php#L1593
286+
*
287+
* @param string $name Name of an inaccessible property.
288+
* @param mixed $value Value to assign to the property.
289+
* @return void Silently fail to set the property when this is tried from outside of this class context.
290+
* (Inside this class context, the __set() method if not used as there is direct access.)
291+
*/
292+
public function __set( $name, $value ) {
293+
return;
294+
}
295+
296+
/**
297+
* Magic method to get the value of a protected property outside of this class context.
298+
*
299+
* @param string $name Name of an inaccessible property.
300+
* @return mixed The property value.
301+
*/
302+
public function __get( $name ) {
303+
return $this->{$name};
304+
}
305+
274306
/**
275307
* Initialise the interactions between this class and WordPress.
276308
*
@@ -1900,6 +1932,21 @@ function tgmpa( $plugins, $config = array() ) {
19001932
}
19011933

19021934
if ( ! empty( $config ) && is_array( $config ) ) {
1935+
// Send out notices for deprecated arguments passed.
1936+
if ( isset( $config['notices'] ) ) {
1937+
_deprecated_argument( __FUNCTION__, '2.2.0', 'The `notices` config parameter was renamed to `has_notices` in TGMPA 2.2.0. Please adjust your configuration.' );
1938+
if ( ! isset( $config['has_notices'] ) ) {
1939+
$config['has_notices'] = $config['notices'];
1940+
}
1941+
}
1942+
1943+
if ( isset( $config['parent_menu_slug'] ) ) {
1944+
_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.' );
1945+
}
1946+
if ( isset( $config['parent_url_slug'] ) ) {
1947+
_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.' );
1948+
}
1949+
19031950
call_user_func( array( $instance, 'config' ), $config );
19041951
}
19051952
}
@@ -2697,9 +2744,9 @@ public function process_bulk_actions() {
26972744
}
26982745
unset( $slug, $name, $source );
26992746

2700-
// Create a new instance of TGM_Bulk_Installer.
2701-
$installer = new TGM_Bulk_Installer(
2702-
new TGM_Bulk_Installer_Skin(
2747+
// Create a new instance of TGMPA_Bulk_Installer.
2748+
$installer = new TGMPA_Bulk_Installer(
2749+
new TGMPA_Bulk_Installer_Skin(
27032750
array(
27042751
'url' => esc_url_raw( $this->tgmpa->get_tgmpa_url() ),
27052752
'nonce' => 'bulk-' . $this->_args['plural'],
@@ -2846,6 +2893,24 @@ protected function _get_plugin_data_from_name( $name, $data = 'slug' ) {
28462893
}
28472894
}
28482895

2896+
2897+
if ( ! class_exists( 'TGM_Bulk_Installer' ) ) {
2898+
2899+
/**
2900+
* Hack: Prevent TGMPA v2.4.1- bulk installer class from being loaded if 2.4.1- is loaded after 2.5+.
2901+
*/
2902+
class TGM_Bulk_Installer {
2903+
}
2904+
}
2905+
if ( ! class_exists( 'TGM_Bulk_Installer_Skin' ) ) {
2906+
2907+
/**
2908+
* Hack: Prevent TGMPA v2.4.1- bulk installer skin class from being loaded if 2.4.1- is loaded after 2.5+.
2909+
*/
2910+
class TGM_Bulk_Installer_Skin {
2911+
}
2912+
}
2913+
28492914
/**
28502915
* The WP_Upgrader file isn't always available. If it isn't available,
28512916
* we load it here.
@@ -2862,6 +2927,11 @@ protected function _get_plugin_data_from_name( $name, $data = 'slug' ) {
28622927
* Load bulk installer
28632928
*/
28642929
function tgmpa_load_bulk_installer() {
2930+
// Silently fail if 2.5+ is loaded *after* an older version.
2931+
if ( ! isset( $GLOBALS['tgmpa'] ) ) {
2932+
return;
2933+
}
2934+
28652935
// Get TGMPA class instance.
28662936
$tgmpa_instance = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) );
28672937

@@ -2870,7 +2940,7 @@ function tgmpa_load_bulk_installer() {
28702940
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
28712941
}
28722942

2873-
if ( ! class_exists( 'TGM_Bulk_Installer' ) ) {
2943+
if ( ! class_exists( 'TGMPA_Bulk_Installer' ) ) {
28742944

28752945
/**
28762946
* Installer class to handle bulk plugin installations.
@@ -2881,12 +2951,14 @@ function tgmpa_load_bulk_installer() {
28812951
* @since 2.2.0
28822952
*
28832953
* @internal Since 2.5.0 the class is an extension of Plugin_Upgrader rather than WP_Upgrader
2954+
* @internal Since 2.5.2 the class has been renamed from TGM_Bulk_Installer to TGMPA_Bulk_Installer.
2955+
* This was done to prevent backward compatibility issues with v2.3.6.
28842956
*
28852957
* @package TGM-Plugin-Activation
28862958
* @author Thomas Griffin
28872959
* @author Gary Jones
28882960
*/
2889-
class TGM_Bulk_Installer extends Plugin_Upgrader {
2961+
class TGMPA_Bulk_Installer extends Plugin_Upgrader {
28902962
/**
28912963
* Holds result of bulk plugin installation.
28922964
*
@@ -3192,7 +3264,7 @@ public function auto_activate( $bool ) {
31923264
}
31933265
}
31943266

3195-
if ( ! class_exists( 'TGM_Bulk_Installer_Skin' ) ) {
3267+
if ( ! class_exists( 'TGMPA_Bulk_Installer_Skin' ) ) {
31963268

31973269
/**
31983270
* Installer skin to set strings for the bulk plugin installations..
@@ -3202,13 +3274,17 @@ public function auto_activate( $bool ) {
32023274
*
32033275
* @since 2.2.0
32043276
*
3277+
* @internal Since 2.5.2 the class has been renamed from TGM_Bulk_Installer_Skin to
3278+
* TGMPA_Bulk_Installer_Skin.
3279+
* This was done to prevent backward compatibility issues with v2.3.6.
3280+
*
32053281
* @see https://core.trac.wordpress.org/browser/trunk/src/wp-admin/includes/class-wp-upgrader-skins.php
32063282
*
32073283
* @package TGM-Plugin-Activation
32083284
* @author Thomas Griffin
32093285
* @author Gary Jones
32103286
*/
3211-
class TGM_Bulk_Installer_Skin extends Bulk_Upgrader_Skin {
3287+
class TGMPA_Bulk_Installer_Skin extends Bulk_Upgrader_Skin {
32123288
/**
32133289
* Holds plugin info for each individual plugin installation.
32143290
*

example.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
* @package TGM-Plugin-Activation
1212
* @subpackage Example
13-
* @version 2.5.1
13+
* @version 2.5.2
1414
* @author Thomas Griffin, Gary Jones, Juliette Reinders Folmer
1515
* @copyright Copyright (c) 2011, Thomas Griffin
1616
* @license http://opensource.org/licenses/gpl-2.0.php GPL v2 or later

0 commit comments

Comments
 (0)