| @@ -31,9 +31,15 @@ | ||
| 31 | 31 | return $widgets; |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | public function callback_ajax_loadmore_posts() { |
| 35 | + // Verify the front-end nonce (sent by UltimatePostKitConfig.nonce) before | |
| 36 | + // processing this public load-more request. | |
| 37 | + if ( ! check_ajax_referer( 'upk-site', 'nonce', false ) ) { | |
| 38 | + wp_send_json_error( array( 'message' => esc_html__( 'Security check failed.', 'ultimate-post-kit' ) ), 403 ); | |
| 39 | + } | |
| 35 | 40 | |
| 41 | + | |
| 36 | 42 | $settings = []; |
| 37 | 43 | |
| 38 | 44 | if ( isset( $_POST['settings'] ) && is_array( $_POST['settings'] ) ) { |
| 39 | 45 | $settings = map_deep( wp_unslash( $_POST['settings'] ), 'sanitize_text_field' ); |
| @@ -56,8 +62,11 @@ | ||
| 56 | 62 | ], |
| 57 | 63 | $settings |
| 58 | 64 | ); |
| 59 | 65 | |
| 66 | + // Fill display flags the request may have omitted (see trait) before the render loop reads them. | |
| 67 | + $settings = array_merge( $this->loadmore_display_defaults(), $settings ); | |
| 68 | + | |
| 60 | 69 | $ajaxposts = $this->query_args( $settings ); |
| 61 | 70 | |
| 62 | 71 | ob_start(); |
| 63 | 72 | $found_posts = false; |
| @@ -76,15 +85,10 @@ | ||
| 76 | 85 | $image_src = $image_src ? $image_src[0] : $placeholder; |
| 77 | 86 | |
| 78 | 87 | $title_tag = Utils::get_valid_html_tag($settings['title_tags']); |
| 79 | 88 | |
| 80 | - $onclick = ''; | |
| 81 | - if ( ! empty( $settings['global_link'] ) && $settings['global_link'] === 'yes' ) { | |
| 82 | - $onclick = 'onclick="window.open(\'' . esc_url( $post_link ) . '\', \'_self\')"'; | |
| 83 | - } | |
| 84 | - | |
| 85 | 89 | ?> |
| 86 | - <div <?php echo $onclick; ?> class="upk-item"> | |
| 90 | + <div <?php if ( ! empty( $settings['global_link'] ) && $settings['global_link'] === 'yes' ) { printf( 'onclick="window.open(\'%s\', \'_self\')"', esc_url( $post_link ) ); } ?> class="upk-item"> | |
| 87 | 91 | <div class="upk-content upk-flex upk-flex-middle"> |
| 88 | 92 | |
| 89 | 93 | <?php if ( $settings['show_counter_number'] === 'yes' ) : ?> |
| 90 | 94 | <div class="upk-counter"></div> |
| @@ -93,11 +97,12 @@ | ||
| 93 | 97 | <?php if ( $settings['show_image'] === 'yes' ) : ?> |
| 94 | 98 | <img class="upk-img" src="<?php echo esc_url( $image_src ); ?>" alt="<?php echo esc_attr( $title ); ?>"> |
| 95 | 99 | <?php endif; ?> |
| 96 | 100 | |
| 97 | - <?php if ( ! empty( $settings['show_item_icon']['value'] ) ) : ?> | |
| 101 | + <?php $upk_item_icon = ultimate_post_kit_sanitize_request_icon( $settings['show_item_icon'] ?? null ); ?> | |
| 102 | + <?php if ( $upk_item_icon ) : ?> | |
| 98 | 103 | <div class="upk-title-icon"> |
| 99 | - <?php \Elementor\Icons_Manager::render_icon( $settings['show_item_icon'], [ 'aria-hidden' => 'true', 'class' => 'fa-fw' ] ); ?> | |
| 104 | + <?php \Elementor\Icons_Manager::render_icon( $upk_item_icon, [ 'aria-hidden' => 'true', 'class' => 'fa-fw' ] ); ?> | |
| 100 | 105 | </div> |
| 101 | 106 | <?php endif; ?> |
| 102 | 107 | |
| 103 | 108 | <?php if ( ! isset( $settings['show_title'] ) || $settings['show_title'] === 'yes' ) : ?> |