Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#50079 closed enhancement (duplicate)

FIlter hook for custom text password protected post

Reported by: pickplugins's profile pickplugins Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords:
Focuses: template Cc:

Description

I notice there is no way to change the text for password protected excerpt. I recommend to add a filter hook for this would help to override by custom text.

wp-includes/post-template.php
Line: 415
function: get_the_excerpt()

function get_the_excerpt( $post = null ) {
	if ( is_bool( $post ) ) {
		_deprecated_argument( __FUNCTION__, '2.3.0' );
	}

	$post = get_post( $post );
	if ( empty( $post ) ) {
		return '';
	}

	if ( post_password_required( $post ) ) {
		return __( 'There is no excerpt because this is a protected post.' );
	}

	/**
	 * Filters the retrieved post excerpt.
	 *
	 * @since 1.2.0
	 * @since 4.5.0 Introduced the `$post` parameter.
	 *
	 * @param string  $post_excerpt The post excerpt.
	 * @param WP_Post $post         Post object.
	 */
	return apply_filters( 'get_the_excerpt', $post->post_excerpt, $post );
}

Recommend change in line: 415

Old:
return __( 'There is no excerpt because this is a protected post.' );

New
return apply_filters( 'password_protected_excerpt', __( 'There is no excerpt because this is a protected post.' ) );

Change History (1)

#1 @dlh
5 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed
  • Version 5.4 deleted

Hi @pickplugins, and thanks for the ticket. We're tracking this enhancement in #35308.

Note: See TracTickets for help on using tickets.