| 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 |
'parcelpanel' => array( |
| 285 |
'slug' => 'parcelpanel', |
| 286 |
'name' => 'Parcel Panel Order Tracking for WooCommerce', |
| 287 |
'short_description' => 'The #1 order tracking app specially designed for WooCommerce, driving customer loyalty and more sales by providing the best post-purchase experience', |
| 288 |
'icon' => 'https://ps.w.org/parcelpanel/assets/icon-256x256.png?rev=2742561', |
| 289 |
'download_link' => 'https://downloads.wordpress.org/plugin/parcelpanel.zip', |
| 290 |
'type' => array( 'woocommerce' ), |
| 291 |
'version' => 0, |
| 292 |
), |
| 293 |
); |
| 294 |
} |
| 295 |
|
| 296 |
public function yay_recommended_get_plugin_data() { |
| 297 |
try { |
| 298 |
if ( isset( $_POST['tab'] ) ) { |
| 299 |
$nonce = isset( $_POST['nonce'] ) ? sanitize_text_field( $_POST['nonce'] ) : ''; |
| 300 |
if ( ! wp_verify_nonce( $nonce, 'yay_recommended_nonce' ) ) { |
| 301 |
wp_send_json_error( array( 'mess' => __( 'Nonce is invalid', 'yaycommerce' ) ) ); |
| 302 |
} |
| 303 |
require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; |
| 304 |
$tab = sanitize_text_field( $_POST['tab'] ); |
| 305 |
$recommendedPlugins = array(); |
| 306 |
$recommendedData = apply_filters( 'yay_recommended_plugins_excluded', self::get_other_plugins() ); |
| 307 |
foreach ( $recommendedData as $key => $plugin ) { |
| 308 |
if ( in_array( $tab, $plugin['type'] ) || 'all' === $tab ) { |
| 309 |
$recommendedPlugins[ $key ] = $plugin; |
| 310 |
} |
| 311 |
} |
| 312 |
ob_start(); |
| 313 |
$path = plugin_dir_path( __FILE__ ) . 'views/other-plugins-content.php'; |
| 314 |
include $path; |
| 315 |
$html = ob_get_contents(); |
| 316 |
ob_end_clean(); |
| 317 |
wp_send_json_success( |
| 318 |
array( |
| 319 |
'mess' => __( 'Get data success', 'yaycommerce' ), |
| 320 |
'html' => $html, |
| 321 |
) |
| 322 |
); |
| 323 |
} |
| 324 |
} catch ( \Exception $ex ) { |
| 325 |
wp_send_json_error( |
| 326 |
array( |
| 327 |
'mess' => __( 'Error exception.', 'yaycommerce' ), |
| 328 |
array( |
| 329 |
'error' => $ex, |
| 330 |
), |
| 331 |
) |
| 332 |
); |
| 333 |
} catch ( \Error $ex ) { |
| 334 |
wp_send_json_error( |
| 335 |
array( |
| 336 |
'mess' => __( 'Error.', 'yaycommerce' ), |
| 337 |
array( |
| 338 |
'error' => $ex, |
| 339 |
), |
| 340 |
) |
| 341 |
); |
| 342 |
} |
| 343 |
} |
| 344 |
|
| 345 |
public function yay_recommended_activate_plugin() { |
| 346 |
try { |
| 347 |
if ( isset( $_POST['file'] ) ) { |
| 348 |
$nonce = isset( $_POST['nonce'] ) ? sanitize_text_field( $_POST['nonce'] ) : ''; |
| 349 |
if ( ! wp_verify_nonce( $nonce, 'yay_recommended_nonce' ) ) { |
| 350 |
wp_send_json_error( array( 'mess' => __( 'Nonce is invalid', 'yaycommerce' ) ) ); |
| 351 |
} |
| 352 |
$file = sanitize_text_field( $_POST['file'] ); |
| 353 |
$result = activate_plugin( $file ); |
| 354 |
|
| 355 |
if ( is_wp_error( $result ) ) { |
| 356 |
wp_send_json_error( |
| 357 |
array( |
| 358 |
'mess' => $result->get_error_message(), |
| 359 |
) |
| 360 |
); |
| 361 |
} |
| 362 |
wp_send_json_success( |
| 363 |
array( |
| 364 |
'mess' => __( 'Activate success', 'yaycommerce' ), |
| 365 |
) |
| 366 |
); |
| 367 |
} |
| 368 |
} catch ( \Exception $ex ) { |
| 369 |
wp_send_json_error( |
| 370 |
array( |
| 371 |
'mess' => __( 'Error exception.', 'yaycommerce' ), |
| 372 |
array( |
| 373 |
'error' => $ex, |
| 374 |
), |
| 375 |
) |
| 376 |
); |
| 377 |
} catch ( \Error $ex ) { |
| 378 |
wp_send_json_error( |
| 379 |
array( |
| 380 |
'mess' => __( 'Error.', 'yaycommerce' ), |
| 381 |
array( |
| 382 |
'error' => $ex, |
| 383 |
), |
| 384 |
) |
| 385 |
); |
| 386 |
} |
| 387 |
} |
| 388 |
|
| 389 |
public function yay_recommended_upgrade_plugin() { |
| 390 |
try { |
| 391 |
require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; |
| 392 |
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
| 393 |
require_once ABSPATH . 'wp-admin/includes/class-wp-ajax-upgrader-skin.php'; |
| 394 |
require_once ABSPATH . 'wp-admin/includes/class-plugin-upgrader.php'; |
| 395 |
if ( isset( $_POST['plugin'] ) ) { |
| 396 |
$nonce = isset( $_POST['nonce'] ) ? sanitize_text_field( $_POST['nonce'] ) : ''; |
| 397 |
if ( ! wp_verify_nonce( $nonce, 'yay_recommended_nonce' ) ) { |
| 398 |
wp_send_json_error( array( 'mess' => __( 'Nonce is invalid', 'yaycommerce' ) ) ); |
| 399 |
} |
| 400 |
$plugin = sanitize_text_field( $_POST['plugin'] ); |
| 401 |
$type = isset( $_POST['type'] ) ? sanitize_text_field( $_POST['type'] ) : 'install'; |
| 402 |
$skin = new \WP_Ajax_Upgrader_Skin(); |
| 403 |
$upgrader = new \Plugin_Upgrader( $skin ); |
| 404 |
if ( 'install' === $type ) { |
| 405 |
$result = $upgrader->install( $plugin ); |
| 406 |
if ( is_wp_error( $result ) ) { |
| 407 |
wp_send_json_error( |
| 408 |
array( |
| 409 |
'mess' => $result->get_error_message(), |
| 410 |
) |
| 411 |
); |
| 412 |
} |
| 413 |
$args = array( |
| 414 |
'slug' => $upgrader->result['destination_name'], |
| 415 |
'fields' => array( |
| 416 |
'short_description' => true, |
| 417 |
'icons' => true, |
| 418 |
'banners' => false, |
| 419 |
'added' => false, |
| 420 |
'reviews' => false, |
| 421 |
'sections' => false, |
| 422 |
'requires' => false, |
| 423 |
'rating' => false, |
| 424 |
'ratings' => false, |
| 425 |
'downloaded' => false, |
| 426 |
'last_updated' => false, |
| 427 |
'added' => false, |
| 428 |
'tags' => false, |
| 429 |
'compatibility' => false, |
| 430 |
'homepage' => false, |
| 431 |
'donate_link' => false, |
| 432 |
), |
| 433 |
); |
| 434 |
$pluginData = plugins_api( 'plugin_information', $args ); |
| 435 |
if ( $pluginData && ! is_wp_error( $pluginData ) ) { |
| 436 |
$installStatus = install_plugin_install_status( $pluginData ); |
| 437 |
$activePlugin = activate_plugin( $installStatus['file'] ); |
| 438 |
if ( is_wp_error( $activePlugin ) ) { |
| 439 |
wp_send_json_error( |
| 440 |
array( |
| 441 |
'mess' => $activePlugin->get_error_message(), |
| 442 |
) |
| 443 |
); |
| 444 |
} else { |
| 445 |
wp_send_json_success( |
| 446 |
array( |
| 447 |
'mess' => __( 'Install success', 'yaycommerce' ), |
| 448 |
) |
| 449 |
); |
| 450 |
} |
| 451 |
} else { |
| 452 |
wp_send_json_error( |
| 453 |
array( |
| 454 |
'mess' => 'Error', |
| 455 |
) |
| 456 |
); |
| 457 |
} |
| 458 |
} else { |
| 459 |
$is_active = is_plugin_active( $plugin ); |
| 460 |
$result = $upgrader->upgrade( $plugin ); |
| 461 |
if ( is_wp_error( $result ) ) { |
| 462 |
wp_send_json_error( |
| 463 |
array( |
| 464 |
'mess' => $result->get_error_message(), |
| 465 |
) |
| 466 |
); |
| 467 |
} else { |
| 468 |
activate_plugin( $plugin ); |
| 469 |
wp_send_json_success( |
| 470 |
array( |
| 471 |
'mess' => __( 'Update success', 'yaycommerce' ), |
| 472 |
'active' => $is_active, |
| 473 |
) |
| 474 |
); |
| 475 |
} |
| 476 |
} |
| 477 |
} |
| 478 |
} catch ( \Exception $ex ) { |
| 479 |
wp_send_json_error( |
| 480 |
array( |
| 481 |
'mess' => __( 'Error exception.', 'yaycommerce' ), |
| 482 |
array( |
| 483 |
'error' => $ex, |
| 484 |
), |
| 485 |
) |
| 486 |
); |
| 487 |
} catch ( \Error $ex ) { |
| 488 |
wp_send_json_error( |
| 489 |
array( |
| 490 |
'mess' => __( 'Error.', 'yaycommerce' ), |
| 491 |
array( |
| 492 |
'error' => $ex, |
| 493 |
), |
| 494 |
) |
| 495 |
); |
| 496 |
} |
| 497 |
} |
| 498 |
|
| 499 |
public function check_pro_version_exists( $pluginDetail ) { |
| 500 |
$existProVer = false; |
| 501 |
$allPlugin = get_plugins(); |
| 502 |
if ( 'filebird' === $pluginDetail['slug'] ) { |
| 503 |
$existProVer = array_key_exists( 'filebird-pro/filebird.php', $allPlugin ) === true ? 'filebird-pro/filebird.php' : false; |
| 504 |
} |
| 505 |
if ( 'yaymail' === $pluginDetail['slug'] ) { |
| 506 |
if ( array_key_exists( 'yaymail-pro/yaymail.php', $allPlugin ) ) { |
| 507 |
$existProVer = 'yaymail-pro/yaymail.php'; |
| 508 |
} elseif ( array_key_exists( 'email-customizer-for-woocommerce/yaymail.php', $allPlugin ) ) { |
| 509 |
$existProVer = 'email-customizer-for-woocommerce/yaymail.php'; |
| 510 |
} |
| 511 |
} |
| 512 |
if ( 'yaycurrency' === $pluginDetail['slug'] ) { |
| 513 |
if ( array_key_exists( 'yaycurrency-pro/yay-currency.php', $allPlugin ) ) { |
| 514 |
$existProVer = 'yaycurrency-pro/yay-currency.php'; |
| 515 |
} elseif ( array_key_exists( 'multi-currency-switcher/yay-currency.php', $allPlugin ) ) { |
| 516 |
$existProVer = 'multi-currency-switcher/yay-currency.php'; |
| 517 |
} |
| 518 |
} |
| 519 |
if ( 'yaysmtp' === $pluginDetail['slug'] ) { |
| 520 |
$existProVer = array_key_exists( 'yaysmtp-pro/yay-smtp.php', $allPlugin ) === true ? 'yaysmtp-pro/yay-smtp.php' : false; |
| 521 |
} |
| 522 |
if ( 'yayswatches' === $pluginDetail['slug'] ) { |
| 523 |
$existProVer = array_key_exists( 'yayswatches-pro/yay-swatches.php', $allPlugin ) === true ? 'yayswatches-pro/yay-swatches.php' : false; |
| 524 |
} |
| 525 |
if ( 'yayextra' === $pluginDetail['slug'] ) { |
| 526 |
$existProVer = array_key_exists( 'yayextra-pro/yayextra.php', $allPlugin ) === true ? 'yayextra-pro/yayextra.php' : false; |
| 527 |
} |
| 528 |
if ( 'yaypricing' === $pluginDetail['slug'] ) { |
| 529 |
if ( array_key_exists( 'yaypricing-pro/yaypricing.php', $allPlugin ) ) { |
| 530 |
$existProVer = 'yaypricing-pro/yaypricing.php'; |
| 531 |
} elseif ( array_key_exists( 'dynamic-pricing-discounts/yaypricing.php', $allPlugin ) ) { |
| 532 |
$existProVer = 'dynamic-pricing-discounts/yaypricing.php'; |
| 533 |
} |
| 534 |
} |
| 535 |
if ( 'cf7-multi-step' === $pluginDetail['slug'] ) { |
| 536 |
$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; |
| 537 |
} |
| 538 |
if ( 'cf7-database' === $pluginDetail['slug'] ) { |
| 539 |
$existProVer = array_key_exists( 'contact-form-7-database-pro/cf7-database.php', $allPlugin ) === true ? 'contact-form-7-database-pro/cf7-database.php' : false; |
| 540 |
} |
| 541 |
if ( 'wp-whatsapp' === $pluginDetail['slug'] ) { |
| 542 |
$existProVer = array_key_exists( 'whatsapp-for-wordpress/whatsapp.php', $allPlugin ) === true ? 'whatsapp-for-wordpress/whatsapp.php' : false; |
| 543 |
} |
| 544 |
if ( 'parcelpanel' === $pluginDetail['slug'] ) { |
| 545 |
$existProVer = array_key_exists( 'parcelpanel/parcelpanel.php', $allPlugin ) === true ? 'parcelpanel/parcelpanel.php' : false; |
| 546 |
} |
| 547 |
return $existProVer; |
| 548 |
} |
| 549 |
} |
| 550 |
|