| @@ -11,8 +11,9 @@ | ||
| 11 | 11 | use Elementor\Group_Control_Typography; |
| 12 | 12 | use Elementor\Icons_Manager; |
| 13 | 13 | use Elementor\Repeater; |
| 14 | 14 | use Elementor\Group_Control_Image_Size; |
| 15 | +use Elementor\Utils; | |
| 15 | 16 | use WP_Query; |
| 16 | 17 | |
| 17 | 18 | if (!defined('ABSPATH')) { |
| 18 | 19 | exit; |
| @@ -2226,10 +2227,9 @@ | ||
| 2226 | 2227 | ] |
| 2227 | 2228 | ] |
| 2228 | 2229 | ); |
| 2229 | 2230 | |
| 2230 | - Core::renderUpgradeProNotice($repeater, Controls_Manager::RAW_HTML, 'grid', 'element_select', ['pro-lk', 'pro-shr']); | |
| 2231 | - Core::renderUpgradeProNotice($repeater, Controls_Manager::RAW_HTML, 'grid', 'element_select', ['pro-cf']); | |
| 2231 | + Core::renderUpgradeProNotice($repeater, Controls_Manager::RAW_HTML, 'grid', 'element_select', ['pro-lk', 'pro-shr', 'pro-cf']); | |
| 2232 | 2232 | |
| 2233 | 2233 | $repeater->add_control( |
| 2234 | 2234 | 'element_location', |
| 2235 | 2235 | [ |
| @@ -8397,9 +8397,9 @@ | ||
| 8397 | 8397 | } |
| 8398 | 8398 | |
| 8399 | 8399 | public function get_main_query_args() |
| 8400 | 8400 | { |
| 8401 | - $settings = $this->get_settings(); | |
| 8401 | + $settings = Core::displaySettings($this); | |
| 8402 | 8402 | |
| 8403 | 8403 | // Detect paged |
| 8404 | 8404 | $paged = get_query_var('paged') ?: (get_query_var('page') ?: 1); |
| 8405 | 8405 | |
| @@ -8546,9 +8546,9 @@ | ||
| 8546 | 8546 | } |
| 8547 | 8547 | |
| 8548 | 8548 | public function get_tax_query_args() |
| 8549 | 8549 | { |
| 8550 | - $settings = $this->get_settings(); | |
| 8550 | + $settings = Core::displaySettings($this); | |
| 8551 | 8551 | |
| 8552 | 8552 | // "RELATED" means match the same terms as current post in a chosen taxonomy |
| 8553 | 8553 | if ('related' === $settings['query_source']) { |
| 8554 | 8554 | return [[ |
| @@ -8580,9 +8580,8 @@ | ||
| 8580 | 8580 | } |
| 8581 | 8581 | |
| 8582 | 8582 | public function get_animation_class($data, $object) |
| 8583 | 8583 | { |
| 8584 | - // Disable if mobile + disable-mobile setting | |
| 8585 | 8584 | if ( |
| 8586 | 8585 | 'overlay' !== $object && |
| 8587 | 8586 | 'yes' === ($data[$object . '_animation_disable_mobile'] ?? '') && |
| 8588 | 8587 | wp_is_mobile() |
| @@ -8589,18 +8588,18 @@ | ||
| 8589 | 8588 | ) { |
| 8590 | 8589 | return ''; |
| 8591 | 8590 | } |
| 8592 | 8591 | |
| 8593 | - $class = ''; | |
| 8594 | - $anim = $data[$object . '_animation'] ?? 'none'; | |
| 8592 | + $animation = Grid_Ajax_Security::sanitize_animation($data[$object . '_animation'] ?? 'none'); | |
| 8593 | + if ('none' === $animation) { | |
| 8594 | + return ''; | |
| 8595 | + } | |
| 8595 | 8596 | |
| 8596 | - if ('none' !== $anim) { | |
| 8597 | - $class .= ' king-addons-' . $object . '-' . $anim; | |
| 8598 | - $class .= ' king-addons-anim-size-' . ($data[$object . '_animation_size'] ?? ''); | |
| 8599 | - $class .= ' king-addons-animation-timing-' . ($data[$object . '_animation_timing'] ?? ''); | |
| 8600 | - if ('yes' === ($data[$object . '_animation_tr'] ?? '')) { | |
| 8601 | - $class .= ' king-addons-anim-transparency'; | |
| 8602 | - } | |
| 8597 | + $class = ' king-addons-' . sanitize_html_class((string) $object) . '-' . $animation; | |
| 8598 | + $class .= ' king-addons-anim-size-' . Grid_Ajax_Security::sanitize_animation_size($data[$object . '_animation_size'] ?? 'large'); | |
| 8599 | + $class .= ' king-addons-animation-timing-' . Grid_Ajax_Security::sanitize_animation_timing($data[$object . '_animation_timing'] ?? 'ease-default'); | |
| 8600 | + if ('yes' === Grid_Ajax_Security::sanitize_yes_no_switcher($data[$object . '_animation_tr'] ?? '')) { | |
| 8601 | + $class .= ' king-addons-anim-transparency'; | |
| 8603 | 8602 | } |
| 8604 | 8603 | return $class; |
| 8605 | 8604 | } |
| 8606 | 8605 | |
| @@ -8605,30 +8604,18 @@ | ||
| 8605 | 8604 | } |
| 8606 | 8605 | |
| 8607 | 8606 | public function get_image_effect_class($settings) |
| 8608 | 8607 | { |
| 8609 | - // Restrict effects if premium not available | |
| 8610 | - if ( | |
| 8611 | - !king_addons_freemius()->can_use_premium_code__premium_only() && | |
| 8612 | - in_array($settings['image_effects'], ['pro-zi', 'pro-zo', 'pro-go', 'pro-bo']) | |
| 8613 | - ) { | |
| 8614 | - $settings['image_effects'] = 'none'; | |
| 8615 | - } | |
| 8616 | - | |
| 8608 | + $effect = Grid_Ajax_Security::sanitize_image_effect($settings['image_effects'] ?? 'none'); | |
| 8617 | 8609 | $class = ''; |
| 8618 | - $effect = $settings['image_effects'] ?? 'none'; | |
| 8619 | - | |
| 8620 | 8610 | if ('none' !== $effect) { |
| 8621 | 8611 | $class .= ' king-addons-' . $effect; |
| 8622 | 8612 | } |
| 8623 | - | |
| 8624 | - // For 'slide' vs other effect directions | |
| 8625 | 8613 | if ('slide' !== $effect) { |
| 8626 | - $class .= ' king-addons-effect-size-' . ($settings['image_effects_size'] ?? ''); | |
| 8614 | + $class .= ' king-addons-effect-size-' . Grid_Ajax_Security::sanitize_image_effect_size($settings['image_effects_size'] ?? 'medium'); | |
| 8627 | 8615 | } else { |
| 8628 | - $class .= ' king-addons-effect-dir-' . ($settings['image_effects_direction'] ?? ''); | |
| 8616 | + $class .= ' king-addons-effect-dir-' . Grid_Ajax_Security::sanitize_image_effect_direction($settings['image_effects_direction'] ?? 'bottom'); | |
| 8629 | 8617 | } |
| 8630 | - | |
| 8631 | 8618 | return $class; |
| 8632 | 8619 | } |
| 8633 | 8620 | |
| 8634 | 8621 | public function render_password_protected_input() |
| @@ -8659,8 +8646,14 @@ | ||
| 8659 | 8646 | { |
| 8660 | 8647 | $id = get_post_thumbnail_id(); |
| 8661 | 8648 | $src = Group_Control_Image_Size::get_attachment_image_src($id, 'layout_image_crop', $settings); |
| 8662 | 8649 | |
| 8650 | + // A post with no featured image would otherwise drop the whole media block, | |
| 8651 | + // and the cards beside it in the row would no longer line up. | |
| 8652 | + if (!$src) { | |
| 8653 | + $src = Utils::get_placeholder_image_src(); | |
| 8654 | + } | |
| 8655 | + | |
| 8663 | 8656 | // Secondary image |
| 8664 | 8657 | $sec_meta = get_post_meta(get_the_ID(), 'king_addons_secondary_image_id', true); |
| 8665 | 8658 | $src2 = !empty($sec_meta) |
| 8666 | 8659 | ? Group_Control_Image_Size::get_attachment_image_src($sec_meta, 'layout_image_crop', $settings) |
| @@ -8670,27 +8663,25 @@ | ||
| 8670 | 8663 | $alt = '' === wp_get_attachment_caption($id) |
| 8671 | 8664 | ? get_the_title() |
| 8672 | 8665 | : wp_get_attachment_caption($id); |
| 8673 | 8666 | |
| 8674 | - if (has_post_thumbnail()) { | |
| 8675 | - echo '<div class="king-addons-grid-image-wrap" data-src="' . esc_url($src) . '" data-img-on-hover="' . esc_attr($settings['secondary_img_on_hover']) . '" data-src-secondary="' . esc_url($src2) . '">'; | |
| 8667 | + echo '<div class="king-addons-grid-image-wrap" data-src="' . esc_url($src) . '" data-img-on-hover="' . esc_attr($settings['secondary_img_on_hover']) . '" data-src-secondary="' . esc_url($src2) . '">'; | |
| 8676 | 8668 | |
| 8677 | - // Lazy loading vs normal | |
| 8678 | - /** @noinspection PhpIfWithCommonPartsInspection */ | |
| 8679 | - if ('yes' === $settings['grid_lazy_loading']) { | |
| 8680 | - echo '<img loading="lazy" src="'.esc_url($src).'" | |
| 8669 | + // Lazy loading vs normal | |
| 8670 | + /** @noinspection PhpIfWithCommonPartsInspection */ | |
| 8671 | + if ('yes' === $settings['grid_lazy_loading']) { | |
| 8672 | + echo '<img loading="lazy" src="'.esc_url($src).'" | |
| 8681 | 8673 | alt="' . esc_attr($alt) . '" class="king-addons-hidden-image king-addons-animation-timing-' . esc_attr($settings['image_effects_animation_timing']) . '">'; |
| 8682 | - if ('yes' === $settings['secondary_img_on_hover']) { | |
| 8683 | - echo '<img src="' . esc_url($src2) . '" alt="' . esc_attr($alt) . '" class="king-addons-hidden-img king-addons-animation-timing-' . esc_attr($settings['image_effects_animation_timing']) . '">'; | |
| 8684 | - } | |
| 8685 | - } else { | |
| 8686 | - echo '<img src="' . esc_url($src) . '" alt="' . esc_attr($alt) . '" class="king-addons-animation-timing-' . esc_attr($settings['image_effects_animation_timing']) . '">'; | |
| 8687 | - if ('yes' === $settings['secondary_img_on_hover']) { | |
| 8688 | - echo '<img src="' . esc_url($src2) . '" alt="' . esc_attr($alt) . '" class="king-addons-hidden-img king-addons-animation-timing-' . esc_attr($settings['image_effects_animation_timing']) . '">'; | |
| 8689 | - } | |
| 8674 | + if ('yes' === $settings['secondary_img_on_hover']) { | |
| 8675 | + echo '<img src="' . esc_url($src2) . '" alt="' . esc_attr($alt) . '" class="king-addons-hidden-img king-addons-animation-timing-' . esc_attr($settings['image_effects_animation_timing']) . '">'; | |
| 8690 | 8676 | } |
| 8691 | - echo '</div>'; | |
| 8677 | + } else { | |
| 8678 | + echo '<img src="' . esc_url($src) . '" alt="' . esc_attr($alt) . '" class="king-addons-animation-timing-' . esc_attr($settings['image_effects_animation_timing']) . '">'; | |
| 8679 | + if ('yes' === $settings['secondary_img_on_hover']) { | |
| 8680 | + echo '<img src="' . esc_url($src2) . '" alt="' . esc_attr($alt) . '" class="king-addons-hidden-img king-addons-animation-timing-' . esc_attr($settings['image_effects_animation_timing']) . '">'; | |
| 8681 | + } | |
| 8692 | 8682 | } |
| 8683 | + echo '</div>'; | |
| 8693 | 8684 | } |
| 8694 | 8685 | |
| 8695 | 8686 | public function render_media_overlay($settings) |
| 8696 | 8687 | { |
| @@ -8704,12 +8695,12 @@ | ||
| 8704 | 8695 | public function render_post_title($settings, $class) |
| 8705 | 8696 | { |
| 8706 | 8697 | // Fallback pointer for non-premium |
| 8707 | 8698 | $title_pointer = king_addons_freemius()->can_use_premium_code__premium_only() |
| 8708 | - ? ($this->get_settings()['title_pointer'] ?? 'none') | |
| 8699 | + ? (Core::displaySettings($this)['title_pointer'] ?? 'none') | |
| 8709 | 8700 | : 'none'; |
| 8710 | 8701 | $title_pointer_animation = king_addons_freemius()->can_use_premium_code__premium_only() |
| 8711 | - ? ($this->get_settings()['title_pointer_animation'] ?? 'fade') | |
| 8702 | + ? (Core::displaySettings($this)['title_pointer_animation'] ?? 'fade') | |
| 8712 | 8703 | : 'fade'; |
| 8713 | 8704 | |
| 8714 | 8705 | $pointer_item_class = ($title_pointer !== 'none') |
| 8715 | 8706 | ? 'class="king-addons-pointer-item"' |
| @@ -8714,9 +8705,9 @@ | ||
| 8714 | 8705 | $pointer_item_class = ($title_pointer !== 'none') |
| 8715 | 8706 | ? 'class="king-addons-pointer-item"' |
| 8716 | 8707 | : ''; |
| 8717 | 8708 | |
| 8718 | - $new_tab = ('yes' === $this->get_settings()['open_links_in_new_tab']) ? '_blank' : '_self'; | |
| 8709 | + $new_tab = ('yes' === Core::displaySettings($this)['open_links_in_new_tab']) ? '_blank' : '_self'; | |
| 8719 | 8710 | |
| 8720 | 8711 | $class .= ' king-addons-pointer-' . $title_pointer; |
| 8721 | 8712 | $class .= ' king-addons-pointer-line-fx king-addons-pointer-fx-' . $title_pointer_animation; |
| 8722 | 8713 | |
| @@ -8940,12 +8931,12 @@ | ||
| 8940 | 8931 | public function render_post_read_more($settings, $class) |
| 8941 | 8932 | { |
| 8942 | 8933 | // Fallback animation for non-premium |
| 8943 | 8934 | $read_more_animation = king_addons_freemius()->can_use_premium_code__premium_only() |
| 8944 | - ? $this->get_settings()['read_more_animation'] | |
| 8935 | + ? Core::displaySettings($this)['read_more_animation'] | |
| 8945 | 8936 | : 'king-addons-button-none'; |
| 8946 | 8937 | |
| 8947 | - $new_tab = ('yes' === $this->get_settings()['open_links_in_new_tab']) ? '_blank' : '_self'; | |
| 8938 | + $new_tab = ('yes' === Core::displaySettings($this)['open_links_in_new_tab']) ? '_blank' : '_self'; | |
| 8948 | 8939 | |
| 8949 | 8940 | echo '<div class="' . esc_attr($class) . '">'; |
| 8950 | 8941 | echo ' <div class="inner-block">'; |
| 8951 | 8942 | echo ' <a target="' . esc_attr($new_tab) . '" href="' . esc_url(get_the_permalink()) . '" class="king-addons-button-effect ' . esc_attr($read_more_animation) . '">'; |
| @@ -9065,18 +9056,18 @@ | ||
| 9065 | 9056 | } |
| 9066 | 9057 | |
| 9067 | 9058 | // Handle pointer classes (premium or fallback) |
| 9068 | 9059 | $tax1_pointer = king_addons_freemius()->can_use_premium_code__premium_only() |
| 9069 | - ? ($this->get_settings()['tax1_pointer'] ?? 'none') | |
| 9060 | + ? (Core::displaySettings($this)['tax1_pointer'] ?? 'none') | |
| 9070 | 9061 | : 'none'; |
| 9071 | 9062 | $tax1_pointer_animation = king_addons_freemius()->can_use_premium_code__premium_only() |
| 9072 | - ? ($this->get_settings()['tax1_pointer_animation'] ?? 'fade') | |
| 9063 | + ? (Core::displaySettings($this)['tax1_pointer_animation'] ?? 'fade') | |
| 9073 | 9064 | : 'fade'; |
| 9074 | 9065 | $tax2_pointer = king_addons_freemius()->can_use_premium_code__premium_only() |
| 9075 | - ? ($this->get_settings()['tax2_pointer'] ?? 'none') | |
| 9066 | + ? (Core::displaySettings($this)['tax2_pointer'] ?? 'none') | |
| 9076 | 9067 | : 'none'; |
| 9077 | 9068 | $tax2_pointer_animation = king_addons_freemius()->can_use_premium_code__premium_only() |
| 9078 | - ? ($this->get_settings()['tax2_pointer_animation'] ?? 'fade') | |
| 9069 | + ? (Core::displaySettings($this)['tax2_pointer_animation'] ?? 'fade') | |
| 9079 | 9070 | : 'fade'; |
| 9080 | 9071 | |
| 9081 | 9072 | // Decide which pointer to use |
| 9082 | 9073 | if ('king-addons-grid-tax-style-1' === $settings['element_tax_style']) { |
| @@ -9106,13 +9097,13 @@ | ||
| 9106 | 9097 | |
| 9107 | 9098 | foreach ($terms as $term) { |
| 9108 | 9099 | // Possibly set custom colors (premium) for tax style 1 |
| 9109 | 9100 | if ( |
| 9110 | - 'yes' === ($this->get_settings()['tax1_custom_color_switcher'] ?? '') && | |
| 9101 | + 'yes' === (Core::displaySettings($this)['tax1_custom_color_switcher'] ?? '') && | |
| 9111 | 9102 | 'king-addons-grid-tax-style-1' === $settings['element_tax_style'] |
| 9112 | 9103 | ) { |
| 9113 | - $cfc_text = get_term_meta($term->term_id, $this->get_settings()['tax1_custom_color_field_text'], true); | |
| 9114 | - $cfc_bg = get_term_meta($term->term_id, $this->get_settings()['tax1_custom_color_field_bg'], true); | |
| 9104 | + $cfc_text = get_term_meta($term->term_id, Core::displaySettings($this)['tax1_custom_color_field_text'], true); | |
| 9105 | + $cfc_bg = get_term_meta($term->term_id, Core::displaySettings($this)['tax1_custom_color_field_bg'], true); | |
| 9115 | 9106 | $color_css = "color:$cfc_text; background-color:$cfc_bg; border-color:$cfc_bg;"; |
| 9116 | 9107 | $custom_selector = '.elementor-element' . $this->get_unique_selector() . |
| 9117 | 9108 | ' .king-addons-grid-tax-style-1 .inner-block a.king-addons-tax-id-' . esc_attr($term->term_id); |
| 9118 | 9109 | echo '<style>' . $custom_selector . '{' . $color_css . '}</style>'; |
| @@ -9827,9 +9818,9 @@ | ||
| 9827 | 9818 | } |
| 9828 | 9819 | |
| 9829 | 9820 | protected function render() |
| 9830 | 9821 | { |
| 9831 | - $settings = $this->get_settings(); | |
| 9822 | + $settings = Core::displaySettings($this); | |
| 9832 | 9823 | $posts = new WP_Query($this->get_main_query_args()); |
| 9833 | 9824 | |
| 9834 | 9825 | if ($posts->have_posts()) { |
| 9835 | 9826 | // Render filters if not slider |
| @@ -9857,9 +9848,9 @@ | ||
| 9857 | 9848 | // Location: ABOVE |
| 9858 | 9849 | $this->get_elements_by_location('above', $settings, get_the_ID()); |
| 9859 | 9850 | |
| 9860 | 9851 | // If has featured image, render |
| 9861 | - if (has_post_thumbnail() && 'yes' !== $settings['hide_post_thumbnail']) { | |
| 9852 | + if ('yes' !== $settings['hide_post_thumbnail']) { | |
| 9862 | 9853 | echo '<div class="king-addons-grid-media-wrap' . esc_attr($this->get_image_effect_class($settings)) . '" data-overlay-link="' . esc_attr($settings['overlay_post_link']) . '">'; |
| 9863 | 9854 | $this->render_post_thumbnail($settings); |
| 9864 | 9855 | |
| 9865 | 9856 | echo '<div class="king-addons-grid-media-hover king-addons-animation-wrap">'; |