Changeset 35624
- Timestamp:
- 11/11/2015 11:49:31 PM (9 years ago)
- Location:
- trunk/src/wp-includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/deprecated.php
r35325 r35624 3636 3636 return force_ssl_admin( $force ); 3637 3637 } 3638 3639 /**3640 * Formerly used to display or retrieve page title for all areas of blog.3641 *3642 * By default, the page title will display the separator before the page title,3643 * so that the blog title will be before the page title. This is not good for3644 * title display, since the blog title shows up on most tabs and not what is3645 * important, which is the page that the user is looking at.3646 *3647 * There are also SEO benefits to having the blog title after or to the 'right'3648 * or the page title. However, it is mostly common sense to have the blog title3649 * to the right with most browsers supporting tabs. You can achieve this by3650 * using the seplocation parameter and setting the value to 'right'. This change3651 * was introduced around 2.5.0, in case backwards compatibility of themes is3652 * important.3653 *3654 * @since 1.0.03655 * @deprecated 4.4.0 Use `add_theme_support( 'title-tag' )`3656 * @see add_theme_support()3657 *3658 * @param string $sep Optional, default is '»'. How to separate the various items3659 * within the page title.3660 * @param bool $display Optional, default is true. Whether to display or retrieve title.3661 * @param string $seplocation Optional. Direction to display title, 'right'.3662 * @return string|null String on retrieve, null when displaying.3663 */3664 function wp_title( $sep = '»', $display = true, $seplocation = '' ) {3665 _deprecated_function( __FUNCTION__, '4.4', 'add_theme_support( \'title-tag\' )' );3666 3667 global $wp_locale;3668 3669 $m = get_query_var( 'm' );3670 $year = get_query_var( 'year' );3671 $monthnum = get_query_var( 'monthnum' );3672 $day = get_query_var( 'day' );3673 $search = get_query_var( 's' );3674 $title = '';3675 3676 $t_sep = '%WP_TITILE_SEP%'; // Temporary separator, for accurate flipping, if necessary3677 3678 // If there is a post3679 if ( is_single() || ( is_home() && ! is_front_page() ) || ( is_page() && ! is_front_page() ) ) {3680 $title = single_post_title( '', false );3681 }3682 3683 // If there's a post type archive3684 if ( is_post_type_archive() ) {3685 $post_type = get_query_var( 'post_type' );3686 if ( is_array( $post_type ) ) {3687 $post_type = reset( $post_type );3688 }3689 $post_type_object = get_post_type_object( $post_type );3690 if ( ! $post_type_object->has_archive ) {3691 $title = post_type_archive_title( '', false );3692 }3693 }3694 3695 // If there's a category or tag3696 if ( is_category() || is_tag() ) {3697 $title = single_term_title( '', false );3698 }3699 3700 // If there's a taxonomy3701 if ( is_tax() ) {3702 $term = get_queried_object();3703 if ( $term ) {3704 $tax = get_taxonomy( $term->taxonomy );3705 $title = single_term_title( $tax->labels->name . $t_sep, false );3706 }3707 }3708 3709 // If there's an author3710 if ( is_author() && ! is_post_type_archive() ) {3711 $author = get_queried_object();3712 if ( $author ) {3713 $title = $author->display_name;3714 }3715 }3716 3717 // Post type archives with has_archive should override terms.3718 if ( is_post_type_archive() && $post_type_object->has_archive ) {3719 $title = post_type_archive_title( '', false );3720 }3721 3722 // If there's a month3723 if ( is_archive() && ! empty( $m ) ) {3724 $my_year = substr( $m, 0, 4 );3725 $my_month = $wp_locale->get_month( substr( $m, 4, 2 ) );3726 $my_day = intval( substr( $m, 6, 2 ) );3727 $title = $my_year . ( $my_month ? $t_sep . $my_month : '' ) . ( $my_day ? $t_sep . $my_day : '' );3728 }3729 3730 // If there's a year3731 if ( is_archive() && ! empty( $year ) ) {3732 $title = $year;3733 if ( ! empty( $monthnum ) ) {3734 $title .= $t_sep . $wp_locale->get_month( $monthnum );3735 }3736 if ( ! empty( $day ) ) {3737 $title .= $t_sep . zeroise( $day, 2 );3738 }3739 }3740 3741 // If it's a search3742 if ( is_search() ) {3743 /* translators: 1: separator, 2: search phrase */3744 $title = sprintf( __( 'Search Results %1$s %2$s' ), $t_sep, strip_tags( $search ) );3745 }3746 3747 // If it's a 404 page3748 if ( is_404() ) {3749 $title = __( 'Page not found' );3750 }3751 3752 $prefix = '';3753 if ( ! empty( $title ) ) {3754 $prefix = " $sep ";3755 }3756 3757 /**3758 * Filter the parts of the page title.3759 *3760 * @since 4.0.03761 *3762 * @param array $title_array Parts of the page title.3763 */3764 $title_array = apply_filters( 'wp_title_parts', explode( $t_sep, $title ) );3765 3766 // Determines position of the separator and direction of the breadcrumb3767 if ( 'right' == $seplocation ) { // sep on right, so reverse the order3768 $title_array = array_reverse( $title_array );3769 $title = implode( " $sep ", $title_array ) . $prefix;3770 } else {3771 $title = $prefix . implode( " $sep ", $title_array );3772 }3773 3774 /**3775 * Filter the text of the page title.3776 *3777 * @since 2.0.03778 *3779 * @param string $title Page title.3780 * @param string $sep Title separator.3781 * @param string $seplocation Location of the separator (left or right).3782 */3783 $title = apply_filters( 'wp_title', $title, $sep, $seplocation );3784 3785 // Send it out3786 if ( $display ) {3787 echo $title;3788 } else {3789 return $title;3790 }3791 } -
trunk/src/wp-includes/general-template.php
r35572 r35624 955 955 956 956 echo '<title>' . wp_get_document_title() . '</title>' . "\n"; 957 } 958 959 /** 960 * Display or retrieve page title for all areas of blog. 961 * 962 * By default, the page title will display the separator before the page title, 963 * so that the blog title will be before the page title. This is not good for 964 * title display, since the blog title shows up on most tabs and not what is 965 * important, which is the page that the user is looking at. 966 * 967 * There are also SEO benefits to having the blog title after or to the 'right' 968 * or the page title. However, it is mostly common sense to have the blog title 969 * to the right with most browsers supporting tabs. You can achieve this by 970 * using the seplocation parameter and setting the value to 'right'. This change 971 * was introduced around 2.5.0, in case backwards compatibility of themes is 972 * important. 973 * 974 * @since 1.0.0 975 * 976 * @global WP_Locale $wp_locale 977 * 978 * @param string $sep Optional, default is '»'. How to separate the various items 979 * within the page title. 980 * @param bool $display Optional, default is true. Whether to display or retrieve title. 981 * @param string $seplocation Optional. Direction to display title, 'right'. 982 * @return string|null String on retrieve, null when displaying. 983 */ 984 function wp_title( $sep = '»', $display = true, $seplocation = '' ) { 985 global $wp_locale; 986 987 $m = get_query_var( 'm' ); 988 $year = get_query_var( 'year' ); 989 $monthnum = get_query_var( 'monthnum' ); 990 $day = get_query_var( 'day' ); 991 $search = get_query_var( 's' ); 992 $title = ''; 993 994 $t_sep = '%WP_TITILE_SEP%'; // Temporary separator, for accurate flipping, if necessary 995 996 // If there is a post 997 if ( is_single() || ( is_home() && ! is_front_page() ) || ( is_page() && ! is_front_page() ) ) { 998 $title = single_post_title( '', false ); 999 } 1000 1001 // If there's a post type archive 1002 if ( is_post_type_archive() ) { 1003 $post_type = get_query_var( 'post_type' ); 1004 if ( is_array( $post_type ) ) { 1005 $post_type = reset( $post_type ); 1006 } 1007 $post_type_object = get_post_type_object( $post_type ); 1008 if ( ! $post_type_object->has_archive ) { 1009 $title = post_type_archive_title( '', false ); 1010 } 1011 } 1012 1013 // If there's a category or tag 1014 if ( is_category() || is_tag() ) { 1015 $title = single_term_title( '', false ); 1016 } 1017 1018 // If there's a taxonomy 1019 if ( is_tax() ) { 1020 $term = get_queried_object(); 1021 if ( $term ) { 1022 $tax = get_taxonomy( $term->taxonomy ); 1023 $title = single_term_title( $tax->labels->name . $t_sep, false ); 1024 } 1025 } 1026 1027 // If there's an author 1028 if ( is_author() && ! is_post_type_archive() ) { 1029 $author = get_queried_object(); 1030 if ( $author ) { 1031 $title = $author->display_name; 1032 } 1033 } 1034 1035 // Post type archives with has_archive should override terms. 1036 if ( is_post_type_archive() && $post_type_object->has_archive ) { 1037 $title = post_type_archive_title( '', false ); 1038 } 1039 1040 // If there's a month 1041 if ( is_archive() && ! empty( $m ) ) { 1042 $my_year = substr( $m, 0, 4 ); 1043 $my_month = $wp_locale->get_month( substr( $m, 4, 2 ) ); 1044 $my_day = intval( substr( $m, 6, 2 ) ); 1045 $title = $my_year . ( $my_month ? $t_sep . $my_month : '' ) . ( $my_day ? $t_sep . $my_day : '' ); 1046 } 1047 1048 // If there's a year 1049 if ( is_archive() && ! empty( $year ) ) { 1050 $title = $year; 1051 if ( ! empty( $monthnum ) ) { 1052 $title .= $t_sep . $wp_locale->get_month( $monthnum ); 1053 } 1054 if ( ! empty( $day ) ) { 1055 $title .= $t_sep . zeroise( $day, 2 ); 1056 } 1057 } 1058 1059 // If it's a search 1060 if ( is_search() ) { 1061 /* translators: 1: separator, 2: search phrase */ 1062 $title = sprintf( __( 'Search Results %1$s %2$s' ), $t_sep, strip_tags( $search ) ); 1063 } 1064 1065 // If it's a 404 page 1066 if ( is_404() ) { 1067 $title = __( 'Page not found' ); 1068 } 1069 1070 $prefix = ''; 1071 if ( ! empty( $title ) ) { 1072 $prefix = " $sep "; 1073 } 1074 1075 /** 1076 * Filter the parts of the page title. 1077 * 1078 * @since 4.0.0 1079 * 1080 * @param array $title_array Parts of the page title. 1081 */ 1082 $title_array = apply_filters( 'wp_title_parts', explode( $t_sep, $title ) ); 1083 1084 // Determines position of the separator and direction of the breadcrumb 1085 if ( 'right' == $seplocation ) { // sep on right, so reverse the order 1086 $title_array = array_reverse( $title_array ); 1087 $title = implode( " $sep ", $title_array ) . $prefix; 1088 } else { 1089 $title = $prefix . implode( " $sep ", $title_array ); 1090 } 1091 1092 /** 1093 * Filter the text of the page title. 1094 * 1095 * @since 2.0.0 1096 * 1097 * @param string $title Page title. 1098 * @param string $sep Title separator. 1099 * @param string $seplocation Location of the separator (left or right). 1100 */ 1101 $title = apply_filters( 'wp_title', $title, $sep, $seplocation ); 1102 1103 // Send it out 1104 if ( $display ) { 1105 echo $title; 1106 } else { 1107 return $title; 1108 } 957 1109 } 958 1110
Note: See TracChangeset
for help on using the changeset viewer.