Ticket #17673: 17673.diff
File 17673.diff, 7.9 KB (added by , 14 years ago) |
---|
-
wp-includes/link-template.php
1065 1065 * @since 1.5.0 1066 1066 * 1067 1067 * @param bool $in_same_cat Optional. Whether post should be in same category. 1068 * @param string $excluded_categories Optional. Excluded categoriesIDs.1068 * @param string $excluded_categories Optional. Comma-separated list of excluded category IDs. 1069 1069 * @return mixed Post object if successful. Null if global $post is not set. Empty string if no corresponding post exists. 1070 1070 */ 1071 1071 function get_previous_post($in_same_cat = false, $excluded_categories = '') { … … 1078 1078 * @since 1.5.0 1079 1079 * 1080 1080 * @param bool $in_same_cat Optional. Whether post should be in same category. 1081 * @param string $excluded_categories Optional. Excluded categoriesIDs.1081 * @param string $excluded_categories Optional. Comma-separated list of excluded category IDs. 1082 1082 * @return mixed Post object if successful. Null if global $post is not set. Empty string if no corresponding post exists. 1083 1083 */ 1084 1084 function get_next_post($in_same_cat = false, $excluded_categories = '') { … … 1093 1093 * @since 2.5.0 1094 1094 * 1095 1095 * @param bool $in_same_cat Optional. Whether post should be in same category. 1096 * @param string $excluded_categories Optional. Excluded categoriesIDs.1096 * @param string $excluded_categories Optional. Comma-separated list of excluded category IDs. 1097 1097 * @param bool $previous Optional. Whether to retrieve previous post. 1098 1098 * @return mixed Post object if successful. Null if global $post is not set. Empty string if no corresponding post exists. 1099 1099 */ … … 1107 1107 1108 1108 $join = ''; 1109 1109 $posts_in_ex_cats_sql = ''; 1110 if ( $in_same_cat || ! empty($excluded_categories) ) {1110 if ( $in_same_cat || ! empty( $excluded_categories ) ) { 1111 1111 $join = " INNER JOIN $wpdb->term_relationships AS tr ON p.ID = tr.object_id INNER JOIN $wpdb->term_taxonomy tt ON tr.term_taxonomy_id = tt.term_taxonomy_id"; 1112 1112 1113 1113 if ( $in_same_cat ) { … … 1116 1116 } 1117 1117 1118 1118 $posts_in_ex_cats_sql = "AND tt.taxonomy = 'category'"; 1119 if ( !empty($excluded_categories) ) { 1120 $excluded_categories = array_map('intval', explode(' and ', $excluded_categories)); 1121 if ( !empty($cat_array) ) { 1119 if ( ! empty( $excluded_categories ) ) { 1120 // back-compat, $excluded_categories used to be IDs separated by " and " 1121 if( strpos( $excluded_categories, ' and ' ) !== false ) 1122 $excluded_categories = explode( ' and ', $excluded_categories ); 1123 else 1124 $excluded_categories = explode( ',', $excluded_categories ); 1125 1126 $excluded_categories = array_map( 'intval', $excluded_categories ); 1127 1128 if ( ! empty( $cat_array ) ) { 1122 1129 $excluded_categories = array_diff($excluded_categories, $cat_array); 1123 1130 $posts_in_ex_cats_sql = ''; 1124 1131 } … … 1160 1167 * 1161 1168 * @param string $title Optional. Link title format. 1162 1169 * @param bool $in_same_cat Optional. Whether link should be in same category. 1163 * @param string $excluded_categories Optional. Excluded categoriesIDs.1170 * @param string $excluded_categories Optional. Comma-separated list of excluded category IDs. 1164 1171 * @param bool $previous Optional, default is true. Whether display link to previous post. 1165 1172 * @return string 1166 1173 */ … … 1197 1204 * 1198 1205 * @param string $title Optional. Link title format. 1199 1206 * @param bool $in_same_cat Optional. Whether link should be in same category. 1200 * @param string $excluded_categories Optional. Excluded categoriesIDs.1207 * @param string $excluded_categories Optional. Comma-separated list of excluded category IDs. 1201 1208 */ 1202 1209 function adjacent_posts_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '') { 1203 1210 echo get_adjacent_post_rel_link($title, $in_same_cat, $excluded_categories = '', true); … … 1224 1231 * 1225 1232 * @param string $title Optional. Link title format. 1226 1233 * @param bool $in_same_cat Optional. Whether link should be in same category. 1227 * @param string $excluded_categories Optional. Excluded categoriesIDs.1234 * @param string $excluded_categories Optional. Comma-separated list of excluded category IDs. 1228 1235 */ 1229 1236 function next_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '') { 1230 1237 echo get_adjacent_post_rel_link($title, $in_same_cat, $excluded_categories = '', false); … … 1237 1244 * 1238 1245 * @param string $title Optional. Link title format. 1239 1246 * @param bool $in_same_cat Optional. Whether link should be in same category. 1240 * @param string $excluded_categories Optional. Excluded categoriesIDs.1247 * @param string $excluded_categories Optional. Comma-separated list of excluded category IDs. 1241 1248 */ 1242 1249 function prev_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '') { 1243 1250 echo get_adjacent_post_rel_link($title, $in_same_cat, $excluded_categories = '', true); … … 1252 1259 * @since 2.8.0 1253 1260 * 1254 1261 * @param bool $in_same_cat Optional. Whether returned post should be in same category. 1255 * @param string $excluded_categories Optional. Excluded categoriesIDs.1262 * @param string $excluded_categories Optional. Comma-separated list of excluded category IDs. 1256 1263 * @param bool $start Optional. Whether to retrieve first or last post. 1257 1264 * @return object 1258 1265 */ … … 1298 1305 * 1299 1306 * @param string $title Optional. Link title format. 1300 1307 * @param bool $in_same_cat Optional. Whether link should be in same category. 1301 * @param string $excluded_categories Optional. Excluded categoriesIDs.1308 * @param string $excluded_categories Optional. Comma-separated list of excluded category IDs. 1302 1309 * @param bool $start Optional, default is true. Whether display link to first or last post. 1303 1310 * @return string 1304 1311 */ … … 1335 1342 * 1336 1343 * @param string $title Optional. Link title format. 1337 1344 * @param bool $in_same_cat Optional. Whether link should be in same category. 1338 * @param string $excluded_categories Optional. Excluded categoriesIDs.1345 * @param string $excluded_categories Optional. Comma-separated list of excluded category IDs. 1339 1346 */ 1340 1347 function start_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '') { 1341 1348 echo get_boundary_post_rel_link($title, $in_same_cat, $excluded_categories, true); … … 1407 1414 * @param string $format Optional. Link anchor format. 1408 1415 * @param string $link Optional. Link permalink format. 1409 1416 * @param bool $in_same_cat Optional. Whether link should be in same category. 1410 * @param string $excluded_categories Optional. Excluded categoriesIDs.1417 * @param string $excluded_categories Optional. Comma-separated list of excluded category IDs. 1411 1418 */ 1412 1419 function previous_post_link($format='« %link', $link='%title', $in_same_cat = false, $excluded_categories = '') { 1413 1420 adjacent_post_link($format, $link, $in_same_cat, $excluded_categories, true); … … 1421 1428 * @param string $format Optional. Link anchor format. 1422 1429 * @param string $link Optional. Link permalink format. 1423 1430 * @param bool $in_same_cat Optional. Whether link should be in same category. 1424 * @param string $excluded_categories Optional. Excluded categoriesIDs.1431 * @param string $excluded_categories Optional. Comma-separated list of excluded category IDs. 1425 1432 */ 1426 1433 function next_post_link($format='%link »', $link='%title', $in_same_cat = false, $excluded_categories = '') { 1427 1434 adjacent_post_link($format, $link, $in_same_cat, $excluded_categories, false); … … 1437 1444 * @param string $format Link anchor format. 1438 1445 * @param string $link Link permalink format. 1439 1446 * @param bool $in_same_cat Optional. Whether link should be in same category. 1440 * @param string $excluded_categories Optional. Excluded categoriesIDs.1447 * @param string $excluded_categories Optional. Comma-separated list of excluded category IDs. 1441 1448 * @param bool $previous Optional, default is true. Whether display link to previous post. 1442 1449 */ 1443 1450 function adjacent_post_link($format, $link, $in_same_cat = false, $excluded_categories = '', $previous = true) {