PluginProbe
YayMail – WooCommerce Email Customizer / 3.4
YayMail – WooCommerce Email Customizer v3.4
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 3.4.2 3.4.3 All 55 releases
yaymail / includes / YayCommerceMenu / OtherPluginsMenu.php

OtherPluginsMenu.php in YayMail – WooCommerce Email Customizer 3.4, at includes/YayCommerceMenu/OtherPluginsMenu.php

541 lines 20.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * YayCommerce other plugins menu
4 *
5 * @package YayMail\Admin
6 */
7
8 namespace YayMail\YayCommerceMenu;
9
10 defined( 'ABSPATH' ) || exit;
11
12 /**
13 * Declare class
14 */
15 class OtherPluginsMenu {
16
17 protected static $instance = null;
18
19 public static function get_instance() {
20 if ( empty( self::$instance ) ) {
21 self::$instance = new self();
22 }
23 return self::$instance;
24 }
25
26 protected function __construct() {
27 add_action( 'wp_ajax_yay_recommended_get_plugin_data', array( $this, 'yay_recommended_get_plugin_data' ), 1 );
28 add_action( 'wp_ajax_yay_recommended_activate_plugin', array( $this, 'yay_recommended_activate_plugin' ), 1 );
29 add_action( 'wp_ajax_yay_recommended_upgrade_plugin', array( $this, 'yay_recommended_upgrade_plugin' ), 1 );
30 }
31
32 public static function render() {
33 if ( function_exists( 'WC' ) ) {
34 $featuredTab = '<li class="plugin-install-tab plugin-install-featured" data-tab="featured"><a href="#" >Featured</a> </li>';
35 $wooTab = '<li class="plugin-install-tab plugin-install-woocommerce" data-tab="woocommerce"><a href="#" class="current" aria-current="page">WooCommerce</a> </li>';
36 } else {
37 $featuredTab = '<li class="plugin-install-tab plugin-install-featured" data-tab="featured"><a href="#" class="current" aria-current="page">Featured</a> </li>';
38 $wooTab = '<li class="plugin-install-tab plugin-install-woocommerce" data-tab="woocommerce"><a href="#" >WooCommerce</a> </li>';
39 }
40 ?>
41 <script>
42 document.querySelector("#wpbody-content").innerHTML = "";
43 </script>
44 <style>
45 .yay-recommended-plugins-layout {
46 margin-top: 20px;
47 }
48 .wrap .notice, .wrap .error {
49 display: none !important;
50 }
51 .yay-recommended-plugins-layout-header {
52 background: #fff;
53 box-sizing: border-box;
54 padding: 0;
55 z-index: 1001;
56 }
57
58 .yay-recommended-plugins-header{
59 display: flex;
60 flex-wrap: wrap;
61 justify-content: space-between;
62 align-items: center;
63 position: relative;
64 box-sizing: border-box;
65 margin: 12px 0 25px;
66 padding: 0 10px;
67 width: 100%;
68 box-shadow: 0 1px 1px rgb(0 0 0 / 4%);
69 border: 1px solid #c3c4c7;
70 background: #fff;
71 color: #50575e;
72 font-size: 13px;
73 }
74 .yay-recommended-plugins-header-title {
75 font-size: 1.2em;
76 margin-left: 8px;
77 }
78 .yay-recommended-plugins-layout .plugin-card .desc, .plugin-card .name {
79 margin-right: 0;
80 }
81 .yay-recommended-plugins-layout .plugin-card-bottom {
82 display: flex;
83 justify-content: space-between;
84 align-items: center;
85 }
86 .yay-recommended-plugins-layout .plugin-action-buttons,
87 .yay-recommended-plugins-layout .plugin-action-buttons li,
88 .plugin-card .column-rating, .plugin-card .column-updated {
89 margin-bottom: 0;
90 }
91 .yay-recommended-plugins-layout .loading-process {
92 pointer-events: none;
93 }
94 .yay-recommended-plugins-layout .column-rating {
95 min-height: 30px;
96 line-height: 30px;
97 }
98 .yay-recommended-plugins-layout .plugin-status-inactive {
99 color: #ff4d4f;
100 }
101 .yay-recommended-plugins-layout .plugin-status-active {
102 color: #52c41a;
103 }
104 .yay-recommended-plugins-layout .plugin-status-not-install {
105 color: #1d2327;
106 }
107 @media screen and (max-width: 1100px) and (min-width: 782px), (max-width: 480px) {
108 .yay-recommended-plugins-layout .plugin-card .column-compatibility,
109 .yay-recommended-plugins-layout .plugin-card .column-updated {
110 width: calc(100% - 220px);
111 }
112 .yay-recommended-plugins-layout .plugin-action-buttons li .button,
113 .yay-recommended-plugins-layout .plugin-action-buttons {
114 margin: 0;
115 }
116 }
117 </style>
118 <div class="wrap">
119 <div class="yay-recommended-plugins-layout">
120 <div class="yay-recommended-plugins-layout-header">
121 <div class="wp-filter yay-recommended-plugins-header">
122 <h2 class="yay-recommended-plugins-header-title"><?php esc_attr_e( 'Other Plugins', 'filebird' ); ?></h2>
123 <ul class="filter-links">
124 <?php
125 echo wp_kses_post( $featuredTab );
126 ?>
127 <li class="plugin-install-tab plugin-install-all" data-tab="all"><a href="#">All</a></li>
128 <?php
129 echo wp_kses_post( $wooTab );
130 ?>
131 <li class="plugin-install-tab plugin-install-management" data-tab="management"><a href="#">Management</a> </li>
132 <li class="plugin-install-tab plugin-install-marketing" data-tab="marketing"><a href="#">Marketing</a></li>
133 </ul>
134 </div>
135 </div>
136 <div class="wp-list-table widefat plugin-install">
137 <div id="the-list"></div>
138 </div>
139 </div>
140 </div>
141 <?php
142 }
143
144 public static function enqueue_scripts() {
145 wp_enqueue_script( 'plugin-install' );
146 wp_enqueue_script( 'thickbox' );
147 wp_enqueue_style( 'thickbox' );
148 wp_register_script( 'yaycommerce-other-plugins', plugin_dir_url( __FILE__ ) . '/assets/js/other-plugins.js', array( 'jquery' ), '1.0', true );
149 wp_localize_script(
150 'yaycommerce-other-plugins',
151 'yayRecommended',
152 array(
153 'nonce' => wp_create_nonce( 'yay_recommended_nonce' ),
154 'admin_ajax' => admin_url( 'admin-ajax.php' ),
155 'woo_active' => function_exists( 'WC' ),
156 )
157 );
158 wp_enqueue_script( 'yaycommerce-other-plugins' );
159 }
160
161 public static function load_data() {
162 add_action( 'admin_enqueue_scripts', array( __CLASS__, 'enqueue_scripts' ) );
163 }
164
165 public static function get_other_plugins() {
166 return array(
167 'filebird' => array(
168 'slug' => 'filebird',
169 'name' => 'FileBird - WordPress Media Library Folders & File Manager',
170 'short_description' => 'Organize thousands of WordPress media files in folders / categories at ease.',
171 'icon' => 'https://ps.w.org/filebird/assets/icon-128x128.gif?rev=2299145',
172 'download_link' => 'https://downloads.wordpress.org/plugin/filebird.zip',
173 'type' => array( 'featured' ),
174 'version' => 0,
175 ),
176 'yaymail' => array(
177 'slug' => 'yaymail',
178 'name' => 'YayMail - WooCommerce Email Customizer',
179 'short_description' => 'Customize WooCommerce email templates with live preview & drag and drop email builder.',
180 'icon' => 'https://ps.w.org/yaymail/assets/icon-256x256.gif?rev=2599198',
181 'download_link' => 'https://downloads.wordpress.org/plugin/yaymail.zip',
182 'type' => array( 'featured', 'woocommerce' ),
183 'version' => 0,
184 ),
185 'yaycurrency' => array(
186 'slug' => 'yaycurrency',
187 'name' => 'YayCurrency - WooCommerce Multi-Currency Switcher',
188 'short_description' => 'WooCommerce Multi-Currency made easy, powerful, and flexible.',
189 'icon' => 'https://ps.w.org/yaycurrency/assets/icon-256x256.png?rev=2550570',
190 'download_link' => 'https://downloads.wordpress.org/plugin/yaycurrency.zip',
191 'type' => array( 'featured', 'woocommerce' ),
192 'version' => 0,
193 ),
194 'yayswatches' => array(
195 'slug' => 'yayswatches',
196 'name' => 'YaySwatches - Variation Swatches for WooCommerce',
197 'short_description' => 'Optimize your variable product showcase with color swatches, image swatches, custom images, buttons, and more!',
198 'icon' => 'https://ps.w.org/yayswatches/assets/icon-256x256.png?rev=2757155',
199 'download_link' => 'https://downloads.wordpress.org/plugin/yayswatches.zip',
200 'type' => array( 'woocommerce' ),
201 'version' => 0,
202 ),
203 'yayextra' => array(
204 'slug' => 'yayextra',
205 'name' => 'YayExtra - WooCommerce Extra Product Options',
206 'short_description' => 'Add WooCommerce product options like personal engraving, print-on-demand items, gifts, custom canvas prints, and personalized products.',
207 'icon' => 'https://ps.w.org/yayextra/assets/icon-256x256.png?rev=2776349',
208 'download_link' => 'https://downloads.wordpress.org/plugin/yayextra.zip',
209 'type' => array( 'woocommerce' ),
210 'version' => 0,
211 ),
212 'yaypricing' => array(
213 'slug' => 'yaypricing',
214 'name' => 'YayPricing - WooCommerce Dynamic Pricing & Discounts',
215 'short_description' => 'Offer automatic pricing and discounts to design a powerful marketing strategy for your WooCommerce store.',
216 'icon' => 'https://yaycommerce.com/wp-content/uploads/2022/11/yaypricing-256x256-1.png',
217 'download_link' => 'https://yaycommerce.com/yaypricing-woocommerce-dynamic-pricing-and-discounts/',
218 'type' => array( 'woocommerce' ),
219 'version' => 0,
220 ),
221 'yaysmtp' => array(
222 'slug' => 'yaysmtp',
223 'name' => 'YaySMTP - Simple WP SMTP Mail',
224 'short_description' => 'Send WordPress emails successfully with WP Mail SMTP via your favorite Mailer.',
225 'icon' => 'https://ps.w.org/yaysmtp/assets/icon-256x256.png?rev=2437984',
226 'download_link' => 'https://downloads.wordpress.org/plugin/yaysmtp.zip',
227 'type' => array( 'featured', 'marketing' ),
228 'version' => 0,
229 ),
230 'wp-whatsapp' => array(
231 'slug' => 'wp-whatsapp',
232 'name' => 'WP Chat App',
233 'short_description' => 'Integrate WhatsApp experience directly into your WordPress website.',
234 'icon' => 'https://ps.w.org/wp-whatsapp/assets/icon-256x256.png?rev=2725670',
235 'download_link' => 'https://downloads.wordpress.org/plugin/wp-whatsapp.zip',
236 'type' => array( 'featured' ),
237 'version' => 0,
238 ),
239 'filester' => array(
240 'slug' => 'filester',
241 'name' => 'Filester - File Manager Pro',
242 'short_description' => 'Best WordPress file manager without FTP access. Clean design. No need to upgrade because this…',
243 'icon' => 'https://ps.w.org/filester/assets/icon-256x256.gif?rev=2305540',
244 'download_link' => 'https://downloads.wordpress.org/plugin/filester.zip',
245 'type' => array( 'management' ),
246 'version' => 0,
247 ),
248 'cf7-multi-step' => array(
249 'slug' => 'cf7-multi-step',
250 'name' => 'Multi Step for Contact Form 7',
251 'short_description' => 'Break your looooooong form into user-friendly steps.',
252 'icon' => 'https://ps.w.org/cf7-multi-step/assets/icon-256x256.png?rev=1994366',
253 'download_link' => 'https://downloads.wordpress.org/plugin/cf7-multi-step.zip',
254 'type' => array( 'management' ),
255 'version' => 0,
256 ),
257 'cf7-database' => array(
258 'slug' => 'cf7-database',
259 'name' => 'Database for Contact Form 7',
260 'short_description' => 'Automatically save all data submitted via Contact Form 7 to your database.',
261 'icon' => 'https://ps.w.org/cf7-database/assets/icon-128x128.png?rev=1614091',
262 'download_link' => 'https://downloads.wordpress.org/plugin/cf7-database.zip',
263 'type' => array( 'management' ),
264 'version' => 0,
265 ),
266 'wp-duplicate-page' => array(
267 'slug' => 'wp-duplicate-page',
268 'name' => 'WP Duplicate Page',
269 'short_description' => 'Clone WordPress page, post, custom post types.',
270 'icon' => 'https://ps.w.org/wp-duplicate-page/assets/icon-256x256.gif?rev=2432962',
271 'download_link' => 'https://downloads.wordpress.org/plugin/wp-duplicate-page.zip',
272 'type' => array( 'management' ),
273 'version' => 0,
274 ),
275 'notibar' => array(
276 'slug' => 'notibar',
277 'name' => 'Notibar - Notification Bar for WordPress',
278 'short_description' => 'Customizer for sticky header, notification bar, alert, promo code, marketing campaign, top banner.',
279 'icon' => 'https://ps.w.org/notibar/assets/icon-256x256.png?rev=2387855',
280 'download_link' => 'https://downloads.wordpress.org/plugin/notibar.zip',
281 'type' => array( 'marketing' ),
282 'version' => 0,
283 ),
284 );
285 }
286
287 public function yay_recommended_get_plugin_data() {
288 try {
289 if ( isset( $_POST['tab'] ) ) {
290 $nonce = isset( $_POST['nonce'] ) ? sanitize_text_field( $_POST['nonce'] ) : '';
291 if ( ! wp_verify_nonce( $nonce, 'yay_recommended_nonce' ) ) {
292 wp_send_json_error( array( 'mess' => __( 'Nonce is invalid', 'yaycommerce' ) ) );
293 }
294 require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
295 $tab = sanitize_text_field( $_POST['tab'] );
296 $recommendedPlugins = array();
297 $recommendedData = apply_filters( 'yay_recommended_plugins_excluded', self::get_other_plugins() );
298 foreach ( $recommendedData as $key => $plugin ) {
299 if ( in_array( $tab, $plugin['type'] ) || 'all' === $tab ) {
300 $recommendedPlugins[ $key ] = $plugin;
301 }
302 }
303 ob_start();
304 $path = plugin_dir_path( __FILE__ ) . 'views/other-plugins-content.php';
305 include $path;
306 $html = ob_get_contents();
307 ob_end_clean();
308 wp_send_json_success(
309 array(
310 'mess' => __( 'Get data success', 'yaycommerce' ),
311 'html' => $html,
312 )
313 );
314 }
315 } catch ( \Exception $ex ) {
316 wp_send_json_error(
317 array(
318 'mess' => __( 'Error exception.', 'yaycommerce' ),
319 array(
320 'error' => $ex,
321 ),
322 )
323 );
324 } catch ( \Error $ex ) {
325 wp_send_json_error(
326 array(
327 'mess' => __( 'Error.', 'yaycommerce' ),
328 array(
329 'error' => $ex,
330 ),
331 )
332 );
333 }
334 }
335
336 public function yay_recommended_activate_plugin() {
337 try {
338 if ( isset( $_POST['file'] ) ) {
339 $nonce = isset( $_POST['nonce'] ) ? sanitize_text_field( $_POST['nonce'] ) : '';
340 if ( ! wp_verify_nonce( $nonce, 'yay_recommended_nonce' ) ) {
341 wp_send_json_error( array( 'mess' => __( 'Nonce is invalid', 'yaycommerce' ) ) );
342 }
343 $file = sanitize_text_field( $_POST['file'] );
344 $result = activate_plugin( $file );
345
346 if ( is_wp_error( $result ) ) {
347 wp_send_json_error(
348 array(
349 'mess' => $result->get_error_message(),
350 )
351 );
352 }
353 wp_send_json_success(
354 array(
355 'mess' => __( 'Activate success', 'yaycommerce' ),
356 )
357 );
358 }
359 } catch ( \Exception $ex ) {
360 wp_send_json_error(
361 array(
362 'mess' => __( 'Error exception.', 'yaycommerce' ),
363 array(
364 'error' => $ex,
365 ),
366 )
367 );
368 } catch ( \Error $ex ) {
369 wp_send_json_error(
370 array(
371 'mess' => __( 'Error.', 'yaycommerce' ),
372 array(
373 'error' => $ex,
374 ),
375 )
376 );
377 }
378 }
379
380 public function yay_recommended_upgrade_plugin() {
381 try {
382 require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
383 require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
384 require_once ABSPATH . 'wp-admin/includes/class-wp-ajax-upgrader-skin.php';
385 require_once ABSPATH . 'wp-admin/includes/class-plugin-upgrader.php';
386 if ( isset( $_POST['plugin'] ) ) {
387 $nonce = isset( $_POST['nonce'] ) ? sanitize_text_field( $_POST['nonce'] ) : '';
388 if ( ! wp_verify_nonce( $nonce, 'yay_recommended_nonce' ) ) {
389 wp_send_json_error( array( 'mess' => __( 'Nonce is invalid', 'yaycommerce' ) ) );
390 }
391 $plugin = sanitize_text_field( $_POST['plugin'] );
392 $type = isset( $_POST['type'] ) ? sanitize_text_field( $_POST['type'] ) : 'install';
393 $skin = new \WP_Ajax_Upgrader_Skin();
394 $upgrader = new \Plugin_Upgrader( $skin );
395 if ( 'install' === $type ) {
396 $result = $upgrader->install( $plugin );
397 if ( is_wp_error( $result ) ) {
398 wp_send_json_error(
399 array(
400 'mess' => $result->get_error_message(),
401 )
402 );
403 }
404 $args = array(
405 'slug' => $upgrader->result['destination_name'],
406 'fields' => array(
407 'short_description' => true,
408 'icons' => true,
409 'banners' => false,
410 'added' => false,
411 'reviews' => false,
412 'sections' => false,
413 'requires' => false,
414 'rating' => false,
415 'ratings' => false,
416 'downloaded' => false,
417 'last_updated' => false,
418 'added' => false,
419 'tags' => false,
420 'compatibility' => false,
421 'homepage' => false,
422 'donate_link' => false,
423 ),
424 );
425 $pluginData = plugins_api( 'plugin_information', $args );
426 if ( $pluginData && ! is_wp_error( $pluginData ) ) {
427 $installStatus = install_plugin_install_status( $pluginData );
428 $activePlugin = activate_plugin( $installStatus['file'] );
429 if ( is_wp_error( $activePlugin ) ) {
430 wp_send_json_error(
431 array(
432 'mess' => $activePlugin->get_error_message(),
433 )
434 );
435 } else {
436 wp_send_json_success(
437 array(
438 'mess' => __( 'Install success', 'yaycommerce' ),
439 )
440 );
441 }
442 } else {
443 wp_send_json_error(
444 array(
445 'mess' => 'Error',
446 )
447 );
448 }
449 } else {
450 $is_active = is_plugin_active( $plugin );
451 $result = $upgrader->upgrade( $plugin );
452 if ( is_wp_error( $result ) ) {
453 wp_send_json_error(
454 array(
455 'mess' => $result->get_error_message(),
456 )
457 );
458 } else {
459 activate_plugin( $plugin );
460 wp_send_json_success(
461 array(
462 'mess' => __( 'Update success', 'yaycommerce' ),
463 'active' => $is_active,
464 )
465 );
466 }
467 }
468 }
469 } catch ( \Exception $ex ) {
470 wp_send_json_error(
471 array(
472 'mess' => __( 'Error exception.', 'yaycommerce' ),
473 array(
474 'error' => $ex,
475 ),
476 )
477 );
478 } catch ( \Error $ex ) {
479 wp_send_json_error(
480 array(
481 'mess' => __( 'Error.', 'yaycommerce' ),
482 array(
483 'error' => $ex,
484 ),
485 )
486 );
487 }
488 }
489
490 public function check_pro_version_exists( $pluginDetail ) {
491 $existProVer = false;
492 $allPlugin = get_plugins();
493 if ( 'filebird' === $pluginDetail['slug'] ) {
494 $existProVer = array_key_exists( 'filebird-pro/filebird.php', $allPlugin ) === true ? 'filebird-pro/filebird.php' : false;
495 }
496 if ( 'yaymail' === $pluginDetail['slug'] ) {
497 if ( array_key_exists( 'yaymail-pro/yaymail.php', $allPlugin ) ) {
498 $existProVer = 'yaymail-pro/yaymail.php';
499 } elseif ( array_key_exists( 'email-customizer-for-woocommerce/yaymail.php', $allPlugin ) ) {
500 $existProVer = 'email-customizer-for-woocommerce/yaymail.php';
501 }
502 }
503 if ( 'yaycurrency' === $pluginDetail['slug'] ) {
504 if ( array_key_exists( 'yaycurrency-pro/yay-currency.php', $allPlugin ) ) {
505 $existProVer = 'yaycurrency-pro/yay-currency.php';
506 } elseif ( array_key_exists( 'multi-currency-switcher/yay-currency.php', $allPlugin ) ) {
507 $existProVer = 'multi-currency-switcher/yay-currency.php';
508 }
509 }
510 if ( 'yaysmtp' === $pluginDetail['slug'] ) {
511 $existProVer = array_key_exists( 'yaysmtp-pro/yay-smtp.php', $allPlugin ) === true ? 'yaysmtp-pro/yay-smtp.php' : false;
512 }
513 if ( 'yayswatches' === $pluginDetail['slug'] ) {
514 $existProVer = array_key_exists( 'yayswatches-pro/yay-swatches.php', $allPlugin ) === true ? 'yayswatches-pro/yay-swatches.php' : false;
515 }
516 if ( 'yayextra' === $pluginDetail['slug'] ) {
517 $existProVer = array_key_exists( 'yayextra-pro/yayextra.php', $allPlugin ) === true ? 'yayextra-pro/yayextra.php' : false;
518 }
519 if ( 'yaypricing' === $pluginDetail['slug'] ) {
520 if ( array_key_exists( 'yaypricing-pro/yaypricing.php', $allPlugin ) ) {
521 $existProVer = 'yaypricing-pro/yaypricing.php';
522 } elseif ( array_key_exists( 'dynamic-pricing-discounts/yaypricing.php', $allPlugin ) ) {
523 $existProVer = 'dynamic-pricing-discounts/yaypricing.php';
524 }
525 }
526 if ( 'cf7-multi-step' === $pluginDetail['slug'] ) {
527 $existProVer = array_key_exists( 'contact-form-7-multi-step-pro/contact-form-7-multi-step.php', $allPlugin ) === true ? 'contact-form-7-multi-step-pro/contact-form-7-multi-step.php' : false;
528 }
529 if ( 'cf7-database' === $pluginDetail['slug'] ) {
530 $existProVer = array_key_exists( 'contact-form-7-database-pro/cf7-database.php', $allPlugin ) === true ? 'contact-form-7-database-pro/cf7-database.php' : false;
531 }
532 if ( 'wp-whatsapp' === $pluginDetail['slug'] ) {
533 $existProVer = array_key_exists( 'whatsapp-for-wordpress/whatsapp.php', $allPlugin ) === true ? 'whatsapp-for-wordpress/whatsapp.php' : false;
534 }
535 if ( 'parcelpanel' === $pluginDetail['slug'] ) {
536 $existProVer = array_key_exists( 'parcelpanel/parcelpanel.php', $allPlugin ) === true ? 'parcelpanel/parcelpanel.php' : false;
537 }
538 return $existProVer;
539 }
540 }
541