summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/jetpack/modules/theme-tools/content-options/blog-display.php')
-rw-r--r--plugins/jetpack/modules/theme-tools/content-options/blog-display.php32
1 files changed, 26 insertions, 6 deletions
diff --git a/plugins/jetpack/modules/theme-tools/content-options/blog-display.php b/plugins/jetpack/modules/theme-tools/content-options/blog-display.php
index a3f74d0b..66273b12 100644
--- a/plugins/jetpack/modules/theme-tools/content-options/blog-display.php
+++ b/plugins/jetpack/modules/theme-tools/content-options/blog-display.php
@@ -30,9 +30,25 @@ if ( ! in_array( $blog_display, array( 'content', 'excerpt', 'mixed' ) ) ) {
/**
* Apply Content filters.
+ *
+ * @since 9.7.0 Deprecated $content parameter.
+ *
+ * @param string $content Post content. Deprecated.
*/
-function jetpack_blog_display_custom_excerpt( $content ) {
+function jetpack_blog_display_custom_excerpt( $content = '' ) {
+ if ( ! empty( $content ) ) {
+ _doing_it_wrong(
+ 'jetpack_blog_display_custom_excerpt',
+ esc_html__( 'You do not need to pass a $content parameter anymore.', 'jetpack' ),
+ 'jetpack-9.7.0'
+ );
+ }
+
$post = get_post();
+ if ( empty( $post ) ) {
+ return '';
+ }
+
if ( empty( $post->post_excerpt ) ) {
$text = strip_shortcodes( $post->post_content );
$text = str_replace( ']]>', ']]>', $text );
@@ -47,7 +63,7 @@ function jetpack_blog_display_custom_excerpt( $content ) {
* enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.
* Do not translate into your own language.
*/
- if ( strpos( _x( 'words', 'Word count type. Do not translate!' ), 'characters' ) === 0 && preg_match( '/^utf\-?8$/i', get_option( 'blog_charset' ) ) ) {
+ if ( strpos( _x( 'words', 'Word count type. Do not translate!', 'jetpack' ), 'characters' ) === 0 && preg_match( '/^utf\-?8$/i', get_option( 'blog_charset' ) ) ) {
$text = trim( preg_replace( "/[\n\r\t ]+/", ' ', $text ), ' ' );
preg_match_all( '/./u', $text, $words );
$words = array_slice( $words[0], 0, $excerpt_length + 1 );
@@ -76,12 +92,16 @@ function jetpack_blog_display_custom_excerpt( $content ) {
function jetpack_the_content_to_the_excerpt( $content ) {
if ( ( is_home() || is_archive() ) && ! is_post_type_archive( array( 'jetpack-testimonial', 'jetpack-portfolio', 'product' ) ) ) {
if ( post_password_required() ) {
- $content = sprintf( '<p>%s</p>', esc_html__( 'There is no excerpt because this is a protected post.', 'jetpack' ) );
+ $excerpt = sprintf( '<p>%s</p>', esc_html__( 'There is no excerpt because this is a protected post.', 'jetpack' ) );
} else {
- $content = jetpack_blog_display_custom_excerpt( $content );
+ $excerpt = jetpack_blog_display_custom_excerpt();
}
}
- return $content;
+ if ( empty( $excerpt ) ) {
+ return $content;
+ } else {
+ return $excerpt;
+ }
}
/**
@@ -118,7 +138,7 @@ function jetpack_the_content_customizer( $content ) {
if ( post_password_required() ) {
$excerpt = sprintf( '<p>%s</p>', esc_html__( 'There is no excerpt because this is a protected post.', 'jetpack' ) );
} else {
- $excerpt = jetpack_blog_display_custom_excerpt( $content );
+ $excerpt = jetpack_blog_display_custom_excerpt();
}
}
if ( empty( $excerpt ) ) {