| @@ -11,16 +11,35 @@ | ||
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | 13 | * Gets license key |
| 14 | 14 | * |
| 15 | + * PostX Pro answers through the `ultp_license_key` filter. | |
| 16 | + * | |
| 15 | 17 | * @return string |
| 16 | 18 | */ |
| 17 | 19 | public static function get_lc_key() { |
| 18 | - return get_option( 'edd_ultp_license_key', '' ); | |
| 20 | + if ( has_filter( 'ultp_license_key' ) ) { | |
| 21 | + $key = apply_filters( 'ultp_license_key', '' ); | |
| 22 | + return is_string( $key ) ? $key : ''; | |
| 23 | + } | |
| 24 | + if ( self::is_pro_before_1_9_0() ) { | |
| 25 | + return get_option( 'edd_ultp_license_key', '' ); | |
| 26 | + } | |
| 27 | + return ''; | |
| 19 | 28 | } |
| 20 | 29 | |
| 30 | + /** | |
| 31 | + * Checks if the license is active. | |
| 32 | + * | |
| 33 | + * PostX Pro answers through the `ultp_license_active` filter. | |
| 34 | + * | |
| 35 | + * @return bool | |
| 36 | + */ | |
| 21 | 37 | public static function is_lc_active() { |
| 22 | - if ( defined( 'ULTP_PRO_VER' ) ) { | |
| 38 | + if ( has_filter( 'ultp_license_active' ) ) { | |
| 39 | + return true === apply_filters( 'ultp_license_active', false ); | |
| 40 | + } | |
| 41 | + if ( self::is_pro_before_1_9_0() ) { | |
| 23 | 42 | $license_data = get_option( 'edd_ultp_license_data', array() ); |
| 24 | 43 | return isset( $license_data['license'] ) && 'valid' === $license_data['license']; |
| 25 | 44 | } |
| 26 | 45 | return false; |
| @@ -26,19 +45,36 @@ | ||
| 26 | 45 | return false; |
| 27 | 46 | } |
| 28 | 47 | |
| 29 | 48 | /** |
| 49 | + * Checks if PostX Pro is a version before 1.9.0. | |
| 50 | + * | |
| 51 | + * Those versions hook none of the filters PostX now asks PostX Pro through (the | |
| 52 | + * `ultp_license_*` ones, `ultp_template_request_body`, `ultp_seo_meta_excerpt`), | |
| 53 | + * so PostX still does that work itself for them. | |
| 54 | + * | |
| 55 | + * @return bool | |
| 56 | + */ | |
| 57 | + public static function is_pro_before_1_9_0() { | |
| 58 | + return defined( 'ULTP_PRO_VER' ) && version_compare( ULTP_PRO_VER, '1.9.0', '<' ); | |
| 59 | + } | |
| 60 | + | |
| 61 | + /** | |
| 30 | 62 | * Checks if the license has expired. |
| 31 | 63 | * |
| 32 | - * This method checks the stored license data in the WordPress options table | |
| 33 | - * and determines if the license status is set to 'expired'. It returns `true` | |
| 34 | - * if the license is expired, otherwise `false`. | |
| 64 | + * PostX Pro answers through the `ultp_license_expired` filter. | |
| 35 | 65 | * |
| 36 | 66 | * @return bool True if the license is expired, otherwise false. |
| 37 | 67 | */ |
| 38 | 68 | public static function is_lc_expired() { |
| 39 | - $license_data = get_option( 'edd_ultp_license_data', array() ); | |
| 40 | - return isset( $license_data['license'] ) && 'expired' === $license_data['license']; | |
| 69 | + if ( has_filter( 'ultp_license_expired' ) ) { | |
| 70 | + return true === apply_filters( 'ultp_license_expired', false ); | |
| 71 | + } | |
| 72 | + if ( self::is_pro_before_1_9_0() ) { | |
| 73 | + $license_data = get_option( 'edd_ultp_license_data', array() ); | |
| 74 | + return isset( $license_data['license'] ) && 'expired' === $license_data['license']; | |
| 75 | + } | |
| 76 | + return false; | |
| 41 | 77 | } |
| 42 | 78 | |
| 43 | 79 | /** |
| 44 | 80 | * Get Option Value bypassing cache |
| @@ -200,109 +236,124 @@ | ||
| 200 | 236 | } |
| 201 | 237 | |
| 202 | 238 | public static function generate_utm_link( $params = array() ) { |
| 203 | 239 | $default_config = array( |
| 204 | - 'example' => array( | |
| 240 | + 'example' => array( | |
| 205 | 241 | 'source' => 'db-postx-featurename', |
| 206 | 242 | 'medium' => 'block-feature', |
| 207 | 243 | 'campaign' => 'postx-dashboard', |
| 208 | 244 | ), |
| 209 | - 'summer_db' => array( | |
| 245 | + 'summer_db' => array( | |
| 210 | 246 | 'source' => 'db-postx-notice', |
| 211 | - 'medium' => 'black-friday-sale', | |
| 247 | + 'medium' => 'summer-sale', | |
| 212 | 248 | 'campaign' => 'postx-dashboard', |
| 213 | 249 | ), |
| 214 | - 'plugin_dir_pro' => array( | |
| 250 | + 'birthday' => array( | |
| 251 | + 'source' => 'db-postx-notice', | |
| 252 | + 'medium' => 'birthday', | |
| 253 | + 'campaign' => 'postx-dashboard', | |
| 254 | + ), | |
| 255 | + 'plugin_dir_pro' => array( | |
| 215 | 256 | 'source' => 'db-postx-plugin', |
| 216 | 257 | 'medium' => 'upgrade-pro', |
| 217 | 258 | 'campaign' => 'postx-dashboard', |
| 218 | 259 | ), |
| 219 | - 'post_type_page' => array( | |
| 260 | + 'post_type_page' => array( | |
| 220 | 261 | 'source' => 'db-postx-posttype', |
| 221 | 262 | 'medium' => 'upgrade-pro', |
| 222 | 263 | 'campaign' => 'postx-dashboard', |
| 223 | 264 | ), |
| 224 | - 'plugin_dir_support' => array( | |
| 265 | + 'plugin_dir_support' => array( | |
| 225 | 266 | 'source' => 'db-postx-pluginmeta', |
| 226 | 267 | 'medium' => 'meta-support', |
| 227 | 268 | 'campaign' => 'postx-dashboard', |
| 228 | 269 | ), |
| 229 | - 'dashboard_go_pro' => array( | |
| 270 | + 'dashboard_go_pro' => array( | |
| 230 | 271 | 'source' => 'db-postx-submenu', |
| 231 | 272 | 'medium' => 'left-menu-upgrade', |
| 232 | 273 | 'campaign' => 'postx-dashboard', |
| 233 | 274 | ), |
| 234 | - 'sub_menu' => array( | |
| 275 | + 'sub_menu' => array( | |
| 235 | 276 | 'source' => 'db-postx-submenu', |
| 236 | 277 | 'medium' => 'upgrade-pro', |
| 237 | 278 | 'campaign' => 'postx-dashboard', |
| 238 | 279 | ), |
| 239 | - 'content_notice' => array( | |
| 280 | + 'content_notice' => array( | |
| 240 | 281 | 'source' => 'db-postx-notice', |
| 241 | 282 | 'medium' => 'spring-sale', |
| 242 | 283 | 'campaign' => 'postx-dashboard', |
| 243 | 284 | ), |
| 285 | + 'summer_sale_meta' => array( | |
| 286 | + 'source' => 'db-postx-plugin-meta', | |
| 287 | + 'medium' => 'summer-sale', | |
| 288 | + 'campaign' => 'postx-dashboard', | |
| 289 | + ), | |
| 290 | + 'base_price_meta' => array( | |
| 291 | + 'source' => 'db-postx-plugin-meta', | |
| 292 | + 'medium' => 'base-price', | |
| 293 | + 'campaign' => 'postx-dashboard', | |
| 294 | + ), | |
| 244 | 295 | |
| 245 | 296 | // Flash sale. |
| 246 | - 'flash_sale_content' => array( | |
| 297 | + 'flash_sale_content' => array( | |
| 247 | 298 | 'source' => 'db-postx-notice-content', |
| 248 | 299 | 'medium' => 'summer-flash-sale', |
| 249 | 300 | 'campaign' => 'postx-dashboard', |
| 250 | 301 | ), |
| 251 | - 'flash_sale' => array( | |
| 302 | + 'flash_sale' => array( | |
| 252 | 303 | 'source' => 'db-postx-notice', |
| 253 | 304 | 'medium' => 'summer-flash-sale', |
| 254 | 305 | 'campaign' => 'postx-dashboard', |
| 255 | 306 | ), |
| 256 | - 'flash_sale_meta' => array( | |
| 307 | + 'flash_sale_meta' => array( | |
| 257 | 308 | 'source' => 'db-postx-plugin-meta', |
| 258 | 309 | 'medium' => 'summer-flash-sale', |
| 259 | 310 | 'campaign' => 'postx-dashboard', |
| 260 | 311 | ), |
| 261 | - // Massive Sale | |
| 262 | - 'massive_sale_content' => array( | |
| 312 | + // Massive Sale | |
| 313 | + 'massive_sale_content' => array( | |
| 263 | 314 | 'source' => 'db-postx-notice-content', |
| 264 | 315 | 'medium' => 'summer-massive-sale', |
| 265 | 316 | 'campaign' => 'postx-dashboard', |
| 266 | 317 | ), |
| 267 | - 'massive_sale' => array( | |
| 318 | + 'massive_sale' => array( | |
| 268 | 319 | 'source' => 'db-postx-notice', |
| 269 | 320 | 'medium' => 'summer-massive-sale', |
| 270 | 321 | 'campaign' => 'postx-dashboard', |
| 271 | 322 | ), |
| 272 | - 'massive_sale_meta' => array( | |
| 323 | + 'massive_sale_meta' => array( | |
| 273 | 324 | 'source' => 'db-postx-plugin-meta', |
| 274 | 325 | 'medium' => 'summer-massive-sale', |
| 275 | 326 | 'campaign' => 'postx-dashboard', |
| 276 | 327 | ), |
| 277 | 328 | // Surprise Sale |
| 278 | - 'surprise_sale_content' => array( | |
| 329 | + 'surprise_sale_content' => array( | |
| 279 | 330 | 'source' => 'db-postx-notice-content', |
| 280 | 331 | 'medium' => 'summer-surprise-sale', |
| 281 | 332 | 'campaign' => 'postx-dashboard', |
| 282 | 333 | ), |
| 283 | - 'surprise_sale' => array( | |
| 334 | + 'surprise_sale' => array( | |
| 284 | 335 | 'source' => 'db-postx-notice', |
| 285 | 336 | 'medium' => 'summer-surprise-sale', |
| 286 | 337 | 'campaign' => 'postx-dashboard', |
| 287 | 338 | ), |
| 288 | - 'surprise_sale_meta' => array( | |
| 339 | + 'surprise_sale_meta' => array( | |
| 289 | 340 | 'source' => 'db-postx-plugin-meta', |
| 290 | 341 | 'medium' => 'summer-surprise-sale', |
| 291 | 342 | 'campaign' => 'postx-dashboard', |
| 292 | 343 | ), |
| 293 | 344 | // Final Hours Sale |
| 294 | - 'final_hours_content' => array( | |
| 345 | + 'final_hours_content' => array( | |
| 295 | 346 | 'source' => 'db-postx-notice-content', |
| 296 | 347 | 'medium' => 'summer-final-sale', |
| 297 | 348 | 'campaign' => 'postx-dashboard', |
| 298 | 349 | ), |
| 299 | - 'final_hour' => array( | |
| 350 | + 'final_hour' => array( | |
| 300 | 351 | 'source' => 'db-postx-notice', |
| 301 | 352 | 'medium' => 'summer-final-sale', |
| 302 | 353 | 'campaign' => 'postx-dashboard', |
| 303 | 354 | ), |
| 304 | - 'final_hour_meta' => array( | |
| 355 | + 'final_hour_meta' => array( | |
| 305 | 356 | 'source' => 'db-postx-plugin-meta', |
| 306 | 357 | 'medium' => 'summer-final-sale', |
| 307 | 358 | 'campaign' => 'postx-dashboard', |
| 308 | 359 | ), |
| @@ -314,9 +365,9 @@ | ||
| 314 | 365 | $affiliate = $params['affiliate'] ?? apply_filters( 'ultp_affiliate_id', '' ); |
| 315 | 366 | $hash = $params['hash'] ?? 'pricing'; |
| 316 | 367 | $custom_config = $params['config'] ?? null; |
| 317 | 368 | |
| 318 | - $parsed_url = parse_url( $base_url ); | |
| 369 | + $parsed_url = wp_parse_url( $base_url ); | |
| 319 | 370 | $scheme = $parsed_url['scheme'] ?? 'https'; |
| 320 | 371 | $host = $parsed_url['host'] ?? ''; |
| 321 | 372 | $path = $parsed_url['path'] ?? ''; |
| 322 | 373 | $query = array(); |
| @@ -368,25 +419,28 @@ | ||
| 368 | 419 | */ |
| 369 | 420 | public static function get_wow_products_details() { |
| 370 | 421 | return array( |
| 371 | 422 | 'products' => array( |
| 372 | - 'wow_shipping' => file_exists( WP_PLUGIN_DIR . '/wow-table-rate-shipping/wow-table-rate-shipping.php' ), | |
| 373 | - 'post_x' => file_exists( WP_PLUGIN_DIR . '/ultimate-post/ultimate-post.php' ), | |
| 374 | - 'wow_store' => file_exists( WP_PLUGIN_DIR . '/product-blocks/product-blocks.php' ), | |
| 375 | - 'wow_optin' => file_exists( WP_PLUGIN_DIR . '/optin/optin.php' ), | |
| 376 | - 'wow_revenue' => file_exists( WP_PLUGIN_DIR . '/revenue/revenue.php' ), | |
| 377 | - 'wholesale_x' => file_exists( WP_PLUGIN_DIR . '/wholesalex/wholesalex.php' ), | |
| 378 | - 'wow_addon' => file_exists( WP_PLUGIN_DIR . '/product-addons/product-addons.php' ), | |
| 379 | - | |
| 423 | + 'wow_shipping' => file_exists( WP_PLUGIN_DIR . '/wow-table-rate-shipping/wow-table-rate-shipping.php' ), | |
| 424 | + 'post_x' => file_exists( WP_PLUGIN_DIR . '/ultimate-post/ultimate-post.php' ), | |
| 425 | + 'wow_store' => file_exists( WP_PLUGIN_DIR . '/product-blocks/product-blocks.php' ), | |
| 426 | + 'wow_optin' => file_exists( WP_PLUGIN_DIR . '/optin/optin.php' ), | |
| 427 | + 'wow_revenue' => file_exists( WP_PLUGIN_DIR . '/revenue/revenue.php' ), | |
| 428 | + 'wholesale_x' => file_exists( WP_PLUGIN_DIR . '/wholesalex/wholesalex.php' ), | |
| 429 | + 'wow_addon' => file_exists( WP_PLUGIN_DIR . '/product-addons/product-addons.php' ), | |
| 430 | + 'wow_invoice' => file_exists( WP_PLUGIN_DIR . '/wow-pdf-invoices-packing-slips/wow-pdf-invoices-packing-slips.php' ), | |
| 431 | + 'wow_recommend' => file_exists( WP_PLUGIN_DIR . '/wow-ai-product-recommendations/wow-ai-product-recommendations.php' ), | |
| 380 | 432 | ), |
| 381 | 433 | 'products_active' => array( |
| 382 | - 'wow_shipping' => defined( 'WTRS_VER' ), | |
| 383 | - 'post_x' => defined( 'ULTP_VER' ), | |
| 384 | - 'wow_store' => defined( 'WOPB_VER' ), | |
| 385 | - 'wow_optin' => defined( 'OPTN_VERSION' ), | |
| 386 | - 'wow_revenue' => defined( 'REVENUE_VER' ), | |
| 387 | - 'wholesale_x' => defined( 'WHOLESALEX_VER' ), | |
| 388 | - 'wow_addon' => defined( 'PRAD_VER' ), | |
| 434 | + 'wow_shipping' => defined( 'WTRS_VER' ), | |
| 435 | + 'post_x' => defined( 'ULTP_VER' ), | |
| 436 | + 'wow_store' => defined( 'WOPB_VER' ), | |
| 437 | + 'wow_optin' => defined( 'OPTN_VERSION' ), | |
| 438 | + 'wow_revenue' => defined( 'REVENUE_VER' ), | |
| 439 | + 'wholesale_x' => defined( 'WHOLESALEX_VER' ), | |
| 440 | + 'wow_addon' => defined( 'PRAD_VER' ), | |
| 441 | + 'wow_invoice' => defined( 'WINV_VER' ), | |
| 442 | + 'wow_recommend' => defined( 'PRECO_VER' ), | |
| 389 | 443 | ), |
| 390 | 444 | ); |
| 391 | 445 | } |
| 392 | 446 | |
| @@ -423,8 +477,15 @@ | ||
| 423 | 477 | break; |
| 424 | 478 | case 'woocommerce': |
| 425 | 479 | $plugin_slug = 'woocommerce'; |
| 426 | 480 | break; |
| 481 | + case 'wow_invoice': | |
| 482 | + $plugin_slug = 'wow-pdf-invoices-packing-slips'; | |
| 483 | + $active_url = admin_url( 'admin.php?page=winv-dashboard#overview' ); | |
| 484 | + break; | |
| 485 | + case 'wow_recommend': | |
| 486 | + $plugin_slug = 'wow-ai-product-recommendations'; | |
| 487 | + break; | |
| 427 | 488 | } |
| 428 | 489 | |
| 429 | 490 | if ( ! file_exists( WP_PLUGIN_DIR . '/' . $plugin_slug . '/' . $plugin_slug . '.php' ) ) { |
| 430 | 491 | $to_r = self::plugin_install( $plugin_slug . '/' . $plugin_slug . '.php', $plugin_slug ); |
| @@ -476,17 +537,21 @@ | ||
| 476 | 537 | ) |
| 477 | 538 | ); |
| 478 | 539 | |
| 479 | 540 | if ( is_wp_error( $api ) ) { |
| 480 | - wp_die( $api ); //phpcs:ignore | |
| 541 | + wp_die( esc_html( $api->get_error_message() ) ); | |
| 481 | 542 | } |
| 482 | - | |
| 543 | + $title = ''; | |
| 544 | + $url = ''; | |
| 545 | + $nonce = ''; | |
| 483 | 546 | $upgrader = new \Plugin_Upgrader( new \WP_Ajax_Upgrader_Skin( compact( 'title', 'url', 'nonce', 'plugin', 'api' ) ) ); |
| 484 | 547 | $install_result = $upgrader->install( $api->download_link ); |
| 485 | 548 | |
| 486 | 549 | if ( ! is_wp_error( $install_result ) ) { |
| 487 | 550 | activate_plugin( $plugin ); |
| 488 | - return array( 'done' => false ); | |
| 551 | + return array( | |
| 552 | + 'done' => false, | |
| 553 | + ); | |
| 489 | 554 | } |
| 490 | 555 | |
| 491 | 556 | return array( 'done' => true ); |
| 492 | 557 | } |