Make WordPress Core

Ticket #18752: 18752.2.diff

File 18752.2.diff, 2.4 KB (added by aaroncampbell, 14 years ago)
  • wp-includes/default-filters.php

     
    196196add_filter( 'nav_menu_meta_box_object', '_wp_nav_menu_meta_box_object'        );
    197197add_filter( 'widget_text',              'shortcode_unautop'                   );
    198198add_filter( 'widget_text',              'do_shortcode'                        );
     199add_filter( 'post_link_categories',     '_sort_terms_by_id'                   );
    199200
    200201// Actions
    201202add_action( 'wp_head',             'wp_enqueue_scripts',              1     );
  • wp-includes/link-template.php

     
    121121                if ( strpos($permalink, '%category%') !== false ) {
    122122                        $cats = get_the_category($post->ID);
    123123                        if ( $cats ) {
    124                                 usort($cats, '_usort_terms_by_ID'); // order by ID
     124                                $cats = apply_filters( 'post_link_categories', $cats );
    125125                                $category = $cats[0]->slug;
    126126                                if ( $parent = $cats[0]->parent )
    127127                                        $category = get_category_parents($parent, false, '/', true) . $category;
     
    11281128                        }
    11291129
    11301130                        $excluded_categories = array_map( 'intval', $excluded_categories );
    1131                                
     1131
    11321132                        if ( ! empty( $cat_array ) ) {
    11331133                                $excluded_categories = array_diff($excluded_categories, $cat_array);
    11341134                                $posts_in_ex_cats_sql = '';
     
    12761276        $cat_array = array();
    12771277        if( ! is_array( $excluded_categories ) )
    12781278                $excluded_categories = explode( ',', $excluded_categories );
    1279                
     1279
    12801280        if ( $in_same_cat || ! empty( $excluded_categories ) ) {
    12811281                if ( $in_same_cat )
    12821282                        $cat_array = wp_get_object_terms( $post->ID, 'category', array( 'fields' => 'ids' ) );
  • wp-includes/category-template.php

     
    126126}
    127127
    128128/**
     129 * Sort terms by ID.
     130 *
     131 * Used with the post_link_categories filter.
     132 *
     133 * @since 3.3.0
     134 * @access private
     135 *
     136 * @param array $terms
     137 *
     138 * @return array Sorted terms
     139 */
     140function _sort_terms_by_id ( $terms ) {
     141        usort( $terms, '_usort_terms_by_ID' );
     142        return $terms;
     143}
     144
     145/**
    129146 * Retrieve category name based on category ID.
    130147 *
    131148 * @since 0.71