Automatic_Upgrader_Skin

Upgrader Skin for Automatic WordPress Upgrades.

Defined (1)

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

/wp-admin/includes/class-automatic-upgrader-skin.php  
  1. class Automatic_Upgrader_Skin extends WP_Upgrader_Skin { 
  2. protected $messages = array(); 
  3.  
  4. /** 
  5. * Determines whether the upgrader needs FTP/SSH details in order to connect 
  6. * to the filesystem. 
  7. * @since 3.7.0 
  8. * @since 4.6.0 The `$context` parameter default changed from `false` to an empty string. 
  9. * @see request_filesystem_credentials() 
  10. * @param bool $error Optional. Whether the current request has failed to connect. 
  11. * Default false. 
  12. * @param string $context Optional. Full path to the directory that is tested 
  13. * for being writable. Default empty. 
  14. * @param bool $allow_relaxed_file_ownership Optional. Whether to allow Group/World writable. Default false. 
  15. * @return bool True on success, false on failure. 
  16. */ 
  17. public function request_filesystem_credentials( $error = false, $context = '', $allow_relaxed_file_ownership = false ) { 
  18. if ( $context ) { 
  19. $this->options['context'] = $context; 
  20. // TODO: fix up request_filesystem_credentials(), or split it, to allow us to request a no-output version 
  21. // This will output a credentials form in event of failure, We don't want that, so just hide with a buffer 
  22. ob_start(); 
  23. $result = parent::request_filesystem_credentials( $error, $context, $allow_relaxed_file_ownership ); 
  24. ob_end_clean(); 
  25. return $result; 
  26.  
  27. /** 
  28. * @access public 
  29. * @return array 
  30. */ 
  31. public function get_upgrade_messages() { 
  32. return $this->messages; 
  33.  
  34. /** 
  35. * @param string|array|WP_Error $data 
  36. */ 
  37. public function feedback( $data ) { 
  38. if ( is_wp_error( $data ) ) { 
  39. $string = $data->get_error_message(); 
  40. } elseif ( is_array( $data ) ) { 
  41. return; 
  42. } else { 
  43. $string = $data; 
  44. if ( ! empty( $this->upgrader->strings[ $string ] ) ) 
  45. $string = $this->upgrader->strings[ $string ]; 
  46.  
  47. if ( strpos( $string, '%' ) !== false ) { 
  48. $args = func_get_args(); 
  49. $args = array_splice( $args, 1 ); 
  50. if ( ! empty( $args ) ) 
  51. $string = vsprintf( $string, $args ); 
  52.  
  53. $string = trim( $string ); 
  54.  
  55. // Only allow basic HTML in the messages, as it'll be used in emails/logs rather than direct browser output. 
  56. $string = wp_kses( $string, array( 
  57. 'a' => array( 
  58. 'href' => true 
  59. ),  
  60. 'br' => true,  
  61. 'em' => true,  
  62. 'strong' => true,  
  63. ) ); 
  64.  
  65. if ( empty( $string ) ) 
  66. return; 
  67.  
  68. $this->messages[] = $string; 
  69.  
  70. /** 
  71. * @access public 
  72. */ 
  73. public function header() { 
  74. ob_start(); 
  75.  
  76. /** 
  77. * @access public 
  78. */ 
  79. public function footer() { 
  80. $output = ob_get_clean(); 
  81. if ( ! empty( $output ) ) 
  82. $this->feedback( $output );