← All changes
|
vendor/codeinwp/themeisle-sdk/src/Modules/Promotions.php
+420
-98
3.10.13
→
3.11.10
View file →
| @@ -31,9 +31,9 @@ | ||
| 31 | 31 | * Holds the promotions. |
| 32 | 32 | * |
| 33 | 33 | * @var array |
| 34 | 34 | */ |
| 35 | - private $promotions = array(); | |
| 35 | + public $promotions = array(); | |
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | 38 | * Holds the values of the promotions that are not allowed to be shown. |
| 39 | 39 | * Can be filtered by each product. |
| @@ -70,15 +70,43 @@ | ||
| 70 | 70 | */ |
| 71 | 71 | private $option_rop = 'themeisle_sdk_promotions_rop_installed'; |
| 72 | 72 | |
| 73 | 73 | /** |
| 74 | - * Option key for Neve FSE promos. | |
| 74 | + * Option key for Neve promo. | |
| 75 | 75 | * |
| 76 | 76 | * @var string |
| 77 | 77 | */ |
| 78 | - private $option_neve_fse = 'themeisle_sdk_promotions_neve_fse_installed'; | |
| 78 | + private $option_neve = 'themeisle_sdk_promotions_neve_installed'; | |
| 79 | 79 | |
| 80 | 80 | /** |
| 81 | + * Option key for Redirection for CF7. | |
| 82 | + * | |
| 83 | + * @var string | |
| 84 | + */ | |
| 85 | + private $option_redirection_cf7 = 'themeisle_sdk_promotions_redirection_cf7_installed'; | |
| 86 | + | |
| 87 | + /** | |
| 88 | + * Option key for Hyve. | |
| 89 | + * | |
| 90 | + * @var string | |
| 91 | + */ | |
| 92 | + private $option_hyve = 'themeisle_sdk_promotions_hyve_installed'; | |
| 93 | + | |
| 94 | + /** | |
| 95 | + * Option key for WP Full Pay. | |
| 96 | + * | |
| 97 | + * @var string | |
| 98 | + */ | |
| 99 | + private $option_wp_full_pay = 'themeisle_sdk_promotions_wp_full_pay_installed'; | |
| 100 | + | |
| 101 | + /** | |
| 102 | + * Option key for Feedzy. | |
| 103 | + * | |
| 104 | + * @var string | |
| 105 | + */ | |
| 106 | + private $option_feedzy = 'themeisle_sdk_promotions_feedzy_installed'; | |
| 107 | + | |
| 108 | + /** | |
| 81 | 109 | * Loaded promotion. |
| 82 | 110 | * |
| 83 | 111 | * @var string |
| 84 | 112 | */ |
| @@ -112,15 +140,25 @@ | ||
| 112 | 140 | if ( $this->is_from_partner( $product ) ) { |
| 113 | 141 | return false; |
| 114 | 142 | } |
| 115 | 143 | |
| 116 | - $this->debug = apply_filters( 'themeisle_sdk_promo_debug', $this->debug ); | |
| 117 | - $promotions_to_load = apply_filters( $product->get_key() . '_load_promotions', array() ); | |
| 144 | + $this->debug = apply_filters( 'themeisle_sdk_promo_debug', $this->debug ); | |
| 145 | + $promotions_to_load = apply_filters( $product->get_key() . '_load_promotions', array() ); | |
| 146 | + | |
| 118 | 147 | $promotions_to_load[] = 'optimole'; |
| 119 | 148 | $promotions_to_load[] = 'rop'; |
| 120 | 149 | $promotions_to_load[] = 'woo_plugins'; |
| 121 | - $promotions_to_load[] = 'neve-fse'; | |
| 150 | + $promotions_to_load[] = 'neve'; | |
| 151 | + $promotions_to_load[] = 'redirection-cf7'; | |
| 152 | + $promotions_to_load[] = 'hyve'; | |
| 153 | + $promotions_to_load[] = 'wp_full_pay'; | |
| 154 | + $promotions_to_load[] = 'feedzy_import'; | |
| 122 | 155 | |
| 156 | + if ( defined( 'NEVE_VERSION' ) || defined( 'WPMM_PATH' ) || defined( 'OTTER_BLOCKS_VERSION' ) || defined( 'OBFX_URL' ) ) { | |
| 157 | + $promotions_to_load[] = 'feedzy_embed'; | |
| 158 | + } | |
| 159 | + $promotions_to_load = array_unique( $promotions_to_load ); | |
| 160 | + | |
| 123 | 161 | $this->promotions = $this->get_promotions(); |
| 124 | 162 | |
| 125 | 163 | $this->dissallowed_promotions = apply_filters( $product->get_key() . '_dissallowed_promotions', array() ); |
| 126 | 164 | |
| @@ -128,9 +166,8 @@ | ||
| 128 | 166 | if ( ! in_array( $slug, $promotions_to_load, true ) ) { |
| 129 | 167 | unset( $this->promotions[ $slug ] ); |
| 130 | 168 | } |
| 131 | 169 | } |
| 132 | - | |
| 133 | 170 | add_action( 'init', array( $this, 'register_settings' ), 99 ); |
| 134 | 171 | add_action( 'admin_init', array( $this, 'register_reference' ), 99 ); |
| 135 | 172 | |
| 136 | 173 | return ! empty( $this->promotions ); |
| @@ -145,16 +182,16 @@ | ||
| 145 | 182 | if ( ! $this->is_writeable() || ! current_user_can( 'install_plugins' ) ) { |
| 146 | 183 | return; |
| 147 | 184 | } |
| 148 | 185 | |
| 149 | - $this->product = $product; | |
| 186 | + $last_dismiss_time = $this->get_last_dismiss_time(); | |
| 150 | 187 | |
| 151 | - $last_dismiss = $this->get_last_dismiss_time(); | |
| 152 | - | |
| 153 | - if ( ! $this->debug && $last_dismiss && ( time() - $last_dismiss ) < 7 * DAY_IN_SECONDS ) { | |
| 188 | + if ( ! $this->debug && is_int( $last_dismiss_time ) && ( time() - $last_dismiss_time ) < ( 3 * WEEK_IN_SECONDS ) ) { | |
| 154 | 189 | return; |
| 155 | 190 | } |
| 156 | 191 | |
| 192 | + $this->product = $product; | |
| 193 | + | |
| 157 | 194 | add_filter( 'attachment_fields_to_edit', array( $this, 'add_attachment_field' ), 10, 2 ); |
| 158 | 195 | add_action( 'current_screen', [ $this, 'load_available' ] ); |
| 159 | 196 | add_action( 'elementor/editor/after_enqueue_scripts', array( $this, 'enqueue' ) ); |
| 160 | 197 | add_action( 'wp_ajax_tisdk_update_option', array( $this, 'dismiss_promotion' ) ); |
| @@ -159,9 +196,9 @@ | ||
| 159 | 196 | add_action( 'elementor/editor/after_enqueue_scripts', array( $this, 'enqueue' ) ); |
| 160 | 197 | add_action( 'wp_ajax_tisdk_update_option', array( $this, 'dismiss_promotion' ) ); |
| 161 | 198 | add_filter( 'themeisle_sdk_ran_promos', '__return_true' ); |
| 162 | 199 | |
| 163 | - if ( get_option( $this->option_neve_fse, false ) !== true ) { | |
| 200 | + if ( get_option( $this->option_neve, false ) !== true ) { | |
| 164 | 201 | add_action( 'wp_ajax_themeisle_sdk_dismiss_notice', 'ThemeisleSDK\Modules\Notification::regular_dismiss' ); |
| 165 | 202 | } |
| 166 | 203 | } |
| 167 | 204 | |
| @@ -208,11 +245,23 @@ | ||
| 208 | 245 | if ( isset( $_GET['rop_reference_key'] ) ) { |
| 209 | 246 | update_option( 'rop_reference_key', sanitize_key( $_GET['rop_reference_key'] ) ); |
| 210 | 247 | } |
| 211 | 248 | |
| 212 | - if ( isset( $_GET['neve_fse_reference_key'] ) ) { | |
| 213 | - update_option( 'neve_fse_reference_key', sanitize_key( $_GET['neve_fse_reference_key'] ) ); | |
| 249 | + if ( isset( $_GET['neve_reference_key'] ) ) { | |
| 250 | + update_option( 'neve_reference_key', sanitize_key( $_GET['neve_reference_key'] ) ); | |
| 214 | 251 | } |
| 252 | + | |
| 253 | + if ( isset( $_GET['hyve_reference_key'] ) ) { | |
| 254 | + update_option( 'hyve_reference_key', sanitize_key( $_GET['hyve_reference_key'] ) ); | |
| 255 | + } | |
| 256 | + | |
| 257 | + if ( isset( $_GET['wp_full_pay_reference_key'] ) ) { | |
| 258 | + update_option( 'wp_full_pay_reference_key', sanitize_key( $_GET['wp_full_pay_reference_key'] ) ); | |
| 259 | + } | |
| 260 | + if ( isset( $_GET['feedzy_reference_key'] ) || ( isset( $_GET['from'], $_GET['plugin'] ) && $_GET['from'] === 'import' && str_starts_with( sanitize_key( $_GET['plugin'] ), 'feedzy' ) ) ) { | |
| 261 | + update_option( 'feedzy_reference_key', sanitize_key( $_GET['feedzy_reference_key'] ?? 'i-' . $this->product->get_key() ) ); | |
| 262 | + update_option( $this->option_feedzy, 1 ); | |
| 263 | + } | |
| 215 | 264 | } |
| 216 | 265 | |
| 217 | 266 | /** |
| 218 | 267 | * Register Settings |
| @@ -262,9 +311,9 @@ | ||
| 262 | 311 | ) |
| 263 | 312 | ); |
| 264 | 313 | register_setting( |
| 265 | 314 | 'themeisle_sdk_settings', |
| 266 | - $this->option_neve_fse, | |
| 315 | + $this->option_neve, | |
| 267 | 316 | array( |
| 268 | 317 | 'type' => 'boolean', |
| 269 | 318 | 'sanitize_callback' => 'rest_sanitize_boolean', |
| 270 | 319 | 'show_in_rest' => true, |
| @@ -270,8 +319,38 @@ | ||
| 270 | 319 | 'show_in_rest' => true, |
| 271 | 320 | 'default' => false, |
| 272 | 321 | ) |
| 273 | 322 | ); |
| 323 | + register_setting( | |
| 324 | + 'themeisle_sdk_settings', | |
| 325 | + $this->option_redirection_cf7, | |
| 326 | + array( | |
| 327 | + 'type' => 'boolean', | |
| 328 | + 'sanitize_callback' => 'rest_sanitize_boolean', | |
| 329 | + 'show_in_rest' => true, | |
| 330 | + 'default' => false, | |
| 331 | + ) | |
| 332 | + ); | |
| 333 | + register_setting( | |
| 334 | + 'themeisle_sdk_settings', | |
| 335 | + $this->option_hyve, | |
| 336 | + array( | |
| 337 | + 'type' => 'boolean', | |
| 338 | + 'sanitize_callback' => 'rest_sanitize_boolean', | |
| 339 | + 'show_in_rest' => true, | |
| 340 | + 'default' => false, | |
| 341 | + ) | |
| 342 | + ); | |
| 343 | + register_setting( | |
| 344 | + 'themeisle_sdk_settings', | |
| 345 | + $this->option_wp_full_pay, | |
| 346 | + array( | |
| 347 | + 'type' => 'boolean', | |
| 348 | + 'sanitize_callback' => 'rest_sanitize_boolean', | |
| 349 | + 'show_in_rest' => true, | |
| 350 | + 'default' => false, | |
| 351 | + ) | |
| 352 | + ); | |
| 274 | 353 | } |
| 275 | 354 | |
| 276 | 355 | /** |
| 277 | 356 | * Check if the path is writable. |
| @@ -312,33 +391,47 @@ | ||
| 312 | 391 | * |
| 313 | 392 | * @return array |
| 314 | 393 | */ |
| 315 | 394 | private function get_promotions() { |
| 316 | - $has_otter = defined( 'OTTER_BLOCKS_VERSION' ) || $this->is_plugin_installed( 'otter-blocks' ); | |
| 317 | - $had_otter_from_promo = get_option( $this->option_otter, false ); | |
| 318 | - $has_optimole = defined( 'OPTIMOLE_VERSION' ) || $this->is_plugin_installed( 'optimole-wp' ); | |
| 319 | - $had_optimole_from_promo = get_option( $this->option_optimole, false ); | |
| 320 | - $has_rop = defined( 'ROP_LITE_VERSION' ) || $this->is_plugin_installed( 'tweet-old-post' ); | |
| 321 | - $had_rop_from_promo = get_option( $this->option_rop, false ); | |
| 322 | - $has_woocommerce = class_exists( 'WooCommerce' ); | |
| 323 | - $has_sparks = defined( 'SPARKS_WC_VERSION' ) || $this->is_plugin_installed( 'sparks-for-woocommerce' ); | |
| 324 | - $has_ppom = defined( 'PPOM_VERSION' ) || $this->is_plugin_installed( 'woocommerce-product-addon' ); | |
| 325 | - $is_min_req_v = version_compare( get_bloginfo( 'version' ), '5.8', '>=' ); | |
| 326 | - $is_min_fse_v = version_compare( get_bloginfo( 'version' ), '6.2', '>=' ); | |
| 327 | - $current_theme = wp_get_theme(); | |
| 328 | - $has_neve_fse = $current_theme->template === 'neve-fse' || $current_theme->parent() === 'neve-fse'; | |
| 329 | - $has_enough_attachments = $this->has_min_media_attachments(); | |
| 330 | - $has_enough_old_posts = $this->has_old_posts(); | |
| 395 | + $has_otter = defined( 'OTTER_BLOCKS_VERSION' ) || $this->is_plugin_installed( 'otter-blocks' ); | |
| 396 | + $had_otter_from_promo = get_option( $this->option_otter, false ); | |
| 397 | + $has_optimole = defined( 'OPTIMOLE_VERSION' ) || $this->is_plugin_installed( 'optimole-wp' ); | |
| 398 | + $had_optimole_from_promo = get_option( $this->option_optimole, false ); | |
| 399 | + $has_rop = defined( 'ROP_LITE_VERSION' ) || $this->is_plugin_installed( 'tweet-old-post' ); | |
| 400 | + $had_rop_from_promo = get_option( $this->option_rop, false ); | |
| 401 | + $has_woocommerce = class_exists( 'WooCommerce' ); | |
| 402 | + $has_sparks = defined( 'SPARKS_WC_VERSION' ) || $this->is_plugin_installed( 'sparks-for-woocommerce' ); | |
| 403 | + $has_ppom = defined( 'PPOM_VERSION' ) || $this->is_plugin_installed( 'woocommerce-product-addon' ); | |
| 404 | + $has_redirection_cf7 = defined( 'WPCF7_PRO_REDIRECT_PLUGIN_VERSION' ) || $this->is_plugin_installed( 'wpcf7-redirect' ); | |
| 405 | + $had_redirection_cf7_promo = get_option( $this->option_redirection_cf7, false ); | |
| 406 | + $has_hyve = defined( 'HYVE_LITE_VERSION' ) || $this->is_plugin_installed( 'hyve' ) || $this->is_plugin_installed( 'hyve-lite' ); | |
| 407 | + $had_hyve_from_promo = get_option( $this->option_hyve, false ); | |
| 408 | + $has_hyve_conditions = version_compare( get_bloginfo( 'version' ), '6.2', '>=' ) && $this->has_support_page(); | |
| 409 | + $has_wfp_full_pay = defined( 'WP_FULL_STRIPE_BASENAME' ) || $this->is_plugin_installed( 'wp-full-stripe-free' ); | |
| 410 | + $had_wfp_from_promo = get_option( $this->option_wp_full_pay, false ); | |
| 411 | + $has_wfp_conditions = $this->has_donate_page(); | |
| 412 | + $is_min_req_v = version_compare( get_bloginfo( 'version' ), '5.8', '>=' ); | |
| 413 | + $current_theme = wp_get_theme(); | |
| 414 | + $has_neve = $current_theme->template === 'neve' || $current_theme->parent() === 'neve'; | |
| 415 | + $has_neve_from_promo = get_option( $this->option_neve, false ); | |
| 416 | + $has_enough_attachments = $this->has_min_media_attachments(); | |
| 417 | + $has_enough_old_posts = $this->has_old_posts(); | |
| 418 | + $is_min_php_8_1 = version_compare( PHP_VERSION, '8.1', '>=' ); | |
| 331 | 419 | |
| 420 | + $has_feedzy = defined( 'FEEDZY_BASEFILE' ) || $this->is_plugin_installed( 'feedzy-rss-feedss' ); | |
| 421 | + $had_feedzy_from_promo = get_option( $this->option_feedzy, false ); | |
| 422 | + | |
| 332 | 423 | $all = [ |
| 333 | - 'optimole' => [ | |
| 424 | + 'optimole' => [ | |
| 334 | 425 | 'om-editor' => [ |
| 335 | - 'env' => ! $has_optimole && $is_min_req_v && ! $had_optimole_from_promo, | |
| 336 | - 'screen' => 'editor', | |
| 426 | + 'env' => ! $has_optimole && $is_min_req_v && ! $had_optimole_from_promo, | |
| 427 | + 'screen' => 'editor', | |
| 428 | + 'delayed' => true, | |
| 337 | 429 | ], |
| 338 | 430 | 'om-image-block' => [ |
| 339 | - 'env' => ! $has_optimole && $is_min_req_v && ! $had_optimole_from_promo, | |
| 340 | - 'screen' => 'editor', | |
| 431 | + 'env' => ! $has_optimole && $is_min_req_v && ! $had_optimole_from_promo, | |
| 432 | + 'screen' => 'editor', | |
| 433 | + 'delayed' => true, | |
| 341 | 434 | ], |
| 342 | 435 | 'om-attachment' => [ |
| 343 | 436 | 'env' => ! $has_optimole && ! $had_optimole_from_promo, |
| 344 | 437 | 'screen' => 'media-editor', |
| @@ -347,33 +440,51 @@ | ||
| 347 | 440 | 'env' => ! $has_optimole && ! $had_optimole_from_promo && $has_enough_attachments, |
| 348 | 441 | 'screen' => 'media', |
| 349 | 442 | ], |
| 350 | 443 | 'om-elementor' => [ |
| 351 | - 'env' => ! $has_optimole && ! $had_optimole_from_promo && defined( 'ELEMENTOR_VERSION' ), | |
| 352 | - 'screen' => 'elementor', | |
| 444 | + 'env' => ! $has_optimole && ! $had_optimole_from_promo && defined( 'ELEMENTOR_VERSION' ), | |
| 445 | + 'screen' => 'elementor', | |
| 446 | + 'delayed' => true, | |
| 353 | 447 | ], |
| 354 | 448 | ], |
| 355 | - 'otter' => [ | |
| 449 | + 'feedzy_import' => [ | |
| 450 | + 'feedzy-import' => [ | |
| 451 | + 'env' => true, | |
| 452 | + 'screen' => 'import', | |
| 453 | + 'always' => true, | |
| 454 | + ], | |
| 455 | + ], | |
| 456 | + 'feedzy_embed' => [ | |
| 457 | + 'feedzy-editor' => [ | |
| 458 | + 'env' => ! $has_feedzy && is_main_site() && ! $had_feedzy_from_promo, | |
| 459 | + 'screen' => 'editor', | |
| 460 | + ], | |
| 461 | + ], | |
| 462 | + 'otter' => [ | |
| 356 | 463 | 'blocks-css' => [ |
| 357 | - 'env' => ! $has_otter && $is_min_req_v && ! $had_otter_from_promo, | |
| 358 | - 'screen' => 'editor', | |
| 464 | + 'env' => ! $has_otter && $is_min_req_v && ! $had_otter_from_promo, | |
| 465 | + 'screen' => 'editor', | |
| 466 | + 'delayed' => true, | |
| 359 | 467 | ], |
| 360 | 468 | 'blocks-animation' => [ |
| 361 | - 'env' => ! $has_otter && $is_min_req_v && ! $had_otter_from_promo, | |
| 362 | - 'screen' => 'editor', | |
| 469 | + 'env' => ! $has_otter && $is_min_req_v && ! $had_otter_from_promo, | |
| 470 | + 'screen' => 'editor', | |
| 471 | + 'delayed' => true, | |
| 363 | 472 | ], |
| 364 | 473 | 'blocks-conditions' => [ |
| 365 | - 'env' => ! $has_otter && $is_min_req_v && ! $had_otter_from_promo, | |
| 366 | - 'screen' => 'editor', | |
| 474 | + 'env' => ! $has_otter && $is_min_req_v && ! $had_otter_from_promo, | |
| 475 | + 'screen' => 'editor', | |
| 476 | + 'delayed' => true, | |
| 367 | 477 | ], |
| 368 | 478 | ], |
| 369 | - 'rop' => [ | |
| 479 | + 'rop' => [ | |
| 370 | 480 | 'rop-posts' => [ |
| 371 | - 'env' => ! $has_rop && ! $had_rop_from_promo && $has_enough_old_posts, | |
| 372 | - 'screen' => 'edit-post', | |
| 481 | + 'env' => ! $has_rop && ! $had_rop_from_promo && $has_enough_old_posts, | |
| 482 | + 'screen' => 'edit-post', | |
| 483 | + 'delayed' => true, | |
| 373 | 484 | ], |
| 374 | 485 | ], |
| 375 | - 'woo_plugins' => [ | |
| 486 | + 'woo_plugins' => [ | |
| 376 | 487 | 'ppom' => [ |
| 377 | 488 | 'env' => ! $has_ppom && $has_woocommerce, |
| 378 | 489 | 'screen' => 'edit-product', |
| 379 | 490 | ], |
| @@ -389,14 +500,33 @@ | ||
| 389 | 500 | 'env' => ! $has_sparks && $has_woocommerce, |
| 390 | 501 | 'screen' => 'edit-product', |
| 391 | 502 | ], |
| 392 | 503 | ], |
| 393 | - 'neve-fse' => [ | |
| 394 | - 'neve-fse-themes-popular' => [ | |
| 395 | - 'env' => ! $has_neve_fse && $is_min_fse_v, | |
| 504 | + 'neve' => [ | |
| 505 | + 'neve-themes-popular' => [ | |
| 506 | + 'env' => ! $has_neve && ! $has_neve_from_promo, | |
| 396 | 507 | 'screen' => 'themes-install-popular', |
| 397 | 508 | ], |
| 398 | 509 | ], |
| 510 | + 'redirection-cf7' => [ | |
| 511 | + 'wpcf7' => [ | |
| 512 | + 'env' => ! $has_redirection_cf7 && ! $had_redirection_cf7_promo, | |
| 513 | + 'screen' => 'wpcf7', | |
| 514 | + 'delayed' => true, | |
| 515 | + ], | |
| 516 | + ], | |
| 517 | + 'hyve' => [ | |
| 518 | + 'hyve-plugins-install' => [ | |
| 519 | + 'env' => $is_min_php_8_1 && ! $has_hyve && ! $had_hyve_from_promo && $has_hyve_conditions, | |
| 520 | + 'screen' => 'plugin-install', | |
| 521 | + ], | |
| 522 | + ], | |
| 523 | + 'wp_full_pay' => [ | |
| 524 | + 'wp-full-pay-plugins-install' => [ | |
| 525 | + 'env' => ! $has_wfp_full_pay && ! $had_wfp_from_promo && $has_wfp_conditions, | |
| 526 | + 'screen' => 'plugin-install', | |
| 527 | + ], | |
| 528 | + ], | |
| 399 | 529 | ]; |
| 400 | 530 | |
| 401 | 531 | foreach ( $all as $slug => $data ) { |
| 402 | 532 | foreach ( $data as $key => $conditions ) { |
| @@ -414,9 +544,8 @@ | ||
| 414 | 544 | if ( empty( $all[ $slug ] ) ) { |
| 415 | 545 | unset( $all[ $slug ] ); |
| 416 | 546 | } |
| 417 | 547 | } |
| 418 | - | |
| 419 | 548 | return $all; |
| 420 | 549 | } |
| 421 | 550 | |
| 422 | 551 | /** |
| @@ -441,20 +570,14 @@ | ||
| 441 | 570 | |
| 442 | 571 | /** |
| 443 | 572 | * Get the last dismiss time of a promotion. |
| 444 | 573 | * |
| 445 | - * @return int The timestamp of last dismiss, or install time - 4 days. | |
| 574 | + * @return int | false The timestamp of last dismiss or false. | |
| 446 | 575 | */ |
| 447 | 576 | private function get_last_dismiss_time() { |
| 448 | 577 | $dismissed = $this->get_upsells_dismiss_time(); |
| 449 | 578 | |
| 450 | - if ( empty( $dismissed ) ) { | |
| 451 | - // we return the product install time - 4 days because we want to show the upsell after 3 days, | |
| 452 | - // and we move the product install time 4 days in the past. | |
| 453 | - return $this->product->get_install_time() - 4 * DAY_IN_SECONDS; | |
| 454 | - } | |
| 455 | - | |
| 456 | - return max( array_values( $dismissed ) ); | |
| 579 | + return empty( $dismissed ) ? false : max( array_values( $dismissed ) ); | |
| 457 | 580 | } |
| 458 | 581 | |
| 459 | 582 | /** |
| 460 | 583 | * Filter by screen & merge into single array of keys. |
| @@ -463,19 +586,45 @@ | ||
| 463 | 586 | */ |
| 464 | 587 | private function filter_by_screen_and_merge() { |
| 465 | 588 | $current_screen = get_current_screen(); |
| 466 | 589 | |
| 467 | - $is_elementor = isset( $_GET['action'] ) && $_GET['action'] === 'elementor'; | |
| 468 | - $is_media = isset( $current_screen->id ) && $current_screen->id === 'upload'; | |
| 469 | - $is_posts = isset( $current_screen->id ) && $current_screen->id === 'edit-post'; | |
| 470 | - $is_editor = method_exists( $current_screen, 'is_block_editor' ) && $current_screen->is_block_editor(); | |
| 471 | - $is_theme_install = isset( $current_screen->id ) && ( $current_screen->id === 'theme-install' || $current_screen->id === 'themes' ); | |
| 472 | - $is_product = isset( $current_screen->id ) && $current_screen->id === 'product'; | |
| 590 | + $is_elementor = isset( $_GET['action'] ) && $_GET['action'] === 'elementor'; | |
| 591 | + $is_media = isset( $current_screen->id ) && $current_screen->id === 'upload'; | |
| 592 | + $is_posts = isset( $current_screen->id ) && $current_screen->id === 'edit-post'; | |
| 593 | + $is_editor = method_exists( $current_screen, 'is_block_editor' ) && $current_screen->is_block_editor(); | |
| 594 | + $is_theme_install = isset( $current_screen->id ) && ( $current_screen->id === 'theme-install' ); | |
| 595 | + $is_plugin_install = isset( $current_screen->id ) && ( $current_screen->id === 'plugin-install' ); | |
| 596 | + $is_product = isset( $current_screen->id ) && $current_screen->id === 'product'; | |
| 597 | + $is_import = isset( $current_screen->id ) && $current_screen->id === 'import'; | |
| 598 | + $is_cf7_install = isset( $current_screen->id ) && function_exists( 'str_contains' ) ? str_contains( $current_screen->id, 'page_wpcf7' ) : false; | |
| 473 | 599 | |
| 474 | - $return = []; | |
| 475 | - | |
| 600 | + $return = []; | |
| 601 | + $product_install_time = (int) $this->product->get_install_time(); | |
| 602 | + $is_older = time() > ( $product_install_time + ( 3 * DAY_IN_SECONDS ) ); | |
| 603 | + $is_newer = time() < ( $product_install_time + ( 6 * HOUR_IN_SECONDS ) ); | |
| 476 | 604 | foreach ( $this->promotions as $slug => $promos ) { |
| 477 | 605 | foreach ( $promos as $key => $data ) { |
| 606 | + | |
| 607 | + $data = wp_parse_args( | |
| 608 | + $data, | |
| 609 | + [ | |
| 610 | + 'delayed' => false, | |
| 611 | + 'always' => false, | |
| 612 | + ] | |
| 613 | + ); | |
| 614 | + | |
| 615 | + if ( | |
| 616 | + ! $this->debug && | |
| 617 | + ( | |
| 618 | + ( $data['delayed'] === true && ! $is_older ) || // Skip promotions that are delayed for 3 days. | |
| 619 | + $is_newer // Skip promotions for the first 6 hours after install. | |
| 620 | + ) | |
| 621 | + && ! $data['always'] | |
| 622 | + ) { | |
| 623 | + unset( $this->promotions[ $slug ][ $key ] ); | |
| 624 | + | |
| 625 | + continue; | |
| 626 | + } | |
| 478 | 627 | switch ( $data['screen'] ) { |
| 479 | 628 | case 'media-editor': |
| 480 | 629 | if ( ! $is_media && ! $is_editor ) { |
| 481 | 630 | unset( $this->promotions[ $slug ][ $key ] ); |
| @@ -490,8 +639,13 @@ | ||
| 490 | 639 | if ( ! $is_editor || $is_elementor ) { |
| 491 | 640 | unset( $this->promotions[ $slug ][ $key ] ); |
| 492 | 641 | } |
| 493 | 642 | break; |
| 643 | + case 'import': | |
| 644 | + if ( ! $is_import ) { | |
| 645 | + unset( $this->promotions[ $slug ][ $key ] ); | |
| 646 | + } | |
| 647 | + break; | |
| 494 | 648 | case 'elementor': |
| 495 | 649 | if ( ! $is_elementor ) { |
| 496 | 650 | unset( $this->promotions[ $slug ][ $key ] ); |
| 497 | 651 | } |
| @@ -510,8 +664,18 @@ | ||
| 510 | 664 | if ( ! $is_theme_install ) { |
| 511 | 665 | unset( $this->promotions[ $slug ][ $key ] ); |
| 512 | 666 | } |
| 513 | 667 | break; |
| 668 | + case 'wpcf7': | |
| 669 | + if ( ! $is_cf7_install ) { | |
| 670 | + unset( $this->promotions[ $slug ][ $key ] ); | |
| 671 | + } | |
| 672 | + break; | |
| 673 | + case 'plugin-install': | |
| 674 | + if ( ! $is_plugin_install ) { | |
| 675 | + unset( $this->promotions[ $slug ][ $key ] ); | |
| 676 | + } | |
| 677 | + break; | |
| 514 | 678 | } |
| 515 | 679 | } |
| 516 | 680 | |
| 517 | 681 | $return = array_merge( $return, $this->promotions[ $slug ] ); |
| @@ -544,17 +708,27 @@ | ||
| 544 | 708 | } |
| 545 | 709 | if ( $this->get_upsells_dismiss_time( 'rop-posts' ) === false ) { |
| 546 | 710 | add_action( 'admin_notices', [ $this, 'render_rop_dash_notice' ] ); |
| 547 | 711 | } |
| 548 | - if ( $this->get_upsells_dismiss_time( 'neve-fse-themes-popular' ) === false ) { | |
| 549 | - add_action( 'admin_notices', [ $this, 'render_neve_fse_themes_notice' ] ); | |
| 712 | + if ( $this->get_upsells_dismiss_time( 'neve-themes-popular' ) === false ) { | |
| 713 | + add_action( 'admin_notices', [ $this, 'render_neve_themes_notice' ] ); | |
| 550 | 714 | } |
| 715 | + if ( $this->get_upsells_dismiss_time( 'redirection-cf7' ) === false ) { | |
| 716 | + add_action( 'admin_notices', [ $this, 'render_redirection_cf7_notice' ] ); | |
| 717 | + } | |
| 718 | + if ( $this->get_upsells_dismiss_time( 'hyve-plugins-install' ) === false ) { | |
| 719 | + add_action( 'admin_notices', [ $this, 'render_hyve_notice' ] ); | |
| 720 | + } | |
| 551 | 721 | |
| 722 | + if ( $this->get_upsells_dismiss_time( 'wp-full-pay-plugins-install' ) === false ) { | |
| 723 | + add_action( 'admin_notices', [ $this, 'render_wp_full_pay_notice' ] ); | |
| 724 | + } | |
| 725 | + | |
| 726 | + add_action( 'load-import.php', [ $this, 'add_import' ] ); | |
| 552 | 727 | $this->load_woo_promos(); |
| 553 | 728 | |
| 554 | 729 | return; |
| 555 | 730 | } |
| 556 | - | |
| 557 | 731 | switch ( $slug ) { |
| 558 | 732 | case 'om-editor': |
| 559 | 733 | case 'om-image-block': |
| 560 | 734 | case 'blocks-css': |
| @@ -572,8 +746,15 @@ | ||
| 572 | 746 | case 'rop-posts': |
| 573 | 747 | add_action( 'admin_enqueue_scripts', [ $this, 'enqueue' ] ); |
| 574 | 748 | add_action( 'admin_notices', [ $this, 'render_rop_dash_notice' ] ); |
| 575 | 749 | break; |
| 750 | + case 'feedzy-import': | |
| 751 | + add_action( 'load-import.php', [ $this, 'add_import' ] ); | |
| 752 | + | |
| 753 | + break; | |
| 754 | + case 'feedzy-editor': | |
| 755 | + add_action( 'enqueue_block_editor_assets', [ $this, 'enqueue' ] ); | |
| 756 | + break; | |
| 576 | 757 | case 'ppom': |
| 577 | 758 | case 'sparks-wishlist': |
| 578 | 759 | case 'sparks-announcement': |
| 579 | 760 | case 'sparks-product-reviews': |
| @@ -578,10 +759,10 @@ | ||
| 578 | 759 | case 'sparks-announcement': |
| 579 | 760 | case 'sparks-product-reviews': |
| 580 | 761 | $this->load_woo_promos(); |
| 581 | 762 | break; |
| 582 | - case 'neve-fse-themes-popular': | |
| 583 | - // Remove any other notifications if Neve FSE promotion is showing | |
| 763 | + case 'neve-themes-popular': | |
| 764 | + // Remove any other notifications if Neve promotion is showing | |
| 584 | 765 | remove_action( 'admin_notices', array( 'ThemeisleSDK\Modules\Notification', 'show_notification' ) ); |
| 585 | 766 | remove_action( |
| 586 | 767 | 'wp_ajax_themeisle_sdk_dismiss_notice', |
| 587 | 768 | array( |
| @@ -592,14 +773,45 @@ | ||
| 592 | 773 | remove_action( 'admin_head', array( 'ThemeisleSDK\Modules\Notification', 'dismiss_get' ) ); |
| 593 | 774 | remove_action( 'admin_head', array( 'ThemeisleSDK\Modules\Notification', 'setup_notifications' ) ); |
| 594 | 775 | // Add required actions to display this notification |
| 595 | 776 | add_action( 'admin_enqueue_scripts', [ $this, 'enqueue' ] ); |
| 596 | - add_action( 'admin_notices', [ $this, 'render_neve_fse_themes_notice' ] ); | |
| 777 | + add_action( 'admin_notices', [ $this, 'render_neve_themes_notice' ] ); | |
| 597 | 778 | break; |
| 779 | + case 'wpcf7': | |
| 780 | + add_action( 'admin_enqueue_scripts', [ $this, 'enqueue' ] ); | |
| 781 | + add_action( 'admin_notices', [ $this, 'render_redirection_cf7_notice' ] ); | |
| 782 | + break; | |
| 783 | + case 'hyve-plugins-install': | |
| 784 | + add_action( 'admin_enqueue_scripts', [ $this, 'enqueue' ] ); | |
| 785 | + add_action( 'admin_notices', [ $this, 'render_hyve_notice' ] ); | |
| 786 | + break; | |
| 787 | + case 'wp-full-pay-plugins-install': | |
| 788 | + add_action( 'admin_enqueue_scripts', [ $this, 'enqueue' ] ); | |
| 789 | + add_action( 'admin_notices', [ $this, 'render_wp_full_pay_notice' ] ); | |
| 790 | + break; | |
| 598 | 791 | } |
| 599 | 792 | } |
| 600 | 793 | |
| 601 | 794 | /** |
| 795 | + * Add import row. | |
| 796 | + * | |
| 797 | + * @return void | |
| 798 | + */ | |
| 799 | + public function add_import() { | |
| 800 | + global $wp_importers; | |
| 801 | + if ( isset( $wp_importers['feedzy-rss-feeds'] ) ) { | |
| 802 | + return; | |
| 803 | + } | |
| 804 | + $wp_importers['feedzy-rss-feeds'] = array( // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited | |
| 805 | + 'Feedzy', | |
| 806 | + sprintf( Loader::$labels['promotions']['feedzy']['import_desc'], '<span style="float: left; font-style: italic;margin-top:0.4em;">', $this->product->get_friendly_name(), '</span>' ), | |
| 807 | + 'install' => 'feedzy-rss-feeds', | |
| 808 | + ); | |
| 809 | + if ( defined( 'FEEDZY_BASEFILE' ) ) { | |
| 810 | + unset( $wp_importers['feedzy-rss-feeds']['install'] ); | |
| 811 | + } | |
| 812 | + } | |
| 813 | + /** | |
| 602 | 814 | * Render dashboard notice. |
| 603 | 815 | */ |
| 604 | 816 | public function render_optimole_dash_notice() { |
| 605 | 817 | $screen = get_current_screen(); |
| @@ -622,33 +834,66 @@ | ||
| 622 | 834 | $user = wp_get_current_user(); |
| 623 | 835 | $asset_file = require $themeisle_sdk_max_path . '/assets/js/build/promos/index.asset.php'; |
| 624 | 836 | $deps = array_merge( $asset_file['dependencies'], [ 'updates' ] ); |
| 625 | 837 | |
| 838 | + $themes = wp_get_themes(); | |
| 839 | + $neve_action = isset( $themes['neve'] ) ? 'activate' : 'install'; | |
| 840 | + $labels = Loader::$labels['promotions']; | |
| 841 | + $labels['feedzy']['editor_recommends'] = sprintf( | |
| 842 | + $labels['feedzy']['editor_recommends'], | |
| 843 | + $this->product->get_friendly_name(), | |
| 844 | + '<a target="_blank" href="' . add_query_arg( | |
| 845 | + array( | |
| 846 | + 'tab' => 'plugin-information', | |
| 847 | + 'plugin' => 'feedzy-rss-feeds', | |
| 848 | + '_wpnonce' => wp_create_nonce( 'activate-plugin_feedzy-rss-feeds' ), | |
| 849 | + 'feedzy_reference_key' => 'e-' . $this->product->get_key(), | |
| 850 | + ), | |
| 851 | + network_admin_url( 'plugin-install.php' ) | |
| 852 | + ) . '">', | |
| 853 | + '</a>' | |
| 854 | + ); | |
| 626 | 855 | wp_register_script( $handle, $themeisle_sdk_src . 'assets/js/build/promos/index.js', $deps, $asset_file['version'], true ); |
| 627 | 856 | wp_localize_script( |
| 628 | 857 | $handle, |
| 629 | 858 | 'themeisleSDKPromotions', |
| 630 | 859 | [ |
| 631 | - 'debug' => $this->debug, | |
| 632 | - 'labels' => [ | |
| 633 | - 'optimole' => Loader::$labels['promotions']['optimole'], | |
| 634 | - ], | |
| 635 | - 'email' => $user->user_email, | |
| 636 | - 'showPromotion' => $this->loaded_promo, | |
| 637 | - 'optionKey' => $this->option_main, | |
| 638 | - 'product' => $this->product->get_name(), | |
| 639 | - 'option' => empty( $saved ) ? new \stdClass() : $saved, | |
| 640 | - 'nonce' => wp_create_nonce( 'wp_rest' ), | |
| 641 | - 'assets' => $themeisle_sdk_src . 'assets/images/', | |
| 642 | - 'optimoleApi' => esc_url( rest_url( 'optml/v1/register_service' ) ), | |
| 643 | - 'optimoleActivationUrl' => $this->get_plugin_activation_link( 'optimole-wp' ), | |
| 644 | - 'otterActivationUrl' => $this->get_plugin_activation_link( 'otter-blocks' ), | |
| 645 | - 'ropActivationUrl' => $this->get_plugin_activation_link( 'tweet-old-post' ), | |
| 646 | - 'optimoleDash' => esc_url( add_query_arg( [ 'page' => 'optimole' ], admin_url( 'upload.php' ) ) ), | |
| 647 | - 'ropDash' => esc_url( add_query_arg( [ 'page' => 'TweetOldPost' ], admin_url( 'admin.php' ) ) ), | |
| 648 | - 'neveFSEMoreUrl' => tsdk_utmify( 'https://themeisle.com/themes/neve-fse/', 'neve-fse-themes-popular', 'theme-install' ), | |
| 860 | + 'debug' => $this->debug, | |
| 861 | + 'labels' => $labels, | |
| 862 | + 'email' => $user->user_email, | |
| 863 | + 'showPromotion' => $this->loaded_promo, | |
| 864 | + 'optionKey' => $this->option_main, | |
| 865 | + 'product' => $this->product->get_name(), | |
| 866 | + 'option' => empty( $saved ) ? new \stdClass() : $saved, | |
| 867 | + 'nonce' => wp_create_nonce( 'wp_rest' ), | |
| 868 | + 'assets' => $themeisle_sdk_src . 'assets/images/', | |
| 869 | + 'optimoleApi' => esc_url( rest_url( 'optml/v1/register_service' ) ), | |
| 870 | + 'optimoleActivationUrl' => $this->get_plugin_activation_link( 'optimole-wp' ), | |
| 871 | + 'otterActivationUrl' => $this->get_plugin_activation_link( 'otter-blocks' ), | |
| 872 | + 'ropActivationUrl' => $this->get_plugin_activation_link( 'tweet-old-post' ), | |
| 873 | + 'optimoleDash' => esc_url( add_query_arg( [ 'page' => 'optimole' ], admin_url( 'upload.php' ) ) ), | |
| 874 | + 'ropDash' => esc_url( add_query_arg( [ 'page' => 'TweetOldPost' ], admin_url( 'admin.php' ) ) ), | |
| 649 | 875 | // translators: %s is the product name. |
| 650 | - 'title' => esc_html( sprintf( Loader::$labels['promotions']['recommended'], $this->product->get_name() ) ), | |
| 876 | + 'title' => esc_html( sprintf( Loader::$labels['promotions']['recommended'], $this->product->get_name() ) ), | |
| 877 | + 'redirectionCF7MoreUrl' => tsdk_utmify( 'https://docs.themeisle.com/collection/2014-redirection-for-contact-form-7', 'redirection-for-contact-form-7', 'plugin-install' ), | |
| 878 | + 'rfCF7ActivationUrl' => $this->get_plugin_activation_link( 'wpcf7-redirect' ), | |
| 879 | + 'cf7Dash' => esc_url( add_query_arg( [ 'page' => 'wpcf7-new' ], admin_url( 'admin.php' ) ) ), | |
| 880 | + 'hyveActivationUrl' => $this->get_plugin_activation_link( 'hyve-lite' ), | |
| 881 | + 'hyveDash' => esc_url( add_query_arg( [ 'page' => 'wpfs-settings-stripe' ], admin_url( 'admin.php' ) ) ), | |
| 882 | + 'wpFullPayActivationUrl' => $this->get_plugin_activation_link( 'wp-full-stripe-free' ), | |
| 883 | + 'wpFullPayDash' => esc_url( add_query_arg( [ 'page' => 'wpfs-settings-stripe' ], admin_url( 'admin.php' ) ) ), | |
| 884 | + 'nevePreviewURL' => esc_url( add_query_arg( [ 'theme' => 'neve' ], admin_url( 'theme-install.php' ) ) ), | |
| 885 | + 'neveAction' => $neve_action, | |
| 886 | + 'activateNeveURL' => esc_url( | |
| 887 | + add_query_arg( | |
| 888 | + [ | |
| 889 | + 'action' => 'activate', | |
| 890 | + 'stylesheet' => 'neve', | |
| 891 | + '_wpnonce' => wp_create_nonce( 'switch-theme_neve' ), | |
| 892 | + ], | |
| 893 | + admin_url( 'themes.php' ) | |
| 894 | + ) | |
| 895 | + ), | |
| 651 | 896 | ] |
| 652 | 897 | ); |
| 653 | 898 | wp_enqueue_script( $handle ); |
| 654 | 899 | wp_enqueue_style( $handle, $themeisle_sdk_src . 'assets/js/build/promos/style-index.css', [ 'wp-components' ], $asset_file['version'] ); |
| @@ -667,15 +912,36 @@ | ||
| 667 | 912 | echo '<div id="ti-rop-notice" class="notice notice-info ti-sdk-rop-notice"></div>'; |
| 668 | 913 | } |
| 669 | 914 | |
| 670 | 915 | /** |
| 671 | - * Render Neve FSE Themes notice. | |
| 916 | + * Render Neve Themes notice. | |
| 672 | 917 | */ |
| 673 | - public function render_neve_fse_themes_notice() { | |
| 674 | - echo '<div id="ti-neve-fse-notice" class="notice notice-info ti-sdk-neve-fse-notice"></div>'; | |
| 918 | + public function render_neve_themes_notice() { | |
| 919 | + echo '<div id="ti-neve-notice" class="notice notice-info ti-sdk-om-notice"></div>'; | |
| 675 | 920 | } |
| 676 | 921 | |
| 677 | 922 | /** |
| 923 | + * Render Hyve notice. | |
| 924 | + */ | |
| 925 | + public function render_hyve_notice() { | |
| 926 | + echo '<div id="ti-hyve-notice" class="notice notice-info ti-sdk-om-notice"></div>'; | |
| 927 | + } | |
| 928 | + | |
| 929 | + /** | |
| 930 | + * Render WP Full Pay notice. | |
| 931 | + */ | |
| 932 | + public function render_wp_full_pay_notice() { | |
| 933 | + echo '<div id="ti-wp-full-pay-notice" class="notice notice-info ti-sdk-om-notice"></div>'; | |
| 934 | + } | |
| 935 | + | |
| 936 | + /** | |
| 937 | + * Render Redirection for CF7 notice. | |
| 938 | + */ | |
| 939 | + public function render_redirection_cf7_notice() { | |
| 940 | + echo '<div id="ti-redirection-cf7-notice" class="notice notice-info ti-sdk-om-notice"></div>'; | |
| 941 | + } | |
| 942 | + | |
| 943 | + /** | |
| 678 | 944 | * Add promo to attachment modal. |
| 679 | 945 | * |
| 680 | 946 | * @param array $fields Fields array. |
| 681 | 947 | * @param \WP_Post $post Post object. |
| @@ -692,9 +958,9 @@ | ||
| 692 | 958 | } |
| 693 | 959 | |
| 694 | 960 | $meta = wp_get_attachment_metadata( $post->ID ); |
| 695 | 961 | |
| 696 | - if ( isset( $meta['filesize'] ) && $meta['filesize'] < 200000 ) { | |
| 962 | + if ( isset( $meta['filesize'] ) && $meta['filesize'] < 100000 ) { | |
| 697 | 963 | return $fields; |
| 698 | 964 | } |
| 699 | 965 | |
| 700 | 966 | $fields['optimole'] = array( |
| @@ -922,9 +1188,8 @@ | ||
| 922 | 1188 | .tisdk-suggestions_options a::before { |
| 923 | 1189 | content: url("data:image/svg+xml,%3Csvg fill='%23135e96' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'%3E%3Cpath d='<?php echo esc_attr( $icon ); ?>'/%3E%3C/svg%3E") !important; |
| 924 | 1190 | min-width: 13px; |
| 925 | 1191 | max-width: 13px; |
| 926 | - margin: auto; | |
| 927 | 1192 | } |
| 928 | 1193 | |
| 929 | 1194 | .tisdk-suggestions_options.active a::before { |
| 930 | 1195 | content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'%3E%3Cpath d='<?php echo esc_attr( $icon ); ?>'/%3E%3C/svg%3E") !important; |
| @@ -1082,6 +1347,63 @@ | ||
| 1082 | 1347 | ); |
| 1083 | 1348 | |
| 1084 | 1349 | wp_send_json( $response ); |
| 1085 | 1350 | wp_die(); |
| 1351 | + } | |
| 1352 | + | |
| 1353 | + /** | |
| 1354 | + * Check if the user has a support page. | |
| 1355 | + */ | |
| 1356 | + public function has_support_page() { | |
| 1357 | + $transient_name = 'tisdk_has_support_page'; | |
| 1358 | + $has_support = get_transient( $transient_name ); | |
| 1359 | + | |
| 1360 | + if ( false === $has_support ) { | |
| 1361 | + global $wpdb; | |
| 1362 | + | |
| 1363 | + // We use %i escape identifier that was added in WP 6.2.0, hence need to ignore PHPCS warning. | |
| 1364 | + // We only show this notice to users on higher version as that is the minimum for Hyve as well. | |
| 1365 | + $query = $wpdb->get_var( //phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching | |
| 1366 | + $wpdb->prepare( // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders.ReplacementsWrongNumber | |
| 1367 | + 'SELECT ID FROM %i WHERE post_type = %s AND post_status = %s AND post_title LIKE %s LIMIT 1', // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders.UnsupportedPlaceholder | |
| 1368 | + $wpdb->posts, | |
| 1369 | + 'page', | |
| 1370 | + 'publish', | |
| 1371 | + '%support%' | |
| 1372 | + ) | |
| 1373 | + ); | |
| 1374 | + | |
| 1375 | + $has_support = $query ? 'yes' : 'no'; | |
| 1376 | + | |
| 1377 | + set_transient( $transient_name, $has_support, 7 * DAY_IN_SECONDS ); | |
| 1378 | + } | |
| 1379 | + | |
| 1380 | + return 'yes' === $has_support; | |
| 1381 | + } | |
| 1382 | + | |
| 1383 | + /** | |
| 1384 | + * Check if the user has a donate page. | |
| 1385 | + */ | |
| 1386 | + public function has_donate_page() { | |
| 1387 | + $transient_name = 'tisdk_has_donate_page'; | |
| 1388 | + $has_donate = get_transient( $transient_name ); | |
| 1389 | + | |
| 1390 | + if ( false === $has_donate ) { | |
| 1391 | + global $wpdb; | |
| 1392 | + | |
| 1393 | + $query = $wpdb->get_var( //phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching | |
| 1394 | + $wpdb->prepare( | |
| 1395 | + 'SELECT ID FROM ' . $wpdb->posts . ' WHERE post_type = %s AND post_status = %s AND post_title LIKE %s LIMIT 1', | |
| 1396 | + 'page', | |
| 1397 | + 'publish', | |
| 1398 | + '%donate%' | |
| 1399 | + ) | |
| 1400 | + ); | |
| 1401 | + | |
| 1402 | + $has_donate = $query ? 'yes' : 'no'; | |
| 1403 | + | |
| 1404 | + set_transient( $transient_name, $has_donate, 7 * DAY_IN_SECONDS ); | |
| 1405 | + } | |
| 1406 | + | |
| 1407 | + return 'yes' === $has_donate; | |
| 1086 | 1408 | } |
| 1087 | 1409 | } |