[wp-trac] [WordPress Trac] #50079: FIlter hook for custom text password protected post

WordPress Trac noreply at wordpress.org
Mon May 4 15:44:54 UTC 2020


#50079: FIlter hook for custom text password protected post
-------------------------------+-----------------------------
 Reporter:  pickplugins        |      Owner:  (none)
     Type:  enhancement        |     Status:  new
 Priority:  normal             |  Milestone:  Awaiting Review
Component:  Posts, Post Types  |    Version:  5.4
 Severity:  normal             |   Keywords:
  Focuses:  template           |
-------------------------------+-----------------------------
 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.' ) );
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/50079>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list