PluginProbe
YayMail – WooCommerce Email Customizer / 4.4.5
YayMail – WooCommerce Email Customizer v4.4.5
4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 trunk 1.9.6 2.1.4 2.1.5 3.2.2 3.2.6 3.2.7.1 3.2.8.1 3.2.9 3.3 3.3.1 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4 3.4.1 All 57 releases
← All changes | vendor-prefixed/src/Pages/RecommendedPluginsPage.php +44 -45 4.4.2 → 4.4.5 View file →
@@ -9,14 +9,13 @@
9 9 * NOTE: Exceeds 200 LOC because three AJAX handlers (get/activate/upgrade) each
10 10 * require independent error handling + WP upgrader integration. Splitting them
11 11 * into separate classes would fragment cohesive plugin-management logic.
12 12 * Acceptable exception per code standards.
13 - * @internal
14 13 */
15 14 class RecommendedPluginsPage
16 15 {
17 16 protected static ?self $instance = null;
18 - public static function get_instance() : self
17 + public static function get_instance(): self
19 18 {
20 19 if (null === self::$instance) {
21 20 self::$instance = new self();
22 21 }
@@ -27,11 +26,11 @@
27 26 add_action('wp_ajax_yay_recommended_get_plugin_data', [$this, 'ajax_get_plugin_data'], 9);
28 27 add_action('wp_ajax_yay_recommended_activate_plugin', [$this, 'ajax_activate_plugin'], 9);
29 28 add_action('wp_ajax_yay_recommended_upgrade_plugin', [$this, 'ajax_upgrade_plugin'], 9);
30 29 }
31 - public static function render() : void
30 + public static function render(): void
32 31 {
33 - if (\function_exists('YayMailScoped\\WC')) {
32 + if (function_exists('YayMailScoped\WC')) {
34 33 $featured_tab = '<li class="plugin-install-tab plugin-install-featured" data-tab="featured"><a href="#">Featured</a></li>';
35 34 $woo_tab = '<li class="plugin-install-tab plugin-install-woocommerce" data-tab="woocommerce"><a href="#" class="current" aria-current="page">WooCommerce</a></li>';
36 35 } else {
37 36 $featured_tab = '<li class="plugin-install-tab plugin-install-featured" data-tab="featured"><a href="#" class="current" aria-current="page">Featured</a></li>';
@@ -45,9 +44,9 @@
45 44 <div class="yay-recommended-plugins-layout">
46 45 <div class="yay-recommended-plugins-layout-header">
47 46 <div class="wp-filter yay-recommended-plugins-header">
48 47 <h2 class="yay-recommended-plugins-header-title"><?php
49 - \esc_attr_e('Recommended Plugins', 'yaycommerce');
48 + esc_attr_e('Recommended Plugins', 'yaycommerce');
50 49 ?></h2>
51 50 <ul class="filter-links">
52 51 <?php
53 52 echo wp_kses_post($featured_tab);
@@ -67,21 +66,21 @@
67 66 </div>
68 67 </div>
69 68 <?php
70 69 }
71 - public static function load_data() : void
70 + public static function load_data(): void
72 71 {
73 72 add_action('admin_enqueue_scripts', [self::class, 'enqueue_scripts']);
74 73 }
75 - public static function enqueue_scripts() : void
74 + public static function enqueue_scripts(): void
76 75 {
77 - $assets_url = \plugin_dir_url(__FILE__) . '../../assets/';
76 + $assets_url = plugin_dir_url(__FILE__) . '../../assets/';
78 77 wp_enqueue_script('plugin-install');
79 78 wp_enqueue_script('thickbox');
80 79 wp_enqueue_style('thickbox');
81 80 wp_enqueue_style('yaycommerce-other-plugins', $assets_url . 'css/other-plugins.css', [], '1.0');
82 81 wp_register_script('yaycommerce-other-plugins', $assets_url . 'js/other-plugins.js', ['jquery'], '1.0', \true);
83 - wp_localize_script('yaycommerce-other-plugins', 'yayRecommended', ['nonce' => wp_create_nonce('yay_recommended_nonce'), 'admin_ajax' => \admin_url('admin-ajax.php'), 'woo_active' => \function_exists('YayMailScoped\\WC')]);
82 + wp_localize_script('yaycommerce-other-plugins', 'yayRecommended', ['nonce' => wp_create_nonce('yay_recommended_nonce'), 'admin_ajax' => admin_url('admin-ajax.php'), 'woo_active' => function_exists('YayMailScoped\WC')]);
84 83 wp_enqueue_script('yaycommerce-other-plugins');
85 84 }
86 85 /**
87 86 * Return the plugins to display. Filterable via yay_recommended_plugins_excluded.
@@ -87,74 +86,74 @@
87 86 * Return the plugins to display. Filterable via yay_recommended_plugins_excluded.
88 87 *
89 88 * @return array<string, array>
90 89 */
91 - public static function get_other_plugins() : array
90 + public static function get_other_plugins(): array
92 91 {
93 92 return include __DIR__ . '/../../views/recommended-plugins-data.php';
94 93 }
95 - public function ajax_get_plugin_data() : void
94 + public function ajax_get_plugin_data(): void
96 95 {
97 96 try {
98 - if (!\current_user_can('install_plugins')) {
99 - wp_send_json_error(['mess' => \__('Permission denied', 'yaycommerce')]);
97 + if (!current_user_can('install_plugins')) {
98 + wp_send_json_error(['mess' => __('Permission denied', 'yaycommerce')]);
100 99 }
101 100 if (!isset($_POST['tab'])) {
102 101 wp_send_json_error(['mess' => 'Missing tab']);
103 102 }
104 - $nonce = isset($_POST['nonce']) ? \sanitize_text_field($_POST['nonce']) : '';
103 + $nonce = isset($_POST['nonce']) ? sanitize_text_field($_POST['nonce']) : '';
105 104 if (!wp_verify_nonce($nonce, 'yay_recommended_nonce')) {
106 - wp_send_json_error(['mess' => \__('Nonce is invalid', 'yaycommerce')]);
105 + wp_send_json_error(['mess' => __('Nonce is invalid', 'yaycommerce')]);
107 106 }
108 107 require_once \ABSPATH . 'wp-admin/includes/plugin-install.php';
109 - $tab = \sanitize_text_field($_POST['tab']);
110 - $recommended_data = \apply_filters('yay_recommended_plugins_excluded', self::get_other_plugins());
108 + $tab = sanitize_text_field($_POST['tab']);
109 + $recommended_data = apply_filters('yay_recommended_plugins_excluded', self::get_other_plugins());
111 110 $recommended_plugins = [];
112 111 foreach ($recommended_data as $key => $plugin) {
113 - if (\in_array($tab, $plugin['type'], \true) || 'all' === $tab) {
112 + if (in_array($tab, $plugin['type'], \true) || 'all' === $tab) {
114 113 $recommended_plugins[$key] = $plugin;
115 114 }
116 115 }
117 - \ob_start();
116 + ob_start();
118 117 include __DIR__ . '/../../views/recommended-plugins-page.php';
119 - $html = \ob_get_clean();
120 - wp_send_json_success(['mess' => \__('Get data success', 'yaycommerce'), 'html' => $html]);
118 + $html = ob_get_clean();
119 + wp_send_json_success(['mess' => __('Get data success', 'yaycommerce'), 'html' => $html]);
121 120 } catch (\Exception $ex) {
122 - wp_send_json_error(['mess' => \__('Error exception.', 'yaycommerce'), ['error' => $ex]]);
121 + wp_send_json_error(['mess' => __('Error exception.', 'yaycommerce'), ['error' => $ex]]);
123 122 } catch (\Error $ex) {
124 - wp_send_json_error(['mess' => \__('Error.', 'yaycommerce'), ['error' => $ex]]);
123 + wp_send_json_error(['mess' => __('Error.', 'yaycommerce'), ['error' => $ex]]);
125 124 }
126 125 }
127 - public function ajax_activate_plugin() : void
126 + public function ajax_activate_plugin(): void
128 127 {
129 128 try {
130 - if (!\current_user_can('activate_plugins')) {
131 - wp_send_json_error(['mess' => \__('Permission denied', 'yaycommerce')]);
129 + if (!current_user_can('activate_plugins')) {
130 + wp_send_json_error(['mess' => __('Permission denied', 'yaycommerce')]);
132 131 }
133 132 if (!isset($_POST['file'])) {
134 133 wp_send_json_error(['mess' => 'Missing file']);
135 134 }
136 - $nonce = isset($_POST['nonce']) ? \sanitize_text_field($_POST['nonce']) : '';
135 + $nonce = isset($_POST['nonce']) ? sanitize_text_field($_POST['nonce']) : '';
137 136 if (!wp_verify_nonce($nonce, 'yay_recommended_nonce')) {
138 - wp_send_json_error(['mess' => \__('Nonce is invalid', 'yaycommerce')]);
137 + wp_send_json_error(['mess' => __('Nonce is invalid', 'yaycommerce')]);
139 138 }
140 - $file = \sanitize_text_field($_POST['file']);
139 + $file = sanitize_text_field($_POST['file']);
141 140 $result = activate_plugin($file);
142 141 if (is_wp_error($result)) {
143 142 wp_send_json_error(['mess' => $result->get_error_message()]);
144 143 }
145 - wp_send_json_success(['mess' => \__('Activate success', 'yaycommerce')]);
144 + wp_send_json_success(['mess' => __('Activate success', 'yaycommerce')]);
146 145 } catch (\Exception $ex) {
147 - wp_send_json_error(['mess' => \__('Error exception.', 'yaycommerce'), ['error' => $ex]]);
146 + wp_send_json_error(['mess' => __('Error exception.', 'yaycommerce'), ['error' => $ex]]);
148 147 } catch (\Error $ex) {
149 - wp_send_json_error(['mess' => \__('Error.', 'yaycommerce'), ['error' => $ex]]);
148 + wp_send_json_error(['mess' => __('Error.', 'yaycommerce'), ['error' => $ex]]);
150 149 }
151 150 }
152 - public function ajax_upgrade_plugin() : void
151 + public function ajax_upgrade_plugin(): void
153 152 {
154 153 try {
155 - if (!\current_user_can('install_plugins')) {
156 - wp_send_json_error(['mess' => \__('Permission denied', 'yaycommerce')]);
154 + if (!current_user_can('install_plugins')) {
155 + wp_send_json_error(['mess' => __('Permission denied', 'yaycommerce')]);
157 156 }
158 157 require_once \ABSPATH . 'wp-admin/includes/plugin-install.php';
159 158 require_once \ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
160 159 require_once \ABSPATH . 'wp-admin/includes/class-wp-ajax-upgrader-skin.php';
@@ -161,14 +160,14 @@
161 160 require_once \ABSPATH . 'wp-admin/includes/class-plugin-upgrader.php';
162 161 if (!isset($_POST['plugin'])) {
163 162 wp_send_json_error(['mess' => 'Missing plugin']);
164 163 }
165 - $nonce = isset($_POST['nonce']) ? \sanitize_text_field($_POST['nonce']) : '';
164 + $nonce = isset($_POST['nonce']) ? sanitize_text_field($_POST['nonce']) : '';
166 165 if (!wp_verify_nonce($nonce, 'yay_recommended_nonce')) {
167 - wp_send_json_error(['mess' => \__('Nonce is invalid', 'yaycommerce')]);
166 + wp_send_json_error(['mess' => __('Nonce is invalid', 'yaycommerce')]);
168 167 }
169 - $plugin = \sanitize_text_field($_POST['plugin']);
170 - $type = isset($_POST['type']) ? \sanitize_text_field($_POST['type']) : 'install';
168 + $plugin = sanitize_text_field($_POST['plugin']);
169 + $type = isset($_POST['type']) ? sanitize_text_field($_POST['type']) : 'install';
171 170 $skin = new \WP_Ajax_Upgrader_Skin();
172 171 $upgrader = new \Plugin_Upgrader($skin);
173 172 if ('install' === $type) {
174 173 $result = $upgrader->install($plugin);
@@ -182,9 +181,9 @@
182 181 $active_plugin = activate_plugin($install_status['file']);
183 182 if (is_wp_error($active_plugin)) {
184 183 wp_send_json_error(['mess' => $active_plugin->get_error_message()]);
185 184 }
186 - wp_send_json_success(['mess' => \__('Install success', 'yaycommerce')]);
185 + wp_send_json_success(['mess' => __('Install success', 'yaycommerce')]);
187 186 } else {
188 187 wp_send_json_error(['mess' => 'Error']);
189 188 }
190 189 } else {
@@ -193,23 +192,23 @@
193 192 if (is_wp_error($result)) {
194 193 wp_send_json_error(['mess' => $result->get_error_message()]);
195 194 }
196 195 activate_plugin($plugin);
197 - wp_send_json_success(['mess' => \__('Update success', 'yaycommerce'), 'active' => $is_active]);
196 + wp_send_json_success(['mess' => __('Update success', 'yaycommerce'), 'active' => $is_active]);
198 197 }
199 198 } catch (\Exception $ex) {
200 - wp_send_json_error(['mess' => \__('Error exception.', 'yaycommerce'), ['error' => $ex]]);
199 + wp_send_json_error(['mess' => __('Error exception.', 'yaycommerce'), ['error' => $ex]]);
201 200 } catch (\Error $ex) {
202 - wp_send_json_error(['mess' => \__('Error.', 'yaycommerce'), ['error' => $ex]]);
201 + wp_send_json_error(['mess' => __('Error.', 'yaycommerce'), ['error' => $ex]]);
203 202 }
204 203 }
205 - public function check_pro_version_exists(array $plugin_detail) : ?string
204 + public function check_pro_version_exists(array $plugin_detail): ?string
206 205 {
207 206 $all_plugins = get_plugins();
208 207 $slug = $plugin_detail['slug'] ?? '';
209 208 $map = ['filebird' => ['filebird-pro/filebird.php'], 'yaymail' => ['yaymail-pro/yaymail.php', 'email-customizer-for-woocommerce/yaymail.php'], 'yaycurrency' => ['yaycurrency-pro/yay-currency.php', 'multi-currency-switcher/yay-currency.php'], 'yaysmtp' => ['yaysmtp-pro/yay-smtp.php'], 'yayswatches' => ['yayswatches-pro/yay-swatches.php'], 'yayextra' => ['yayextra-pro/yayextra.php'], 'yaypricing' => ['yaypricing-pro/yaypricing.php', 'dynamic-pricing-discounts/yaypricing.php'], 'yay-customer-reviews-woocommerce' => ['yayreviews-pro/yay-customer-reviews-woocommerce.php'], 'yay-wholesale-b2b' => ['yay-wholesale-b2b-pro/yay-wholesale-b2b.php'], 'yayboost-sales-booster-for-woocommerce' => ['yayboost-pro/yayboost-sales-booster-for-woocommerce.php'], 'cf7-multi-step' => ['contact-form-7-multi-step-pro/contact-form-7-multi-step.php'], 'cf7-database' => ['contact-form-7-database-pro/cf7-database.php'], 'wp-whatsapp' => ['whatsapp-for-wordpress/whatsapp.php']];
210 209 foreach ($map[$slug] ?? [] as $basename) {
211 - if (\array_key_exists($basename, $all_plugins)) {
210 + if (array_key_exists($basename, $all_plugins)) {
212 211 return $basename;
213 212 }
214 213 }
215 214 return null;