WordPress.org

Make WordPress Core

Ticket #17807: 17807.8.patch

File 17807.8.patch, 22.7 KB (added by ethitter, 4 years ago)
  • src/wp-includes/link-template.php

     
    10911091 * 
    10921092 * @since 1.5.0 
    10931093 * 
    1094  * @param bool $in_same_cat Optional. Whether post should be in a same category. 
    1095  * @param array|string $excluded_categories Optional. Array or comma-separated list of excluded category IDs. 
     1094 * @param bool $in_same_term Optional. Whether post should be in a same taxonomy term. 
     1095 * @param array|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. 
     1096 * @param string $taxonomy Optional, default is category. Taxonomy, if $in_same_term is true. 
    10961097 * @return mixed Post object if successful. Null if global $post is not set. Empty string if no corresponding post exists. 
    10971098 */ 
    1098 function get_previous_post($in_same_cat = false, $excluded_categories = '') { 
    1099         return get_adjacent_post($in_same_cat, $excluded_categories); 
     1099function get_previous_post( $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) { 
     1100        return get_adjacent_post( $in_same_term, $excluded_terms, true, $taxonomy ); 
    11001101} 
    11011102 
    11021103/** 
     
    11041105 * 
    11051106 * @since 1.5.0 
    11061107 * 
    1107  * @param bool $in_same_cat Optional. Whether post should be in a same category. 
    1108  * @param array|string $excluded_categories Optional. Array or comma-separated list of excluded category IDs. 
     1108 * @param bool $in_same_term Optional. Whether post should be in a same taxonomy term. 
     1109 * @param array|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. 
     1110 * @param string $taxonomy Optional, default is category. Taxonomy, if $in_same_term is true. 
    11091111 * @return mixed Post object if successful. Null if global $post is not set. Empty string if no corresponding post exists. 
    11101112 */ 
    1111 function get_next_post($in_same_cat = false, $excluded_categories = '') { 
    1112         return get_adjacent_post($in_same_cat, $excluded_categories, false); 
     1113function get_next_post( $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) { 
     1114        return get_adjacent_post( $in_same_term, $excluded_terms, false, $taxonomy ); 
    11131115} 
    11141116 
    11151117/** 
     
    11191121 * 
    11201122 * @since 2.5.0 
    11211123 * 
    1122  * @param bool $in_same_cat Optional. Whether post should be in a same category. 
    1123  * @param array|string $excluded_categories Optional. Array or comma-separated list of excluded category IDs. 
     1124 * @param bool $in_same_term Optional. Whether post should be in a same taxonomy term. 
     1125 * @param array|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. 
    11241126 * @param bool $previous Optional. Whether to retrieve previous post. 
     1127 * @param string $taxonomy Optional, default is category. Taxonomy, if $in_same_term is true. 
    11251128 * @return mixed Post object if successful. Null if global $post is not set. Empty string if no corresponding post exists. 
    11261129 */ 
    1127 function get_adjacent_post( $in_same_cat = false, $excluded_categories = '', $previous = true ) { 
     1130function get_adjacent_post( $in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category' ) { 
    11281131        global $wpdb; 
    11291132 
    1130         if ( ! $post = get_post() ) 
     1133        if ( ( ! $post = get_post() ) || ! taxonomy_exists( $taxonomy ) ) 
    11311134                return null; 
    11321135 
    11331136        $current_post_date = $post->post_date; 
    11341137 
    11351138        $join = ''; 
    1136         $posts_in_ex_cats_sql = ''; 
    1137         if ( $in_same_cat || ! empty( $excluded_categories ) ) { 
     1139        $posts_in_ex_terms_sql = ''; 
     1140        if ( $in_same_term || ! empty( $excluded_terms ) ) { 
    11381141                $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"; 
    11391142 
    1140                 if ( $in_same_cat ) { 
    1141                         if ( ! is_object_in_taxonomy( $post->post_type, 'category' ) ) 
     1143                if ( $in_same_term ) { 
     1144                        if ( ! is_object_in_taxonomy( $post->post_type, $taxonomy ) ) 
    11421145                                return ''; 
    1143                         $cat_array = wp_get_object_terms($post->ID, 'category', array('fields' => 'ids')); 
    1144                         if ( ! $cat_array || is_wp_error( $cat_array ) ) 
     1146                        $term_array = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) ); 
     1147                        if ( ! $term_array || is_wp_error( $term_array ) ) 
    11451148                                return ''; 
    1146                         $join .= " AND tt.taxonomy = 'category' AND tt.term_id IN (" . implode(',', $cat_array) . ")"; 
     1149                        $join .= $wpdb->prepare( " AND tt.taxonomy = %s AND tt.term_id IN (" . implode( ',', array_map( 'intval', $term_array ) ) . ")", $taxonomy ); 
    11471150                } 
    11481151 
    1149                 $posts_in_ex_cats_sql = "AND tt.taxonomy = 'category'"; 
    1150                 if ( ! empty( $excluded_categories ) ) { 
    1151                         if ( ! is_array( $excluded_categories ) ) { 
    1152                                 // back-compat, $excluded_categories used to be IDs separated by " and " 
    1153                                 if ( strpos( $excluded_categories, ' and ' ) !== false ) { 
    1154                                         _deprecated_argument( __FUNCTION__, '3.3', sprintf( __( 'Use commas instead of %s to separate excluded categories.' ), "'and'" ) ); 
    1155                                         $excluded_categories = explode( ' and ', $excluded_categories ); 
     1152                $posts_in_ex_terms_sql = $wpdb->prepare( "AND tt.taxonomy = %s", $taxonomy ); 
     1153                if ( ! empty( $excluded_terms ) ) { 
     1154                        if ( ! is_array( $excluded_terms ) ) { 
     1155                                // back-compat, $excluded_terms used to be $excluded_terms with IDs separated by " and " 
     1156                                if ( false !== strpos( $excluded_terms, ' and ' ) ) { 
     1157                                        _deprecated_argument( __FUNCTION__, '3.3', sprintf( __( 'Use commas instead of %s to separate excluded terms.' ), "'and'" ) ); 
     1158                                        $excluded_terms = explode( ' and ', $excluded_terms ); 
    11561159                                } else { 
    1157                                         $excluded_categories = explode( ',', $excluded_categories ); 
     1160                                        $excluded_terms = explode( ',', $excluded_terms ); 
    11581161                                } 
    11591162                        } 
    11601163 
    1161                         $excluded_categories = array_map( 'intval', $excluded_categories ); 
     1164                        $excluded_terms = array_map( 'intval', $excluded_terms ); 
    11621165 
    1163                         if ( ! empty( $cat_array ) ) { 
    1164                                 $excluded_categories = array_diff($excluded_categories, $cat_array); 
    1165                                 $posts_in_ex_cats_sql = ''; 
     1166                        if ( ! empty( $term_array ) ) { 
     1167                                $excluded_terms = array_diff( $excluded_terms, $term_array ); 
     1168                                $posts_in_ex_terms_sql = ''; 
    11661169                        } 
    11671170 
    1168                         if ( !empty($excluded_categories) ) { 
    1169                                 $posts_in_ex_cats_sql = " AND tt.taxonomy = 'category' AND tt.term_id NOT IN (" . implode($excluded_categories, ',') . ')'; 
     1171                        if ( ! empty( $excluded_terms ) ) { 
     1172                                $posts_in_ex_terms_sql = $wpdb->prepare( " AND tt.taxonomy = %s AND tt.term_id NOT IN (" . implode( $excluded_terms, ',' ) . ')', $taxonomy ); 
    11701173                        } 
    11711174                } 
    11721175        } 
     
    11751178        $op = $previous ? '<' : '>'; 
    11761179        $order = $previous ? 'DESC' : 'ASC'; 
    11771180 
    1178         $join  = apply_filters( "get_{$adjacent}_post_join", $join, $in_same_cat, $excluded_categories ); 
    1179         $where = apply_filters( "get_{$adjacent}_post_where", $wpdb->prepare("WHERE p.post_date $op %s AND p.post_type = %s AND p.post_status = 'publish' $posts_in_ex_cats_sql", $current_post_date, $post->post_type), $in_same_cat, $excluded_categories ); 
     1181        $join  = apply_filters( "get_{$adjacent}_post_join", $join, $in_same_term, $excluded_terms ); 
     1182        $where = apply_filters( "get_{$adjacent}_post_where", $wpdb->prepare( "WHERE p.post_date $op %s AND p.post_type = %s AND p.post_status = 'publish' $posts_in_ex_terms_sql", $current_post_date, $post->post_type), $in_same_term, $excluded_terms ); 
    11801183        $sort  = apply_filters( "get_{$adjacent}_post_sort", "ORDER BY p.post_date $order LIMIT 1" ); 
    11811184 
    11821185        $query = "SELECT p.ID FROM $wpdb->posts AS p $join $where $sort"; 
    1183         $query_key = 'adjacent_post_' . md5($query); 
    1184         $result = wp_cache_get($query_key, 'counts'); 
     1186        $query_key = 'adjacent_post_' . md5( $query ); 
     1187        $result = wp_cache_get( $query_key, 'counts' ); 
    11851188        if ( false !== $result ) { 
    11861189                if ( $result ) 
    11871190                        $result = get_post( $result ); 
     
    11921195        if ( null === $result ) 
    11931196                $result = ''; 
    11941197 
    1195         wp_cache_set($query_key, $result, 'counts'); 
     1198        wp_cache_set( $query_key, $result, 'counts' ); 
    11961199 
    11971200        if ( $result ) 
    11981201                $result = get_post( $result ); 
     
    12081211 * @since 2.8.0 
    12091212 * 
    12101213 * @param string $title Optional. Link title format. 
    1211  * @param bool $in_same_cat Optional. Whether link should be in a same category. 
    1212  * @param array|string $excluded_categories Optional. Array or comma-separated list of excluded category IDs. 
     1214 * @param bool $in_same_term Optional. Whether link should be in a same taxonomy term. 
     1215 * @param array|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. 
    12131216 * @param bool $previous Optional, default is true. Whether to display link to previous or next post. 
     1217 * @param string $taxonony Options, default is category. Taxonomy, if $in_same_term is true. 
    12141218 * @return string 
    12151219 */ 
    1216 function get_adjacent_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '', $previous = true) { 
     1220function get_adjacent_post_rel_link( $title = '%title', $in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category' ) { 
    12171221        if ( $previous && is_attachment() && $post = get_post() ) 
    12181222                $post = get_post( $post->post_parent ); 
    12191223        else 
    1220                 $post = get_adjacent_post( $in_same_cat, $excluded_categories, $previous ); 
     1224                $post = get_adjacent_post( $in_same_term, $excluded_terms, $previous, $taxonomy ); 
    12211225 
    1222         if ( empty($post) ) 
     1226        if ( empty( $post ) ) 
    12231227                return; 
    12241228 
    12251229        $post_title = the_title_attribute( array( 'echo' => false, 'post' => $post ) ); 
    12261230 
    12271231        if ( empty( $post_title ) ) 
    1228                 $post_title = $previous ? __('Previous Post') : __('Next Post'); 
     1232                $post_title = $previous ? __( 'Previous Post' ) : __( 'Next Post' ); 
    12291233 
    1230         $date = mysql2date(get_option('date_format'), $post->post_date); 
     1234        $date = mysql2date( get_option( 'date_format' ), $post->post_date ); 
    12311235 
    1232         $title = str_replace('%title', $post_title, $title); 
    1233         $title = str_replace('%date', $date, $title); 
     1236        $title = str_replace( '%title', $post_title, $title ); 
     1237        $title = str_replace( '%date', $date, $title ); 
    12341238 
    12351239        $link = $previous ? "<link rel='prev' title='" : "<link rel='next' title='"; 
    12361240        $link .= esc_attr( $title ); 
    1237         $link .= "' href='" . get_permalink($post) . "' />\n"; 
     1241        $link .= "' href='" . get_permalink( $post ) . "' />\n"; 
    12381242 
    12391243        $adjacent = $previous ? 'previous' : 'next'; 
    12401244        return apply_filters( "{$adjacent}_post_rel_link", $link ); 
     
    12461250 * @since 2.8.0 
    12471251 * 
    12481252 * @param string $title Optional. Link title format. 
    1249  * @param bool $in_same_cat Optional. Whether link should be in a same category. 
    1250  * @param array|string $excluded_categories Optional. Array or comma-separated list of excluded category IDs. 
     1253 * @param bool $in_same_term Optional. Whether link should be in a same taxonomy term. 
     1254 * @param array|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. 
     1255 * @param string $taxonomy Optional, default is category. Taxonomy, if $in_same_term is true. 
    12511256 */ 
    1252 function adjacent_posts_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '') { 
    1253         echo get_adjacent_post_rel_link($title, $in_same_cat, $excluded_categories = '', true); 
    1254         echo get_adjacent_post_rel_link($title, $in_same_cat, $excluded_categories = '', false); 
     1257function adjacent_posts_rel_link( $title = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) { 
     1258        echo get_adjacent_post_rel_link( $title, $in_same_term, $excluded_terms = '', true, $taxonomy ); 
     1259        echo get_adjacent_post_rel_link( $title, $in_same_term, $excluded_terms = '', false, $taxonomy ); 
    12551260} 
    12561261 
    12571262/** 
     
    12731278 * @since 2.8.0 
    12741279 * 
    12751280 * @param string $title Optional. Link title format. 
    1276  * @param bool $in_same_cat Optional. Whether link should be in a same category. 
    1277  * @param array|string $excluded_categories Optional. Array or comma-separated list of excluded category IDs. 
     1281 * @param bool $in_same_term Optional. Whether link should be in a same taxonomy term. 
     1282 * @param array|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. 
     1283 * @param string $taxonomy Optional, default is category. Taxonomy, if $in_same_term is true. 
    12781284 */ 
    1279 function next_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '') { 
    1280         echo get_adjacent_post_rel_link($title, $in_same_cat, $excluded_categories = '', false); 
     1285function next_post_rel_link( $title = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) { 
     1286        echo get_adjacent_post_rel_link( $title, $in_same_term, $excluded_terms = '', false, $taxonomy ); 
    12811287} 
    12821288 
    12831289/** 
     
    12851291 * 
    12861292 * @since 2.8.0 
    12871293 * 
    1288  * @param string $title Optional. Link title format. 
    1289  * @param bool $in_same_cat Optional. Whether link should be in a same category. 
    1290  * @param array|string $excluded_categories Optional. Array or comma-separated list of excluded category IDs. 
     1294 * @param string $title (optional) Link title format. 
     1295 * @param bool $in_same_term (optional) Whether link should be in a same taxonomy term. 
     1296 * @param array|string $excluded_terms (optional) Array or comma-separated list of excluded term IDs. 
     1297 * @param string $taxonomy (optional) Default is category. Taxonomy, if $in_same_term is true. 
    12911298 */ 
    1292 function prev_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '') { 
    1293         echo get_adjacent_post_rel_link($title, $in_same_cat, $excluded_categories = '', true); 
     1299function prev_post_rel_link( $title = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) { 
     1300        echo get_adjacent_post_rel_link( $title, $in_same_term, $excluded_terms = '', true, $taxonomy ); 
    12941301} 
    12951302 
    12961303/** 
    12971304 * Retrieve boundary post. 
    12981305 * 
    12991306 * Boundary being either the first or last post by publish date within the constraints specified 
    1300  * by $in_same_cat or $excluded_categories. 
     1307 * by $in_same_term or $excluded_terms. 
    13011308 * 
    13021309 * @since 2.8.0 
    13031310 * 
    1304  * @param bool $in_same_cat Optional. Whether returned post should be in a same category. 
    1305  * @param array|string $excluded_categories Optional. Array or comma-separated list of excluded category IDs. 
    1306  * @param bool $start Optional. Whether to retrieve first or last post. 
     1311 * @param bool $in_same_term (optional) Whether returned post should be in a same taxonomy term. 
     1312 * @param array|string $excluded_terms (optional) Array or comma-separated list of excluded term IDs. 
     1313 * @param bool $start (optional) Whether to retrieve first or last post. 
     1314 * @param $taxonomy (optional) Default is category. Taxonomy, if $in_same_term is true. 
    13071315 * @return object 
    13081316 */ 
    1309 function get_boundary_post( $in_same_cat = false, $excluded_categories = '', $start = true ) { 
     1317function get_boundary_post( $in_same_term = false, $excluded_terms = '', $start = true, $taxonomy = 'category' ) { 
    13101318        $post = get_post(); 
    1311         if ( ! $post || ! is_single() || is_attachment() ) 
     1319        if ( ! $post || ! is_single() || is_attachment() || ! taxonomy_exists( $taxonomy ) ) 
    13121320                return null; 
    13131321 
    1314         $cat_array = array(); 
    1315         if( ! is_array( $excluded_categories ) ) 
    1316                 $excluded_categories = explode( ',', $excluded_categories ); 
     1322        $query_args = array( 
     1323                'posts_per_page' => 1, 
     1324                'order' => $start ? 'ASC' : 'DESC', 
     1325                'update_post_term_cache' => false, 
     1326                'update_post_meta_cache' => false 
     1327        ); 
    13171328 
    1318         if ( $in_same_cat || ! empty( $excluded_categories ) ) { 
    1319                 if ( $in_same_cat ) 
    1320                         $cat_array = wp_get_object_terms( $post->ID, 'category', array( 'fields' => 'ids' ) ); 
     1329        $term_array = array(); 
     1330        if ( ! is_array( $excluded_terms ) ) 
     1331                if ( ! empty( $excluded_terms ) ) 
     1332                        $excluded_terms = explode( ',', $excluded_terms ); 
     1333                else 
     1334                        $excluded_terms = array(); 
    13211335 
    1322                 if ( ! empty( $excluded_categories ) ) { 
    1323                         $excluded_categories = array_map( 'intval', $excluded_categories ); 
    1324                         $excluded_categories = array_diff( $excluded_categories, $cat_array ); 
     1336        if ( $in_same_term || ! empty( $excluded_terms ) ) { 
     1337                if ( $in_same_term ) 
     1338                        $term_array = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) ); 
    13251339 
    1326                         $inverse_cats = array(); 
    1327                         foreach ( $excluded_categories as $excluded_category ) 
    1328                                 $inverse_cats[] = $excluded_category * -1; 
    1329                         $excluded_categories = $inverse_cats; 
     1340                if ( ! empty( $excluded_terms ) ) { 
     1341                        $excluded_terms = array_map( 'intval', $excluded_terms ); 
     1342                        $excluded_terms = array_diff( $excluded_terms, $term_array ); 
     1343 
     1344                        $inverse_terms = array(); 
     1345                        foreach ( $excluded_terms as $excluded_term ) 
     1346                                $inverse_terms[] = $excluded_term * -1; 
     1347                        $excluded_terms = $inverse_terms; 
    13301348                } 
     1349 
     1350                $query_args[ 'tax_query' ] = array( array( 
     1351                        'taxonomy' => $taxonomy, 
     1352                        'terms' => array_merge( $term_array, $excluded_terms ) 
     1353                ) ); 
    13311354        } 
    13321355 
    1333         $categories = implode( ',', array_merge( $cat_array, $excluded_categories ) ); 
    1334  
    1335         $order = $start ? 'ASC' : 'DESC'; 
    1336  
    1337         return get_posts( array('numberposts' => 1, 'category' => $categories, 'order' => $order, 'update_post_term_cache' => false, 'update_post_meta_cache' => false) ); 
     1356        return get_posts( $query_args ); 
    13381357} 
    13391358 
    13401359/* 
     
    13441363 * 
    13451364 * @param string $format Optional. Link anchor format. 
    13461365 * @param string $link Optional. Link permalink format. 
    1347  * @param bool $in_same_cat Optional. Whether link should be in same category. 
    1348  * @param string $excluded_categories Optional. Excluded categories IDs. 
     1366 * @param bool $in_same_term Optional. Whether link should be in a same taxonomy term. 
     1367 * @param array|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. 
     1368 * @param string $taxonomy Optional, default is category. Taxonomy, if $in_same_term is true. 
    13491369 * @return string 
    13501370 */ 
    1351 function get_previous_post_link( $format = '&laquo; %link', $link = '%title', $in_same_cat = false, $excluded_categories = '' ) { 
    1352         return get_adjacent_post_link( $format, $link, $in_same_cat, $excluded_categories, true ); 
     1371function get_previous_post_link( $format = '&laquo; %link', $link = '%title', $in_same_cat = false, $excluded_terms = '', $taxonomy = 'category' ) { 
     1372        return get_adjacent_post_link( $format, $link, $in_same_cat, $excluded_terms, true, $taxonomy ); 
    13531373} 
    13541374 
    13551375/** 
     
    13611381 * @param string $format Optional. Link anchor format. 
    13621382 * @param string $link Optional. Link permalink format. 
    13631383 * @param bool $in_same_cat Optional. Whether link should be in a same category. 
    1364  * @param array|string $excluded_categories Optional. Array or comma-separated list of excluded category IDs. 
     1384 * @param bool $in_same_term Optional. Whether link should be in a same taxonomy term. 
     1385 * @param array|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. 
     1386 * @param string $taxonomy Optional, default is category. Taxonomy, if $in_same_term is true. 
    13651387 */ 
    1366 function previous_post_link( $format = '&laquo; %link', $link = '%title', $in_same_cat = false, $excluded_categories = '' ) { 
    1367         echo get_previous_post_link( $format, $link, $in_same_cat, $excluded_categories ); 
     1388function previous_post_link( $format = '&laquo; %link', $link = '%title', $in_same_cat = false, $excluded_terms = '', $taxonomy = 'category' ) { 
     1389        echo get_previous_post_link( $format, $link, $in_same_cat, $excluded_terms, $taxonomy ); 
    13681390} 
    13691391 
    13701392/** 
     
    13751397 * 
    13761398 * @param string $format Optional. Link anchor format. 
    13771399 * @param string $link Optional. Link permalink format. 
    1378  * @param bool $in_same_cat Optional. Whether link should be in same category. 
    1379  * @param string $excluded_categories Optional. Excluded categories IDs. 
     1400 * @param bool $in_same_term Optional. Whether link should be in a same taxonomy term. 
     1401 * @param array|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. 
     1402 * @param string $taxonomy Optional, default is category. Taxonomy, if $in_same_term is true. 
    13801403 * @return string 
    13811404 */ 
    1382 function get_next_post_link( $format = '&laquo; %link', $link = '%title', $in_same_cat = false, $excluded_categories = '' ) { 
    1383         return get_adjacent_post_link( $format, $link, $in_same_cat, $excluded_categories, false ); 
     1405function get_next_post_link( $format = '&laquo; %link', $link = '%title', $in_same_cat = false, $excluded_terms = '', $taxonomy = 'category' ) { 
     1406        return get_adjacent_post_link( $format, $link, $in_same_cat, $excluded_terms, false, $taxonomy ); 
    13841407} 
    13851408 
    13861409/** 
     
    13911414 * @param string $format Optional. Link anchor format. 
    13921415 * @param string $link Optional. Link permalink format. 
    13931416 * @param bool $in_same_cat Optional. Whether link should be in a same category. 
    1394  * @param array|string $excluded_categories Optional. Array or comma-separated list of excluded category IDs. 
     1417 * @param bool $in_same_term Optional. Whether link should be in a same taxonomy term. 
     1418 * @param array|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. 
     1419 * @param string $taxonomy Optional, default is category. Taxonomy, if $in_same_term is true. 
    13951420 */ 
    1396 function next_post_link( $format = '%link &raquo;', $link = '%title', $in_same_cat = false, $excluded_categories = '' ) { 
    1397          echo get_next_post_link( $format, $link, $in_same_cat, $excluded_categories ); 
     1421function next_post_link( $format = '%link &raquo;', $link = '%title', $in_same_cat = false, $excluded_terms = '', $taxonomy = 'category' ) { 
     1422         echo get_next_post_link( $format, $link, $in_same_cat, $excluded_terms, $taxonomy ); 
    13981423} 
    13991424 
    14001425/** 
     
    14071432 * @param string $format Link anchor format. 
    14081433 * @param string $link Link permalink format. 
    14091434 * @param bool $in_same_cat Optional. Whether link should be in a same category. 
    1410  * @param array|string $excluded_categories Optional. Array or comma-separated list of excluded category IDs. 
     1435 * @param bool $in_same_term (optional) Whether link should be in a same taxonomy term. 
     1436 * @param array|string $excluded_terms (optional) Array or comma-separated list of excluded terms IDs. 
    14111437 * @param bool $previous Optional, default is true. Whether to display link to previous or next post. 
     1438 * @param string $taxonomy (optional) Default is category. Taxonomy, if $in_same_term is true. 
    14121439 * @return string 
    14131440 */ 
    1414 function get_adjacent_post_link( $format, $link, $in_same_cat = false, $excluded_categories = '', $previous = true ) { 
     1441function get_adjacent_post_link( $format, $link, $in_same_cat = false, $excluded_terms = '', $previous = true, $taxonomy = 'category' ) { 
    14151442        if ( $previous && is_attachment() ) 
    14161443                $post = get_post( get_post()->post_parent ); 
    14171444        else 
    1418                 $post = get_adjacent_post( $in_same_cat, $excluded_categories, $previous ); 
     1445                $post = get_adjacent_post( $in_same_cat, $excluded_terms, $previous, $taxonomy ); 
    14191446 
    14201447        if ( ! $post ) { 
    14211448                $output = ''; 
     
    14541481 * @param string $format Link anchor format. 
    14551482 * @param string $link Link permalink format. 
    14561483 * @param bool $in_same_cat Optional. Whether link should be in a same category. 
    1457  * @param array|string $excluded_categories Optional. Array or comma-separated list of excluded category IDs. 
     1484 * @param array|string $excluded_terms Optional. Array or comma-separated list of excluded category IDs. 
    14581485 * @param bool $previous Optional, default is true. Whether to display link to previous or next post. 
    14591486 * @return string 
    14601487 */ 
    1461 function adjacent_post_link( $format, $link, $in_same_cat = false, $excluded_categories = '', $previous = true ) { 
    1462         echo get_adjacent_post_link( $format, $link, $in_same_cat, $excluded_categories, $previous ); 
     1488function adjacent_post_link( $format, $link, $in_same_cat = false, $excluded_terms = '', $previous = true ) { 
     1489        echo get_adjacent_post_link( $format, $link, $in_same_cat, $excluded_terms, $previous ); 
    14631490} 
    14641491 
    14651492/**