| 1 | <?php |
|---|
| 2 | defined( 'ABSPATH' ) || exit; |
|---|
| 3 | |
|---|
| 4 | /** |
|---|
| 5 | * Class WCCT_XL_Support |
|---|
| 6 | * @package Finale-Lite |
|---|
| 7 | * @author XlPlugins |
|---|
| 8 | */ |
|---|
| 9 | #[AllowDynamicProperties] |
|---|
| 10 | class WCCT_XL_Support { |
|---|
| 11 | |
|---|
| 12 | public static $_instance = null; |
|---|
| 13 | public $full_name = WCCT_FULL_NAME; |
|---|
| 14 | public $is_license_needed = false; |
|---|
| 15 | public $license_instance; |
|---|
| 16 | public $expected_url; |
|---|
| 17 | |
|---|
| 18 | /** |
|---|
| 19 | * Options Page title |
|---|
| 20 | * @var string |
|---|
| 21 | */ |
|---|
| 22 | protected $title = 'Sales Triggers'; |
|---|
| 23 | protected $slug = 'wcct'; |
|---|
| 24 | |
|---|
| 25 | public function __construct() { |
|---|
| 26 | $this->expected_url = admin_url( 'admin.php?page=xlplugins' ); |
|---|
| 27 | |
|---|
| 28 | /** |
|---|
| 29 | * XL CORE HOOKS |
|---|
| 30 | */ |
|---|
| 31 | add_filter( 'xl_optin_notif_show', array( $this, 'wcct_xl_show_optin_pages' ), 10, 1 ); |
|---|
| 32 | add_action( 'wp_ajax_xl_addon_installation', array( $this, 'xl_addon_installation' ), 10, 1 ); |
|---|
| 33 | |
|---|
| 34 | add_action( 'admin_init', array( $this, 'wcct_xl_expected_slug' ), 9 ); |
|---|
| 35 | |
|---|
| 36 | add_action( 'admin_init', array( $this, 'modify_api_args_if_wcct_dashboard' ), 20 ); |
|---|
| 37 | add_filter( 'extra_plugin_headers', array( $this, 'extra_woocommerce_headers' ) ); |
|---|
| 38 | |
|---|
| 39 | add_filter( 'add_menu_classes', array( $this, 'modify_menu_classes' ) ); |
|---|
| 40 | |
|---|
| 41 | add_action( 'xl_licenses_submitted', array( $this, 'process_licensing_form' ) ); |
|---|
| 42 | add_action( 'xl_deactivate_request', array( $this, 'maybe_process_deactivation' ) ); |
|---|
| 43 | |
|---|
| 44 | add_filter( 'xl_dashboard_tabs', array( $this, 'wcct_modify_tabs' ), 999, 1 ); |
|---|
| 45 | add_filter( 'xl_after_license_table_notice', array( $this, 'wcct_after_license_table_notice' ), 999, 1 ); |
|---|
| 46 | |
|---|
| 47 | add_action( 'wcct_options_page_right_content', array( $this, 'wcct_options_page_right_content' ), 10 ); |
|---|
| 48 | |
|---|
| 49 | add_action( 'admin_menu', array( $this, 'add_menus' ), 86 ); |
|---|
| 50 | add_action( 'admin_menu', array( $this, 'add_wcct_menu' ), 85 ); |
|---|
| 51 | |
|---|
| 52 | add_action( 'xl_tabs_modal_licenses', array( $this, 'schedule_license_check' ), 1 ); |
|---|
| 53 | add_filter( 'xl_uninstall_reasons', array( $this, 'modify_uninstall_reason' ) ); |
|---|
| 54 | |
|---|
| 55 | add_filter( 'xl_uninstall_reason_threshold_' . WCCT_PLUGIN_BASENAME, function () { |
|---|
| 56 | return 12; |
|---|
| 57 | } ); |
|---|
| 58 | add_filter( 'xl_default_reason_' . WCCT_PLUGIN_BASENAME, function () { |
|---|
| 59 | return 8; |
|---|
| 60 | } ); |
|---|
| 61 | // tools |
|---|
| 62 | add_action( 'xl_fetch_tools_data', array( $this, 'xl_fetch_tools_data' ), 10, 2 ); |
|---|
| 63 | |
|---|
| 64 | add_filter( 'xl_in_update_message_support', array( $this, 'finale_update_message' ), 10 ); |
|---|
| 65 | } |
|---|
| 66 | |
|---|
| 67 | /** |
|---|
| 68 | * @return null|WCCT_XL_Support |
|---|
| 69 | */ |
|---|
| 70 | public static function get_instance() { |
|---|
| 71 | if ( self::$_instance == null ) { |
|---|
| 72 | self::$_instance = new self; |
|---|
| 73 | } |
|---|
| 74 | |
|---|
| 75 | return self::$_instance; |
|---|
| 76 | } |
|---|
| 77 | |
|---|
| 78 | public function wcct_xl_show_optin_pages( $is_show ) { |
|---|
| 79 | return true; |
|---|
| 80 | } |
|---|
| 81 | |
|---|
| 82 | public function wcct_xl_expected_slug() { |
|---|
| 83 | if ( isset( $_GET['page'] ) && ( $_GET['page'] == 'xlplugins' || $_GET['page'] == 'xlplugins-support' || $_GET['page'] == 'xlplugins-addons' ) ) { |
|---|
| 84 | XL_dashboard::set_expected_slug( $this->slug ); |
|---|
| 85 | } |
|---|
| 86 | XL_dashboard::set_expected_url( $this->expected_url ); |
|---|
| 87 | |
|---|
| 88 | /** |
|---|
| 89 | * Pushing notifications for invalid licenses found in ecosystem |
|---|
| 90 | */ |
|---|
| 91 | $licenses = XL_licenses::get_instance()->get_data(); |
|---|
| 92 | $invalid_licenses = array(); |
|---|
| 93 | if ( $licenses && count( $licenses ) > 0 ) { |
|---|
| 94 | foreach ( $licenses as $key => $license ) { |
|---|
| 95 | if ( $license['product_status'] == 'invalid' ) { |
|---|
| 96 | $invalid_licenses[] = $license['plugin']; |
|---|
| 97 | } |
|---|
| 98 | } |
|---|
| 99 | } |
|---|
| 100 | |
|---|
| 101 | if ( ! XL_admin_notifications::has_notification( 'license_needs_attention' ) && count( $invalid_licenses ) > 0 ) { |
|---|
| 102 | $license_invalid_text = sprintf( __( '<p>You are <strong>not receiving</strong> Latest Updates, New Features, Security Updates & Bug Fixes for <strong>%1$s</strong>. <a href="%2$s">Click Here To Fix This</a>.</p>', 'finale-woocommerce-sales-countdown-timer-discount' ), implode( ',', $invalid_licenses ), add_query_arg( array( |
|---|
| 103 | 'tab' => 'licenses', |
|---|
| 104 | ), $this->expected_url ) ); |
|---|
| 105 | |
|---|
| 106 | XL_admin_notifications::add_notification( array( |
|---|
| 107 | 'license_needs_attention' => array( |
|---|
| 108 | 'type' => 'error', |
|---|
| 109 | 'is_dismissable' => false, |
|---|
| 110 | 'content' => $license_invalid_text, |
|---|
| 111 | ), |
|---|
| 112 | ) ); |
|---|
| 113 | } |
|---|
| 114 | } |
|---|
| 115 | |
|---|
| 116 | public function wcct_metabox_always_open( $classes ) { |
|---|
| 117 | if ( ( $key = array_search( 'closed', $classes ) ) !== false ) { |
|---|
| 118 | unset( $classes[ $key ] ); |
|---|
| 119 | } |
|---|
| 120 | |
|---|
| 121 | return $classes; |
|---|
| 122 | } |
|---|
| 123 | |
|---|
| 124 | public function modify_api_args_if_wcct_dashboard() { |
|---|
| 125 | if ( XL_dashboard::get_expected_slug() == $this->slug ) { |
|---|
| 126 | add_filter( 'xl_api_call_agrs', array( $this, 'modify_api_args_for_gravityxl' ) ); |
|---|
| 127 | XL_dashboard::register_dashboard( array( |
|---|
| 128 | 'parent' => array( |
|---|
| 129 | 'woocommerce' => 'WooCommerce Add-ons', |
|---|
| 130 | ), |
|---|
| 131 | 'name' => $this->slug, |
|---|
| 132 | ) ); |
|---|
| 133 | } |
|---|
| 134 | } |
|---|
| 135 | |
|---|
| 136 | public function xlplugins_page() { |
|---|
| 137 | if ( ! isset( $_GET['tab'] ) ) { |
|---|
| 138 | $licenses = apply_filters( 'xl_plugins_license_needed', array() ); |
|---|
| 139 | if ( empty( $licenses ) ) { |
|---|
| 140 | XL_dashboard::$selected = 'support'; |
|---|
| 141 | } else { |
|---|
| 142 | XL_dashboard::$selected = 'licenses'; |
|---|
| 143 | } |
|---|
| 144 | } |
|---|
| 145 | XL_dashboard::load_page(); |
|---|
| 146 | } |
|---|
| 147 | |
|---|
| 148 | public function xlplugins_support_page() { |
|---|
| 149 | if ( ! isset( $_GET['tab'] ) ) { |
|---|
| 150 | XL_dashboard::$selected = 'support'; |
|---|
| 151 | } |
|---|
| 152 | XL_dashboard::load_page(); |
|---|
| 153 | } |
|---|
| 154 | |
|---|
| 155 | public function xlplugins_plugins_page() { |
|---|
| 156 | XL_dashboard::$selected = 'plugins'; |
|---|
| 157 | XL_dashboard::load_page(); |
|---|
| 158 | } |
|---|
| 159 | |
|---|
| 160 | public function modify_api_args_for_gravityxl( $args ) { |
|---|
| 161 | if ( isset( $args['edd_action'] ) && $args['edd_action'] == 'get_xl_plugins' ) { |
|---|
| 162 | $args['attrs']['tax_query'] = array( |
|---|
| 163 | array( |
|---|
| 164 | 'taxonomy' => 'xl_edd_tax_parent', |
|---|
| 165 | 'field' => 'slug', |
|---|
| 166 | 'terms' => 'woocommerce', |
|---|
| 167 | 'operator' => 'IN', |
|---|
| 168 | ), |
|---|
| 169 | ); |
|---|
| 170 | } |
|---|
| 171 | $args['purchase'] = WCCT_PURCHASE; |
|---|
| 172 | |
|---|
| 173 | return $args; |
|---|
| 174 | } |
|---|
| 175 | |
|---|
| 176 | /** |
|---|
| 177 | * Adding XL Header to tell WordPress to read one extra params while reading plugin's header info/. <br/> |
|---|
| 178 | * Hooked over `extra_plugin_headers` |
|---|
| 179 | * |
|---|
| 180 | * @param array $headers already registered arrays |
|---|
| 181 | * |
|---|
| 182 | * @return type |
|---|
| 183 | * @since 1.0.0 |
|---|
| 184 | * |
|---|
| 185 | */ |
|---|
| 186 | public function extra_woocommerce_headers( $headers ) { |
|---|
| 187 | array_push( $headers, 'XL' ); |
|---|
| 188 | |
|---|
| 189 | return $headers; |
|---|
| 190 | } |
|---|
| 191 | |
|---|
| 192 | public function modify_menu_classes( $menu ) { |
|---|
| 193 | return $menu; |
|---|
| 194 | } |
|---|
| 195 | |
|---|
| 196 | public function process_licensing_form( $posted_data ) { |
|---|
| 197 | if ( isset( $posted_data['license_keys'][ WCCT_PLUGIN_BASENAME ] ) ) { |
|---|
| 198 | $shortname = $this->edd_slugify_module_name( $this->full_name ); |
|---|
| 199 | update_option( 'xl_licenses_' . $shortname, $posted_data['license_keys'][ WCCT_PLUGIN_BASENAME ], false ); |
|---|
| 200 | $this->license_instance->activate_license( $posted_data['license_keys'][ WCCT_PLUGIN_BASENAME ] ); |
|---|
| 201 | } |
|---|
| 202 | } |
|---|
| 203 | |
|---|
| 204 | /** |
|---|
| 205 | * License management helper function to create a slug that is friendly with edd |
|---|
| 206 | * |
|---|
| 207 | * @param $name |
|---|
| 208 | * |
|---|
| 209 | * @return string |
|---|
| 210 | */ |
|---|
| 211 | public function edd_slugify_module_name( $name ) { |
|---|
| 212 | return preg_replace( '/[^a-zA-Z0-9_\s]/', '', str_replace( ' ', '_', strtolower( $name ) ) ); |
|---|
| 213 | } |
|---|
| 214 | |
|---|
| 215 | /** |
|---|
| 216 | * Validate is it is for email product deactivation |
|---|
| 217 | * |
|---|
| 218 | * @param $posted_data |
|---|
| 219 | */ |
|---|
| 220 | public function maybe_process_deactivation( $posted_data ) { |
|---|
| 221 | if ( isset( $posted_data['filepath'] ) && $posted_data['filepath'] === WCCT_PLUGIN_BASENAME ) { |
|---|
| 222 | $this->license_instance->deactivate_license(); |
|---|
| 223 | wp_safe_redirect( 'admin.php?page=' . $posted_data['page'] . '&tab=' . $posted_data['tab'] ); |
|---|
| 224 | } |
|---|
| 225 | } |
|---|
| 226 | |
|---|
| 227 | public function wcct_modify_tabs( $tabs ) { |
|---|
| 228 | if ( $this->slug === XL_dashboard::get_expected_slug() ) { |
|---|
| 229 | return array(); |
|---|
| 230 | } |
|---|
| 231 | |
|---|
| 232 | return $tabs; |
|---|
| 233 | } |
|---|
| 234 | |
|---|
| 235 | public function wcct_after_license_table_notice( $notice ) { |
|---|
| 236 | return 'Note: You need to have a valid license key to receiving updates for these plugins. Click here to get your <a href="https://xlplugins.com/manage-licenses/" target="_blank">License Keys</a>.'; |
|---|
| 237 | } |
|---|
| 238 | |
|---|
| 239 | /** |
|---|
| 240 | * Adding WooCommerce sub-menu for global options |
|---|
| 241 | */ |
|---|
| 242 | public function add_menus() { |
|---|
| 243 | if ( ! XL_dashboard::$is_core_menu ) { |
|---|
| 244 | |
|---|
| 245 | add_menu_page( __( 'XLPlugins', 'finale-woocommerce-sales-countdown-timer-discount' ), __( 'XLPlugins', 'finale-woocommerce-sales-countdown-timer-discount' ), 'manage_woocommerce', 'xlplugins', array( |
|---|
| 246 | $this, |
|---|
| 247 | 'xlplugins_page', |
|---|
| 248 | ), '', '59.5' ); |
|---|
| 249 | if ( ! class_exists( 'FKWCS_Gateway_Stripe' ) ) { |
|---|
| 250 | add_submenu_page( 'xlplugins', 'Payments', esc_html__( 'Payments', 'woo-thank-you-page-nextmove-lite' ), // Title. |
|---|
| 251 | 'manage_woocommerce', 'xl-payments', array( $this, 'xl_stripe' ) ); |
|---|
| 252 | } |
|---|
| 253 | if ( ! defined( 'FKCART_VERSION' ) ) { |
|---|
| 254 | add_submenu_page( 'xlplugins', 'Cart', esc_html__( 'Cart', 'woo-thank-you-page-nextmove-lite' ), // Title. |
|---|
| 255 | 'manage_options', 'xl-cart', // slug url. |
|---|
| 256 | array( $this, 'xl_cart' ) ); |
|---|
| 257 | } |
|---|
| 258 | if ( ! class_exists( 'WFFN_Core' ) ) { |
|---|
| 259 | add_submenu_page( 'xlplugins', 'Checkout', esc_html__( 'Checkout', 'woo-thank-you-page-nextmove-lite' ), // Title. |
|---|
| 260 | 'manage_options', 'xl-checkout', // slug url. |
|---|
| 261 | array( $this, 'xl_checkout' ) ); |
|---|
| 262 | } |
|---|
| 263 | if ( ! class_exists( 'BWFAN_Core' ) ) { |
|---|
| 264 | add_submenu_page( 'xlplugins', 'Automation', esc_html__( 'Automations', 'woo-thank-you-page-nextmove-lite' ), // Title. |
|---|
| 265 | 'manage_woocommerce', 'xl-automations', array( $this, 'xl_automation' ) ); |
|---|
| 266 | } |
|---|
| 267 | |
|---|
| 268 | $licenses = apply_filters( 'xl_plugins_license_needed', array() ); |
|---|
| 269 | if ( ! empty( $licenses ) ) { |
|---|
| 270 | add_submenu_page( 'xlplugins', __( 'Licenses', 'finale-woocommerce-sales-countdown-timer-discount' ), __( 'License', 'finale-woocommerce-sales-countdown-timer-discount' ), 'manage_woocommerce', 'xlplugins' ); |
|---|
| 271 | } |
|---|
| 272 | |
|---|
| 273 | XL_dashboard::$is_core_menu = true; |
|---|
| 274 | } |
|---|
| 275 | } |
|---|
| 276 | |
|---|
| 277 | public function add_wcct_menu() { |
|---|
| 278 | add_submenu_page( 'xlplugins', WCCT_FULL_NAME, 'Finale Lite', 'manage_woocommerce', 'admin.php?page=wc-settings&tab=' . WCCT_Common::get_wc_settings_tab_slug() . '', false ); |
|---|
| 279 | } |
|---|
| 280 | |
|---|
| 281 | public function xl_checkout() { |
|---|
| 282 | include_once WCCT_PLUGIN_DIR . '/admin/includes/pages/xl-checkout.php'; |
|---|
| 283 | XL_Addon_Install_Checkout::render(); |
|---|
| 284 | } |
|---|
| 285 | |
|---|
| 286 | public function xl_automation() { |
|---|
| 287 | include_once WCCT_PLUGIN_DIR . '/admin/includes/pages/xl-automation.php'; |
|---|
| 288 | XL_Addon_Install_Automation::render(); |
|---|
| 289 | } |
|---|
| 290 | |
|---|
| 291 | public function xl_stripe() { |
|---|
| 292 | include_once WCCT_PLUGIN_DIR . '/admin/includes/pages/xl-stripe.php'; |
|---|
| 293 | XL_Addon_Install_Stripe::render(); |
|---|
| 294 | } |
|---|
| 295 | |
|---|
| 296 | public function xl_cart() { |
|---|
| 297 | include_once WCCT_PLUGIN_DIR . '/admin/includes/pages/xl-cart.php'; |
|---|
| 298 | XL_Addon_Install_Cart::render(); |
|---|
| 299 | } |
|---|
| 300 | |
|---|
| 301 | public function wcct_options_page_right_content() { |
|---|
| 302 | $get_instance_access_link = add_query_arg( array( |
|---|
| 303 | 'utm_source' => 'finale-lite', |
|---|
| 304 | 'utm_medium' => 'sidebar', |
|---|
| 305 | 'utm_campaign' => 'ebook-download', |
|---|
| 306 | 'utm_term' => '13-promotional-campaign-ideas', |
|---|
| 307 | ), 'https://xlplugins.com/high-converting-woocommerce-sales-promotional-campaigs/' ); |
|---|
| 308 | $go_pro_link = add_query_arg( array( |
|---|
| 309 | 'utm_source' => 'finale-lite', |
|---|
| 310 | 'utm_medium' => 'sidebar', |
|---|
| 311 | 'utm_campaign' => 'plugin-resource', |
|---|
| 312 | 'utm_term' => 'buy_now', |
|---|
| 313 | ), 'https://xlplugins.com/lite-to-pro-upgrade-page/' ); |
|---|
| 314 | $demo_link = add_query_arg( array( |
|---|
| 315 | 'utm_source' => 'finale-lite', |
|---|
| 316 | 'utm_medium' => 'sidebar', |
|---|
| 317 | 'utm_campaign' => 'plugin-resource', |
|---|
| 318 | 'utm_term' => 'demo', |
|---|
| 319 | ), 'http://demo.xlplugins.com/finale/' ); |
|---|
| 320 | $support_link = add_query_arg( array( |
|---|
| 321 | 'pro' => 'finale', |
|---|
| 322 | 'utm_source' => 'finale-lite', |
|---|
| 323 | 'utm_medium' => 'sidebar', |
|---|
| 324 | 'utm_campaign' => 'plugin-resource', |
|---|
| 325 | 'utm_term' => 'support', |
|---|
| 326 | ), 'https://xlplugins.com/support/' ); |
|---|
| 327 | $documentation_link = add_query_arg( array( |
|---|
| 328 | 'utm_source' => 'finale-lite', |
|---|
| 329 | 'utm_medium' => 'sidebar', |
|---|
| 330 | 'utm_campaign' => 'plugin-resource', |
|---|
| 331 | 'utm_term' => 'documentation', |
|---|
| 332 | ), 'https://xlplugins.com/documentation/' ); |
|---|
| 333 | |
|---|
| 334 | $other_products = array(); |
|---|
| 335 | |
|---|
| 336 | /** Finale */ |
|---|
| 337 | $finale_link = add_query_arg( array( |
|---|
| 338 | 'utm_source' => 'finale-lite', |
|---|
| 339 | 'utm_medium' => 'sidebar', |
|---|
| 340 | 'utm_campaign' => 'other-products', |
|---|
| 341 | 'utm_term' => 'finale', |
|---|
| 342 | ), 'https://xlplugins.com/finale-woocommerce-sales-countdown-timer-discount-plugin/' ); |
|---|
| 343 | if ( ! class_exists( 'WCCT_Core' ) ) { |
|---|
| 344 | $other_products['finale'] = array( |
|---|
| 345 | 'image' => 'finale.png', |
|---|
| 346 | 'link' => $finale_link, |
|---|
| 347 | 'head' => 'Finale WooCommerce Sales Countdown Timer', |
|---|
| 348 | 'desc' => 'Run Urgency Marketing Campaigns On Your Store And Move Buyers to Make A Purchase', |
|---|
| 349 | ); |
|---|
| 350 | } |
|---|
| 351 | |
|---|
| 352 | /** Sales Trigger */ |
|---|
| 353 | $sales_trigger_link = add_query_arg( array( |
|---|
| 354 | 'utm_source' => 'finale-lite', |
|---|
| 355 | 'utm_medium' => 'sidebar', |
|---|
| 356 | 'utm_campaign' => 'other-products', |
|---|
| 357 | 'utm_term' => 'sales-trigger', |
|---|
| 358 | ), 'https://xlplugins.com/woocommerce-sales-triggers/' ); |
|---|
| 359 | if ( ! defined( 'WCST_SLUG' ) ) { |
|---|
| 360 | $other_products['sales_trigger'] = array( |
|---|
| 361 | 'image' => 'sales-trigger.png', |
|---|
| 362 | 'link' => $sales_trigger_link, |
|---|
| 363 | 'head' => 'XL WooCommerce Sales Triggers', |
|---|
| 364 | 'desc' => 'Use 7 Built-in Sales Triggers to Optimise Single Product Pages For More Conversions', |
|---|
| 365 | ); |
|---|
| 366 | } |
|---|
| 367 | |
|---|
| 368 | /** NextMove */ |
|---|
| 369 | $nextmove_link = add_query_arg( array( |
|---|
| 370 | 'utm_source' => 'finale-lite', |
|---|
| 371 | 'utm_medium' => 'sidebar', |
|---|
| 372 | 'utm_campaign' => 'other-products', |
|---|
| 373 | 'utm_term' => 'nextmove', |
|---|
| 374 | ), 'https://xlplugins.com/woocommerce-thank-you-page-nextmove/' ); |
|---|
| 375 | if ( ! class_exists( 'XLWCTY_Core' ) ) { |
|---|
| 376 | $other_products['nextmove'] = array( |
|---|
| 377 | 'image' => 'nextmove.png', |
|---|
| 378 | 'link' => $nextmove_link, |
|---|
| 379 | 'head' => 'NextMove WooCommerce Thank You Pages', |
|---|
| 380 | 'desc' => 'Get More Repeat Orders With 17 Plug n Play Components', |
|---|
| 381 | ); |
|---|
| 382 | } |
|---|
| 383 | |
|---|
| 384 | if ( is_array( $other_products ) && count( $other_products ) > 0 ) { |
|---|
| 385 | $offer_link = add_query_arg( array( |
|---|
| 386 | 'utm_source' => 'finale-lite', |
|---|
| 387 | 'utm_medium' => 'sidebar', |
|---|
| 388 | 'utm_campaign' => 'other-products', |
|---|
| 389 | 'utm_term' => 'easter-offer', |
|---|
| 390 | ), 'https://xlplugins.com/exclusive-offers/' ); |
|---|
| 391 | $bundle_link = add_query_arg( array( |
|---|
| 392 | 'utm_source' => 'finale-lite', |
|---|
| 393 | 'utm_medium' => 'sidebar', |
|---|
| 394 | 'utm_campaign' => 'other-products', |
|---|
| 395 | 'utm_term' => 'exclusive-bundle', |
|---|
| 396 | ), 'https://xlplugins.com/exclusive-offers/' ); |
|---|
| 397 | $easter_offer = false; |
|---|
| 398 | if ( date( 'Ymd' ) > 20180320 && date( 'Ymd' ) < 20180403 ) { |
|---|
| 399 | $easter_offer = true; |
|---|
| 400 | } |
|---|
| 401 | |
|---|
| 402 | if ( true === $easter_offer ) { |
|---|
| 403 | ?> |
|---|
| 404 | <h3>Checkout Offer & Plugins:</h3> |
|---|
| 405 | <div class="postbox wcct_side_content wcct_xlplugins wcct_xlplugins_easter_offer"> |
|---|
| 406 | <a href="<?php echo $offer_link; ?>" target="_blank"></a> |
|---|
| 407 | <img src="<?php echo plugin_dir_url( WCCT_PLUGIN_FILE ) . 'admin/assets/img/easter.png'; ?>"/> |
|---|
| 408 | <div class="wcct_plugin_head">EASTER SPL.: UPTO 20% OFF!</div> |
|---|
| 409 | <div class="wcct_plugin_desc">Upgrade yourself to the full-feature plan or buy the plugin bundle at a hugely discounted price! Click here.</div> |
|---|
| 410 | </div> |
|---|
| 411 | <?php |
|---|
| 412 | } else { |
|---|
| 413 | $bundle_text = 'Get up to <strong><u>20% off</u></strong> on our bundles. Club our best-seller Finale with our other conversion-lifting plugins.<br>Act fast!'; |
|---|
| 414 | |
|---|
| 415 | $current_date_obj = new DateTime( 'now', new DateTimeZone( 'America/New_York' ) ); |
|---|
| 416 | /** Black friday */ |
|---|
| 417 | if ( $current_date_obj->getTimestamp() > 1542945600 && $current_date_obj->getTimestamp() < 1543550400 ) { |
|---|
| 418 | $bundle_text = 'Get flat <strong><u>30% off</u></strong> on our bundles. Club our best-seller Finale with our other conversion-lifting plugins.<br>Act fast!'; |
|---|
| 419 | } /** Christmas */ elseif ( $current_date_obj->getTimestamp() > 1545278400 && $current_date_obj->getTimestamp() < 1546401600 ) { |
|---|
| 420 | $bundle_text = 'Get flat <strong><u>25% off</u></strong> on our bundles. Club our best-seller Finale with our other conversion-lifting plugins.<br>Act fast!'; |
|---|
| 421 | } |
|---|
| 422 | ?> |
|---|
| 423 | <h3>Conversion Essentials Bundle</h3> |
|---|
| 424 | <div class="postbox wcct_side_content wcct_xlplugins wcct_xlplugins_bundle"> |
|---|
| 425 | <a href="<?php echo $bundle_link; ?>" target="_blank"></a> |
|---|
| 426 | <img src="<?php echo plugin_dir_url( WCCT_PLUGIN_FILE ) . 'admin/assets/img/special-offers.png'; ?>"> |
|---|
| 427 | <div class="wcct_plugin_head">Considering Finale? Here's a great deal for you!</div> |
|---|
| 428 | <div class="wcct_plugin_desc"><?php echo $bundle_text; ?></div> |
|---|
| 429 | </div> |
|---|
| 430 | <h3>Unlock Premium Finale Features</h3> |
|---|
| 431 | <div class="postbox wcct_side_content wcct_xlplugins wcct_xlplugins_finale"> |
|---|
| 432 | <a href="<?php echo $finale_link; ?>" target="_blank"></a> |
|---|
| 433 | <img src="<?php echo plugin_dir_url( WCCT_PLUGIN_FILE ) . 'admin/assets/img/finale.png'; ?>"> |
|---|
| 434 | <div class="wcct_plugin_desc">Now create Recurring and Evergreen campaigns too! Or set up dedicated Deals pages, Sticky Header and Footer and more. Create Campaigns that convert |
|---|
| 435 | with Finale Pro. |
|---|
| 436 | </div> |
|---|
| 437 | </div> |
|---|
| 438 | <h3>Checkout Our Other Plugins</h3> |
|---|
| 439 | <?php |
|---|
| 440 | } |
|---|
| 441 | foreach ( $other_products as $product_short_name => $product_data ) { |
|---|
| 442 | ?> |
|---|
| 443 | <div class="postbox wcct_side_content wcct_xlplugins wcct_xlplugins_<?php echo $product_short_name; ?>"> |
|---|
| 444 | <a href="<?php echo $product_data['link']; ?>" target="_blank"></a> |
|---|
| 445 | <img src="<?php echo plugin_dir_url( WCCT_PLUGIN_FILE ) . 'admin/assets/img/' . $product_data['image']; ?>"/> |
|---|
| 446 | <div class="wcct_plugin_head"><?php echo $product_data['head']; ?></div> |
|---|
| 447 | <div class="wcct_plugin_desc"><?php echo $product_data['desc']; ?></div> |
|---|
| 448 | </div> |
|---|
| 449 | <?php |
|---|
| 450 | } |
|---|
| 451 | ?> |
|---|
| 452 | <?php |
|---|
| 453 | } |
|---|
| 454 | ?> |
|---|
| 455 | <div class="postbox wcct_side_content"> |
|---|
| 456 | <div class="inside"> |
|---|
| 457 | <h3>Resources</h3> |
|---|
| 458 | <ul> |
|---|
| 459 | <li><a href="<?php echo $go_pro_link; ?>" target="_blank">Get PRO</a></li> |
|---|
| 460 | <li><a href="<?php echo $demo_link; ?>" target="_blank">Demo</a></li> |
|---|
| 461 | <li><a href="<?php echo $support_link; ?>" target="_blank">Support</a></li> |
|---|
| 462 | <li><a href="<?php echo $documentation_link; ?>" target="_blank">Documentation</a></li> |
|---|
| 463 | </ul> |
|---|
| 464 | </div> |
|---|
| 465 | </div> |
|---|
| 466 | <?php |
|---|
| 467 | } |
|---|
| 468 | |
|---|
| 469 | public function schedule_license_check() { |
|---|
| 470 | wp_schedule_single_event( time() + 10, 'wcct_maybe_schedule_check_license' ); |
|---|
| 471 | } |
|---|
| 472 | |
|---|
| 473 | public function modify_uninstall_reason( $reasons ) { |
|---|
| 474 | $reasons_our = $reasons; |
|---|
| 475 | |
|---|
| 476 | $reason_other = array( |
|---|
| 477 | 'id' => 7, |
|---|
| 478 | 'text' => __( 'Other', 'finale-woocommerce-sales-countdown-timer-discount' ), |
|---|
| 479 | 'input_type' => 'textfield', |
|---|
| 480 | 'input_placeholder' => __( 'Other', 'finale-woocommerce-sales-countdown-timer-discount' ), |
|---|
| 481 | ); |
|---|
| 482 | |
|---|
| 483 | $countdown_timer_debug_doc_link = add_query_arg( array( |
|---|
| 484 | 'utm_source' => 'finale-lite', |
|---|
| 485 | 'utm_medium' => 'deactivation-modal', |
|---|
| 486 | 'utm_term' => 'timer-bar-not-showing', |
|---|
| 487 | ), 'https://xlplugins.com/documentation/finale-woocommerce-sales-countdown-timer-scheduler-documentation/troubleshooting-guides/unable-to-see-countdown-timer-or-counter-bar/' ); |
|---|
| 488 | |
|---|
| 489 | $explore_feature_link = add_query_arg( array( |
|---|
| 490 | 'utm_source' => 'finale-lite', |
|---|
| 491 | 'utm_medium' => 'deactivation-modal', |
|---|
| 492 | 'utm_term' => 'explore-finale', |
|---|
| 493 | ), 'https://xlplugins.com/finale-woocommerce-sales-countdown-timer-discount-plugin/' ); |
|---|
| 494 | |
|---|
| 495 | $supoort_ticket_link = admin_url( 'admin.php?page=xlplugins' ); |
|---|
| 496 | |
|---|
| 497 | $product_position_mismatch_link = add_query_arg( array( |
|---|
| 498 | 'utm_source' => 'finale-lite', |
|---|
| 499 | 'utm_medium' => 'deactivation-modal', |
|---|
| 500 | 'utm_term' => 'timer-bar-position-mismatch', |
|---|
| 501 | ), 'https://xlplugins.com/documentation/finale-woocommerce-sales-countdown-timer-scheduler-documentation/troubleshooting-guides/countdown-timer-or-counter-bar-render-at-wrong-positions/' ); |
|---|
| 502 | |
|---|
| 503 | $xl_contact_link = add_query_arg( array( |
|---|
| 504 | 'utm_source' => 'finale-lite', |
|---|
| 505 | 'utm_medium' => 'deactivation-modal', |
|---|
| 506 | 'utm_term' => 'contact', |
|---|
| 507 | ), 'https://xlplugins.com/contact/' ); |
|---|
| 508 | |
|---|
| 509 | $reasons_our[ WCCT_PLUGIN_BASENAME ] = array( |
|---|
| 510 | array( |
|---|
| 511 | 'id' => 8, |
|---|
| 512 | 'text' => __( 'I am going to upgrade to PRO version', 'finale-woocommerce-sales-countdown-timer-discount' ), |
|---|
| 513 | 'input_type' => '', |
|---|
| 514 | 'input_placeholder' => '', |
|---|
| 515 | 'html' => __( "Smart choice! Finale PRO has tons of additional features to boost your revenue. <a href='" . $explore_feature_link . "' target='_blank'>Explore the features</a>.", 'finale-woocommerce-sales-countdown-timer-discount' ), |
|---|
| 516 | ), |
|---|
| 517 | |
|---|
| 518 | array( |
|---|
| 519 | 'id' => 29, |
|---|
| 520 | 'text' => __( 'Countdown Timer or Counter Bar didn\'t show even while campaign was running', 'finale-woocommerce-sales-countdown-timer-discount' ), |
|---|
| 521 | 'input_type' => '', |
|---|
| 522 | 'input_placeholder' => '', |
|---|
| 523 | 'html' => __( 'There could be multiple reasons for this. Take 2 mins and read <a href="' . $countdown_timer_debug_doc_link . '" target="_blank">step by step guide</a> to get resolution.', 'finale-woocommerce-sales-countdown-timer-discount' ), |
|---|
| 524 | ), |
|---|
| 525 | array( |
|---|
| 526 | 'id' => 30, |
|---|
| 527 | 'text' => __( 'Expected discount amount didn\'t appear', 'finale-woocommerce-sales-countdown-timer-discount' ), |
|---|
| 528 | 'input_type' => '', |
|---|
| 529 | 'input_placeholder' => '', |
|---|
| 530 | 'html' => __( 'There could be a caching plugin, try clearing Cache.<br/>OR you could be using other plugins that modify pricing such as currency switcher, discounting plugin, etc. Then Raise a <a href="' . $supoort_ticket_link . '">Support ticket</a> and will try & help resolve this.', 'finale-woocommerce-sales-countdown-timer-discount' ), |
|---|
| 531 | ), |
|---|
| 532 | array( |
|---|
| 533 | 'id' => 31, |
|---|
| 534 | 'text' => __( 'Campaigns were not restricted as per rules', 'finale-woocommerce-sales-countdown-timer-discount' ), |
|---|
| 535 | 'input_type' => '', |
|---|
| 536 | 'input_placeholder' => '', |
|---|
| 537 | 'html' => __( 'Raise a <a href="' . $supoort_ticket_link . '">Support ticket</a> with the screenshot of rules settings and will help you resolve this.', 'finale-woocommerce-sales-countdown-timer-discount' ), |
|---|
| 538 | ), |
|---|
| 539 | array( |
|---|
| 540 | 'id' => 32, |
|---|
| 541 | 'text' => __( 'Countdown Timer or Counter Bar didn\'t appear at right positions', 'finale-woocommerce-sales-countdown-timer-discount' ), |
|---|
| 542 | 'input_type' => '', |
|---|
| 543 | 'input_placeholder' => '', |
|---|
| 544 | 'html' => __( 'It seems your theme modified the native WooCommerce positions. Take 2 mins and read <a href="' . $product_position_mismatch_link . '" target="_blank">step by step guide</a> to get resolution.', 'finale-woocommerce-sales-countdown-timer-discount' ), |
|---|
| 545 | ), |
|---|
| 546 | array( |
|---|
| 547 | 'id' => 33, |
|---|
| 548 | 'text' => __( 'Finale Activation caused PHP Errors or blank white screen', 'finale-woocommerce-sales-countdown-timer-discount' ), |
|---|
| 549 | 'input_type' => '', |
|---|
| 550 | 'input_placeholder' => '', |
|---|
| 551 | 'html' => __( 'Ensure you have the latest version of WooCommerce & Finale. There could be a possibility of conflict with other plugins. Raise a <a href="' . $supoort_ticket_link . '">Support ticket</a> and will help you resolve this.', 'finale-woocommerce-sales-countdown-timer-discount' ), |
|---|
| 552 | ), |
|---|
| 553 | array( |
|---|
| 554 | 'id' => 34, |
|---|
| 555 | 'text' => __( 'Add to Cart wasn\'t working', 'finale-woocommerce-sales-countdown-timer-discount' ), |
|---|
| 556 | 'input_type' => '', |
|---|
| 557 | 'input_placeholder' => '', |
|---|
| 558 | 'html' => __( 'Check Finale\'s Inventory settings or see if you have order with \'Pending Payment\' state. As they may block product inventory.', 'finale-woocommerce-sales-countdown-timer-discount' ), |
|---|
| 559 | ), |
|---|
| 560 | array( |
|---|
| 561 | 'id' => 41, |
|---|
| 562 | 'text' => __( 'Troubleshooting conflicts with other plugins', 'finale-woocommerce-sales-countdown-timer-discount' ), |
|---|
| 563 | 'input_type' => '', |
|---|
| 564 | 'input_placeholder' => '', |
|---|
| 565 | 'html' => __( 'Hope you could resolve conflicts soon.', 'finale-woocommerce-sales-countdown-timer-discount' ), |
|---|
| 566 | ), |
|---|
| 567 | array( |
|---|
| 568 | 'id' => 35, |
|---|
| 569 | 'text' => __( 'Doing Testing', 'finale-woocommerce-sales-countdown-timer-discount' ), |
|---|
| 570 | 'input_type' => '', |
|---|
| 571 | 'input_placeholder' => '', |
|---|
| 572 | 'html' => __( 'Hope to see you using it again.', 'finale-woocommerce-sales-countdown-timer-discount' ), |
|---|
| 573 | ), |
|---|
| 574 | array( |
|---|
| 575 | 'id' => 1, |
|---|
| 576 | 'text' => __( 'I no longer need the plugin', 'finale-woocommerce-sales-countdown-timer-discount' ), |
|---|
| 577 | 'input_type' => '', |
|---|
| 578 | 'input_placeholder' => '', |
|---|
| 579 | 'html' => __( 'Sorry to know that! How can we better your experience? We may be able to fix what we are aware of. Please <a href="' . $xl_contact_link . '" target="_blank">let us know</a>.', 'finale-woocommerce-sales-countdown-timer-discount' ), |
|---|
| 580 | ), |
|---|
| 581 | ); |
|---|
| 582 | |
|---|
| 583 | array_push( $reasons_our[ WCCT_PLUGIN_BASENAME ], $reason_other ); |
|---|
| 584 | |
|---|
| 585 | return $reasons_our; |
|---|
| 586 | } |
|---|
| 587 | |
|---|
| 588 | public function xl_support_system_info( $return = false ) { |
|---|
| 589 | $setting_report = array(); |
|---|
| 590 | $nm_options = array(); |
|---|
| 591 | $setting_report[] = '#### Finale Lite Settings start here ####'; |
|---|
| 592 | |
|---|
| 593 | $free_shipping = $this->get_shipping_method(); |
|---|
| 594 | if ( is_array( $free_shipping ) && count( $free_shipping ) > 0 ) { |
|---|
| 595 | $nm_options['free_coupon_method'] = $free_shipping; |
|---|
| 596 | $setting_report[] = "\r***Avaiable Free Shipping Method***\r"; |
|---|
| 597 | foreach ( $free_shipping as $sk => $shipping ) { |
|---|
| 598 | $sk ++; |
|---|
| 599 | $setting_report[] = "\t{$sk} title - {$shipping["title"]} "; |
|---|
| 600 | $setting_report[] = "\trequires - {$shipping["requires"]} "; |
|---|
| 601 | $setting_report[] = "\tmin_amount - {$shipping["min_amount"]} \r"; |
|---|
| 602 | } |
|---|
| 603 | } |
|---|
| 604 | |
|---|
| 605 | $free_shipping_coupon = $this->get_free_shipping_coupon(); |
|---|
| 606 | if ( is_array( $free_shipping_coupon ) && count( $free_shipping_coupon ) > 0 ) { |
|---|
| 607 | $nm_options['free_coupon_method_coupons'] = $free_shipping_coupon; |
|---|
| 608 | $setting_report[] = "\r***Avaiable Free Shipping Method Coupons (recent 10 only)*** \r"; |
|---|
| 609 | foreach ( $free_shipping_coupon as $sk => $shipping_coupon ) { |
|---|
| 610 | $setting_report[] = "\tcoupon id-{$shipping_coupon["id"]} "; |
|---|
| 611 | if ( isset( $shipping_coupon['date_expires'] ) && $shipping_coupon['date_expires'] != '' ) { |
|---|
| 612 | $date_expires = gmdate( 'Y-m-d', $shipping_coupon['date_expires'] ); |
|---|
| 613 | $setting_report[] = "\tdate_expires - {$date_expires} (yy-mm-dd)"; |
|---|
| 614 | } |
|---|
| 615 | if ( isset( $shipping_coupon['expiry_date'] ) && $shipping_coupon['expiry_date'] != '' ) { |
|---|
| 616 | $setting_report[] = "\texpiry_date - {$shipping_coupon["expiry_date"]} "; |
|---|
| 617 | } |
|---|
| 618 | if ( isset( $shipping_coupon['coupon_code'] ) && $shipping_coupon['coupon_code'] != '' ) { |
|---|
| 619 | $setting_report[] = "\tcoupon_code - {$shipping_coupon["coupon_code"]} \r"; |
|---|
| 620 | } |
|---|
| 621 | } |
|---|
| 622 | } |
|---|
| 623 | |
|---|
| 624 | if ( $return ) { |
|---|
| 625 | return array( |
|---|
| 626 | 'finale_settings' => $nm_options, |
|---|
| 627 | ); |
|---|
| 628 | |
|---|
| 629 | } |
|---|
| 630 | |
|---|
| 631 | $setting_report[] = '#### Finale Lite Settings end here ####'; |
|---|
| 632 | |
|---|
| 633 | return implode( "\r", $setting_report ); |
|---|
| 634 | } |
|---|
| 635 | |
|---|
| 636 | public function get_shipping_method() { |
|---|
| 637 | global $wpdb; |
|---|
| 638 | $output = array(); |
|---|
| 639 | $freeMethod = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}woocommerce_shipping_zone_methods WHERE method_id = %s", 'free_shipping' ), ARRAY_A ); |
|---|
| 640 | if ( is_array( $freeMethod ) && count( $freeMethod ) > 0 ) { |
|---|
| 641 | foreach ( $freeMethod as $method ) { |
|---|
| 642 | $free_shipping = get_option( "woocommerce_free_shipping_{$method["method_order"]}_settings", array() ); |
|---|
| 643 | if ( is_array( $free_shipping ) && count( $free_shipping ) > 0 ) { |
|---|
| 644 | $output[] = $free_shipping; |
|---|
| 645 | } |
|---|
| 646 | } |
|---|
| 647 | } |
|---|
| 648 | |
|---|
| 649 | return $output; |
|---|
| 650 | |
|---|
| 651 | } |
|---|
| 652 | |
|---|
| 653 | public function get_free_shipping_coupon() { |
|---|
| 654 | global $wpdb; |
|---|
| 655 | $where = $wpdb->prepare( "WHERE m.meta_key = %s AND m.meta_value = %s AND p.post_type = %s AND p.post_status = %s", 'free_shipping', 'yes', 'shop_coupon', 'publish' ); |
|---|
| 656 | $free_coupon = $wpdb->get_results( "SELECT p.id, p.post_title FROM {$wpdb->prefix}postmeta as m JOIN {$wpdb->prefix}posts as p ON m.post_id = p.id $where ORDER BY p.post_date DESC LIMIT 10", ARRAY_A ); |
|---|
| 657 | if ( is_array( $free_coupon ) && count( $free_coupon ) > 0 ) { |
|---|
| 658 | foreach ( $free_coupon as $key => $value ) { |
|---|
| 659 | $date_expires = get_post_meta( $value['id'], 'date_expires', true ); |
|---|
| 660 | $expiry_date = get_post_meta( $value['id'], 'expiry_date', true ); |
|---|
| 661 | $free_coupon[ $key ]['date_expires'] = $date_expires; |
|---|
| 662 | $free_coupon[ $key ]['expiry_date'] = $expiry_date; |
|---|
| 663 | $post_title = $free_coupon[ $key ]['post_title']; |
|---|
| 664 | unset( $free_coupon[ $key ]['post_title'] ); |
|---|
| 665 | $free_coupon[ $key ]['coupon_code'] = $post_title; |
|---|
| 666 | } |
|---|
| 667 | } |
|---|
| 668 | |
|---|
| 669 | return $free_coupon; |
|---|
| 670 | } |
|---|
| 671 | |
|---|
| 672 | public function xl_fetch_tools_data( $file, $post ) { |
|---|
| 673 | |
|---|
| 674 | if ( $file == 'finale-woocommerce-sales-countdown-timer-discount-plugin-lite.php' ) { |
|---|
| 675 | $xl_support_url = ''; |
|---|
| 676 | $system_info = XL_Support::get_instance()->prepare_system_information_report( true ) + $this->xl_support_system_info( true ); |
|---|
| 677 | $upload_dir = wp_upload_dir(); |
|---|
| 678 | $basedir = $upload_dir['basedir']; |
|---|
| 679 | $baseurl = $upload_dir['baseurl']; |
|---|
| 680 | if ( is_writable( $basedir ) ) { |
|---|
| 681 | $xl_support = $basedir . '/xl_support'; |
|---|
| 682 | $xl_support_url = $baseurl . '/xl_support'; |
|---|
| 683 | if ( ! file_exists( $xl_support ) ) { |
|---|
| 684 | mkdir( $xl_support, 0755, true ); |
|---|
| 685 | } |
|---|
| 686 | if ( count( $system_info ) > 0 ) { |
|---|
| 687 | $xl_support_file_path = $xl_support . '/finale-lite-support.json'; |
|---|
| 688 | $success = file_put_contents( $xl_support_file_path, json_encode( $system_info ) ); |
|---|
| 689 | if ( $success ) { |
|---|
| 690 | $xl_support_url .= '/finale-lite-support.json'; |
|---|
| 691 | } |
|---|
| 692 | } |
|---|
| 693 | } |
|---|
| 694 | echo $xl_support_url; |
|---|
| 695 | } |
|---|
| 696 | } |
|---|
| 697 | |
|---|
| 698 | public function finale_update_message( $config ) { |
|---|
| 699 | $config[ WCCT_PLUGIN_BASENAME ] = 'https://plugins.svn.wordpress.org/finale-woocommerce-sales-countdown-timer-discount/trunk/readme.txt'; |
|---|
| 700 | |
|---|
| 701 | return $config; |
|---|
| 702 | } |
|---|
| 703 | |
|---|
| 704 | public function xl_addon_installation() { |
|---|
| 705 | if ( ! current_user_can( 'manage_options' ) ) { |
|---|
| 706 | wp_send_json_error( 'Insufficient permissions.' ); |
|---|
| 707 | } |
|---|
| 708 | |
|---|
| 709 | $nonce = isset( $_POST['nonce'] ) ? $_POST['nonce'] : ''; |
|---|
| 710 | if ( empty( $nonce ) || ! wp_verify_nonce( $nonce, 'xl_addon_installation_nonce' ) ) { |
|---|
| 711 | wp_send_json_error( 'Security error.' ); |
|---|
| 712 | } |
|---|
| 713 | |
|---|
| 714 | $plugin_slug = isset( $_POST['xl_slug'] ) ? $_POST['xl_slug'] : ''; |
|---|
| 715 | $plugin_file = isset( $_POST['xl_file'] ) ? $_POST['xl_file'] : ''; |
|---|
| 716 | |
|---|
| 717 | if ( empty( $plugin_slug ) || empty( $plugin_file ) ) { |
|---|
| 718 | wp_send_json_error( 'File slug or name is invalid.' ); |
|---|
| 719 | } |
|---|
| 720 | $plugin_file = $plugin_slug . $plugin_file; |
|---|
| 721 | |
|---|
| 722 | if ( $this->is_plugin_installed( $plugin_file ) ) { |
|---|
| 723 | $activation_result = activate_plugin( $plugin_file ); |
|---|
| 724 | |
|---|
| 725 | if ( is_wp_error( $activation_result ) ) { |
|---|
| 726 | wp_send_json_error( 'Failed to activate plugin.' ); |
|---|
| 727 | } else { |
|---|
| 728 | wp_send_json_success( 'Plugin activated successfully!' ); |
|---|
| 729 | } |
|---|
| 730 | } else { |
|---|
| 731 | include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); |
|---|
| 732 | include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); |
|---|
| 733 | |
|---|
| 734 | $api = plugins_api( 'plugin_information', array( |
|---|
| 735 | 'slug' => $plugin_slug, |
|---|
| 736 | 'fields' => array( |
|---|
| 737 | 'sections' => false, |
|---|
| 738 | ), |
|---|
| 739 | ) ); |
|---|
| 740 | |
|---|
| 741 | $upgrader = new Plugin_Upgrader(); |
|---|
| 742 | |
|---|
| 743 | // Start the installation process |
|---|
| 744 | $result = $upgrader->install( $api->download_link ); |
|---|
| 745 | |
|---|
| 746 | if ( is_wp_error( $result ) ) { |
|---|
| 747 | wp_send_json_error( 'Failed to install plugin.' ); |
|---|
| 748 | } |
|---|
| 749 | |
|---|
| 750 | // Activate the plugin |
|---|
| 751 | $activation_result = activate_plugin( $plugin_file ); |
|---|
| 752 | |
|---|
| 753 | if ( is_wp_error( $activation_result ) ) { |
|---|
| 754 | wp_send_json_error( 'Failed to activate plugin.' ); |
|---|
| 755 | } else { |
|---|
| 756 | wp_send_json_success( 'Plugin installed and activated successfully!' ); |
|---|
| 757 | } |
|---|
| 758 | } |
|---|
| 759 | } |
|---|
| 760 | |
|---|
| 761 | public function is_plugin_installed( $plugin_file ) { |
|---|
| 762 | $installed_plugins = get_plugins(); |
|---|
| 763 | |
|---|
| 764 | foreach ( $installed_plugins as $installed_plugin_file => $plugin_data ) { |
|---|
| 765 | if ( $installed_plugin_file === $plugin_file ) { |
|---|
| 766 | return true; |
|---|
| 767 | } |
|---|
| 768 | } |
|---|
| 769 | |
|---|
| 770 | return false; |
|---|
| 771 | } |
|---|
| 772 | |
|---|
| 773 | } |
|---|
| 774 | |
|---|
| 775 | if ( class_exists( 'WCCT_XL_Support' ) ) { |
|---|
| 776 | WCCT_Core::register( 'xl_support', 'WCCT_XL_Support' ); |
|---|
| 777 | } |
|---|