WordPress.org

Make WordPress Core

Ticket #32096: 32096.4.diff

File 32096.4.diff, 2.0 KB (added by ianbelanger, 9 months ago)

Updated patch to apply to current trunk, updated @since and added another conditional check for author post number

  • src/wp-content/themes/twentyfifteen/functions.php

     
    556556 * @since Twenty Fifteen 1.0
    557557 */
    558558require get_template_directory() . '/inc/customizer.php';
     559
     560/**
     561 * Prevents author-bio.php from being accessed directly if user_nicename is `bio`
     562 *
     563 * @since Twenty Fifteen 2.5
     564 *
     565 * @param string @template Template file
     566 * @return string Replacement template file
     567 */
     568function twentyfifteen_author_bio_template( $template ) {
     569        $author_posts_number = get_the_author_posts();
     570
     571        if ( get_the_author_meta( 'user_nicename' ) === 'bio' || $author_posts_number === 0 ) {
     572                $new_template = locate_template( array( 'archive.php' ) );
     573               
     574                if ( '' != $new_template ) {
     575                        return $new_template;
     576                }
     577
     578        }
     579
     580        return $template;
     581}
     582add_filter( 'template_include', 'twentyfifteen_author_bio_template' );
  • src/wp-content/themes/twentythirteen/functions.php

     
    777777        return $args;
    778778}
    779779add_filter( 'widget_tag_cloud_args', 'twentythirteen_widget_tag_cloud_args' );
     780
     781/**
     782 * Prevents author-bio.php from being accessed directly if user_nicename is `bio`
     783 *
     784 * @since Twenty Fifteen 2.9
     785 *
     786 * @param string @template Template file
     787 * @return string Replacement template file
     788 */
     789function twentythirteen_author_bio_template( $template ) {
     790        $author_posts_number = get_the_author_posts();
     791
     792        if ( get_the_author_meta( 'user_nicename' ) === 'bio' || $author_posts_number === 0 ) {
     793                $new_template = locate_template( array( 'archive.php' ) );
     794               
     795                if ( '' != $new_template ) {
     796                        return $new_template;
     797                }
     798
     799        }
     800
     801        return $template;
     802}
     803add_filter( 'template_include', 'twentythirteen_author_bio_template' );