| @@ -1,20 +1,22 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | if (!defined('ABSPATH')) exit; |
| 4 | -if (!class_exists('BVUpgraderSkin')) : | |
| 5 | -class BVUpgraderSkin extends WP_Upgrader_Skin { | |
| 4 | +if (!class_exists('WPRUpgraderSkin')) : | |
| 5 | +class WPRUpgraderSkin extends WP_Upgrader_Skin { | |
| 6 | 6 | public $status = array(); |
| 7 | 7 | public $action = ''; |
| 8 | 8 | public $plugin_info = array(); |
| 9 | 9 | public $theme_info = array(); |
| 10 | + public $plugins_by_name = array(); | |
| 10 | 11 | public $language_update = null; |
| 11 | 12 | |
| 12 | - const UPGRADER_WING_VERSION = 1.0; | |
| 13 | + const UPGRADER_WING_VERSION = 1.1; | |
| 13 | 14 | |
| 14 | - function __construct($type, $package = '') { | |
| 15 | + function __construct($type, $plugins_by_name = array(), $package = '') { | |
| 15 | 16 | $this->action = $type; |
| 16 | 17 | $this->package = $package; |
| 18 | + $this->plugins_by_name = $plugins_by_name; | |
| 17 | 19 | parent::__construct(array()); |
| 18 | 20 | } |
| 19 | 21 | |
| 20 | 22 | function header() {} |
| @@ -20,10 +22,11 @@ | ||
| 20 | 22 | function header() {} |
| 21 | 23 | |
| 22 | 24 | function footer() {} |
| 23 | 25 | |
| 24 | - function get_key() { | |
| 26 | + function get_keys() { | |
| 25 | 27 | $key = "bvgeneral"; |
| 28 | + $key_by_file = null; | |
| 26 | 29 | switch ($this->action) { |
| 27 | 30 | case "theme_upgrade": |
| 28 | 31 | if (!empty($this->theme_info)) |
| 29 | 32 | $key = $this->theme_info['Name']; |
| @@ -28,10 +31,12 @@ | ||
| 28 | 31 | if (!empty($this->theme_info)) |
| 29 | 32 | $key = $this->theme_info['Name']; |
| 30 | 33 | break; |
| 31 | 34 | case "plugin_upgrade": |
| 32 | - if (!empty($this->plugin_info)) | |
| 35 | + if (!empty($this->plugin_info)) { | |
| 33 | 36 | $key = $this->plugin_info['Name']; |
| 37 | + $key_by_file = $this->plugins_by_name[$key]; | |
| 38 | + } | |
| 34 | 39 | break; |
| 35 | 40 | case "installer": |
| 36 | 41 | if (!empty($this->package)) |
| 37 | 42 | $key = $this->package; |
| @@ -40,13 +45,13 @@ | ||
| 40 | 45 | if (null != $this->language_update) |
| 41 | 46 | $key = $this->language_update->package; |
| 42 | 47 | break; |
| 43 | 48 | } |
| 44 | - return $key; | |
| 49 | + return array($key, $key_by_file); | |
| 45 | 50 | } |
| 46 | 51 | |
| 47 | 52 | function error($errors) { |
| 48 | - $key = $this->get_key(); | |
| 53 | + list($key, $key_by_file) = $this->get_keys(); | |
| 49 | 54 | $message = array(); |
| 50 | 55 | $message['error'] = true; |
| 51 | 56 | if (is_string($errors)) { |
| 52 | 57 | $message['message'] = $errors; |
| @@ -54,8 +59,11 @@ | ||
| 54 | 59 | $message['data'] = $errors->get_error_data(); |
| 55 | 60 | $message['code'] = $errors->get_error_code(); |
| 56 | 61 | } |
| 57 | 62 | $this->status[$this->action.':'.$key][] = $message; |
| 63 | + if (!empty($key_by_file)) { | |
| 64 | + $this->status[$this->action.':'.$key_by_file][] = $message; | |
| 65 | + } | |
| 58 | 66 | } |
| 59 | 67 | |
| 60 | 68 | function feedback($string, ...$args) { |
| 61 | 69 | if ( empty($string) ) |
| @@ -68,11 +76,14 @@ | ||
| 68 | 76 | $string = vsprintf( $string, $args ); |
| 69 | 77 | } |
| 70 | 78 | } |
| 71 | 79 | |
| 72 | - $key = $this->get_key(); | |
| 80 | + list($key, $key_by_file) = $this->get_keys(); | |
| 73 | 81 | $message = array(); |
| 74 | 82 | $message['message'] = $string; |
| 83 | + if (!empty($key_by_file)) { | |
| 84 | + $this->status[$this->action.':'.$key_by_file][] = $message; | |
| 85 | + } | |
| 75 | 86 | $this->status[$this->action.':'.$key][] = $message; |
| 76 | 87 | } |
| 77 | 88 | } |
| 78 | 89 | endif; |