Skip to content

Commit

Permalink
prefixed TGMPA class with CZR to fix potential collision with other p…
Browse files Browse the repository at this point in the history
…lugins using the same class. fixes #1603
  • Loading branch information
nikeo committed Oct 13, 2018
1 parent c66976c commit 795037e
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 23 deletions.
7 changes: 4 additions & 3 deletions core/_dev/_admin/class-fire-admin_init.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,6 @@ function czr_fn_may_be_display_update_notice() {
if ( ( defined('DISPLAY_UPDATE_NOTIFICATION') && ! DISPLAY_UPDATE_NOTIFICATION ) || ( defined('DISPLAY_PRO_UPDATE_NOTIFICATION') && ! DISPLAY_PRO_UPDATE_NOTIFICATION ) )
return;

if ( ! czr_fn_is_plugin_active('nimble-builder/nimble-builder.php') && class_exists('TGM_Plugin_Activation') && ! TGM_Plugin_Activation::get_instance()->czr_fn_is_notice_dismissed() )
return;

$opt_name = CZR_IS_PRO ? 'last_update_notice_pro' : 'last_update_notice';
$last_update_notice_values = czr_fn_opt($opt_name);
$show_new_notice = false;
Expand Down Expand Up @@ -370,6 +367,10 @@ function czr_fn_may_be_display_update_notice() {
if ( ! $show_new_notice )
return;

// prefixed CZR_Plugin_Activation because of the possible issue : https://github.com/presscustomizr/customizr/issues/1603
if ( ! czr_fn_is_plugin_active('nimble-builder/nimble-builder.php') && class_exists('CZR_Plugin_Activation') && ! CZR_Plugin_Activation::get_instance()->czr_fn_is_notice_dismissed() )
return;

ob_start();
?>
<div class="updated czr-update-notice" style="position:relative">
Expand Down
46 changes: 28 additions & 18 deletions core/class-tgm-plugin-activation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 CZR_Plugin_Activation because of the possible issue : https://github.com/presscustomizr/customizr/issues/1603
if ( ! class_exists( 'CZR_Plugin_Activation' ) ) {

/**
* Automatic plugin installation and activation library.
Expand All @@ -47,7 +47,7 @@
* @author Thomas Griffin
* @author Gary Jones
*/
class TGM_Plugin_Activation {
class CZR_lugin_Activation {
/**
* TGMPA version number.
*
Expand Down Expand Up @@ -80,7 +80,7 @@ class TGM_Plugin_Activation {
*
* @since 1.0.0
*
* @var TGM_Plugin_Activation
* @var CZR_Plugin_Activation
*/
public static $instance;

Expand Down Expand Up @@ -250,7 +250,7 @@ class TGM_Plugin_Activation {
*
* @since 1.0.0
*
* @see TGM_Plugin_Activation::init()
* @see CZR_Plugin_Activation::init()
*/
public function __construct() {
// Set the current WordPress version.
Expand Down Expand Up @@ -486,9 +486,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 CZR_Plugin_Activation::admin_menu()
* @see CZR_Plugin_Activation::notices()
* @see CZR_Plugin_Activation::styles()
*/
public function init() {
/**
Expand Down Expand Up @@ -787,8 +787,8 @@ public function thickbox() {
*
* @since 1.0.0
*
* @see TGM_Plugin_Activation::init()
* @see TGM_Plugin_Activation::install_plugins_page()
* @see CZR_Plugin_Activation::init()
* @see CZR_Plugin_Activation::install_plugins_page()
*
* @return null Return early if user lacks capability to install a plugin.
*/
Expand Down Expand Up @@ -1326,7 +1326,7 @@ public function notices() {
$rendered,
__( 'Nimble is a section builder plugin companion for the Customizr theme.', 'customizr'),
sprintf(
__( 'It allows you to drag and drop beautiful pre-designed sections, or create your own sections with modules like Google map or a contact form, in live preview from the WordPress customizer. You\'ll find a quick introduction of the plugin %1$s.', 'customizr' ),
__( 'It allows you to drag and drop pre-built sections, or create your own sections in live preview from the WordPress customizer. You can easily create column layouts and add content like buttons, icons, Google map and even contact forms in any page. You\'ll find a quick introduction of the plugin %1$s.', 'customizr' ),
sprintf('<a href="%1$s" target="_blank" title="%2$s">%2$s</a>', esc_url('docs.presscustomizr.com/article/337-getting-started-with-the-nimble-builder-plugin'), __('here', 'customizr') )
),
__( "The plugin has been designed to integrate perfectly with the Customizr theme. Lightweight and safe.", 'customizr')
Expand Down Expand Up @@ -2210,7 +2210,7 @@ public function show_tgmpa_version() {
*
* @since 2.4.0
*
* @return \TGM_Plugin_Activation The TGM_Plugin_Activation object.
* @return \CZR_Plugin_Activation The CZR_Plugin_Activation object.
*/
public static function get_instance() {
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof self ) ) {
Expand All @@ -2228,7 +2228,7 @@ public static function get_instance() {
* @since 2.5.0
*/
function load_tgm_plugin_activation() {
$GLOBALS['tgmpa'] = TGM_Plugin_Activation::get_instance();
$GLOBALS['tgmpa'] = CZR_Plugin_Activation::get_instance();
}
}

Expand Down Expand Up @@ -3217,20 +3217,30 @@ 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 CZR_Plugin_Activation::_get_plugin_data_from_name()} instead.
* @see CZR_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', 'CZR_Plugin_Activation::_get_plugin_data_from_name()' );

return $this->tgmpa->_get_plugin_data_from_name( $name, $data );
}
}
}
}//end of CZR_Plugin_Activation
}//class_exists()












if ( ! class_exists( 'TGM_Bulk_Installer' ) ) {
Expand Down
5 changes: 3 additions & 2 deletions core/init-base.php
Original file line number Diff line number Diff line change
Expand Up @@ -1114,7 +1114,8 @@ function czr_fn_maybe_register_nimble_location() {
/* ------------------------------------------------------------------------- */
if ( is_admin() && ! czr_fn_is_customizing() && ! czr_fn_is_pro() && ! czr_fn_is_plugin_active('nimble-builder/nimble-builder.php') ) {
/**
* Include the TGM_Plugin_Activation class.
* Include the CZR_Plugin_Activation class.
* prefixed CZR_Plugin_Activation because of the possible issue : https://github.com/presscustomizr/customizr/issues/1603
*/
load_template( get_template_directory() . '/core/class-tgm-plugin-activation.php' );
add_action( 'tgmpa_register', 'czr_fn_register_required_plugins');
Expand All @@ -1130,7 +1131,7 @@ function czr_fn_maybe_register_nimble_location() {
* arrays.
*
* This function is hooked into tgmpa_init, which is fired within the
* TGM_Plugin_Activation class constructor.
* CZR_Plugin_Activation class constructor.
*/
function czr_fn_register_required_plugins() {

Expand Down

0 comments on commit 795037e

Please sign in to comment.