| @@ -67,9 +67,9 @@ | ||
| 67 | 67 | if ( ! isset( $transient->no_update ) || ! is_array( $transient->no_update ) ) { |
| 68 | 68 | $transient->no_update = []; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - $addons = AddonService::instance()->get_remote_data(); | |
| 71 | + $addons = AddonService::instance()->get_addons(); | |
| 72 | 72 | $plugins = get_plugins(); |
| 73 | 73 | |
| 74 | 74 | foreach ( $addons as $slug => $addon ) { |
| 75 | 75 | // Skip addons hosted on wp.org - core already handles them. |
| @@ -113,9 +113,9 @@ | ||
| 113 | 113 | * @return void |
| 114 | 114 | */ |
| 115 | 115 | public function wp_update_plugin_message(): void { |
| 116 | 116 | try { |
| 117 | - $addons = AddonService::instance()->get_remote_data(); | |
| 117 | + $addons = AddonService::instance()->get_addons(); | |
| 118 | 118 | $plugins = get_plugins(); |
| 119 | 119 | |
| 120 | 120 | foreach ( $addons as $addon ) { |
| 121 | 121 | if ( ! empty( $addon->is_org ) ) { |
| @@ -202,14 +202,13 @@ | ||
| 202 | 202 | * |
| 203 | 203 | * @return void |
| 204 | 204 | */ |
| 205 | 205 | public function html_page() { |
| 206 | - /** @use self::render_addons */ | |
| 207 | 206 | $section = apply_filters( |
| 208 | 207 | 'learn-press/admin/addons/page-section', |
| 209 | 208 | array( |
| 210 | 209 | 'wrapper' => '<div class="lp-addons-page">', |
| 211 | - 'notice' => sprintf( | |
| 210 | + 'notice' => sprintf( | |
| 212 | 211 | '<div class="lp-addon-notice">%s</div>', |
| 213 | 212 | Template::print_message( |
| 214 | 213 | sprintf( |
| 215 | 214 | '<div>%s</div>', |
| @@ -225,19 +224,25 @@ | ||
| 225 | 224 | 'info', |
| 226 | 225 | false |
| 227 | 226 | ) |
| 228 | 227 | ), |
| 228 | + 'title' => sprintf( | |
| 229 | + '<h1 class="lp-be-page-title">%s</h1>', | |
| 230 | + esc_html__( 'LearnPress Add-ons New', 'learnpress' ) | |
| 231 | + ), | |
| 229 | 232 | 'subtitle' => sprintf( |
| 230 | - '<p class="lp-addons-page-subtitle">%s</p>', | |
| 233 | + '<p class="lp-be-page-subtitle">%s</p>', | |
| 231 | 234 | esc_html__( |
| 232 | 235 | 'Discover high-performance Premium & Education themes optimized 100% for LearnPress LMS.', |
| 233 | 236 | 'learnpress' |
| 234 | 237 | ) |
| 235 | 238 | ), |
| 239 | + /** @use self::render_addons */ | |
| 236 | 240 | 'addons' => TemplateAJAX::load_content_via_ajax( |
| 237 | 241 | array( |
| 238 | 242 | 'id_url' => 'data-addons', |
| 239 | 243 | 'tab' => $_REQUEST['tab'] ?? '', |
| 244 | + 'ex-date-test' => $_REQUEST['ex-date-test'] ?? '', | |
| 240 | 245 | ), |
| 241 | 246 | array( |
| 242 | 247 | 'class' => self::class, |
| 243 | 248 | 'method' => 'render_addons', |
| @@ -249,10 +254,11 @@ | ||
| 249 | 254 | |
| 250 | 255 | echo AdminTemplate::html_on_wp_admin_screen( |
| 251 | 256 | array( |
| 252 | 257 | 'content' => Template::combine_components( $section ), |
| 253 | - 'title' => __( 'LearnPress Add-ons', 'learnpress' ), | |
| 258 | + 'title' => '', | |
| 254 | 259 | 'id' => 'learn-press-addons', |
| 260 | + 'hide_notices_wp' => true, | |
| 255 | 261 | ) |
| 256 | 262 | ); |
| 257 | 263 | } |
| 258 | 264 | |
| @@ -275,9 +281,9 @@ | ||
| 275 | 281 | |
| 276 | 282 | $addons = AddonService::instance()->get_addons(); |
| 277 | 283 | $plugins_installed = get_plugins(); |
| 278 | 284 | $plugins_activated = get_option( 'active_plugins', array() ); |
| 279 | - $active_tab = LP_Helper::sanitize_params_submitted( $data['tab'] ) ?? 'all'; | |
| 285 | + $active_tab = ! empty( $data['tab'] ) ? LP_Helper::sanitize_params_submitted( $data['tab'] ) : 'all'; | |
| 280 | 286 | $keys_purchase = LP_Settings::get_option( AddonService::instance()->key_purchase_addons, array() ); |
| 281 | 287 | |
| 282 | 288 | $section = apply_filters( |
| 283 | 289 | 'learn-press/admin/addons/section', |
| @@ -294,8 +300,9 @@ | ||
| 294 | 300 | 'plugins_installed' => $plugins_installed, |
| 295 | 301 | 'plugins_activated' => $plugins_activated, |
| 296 | 302 | 'active_tab' => $active_tab, |
| 297 | 303 | 'keys_purchase' => $keys_purchase, |
| 304 | + 'ex-date-test' => $data['ex-date-test'] ?? '', | |
| 298 | 305 | ) |
| 299 | 306 | ), |
| 300 | 307 | 'wrapper_end' => '</div>', |
| 301 | 308 | ), |
| @@ -322,78 +329,107 @@ | ||
| 322 | 329 | * |
| 323 | 330 | * @return string |
| 324 | 331 | */ |
| 325 | 332 | public static function html_controls( array $data = [] ): string { |
| 326 | - $active_tab = $data['active_tab'] ?? 'all'; | |
| 333 | + $active_tab = ! empty( $data['active_tab'] ) ? $data['active_tab'] : 'all'; | |
| 327 | 334 | $tabs = array( |
| 328 | 335 | 'all' => sprintf( '%s (<span></span>)', __( 'All', 'learnpress' ) ), |
| 329 | 336 | 'installed' => sprintf( '%s (<span></span>)', __( 'Installed', 'learnpress' ) ), |
| 330 | 337 | 'purchase' => sprintf( '%s (<span></span>)', __( 'Paid', 'learnpress' ) ), |
| 331 | 338 | 'free' => sprintf( '%s (<span></span>)', __( 'Free', 'learnpress' ) ), |
| 332 | - 'update' => sprintf( '%s (<span></span>)', __( 'Updated', 'learnpress' ) ), | |
| 333 | - 'license' => sprintf( '%s (<span></span>)', __( 'License', 'learnpress' ) ), | |
| 339 | + 'update' => sprintf( '%s (<span></span>)', __( 'Updated Available', 'learnpress' ) ), | |
| 340 | + 'license' => sprintf( '%s (<span></span>)', __( 'Licensed', 'learnpress' ) ), | |
| 334 | 341 | 'not_installed' => sprintf( '%s (<span></span>)', __( 'Not Installed', 'learnpress' ) ), |
| 335 | 342 | ); |
| 336 | 343 | $addon_categories = array( |
| 337 | 344 | 'create-course' => __( 'Create Course', 'learnpress' ), |
| 338 | - 'engagement' => __( 'Engagement', 'learnpress' ), | |
| 339 | - 'learnpress' => __( 'LearnPress', 'learnpress' ), | |
| 340 | 345 | 'manage-course' => __( 'Manage Course', 'learnpress' ), |
| 341 | - 'marketing-optimization' => __( 'Marketing Optimization', 'learnpress' ), | |
| 342 | 346 | 'monetize-course' => __( 'Monetize Course', 'learnpress' ), |
| 343 | 347 | 'payment' => __( 'Payment', 'learnpress' ), |
| 348 | + 'engagement' => __( 'Engagement', 'learnpress' ), | |
| 349 | + 'marketing-optimization' => __( 'Marketing Optimization', 'learnpress' ), | |
| 344 | 350 | ); |
| 345 | 351 | |
| 346 | 352 | $section_tabs = array(); |
| 347 | 353 | foreach ( $tabs as $tab => $tab_title ) { |
| 348 | - $active_class = ( $tab === $active_tab ) ? ' nav-tab-active' : ''; | |
| 354 | + $is_active = ( $tab === $active_tab ); | |
| 355 | + $active_class = $is_active ? ' nav-tab-active' : ''; | |
| 356 | + $aria_pressed = $is_active ? 'true' : 'false'; | |
| 349 | 357 | |
| 350 | - if ( $active_class ) { | |
| 351 | - $section_tabs[ $tab ] = sprintf( | |
| 352 | - '<a class="lp-addons-filter__item nav-tab%s" data-tab="%s" href="#" aria-pressed="true">%s</a>', | |
| 353 | - esc_attr( $active_class ), | |
| 354 | - esc_attr( $tab ), | |
| 355 | - wp_kses_post( $tab_title ) | |
| 356 | - ); | |
| 357 | - } else { | |
| 358 | - $section_tabs[ $tab ] = sprintf( | |
| 359 | - '<a class="lp-addons-filter__item nav-tab" | |
| 360 | - data-tab="%s" aria-pressed="false" href="?page=learn-press-addons&tab=%s">%s</a>', | |
| 361 | - esc_attr( $tab ), | |
| 362 | - esc_attr( $tab ), | |
| 363 | - wp_kses_post( $tab_title ) | |
| 364 | - ); | |
| 365 | - } | |
| 358 | + $section_tabs[ $tab ] = sprintf( | |
| 359 | + '<button type="button" class="lp-addons-filter__item nav-tab lp-be-nav-tab%s" data-tab="%s" aria-pressed="%s">%s</button>', | |
| 360 | + esc_attr( $active_class ), | |
| 361 | + esc_attr( $tab ), | |
| 362 | + esc_attr( $aria_pressed ), | |
| 363 | + wp_kses_post( $tab_title ) | |
| 364 | + ); | |
| 366 | 365 | } |
| 367 | 366 | |
| 368 | 367 | $section = array( |
| 369 | 368 | 'wrapper' => '<div class="lp-addons-controls">', |
| 370 | - 'toolbar' => '<div class="lp-nav-tab-wrapper lp-addons-toolbar">', | |
| 371 | - 'filter' => sprintf( | |
| 372 | - '<div class="lp-addons-filter" role="group" aria-label="%s">', | |
| 373 | - esc_attr__( 'Filter add-ons', 'learnpress' ) | |
| 369 | + 'toolbar' => '<div class="lp-nav-tab-wrapper lp-addons-toolbar lp-be-toolbar">', | |
| 370 | + 'toolbar_primary' => '<div class="lp-addons-toolbar__primary lp-be-toolbar__main">', | |
| 371 | + 'filter' => sprintf( | |
| 372 | + '<div class="lp-addons-filter" role="group" aria-label="%s"> | |
| 373 | + <button type="button" class="lp-addons-filter__toggle" aria-label="%s" aria-expanded="false" aria-haspopup="true"> | |
| 374 | + <span class="lp-addons-filter__toggle-content"> | |
| 375 | + <span class="lp-addons-filter__toggle-state lp-addons-filter__toggle-state--filter"> | |
| 376 | + <svg class="lp-addons-filter__toggle-icon lp-addons-filter__toggle-icon--filter" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> | |
| 377 | + <polygon points="22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"></polygon> | |
| 378 | + </svg> | |
| 379 | + <span class="lp-addons-filter__toggle-text">%s</span> | |
| 380 | + </span> | |
| 381 | + <span class="lp-addons-filter__toggle-state lp-addons-filter__toggle-state--close"> | |
| 382 | + <svg class="lp-addons-filter__toggle-icon lp-addons-filter__toggle-icon--close" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> | |
| 383 | + <line x1="18" y1="6" x2="6" y2="18"></line> | |
| 384 | + <line x1="6" y1="6" x2="18" y2="18"></line> | |
| 385 | + </svg> | |
| 386 | + <span class="lp-addons-filter__toggle-text">%s</span> | |
| 387 | + </span> | |
| 388 | + </span> | |
| 389 | + </button> | |
| 390 | + <div class="lp-addons-filter__menu">', | |
| 391 | + esc_attr__( 'Filter add-ons', 'learnpress' ), | |
| 392 | + esc_attr__( 'Filter add-ons', 'learnpress' ), | |
| 393 | + esc_html__( 'Filter', 'learnpress' ), | |
| 394 | + esc_html__( 'Close', 'learnpress' ) | |
| 374 | 395 | ), |
| 375 | - 'tabs' => Template::combine_components( $section_tabs ), | |
| 376 | - 'filter_end' => '</div>', | |
| 377 | - 'search' => '<label class="lp-search-addons lp-addons-search">', | |
| 378 | - 'search_text' => sprintf( | |
| 379 | - '<span class="screen-reader-text">%s</span>', | |
| 380 | - esc_html__( 'Search add-ons', 'learnpress' ) | |
| 396 | + 'tabs' => Template::combine_components( $section_tabs ), | |
| 397 | + 'filter_end' => '</div></div>', | |
| 398 | + 'search' => '<div class="lp-search-addons lp-addons-search lp-be-search">', | |
| 399 | + 'search_btn' => sprintf( | |
| 400 | + '<button type="button" class="lp-addons-search__btn lp-be-search__btn" aria-label="%s" aria-expanded="false"> | |
| 401 | + <span class="lp-addons-search__icon lp-icon-search" aria-hidden="true"></span> | |
| 402 | + </button>', | |
| 403 | + esc_attr__( 'Search add-ons', 'learnpress' ) | |
| 381 | 404 | ), |
| 382 | - 'search_icon' => '<span class="lp-addons-search__icon lp-icon-search" aria-hidden="true"></span>', | |
| 383 | - 'search_input' => sprintf( | |
| 384 | - '<input id="lp-search-addons__input" | |
| 385 | - class="lp-addons-search__input" type="search" placeholder="%s"/>', | |
| 386 | - esc_attr__( 'Search add-ons by name…', 'learnpress' ) | |
| 405 | + 'search_field' => sprintf( | |
| 406 | + '<div class="lp-addons-search__field lp-be-search__field"> | |
| 407 | + <span class="screen-reader-text">%s</span> | |
| 408 | + <div class="lp-addons-search__input-wrap lp-be-search__input-wrap"> | |
| 409 | + <span class="lp-addons-search__field-icon lp-be-search__field-icon lp-icon-search" aria-hidden="true"></span> | |
| 410 | + <input id="lp-search-addons__input" | |
| 411 | + class="lp-addons-search__input lp-be-search__input" type="search" placeholder="%s" autocomplete="off"/> | |
| 412 | + </div> | |
| 413 | + <button type="button" class="lp-addons-search__btn-clear lp-be-search__btn-clear" disabled>%s</button> | |
| 414 | + <button type="button" class="lp-addons-search__close lp-be-search__close" aria-label="%s"> | |
| 415 | + <span aria-hidden="true">×</span> | |
| 416 | + </button> | |
| 417 | + </div>', | |
| 418 | + esc_html__( 'Search add-ons', 'learnpress' ), | |
| 419 | + esc_attr__( 'Search add-ons by name…', 'learnpress' ), | |
| 420 | + esc_html__( 'Clear', 'learnpress' ), | |
| 421 | + esc_attr__( 'Close search', 'learnpress' ) | |
| 387 | 422 | ), |
| 388 | - 'search_end' => '</label>', | |
| 389 | - 'toolbar_end' => '</div>', | |
| 390 | - 'categories' => self::html_categories( | |
| 423 | + 'search_end' => '</div>', | |
| 424 | + 'toolbar_primary_end' => '</div>', | |
| 425 | + 'categories' => self::html_categories( | |
| 391 | 426 | array( |
| 392 | 427 | 'addon_categories' => $addon_categories, |
| 393 | 428 | ) |
| 394 | 429 | ), |
| 395 | - 'wrapper_end' => '</div>', | |
| 430 | + 'toolbar_end' => '</div>', | |
| 431 | + 'wrapper_end' => '</div>', | |
| 396 | 432 | ); |
| 397 | 433 | |
| 398 | 434 | return Template::combine_components( $section ); |
| 399 | 435 | } |
| @@ -408,15 +444,14 @@ | ||
| 408 | 444 | public static function html_categories( array $data = [] ): string { |
| 409 | 445 | $addon_categories = $data['addon_categories'] ?? array(); |
| 410 | 446 | $section = array( |
| 411 | 447 | 'wrapper' => sprintf( |
| 412 | - '<div class="lp-addons-categories" role="group" aria-label="%s">', | |
| 448 | + '<div class="lp-addons-categories lp-be-categories" role="group" aria-label="%s">', | |
| 413 | 449 | esc_attr__( 'Filter add-ons by category', 'learnpress' ) |
| 414 | 450 | ), |
| 415 | 451 | 'all' => sprintf( |
| 416 | - '<button type="button" class="lp-addons-category active" | |
| 417 | - data-category="all" aria-pressed="true">%s <span class="lp-addons-category__count"></span> | |
| 418 | - </button>', | |
| 452 | + '<button type="button" class="lp-addons-category lp-be-category active" | |
| 453 | + data-category="all" aria-pressed="true">%s</button>', | |
| 419 | 454 | esc_html__( 'All', 'learnpress' ) |
| 420 | 455 | ), |
| 421 | 456 | ); |
| 422 | 457 | |
| @@ -421,11 +456,10 @@ | ||
| 421 | 456 | ); |
| 422 | 457 | |
| 423 | 458 | foreach ( $addon_categories as $category_slug => $category_label ) { |
| 424 | 459 | $section[ $category_slug ] = sprintf( |
| 425 | - '<button type="button" class="lp-addons-category" | |
| 426 | - data-category="%s" aria-pressed="false">%s <span class="lp-addons-category__count"></span> | |
| 427 | - </button>', | |
| 460 | + '<button type="button" class="lp-addons-category lp-be-category" | |
| 461 | + data-category="%s" aria-pressed="false">%s</button>', | |
| 428 | 462 | esc_attr( $category_slug ), |
| 429 | 463 | esc_html( $category_label ) |
| 430 | 464 | ); |
| 431 | 465 | } |
| @@ -478,18 +512,9 @@ | ||
| 478 | 512 | ), |
| 479 | 513 | 'content' => '<div class="lp-addon-item__content">', |
| 480 | 514 | 'header' => self::html_addon_header( $addon ), |
| 481 | 515 | 'license' => ! $state['is_free'] |
| 482 | - ? self::html_addon_license( | |
| 483 | - $addon, | |
| 484 | - array( | |
| 485 | - 'license_status' => $state['license_status'], | |
| 486 | - 'number_days_remaining' => $state['number_days_remaining'], | |
| 487 | - 'date_expired' => $state['date_expired'], | |
| 488 | - 'purchase_code_masked' => $state['purchase_code_masked'], | |
| 489 | - 'show_license_panel' => $state['show_license_panel'], | |
| 490 | - ) | |
| 491 | - ) | |
| 516 | + ? self::html_addon_license( $addon, $state ) | |
| 492 | 517 | : '', |
| 493 | 518 | 'description' => sprintf( |
| 494 | 519 | '<p class="lp-addon-item__description" title="%s">%s</p>', |
| 495 | 520 | esc_attr( $addon->description ?? '' ), |
| @@ -508,16 +533,9 @@ | ||
| 508 | 533 | esc_html( $state['version_latest'] ) |
| 509 | 534 | ) |
| 510 | 535 | : '', |
| 511 | 536 | 'content_end' => '</div>', |
| 512 | - 'actions' => self::html_addon_actions( | |
| 513 | - $addon, | |
| 514 | - array( | |
| 515 | - 'is_free' => $state['is_free'], | |
| 516 | - 'is_installed' => $state['is_installed'], | |
| 517 | - 'is_updated' => $state['is_updated'], | |
| 518 | - ) | |
| 519 | - ), | |
| 537 | + 'actions' => self::html_addon_actions( $addon ), | |
| 520 | 538 | 'purchase' => self::html_purchase_panel( |
| 521 | 539 | $addon, |
| 522 | 540 | array( |
| 523 | 541 | 'purchase_code_masked' => $state['purchase_code_masked'], |
| @@ -583,9 +601,9 @@ | ||
| 583 | 601 | } |
| 584 | 602 | |
| 585 | 603 | if ( $addon_purchased ) { |
| 586 | 604 | $classes_status[] = 'license'; |
| 587 | - $date_expired_str = $addon_purchased->date_expire ?? ''; | |
| 605 | + $date_expired_str = ! empty( $data['ex-date-test'] ) ? $data['ex-date-test'] : ( $addon_purchased->date_expire ?? '' ); | |
| 588 | 606 | if ( ! empty( $date_expired_str ) ) { |
| 589 | 607 | $date_expired = new DateTime( $date_expired_str ); |
| 590 | 608 | $date_now = new DateTime( gmdate( 'Y-m-d' ) ); |
| 591 | 609 | $date_diff = date_diff( $date_now, $date_expired ); |
| @@ -604,9 +622,10 @@ | ||
| 604 | 622 | $classes_status[] = 'expired'; |
| 605 | 623 | } |
| 606 | 624 | } |
| 607 | 625 | |
| 608 | - $purchase_code_masked = AddonService::mask_purchase_code( $keys_purchase[ $addon->slug ] ?? '' ); | |
| 626 | + $purchase_code = $keys_purchase[ $addon->slug ] ?? ''; | |
| 627 | + $purchase_code_masked = AddonService::mask_purchase_code( $purchase_code ); | |
| 609 | 628 | |
| 610 | 629 | if ( ! in_array( $active_tab, $classes_status, true ) && 'all' !== $active_tab ) { |
| 611 | 630 | $classes_status[] = 'hide'; |
| 612 | 631 | } |
| @@ -620,8 +639,9 @@ | ||
| 620 | 639 | 'version_latest' => $version_latest, |
| 621 | 640 | 'license_status' => $license_status, |
| 622 | 641 | 'number_days_remaining' => $number_days_remaining, |
| 623 | 642 | 'date_expired' => $date_expired, |
| 643 | + 'purchase_code' => $purchase_code, | |
| 624 | 644 | 'purchase_code_masked' => $purchase_code_masked, |
| 625 | 645 | 'show_license_panel' => $show_license_panel, |
| 626 | 646 | 'addon_category' => $addon_category, |
| 627 | 647 | ); |
| @@ -673,8 +693,9 @@ | ||
| 673 | 693 | $license_status = $data['license_status'] ?? ''; |
| 674 | 694 | $number_days_remaining = $data['number_days_remaining'] ?? null; |
| 675 | 695 | /** @var DateTime $date_expired */ |
| 676 | 696 | $date_expired = $data['date_expired'] ?? null; |
| 697 | + $purchase_code = $data['purchase_code'] ?? ''; | |
| 677 | 698 | $purchase_code_masked = $data['purchase_code_masked'] ?? ''; |
| 678 | 699 | $show_license_panel = $data['show_license_panel'] ?? false; |
| 679 | 700 | $license_status_label = 'active' === $license_status |
| 680 | 701 | ? __( 'Active', 'learnpress' ) |
| @@ -696,43 +717,38 @@ | ||
| 696 | 717 | : __( '(Updates until %s)', 'learnpress' ); |
| 697 | 718 | $expiry_text = esc_html( sprintf( $expiry_format, $lpDate->format( LPDateTime::FORMAT_I18N_DATE ) ) ); |
| 698 | 719 | } |
| 699 | 720 | |
| 700 | - $extend_link = ''; | |
| 701 | - if ( 'expired' === $license_status ) { | |
| 702 | - $extend_link = sprintf( | |
| 703 | - '<a class="need-extend__link" href="%s" target="_blank" rel="noopener">%s</a>', | |
| 704 | - esc_url( $addon->link ?? '' ), | |
| 705 | - esc_html__( 'Extend now', 'learnpress' ) | |
| 706 | - ); | |
| 707 | - } | |
| 721 | + $link_extend = add_query_arg( | |
| 722 | + 'purchase_code', | |
| 723 | + $purchase_code, | |
| 724 | + AddonService::instance()->link_extend_site | |
| 725 | + ); | |
| 726 | + $html_extend_link = sprintf( | |
| 727 | + '<a class="need-extend__link" href="%s" target="_blank" rel="noopener">%s</a>', | |
| 728 | + esc_url( $link_extend ), | |
| 729 | + esc_html__( 'Extend now', 'learnpress' ) | |
| 730 | + ); | |
| 708 | 731 | |
| 709 | - $message = ''; | |
| 710 | - $button_extends = ''; | |
| 732 | + $html_near_expire = ''; | |
| 711 | 733 | if ( ! empty( $addon->purchase_info ) ) { |
| 712 | - $button_extends = sprintf( | |
| 713 | - '<a class="need-extend__link" href="%s" target="_blank" rel="noopener">%s</a>', | |
| 714 | - esc_url( $addon->link ?? '' ), | |
| 715 | - esc_html__( 'Extend now', 'learnpress' ) | |
| 716 | - ); | |
| 717 | - | |
| 718 | 734 | if ( isset( $number_days_remaining ) && $number_days_remaining > 0 && $number_days_remaining < 61 ) { |
| 719 | - $message = sprintf( | |
| 735 | + $message_near_expire = sprintf( | |
| 720 | 736 | __( 'You have a license for this item with %s day(s) of update & support remaining. Please extend your update & support license to continue receiving the latest versions and customer support from Thimpress before it expires.', 'learnpress' ), |
| 721 | 737 | sprintf( '<strong class="need-extend__days">%d</strong>', $number_days_remaining ) |
| 722 | 738 | ); |
| 723 | - } else { | |
| 724 | - $button_extends = ''; | |
| 739 | + | |
| 740 | + $html_near_expire = sprintf( | |
| 741 | + '<span class="need-extend">%s %s</span>', | |
| 742 | + $message_near_expire, | |
| 743 | + $html_extend_link | |
| 744 | + ); | |
| 725 | 745 | } |
| 726 | 746 | } |
| 727 | 747 | |
| 728 | - $need_extend = ''; | |
| 729 | - if ( ! empty( $message ) || ! empty( $button_extends ) ) { | |
| 730 | - $need_extend = sprintf( | |
| 731 | - '<span class="need-extend">%s %s</span>', | |
| 732 | - $message, | |
| 733 | - $button_extends | |
| 734 | - ); | |
| 748 | + $text_btn_to_purchase_code = esc_html__( 'Activate Now', 'learnpress' ); | |
| 749 | + if ( ! empty( $purchase_code ) ) { | |
| 750 | + $text_btn_to_purchase_code = esc_html__( 'Change License', 'learnpress' ); | |
| 735 | 751 | } |
| 736 | 752 | |
| 737 | 753 | $section = array( |
| 738 | 754 | 'wrapper' => sprintf( |
| @@ -754,15 +770,23 @@ | ||
| 754 | 770 | '<span class="lp-addon-license__expiry"%s>%s</span>', |
| 755 | 771 | $expiry_hidden, |
| 756 | 772 | $expiry_text |
| 757 | 773 | ), |
| 758 | - 'extend_link' => $extend_link, | |
| 774 | + 'extend_link' => 'expired' === $license_status ? $html_extend_link : '', | |
| 759 | 775 | 'summary_end' => '</div>', |
| 760 | - 'need_extend' => $need_extend, | |
| 776 | + 'near_expire' => $html_near_expire, | |
| 777 | + 'cancel_btn' => '<button | |
| 778 | + class="lp-button btn-addon-action lp-be-btn lp-be-btn--outline lp-addon-purchase__cancel-clear lp-hidden" | |
| 779 | + data-action="cancel-clear-license" type="button">', | |
| 780 | + 'cancel_text' => sprintf( | |
| 781 | + '<span class="text">%s</span>', | |
| 782 | + esc_html__( 'Cancel', 'learnpress' ) | |
| 783 | + ), | |
| 784 | + 'cancel_end' => '</button>', | |
| 761 | 785 | 'manage' => sprintf( |
| 762 | 786 | '<button class="btn-addon-action lp-addon-license__manage" |
| 763 | 787 | data-action="update-purchase-code" type="button">%s</button>', |
| 764 | - esc_html__( 'Manage', 'learnpress' ) | |
| 788 | + $text_btn_to_purchase_code | |
| 765 | 789 | ), |
| 766 | 790 | 'wrapper_end' => '</div>', |
| 767 | 791 | ); |
| 768 | 792 | |
| @@ -860,43 +884,42 @@ | ||
| 860 | 884 | * |
| 861 | 885 | * @return string |
| 862 | 886 | */ |
| 863 | 887 | public static function html_addon_actions( object $addon, array $data = [] ): string { |
| 864 | - $is_free = $data['is_free'] ?? false; | |
| 865 | 888 | $section_right = apply_filters( |
| 866 | 889 | 'learn-press/admin/addons/actions/section_right', |
| 867 | 890 | array( |
| 868 | - 'install' => $is_free | |
| 891 | + 'install' => $addon->is_free && ! $addon->is_org | |
| 869 | 892 | ? sprintf( |
| 870 | - '<a class="lp-button btn-addon-action" data-action="install" href="%s" | |
| 893 | + '<a class="lp-button btn-addon-action lp-be-btn lp-be-btn--sm lp-be-btn--primary" data-action="install" href="%s" | |
| 871 | 894 | target="_blank" rel="noopener">%s</a>', |
| 872 | 895 | esc_url( $addon->link ?? '' ), |
| 873 | 896 | esc_html__( 'Install', 'learnpress' ) |
| 874 | 897 | ) |
| 875 | 898 | : sprintf( |
| 876 | - '<button class="lp-button btn-addon-action" data-action="install"> | |
| 899 | + '<button class="lp-button btn-addon-action lp-be-btn lp-be-btn--sm lp-be-btn--primary" data-action="install"> | |
| 877 | 900 | <span class="text">%s</span> |
| 878 | 901 | </button>', |
| 879 | 902 | esc_html__( 'Install', 'learnpress' ) |
| 880 | 903 | ), |
| 881 | 904 | 'purchase' => sprintf( |
| 882 | - '<button class="lp-button btn-addon-action" data-action="purchase">%s</button>', | |
| 905 | + '<button class="lp-button btn-addon-action lp-be-btn lp-be-btn--sm lp-be-btn--primary" data-action="purchase">%s</button>', | |
| 883 | 906 | esc_html__( 'Install', 'learnpress' ) |
| 884 | 907 | ), |
| 885 | 908 | 'update' => sprintf( |
| 886 | - '<button class="lp-button btn-addon-action" data-action="update"> | |
| 909 | + '<button class="lp-button btn-addon-action lp-be-btn lp-be-btn--sm lp-be-btn--primary" data-action="update"> | |
| 887 | 910 | <span class="text">%s</span> |
| 888 | 911 | </button>', |
| 889 | 912 | esc_html__( 'Update', 'learnpress' ) |
| 890 | 913 | ), |
| 891 | 914 | 'deactivate' => sprintf( |
| 892 | - '<button class="lp-button btn-addon-action" data-action="deactivate"> | |
| 915 | + '<button class="lp-button btn-addon-action lp-be-btn lp-be-btn--sm" data-action="deactivate"> | |
| 893 | 916 | <span class="text">%s</span> |
| 894 | 917 | </button>', |
| 895 | 918 | esc_html__( 'Deactivate', 'learnpress' ) |
| 896 | 919 | ), |
| 897 | 920 | 'activate' => sprintf( |
| 898 | - '<button class="lp-button btn-addon-action" data-action="activate"> | |
| 921 | + '<button class="lp-button btn-addon-action lp-be-btn lp-be-btn--sm" data-action="activate"> | |
| 899 | 922 | <span class="text">%s</span> |
| 900 | 923 | </button>', |
| 901 | 924 | esc_html__( 'Activate', 'learnpress' ) |
| 902 | 925 | ), |
| @@ -930,8 +953,11 @@ | ||
| 930 | 953 | * |
| 931 | 954 | * @return string |
| 932 | 955 | */ |
| 933 | 956 | public static function html_purchase_panel( object $addon, array $data = [] ): string { |
| 957 | + $purchase_code_masked = $data['purchase_code_masked'] ?? ''; | |
| 958 | + $has_purchase_code = ! empty( $purchase_code_masked ); | |
| 959 | + | |
| 934 | 960 | $panel = array( |
| 935 | 961 | 'wrapper' => '<div class="purchase-install">', |
| 936 | 962 | 'header' => '<div class="lp-addon-purchase__header">', |
| 937 | 963 | 'title' => sprintf( |
| @@ -951,22 +977,43 @@ | ||
| 951 | 977 | '<span class="screen-reader-text">%s</span>', |
| 952 | 978 | esc_html__( 'Purchase Code', 'learnpress' ) |
| 953 | 979 | ), |
| 954 | 980 | 'field_input' => sprintf( |
| 955 | - '<input type="text" class="enter-purchase-code" placeholder="%s" value="">', | |
| 956 | - esc_attr__( 'Enter Purchase Code', 'learnpress' ) | |
| 981 | + '<input type="text" class="enter-purchase-code" placeholder="%s" value="%s"%s>', | |
| 982 | + esc_attr__( 'Enter Purchase Code', 'learnpress' ), | |
| 983 | + esc_attr( $purchase_code_masked ), | |
| 984 | + $has_purchase_code ? ' disabled' : '' | |
| 957 | 985 | ), |
| 958 | 986 | 'field_end' => '</label>', |
| 959 | - 'submit' => '<button class="lp-button btn-addon-action lp-addon-purchase__submit" | |
| 960 | - data-action="install" type="button">', | |
| 961 | - 'submit_text' => sprintf( '<span class="text">%s</span>', esc_html__( 'Submit', 'learnpress' ) ), | |
| 987 | + 'submit' => sprintf( | |
| 988 | + '<button class="lp-button btn-addon-action lp-be-btn lp-be-btn--primary lp-addon-purchase__submit%s" | |
| 989 | + data-action="install" type="button">', | |
| 990 | + $has_purchase_code ? ' lp-hidden' : '' | |
| 991 | + ), | |
| 992 | + 'submit_text' => sprintf( '<span class="text">%s</span>', esc_html__( 'Verify & Activate', 'learnpress' ) ), | |
| 962 | 993 | 'submit_end' => '</button>', |
| 994 | + 'cancel_clear' => '<button class="lp-button btn-addon-action lp-be-btn lp-be-btn--outline lp-addon-purchase__cancel-clear lp-hidden" | |
| 995 | + data-action="cancel-clear-license" type="button">', | |
| 996 | + 'cancel_clear_text' => sprintf( | |
| 997 | + '<span class="text">%s</span>', | |
| 998 | + esc_html__( 'Cancel', 'learnpress' ) | |
| 999 | + ), | |
| 1000 | + 'cancel_clear_end' => '</button>', | |
| 1001 | + 'clear' => sprintf( | |
| 1002 | + '<button class="lp-button btn-addon-action lp-be-btn lp-be-btn--primary lp-addon-purchase__clear%s" | |
| 1003 | + data-action="clear-license" type="button">', | |
| 1004 | + $has_purchase_code ? '' : ' lp-hidden' | |
| 1005 | + ), | |
| 1006 | + 'clear_text' => sprintf( '<span class="text">%s</span>', esc_html__( 'Clear', 'learnpress' ) ), | |
| 1007 | + 'clear_end' => '</button>', | |
| 963 | 1008 | 'divider' => sprintf( |
| 964 | 1009 | '<div class="lp-addon-purchase__divider"><span>%s</span></div>', |
| 965 | - esc_html__( 'Don\'t have a code?', 'learnpress' ) | |
| 1010 | + $has_purchase_code | |
| 1011 | + ? esc_html__( 'Or', 'learnpress' ) | |
| 1012 | + : esc_html__( 'Don\'t have a code?', 'learnpress' ) | |
| 966 | 1013 | ), |
| 967 | 1014 | 'buy' => sprintf( |
| 968 | - '<a class="btn-addon-action lp-addon-purchase__buy" href="%s" target="_blank" rel="noopener">%s</a>', | |
| 1015 | + '<a class="btn-addon-action lp-addon-purchase__buy lp-be-btn lp-be-btn--outline" href="%s" target="_blank" rel="noopener">%s</a>', | |
| 969 | 1016 | esc_url( $addon->link ?? '' ), |
| 970 | 1017 | esc_html__( 'Buy Now', 'learnpress' ) |
| 971 | 1018 | ), |
| 972 | 1019 | 'wrapper_end' => '</div>', |