PluginProbe ʕ •ᴥ•ʔ
Strong Testimonials / trunk
Strong Testimonials vtrunk
3.3.2 3.3.1 trunk 1.0.1 2.30.9 2.31.10 2.32 2.32.1 2.32.2 2.32.3 2.32.4 2.33 2.34 2.35 2.36 2.37 2.38 2.38.1 2.39 2.39.1 2.39.2 2.39.3 2.40.0 2.40.1 2.40.2 2.40.3 2.40.4 2.40.5 2.40.6 2.40.7 2.41.0 2.41.1 2.50.0 2.50.1 2.50.2 2.50.3 2.50.4 2.51.0 2.51.1 2.51.2 2.51.3 2.51.4 2.51.5 2.51.6 2.51.7 2.51.8 2.51.9 3.0.0 3.0.1 3.0.2 3.0.3 3.1.0 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.17 3.1.18 3.1.19 3.1.2 3.1.20 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.10 3.2.11 3.2.12 3.2.13 3.2.14 3.2.15 3.2.16 3.2.17 3.2.18 3.2.19 3.2.2 3.2.20 3.2.21 3.2.22 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 3.3.0
strong-testimonials / includes / functions-content.php
strong-testimonials / includes Last commit date
elementor 1 year ago logs 1 month ago strong-testimonials-beaver-block 1 year ago submodules 8 months ago class-strong-gutemberg.php 1 year ago class-strong-log.php 1 year ago class-strong-mail.php 1 year ago class-strong-testimonials-average-shortcode.php 1 year ago class-strong-testimonials-count-shortcode.php 1 year ago class-strong-testimonials-defaults.php 1 month ago class-strong-testimonials-form.php 1 month ago class-strong-testimonials-order.php 1 year ago class-strong-testimonials-privacy.php 1 year ago class-strong-testimonials-render.php 1 month ago class-strong-testimonials-templates.php 1 year ago class-strong-testimonials-view-shortcode.php 1 week ago class-strong-testimonials-view-widget.php 1 year ago class-strong-view-display.php 15 hours ago class-strong-view-form.php 15 hours ago class-strong-view-slideshow.php 15 hours ago class-strong-view.php 15 hours ago class-walker-strong-category-checklist-front.php 1 year ago deprecated.php 1 year ago filters.php 1 month ago functions-activation.php 1 month ago functions-content.php 11 months ago functions-image.php 5 months ago functions-rating.php 1 year ago functions-template-form.php 1 week ago functions-template.php 4 months ago functions-views.php 1 year ago functions.php 1 month ago l10n-polylang.php 1 year ago l10n-wpml.php 1 year ago post-types.php 1 week ago retro.php 1 year ago scripts.php 1 month ago
functions-content.php
280 lines
1 <?php
2 /**
3 * Content functions.
4 */
5
6 /**
7 * Based on the_content().
8 *
9 * @param null $more_link_text
10 * @param bool $strip_teaser
11 *
12 * @return string
13 */
14 function wpmtst_the_content_filtered( $more_link_text = null, $strip_teaser = false ) {
15 $content = get_the_content( $more_link_text, $strip_teaser );
16 $content = apply_filters( 'wpmtst_the_content', $content );
17 $content = str_replace( ']]>', ']]&gt;', $content );
18 return $content;
19 }
20
21 /**
22 * Based on the_excerpt().
23 *
24 * @since 2.26.0
25 */
26 function wpmtst_the_excerpt_filtered() {
27 return apply_filters( 'wpmtst_the_excerpt', wpmtst_get_the_excerpt() );
28 }
29
30 /**
31 * Based on get_the_excerpt().
32 *
33 * @since 2.26.0
34 * @param null $post
35 *
36 * @return string
37 */
38 function wpmtst_get_the_excerpt( $post = null ) {
39 $post = get_post( $post );
40 if ( empty( $post ) ) {
41 return '';
42 }
43
44 if ( post_password_required( $post ) ) {
45 return esc_html__( 'There is no excerpt because this is a protected post.', 'strong-testimonials' );
46 }
47
48 /**
49 * Filters the retrieved post excerpt.
50 *
51 * @param string $post_excerpt The post excerpt.
52 * @param WP_Post $post Post object.
53 */
54 return apply_filters( 'wpmtst_get_the_excerpt', $post->post_excerpt, $post );
55 }
56
57 /**
58 * Force bypass of the manual excerpt.
59 *
60 * @since 2.26.0
61 * @param $text
62 *
63 * @return string
64 */
65 function wpmtst_bypass_excerpt( $text ) {
66 return '';
67 }
68
69 /**
70 * Based on wp_trim_excerpt(). On wpmtst_get_the_excerpt hook.
71 *
72 * @since 2.26.0
73 * @param string $excerpt The manual excerpt.
74 *
75 * @return string
76 */
77 function wpmtst_trim_excerpt( $excerpt = '' ) {
78 $raw_excerpt = $excerpt;
79
80 /**
81 * Filter hybrid value here to allow individual overrides.
82 */
83 $hybrid = apply_filters( 'wpmtst_is_hybrid_content', false );
84
85 $text = wpmtst_get_the_prepared_text();
86 $excerpt_length = 0;
87 $excerpt_more = '';
88
89 // Create excerpt if post has no manual excerpt.
90 if ( empty( $excerpt ) ) {
91 $excerpt_length = apply_filters( 'excerpt_length', 55 );
92 $excerpt_more = apply_filters( 'excerpt_more', ' [&hellip;]' );
93 }
94
95 $excerpt = wpmtst_trim_words( $text, $excerpt_length, $excerpt_more, $hybrid, $excerpt );
96
97 /**
98 * Filters the trimmed excerpt string.
99 *
100 * @param string $text The trimmed text.
101 * @param string $raw_excerpt The text prior to trimming.
102 */
103 return apply_filters( 'wpmtst_trim_excerpt', $excerpt, $raw_excerpt );
104 }
105
106 /**
107 * Prepare the post content.
108 *
109 * @param bool $hybrid
110 * @since 2.33.0
111 *
112 * @return string
113 */
114 function wpmtst_get_the_prepared_text( $hybrid = false ) {
115 $text = get_the_content( '' );
116
117 if ( function_exists( 'et_core_is_builder_used_on_current_request' ) && et_core_is_builder_used_on_current_request() ) {
118 $text = wp_strip_all_tags( et_strip_shortcodes( $text ), true );
119 } elseif ( ! $hybrid ) {
120 $text = strip_shortcodes( $text );
121 }
122
123 $text = apply_filters( 'wpmtst_the_content', $text );
124 $text = str_replace( ']]>', ']]&gt;', $text );
125
126 return $text;
127 }
128
129 /**
130 * Construct the "Read more" link (both automatic and manual).
131 *
132 * @since 2.27.0 Filters on URL and full link.
133 *
134 * @return string
135 */
136 function wpmtst_get_excerpt_more_link() {
137 $url = apply_filters( 'wpmtst_read_more_post_url', get_permalink(), WPMST()->atts() );
138
139 $link_text = sprintf(
140 '%s<span class="screen-reader-text"> "%s"</span>',
141 apply_filters( 'wpmtst_read_more_post_link_text', esc_html( WPMST()->atts( 'more_post_text' ) ), WPMST()->atts() ),
142 get_the_title()
143 );
144
145 $link_class = apply_filters( 'wpmtst_read_more_post_link_class', 'readmore' );
146
147 if ( apply_filters( 'wpmtst_is_hybrid_content', false ) ) {
148 // no href
149 $link = sprintf(
150 '<a aria-expanded="false" aria-controls="more-%1$d" role="button" tabindex="0" class="%2$s readmore-toggle"><span class="readmore-text" data-more-text="%4$s" data-less-text="%5$s">%3$s</span></a>',
151 get_the_ID(), // 1
152 $link_class, // 2
153 $link_text, // 3
154 esc_attr( WPMST()->atts( 'more_post_text' ) ), // 4
155 esc_attr( WPMST()->atts( 'less_post_text' ) ) // 5
156 );
157 } else {
158 $link = sprintf( '<a href="%s" class="%s">%s</a>', esc_url( $url ), $link_class, $link_text );
159 }
160
161 return apply_filters( 'wpmtst_read_more_post_link', $link );
162 }
163
164 /**
165 * Based on wp_trim_words().
166 *
167 * @param $text
168 * @param int $num_words
169 * @param null $more
170 * @param bool $hybrid
171 *
172 * @return string
173 */
174 function wpmtst_trim_words( $text, $num_words = 55, $more = null, $hybrid = false, $excerpt = '' ) {
175 if ( null === $more ) {
176 $more = __( '&hellip;', 'strong-testimonials' );
177 }
178
179 if ( WPMST()->atts( 'html_content' ) || ! empty( $excerpt ) ) {
180 $full_text = strip_tags( $text, '<p><br><img><b><strong><i><em><ul><ol><li><del><a><sup>' );
181 } else {
182 $full_text = strip_tags( $text );
183 }
184
185 $text = strip_tags( $text );
186
187 /*
188 * translators: If your word count is based on single characters (e.g. East Asian characters),
189 * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.
190 * Do not translate into your own language.
191 */
192 if ( ( strpos( esc_html_x( 'words', 'Word count type. Do not translate!', 'strong-testimonials' ), 'characters' ) === 0 && preg_match( '/^utf\-?8$/i', get_option( 'blog_charset' ) ) ) || apply_filters( 'wpmtst_excerpt_by_characters_count', false ) ) {
193 $text = trim( preg_replace( "/[\n\r\t ]+/", ' ', $text ), ' ' );
194 preg_match_all( '/./u', $text, $words_array );
195 $words_array = array_slice( $words_array[0], 0, $num_words + 1 );
196 $sep = '';
197 } else {
198 $offset = $hybrid ? 0 : $num_words + 1;
199 $words_array = preg_split( "/[\n\r\t ]+/", $text, $offset, PREG_SPLIT_NO_EMPTY );
200 $sep = ' ';
201 }
202
203 if ( count( $words_array ) > $num_words ) {
204 if ( $hybrid ) {
205 $text = wpmtst_assemble_hybrid( $words_array, $num_words, $sep, $more, $full_text, $excerpt );
206 } else {
207 $text = wpmtst_assemble_excerpt( $words_array, $sep, $more, $excerpt );
208 }
209 } else {
210 $text = implode( $sep, $words_array );
211 }
212
213 return $text;
214 }
215
216 /**
217 * Assemble excerpt from trimmed array.
218 *
219 * @param $words_array
220 * @param $sep
221 * @param $more
222 * @since 2.33.0
223 *
224 * @return string
225 */
226 function wpmtst_assemble_excerpt( $words_array, $sep, $more, $excerpt = '' ) {
227 if ( ! empty( $excerpt ) ) {
228 return $excerpt;
229 }
230 array_pop( $words_array );
231 $text = implode( $sep, $words_array );
232
233 return $text . $more;
234 }
235
236 /**
237 * Assemble excerpt + rest of content in hidden span.
238 *
239 * @param $words_array
240 * @param $num_words
241 * @param $sep
242 * @param $more
243 * @since 2.33.0
244 *
245 * @return string
246 */
247 function wpmtst_assemble_hybrid( $words_array, $num_words, $sep, $more, $full_text, $excerpt = '' ) {
248 $ellipsis = wpmtst_ellipsis();
249 if ( $ellipsis ) {
250 $ellipsis = '<div class="ellipsis" style="display:inline;">' . $ellipsis . ' </div>';
251 /* ! This space is important: ^ */
252 }
253 if ( ! empty( $excerpt ) ) {
254 $first_half = $excerpt;
255 } else {
256 $first_half = implode( $sep, array_slice( $words_array, 0, $num_words ) );
257 }
258
259 $wrap_open_class = '';
260
261 if ( WPMST()->atts( 'html_content' ) || ! empty( $excerpt ) ) {
262 $wrap_open_class = 'all-html';
263 }
264 $inline = '';
265 if ( WPMST()->atts( 'more_post_text_inline' ) ) {
266 $more = '<div class="wpmtst-inline-readme" style="display:inline;">' . $more . '</div>';
267 $wrap_open_class = 'readmore-excerpt-inline';
268 $inline = 'readmore-content-inline';
269 }
270
271 $wrap_open_excerpt = '<div class="readmore-excerpt animated ' . esc_attr( $wrap_open_class ) . '">';
272 $wrap_open = '<div class="readmore-content animated ' . esc_attr( $inline ) . '" id="more-' . esc_attr( get_the_ID() ) . '" hidden>';
273 $wrap_close = '</div>';
274 $wrap_close_excerpt = '</div>';
275 $first_half = '<div style="display:inline;">' . wp_kses_post( $first_half ) . '</div>';
276
277 return $wrap_open_excerpt . $first_half . $ellipsis . $wrap_close_excerpt . $wrap_open . ' ' . $full_text . $wrap_close . $more;
278 /* ! This space is important: ^ */
279 }
280