Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Check if tgmpa_load_bulk_installer is declared. #207

Closed
wants to merge 1 commit into from

6 participants

@SmashBrando

Adds in a check to see if the tgmpa_load_bulk_installer function has been declared already. Typically it is redeclared when multiple instances are running.

@SmashBrando SmashBrando Check if tgmpa_load_bulk_installer is declared.
Adds in a check to see if the tgmpa_load_bulk_installer function has been declared already. Typically it is redeclared when multiple instances are running.
a4f00d5
@tripflex

This is going to be an issue for anybody that has a site using tgmpa in other plugins or themes .... is a major bug

@jamesckemp

Yup, needs to happen!

@thomasgriffin

Ok - I will look into this and try to get it merged in this week.

@maiorcasunglasses

hi, i purchase "WooCommerce Product Configurator", use in theme "One" from ThemeForest, when i install the plugin i have this error:
Fatal error: Cannot redeclare tgmpa_load_bulk_installer() in /customers/0/1/6/maiorcasunglasses.com/httpd.www/wp-content/themes/one/framework/lib/class.tgm_plugin_activation.php on line 1692
what is the problem?
thank you

@tripflex

@maiorcasunglasses exactly what this pull request is all about.

Open that file, and add/change this:

function tgmpa_load_bulk_installer(){
...
}

to this:

if ( ! function_exists ('tgmpa_load_bulk_installer') ) {
    function tgmpa_load_bulk_installer(){
        ...
    }
}

But basically it means you have multiple plugin/theme using TGMPA and this bug affects both, so you may need to modify both files.

@jamesckemp

@maiorcasunglasses Hey. You misunderstood what I said. You need to direct the Author of your theme to this thread, as they need to make the update. I've already done so in the plugin.

@jamesckemp

Hi @thomasgriffin - Any chance we can get this sorted? I'm getting a lot of complaints, even though I have the fix implemented. It's now plugins that aren't aware of the issue conflicting with mine, and nothing I can do about it unless TGM is updated!

Appreciated

@tripflex

Still an issue getting people submitting bug reports daily about this ...

@adampickering

Why don't you ping Thomas on Skype, Twitter etc its obvious he doesn't read GitHub messages.

https://twitter.com/jthomasgriffin

@tripflex

For me it's only on older version of my plugin, since those versions I just renamed the function in my plugin so there isn't any issues.

I recommend everyone else who is having issues just change the function name to something else to prevent compatibility issues

And not gonna try that because last time I did with an issue I had with Soliloquy I never received a response, email or twitter, so not worth it :)

@thomasgriffin thomasgriffin referenced this pull request from a commit
@thomasgriffin thomasgriffin Fixes #206 and #207.
Prevents clashing if multiple TGM libraries are active at one time with
a proper function check.
3435b07
@thomasgriffin

I'm sorry guys - I don't receive notification emails for any of my Github repos. I've just pushed the fix for this and confirmed that it fixes the bug. So sorry for the delay.

@tripflex - I apologize if I haven't gotten back to you on any support request with a product. You can ping me on twitter @jthomasgriffin and I will make sure to get you taken care of.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 19, 2014
  1. @SmashBrando

    Check if tgmpa_load_bulk_installer is declared.

    SmashBrando authored
    Adds in a check to see if the tgmpa_load_bulk_installer function has been declared already. Typically it is redeclared when multiple instances are running.
This page is out of date. Refresh to see the latest.
Showing with 422 additions and 420 deletions.
  1. +422 −420 class-tgm-plugin-activation.php
View
842 class-tgm-plugin-activation.php
@@ -353,16 +353,16 @@ public function admin_menu() {
if ( ! is_plugin_active( $plugin['file_path'] ) ) {
$args = apply_filters(
- 'tgmpa_admin_menu_args',
- array(
- 'parent_slug'=> 'themes.php', // Parent Menu slug.
- 'page_title' => $this->strings['page_title'], // Page title.
- 'menu_title' => $this->strings['menu_title'], // Menu title.
- 'capability' => 'edit_theme_options', // Capability.
- 'menu_slug' => $this->menu, // Menu slug.
- 'function' => array( $this, 'install_plugins_page' ) // Callback.
- )
- );
+ 'tgmpa_admin_menu_args',
+ array(
+ 'parent_slug'=> 'themes.php', // Parent Menu slug.
+ 'page_title' => $this->strings['page_title'], // Page title.
+ 'menu_title' => $this->strings['menu_title'], // Menu title.
+ 'capability' => 'edit_theme_options', // Capability.
+ 'menu_slug' => $this->menu, // Menu slug.
+ 'function' => array( $this, 'install_plugins_page' ) // Callback.
+ )
+ );
if( apply_filters( 'tgmpa_admin_menu_use_add_theme_page', true ) ) {
add_theme_page($args['page_title'], $args['menu_title'], $args['capability'], $args['menu_slug'], $args['function']);
@@ -1703,516 +1703,518 @@ public function prepare_items() {
* @since 2.2.0
*/
add_action( 'admin_init', 'tgmpa_load_bulk_installer' );
-function tgmpa_load_bulk_installer() {
-
- if ( ! class_exists( 'WP_Upgrader' ) && ( isset( $_GET['page'] ) && TGM_Plugin_Activation::$instance->menu === $_GET['page'] ) ) {
- require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
-
- if ( ! class_exists( 'TGM_Bulk_Installer' ) ) {
- /**
- * Installer class to handle bulk plugin installations.
- *
- * Extends WP_Upgrader and customizes to suit the installation of multiple
- * plugins.
- *
- * @since 2.2.0
- *
- * @package TGM-Plugin-Activation
- * @author Thomas Griffin <thomasgriffinmedia.com>
- * @author Gary Jones <gamajo.com>
- */
- class TGM_Bulk_Installer extends WP_Upgrader {
+if ( ! function_exists ('tgmpa_load_bulk_installer')) {
+ function tgmpa_load_bulk_installer() {
- /**
- * Holds result of bulk plugin installation.
- *
- * @since 2.2.0
- *
- * @var string
- */
- public $result;
+ if ( ! class_exists( 'WP_Upgrader' ) && ( isset( $_GET['page'] ) && TGM_Plugin_Activation::$instance->menu === $_GET['page'] ) ) {
+ require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
+ if ( ! class_exists( 'TGM_Bulk_Installer' ) ) {
/**
- * Flag to check if bulk installation is occurring or not.
+ * Installer class to handle bulk plugin installations.
*
- * @since 2.2.0
- *
- * @var boolean
- */
- public $bulk = false;
-
- /**
- * Processes the bulk installation of plugins.
+ * Extends WP_Upgrader and customizes to suit the installation of multiple
+ * plugins.
*
* @since 2.2.0
*
- * @param array $packages The plugin sources needed for installation.
- * @return string|boolean Install confirmation messages on success, false on failure.
+ * @package TGM-Plugin-Activation
+ * @author Thomas Griffin <thomasgriffinmedia.com>
+ * @author Gary Jones <gamajo.com>
*/
- public function bulk_install( $packages ) {
-
- // Pass installer skin object and set bulk property to true.
- $this->init();
- $this->bulk = true;
-
- // Set install strings and automatic activation strings (if config option is set to true).
- $this->install_strings();
- if ( TGM_Plugin_Activation::$instance->is_automatic ) {
- $this->activate_strings();
- }
+ class TGM_Bulk_Installer extends WP_Upgrader {
+
+ /**
+ * Holds result of bulk plugin installation.
+ *
+ * @since 2.2.0
+ *
+ * @var string
+ */
+ public $result;
+
+ /**
+ * Flag to check if bulk installation is occurring or not.
+ *
+ * @since 2.2.0
+ *
+ * @var boolean
+ */
+ public $bulk = false;
+
+ /**
+ * Processes the bulk installation of plugins.
+ *
+ * @since 2.2.0
+ *
+ * @param array $packages The plugin sources needed for installation.
+ * @return string|boolean Install confirmation messages on success, false on failure.
+ */
+ public function bulk_install( $packages ) {
+
+ // Pass installer skin object and set bulk property to true.
+ $this->init();
+ $this->bulk = true;
+
+ // Set install strings and automatic activation strings (if config option is set to true).
+ $this->install_strings();
+ if ( TGM_Plugin_Activation::$instance->is_automatic ) {
+ $this->activate_strings();
+ }
- // Run the header string to notify user that the process has begun.
- $this->skin->header();
+ // Run the header string to notify user that the process has begun.
+ $this->skin->header();
- // Connect to the Filesystem.
- $res = $this->fs_connect( array( WP_CONTENT_DIR, WP_PLUGIN_DIR ) );
- if ( ! $res ) {
- $this->skin->footer();
- return false;
- }
+ // Connect to the Filesystem.
+ $res = $this->fs_connect( array( WP_CONTENT_DIR, WP_PLUGIN_DIR ) );
+ if ( ! $res ) {
+ $this->skin->footer();
+ return false;
+ }
- // Set the bulk header and prepare results array.
- $this->skin->bulk_header();
- $results = array();
+ // Set the bulk header and prepare results array.
+ $this->skin->bulk_header();
+ $results = array();
- // Get the total number of packages being processed and iterate as each package is successfully installed.
- $this->update_count = count( $packages );
- $this->update_current = 0;
+ // Get the total number of packages being processed and iterate as each package is successfully installed.
+ $this->update_count = count( $packages );
+ $this->update_current = 0;
- // Loop through each plugin and process the installation.
- foreach ( $packages as $plugin ) {
- $this->update_current++; // Increment counter.
+ // Loop through each plugin and process the installation.
+ foreach ( $packages as $plugin ) {
+ $this->update_current++; // Increment counter.
- // Do the plugin install.
- $result = $this->run(
- array(
- 'package' => $plugin, // The plugin source.
- 'destination' => WP_PLUGIN_DIR, // The destination dir.
- 'clear_destination' => false, // Do we want to clear the destination or not?
- 'clear_working' => true, // Remove original install file.
- 'is_multi' => true, // Are we processing multiple installs?
- 'hook_extra' => array( 'plugin' => $plugin, ), // Pass plugin source as extra data.
- )
- );
+ // Do the plugin install.
+ $result = $this->run(
+ array(
+ 'package' => $plugin, // The plugin source.
+ 'destination' => WP_PLUGIN_DIR, // The destination dir.
+ 'clear_destination' => false, // Do we want to clear the destination or not?
+ 'clear_working' => true, // Remove original install file.
+ 'is_multi' => true, // Are we processing multiple installs?
+ 'hook_extra' => array( 'plugin' => $plugin, ), // Pass plugin source as extra data.
+ )
+ );
- // Store installation results in result property.
- $results[$plugin] = $this->result;
+ // Store installation results in result property.
+ $results[$plugin] = $this->result;
- // Prevent credentials auth screen from displaying multiple times.
- if ( false === $result ) {
- break;
+ // Prevent credentials auth screen from displaying multiple times.
+ if ( false === $result ) {
+ break;
+ }
}
- }
-
- // Pass footer skin strings.
- $this->skin->bulk_footer();
- $this->skin->footer();
-
- // Return our results.
- return $results;
-
- }
-
- /**
- * Performs the actual installation of each plugin.
- *
- * This method also activates the plugin in the automatic flag has been
- * set to true for the TGMPA class.
- *
- * @since 2.2.0
- *
- * @param array $options The installation config options
- * @return null/array Return early if error, array of installation data on success
- */
- public function run( $options ) {
-
- // Default config options.
- $defaults = array(
- 'package' => '',
- 'destination' => '',
- 'clear_destination' => false,
- 'clear_working' => true,
- 'is_multi' => false,
- 'hook_extra' => array(),
- );
- // Parse default options with config options from $this->bulk_upgrade and extract them.
- $options = wp_parse_args( $options, $defaults );
- extract( $options );
+ // Pass footer skin strings.
+ $this->skin->bulk_footer();
+ $this->skin->footer();
- // Connect to the Filesystem.
- $res = $this->fs_connect( array( WP_CONTENT_DIR, $destination ) );
- if ( ! $res ) {
- return false;
- }
+ // Return our results.
+ return $results;
- // Return early if there is an error connecting to the Filesystem.
- if ( is_wp_error( $res ) ) {
- $this->skin->error( $res );
- return $res;
}
- // Call $this->header separately if running multiple times.
- if ( ! $is_multi )
- $this->skin->header();
+ /**
+ * Performs the actual installation of each plugin.
+ *
+ * This method also activates the plugin in the automatic flag has been
+ * set to true for the TGMPA class.
+ *
+ * @since 2.2.0
+ *
+ * @param array $options The installation config options
+ * @return null/array Return early if error, array of installation data on success
+ */
+ public function run( $options ) {
+
+ // Default config options.
+ $defaults = array(
+ 'package' => '',
+ 'destination' => '',
+ 'clear_destination' => false,
+ 'clear_working' => true,
+ 'is_multi' => false,
+ 'hook_extra' => array(),
+ );
- // Set strings before the package is installed.
- $this->skin->before();
+ // Parse default options with config options from $this->bulk_upgrade and extract them.
+ $options = wp_parse_args( $options, $defaults );
+ extract( $options );
- // Download the package (this just returns the filename of the file if the package is a local file).
- $download = $this->download_package( $package );
- if ( is_wp_error( $download ) ) {
- $this->skin->error( $download );
- $this->skin->after();
- return $download;
- }
+ // Connect to the Filesystem.
+ $res = $this->fs_connect( array( WP_CONTENT_DIR, $destination ) );
+ if ( ! $res ) {
+ return false;
+ }
- // Don't accidentally delete a local file.
- $delete_package = ( $download != $package );
+ // Return early if there is an error connecting to the Filesystem.
+ if ( is_wp_error( $res ) ) {
+ $this->skin->error( $res );
+ return $res;
+ }
- // Unzip file into a temporary working directory.
- $working_dir = $this->unpack_package( $download, $delete_package );
- if ( is_wp_error( $working_dir ) ) {
- $this->skin->error( $working_dir );
- $this->skin->after();
- return $working_dir;
- }
+ // Call $this->header separately if running multiple times.
+ if ( ! $is_multi )
+ $this->skin->header();
- // Install the package into the working directory with all passed config options.
- $result = $this->install_package(
- array(
- 'source' => $working_dir,
- 'destination' => $destination,
- 'clear_destination' => $clear_destination,
- 'clear_working' => $clear_working,
- 'hook_extra' => $hook_extra,
- )
- );
+ // Set strings before the package is installed.
+ $this->skin->before();
- // Pass the result of the installation.
- $this->skin->set_result( $result );
+ // Download the package (this just returns the filename of the file if the package is a local file).
+ $download = $this->download_package( $package );
+ if ( is_wp_error( $download ) ) {
+ $this->skin->error( $download );
+ $this->skin->after();
+ return $download;
+ }
- // Set correct strings based on results.
- if ( is_wp_error( $result ) ) {
- $this->skin->error( $result );
- $this->skin->feedback( 'process_failed' );
- }
- // The plugin install is successful.
- else {
- $this->skin->feedback( 'process_success' );
- }
+ // Don't accidentally delete a local file.
+ $delete_package = ( $download != $package );
- // Only process the activation of installed plugins if the automatic flag is set to true.
- if ( TGM_Plugin_Activation::$instance->is_automatic ) {
- // Flush plugins cache so we can make sure that the installed plugins list is always up to date.
- wp_cache_flush();
+ // Unzip file into a temporary working directory.
+ $working_dir = $this->unpack_package( $download, $delete_package );
+ if ( is_wp_error( $working_dir ) ) {
+ $this->skin->error( $working_dir );
+ $this->skin->after();
+ return $working_dir;
+ }
- // Get the installed plugin file and activate it.
- $plugin_info = $this->plugin_info( $package );
- $activate = activate_plugin( $plugin_info );
+ // Install the package into the working directory with all passed config options.
+ $result = $this->install_package(
+ array(
+ 'source' => $working_dir,
+ 'destination' => $destination,
+ 'clear_destination' => $clear_destination,
+ 'clear_working' => $clear_working,
+ 'hook_extra' => $hook_extra,
+ )
+ );
- // Re-populate the file path now that the plugin has been installed and activated.
- TGM_Plugin_Activation::$instance->populate_file_path();
+ // Pass the result of the installation.
+ $this->skin->set_result( $result );
// Set correct strings based on results.
- if ( is_wp_error( $activate ) ) {
- $this->skin->error( $activate );
- $this->skin->feedback( 'activation_failed' );
+ if ( is_wp_error( $result ) ) {
+ $this->skin->error( $result );
+ $this->skin->feedback( 'process_failed' );
}
- // The plugin activation is successful.
+ // The plugin install is successful.
else {
- $this->skin->feedback( 'activation_success' );
+ $this->skin->feedback( 'process_success' );
}
- }
- // Flush plugins cache so we can make sure that the installed plugins list is always up to date.
- wp_cache_flush();
-
- // Set install footer strings.
- $this->skin->after();
- if ( ! $is_multi ) {
- $this->skin->footer();
- }
+ // Only process the activation of installed plugins if the automatic flag is set to true.
+ if ( TGM_Plugin_Activation::$instance->is_automatic ) {
+ // Flush plugins cache so we can make sure that the installed plugins list is always up to date.
+ wp_cache_flush();
- return $result;
+ // Get the installed plugin file and activate it.
+ $plugin_info = $this->plugin_info( $package );
+ $activate = activate_plugin( $plugin_info );
- }
+ // Re-populate the file path now that the plugin has been installed and activated.
+ TGM_Plugin_Activation::$instance->populate_file_path();
- /**
- * Sets the correct install strings for the installer skin to use.
- *
- * @since 2.2.0
- */
- public function install_strings() {
+ // Set correct strings based on results.
+ if ( is_wp_error( $activate ) ) {
+ $this->skin->error( $activate );
+ $this->skin->feedback( 'activation_failed' );
+ }
+ // The plugin activation is successful.
+ else {
+ $this->skin->feedback( 'activation_success' );
+ }
+ }
- $this->strings['no_package'] = __( 'Install package not available.', 'tgmpa' );
- $this->strings['downloading_package'] = __( 'Downloading install package from <span class="code">%s</span>&#8230;', 'tgmpa' );
- $this->strings['unpack_package'] = __( 'Unpacking the package&#8230;', 'tgmpa' );
- $this->strings['installing_package'] = __( 'Installing the plugin&#8230;', 'tgmpa' );
- $this->strings['process_failed'] = __( 'Plugin install failed.', 'tgmpa' );
- $this->strings['process_success'] = __( 'Plugin installed successfully.', 'tgmpa' );
+ // Flush plugins cache so we can make sure that the installed plugins list is always up to date.
+ wp_cache_flush();
- }
+ // Set install footer strings.
+ $this->skin->after();
+ if ( ! $is_multi ) {
+ $this->skin->footer();
+ }
- /**
- * Sets the correct activation strings for the installer skin to use.
- *
- * @since 2.2.0
- */
- public function activate_strings() {
+ return $result;
- $this->strings['activation_failed'] = __( 'Plugin activation failed.', 'tgmpa' );
- $this->strings['activation_success'] = __( 'Plugin activated successfully.', 'tgmpa' );
+ }
- }
+ /**
+ * Sets the correct install strings for the installer skin to use.
+ *
+ * @since 2.2.0
+ */
+ public function install_strings() {
- /**
- * Grabs the plugin file from an installed plugin.
- *
- * @since 2.2.0
- *
- * @return string|boolean Return plugin file on success, false on failure
- */
- public function plugin_info() {
+ $this->strings['no_package'] = __( 'Install package not available.', 'tgmpa' );
+ $this->strings['downloading_package'] = __( 'Downloading install package from <span class="code">%s</span>&#8230;', 'tgmpa' );
+ $this->strings['unpack_package'] = __( 'Unpacking the package&#8230;', 'tgmpa' );
+ $this->strings['installing_package'] = __( 'Installing the plugin&#8230;', 'tgmpa' );
+ $this->strings['process_failed'] = __( 'Plugin install failed.', 'tgmpa' );
+ $this->strings['process_success'] = __( 'Plugin installed successfully.', 'tgmpa' );
- // Return false if installation result isn't an array or the destination name isn't set.
- if ( ! is_array( $this->result ) ) {
- return false;
}
- if ( empty( $this->result['destination_name'] ) ) {
- return false;
- }
+ /**
+ * Sets the correct activation strings for the installer skin to use.
+ *
+ * @since 2.2.0
+ */
+ public function activate_strings() {
+
+ $this->strings['activation_failed'] = __( 'Plugin activation failed.', 'tgmpa' );
+ $this->strings['activation_success'] = __( 'Plugin activated successfully.', 'tgmpa' );
- /// Get the installed plugin file or return false if it isn't set.
- $plugin = get_plugins( '/' . $this->result['destination_name'] );
- if ( empty( $plugin ) ) {
- return false;
}
- // Assume the requested plugin is the first in the list.
- $pluginfiles = array_keys( $plugin );
+ /**
+ * Grabs the plugin file from an installed plugin.
+ *
+ * @since 2.2.0
+ *
+ * @return string|boolean Return plugin file on success, false on failure
+ */
+ public function plugin_info() {
+
+ // Return false if installation result isn't an array or the destination name isn't set.
+ if ( ! is_array( $this->result ) ) {
+ return false;
+ }
- return $this->result['destination_name'] . '/' . $pluginfiles[0];
+ if ( empty( $this->result['destination_name'] ) ) {
+ return false;
+ }
- }
+ /// Get the installed plugin file or return false if it isn't set.
+ $plugin = get_plugins( '/' . $this->result['destination_name'] );
+ if ( empty( $plugin ) ) {
+ return false;
+ }
- }
- }
+ // Assume the requested plugin is the first in the list.
+ $pluginfiles = array_keys( $plugin );
- if ( ! class_exists( 'TGM_Bulk_Installer_Skin' ) ) {
- /**
- * Installer skin to set strings for the bulk plugin installations..
- *
- * Extends Bulk_Upgrader_Skin and customizes to suit the installation of multiple
- * plugins.
- *
- * @since 2.2.0
- *
- * @package TGM-Plugin-Activation
- * @author Thomas Griffin <thomasgriffinmedia.com>
- * @author Gary Jones <gamajo.com>
- */
- class TGM_Bulk_Installer_Skin extends Bulk_Upgrader_Skin {
+ return $this->result['destination_name'] . '/' . $pluginfiles[0];
- /**
- * Holds plugin info for each individual plugin installation.
- *
- * @since 2.2.0
- *
- * @var array
- */
- public $plugin_info = array();
+ }
- /**
- * Holds names of plugins that are undergoing bulk installations.
- *
- * @since 2.2.0
- *
- * @var array
- */
- public $plugin_names = array();
+ }
+ }
+ if ( ! class_exists( 'TGM_Bulk_Installer_Skin' ) ) {
/**
- * Integer to use for iteration through each plugin installation.
+ * Installer skin to set strings for the bulk plugin installations..
*
- * @since 2.2.0
- *
- * @var integer
- */
- public $i = 0;
-
- /**
- * Constructor. Parses default args with new ones and extracts them for use.
+ * Extends Bulk_Upgrader_Skin and customizes to suit the installation of multiple
+ * plugins.
*
* @since 2.2.0
*
- * @param array $args Arguments to pass for use within the class.
+ * @package TGM-Plugin-Activation
+ * @author Thomas Griffin <thomasgriffinmedia.com>
+ * @author Gary Jones <gamajo.com>
*/
- public function __construct( $args = array() ) {
-
- // Parse default and new args.
- $defaults = array( 'url' => '', 'nonce' => '', 'names' => array() );
- $args = wp_parse_args( $args, $defaults );
-
- // Set plugin names to $this->plugin_names property.
- $this->plugin_names = $args['names'];
+ class TGM_Bulk_Installer_Skin extends Bulk_Upgrader_Skin {
+
+ /**
+ * Holds plugin info for each individual plugin installation.
+ *
+ * @since 2.2.0
+ *
+ * @var array
+ */
+ public $plugin_info = array();
+
+ /**
+ * Holds names of plugins that are undergoing bulk installations.
+ *
+ * @since 2.2.0
+ *
+ * @var array
+ */
+ public $plugin_names = array();
+
+ /**
+ * Integer to use for iteration through each plugin installation.
+ *
+ * @since 2.2.0
+ *
+ * @var integer
+ */
+ public $i = 0;
+
+ /**
+ * Constructor. Parses default args with new ones and extracts them for use.
+ *
+ * @since 2.2.0
+ *
+ * @param array $args Arguments to pass for use within the class.
+ */
+ public function __construct( $args = array() ) {
+
+ // Parse default and new args.
+ $defaults = array( 'url' => '', 'nonce' => '', 'names' => array() );
+ $args = wp_parse_args( $args, $defaults );
+
+ // Set plugin names to $this->plugin_names property.
+ $this->plugin_names = $args['names'];
+
+ // Extract the new args.
+ parent::__construct( $args );
- // Extract the new args.
- parent::__construct( $args );
+ }
- }
+ /**
+ * Sets install skin strings for each individual plugin.
+ *
+ * Checks to see if the automatic activation flag is set and uses the
+ * the proper strings accordingly.
+ *
+ * @since 2.2.0
+ */
+ public function add_strings() {
+
+ // Automatic activation strings.
+ if ( TGM_Plugin_Activation::$instance->is_automatic ) {
+ $this->upgrader->strings['skin_upgrade_start'] = __( 'The installation and activation process is starting. This process may take a while on some hosts, so please be patient.', 'tgmpa' );
+ $this->upgrader->strings['skin_update_successful'] = __( '%1$s installed and activated successfully.', 'tgmpa' ) . ' <a onclick="%2$s" href="#" class="hide-if-no-js"><span>' . __( 'Show Details', 'tgmpa' ) . '</span><span class="hidden">' . __( 'Hide Details', 'tgmpa' ) . '</span>.</a>';
+ $this->upgrader->strings['skin_upgrade_end'] = __( 'All installations and activations have been completed.', 'tgmpa' );
+ $this->upgrader->strings['skin_before_update_header'] = __( 'Installing and Activating Plugin %1$s (%2$d/%3$d)', 'tgmpa' );
+ }
+ // Default installation strings.
+ else {
+ $this->upgrader->strings['skin_upgrade_start'] = __( 'The installation process is starting. This process may take a while on some hosts, so please be patient.', 'tgmpa' );
+ $this->upgrader->strings['skin_update_failed_error'] = __( 'An error occurred while installing %1$s: <strong>%2$s</strong>.', 'tgmpa' );
+ $this->upgrader->strings['skin_update_failed'] = __( 'The installation of %1$s failed.', 'tgmpa' );
+ $this->upgrader->strings['skin_update_successful'] = __( '%1$s installed successfully.', 'tgmpa' ) . ' <a onclick="%2$s" href="#" class="hide-if-no-js"><span>' . __( 'Show Details', 'tgmpa' ) . '</span><span class="hidden">' . __( 'Hide Details', 'tgmpa' ) . '</span>.</a>';
+ $this->upgrader->strings['skin_upgrade_end'] = __( 'All installations have been completed.', 'tgmpa' );
+ $this->upgrader->strings['skin_before_update_header'] = __( 'Installing Plugin %1$s (%2$d/%3$d)', 'tgmpa' );
+ }
- /**
- * Sets install skin strings for each individual plugin.
- *
- * Checks to see if the automatic activation flag is set and uses the
- * the proper strings accordingly.
- *
- * @since 2.2.0
- */
- public function add_strings() {
-
- // Automatic activation strings.
- if ( TGM_Plugin_Activation::$instance->is_automatic ) {
- $this->upgrader->strings['skin_upgrade_start'] = __( 'The installation and activation process is starting. This process may take a while on some hosts, so please be patient.', 'tgmpa' );
- $this->upgrader->strings['skin_update_successful'] = __( '%1$s installed and activated successfully.', 'tgmpa' ) . ' <a onclick="%2$s" href="#" class="hide-if-no-js"><span>' . __( 'Show Details', 'tgmpa' ) . '</span><span class="hidden">' . __( 'Hide Details', 'tgmpa' ) . '</span>.</a>';
- $this->upgrader->strings['skin_upgrade_end'] = __( 'All installations and activations have been completed.', 'tgmpa' );
- $this->upgrader->strings['skin_before_update_header'] = __( 'Installing and Activating Plugin %1$s (%2$d/%3$d)', 'tgmpa' );
}
- // Default installation strings.
- else {
- $this->upgrader->strings['skin_upgrade_start'] = __( 'The installation process is starting. This process may take a while on some hosts, so please be patient.', 'tgmpa' );
- $this->upgrader->strings['skin_update_failed_error'] = __( 'An error occurred while installing %1$s: <strong>%2$s</strong>.', 'tgmpa' );
- $this->upgrader->strings['skin_update_failed'] = __( 'The installation of %1$s failed.', 'tgmpa' );
- $this->upgrader->strings['skin_update_successful'] = __( '%1$s installed successfully.', 'tgmpa' ) . ' <a onclick="%2$s" href="#" class="hide-if-no-js"><span>' . __( 'Show Details', 'tgmpa' ) . '</span><span class="hidden">' . __( 'Hide Details', 'tgmpa' ) . '</span>.</a>';
- $this->upgrader->strings['skin_upgrade_end'] = __( 'All installations have been completed.', 'tgmpa' );
- $this->upgrader->strings['skin_before_update_header'] = __( 'Installing Plugin %1$s (%2$d/%3$d)', 'tgmpa' );
- }
-
- }
- /**
- * Outputs the header strings and necessary JS before each plugin installation.
- *
- * @since 2.2.0
- */
- public function before( $title = '' ) {
+ /**
+ * Outputs the header strings and necessary JS before each plugin installation.
+ *
+ * @since 2.2.0
+ */
+ public function before( $title = '' ) {
- // We are currently in the plugin installation loop, so set to true.
- $this->in_loop = true;
+ // We are currently in the plugin installation loop, so set to true.
+ $this->in_loop = true;
- printf( '<h4>' . $this->upgrader->strings['skin_before_update_header'] . ' <img alt="" src="' . admin_url( 'images/wpspin_light.gif' ) . '" class="hidden waiting-' . $this->upgrader->update_current . '" style="vertical-align:middle;" /></h4>', $this->plugin_names[$this->i], $this->upgrader->update_current, $this->upgrader->update_count );
- echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js( $this->upgrader->update_current ) . '\').show();</script>';
- echo '<div class="update-messages hide-if-js" id="progress-' . esc_attr( $this->upgrader->update_current ) . '"><p>';
+ printf( '<h4>' . $this->upgrader->strings['skin_before_update_header'] . ' <img alt="" src="' . admin_url( 'images/wpspin_light.gif' ) . '" class="hidden waiting-' . $this->upgrader->update_current . '" style="vertical-align:middle;" /></h4>', $this->plugin_names[$this->i], $this->upgrader->update_current, $this->upgrader->update_count );
+ echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js( $this->upgrader->update_current ) . '\').show();</script>';
+ echo '<div class="update-messages hide-if-js" id="progress-' . esc_attr( $this->upgrader->update_current ) . '"><p>';
- // Flush header output buffer.
- $this->before_flush_output();
+ // Flush header output buffer.
+ $this->before_flush_output();
- }
+ }
- /**
- * Outputs the footer strings and necessary JS after each plugin installation.
- *
- * Checks for any errors and outputs them if they exist, else output
- * success strings.
- *
- * @since 2.2.0
- */
- public function after( $title = '' ) {
+ /**
+ * Outputs the footer strings and necessary JS after each plugin installation.
+ *
+ * Checks for any errors and outputs them if they exist, else output
+ * success strings.
+ *
+ * @since 2.2.0
+ */
+ public function after( $title = '' ) {
+
+ // Close install strings.
+ echo '</p></div>';
+
+ // Output error strings if an error has occurred.
+ if ( $this->error || ! $this->result ) {
+ if ( $this->error ) {
+ echo '<div class="error"><p>' . sprintf( $this->upgrader->strings['skin_update_failed_error'], $this->plugin_names[$this->i], $this->error ) . '</p></div>';
+ } else {
+ echo '<div class="error"><p>' . sprintf( $this->upgrader->strings['skin_update_failed'], $this->plugin_names[$this->i] ) . '</p></div>';
+ }
- // Close install strings.
- echo '</p></div>';
+ echo '<script type="text/javascript">jQuery(\'#progress-' . esc_js( $this->upgrader->update_current ) . '\').show();</script>';
+ }
- // Output error strings if an error has occurred.
- if ( $this->error || ! $this->result ) {
- if ( $this->error ) {
- echo '<div class="error"><p>' . sprintf( $this->upgrader->strings['skin_update_failed_error'], $this->plugin_names[$this->i], $this->error ) . '</p></div>';
- } else {
- echo '<div class="error"><p>' . sprintf( $this->upgrader->strings['skin_update_failed'], $this->plugin_names[$this->i] ) . '</p></div>';
+ // If the result is set and there are no errors, success!
+ if ( ! empty( $this->result ) && ! is_wp_error( $this->result ) ) {
+ echo '<div class="updated"><p>' . sprintf( $this->upgrader->strings['skin_update_successful'], $this->plugin_names[$this->i], 'jQuery(\'#progress-' . esc_js( $this->upgrader->update_current ) . '\').toggle();jQuery(\'span\', this).toggle(); return false;' ) . '</p></div>';
+ echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js( $this->upgrader->update_current ) . '\').hide();</script>';
}
- echo '<script type="text/javascript">jQuery(\'#progress-' . esc_js( $this->upgrader->update_current ) . '\').show();</script>';
- }
+ // Set in_loop and error to false and flush footer output buffer.
+ $this->reset();
+ $this->after_flush_output();
- // If the result is set and there are no errors, success!
- if ( ! empty( $this->result ) && ! is_wp_error( $this->result ) ) {
- echo '<div class="updated"><p>' . sprintf( $this->upgrader->strings['skin_update_successful'], $this->plugin_names[$this->i], 'jQuery(\'#progress-' . esc_js( $this->upgrader->update_current ) . '\').toggle();jQuery(\'span\', this).toggle(); return false;' ) . '</p></div>';
- echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js( $this->upgrader->update_current ) . '\').hide();</script>';
}
- // Set in_loop and error to false and flush footer output buffer.
- $this->reset();
- $this->after_flush_output();
+ /**
+ * Outputs links after bulk plugin installation is complete.
+ *
+ * @since 2.2.0
+ */
+ public function bulk_footer() {
- }
+ // Serve up the string to say installations (and possibly activations) are complete.
+ parent::bulk_footer();
- /**
- * Outputs links after bulk plugin installation is complete.
- *
- * @since 2.2.0
- */
- public function bulk_footer() {
+ // Flush plugins cache so we can make sure that the installed plugins list is always up to date.
+ wp_cache_flush();
- // Serve up the string to say installations (and possibly activations) are complete.
- parent::bulk_footer();
+ // Display message based on if all plugins are now active or not.
+ $complete = array();
+ foreach ( TGM_Plugin_Activation::$instance->plugins as $plugin ) {
+ if ( ! is_plugin_active( $plugin['file_path'] ) ) {
+ echo '<p><a href="' . add_query_arg( 'page', TGM_Plugin_Activation::$instance->menu, admin_url( 'themes.php' ) ) . '" title="' . esc_attr( TGM_Plugin_Activation::$instance->strings['return'] ) . '" target="_parent">' . TGM_Plugin_Activation::$instance->strings['return'] . '</a></p>';
+ $complete[] = $plugin;
+ break;
+ }
+ // Nothing to store.
+ else {
+ $complete[] = '';
+ }
+ }
- // Flush plugins cache so we can make sure that the installed plugins list is always up to date.
- wp_cache_flush();
+ // Filter out any empty entries.
+ $complete = array_filter( $complete );
- // Display message based on if all plugins are now active or not.
- $complete = array();
- foreach ( TGM_Plugin_Activation::$instance->plugins as $plugin ) {
- if ( ! is_plugin_active( $plugin['file_path'] ) ) {
- echo '<p><a href="' . add_query_arg( 'page', TGM_Plugin_Activation::$instance->menu, admin_url( 'themes.php' ) ) . '" title="' . esc_attr( TGM_Plugin_Activation::$instance->strings['return'] ) . '" target="_parent">' . TGM_Plugin_Activation::$instance->strings['return'] . '</a></p>';
- $complete[] = $plugin;
- break;
+ // All plugins are active, so we display the complete string and hide the menu to protect users.
+ if ( empty( $complete ) ) {
+ echo '<p>' . sprintf( TGM_Plugin_Activation::$instance->strings['complete'], '<a href="' . admin_url() . '" title="' . __( 'Return to the Dashboard', 'tgmpa' ) . '">' . __( 'Return to the Dashboard', 'tgmpa' ) . '</a>' ) . '</p>';
+ echo '<style type="text/css">#adminmenu .wp-submenu li.current { display: none !important; }</style>';
}
- // Nothing to store.
- else {
- $complete[] = '';
- }
- }
- // Filter out any empty entries.
- $complete = array_filter( $complete );
-
- // All plugins are active, so we display the complete string and hide the menu to protect users.
- if ( empty( $complete ) ) {
- echo '<p>' . sprintf( TGM_Plugin_Activation::$instance->strings['complete'], '<a href="' . admin_url() . '" title="' . __( 'Return to the Dashboard', 'tgmpa' ) . '">' . __( 'Return to the Dashboard', 'tgmpa' ) . '</a>' ) . '</p>';
- echo '<style type="text/css">#adminmenu .wp-submenu li.current { display: none !important; }</style>';
}
- }
+ /**
+ * Flush header output buffer.
+ *
+ * @since 2.2.0
+ */
+ public function before_flush_output() {
- /**
- * Flush header output buffer.
- *
- * @since 2.2.0
- */
- public function before_flush_output() {
+ wp_ob_end_flush_all();
+ flush();
- wp_ob_end_flush_all();
- flush();
+ }
- }
+ /**
+ * Flush footer output buffer and iterate $this->i to make sure the
+ * installation strings reference the correct plugin.
+ *
+ * @since 2.2.0
+ */
+ public function after_flush_output() {
- /**
- * Flush footer output buffer and iterate $this->i to make sure the
- * installation strings reference the correct plugin.
- *
- * @since 2.2.0
- */
- public function after_flush_output() {
+ wp_ob_end_flush_all();
+ flush();
+ $this->i++;
- wp_ob_end_flush_all();
- flush();
- $this->i++;
+ }
}
-
}
}
- }
+ }
}
Something went wrong with that request. Please try again.