diff --git a/wp-includes/post.php b/wp-includes/post.php
index 5eae599..17b5fa5 100644
a
|
b
|
function get_post_types( $args = array(), $output = 'names', $operator = 'and' ) |
908 | 908 | * @return object|WP_Error the registered post type object, or an error object |
909 | 909 | */ |
910 | 910 | function register_post_type($post_type, $args = array()) { |
911 | | global $wp_post_types, $wp_rewrite, $wp; |
| 911 | global $wp_post_types, $wp; |
912 | 912 | |
913 | 913 | if ( !is_array($wp_post_types) ) |
914 | 914 | $wp_post_types = array(); |
… |
… |
function register_post_type($post_type, $args = array()) { |
985 | 985 | $wp->add_query_var($args->query_var); |
986 | 986 | } |
987 | 987 | |
988 | | if ( false !== $args->rewrite && ( is_admin() || '' != get_option('permalink_structure') ) ) { |
| 988 | if ( $args->register_meta_box_cb ) |
| 989 | add_action('add_meta_boxes_' . $post_type, $args->register_meta_box_cb, 10, 1); |
| 990 | |
| 991 | $args->labels = get_post_type_labels( $args ); |
| 992 | $args->label = $args->labels->name; |
| 993 | |
| 994 | $wp_post_types[$post_type] = $args; |
| 995 | |
| 996 | add_action( 'future_' . $post_type, '_future_post_hook', 5, 2 ); |
| 997 | |
| 998 | foreach ( $args->taxonomies as $taxonomy ) { |
| 999 | register_taxonomy_for_object_type( $taxonomy, $post_type ); |
| 1000 | } |
| 1001 | |
| 1002 | return $args; |
| 1003 | } |
| 1004 | |
| 1005 | function _post_type_rewrite_rules() { |
| 1006 | global $wp_rewrite; |
| 1007 | |
| 1008 | if ( '' == get_option('permalink_structure') ) |
| 1009 | return; |
| 1010 | |
| 1011 | foreach ( get_post_types( array( 'rewrite' => false ), 'objects', 'not' ) as $post_type => $args ) { |
989 | 1012 | if ( ! is_array( $args->rewrite ) ) |
990 | 1013 | $args->rewrite = array(); |
991 | 1014 | if ( empty( $args->rewrite['slug'] ) ) |
… |
… |
function register_post_type($post_type, $args = array()) { |
1021 | 1044 | |
1022 | 1045 | $wp_rewrite->add_permastruct($post_type, "{$args->rewrite['slug']}/%$post_type%", $args->rewrite['with_front'], $args->permalink_epmask); |
1023 | 1046 | } |
1024 | | |
1025 | | if ( $args->register_meta_box_cb ) |
1026 | | add_action('add_meta_boxes_' . $post_type, $args->register_meta_box_cb, 10, 1); |
1027 | | |
1028 | | $args->labels = get_post_type_labels( $args ); |
1029 | | $args->label = $args->labels->name; |
1030 | | |
1031 | | $wp_post_types[$post_type] = $args; |
1032 | | |
1033 | | add_action( 'future_' . $post_type, '_future_post_hook', 5, 2 ); |
1034 | | |
1035 | | foreach ( $args->taxonomies as $taxonomy ) { |
1036 | | register_taxonomy_for_object_type( $taxonomy, $post_type ); |
1037 | | } |
1038 | | |
1039 | | return $args; |
1040 | 1047 | } |
| 1048 | add_action( 'pre_flush_rewrite_rules', '_post_type_rewrite_rules', 9 ); |
1041 | 1049 | |
1042 | 1050 | /** |
1043 | 1051 | * Builds an object with all post type capabilities out of a post type object |
diff --git a/wp-includes/rewrite.php b/wp-includes/rewrite.php
index 4502db1..355c0ad 100644
a
|
b
|
class WP_Rewrite { |
1857 | 1857 | * @param bool $hard Whether to update .htaccess (hard flush) or just update rewrite_rules option (soft flush). Default is true (hard). |
1858 | 1858 | */ |
1859 | 1859 | function flush_rules($hard = true) { |
| 1860 | do_action( 'pre_flush_rewrite_rules', $hard ); |
1860 | 1861 | delete_option('rewrite_rules'); |
1861 | 1862 | $this->wp_rewrite_rules(); |
1862 | 1863 | if ( $hard && function_exists('save_mod_rewrite_rules') ) |
diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php
index dee7af8..97e08ed 100644
a
|
b
|
function is_taxonomy_hierarchical($taxonomy) { |
292 | 292 | * @param array|string $args See above description for the two keys values. |
293 | 293 | */ |
294 | 294 | function register_taxonomy( $taxonomy, $object_type, $args = array() ) { |
295 | | global $wp_taxonomies, $wp_rewrite, $wp; |
| 295 | global $wp_taxonomies, $wp; |
296 | 296 | |
297 | 297 | if ( ! is_array($wp_taxonomies) ) |
298 | 298 | $wp_taxonomies = array(); |
… |
… |
function register_taxonomy( $taxonomy, $object_type, $args = array() ) { |
318 | 318 | $wp->add_query_var($args['query_var']); |
319 | 319 | } |
320 | 320 | |
321 | | if ( false !== $args['rewrite'] && '' != get_option('permalink_structure') ) { |
322 | | $args['rewrite'] = wp_parse_args($args['rewrite'], array( |
323 | | 'slug' => sanitize_title_with_dashes($taxonomy), |
324 | | 'with_front' => true, |
325 | | 'hierarchical' => false |
326 | | )); |
327 | | |
328 | | if ( $args['hierarchical'] && $args['rewrite']['hierarchical'] ) |
329 | | $tag = '(.+?)'; |
330 | | else |
331 | | $tag = '([^/]+)'; |
332 | | |
333 | | $wp_rewrite->add_rewrite_tag("%$taxonomy%", $tag, $args['query_var'] ? "{$args['query_var']}=" : "taxonomy=$taxonomy&term="); |
334 | | $wp_rewrite->add_permastruct($taxonomy, "{$args['rewrite']['slug']}/%$taxonomy%", $args['rewrite']['with_front']); |
335 | | } |
336 | | |
337 | 321 | if ( is_null($args['show_ui']) ) |
338 | 322 | $args['show_ui'] = $args['public']; |
339 | 323 | |
… |
… |
function register_taxonomy( $taxonomy, $object_type, $args = array() ) { |
365 | 349 | add_filter('wp_ajax_add-' . $taxonomy, '_wp_ajax_add_hierarchical_term'); |
366 | 350 | } |
367 | 351 | |
| 352 | function _taxonomy_rewrite_rules() { |
| 353 | global $wp_rewrite; |
| 354 | |
| 355 | if ( '' == get_option('permalink_structure') ) |
| 356 | return; |
| 357 | |
| 358 | foreach ( get_taxonomies( array( 'rewrite' => false ), 'objects', 'not' ) as $taxonomy => $args ) { |
| 359 | $args->rewrite = wp_parse_args( $args->rewrite, array( |
| 360 | 'slug' => sanitize_title_with_dashes( $taxonomy ), |
| 361 | 'with_front' => true, |
| 362 | 'hierarchical' => false |
| 363 | ) ); |
| 364 | |
| 365 | if ( $args->hierarchical && $args->rewrite['hierarchical'] ) |
| 366 | $tag = '(.+?)'; |
| 367 | else |
| 368 | $tag = '([^/]+)'; |
| 369 | |
| 370 | $wp_rewrite->add_rewrite_tag( "%$taxonomy%", $tag, $args->query_var ? "{$args->query_var}=" : "taxonomy=$taxonomy&term=" ); |
| 371 | $wp_rewrite->add_permastruct( $taxonomy, $args->rewrite['slug'] . "/%$taxonomy%", $args->rewrite['with_front'] ); |
| 372 | } |
| 373 | } |
| 374 | add_action( 'pre_flush_rewrite_rules', '_taxonomy_rewrite_rules', 9 ); |
| 375 | |
368 | 376 | /** |
369 | 377 | * Builds an object with all taxonomy labels out of a taxonomy object |
370 | 378 | * |