Ticket #8058: 8058.patch
| File 8058.patch, 4.3 KB (added by Viper007Bond, 4 years ago) |
|---|
-
wp-includes/link-template.php
1054 1054 } 1055 1055 1056 1056 /** 1057 * Display the next posts pages link.1057 * Display or return the next posts pages link. 1058 1058 * 1059 1059 * @since 0.71 1060 1060 * 1061 1061 * @param int $max_page Optional. Max pages. 1062 * @param boolean $echo Optional. Echo or return; 1062 1063 */ 1063 function next_posts($max_page = 0) { 1064 echo clean_url(get_next_posts_page_link($max_page)); 1064 function next_posts( $max_page = 0, $echo = true ) { 1065 $output = clean_url( get_next_posts_page_link( $max_page ) ); 1066 1067 if ( $echo ) 1068 echo $output; 1069 else 1070 return $output; 1065 1071 } 1066 1072 1067 1073 /** 1068 * Displaythe next posts pages link.1074 * Return the next posts pages link. 1069 1075 * 1070 * @since 0.711076 * @since 2.7.0 1071 1077 * 1072 1078 * @param string $label Content for link text. 1073 1079 * @param int $max_page Optional. Max pages. 1080 * @return string 1074 1081 */ 1075 function next_posts_link($label='Next Page »', $max_page=0) {1082 function get_next_posts_link( $label = 'Next Page »', $max_page = 0 ) { 1076 1083 global $paged, $wp_query; 1077 1084 if ( !$max_page ) { 1078 1085 $max_page = $wp_query->max_num_pages; … … 1080 1087 if ( !$paged ) 1081 1088 $paged = 1; 1082 1089 $nextpage = intval($paged) + 1; 1083 if ( (! is_single()) && (empty($paged) || $nextpage <= $max_page) ) { 1084 echo '<a href="'; 1085 next_posts($max_page); 1090 $output = ''; 1091 if ( (!is_single() ) && ( empty($paged) || $nextpage <= $max_page) ) { 1086 1092 $attr = apply_filters( 'next_posts_link_attributes', '' ); 1087 echo"\" $attr>". preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $label) .'</a>';1093 $output = '<a href="' . next_posts( $max_page, false ) . "\" $attr>". preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $label) .'</a>'; 1088 1094 } 1095 return $output; 1089 1096 } 1090 1097 1091 1098 /** 1099 * Display the next posts pages link. 1100 * 1101 * @since 0.71 1102 * @uses get_next_posts_link() 1103 * 1104 * @param string $label Content for link text. 1105 * @param int $max_page Optional. Max pages. 1106 */ 1107 function next_posts_link( $label = 'Next Page »', $max_page = 0 ) { 1108 echo get_next_posts_link( $label, $max_page ); 1109 } 1110 1111 /** 1092 1112 * Retrieve previous post pages link. 1093 1113 * 1094 1114 * Will only return string, if not on a single page or post. … … 1111 1131 } 1112 1132 1113 1133 /** 1114 * Display previous posts pages link.1134 * Display or return the previous posts pages link. 1115 1135 * 1116 1136 * @since 0.71 1137 * 1138 * @param boolean $echo Optional. Echo or return; 1117 1139 */ 1118 function previous_posts() { 1119 echo clean_url(get_previous_posts_page_link()); 1140 function previous_posts( $echo = true ) { 1141 $output = clean_url( get_previous_posts_page_link() ); 1142 1143 if ( $echo ) 1144 echo $output; 1145 else 1146 return $output; 1120 1147 } 1121 1148 1122 1149 /** 1123 * Display previous posts pagelink.1150 * Return the previous posts pages link. 1124 1151 * 1125 * @since 0.711152 * @since 2.7.0 1126 1153 * 1127 1154 * @param string $label Optional. Previous page link text. 1155 * @return string 1128 1156 */ 1129 function previous_posts_link($label='« Previous Page') {1157 function get_previous_posts_link( $label = '« Previous Page' ) { 1130 1158 global $paged; 1131 if ( (!is_single()) && ($paged > 1) ) { 1132 echo '<a href="'; 1133 previous_posts(); 1159 $output = ''; 1160 if ( (!is_single() ) && ( $paged > 1) ) { 1134 1161 $attr = apply_filters( 'previous_posts_link_attributes', '' ); 1135 echo "\" $attr>". preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $label) .'</a>';1162 $output = '<a href="' . previous_posts( false ) . "\" $attr>". preg_replace( '/&([^#])(?![a-z]{1,8};)/', '&$1', $label ) .'</a>'; 1136 1163 } 1164 return $output; 1137 1165 } 1138 1166 1139 1167 /** 1168 * Display the previous posts page link. 1169 * 1170 * @since 0.71 1171 * @uses get_previous_posts_link() 1172 * 1173 * @param string $label Optional. Previous page link text. 1174 */ 1175 function previous_posts_link( $label = '« Previous Page' ) { 1176 echo get_previous_posts_link( $label ); 1177 } 1178 1179 /** 1140 1180 * Display post pages link navigation for previous and next pages. 1141 1181 * 1142 1182 * @since 0.71 … … 1145 1185 * @param string $prelabel Optional. Label for previous pages. 1146 1186 * @param string $nxtlabel Optional Label for next pages. 1147 1187 */ 1148 function posts_nav_link( $sep=' — ', $prelabel='« Previous Page', $nxtlabel='Next Page »') {1188 function posts_nav_link( $sep = ' — ', $prelabel = '« Previous Page', $nxtlabel = 'Next Page »' ) { 1149 1189 global $wp_query; 1150 1190 if ( !is_singular() ) { 1151 1191 $max_num_pages = $wp_query->max_num_pages;
