| 1 |
<?php |
| 2 |
/** |
| 3 |
* @since 3.04.02 |
| 4 |
* |
| 5 |
* @package Formidable |
| 6 |
* @subpackage Upgrader Skin |
| 7 |
*/ |
| 8 |
|
| 9 |
// Exit if accessed directly |
| 10 |
if ( ! defined( 'ABSPATH' ) ) { |
| 11 |
exit; |
| 12 |
} |
| 13 |
|
| 14 |
if ( ! class_exists( 'WP_Upgrader_Skin' ) ) { |
| 15 |
// this is to prevent a unit test from failing |
| 16 |
return; |
| 17 |
} |
| 18 |
|
| 19 |
class FrmInstallerSkin extends WP_Upgrader_Skin { |
| 20 |
|
| 21 |
/** |
| 22 |
* Set the upgrader object and store it as a property in the parent class. |
| 23 |
* |
| 24 |
* @since 3.04.02 |
| 25 |
* |
| 26 |
* @param object $upgrader The upgrader object (passed by reference). |
| 27 |
*/ |
| 28 |
public function set_upgrader( &$upgrader ) { |
| 29 |
if ( is_object( $upgrader ) ) { |
| 30 |
$this->upgrader =& $upgrader; |
| 31 |
} |
| 32 |
} |
| 33 |
|
| 34 |
/** |
| 35 |
* Set the upgrader result and store it as a property in the parent class. |
| 36 |
* |
| 37 |
* @since 3.04.02 |
| 38 |
* |
| 39 |
* @param object $result The result of the install process. |
| 40 |
*/ |
| 41 |
public function set_result( $result ) { |
| 42 |
$this->result = $result; |
| 43 |
} |
| 44 |
|
| 45 |
/** |
| 46 |
* Empty out the header of its HTML content and only check to see if it has |
| 47 |
* been performed or not. |
| 48 |
* |
| 49 |
* @since 3.04.02 |
| 50 |
*/ |
| 51 |
public function header() {} |
| 52 |
|
| 53 |
/** |
| 54 |
* Empty out the footer of its HTML contents. |
| 55 |
* |
| 56 |
* @since 3.04.02 |
| 57 |
*/ |
| 58 |
public function footer() {} |
| 59 |
|
| 60 |
/** |
| 61 |
* Instead of outputting HTML for errors, json_encode the errors and send them |
| 62 |
* back to the Ajax script for processing. |
| 63 |
* |
| 64 |
* @since 3.04.02 |
| 65 |
* |
| 66 |
* @param string|\WP_Error $errors The WP Error object of errors with the install process. |
| 67 |
*/ |
| 68 |
public function error( $errors ) { |
| 69 |
if ( ! empty( $errors ) ) { |
| 70 |
if ( ! is_string( $errors ) ) { |
| 71 |
$error = $errors->get_error_message(); |
| 72 |
$message = $errors->get_error_data(); |
| 73 |
$errors = $error . ' ' . $message; |
| 74 |
} |
| 75 |
echo json_encode( |
| 76 |
array( |
| 77 |
'error' => $errors, |
| 78 |
'message' => $errors, |
| 79 |
'success' => false, |
| 80 |
) |
| 81 |
); |
| 82 |
if ( wp_doing_ajax() ) { |
| 83 |
wp_die(); |
| 84 |
} else { |
| 85 |
die(); |
| 86 |
} |
| 87 |
} |
| 88 |
} |
| 89 |
|
| 90 |
/** |
| 91 |
* Empty out the feedback method to prevent outputting HTML strings as the install |
| 92 |
* is progressing. |
| 93 |
* |
| 94 |
* @since 3.04.02 |
| 95 |
* |
| 96 |
* @param string $string The feedback string. |
| 97 |
* @param mixed ...$args Optional text replacements. |
| 98 |
*/ |
| 99 |
public function feedback( $string, ...$args ) {} |
| 100 |
} |
| 101 |
|