Ticket #15378: 15378.2.diff
File 15378.2.diff, 4.9 KB (added by , 14 years ago) |
---|
-
wp-includes/taxonomy.php
19 19 'hierarchical' => true, 20 20 'update_count_callback' => '_update_post_term_count', 21 21 'query_var' => 'category_name', 22 'rewrite' => array(22 'rewrite' => did_action( 'init' ) ? array( 23 23 'hierarchical' => true, 24 24 'slug' => get_option('category_base') ? get_option('category_base') : 'category', 25 'with_front' => false) ,25 'with_front' => false) : false, 26 26 'public' => true, 27 27 'show_ui' => true, 28 28 '_builtin' => true, … … 32 32 'hierarchical' => false, 33 33 'update_count_callback' => '_update_post_term_count', 34 34 'query_var' => 'tag', 35 'rewrite' => array(36 'slug' => get_option('tag_base') ? get_option('tag_base') : 'tag' 37 'with_front' => false) ,35 'rewrite' => did_action( 'init' ) ? array( 36 'slug' => get_option('tag_base') ? get_option('tag_base') : 'tag', 37 'with_front' => false) : false, 38 38 'public' => true, 39 39 'show_ui' => true, 40 40 '_builtin' => true, … … 52 52 'show_ui' => false, 53 53 '_builtin' => true, 54 54 'show_in_nav_menus' => false, 55 ) ) 55 ) ); 56 56 57 57 register_taxonomy( 'link_category', 'link', array( 58 58 'hierarchical' => false, … … 75 75 'public' => false, 76 76 'show_ui' => false, 77 77 '_builtin' => true, 78 ) ) 78 ) ); 79 79 80 $rewrite = false; 81 if ( did_action( 'init' ) && current_theme_supports( 'post-formats' ) ) { 82 $rewrite = apply_filters( 'post_format_rewrite_base', 'type' ); 83 $rewrite = $rewrite ? array( 'slug' => $rewrite ) : false; 84 } 85 80 86 register_taxonomy( 'post_format', 'post', array( 81 'public' => false,87 'public' => true, 82 88 'hierarchical' => false, 83 89 'labels' => array( 84 90 'name' => '', 85 91 'singular_name' => '', 86 92 ), 87 'query_var' => false,88 'rewrite' => false,93 'query_var' => 'post_format', 94 'rewrite' => $rewrite, 89 95 'show_ui' => false, 90 96 '_builtin' => true, 91 97 'show_in_nav_menus' => false, 92 ) ) 98 ) ); 93 99 } 94 100 add_action( 'init', 'create_initial_taxonomies', 0 ); // highest priority 95 101 … … 310 316 $wp->add_query_var($args['query_var']); 311 317 } 312 318 313 if ( false !== $args['rewrite'] && '' != get_option('permalink_structure') && !empty($wp_rewrite)) {319 if ( false !== $args['rewrite'] && '' != get_option('permalink_structure') ) { 314 320 $args['rewrite'] = wp_parse_args($args['rewrite'], array( 315 321 'slug' => sanitize_title_with_dashes($taxonomy), 316 322 'with_front' => true, -
wp-includes/post.php
5058 5058 return $strings; 5059 5059 } 5060 5060 5061 function get_post_format_slugs() { 5062 $slugs = array( 5063 'default' => _x( 'default', 'Post format slug' ), 5064 'aside' => _x( 'aside', 'Post format slug' ), 5065 'chat' => _x( 'chat', 'Post format slug' ), 5066 'gallery' => _x( 'gallery', 'Post format slug' ), 5067 'link' => _x( 'link', 'Post format slug' ), 5068 'image' => _x( 'image', 'Post format slug' ), 5069 'quote' => _x( 'quote', 'Post format slug' ), 5070 'status' => _x( 'status', 'Post format slug' ), 5071 'video' => _x( 'video', 'Post format slug' ), 5072 'audio' => _x( 'audio', 'Post format slug' ), 5073 ); 5074 $slugs = array_map( 'sanitize_title_with_dashes', $slugs ); 5075 return $slugs; 5076 } 5077 5061 5078 /** 5062 5079 * Returns a pretty, translated version of a post format slug 5063 5080 * … … 5096 5113 return false; 5097 5114 } 5098 5115 5116 /** 5117 * Returns a link to a post format index. 5118 * 5119 * @since 3.1.0 5120 * 5121 * @param $format string Post format 5122 * @return string Link 5123 */ 5124 function get_post_format_link( $format ) { 5125 $term = get_term_by('slug', 'post-format-' . $format, 'post_format' ); 5126 if ( ! $term || is_wp_error( $term ) ) 5127 return false; 5128 return get_term_link( $term ); 5129 } 5130 5131 /** 5132 * Filters the request to allow for the format prefix. 5133 * 5134 * @access private 5135 * @since 3.1.0 5136 */ 5137 function _post_format_request( $qvs ) { 5138 if ( ! isset( $qvs['post_format'] ) ) 5139 return $qvs; 5140 $slugs = array_flip( get_post_format_slugs() ); 5141 if ( isset( $slugs[ $qvs['post_format'] ] ) ) 5142 $qvs['post_format'] = 'post-format-' . $slugs[ $qvs['post_format'] ]; 5143 return $qvs; 5144 } 5145 add_filter( 'request', '_post_format_request' ); 5146 5147 /** 5148 * Filters the post format term link to remove the format prefix. 5149 * 5150 * @access private 5151 * @since 3.1.0 5152 */ 5153 function _post_format_link( $link, $term, $taxonomy ) { 5154 global $wp_rewrite; 5155 if ( 'post_format' != $taxonomy ) 5156 return $link; 5157 $slugs = get_post_format_slugs(); 5158 if ( $wp_rewrite->get_extra_permastruct( $taxonomy ) ) { 5159 return str_replace( "/{$term->slug}", '/' . $slugs[ str_replace( 'post-format-', '', $term->slug ) ], $link ); 5160 } else { 5161 $link = remove_query_arg( 'format', $link ); 5162 return add_query_arg( 'format', str_replace( 'post-format-', $term->slug ), $link ); 5163 } 5164 } 5165 add_filter( 'term_link', '_post_format_link', 10, 3 ); 5166 5099 5167 ?>