| @@ -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' ); |
| @@ -76,15 +82,10 @@ | ||
| 76 | 82 | $image_src = wp_get_attachment_image_src( get_post_thumbnail_id(), 'large' ); |
| 77 | 83 | $image_src = $image_src ? $image_src[0] : $placeholder; |
| 78 | 84 | $title_tag = Utils::get_valid_html_tag($settings['title_tags']); |
| 79 | 85 | |
| 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 | 86 | ?> |
| 86 | - <div <?php echo $onclick; ?> class="upk-item"> | |
| 87 | + <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 | 88 | <div class="upk-img-wrap"> |
| 88 | 89 | <img |
| 89 | 90 | class="upk-img" |
| 90 | 91 | src="<?php echo esc_url( $image_src ); ?>" |
| @@ -94,9 +95,9 @@ | ||
| 94 | 95 | |
| 95 | 96 | <div class="upk-content-wrap"> |
| 96 | 97 | <?php if ( $settings['show_category'] === 'yes' ) : ?> |
| 97 | 98 | <div class="upk-category"> |
| 98 | - <?php echo upk_get_category( $post_type ); ?> | |
| 99 | + <?php echo wp_kses_post( upk_get_category( $post_type ) ); ?> | |
| 99 | 100 | </div> |
| 100 | 101 | <?php endif; ?> |
| 101 | 102 | |
| 102 | 103 | <?php if ( ! isset( $settings['show_title'] ) || $settings['show_title'] === 'yes' ) : ?> |