| @@ -469,9 +469,9 @@ | ||
| 469 | 469 | return is_singular('post'); |
| 470 | 470 | } |
| 471 | 471 | |
| 472 | 472 | if ($scope === 'pages') { |
| 473 | - return is_page(); | |
| 473 | + return $this->is_pages_scope_match(); | |
| 474 | 474 | } |
| 475 | 475 | |
| 476 | 476 | return true; |
| 477 | 477 | } |
| @@ -476,8 +476,23 @@ | ||
| 476 | 476 | return true; |
| 477 | 477 | } |
| 478 | 478 | |
| 479 | 479 | /** |
| 480 | + * Pages scope includes WordPress pages and the WooCommerce shop archive. | |
| 481 | + * | |
| 482 | + * WooCommerce shop is a product archive, so is_page() is false there even | |
| 483 | + * when the Shop page ID is selected as a page. | |
| 484 | + */ | |
| 485 | + protected function is_pages_scope_match(): bool | |
| 486 | + { | |
| 487 | + if (is_page()) { | |
| 488 | + return true; | |
| 489 | + } | |
| 490 | + | |
| 491 | + return function_exists('is_shop') && is_shop(); | |
| 492 | + } | |
| 493 | + | |
| 494 | + /** | |
| 480 | 495 | * Checks if current page is excluded from gating. |
| 481 | 496 | * |
| 482 | 497 | * @return bool |
| 483 | 498 | */ |
| @@ -482,13 +497,21 @@ | ||
| 482 | 497 | * @return bool |
| 483 | 498 | */ |
| 484 | 499 | protected function is_excluded_page(): bool |
| 485 | 500 | { |
| 501 | + $exclude_ids = array_map('absint', $this->options['display']['exclude_ids']); | |
| 502 | + | |
| 503 | + if (function_exists('is_shop') && is_shop() && function_exists('wc_get_page_id')) { | |
| 504 | + $shop_id = (int) wc_get_page_id('shop'); | |
| 505 | + if ($shop_id && in_array($shop_id, $exclude_ids, true)) { | |
| 506 | + return true; | |
| 507 | + } | |
| 508 | + } | |
| 509 | + | |
| 486 | 510 | if (!is_singular()) { |
| 487 | 511 | return false; |
| 488 | 512 | } |
| 489 | 513 | |
| 490 | - $exclude_ids = array_map('absint', $this->options['display']['exclude_ids']); | |
| 491 | 514 | $current_id = get_the_ID(); |
| 492 | 515 | |
| 493 | 516 | if (in_array($current_id, $exclude_ids, true)) { |
| 494 | 517 | return true; |
| @@ -562,9 +585,9 @@ | ||
| 562 | 585 | 'denyRedirect' => $deny_redirect_id, |
| 563 | 586 | 'denyRedirectUrl' => $deny_redirect_url, |
| 564 | 587 | 'blockMessage' => $behaviour['block_message'], |
| 565 | 588 | 'consentCheckbox' => (bool) $behaviour['consent_checkbox'], |
| 566 | - 'consentLabel' => esc_html__('I agree to the policy.', 'king-addons'), | |
| 589 | + 'consentLabel' => __('I agree to the policy.', 'king-addons'), | |
| 567 | 590 | 'repeatMode' => $behaviour['repeat_mode'] ?? 'days', |
| 568 | 591 | 'repeatDays' => (int) ($behaviour['repeat_days'] ?? 30), |
| 569 | 592 | ], |
| 570 | 593 | 'cookie' => [ |
| @@ -640,8 +663,12 @@ | ||
| 640 | 663 | * @return array<string, mixed> |
| 641 | 664 | */ |
| 642 | 665 | public function get_options(): array |
| 643 | 666 | { |
| 667 | + if (class_exists('King_Addons\\Text_Entities_Migration')) { | |
| 668 | + Text_Entities_Migration::maybe_run(); | |
| 669 | + } | |
| 670 | + | |
| 644 | 671 | $saved = get_option(self::OPTION_NAME, []); |
| 645 | 672 | $defaults = $this->get_default_options(); |
| 646 | 673 | |
| 647 | 674 | return wp_parse_args($saved, $defaults); |
| @@ -680,12 +707,12 @@ | ||
| 680 | 707 | 'overlay_opacity' => 0.7, |
| 681 | 708 | 'card_background' => '#ffffff', |
| 682 | 709 | 'card_width' => 520, |
| 683 | 710 | 'card_align' => 'center', |
| 684 | - 'title' => esc_html__('Age verification required', 'king-addons'), | |
| 685 | - 'subtitle' => esc_html__('This content is restricted to visitors over the specified age.', 'king-addons'), | |
| 686 | - 'button_yes' => esc_html__('Yes, continue', 'king-addons'), | |
| 687 | - 'button_no' => esc_html__('No, leave', 'king-addons'), | |
| 711 | + 'title' => __('Age verification required', 'king-addons'), | |
| 712 | + 'subtitle' => __('This content is restricted to visitors over the specified age.', 'king-addons'), | |
| 713 | + 'button_yes' => __('Yes, continue', 'king-addons'), | |
| 714 | + 'button_no' => __('No, leave', 'king-addons'), | |
| 688 | 715 | 'text_color' => '#111827', |
| 689 | 716 | 'title_size' => 24, |
| 690 | 717 | 'body_size' => 16, |
| 691 | 718 | 'title_weight' => 700, |
| @@ -706,9 +733,9 @@ | ||
| 706 | 733 | 'behaviour' => [ |
| 707 | 734 | 'deny_action' => 'redirect_url', |
| 708 | 735 | 'deny_redirect_page' => 0, |
| 709 | 736 | 'deny_redirect_url' => 'https://google.com', |
| 710 | - 'block_message' => esc_html__('Access denied. You do not meet the minimum age requirement.', 'king-addons'), | |
| 737 | + 'block_message' => __('Access denied. You do not meet the minimum age requirement.', 'king-addons'), | |
| 711 | 738 | 'consent_checkbox' => false, |
| 712 | 739 | 'reset_on_rule_change' => true, |
| 713 | 740 | 'repeat_mode' => 'days', |
| 714 | 741 | 'repeat_days' => 30, |
| @@ -723,10 +750,10 @@ | ||
| 723 | 750 | ], |
| 724 | 751 | 'dob' => [ |
| 725 | 752 | 'format' => 'dmy', |
| 726 | 753 | 'max_age' => 120, |
| 727 | - 'error_invalid' => esc_html__('Enter a valid date of birth.', 'king-addons'), | |
| 728 | - 'error_denied' => esc_html__('You do not meet the minimum age requirement.', 'king-addons'), | |
| 754 | + 'error_invalid' => __('Enter a valid date of birth.', 'king-addons'), | |
| 755 | + 'error_denied' => __('You do not meet the minimum age requirement.', 'king-addons'), | |
| 729 | 756 | ], |
| 730 | 757 | ]; |
| 731 | 758 | } |
| 732 | 759 | |