PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.10
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.10
4.4.10 4.4.9.1 4.4.9 4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 All 142 releases
← All changes | inc/TemplateHooks/Admin/AdminAddonsPage.php +165 -110 4.4.9.1 → 4.4.10 View file →
@@ -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">&times;</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 ?? '' ),
@@ -576,9 +601,9 @@
576 601 }
577 602
578 603 if ( $addon_purchased ) {
579 604 $classes_status[] = 'license';
580 - $date_expired_str = $addon_purchased->date_expire ?? '';
605 + $date_expired_str = ! empty( $data['ex-date-test'] ) ? $data['ex-date-test'] : ( $addon_purchased->date_expire ?? '' );
581 606 if ( ! empty( $date_expired_str ) ) {
582 607 $date_expired = new DateTime( $date_expired_str );
583 608 $date_now = new DateTime( gmdate( 'Y-m-d' ) );
584 609 $date_diff = date_diff( $date_now, $date_expired );
@@ -597,9 +622,10 @@
597 622 $classes_status[] = 'expired';
598 623 }
599 624 }
600 625
601 - $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 );
602 628
603 629 if ( ! in_array( $active_tab, $classes_status, true ) && 'all' !== $active_tab ) {
604 630 $classes_status[] = 'hide';
605 631 }
@@ -613,8 +639,9 @@
613 639 'version_latest' => $version_latest,
614 640 'license_status' => $license_status,
615 641 'number_days_remaining' => $number_days_remaining,
616 642 'date_expired' => $date_expired,
643 + 'purchase_code' => $purchase_code,
617 644 'purchase_code_masked' => $purchase_code_masked,
618 645 'show_license_panel' => $show_license_panel,
619 646 'addon_category' => $addon_category,
620 647 );
@@ -666,8 +693,9 @@
666 693 $license_status = $data['license_status'] ?? '';
667 694 $number_days_remaining = $data['number_days_remaining'] ?? null;
668 695 /** @var DateTime $date_expired */
669 696 $date_expired = $data['date_expired'] ?? null;
697 + $purchase_code = $data['purchase_code'] ?? '';
670 698 $purchase_code_masked = $data['purchase_code_masked'] ?? '';
671 699 $show_license_panel = $data['show_license_panel'] ?? false;
672 700 $license_status_label = 'active' === $license_status
673 701 ? __( 'Active', 'learnpress' )
@@ -689,43 +717,38 @@
689 717 : __( '(Updates until %s)', 'learnpress' );
690 718 $expiry_text = esc_html( sprintf( $expiry_format, $lpDate->format( LPDateTime::FORMAT_I18N_DATE ) ) );
691 719 }
692 720
693 - $extend_link = '';
694 - if ( 'expired' === $license_status ) {
695 - $extend_link = sprintf(
696 - '<a class="need-extend__link" href="%s" target="_blank" rel="noopener">%s</a>',
697 - esc_url( $addon->link ?? '' ),
698 - esc_html__( 'Extend now', 'learnpress' )
699 - );
700 - }
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 + );
701 731
702 - $message = '';
703 - $button_extends = '';
732 + $html_near_expire = '';
704 733 if ( ! empty( $addon->purchase_info ) ) {
705 - $button_extends = sprintf(
706 - '<a class="need-extend__link" href="%s" target="_blank" rel="noopener">%s</a>',
707 - esc_url( $addon->link ?? '' ),
708 - esc_html__( 'Extend now', 'learnpress' )
709 - );
710 -
711 734 if ( isset( $number_days_remaining ) && $number_days_remaining > 0 && $number_days_remaining < 61 ) {
712 - $message = sprintf(
735 + $message_near_expire = sprintf(
713 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' ),
714 737 sprintf( '<strong class="need-extend__days">%d</strong>', $number_days_remaining )
715 738 );
716 - } else {
717 - $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 + );
718 745 }
719 746 }
720 747
721 - $need_extend = '';
722 - if ( ! empty( $message ) || ! empty( $button_extends ) ) {
723 - $need_extend = sprintf(
724 - '<span class="need-extend">%s %s</span>',
725 - $message,
726 - $button_extends
727 - );
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' );
728 751 }
729 752
730 753 $section = array(
731 754 'wrapper' => sprintf(
@@ -747,15 +770,23 @@
747 770 '<span class="lp-addon-license__expiry"%s>%s</span>',
748 771 $expiry_hidden,
749 772 $expiry_text
750 773 ),
751 - 'extend_link' => $extend_link,
774 + 'extend_link' => 'expired' === $license_status ? $html_extend_link : '',
752 775 'summary_end' => '</div>',
753 - '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>',
754 785 'manage' => sprintf(
755 786 '<button class="btn-addon-action lp-addon-license__manage"
756 787 data-action="update-purchase-code" type="button">%s</button>',
757 - esc_html__( 'Manage', 'learnpress' )
788 + $text_btn_to_purchase_code
758 789 ),
759 790 'wrapper_end' => '</div>',
760 791 );
761 792
@@ -858,37 +889,37 @@
858 889 'learn-press/admin/addons/actions/section_right',
859 890 array(
860 891 'install' => $addon->is_free && ! $addon->is_org
861 892 ? sprintf(
862 - '<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"
863 894 target="_blank" rel="noopener">%s</a>',
864 895 esc_url( $addon->link ?? '' ),
865 896 esc_html__( 'Install', 'learnpress' )
866 897 )
867 898 : sprintf(
868 - '<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">
869 900 <span class="text">%s</span>
870 901 </button>',
871 902 esc_html__( 'Install', 'learnpress' )
872 903 ),
873 904 'purchase' => sprintf(
874 - '<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>',
875 906 esc_html__( 'Install', 'learnpress' )
876 907 ),
877 908 'update' => sprintf(
878 - '<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">
879 910 <span class="text">%s</span>
880 911 </button>',
881 912 esc_html__( 'Update', 'learnpress' )
882 913 ),
883 914 'deactivate' => sprintf(
884 - '<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">
885 916 <span class="text">%s</span>
886 917 </button>',
887 918 esc_html__( 'Deactivate', 'learnpress' )
888 919 ),
889 920 'activate' => sprintf(
890 - '<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">
891 922 <span class="text">%s</span>
892 923 </button>',
893 924 esc_html__( 'Activate', 'learnpress' )
894 925 ),
@@ -922,8 +953,11 @@
922 953 *
923 954 * @return string
924 955 */
925 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 +
926 960 $panel = array(
927 961 'wrapper' => '<div class="purchase-install">',
928 962 'header' => '<div class="lp-addon-purchase__header">',
929 963 'title' => sprintf(
@@ -943,22 +977,43 @@
943 977 '<span class="screen-reader-text">%s</span>',
944 978 esc_html__( 'Purchase Code', 'learnpress' )
945 979 ),
946 980 'field_input' => sprintf(
947 - '<input type="text" class="enter-purchase-code" placeholder="%s" value="">',
948 - 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' : ''
949 985 ),
950 986 'field_end' => '</label>',
951 - 'submit' => '<button class="lp-button btn-addon-action lp-addon-purchase__submit"
952 - data-action="install" type="button">',
953 - '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' ) ),
954 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>',
955 1008 'divider' => sprintf(
956 1009 '<div class="lp-addon-purchase__divider"><span>%s</span></div>',
957 - 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' )
958 1013 ),
959 1014 'buy' => sprintf(
960 - '<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>',
961 1016 esc_url( $addon->link ?? '' ),
962 1017 esc_html__( 'Buy Now', 'learnpress' )
963 1018 ),
964 1019 'wrapper_end' => '</div>',