| @@ -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; |
| @@ -173,9 +182,9 @@ | ||
| 173 | 182 | <?php |
| 174 | 183 | echo esc_html( |
| 175 | 184 | wp_trim_words( |
| 176 | 185 | get_the_excerpt(), |
| 177 | - absint($settings['excerpt_length'] ?? 20) | |
| 186 | + ultimate_post_kit_clamp_excerpt_length($settings['excerpt_length'] ?? 20, 20) | |
| 178 | 187 | ) |
| 179 | 188 | ); |
| 180 | 189 | ?> |
| 181 | 190 | </div> |