| @@ -185,52 +185,30 @@ | ||
| 185 | 185 | |
| 186 | 186 | ); |
| 187 | 187 | |
| 188 | 188 | /* Get the excerpt */ |
| 189 | - | |
| 190 | - $post_id = get_the_ID(); | |
| 191 | - | |
| 192 | - $excerpt = apply_filters('the_excerpt', | |
| 193 | - get_post_field( | |
| 194 | - 'post_excerpt', | |
| 195 | - $post_id, | |
| 196 | - 'display' | |
| 197 | - ) | |
| 198 | - ); | |
| 199 | - | |
| 200 | - if(empty($excerpt) && isset($attributes['excerptLength'])) { | |
| 201 | - // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound, PEAR.Functions.FunctionCallSignature.ContentAfterOpenBracket -- Running the_excerpt directly, Previous rule doesn't take without the_excerpt being moved up a line | |
| 202 | - $excerpt = apply_filters('the_excerpt', | |
| 203 | - wp_trim_words( | |
| 204 | - preg_replace( | |
| 205 | - array( | |
| 206 | - '/\<figcaption>.*\<\/figcaption>/', | |
| 207 | - '/\[caption.*\[\/caption\]/', | |
| 208 | - ), | |
| 209 | - '', | |
| 210 | - get_the_content() | |
| 211 | - ), | |
| 212 | - $attributes['excerptLength'] | |
| 213 | - ) | |
| 214 | - ); | |
| 189 | + | |
| 190 | + global $post; | |
| 191 | + | |
| 192 | + | |
| 193 | + $excerpt = blockspare_post_excerpt($post_id, $post); | |
| 194 | + | |
| 195 | + if (!$excerpt) { | |
| 196 | + $excerpt = null; | |
| 215 | 197 | } |
| 216 | - | |
| 217 | - // Trim the excerpt if necessary. | |
| 218 | - if ( isset( $attributes['excerptLength'] ) ) { | |
| 219 | - $excerpt = wp_trim_words( | |
| 220 | - $excerpt, | |
| 221 | - $attributes['excerptLength'] | |
| 222 | - ); | |
| 198 | + | |
| 199 | + if (!empty($excerpt)) { | |
| 200 | + $excerpt = explode(' ', $excerpt); | |
| 201 | + $trim_to_length = (int)$attributes['excerptLength'] ? (int)$attributes['excerptLength'] : 55; | |
| 202 | + if (count($excerpt) > $trim_to_length) { | |
| 203 | + $excerpt = implode(' ', array_slice($excerpt, 0, $trim_to_length)) . '...'; | |
| 204 | + } else { | |
| 205 | + $excerpt = implode(' ', $excerpt); | |
| 206 | + } | |
| 207 | + | |
| 223 | 208 | } |
| 224 | - | |
| 225 | - $excerpt = apply_filters( 'the_excerpt', $excerpt ); | |
| 226 | - | |
| 227 | - if(!$excerpt) { | |
| 228 | - $excerpt = null; | |
| 229 | - } | |
| 230 | - | |
| 231 | - | |
| 232 | - | |
| 209 | + | |
| 210 | + | |
| 233 | 211 | if ((isset($attributes['displayPostExcerpt']) && $excerpt != null) || isset($attributes['displayPostLink'])) { |
| 234 | 212 | |
| 235 | 213 | |
| 236 | 214 | /* Wrap the excerpt content */ |
| @@ -344,9 +322,9 @@ | ||
| 344 | 322 | $block_content .= ' .' . $blockuniqueclass . ' .blockspare-block-post-grid-author a span{ |
| 345 | 323 | color:' . $attributes['linkColor'] . '; |
| 346 | 324 | }'; |
| 347 | 325 | |
| 348 | - $block_content .= ' .' . $blockuniqueclass . ' a.blockspare-text-link.blockspare-block-post-grid-more-link{ | |
| 326 | + $block_content .= ' .' . $blockuniqueclass . ' .blockspare-text-link a span{ | |
| 349 | 327 | color:' . $attributes['linkColor'] . '; |
| 350 | 328 | }'; |
| 351 | 329 | |
| 352 | 330 | $block_content .= ' .' . $blockuniqueclass . ' .blockspare-block-post-grid-title a span{ |