| @@ -32,9 +32,15 @@ | ||
| 32 | 32 | return $widgets; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | public function callback_ajax_loadmore_posts() { |
| 36 | + // Verify the front-end nonce (sent by UltimatePostKitConfig.nonce) before | |
| 37 | + // processing this public load-more request. | |
| 38 | + if ( ! check_ajax_referer( 'upk-site', 'nonce', false ) ) { | |
| 39 | + wp_send_json_error( array( 'message' => esc_html__( 'Security check failed.', 'ultimate-post-kit' ) ), 403 ); | |
| 40 | + } | |
| 36 | 41 | |
| 42 | + | |
| 37 | 43 | $settings = []; |
| 38 | 44 | |
| 39 | 45 | if ( isset( $_POST['settings'] ) && is_array( $_POST['settings'] ) ) { |
| 40 | 46 | $settings = map_deep( wp_unslash( $_POST['settings'] ), 'sanitize_text_field' ); |
| @@ -57,8 +63,11 @@ | ||
| 57 | 63 | ], |
| 58 | 64 | $settings |
| 59 | 65 | ); |
| 60 | 66 | |
| 67 | + // Fill display flags the request may have omitted (see trait) before the render loop reads them. | |
| 68 | + $settings = array_merge( $this->loadmore_display_defaults(), $settings ); | |
| 69 | + | |
| 61 | 70 | $ajaxposts = $this->query_args($settings); |
| 62 | 71 | |
| 63 | 72 | ob_start(); |
| 64 | 73 | $found_posts = false; |
| @@ -158,9 +167,9 @@ | ||
| 158 | 167 | <?php |
| 159 | 168 | echo esc_html( |
| 160 | 169 | wp_trim_words( |
| 161 | 170 | get_the_excerpt(), |
| 162 | - absint( $settings['excerpt_length'] ?? 20 ), | |
| 171 | + ultimate_post_kit_clamp_excerpt_length( $settings['excerpt_length'] ?? 20, 20 ), | |
| 163 | 172 | '...' |
| 164 | 173 | ) |
| 165 | 174 | ); |
| 166 | 175 | ?> |
| @@ -168,11 +177,12 @@ | ||
| 168 | 177 | |
| 169 | 178 | <?php if ( $settings['readmore_type'] === 'classic' ) : ?> |
| 170 | 179 | <a href="<?php echo esc_url( $post_link ); ?>" class="upk-readmore upk-display-inline-block"> |
| 171 | 180 | <?php echo esc_html( $readmore_text ); ?> |
| 172 | - <?php if ( $settings['readmore_icon']['value'] ) : ?> | |
| 181 | + <?php $upk_readmore_icon = ultimate_post_kit_sanitize_request_icon( $settings['readmore_icon'] ?? null ); ?> | |
| 182 | + <?php if ( $upk_readmore_icon ) : ?> | |
| 173 | 183 | <span class="upk-button-icon-align-<?php echo esc_attr( $settings['readmore_icon_align'] ); ?>"> |
| 174 | - <?php Icons_Manager::render_icon( $settings['readmore_icon'], [ 'aria-hidden' => 'true', 'class' => 'fa-fw' ] ); ?> | |
| 184 | + <?php Icons_Manager::render_icon( $upk_readmore_icon, [ 'aria-hidden' => 'true', 'class' => 'fa-fw' ] ); ?> | |
| 175 | 185 | </span> |
| 176 | 186 | <?php endif; ?> |
| 177 | 187 | </a> |
| 178 | 188 | <?php endif; ?> |