PluginProbe
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites / 1.2.1
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites v1.2.1
4.1.0 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.1.0 1.1.1 1.1.2 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 2.1.2 2.5.0 2.5.3 2.6.1 All 38 releases
← All changes | src/blocks/latest-posts-list/index.php +20 -32 1.3.01.2.1 View file →
@@ -185,42 +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 - if(!$excerpt) {
218 - $excerpt = null;
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 +
219 208 }
220 -
221 -
222 -
209 +
210 +
223 211 if ((isset($attributes['displayPostExcerpt']) && $excerpt != null) || isset($attributes['displayPostLink'])) {
224 212
225 213
226 214 /* Wrap the excerpt content */