skin.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. /**
  3. * Skin class.
  4. *
  5. * @since 6.0.0
  6. *
  7. * @package MonsterInsights
  8. * @subpackage Upgrader Skin
  9. * @author Chris Christoff
  10. */
  11. // Exit if accessed directly
  12. if ( ! defined( 'ABSPATH' ) ) {
  13. exit;
  14. }
  15. class MonsterInsights_Skin extends WP_Upgrader_Skin {
  16. /**
  17. * Primary class constructor.
  18. *
  19. * @since 6.0.0
  20. *
  21. * @param array $args Empty array of args (we will use defaults).
  22. */
  23. public function __construct( $args = array() ) {
  24. parent::__construct();
  25. }
  26. /**
  27. * Set the upgrader object and store it as a property in the parent class.
  28. *
  29. * @since 6.0.0
  30. *
  31. * @param object $upgrader The upgrader object (passed by reference).
  32. */
  33. public function set_upgrader( &$upgrader ) {
  34. if ( is_object( $upgrader ) ) {
  35. $this->upgrader =& $upgrader;
  36. }
  37. }
  38. /**
  39. * Set the upgrader result and store it as a property in the parent class.
  40. *
  41. * @since 6.0.0
  42. *
  43. * @param object $result The result of the install process.
  44. */
  45. public function set_result( $result ) {
  46. $this->result = $result;
  47. }
  48. /**
  49. * Empty out the header of its HTML content and only check to see if it has
  50. * been performed or not.
  51. *
  52. * @since 6.0.0
  53. */
  54. public function header() {}
  55. /**
  56. * Empty out the footer of its HTML contents.
  57. *
  58. * @since 6.0.0
  59. */
  60. function footer() {}
  61. /**
  62. * Instead of outputting HTML for errors, json_encode the errors and send them
  63. * back to the Ajax script for processing.
  64. *
  65. * @since 6.0.0
  66. *
  67. * @param array $errors Array of errors with the install process.
  68. */
  69. function error( $errors ) {
  70. if ( ! empty( $errors ) ) {
  71. echo json_encode( array( 'error' => esc_html__( 'There was an error installing the addon. Please try again.', 'google-analytics-for-wordpress' ) ) );
  72. die;
  73. }
  74. }
  75. /**
  76. * Empty out the feedback method to prevent outputting HTML strings as the install
  77. * is progressing.
  78. *
  79. * @since 6.0.0
  80. *
  81. * @param string $string The feedback string.
  82. */
  83. function feedback( $string ) {
  84. }
  85. }