PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.1
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.1
16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 13.9.2 14.0.1 All 504 releases
← All changes | modules/theme-tools/content-options/blog-display.php +211 -163 12.7.316.3-a.1 View file →
@@ -4,8 +4,12 @@
4 4 *
5 5 * @package automattic/jetpack
6 6 */
7 7
8 +if ( ! defined( 'ABSPATH' ) ) {
9 + exit( 0 );
10 +}
11 +
8 12 /**
9 13 * If the theme doesn't support 'jetpack-content-options', don't continue.
10 14 */
11 15 if ( ! current_theme_supports( 'jetpack-content-options' ) ) {
@@ -29,200 +33,244 @@
29 33 if ( ! in_array( $blog_display, array( 'content', 'excerpt', 'mixed' ), true ) ) {
30 34 return;
31 35 }
32 36
33 -/**
34 - * Apply Content filters.
35 - *
36 - * @since 9.7.0 Deprecated $content parameter.
37 - *
38 - * @param string $content Post content. Deprecated.
39 - */
40 -function jetpack_blog_display_custom_excerpt( $content = '' ) {
41 - if ( ! empty( $content ) ) {
42 - _doing_it_wrong(
43 - 'jetpack_blog_display_custom_excerpt',
44 - esc_html__( 'You do not need to pass a $content parameter anymore.', 'jetpack' ),
45 - 'jetpack-9.7.0'
46 - );
47 - }
37 +if ( ! function_exists( 'jetpack_blog_display_custom_excerpt' ) ) {
48 38
49 - $post = get_post();
50 - if ( empty( $post ) ) {
51 - return '';
52 - }
39 + /**
40 + * Apply Content filters.
41 + *
42 + * @deprecated 13.9 Moved to Classic Theme Helper package.
43 + * @since 9.7.0 Deprecated $content parameter.
44 + *
45 + * @param string $content Post content. Deprecated.
46 + */
47 + function jetpack_blog_display_custom_excerpt( $content = '' ) {
48 + _deprecated_function( __FUNCTION__, 'jetpack-13.9' );
49 + if ( ! empty( $content ) ) {
50 + _doing_it_wrong(
51 + 'jetpack_blog_display_custom_excerpt',
52 + esc_html__( 'You do not need to pass a $content parameter anymore.', 'jetpack' ),
53 + 'jetpack-9.7.0'
54 + );
55 + }
53 56
54 - if ( empty( $post->post_excerpt ) ) {
55 - $text = strip_shortcodes( $post->post_content );
56 - $text = str_replace( ']]>', ']]>', $text );
57 - $text = wp_strip_all_tags( $text );
58 - /** This filter is documented in wp-includes/formatting.php */
59 - $excerpt_length = apply_filters( 'excerpt_length', 55 );
60 - /** This filter is documented in wp-includes/formatting.php */
61 - $excerpt_more = apply_filters( 'excerpt_more', ' [...]' );
57 + $post = get_post();
58 + if ( empty( $post ) ) {
59 + return '';
60 + }
62 61
63 - /*
64 - * translators: If your word count is based on single characters (e.g. East Asian characters),
65 - * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.
66 - * Do not translate into your own language.
67 - */
68 - if ( strpos( _x( 'words', 'Word count type. Do not translate!', 'jetpack' ), 'characters' ) === 0 && preg_match( '/^utf\-?8$/i', get_option( 'blog_charset' ) ) ) {
69 - $text = trim( preg_replace( "/[\n\r\t ]+/", ' ', $text ), ' ' );
70 - preg_match_all( '/./u', $text, $words );
71 - $words = array_slice( $words[0], 0, $excerpt_length + 1 );
72 - $sep = '';
62 + if ( empty( $post->post_excerpt ) ) {
63 + $text = strip_shortcodes( $post->post_content );
64 + $text = str_replace( ']]>', ']]>', $text );
65 + $text = wp_strip_all_tags( $text );
66 + /** This filter is documented in wp-includes/formatting.php */
67 + $excerpt_length = apply_filters( 'excerpt_length', 55 );
68 + /** This filter is documented in wp-includes/formatting.php */
69 + $excerpt_more = apply_filters( 'excerpt_more', ' [...]' );
70 +
71 + /*
72 + * translators: If your word count is based on single characters (e.g. East Asian characters),
73 + * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.
74 + * Do not translate into your own language.
75 + */
76 + if ( strpos( _x( 'words', 'Word count type. Do not translate!', 'jetpack' ), 'characters' ) === 0 && preg_match( '/^utf\-?8$/i', get_option( 'blog_charset' ) ) ) {
77 + $text = trim( preg_replace( "/[\n\r\t ]+/", ' ', $text ), ' ' );
78 + preg_match_all( '/./u', $text, $words );
79 + $words = array_slice( $words[0], 0, $excerpt_length + 1 );
80 + $sep = '';
81 + } else {
82 + $words = preg_split( "/[\n\r\t ]+/", $text, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY );
83 + $sep = ' ';
84 + }
85 +
86 + if ( count( $words ) > $excerpt_length ) {
87 + array_pop( $words );
88 + $text = implode( $sep, $words );
89 + $text .= $excerpt_more;
90 + } else {
91 + $text = implode( $sep, $words );
92 + }
73 93 } else {
74 - $words = preg_split( "/[\n\r\t ]+/", $text, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY );
75 - $sep = ' ';
94 + $text = wp_kses_post( $post->post_excerpt );
76 95 }
96 + return sprintf( '<p>%s</p>', $text );
97 + }
77 98
78 - if ( count( $words ) > $excerpt_length ) {
79 - array_pop( $words );
80 - $text = implode( $sep, $words );
81 - $text = $text . $excerpt_more;
99 +}
100 +
101 +if ( ! function_exists( 'jetpack_the_content_to_the_excerptt' ) ) {
102 +
103 + /**
104 + * Display Excerpt instead of Content.
105 + *
106 + * @deprecated 13.9 Moved to Classic Theme Helper package.
107 + *
108 + * @param string $content Post content.
109 + */
110 + function jetpack_the_content_to_the_excerpt( $content ) {
111 + _deprecated_function( __FUNCTION__, 'jetpack-13.9' );
112 + if ( ( is_home() || is_archive() ) && ! is_post_type_archive( array( 'jetpack-testimonial', 'jetpack-portfolio', 'product' ) ) ) {
113 + if ( post_password_required() ) {
114 + $excerpt = sprintf( '<p>%s</p>', esc_html__( 'There is no excerpt because this is a protected post.', 'jetpack' ) );
115 + } else {
116 + $excerpt = jetpack_blog_display_custom_excerpt();
117 + }
118 + }
119 + if ( empty( $excerpt ) ) {
120 + return $content;
82 121 } else {
83 - $text = implode( $sep, $words );
122 + return $excerpt;
84 123 }
85 - } else {
86 - $text = wp_kses_post( $post->post_excerpt );
87 124 }
88 - return sprintf( '<p>%s</p>', $text );
125 +
89 126 }
90 127
91 -/**
92 - * Display Excerpt instead of Content.
93 - *
94 - * @param string $content Post content.
95 - */
96 -function jetpack_the_content_to_the_excerpt( $content ) {
97 - if ( ( is_home() || is_archive() ) && ! is_post_type_archive( array( 'jetpack-testimonial', 'jetpack-portfolio', 'product' ) ) ) {
98 - if ( post_password_required() ) {
99 - $excerpt = sprintf( '<p>%s</p>', esc_html__( 'There is no excerpt because this is a protected post.', 'jetpack' ) );
100 - } else {
101 - $excerpt = jetpack_blog_display_custom_excerpt();
128 +if ( ! function_exists( 'jetpack_the_excerpt_to_the_content' ) ) {
129 +
130 + /**
131 + * Display Content instead of Excerpt.
132 + *
133 + * @deprecated 13.9 Moved to Classic Theme Helper package.
134 + *
135 + * @param string $content The post excerpt.
136 + */
137 + function jetpack_the_excerpt_to_the_content( $content ) {
138 + _deprecated_function( __FUNCTION__, 'jetpack-13.9' );
139 + if ( ( is_home() || is_archive() ) && ! is_post_type_archive( array( 'jetpack-testimonial', 'jetpack-portfolio', 'product' ) ) ) {
140 + ob_start();
141 + the_content(
142 + sprintf(
143 + wp_kses(
144 + /* translators: %s: Name of current post. Only visible to screen readers */
145 + __( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'jetpack' ),
146 + array(
147 + 'span' => array(
148 + 'class' => array(),
149 + ),
150 + )
151 + ),
152 + get_the_title()
153 + )
154 + );
155 + $content = ob_get_clean();
102 156 }
103 - }
104 - if ( empty( $excerpt ) ) {
105 157 return $content;
106 - } else {
107 - return $excerpt;
108 158 }
159 +
109 160 }
110 161
111 -/**
112 - * Display Content instead of Excerpt.
113 - *
114 - * @param string $content The post excerpt.
115 - */
116 -function jetpack_the_excerpt_to_the_content( $content ) {
117 - if ( ( is_home() || is_archive() ) && ! is_post_type_archive( array( 'jetpack-testimonial', 'jetpack-portfolio', 'product' ) ) ) {
118 - ob_start();
119 - the_content(
120 - sprintf(
121 - wp_kses(
122 - /* translators: %s: Name of current post. Only visible to screen readers */
123 - __( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'jetpack' ),
124 - array(
125 - 'span' => array(
126 - 'class' => array(),
127 - ),
128 - )
129 - ),
130 - get_the_title()
131 - )
132 - );
133 - $content = ob_get_clean();
162 +if ( ! function_exists( 'jetpack_the_content_customizer' ) ) {
163 +
164 + /**
165 + * Display both Content and Excerpt instead of Content in the Customizer so live preview can switch between them.
166 + *
167 + * @deprecated 13.9 Moved to Classic Theme Helper package.
168 + * @param string $content The post content.
169 + */
170 + function jetpack_the_content_customizer( $content ) {
171 + _deprecated_function( __FUNCTION__, 'jetpack-13.9' );
172 + $class = jetpack_the_content_customizer_class();
173 + if ( ( is_home() || is_archive() ) && ! is_post_type_archive( array( 'jetpack-testimonial', 'jetpack-portfolio', 'product' ) ) ) {
174 + if ( post_password_required() ) {
175 + $excerpt = sprintf( '<p>%s</p>', esc_html__( 'There is no excerpt because this is a protected post.', 'jetpack' ) );
176 + } else {
177 + $excerpt = jetpack_blog_display_custom_excerpt();
178 + }
179 + }
180 + if ( empty( $excerpt ) ) {
181 + return $content;
182 + } else {
183 + return sprintf( '<div class="jetpack-blog-display %s jetpack-the-content">%s</div><div class="jetpack-blog-display %s jetpack-the-excerpt">%s</div>', $class, $content, $class, $excerpt );
184 + }
134 185 }
135 - return $content;
186 +
136 187 }
137 188
138 -/**
139 - * Display both Content and Excerpt instead of Content in the Customizer so live preview can switch between them.
140 - *
141 - * @param string $content The post content.
142 - */
143 -function jetpack_the_content_customizer( $content ) {
144 - $class = jetpack_the_content_customizer_class();
145 - if ( ( is_home() || is_archive() ) && ! is_post_type_archive( array( 'jetpack-testimonial', 'jetpack-portfolio', 'product' ) ) ) {
146 - if ( post_password_required() ) {
147 - $excerpt = sprintf( '<p>%s</p>', esc_html__( 'There is no excerpt because this is a protected post.', 'jetpack' ) );
189 +if ( ! function_exists( 'jetpack_the_excerpt_customizer' ) ) {
190 +
191 + /**
192 + * Display both Content and Excerpt instead of Excerpt in the Customizer so live preview can switch between them.
193 + *
194 + * @deprecated 13.9 Moved to Classic Theme Helper package.
195 + * @param string $excerpt The post excerpt.
196 + */
197 + function jetpack_the_excerpt_customizer( $excerpt ) {
198 + _deprecated_function( __FUNCTION__, 'jetpack-13.9' );
199 + if ( ( is_home() || is_archive() ) && ! is_post_type_archive( array( 'jetpack-testimonial', 'jetpack-portfolio', 'product' ) ) ) {
200 + ob_start();
201 + the_content(
202 + sprintf(
203 + wp_kses(
204 + /* translators: %s: Name of current post. Only visible to screen readers */
205 + __( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'jetpack' ),
206 + array(
207 + 'span' => array(
208 + 'class' => array(),
209 + ),
210 + )
211 + ),
212 + get_the_title()
213 + )
214 + );
215 + $content = ob_get_clean();
216 + }
217 + if ( empty( $content ) ) {
218 + return $excerpt;
148 219 } else {
149 - $excerpt = jetpack_blog_display_custom_excerpt();
220 + return sprintf( '<div class="jetpack-blog-display jetpack-the-content">%s</div><div class="jetpack-blog-display jetpack-the-excerpt">%s</div>', $content, $excerpt );
150 221 }
151 222 }
152 - if ( empty( $excerpt ) ) {
223 +
224 +}
225 +
226 +if ( ! function_exists( 'jetpack_the_excerpt_mixed_customizer' ) ) {
227 +
228 + /**
229 + * Display Content instead of Excerpt in the Customizer when theme uses a 'Mixed' display.
230 + *
231 + * @deprecated 13.9 Moved to Classic Theme Helper package.
232 + * @param string $content The post excerpt.
233 + */
234 + function jetpack_the_excerpt_mixed_customizer( $content ) {
235 + _deprecated_function( __FUNCTION__, 'jetpack-13.9' );
236 + if ( ( is_home() || is_archive() ) && ! is_post_type_archive( array( 'jetpack-testimonial', 'jetpack-portfolio', 'product' ) ) ) {
237 + jetpack_the_content_customizer_class( 'output-the-excerpt' );
238 + ob_start();
239 + the_content();
240 + $content = ob_get_clean();
241 + }
153 242 return $content;
154 - } else {
155 - return sprintf( '<div class="jetpack-blog-display %s jetpack-the-content">%s</div><div class="jetpack-blog-display %s jetpack-the-excerpt">%s</div>', $class, $content, $class, $excerpt );
156 243 }
244 +
157 245 }
158 246
159 -/**
160 - * Display both Content and Excerpt instead of Excerpt in the Customizer so live preview can switch between them.
161 - *
162 - * @param string $excerpt The post excerpt.
163 - */
164 -function jetpack_the_excerpt_customizer( $excerpt ) {
165 - if ( ( is_home() || is_archive() ) && ! is_post_type_archive( array( 'jetpack-testimonial', 'jetpack-portfolio', 'product' ) ) ) {
166 - ob_start();
167 - the_content(
168 - sprintf(
169 - wp_kses(
170 - /* translators: %s: Name of current post. Only visible to screen readers */
171 - __( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'jetpack' ),
172 - array(
173 - 'span' => array(
174 - 'class' => array(),
175 - ),
176 - )
177 - ),
178 - get_the_title()
179 - )
180 - );
181 - $content = ob_get_clean();
182 - }
183 - if ( empty( $content ) ) {
184 - return $excerpt;
185 - } else {
186 - return sprintf( '<div class="jetpack-blog-display jetpack-the-content">%s</div><div class="jetpack-blog-display jetpack-the-excerpt">%s</div>', $content, $excerpt );
187 - }
188 -}
247 +if ( ! function_exists( 'jetpack_the_content_customizer_class' ) ) {
189 248
190 -/**
191 - * Display Content instead of Excerpt in the Customizer when theme uses a 'Mixed' display.
192 - *
193 - * @param string $content The post excerpt.
194 - */
195 -function jetpack_the_excerpt_mixed_customizer( $content ) {
196 - if ( ( is_home() || is_archive() ) && ! is_post_type_archive( array( 'jetpack-testimonial', 'jetpack-portfolio', 'product' ) ) ) {
197 - jetpack_the_content_customizer_class( 'output-the-excerpt' );
198 - ob_start();
199 - the_content();
200 - $content = ob_get_clean();
249 + /**
250 + * Returns a class value, `output-the-content` by default.
251 + * Used for themes with a 'Mixed' Blog Display so we can tell which output is by default.
252 + *
253 + * @deprecated 13.9 Moved to Classic Theme Helper package.
254 + * @param string|null $new_class CSS class added to content container.
255 + */
256 + function jetpack_the_content_customizer_class( $new_class = null ) {
257 + _deprecated_function( __FUNCTION__, 'jetpack-13.9' );
258 + static $class;
259 + if ( isset( $new_class ) ) {
260 + // Assign a new class and return.
261 + $class = $new_class;
262 + } elseif ( isset( $class ) ) {
263 + // Reset the class after getting value.
264 + $prev_class = $class;
265 + $class = null;
266 + return $prev_class;
267 + } else {
268 + // Return default class value.
269 + return 'output-the-content';
270 + }
201 271 }
202 - return $content;
203 -}
204 272
205 -/**
206 - * Returns a class value, `output-the-content` by default.
207 - * Used for themes with a 'Mixed' Blog Display so we can tell which output is by default.
208 - *
209 - * @param string|null $new_class CSS class added to content container.
210 - */
211 -function jetpack_the_content_customizer_class( $new_class = null ) {
212 - static $class;
213 - if ( isset( $new_class ) ) {
214 - // Assign a new class and return.
215 - $class = $new_class;
216 - } elseif ( isset( $class ) ) {
217 - // Reset the class after getting value.
218 - $prev_class = $class;
219 - $class = null;
220 - return $prev_class;
221 - } else {
222 - // Return default class value.
223 - return 'output-the-content';
224 - }
225 273 }
226 274
227 275 if ( is_customize_preview() ) {
228 276 /*