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