WordPress.org

Make WordPress Core

Ticket #32096: 32096.3.diff

File 32096.3.diff, 2.0 KB (added by rclations, 5 years ago)
  • src/wp-content/themes/twentyfifteen/functions.php

     
    353353 * @since Twenty Fifteen 1.0
    354354 */
    355355require get_template_directory() . '/inc/customizer.php';
     356
     357/**
     358 * Prevents author-bio.php from being accessed directly if user_nicename is `bio`
     359 *
     360 * @since Twenty Fifteen 1.2
     361 *
     362 * @param string @template Template file
     363 * @return string Replacement template file
     364 */
     365function author_bio_template( $template ) {
     366        if ( get_the_author_meta( 'user_nicename' ) === 'bio' ) {
     367                $new_template = locate_template( array( 'archive.php' ) );
     368                if ( '' != $new_template ) {
     369                        return $new_template ;
     370                }
     371        }
     372        return $template;
     373}
     374add_filter( 'template_include', 'author_bio_template' );
     375 No newline at end of file
  • src/wp-content/themes/twentythirteen/functions.php

     
    550550        wp_enqueue_script( 'twentythirteen-customizer', get_template_directory_uri() . '/js/theme-customizer.js', array( 'customize-preview' ), '20141120', true );
    551551}
    552552add_action( 'customize_preview_init', 'twentythirteen_customize_preview_js' );
     553
     554/**
     555 * Prevents author-bio.php from being accessed directly if user_nicename is `bio`
     556 *
     557 * @since Twenty Thirteen 1.6
     558 *
     559 * @param string @template Template file
     560 * @return string Replacement template file
     561 */
     562function author_bio_template( $template ) {
     563        if ( get_the_author_meta( 'user_nicename' ) === 'bio' ) {
     564                $new_template = locate_template( array( 'author.php' ) );
     565                if ( '' != $new_template ) {
     566                        return $new_template ;
     567                }
     568        }
     569        return $template;
     570}
     571add_filter( 'template_include', 'author_bio_template' );
     572 No newline at end of file