WP_Ajax_Upgrader_Skin

Upgrader Skin for Ajax WordPress upgrades.

Defined (1)

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

/wp-admin/includes/class-wp-ajax-upgrader-skin.php  
  1. class WP_Ajax_Upgrader_Skin extends Automatic_Upgrader_Skin { 
  2.  
  3. /** 
  4. * Holds the WP_Error object. 
  5. * @since 4.6.0 
  6. * @access protected 
  7. * @var null|WP_Error 
  8. */ 
  9. protected $errors = null; 
  10.  
  11. /** 
  12. * Constructor. 
  13. * @since 4.6.0 
  14. * @access public 
  15. * @param array $args Options for the upgrader, see WP_Upgrader_Skin::__construct(). 
  16. */ 
  17. public function __construct( $args = array() ) { 
  18. parent::__construct( $args ); 
  19.  
  20. $this->errors = new WP_Error(); 
  21.  
  22. /** 
  23. * Retrieves the list of errors. 
  24. * @since 4.6.0 
  25. * @access public 
  26. * @return WP_Error Errors during an upgrade. 
  27. */ 
  28. public function get_errors() { 
  29. return $this->errors; 
  30.  
  31. /** 
  32. * Retrieves a string for error messages. 
  33. * @since 4.6.0 
  34. * @access public 
  35. * @return string Error messages during an upgrade. 
  36. */ 
  37. public function get_error_messages() { 
  38. $messages = array(); 
  39.  
  40. foreach ( $this->errors->get_error_codes() as $error_code ) { 
  41. if ( $this->errors->get_error_data( $error_code ) && is_string( $this->errors->get_error_data( $error_code ) ) ) { 
  42. $messages[] = $this->errors->get_error_message( $error_code ) . ' ' . esc_html( strip_tags( $this->errors->get_error_data( $error_code ) ) ); 
  43. } else { 
  44. $messages[] = $this->errors->get_error_message( $error_code ); 
  45.  
  46. return implode( ', ', $messages ); 
  47.  
  48. /** 
  49. * Stores a log entry for an error. 
  50. * @since 4.6.0 
  51. * @access public 
  52. * @param string|WP_Error $errors Errors. 
  53. */ 
  54. public function error( $errors ) { 
  55. if ( is_string( $errors ) ) { 
  56. $string = $errors; 
  57. if ( ! empty( $this->upgrader->strings[ $string ] ) ) { 
  58. $string = $this->upgrader->strings[ $string ]; 
  59.  
  60. if ( false !== strpos( $string, '%' ) ) { 
  61. $args = func_get_args(); 
  62. $args = array_splice( $args, 1 ); 
  63. if ( ! empty( $args ) ) { 
  64. $string = vsprintf( $string, $args ); 
  65.  
  66. // Count existing errors to generate an unique error code. 
  67. $errors_count = count( $errors->get_error_codes() ); 
  68. $this->errors->add( 'unknown_upgrade_error_' . $errors_count + 1 , $string ); 
  69. } elseif ( is_wp_error( $errors ) ) { 
  70. foreach ( $errors->get_error_codes() as $error_code ) { 
  71. $this->errors->add( $error_code, $errors->get_error_message( $error_code ), $errors->get_error_data( $error_code ) ); 
  72.  
  73. $args = func_get_args(); 
  74. call_user_func_array( array( $this, 'parent::error' ), $args ); 
  75.  
  76. /** 
  77. * Stores a log entry. 
  78. * @since 4.6.0 
  79. * @access public 
  80. * @param string|array|WP_Error $data Log entry data. 
  81. */ 
  82. public function feedback( $data ) { 
  83. if ( is_wp_error( $data ) ) { 
  84. foreach ( $data->get_error_codes() as $error_code ) { 
  85. $this->errors->add( $error_code, $data->get_error_message( $error_code ), $data->get_error_data( $error_code ) ); 
  86.  
  87. $args = func_get_args(); 
  88. call_user_func_array( array( $this, 'parent::feedback' ), $args );