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+.

Defined (1)

The class is defined in the following location(s).

/includes/class-tgm-plugin-activation.php  
  1. class TGM_Bulk_Installer_Skin extends Bulk_Upgrader_Skin { 
  2.  
  3. /** 
  4. * Holds plugin info for each individual plugin installation. 
  5. * @since 2.2.0 
  6. * @var array 
  7. */ 
  8. public $plugin_info = array(); 
  9.  
  10. /** 
  11. * Holds names of plugins that are undergoing bulk installations. 
  12. * @since 2.2.0 
  13. * @var array 
  14. */ 
  15. public $plugin_names = array(); 
  16.  
  17. /** 
  18. * Integer to use for iteration through each plugin installation. 
  19. * @since 2.2.0 
  20. * @var integer 
  21. */ 
  22. public $i = 0; 
  23.  
  24. /** 
  25. * Constructor. Parses default args with new ones and extracts them for use. 
  26. * @since 2.2.0 
  27. * @param array $args Arguments to pass for use within the class 
  28. */ 
  29. public function __construct( $args = array() ) { 
  30.  
  31. /** Parse default and new args */ 
  32. $defaults = array( 'url' => '', 'nonce' => '', 'names' => array() ); 
  33. $args = wp_parse_args( $args, $defaults ); 
  34.  
  35. /** Set plugin names to $this->plugin_names property */ 
  36. $this->plugin_names = $args['names']; 
  37.  
  38. /** Extract the new args */ 
  39. parent::__construct( $args ); 
  40.  
  41.  
  42. /** 
  43. * Sets install skin strings for each individual plugin. 
  44. * Checks to see if the automatic activation flag is set and uses the 
  45. * the proper strings accordingly. 
  46. * @since 2.2.0 
  47. */ 
  48. public function add_strings() { 
  49.  
  50. /** Automatic activation strings */ 
  51. if ( TGM_Plugin_Activation::$instance->is_automatic ) { 
  52. $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.', TGM_Plugin_Activation::$instance->domain ); 
  53. $this->upgrader->strings['skin_update_successful'] = __( '%1$s installed and activated successfully.', TGM_Plugin_Activation::$instance->domain ) . ' <a onclick="%2$s" href="#" class="hide-if-no-js"><span>' . __( 'Show Details', TGM_Plugin_Activation::$instance->domain ) . '</span><span class="hidden">' . __( 'Hide Details', TGM_Plugin_Activation::$instance->domain ) . '</span>.</a>'; 
  54. $this->upgrader->strings['skin_upgrade_end'] = __( 'All installations and activations have been completed.', TGM_Plugin_Activation::$instance->domain ); 
  55. $this->upgrader->strings['skin_before_update_header'] = __( 'Installing and Activating Plugin %1$s (%2$d/%3$d)', TGM_Plugin_Activation::$instance->domain ); 
  56. /** Default installation strings */ 
  57. else { 
  58. $this->upgrader->strings['skin_upgrade_start'] = __( 'The installation process is starting. This process may take a while on some hosts, so please be patient.', TGM_Plugin_Activation::$instance->domain ); 
  59. $this->upgrader->strings['skin_update_failed_error'] = __( 'An error occurred while installing %1$s: <strong>%2$s</strong>.', TGM_Plugin_Activation::$instance->domain ); 
  60. $this->upgrader->strings['skin_update_failed'] = __( 'The installation of %1$s failed.', TGM_Plugin_Activation::$instance->domain ); 
  61. $this->upgrader->strings['skin_update_successful'] = __( '%1$s installed successfully.', TGM_Plugin_Activation::$instance->domain ) . ' <a onclick="%2$s" href="#" class="hide-if-no-js"><span>' . __( 'Show Details', TGM_Plugin_Activation::$instance->domain ) . '</span><span class="hidden">' . __( 'Hide Details', TGM_Plugin_Activation::$instance->domain ) . '</span>.</a>'; 
  62. $this->upgrader->strings['skin_upgrade_end'] = __( 'All installations have been completed.', TGM_Plugin_Activation::$instance->domain ); 
  63. $this->upgrader->strings['skin_before_update_header'] = __( 'Installing Plugin %1$s (%2$d/%3$d)', TGM_Plugin_Activation::$instance->domain ); 
  64.  
  65.  
  66. /** 
  67. * Outputs the header strings and necessary JS before each plugin installation. 
  68. * @since 2.2.0 
  69. */ 
  70. public function before() { 
  71.  
  72. /** We are currently in the plugin installation loop, so set to true */ 
  73. $this->in_loop = true; 
  74.  
  75. 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 ); 
  76. echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js( $this->upgrader->update_current ) . '\').show();</script>'; 
  77. echo '<div class="update-messages hide-if-js" id="progress-' . esc_attr( $this->upgrader->update_current ) . '"><p>'; 
  78.  
  79. /** Flush header output buffer */ 
  80. $this->before_flush_output(); 
  81.  
  82.  
  83. /** 
  84. * Outputs the footer strings and necessary JS after each plugin installation. 
  85. * Checks for any errors and outputs them if they exist, else output 
  86. * success strings. 
  87. * @since 2.2.0 
  88. */ 
  89. public function after() { 
  90.  
  91. /** Close install strings */ 
  92. echo '</p></div>'; 
  93.  
  94. /** Output error strings if an error has occurred */ 
  95. if ( $this->error || ! $this->result ) { 
  96. if ( $this->error ) 
  97. echo '<div class="error"><p>' . sprintf( $this->upgrader->strings['skin_update_failed_error'], $this->plugin_names[$this->i], $this->error ) . '</p></div>'; 
  98. else 
  99. echo '<div class="error"><p>' . sprintf( $this->upgrader->strings['skin_update_failed'], $this->plugin_names[$this->i] ) . '</p></div>'; 
  100.  
  101. echo '<script type="text/javascript">jQuery(\'#progress-' . esc_js( $this->upgrader->update_current ) . '\').show();</script>'; 
  102.  
  103. /** If the result is set and there are no errors, success! */ 
  104. if ( ! empty( $this->result ) && ! is_wp_error( $this->result ) ) { 
  105. 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>'; 
  106. echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js( $this->upgrader->update_current ) . '\').hide();</script>'; 
  107.  
  108. /** Set in_loop and error to false and flush footer output buffer */ 
  109. $this->reset(); 
  110. $this->after_flush_output(); 
  111.  
  112.  
  113. /** 
  114. * Outputs links after bulk plugin installation is complete. 
  115. * @since 2.2.0 
  116. */ 
  117. public function bulk_footer() { 
  118.  
  119. /** Serve up the string to say installations (and possibly activations) are complete */ 
  120. parent::bulk_footer(); 
  121.  
  122. /** Flush plugins cache so we can make sure that the installed plugins list is always up to date */ 
  123. wp_cache_flush(); 
  124.  
  125. /** Display message based on if all plugins are now active or not */ 
  126. $complete = array(); 
  127. foreach ( TGM_Plugin_Activation::$instance->plugins as $plugin ) { 
  128. if ( ! is_plugin_active( $plugin['file_path'] ) ) { 
  129. echo '<p><a href="' . add_query_arg( 'page', TGM_Plugin_Activation::$instance->menu, admin_url( TGM_Plugin_Activation::$instance->parent_url_slug ) ) . '" title="' . esc_attr( TGM_Plugin_Activation::$instance->strings['return'] ) . '" target="_parent">' . __( TGM_Plugin_Activation::$instance->strings['return'], TGM_Plugin_Activation::$instance->domain ) . '</a></p>'; 
  130. $complete[] = $plugin; 
  131. break; 
  132. /** Nothing to store */ 
  133. else { 
  134. $complete[] = ''; 
  135.  
  136. /** Filter out any empty entries */ 
  137. $complete = array_filter( $complete ); 
  138.  
  139. /** All plugins are active, so we display the complete string and hide the menu to protect users */ 
  140. if ( empty( $complete ) ) { 
  141. echo '<p>' . sprintf( TGM_Plugin_Activation::$instance->strings['complete'], '<a href="' . admin_url() . '" title="' . __( 'Return to the Dashboard', TGM_Plugin_Activation::$instance->domain ) . '">' . __( 'Return to the Dashboard', TGM_Plugin_Activation::$instance->domain ) . '</a>' ) . '</p>'; 
  142. echo '<style type="text/css">#adminmenu .wp-submenu li.current { display: none !important; }</style>'; 
  143.  
  144.  
  145. /** 
  146. * Flush header output buffer. 
  147. * @since 2.2.0 
  148. */ 
  149. public function before_flush_output() { 
  150.  
  151. wp_ob_end_flush_all(); 
  152. flush(); 
  153.  
  154.  
  155. /** 
  156. * Flush footer output buffer and iterate $this->i to make sure the 
  157. * installation strings reference the correct plugin. 
  158. * @since 2.2.0 
  159. */ 
  160. public function after_flush_output() { 
  161.  
  162. wp_ob_end_flush_all(); 
  163. flush(); 
  164. $this->i++; 
  165.  
  166.