Bulk_Upgrader_Skin

Generic Bulk Upgrader Skin for WordPress Upgrades.

Defined (1)

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

/wp-admin/includes/class-bulk-upgrader-skin.php  
  1. class Bulk_Upgrader_Skin extends WP_Upgrader_Skin { 
  2. public $in_loop = false; 
  3. /** 
  4. * @var string|false 
  5. */ 
  6. public $error = false; 
  7.  
  8. /** 
  9. * @param array $args 
  10. */ 
  11. public function __construct($args = array()) { 
  12. $defaults = array( 'url' => '', 'nonce' => '' ); 
  13. $args = wp_parse_args($args, $defaults); 
  14.  
  15. parent::__construct($args); 
  16.  
  17. /** 
  18. * @access public 
  19. */ 
  20. public function add_strings() { 
  21. $this->upgrader->strings['skin_upgrade_start'] = __('The update process is starting. This process may take a while on some hosts, so please be patient.'); 
  22. /** translators: 1: Title of an update, 2: Error message */ 
  23. $this->upgrader->strings['skin_update_failed_error'] = __('An error occurred while updating %1$s: %2$s'); 
  24. /** translators: 1: Title of an update */ 
  25. $this->upgrader->strings['skin_update_failed'] = __('The update of %1$s failed.'); 
  26. /** translators: 1: Title of an update */ 
  27. $this->upgrader->strings['skin_update_successful'] = __( '%1$s updated successfully.' ) . ' <a onclick="%2$s" href="#" class="hide-if-no-js"><span>' . __( 'Show Details' ) . '</span><span class="hidden">' . __( 'Hide Details' ) . '</span></a>'; 
  28. $this->upgrader->strings['skin_upgrade_end'] = __('All updates have been completed.'); 
  29.  
  30. /** 
  31. * @param string $string 
  32. */ 
  33. public function feedback($string) { 
  34. if ( isset( $this->upgrader->strings[$string] ) ) 
  35. $string = $this->upgrader->strings[$string]; 
  36.  
  37. if ( strpos($string, '%') !== false ) { 
  38. $args = func_get_args(); 
  39. $args = array_splice($args, 1); 
  40. if ( $args ) { 
  41. $args = array_map( 'strip_tags', $args ); 
  42. $args = array_map( 'esc_html', $args ); 
  43. $string = vsprintf($string, $args); 
  44. if ( empty($string) ) 
  45. return; 
  46. if ( $this->in_loop ) 
  47. echo "$string<br />\n"; 
  48. else 
  49. echo "<p>$string</p>\n"; 
  50.  
  51. /** 
  52. * @access public 
  53. */ 
  54. public function header() { 
  55. // Nothing, This will be displayed within a iframe. 
  56.  
  57. /** 
  58. * @access public 
  59. */ 
  60. public function footer() { 
  61. // Nothing, This will be displayed within a iframe. 
  62.  
  63. /** 
  64. * @param string|WP_Error $error 
  65. */ 
  66. public function error($error) { 
  67. if ( is_string($error) && isset( $this->upgrader->strings[$error] ) ) 
  68. $this->error = $this->upgrader->strings[$error]; 
  69.  
  70. if ( is_wp_error($error) ) { 
  71. $messages = array(); 
  72. foreach ( $error->get_error_messages() as $emessage ) { 
  73. if ( $error->get_error_data() && is_string( $error->get_error_data() ) ) 
  74. $messages[] = $emessage . ' ' . esc_html( strip_tags( $error->get_error_data() ) ); 
  75. else 
  76. $messages[] = $emessage; 
  77. $this->error = implode(', ', $messages); 
  78. echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js($this->upgrader->update_current) . '\').hide();</script>'; 
  79.  
  80. /** 
  81. * @access public 
  82. */ 
  83. public function bulk_header() { 
  84. $this->feedback('skin_upgrade_start'); 
  85.  
  86. /** 
  87. * @access public 
  88. */ 
  89. public function bulk_footer() { 
  90. $this->feedback('skin_upgrade_end'); 
  91.  
  92. /** 
  93. * @param string $title 
  94. */ 
  95. public function before($title = '') { 
  96. $this->in_loop = true; 
  97. printf( '<h2>' . $this->upgrader->strings['skin_before_update_header'] . ' <span class="spinner waiting-' . $this->upgrader->update_current . '"></span></h2>', $title, $this->upgrader->update_current, $this->upgrader->update_count ); 
  98. echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js($this->upgrader->update_current) . '\').css("display", "inline-block");</script>'; 
  99. echo '<div class="update-messages hide-if-js" id="progress-' . esc_attr($this->upgrader->update_current) . '"><p>'; 
  100. $this->flush_output(); 
  101.  
  102. /** 
  103. * @param string $title 
  104. */ 
  105. public function after($title = '') { 
  106. echo '</p></div>'; 
  107. if ( $this->error || ! $this->result ) { 
  108. if ( $this->error ) { 
  109. echo '<div class="error"><p>' . sprintf($this->upgrader->strings['skin_update_failed_error'], $title, '<strong>' . $this->error . '</strong>' ) . '</p></div>'; 
  110. } else { 
  111. echo '<div class="error"><p>' . sprintf($this->upgrader->strings['skin_update_failed'], $title) . '</p></div>'; 
  112.  
  113. echo '<script type="text/javascript">jQuery(\'#progress-' . esc_js($this->upgrader->update_current) . '\').show();</script>'; 
  114. if ( $this->result && ! is_wp_error( $this->result ) ) { 
  115. if ( ! $this->error ) 
  116. echo '<div class="updated"><p>' . sprintf($this->upgrader->strings['skin_update_successful'], $title, 'jQuery(\'#progress-' . esc_js($this->upgrader->update_current) . '\').toggle();jQuery(\'span\', this).toggle(); return false;') . '</p></div>'; 
  117. echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js($this->upgrader->update_current) . '\').hide();</script>'; 
  118.  
  119. $this->reset(); 
  120. $this->flush_output(); 
  121.  
  122. /** 
  123. * @access public 
  124. */ 
  125. public function reset() { 
  126. $this->in_loop = false; 
  127. $this->error = false; 
  128.  
  129. /** 
  130. * @access public 
  131. */ 
  132. public function flush_output() { 
  133. wp_ob_end_flush_all(); 
  134. flush();