Ticket #36224: 36224.5.diff
File 36224.5.diff, 22.0 KB (added by , 9 years ago) |
---|
-
src/wp-admin/includes/ajax-actions.php
diff --git src/wp-admin/includes/ajax-actions.php src/wp-admin/includes/ajax-actions.php index f3799b4..35edf54 100644
function wp_ajax_ajax_tag_search() { 134 134 * 135 135 * @since 4.0.0 136 136 * 137 * @param int $characters The minimum number of characters required. Default 2.138 * @param object$tax The taxonomy object.139 * @param string $s The search term.137 * @param int $characters The minimum number of characters required. Default 2. 138 * @param WP_Taxonomy $tax The taxonomy object. 139 * @param string $s The search term. 140 140 */ 141 141 $term_search_min_chars = (int) apply_filters( 'term_search_min_chars', 2, $tax, $s ); 142 142 -
new file src/wp-includes/class-wp-taxonomy.php
diff --git src/wp-includes/class-wp-taxonomy.php src/wp-includes/class-wp-taxonomy.php new file mode 100644 index 0000000..bc2c1b6
- + 1 <?php 2 /** 3 * Taxonomy API: WP_Taxonomy class 4 * 5 * @package WordPress 6 * @subpackage Taxonomy 7 * @since 4.7.0 8 */ 9 10 /** 11 * Core class used for interacting with taxonomies. 12 * 13 * @since 4.7.0 14 */ 15 final class WP_Taxonomy { 16 /** 17 * Taxonomy key. 18 * 19 * @since 4.7.0 20 * @access public 21 * @var string 22 */ 23 public $name; 24 25 /** 26 * Name of the taxonomy shown in the menu. Usually plural. 27 * 28 * @since 4.7.0 29 * @access public 30 * @var string 31 */ 32 public $label; 33 34 /** 35 * An array of labels for this taxonomy. 36 * 37 * @since 4.7.0 38 * @access public 39 * @var array 40 */ 41 public $labels = array(); 42 43 /** 44 * A short descriptive summary of what the taxonomy is for. 45 * 46 * @since 4.7.0 47 * @access public 48 * @var string 49 */ 50 public $description = ''; 51 52 /** 53 * Whether a taxonomy is intended for use publicly either via the admin interface or by front-end users. 54 * 55 * @since 4.7.0 56 * @access public 57 * @var bool 58 */ 59 public $public = true; 60 61 /** 62 * Whether the taxonomy is publicly queryable. 63 * 64 * @since 4.7.0 65 * @access public 66 * @var bool 67 */ 68 public $publicly_queryable = true; 69 70 /** 71 * Whether the taxonomy is hierarchical. 72 * 73 * @since 4.7.0 74 * @access public 75 * @var bool 76 */ 77 public $hierarchical = false; 78 79 /** 80 * Whether to generate and allow a UI for managing terms in this taxonomy in the admin. 81 * 82 * @since 4.7.0 83 * @access public 84 * @var bool 85 */ 86 public $show_ui = true; 87 88 /** 89 * Whether to show the taxonomy in the admin menu. 90 * 91 * If true, the taxonomy is shown as a submenu of the object type menu. If false, no menu is shown. 92 * 93 * @since 4.7.0 94 * @access public 95 * @var bool 96 */ 97 public $show_in_menu = true; 98 99 /** 100 * Whether the taxonomy is available for selection in navigation menus. 101 * 102 * @since 4.7.0 103 * @access public 104 * @var bool 105 */ 106 public $show_in_nav_menus = true; 107 108 /** 109 * Whether to list the taxonomy in the tag cloud widget controls. 110 * 111 * @since 4.7.0 112 * @access public 113 * @var bool 114 */ 115 public $show_tagcloud = true; 116 117 /** 118 * Whether to show the taxonomy in the quick/bulk edit panel. 119 * 120 * @since 4.7.0 121 * @access public 122 * @var bool 123 */ 124 public $show_in_quick_edit = true; 125 126 /** 127 * Whether to display a column for the taxonomy on its post type listing screens. 128 * 129 * @since 4.7.0 130 * @access public 131 * @var bool 132 */ 133 public $show_admin_column = false; 134 135 /** 136 * The callback function for the meta box display. 137 * 138 * @since 4.7.0 139 * @access public 140 * @var bool|callable 141 */ 142 public $meta_box_cb = null; 143 144 /** 145 * An array of object types this taxonomy is registered for. 146 * 147 * @since 4.7.0 148 * @access public 149 * @var array 150 */ 151 public $object_type = null; 152 153 /** 154 * Capabilities for this taxonomy. 155 * 156 * @since 4.7.0 157 * @access public 158 * @var array 159 */ 160 public $cap; 161 162 /** 163 * Rewrites information for this taxonomy. 164 * 165 * @since 4.7.0 166 * @access public 167 * @var array|false 168 */ 169 public $rewrite; 170 171 /** 172 * Query var string for this taxonomy. 173 * 174 * @since 4.7.0 175 * @access public 176 * @var string|false 177 */ 178 public $query_var; 179 180 /** 181 * Function that will be called when the count is updated. 182 * 183 * @since 4.7.0 184 * @access public 185 * @var callable 186 */ 187 public $update_count_callback; 188 189 /** 190 * Whether it is a built-in taxonomy. 191 * 192 * @since 4.7.0 193 * @access public 194 * @var bool 195 */ 196 public $_builtin; 197 198 /** 199 * Constructor. 200 * 201 * @since 4.7.0 202 * @access public 203 * 204 * @global WP $wp WP instance. 205 * 206 * @param string $taxonomy Taxonomy key, must not exceed 32 characters. 207 * @param array|string $object_type Name of the object type for the taxonomy object. 208 * @param array|string $args Optional. Array or query string of arguments for registering a taxonomy. 209 * Default empty array. 210 */ 211 public function __construct( $taxonomy, $object_type, $args = array() ) { 212 $this->name = $taxonomy; 213 214 $this->set_props( $object_type, $args ); 215 } 216 217 /** 218 * Sets taxonomy properties. 219 * 220 * @since 4.7.0 221 * @access public 222 * 223 * @param array|string $object_type Name of the object type for the taxonomy object. 224 * @param array|string $args Array or query string of arguments for registering a taxonomy. 225 */ 226 public function set_props( $object_type, $args ) { 227 $args = wp_parse_args( $args ); 228 229 /** 230 * Filters the arguments for registering a taxonomy. 231 * 232 * @since 4.4.0 233 * 234 * @param array $args Array of arguments for registering a taxonomy. 235 * @param string $taxonomy Taxonomy key. 236 * @param array $object_type Array of names of object types for the taxonomy. 237 */ 238 $args = apply_filters( 'register_taxonomy_args', $args, $this->name, (array) $object_type ); 239 240 $defaults = array( 241 'labels' => array(), 242 'description' => '', 243 'public' => true, 244 'publicly_queryable' => null, 245 'hierarchical' => false, 246 'show_ui' => null, 247 'show_in_menu' => null, 248 'show_in_nav_menus' => null, 249 'show_tagcloud' => null, 250 'show_in_quick_edit' => null, 251 'show_admin_column' => false, 252 'meta_box_cb' => null, 253 'capabilities' => array(), 254 'rewrite' => true, 255 'query_var' => $this->name, 256 'update_count_callback' => '', 257 '_builtin' => false, 258 ); 259 260 $args = array_merge( $defaults, $args ); 261 262 // If not set, default to the setting for public. 263 if ( null === $args['publicly_queryable'] ) { 264 $args['publicly_queryable'] = $args['public']; 265 } 266 267 if ( false !== $args['query_var'] && ( is_admin() || false !== $args['publicly_queryable'] ) ) { 268 if ( true === $args['query_var'] ) { 269 $args['query_var'] = $this->name; 270 } else { 271 $args['query_var'] = sanitize_title_with_dashes( $args['query_var'] ); 272 } 273 } else { 274 // Force query_var to false for non-public taxonomies. 275 $args['query_var'] = false; 276 } 277 278 if ( false !== $args['rewrite'] && ( is_admin() || '' != get_option( 'permalink_structure' ) ) ) { 279 $args['rewrite'] = wp_parse_args( $args['rewrite'], array( 280 'with_front' => true, 281 'hierarchical' => false, 282 'ep_mask' => EP_NONE, 283 ) ); 284 285 if ( empty( $args['rewrite']['slug'] ) ) { 286 $args['rewrite']['slug'] = sanitize_title_with_dashes( $this->name ); 287 } 288 } 289 290 // If not set, default to the setting for public. 291 if ( null === $args['show_ui'] ) { 292 $args['show_ui'] = $args['public']; 293 } 294 295 // If not set, default to the setting for show_ui. 296 if ( null === $args['show_in_menu'] || ! $args['show_ui'] ) { 297 $args['show_in_menu'] = $args['show_ui']; 298 } 299 300 // If not set, default to the setting for public. 301 if ( null === $args['show_in_nav_menus'] ) { 302 $args['show_in_nav_menus'] = $args['public']; 303 } 304 305 // If not set, default to the setting for show_ui. 306 if ( null === $args['show_tagcloud'] ) { 307 $args['show_tagcloud'] = $args['show_ui']; 308 } 309 310 // If not set, default to the setting for show_ui. 311 if ( null === $args['show_in_quick_edit'] ) { 312 $args['show_in_quick_edit'] = $args['show_ui']; 313 } 314 315 $default_caps = array( 316 'manage_terms' => 'manage_categories', 317 'edit_terms' => 'manage_categories', 318 'delete_terms' => 'manage_categories', 319 'assign_terms' => 'edit_posts', 320 ); 321 322 $args['cap'] = (object) array_merge( $default_caps, $args['capabilities'] ); 323 unset( $args['capabilities'] ); 324 325 $args['object_type'] = array_unique( (array) $object_type ); 326 327 // If not set, use the default meta box 328 if ( null === $args['meta_box_cb'] ) { 329 if ( $args['hierarchical'] ) { 330 $args['meta_box_cb'] = 'post_categories_meta_box'; 331 } else { 332 $args['meta_box_cb'] = 'post_tags_meta_box'; 333 } 334 } 335 336 foreach ( $args as $property_name => $property_value ) { 337 $this->$property_name = $property_value; 338 } 339 340 $this->labels = get_taxonomy_labels( $this ); 341 $this->label = $this->labels->name; 342 } 343 344 /** 345 * Adds the necessary rewrite rules for the taxonomy. 346 * 347 * @since 4.7.0 348 * @access public 349 * 350 * @global WP $wp Current WordPress environment instance. 351 */ 352 public function add_rewrite_rules() { 353 /* @var WP $wp */ 354 global $wp; 355 356 // Non-publicly queryable taxonomies should not register query vars, except in the admin. 357 if ( false !== $this->query_var && $wp ) { 358 $wp->add_query_var( $this->query_var ); 359 } 360 361 if ( false !== $this->rewrite && ( is_admin() || '' != get_option( 'permalink_structure' ) ) ) { 362 if ( $this->hierarchical && $this->rewrite['hierarchical'] ) { 363 $tag = '(.+?)'; 364 } else { 365 $tag = '([^/]+)'; 366 } 367 368 add_rewrite_tag( "%$this->name%", $tag, $this->query_var ? "{$this->query_var}=" : "taxonomy=$this->name&term=" ); 369 add_permastruct( $this->name, "{$this->rewrite['slug']}/%$this->name%", $this->rewrite ); 370 } 371 } 372 373 /** 374 * Removes any rewrite rules, permastructs, and rules for the taxonomy. 375 * 376 * @since 4.7.0 377 * @access public 378 * 379 * @global WP $wp Current WordPress environment instance. 380 */ 381 public function remove_rewrite_rules() { 382 /* @var WP $wp */ 383 global $wp; 384 385 // Remove query var. 386 if ( false !== $this->query_var ) { 387 $wp->remove_query_var( $this->query_var ); 388 } 389 390 // Remove rewrite tags and permastructs. 391 if ( false !== $this->rewrite ) { 392 remove_rewrite_tag( "%$this->name%" ); 393 remove_permastruct( $this->name ); 394 } 395 } 396 397 /** 398 * Registers the ajax callback for the meta box. 399 * 400 * @since 4.7.0 401 * @access public 402 */ 403 public function add_hooks() { 404 add_filter( 'wp_ajax_add-' . $this->name, '_wp_ajax_add_hierarchical_term' ); 405 } 406 407 /** 408 * Removes the ajax callback for the meta box. 409 * 410 * @since 4.7.0 411 * @access public 412 */ 413 public function remove_hooks() { 414 remove_filter( 'wp_ajax_add-' . $this->name, '_wp_ajax_add_hierarchical_term' ); 415 } 416 } -
src/wp-includes/class-wp-xmlrpc-server.php
diff --git src/wp-includes/class-wp-xmlrpc-server.php src/wp-includes/class-wp-xmlrpc-server.php index 528c74b..861a0e8 100644
class wp_xmlrpc_server extends IXR_Server { 717 717 * 718 718 * @since 3.4.0 719 719 * 720 * @param array $_taxonomy An array of taxonomy data.721 * @param object$taxonomy Taxonomy object.722 * @param array $fields The subset of taxonomy fields to return.720 * @param array $_taxonomy An array of taxonomy data. 721 * @param WP_Taxonomy $taxonomy Taxonomy object. 722 * @param array $fields The subset of taxonomy fields to return. 723 723 */ 724 724 return apply_filters( 'xmlrpc_prepare_taxonomy', $_taxonomy, $taxonomy, $fields ); 725 725 } -
src/wp-includes/taxonomy.php
diff --git src/wp-includes/taxonomy.php src/wp-includes/taxonomy.php index 73b769c..5ea9e72 100644
function get_object_taxonomies( $object, $output = 'names' ) { 223 223 * @global array $wp_taxonomies The registered taxonomies. 224 224 * 225 225 * @param string $taxonomy Name of taxonomy object to return. 226 * @return object|false The Taxonomy Object or false if $taxonomy doesn't exist.226 * @return WP_Taxonomy|false The Taxonomy Object or false if $taxonomy doesn't exist. 227 227 */ 228 228 function get_taxonomy( $taxonomy ) { 229 229 global $wp_taxonomies; … … function is_taxonomy_hierarchical($taxonomy) { 290 290 * @since 4.5.0 Introduced `publicly_queryable` argument. 291 291 * 292 292 * @global array $wp_taxonomies Registered taxonomies. 293 * @global WP $wp WP instance.294 293 * 295 294 * @param string $taxonomy Taxonomy key, must not exceed 32 characters. 296 295 * @param array|string $object_type Object type or array of object types with which the taxonomy should be associated. … … function register_taxonomy( $taxonomy, $object_type, $args = array() ) { 366 365 367 366 $args = wp_parse_args( $args ); 368 367 369 /**370 * Filters the arguments for registering a taxonomy.371 *372 * @since 4.4.0373 *374 * @param array $args Array of arguments for registering a taxonomy.375 * @param string $taxonomy Taxonomy key.376 * @param array $object_type Array of names of object types for the taxonomy.377 */378 $args = apply_filters( 'register_taxonomy_args', $args, $taxonomy, (array) $object_type );379 380 $defaults = array(381 'labels' => array(),382 'description' => '',383 'public' => true,384 'publicly_queryable' => null,385 'hierarchical' => false,386 'show_ui' => null,387 'show_in_menu' => null,388 'show_in_nav_menus' => null,389 'show_tagcloud' => null,390 'show_in_quick_edit' => null,391 'show_admin_column' => false,392 'meta_box_cb' => null,393 'capabilities' => array(),394 'rewrite' => true,395 'query_var' => $taxonomy,396 'update_count_callback' => '',397 '_builtin' => false,398 );399 $args = array_merge( $defaults, $args );400 401 368 if ( empty( $taxonomy ) || strlen( $taxonomy ) > 32 ) { 402 369 _doing_it_wrong( __FUNCTION__, __( 'Taxonomy names must be between 1 and 32 characters in length.' ), '4.2.0' ); 403 370 return new WP_Error( 'taxonomy_length_invalid', __( 'Taxonomy names must be between 1 and 32 characters in length.' ) ); 404 371 } 405 372 406 // If not set, default to the setting for public. 407 if ( null === $args['publicly_queryable'] ) { 408 $args['publicly_queryable'] = $args['public']; 409 } 373 $taxonomy_object = new WP_Taxonomy( $taxonomy, $object_type, $args ); 374 $taxonomy_object->add_rewrite_rules(); 410 375 411 // Non-publicly queryable taxonomies should not register query vars, except in the admin. 412 if ( false !== $args['query_var'] && ( is_admin() || false !== $args['publicly_queryable'] ) && ! empty( $wp ) ) { 413 if ( true === $args['query_var'] ) 414 $args['query_var'] = $taxonomy; 415 else 416 $args['query_var'] = sanitize_title_with_dashes( $args['query_var'] ); 417 $wp->add_query_var( $args['query_var'] ); 418 } else { 419 // Force query_var to false for non-public taxonomies. 420 $args['query_var'] = false; 421 } 422 423 if ( false !== $args['rewrite'] && ( is_admin() || '' != get_option( 'permalink_structure' ) ) ) { 424 $args['rewrite'] = wp_parse_args( $args['rewrite'], array( 425 'with_front' => true, 426 'hierarchical' => false, 427 'ep_mask' => EP_NONE, 428 ) ); 429 430 if ( empty( $args['rewrite']['slug'] ) ) 431 $args['rewrite']['slug'] = sanitize_title_with_dashes( $taxonomy ); 432 433 if ( $args['hierarchical'] && $args['rewrite']['hierarchical'] ) 434 $tag = '(.+?)'; 435 else 436 $tag = '([^/]+)'; 437 438 add_rewrite_tag( "%$taxonomy%", $tag, $args['query_var'] ? "{$args['query_var']}=" : "taxonomy=$taxonomy&term=" ); 439 add_permastruct( $taxonomy, "{$args['rewrite']['slug']}/%$taxonomy%", $args['rewrite'] ); 440 } 376 $wp_taxonomies[ $taxonomy ] = $taxonomy_object; 441 377 442 // If not set, default to the setting for public. 443 if ( null === $args['show_ui'] ) 444 $args['show_ui'] = $args['public']; 378 $taxonomy_object->add_hooks(); 445 379 446 // If not set, default to the setting for show_ui.447 if ( null === $args['show_in_menu' ] || ! $args['show_ui'] )448 $args['show_in_menu' ] = $args['show_ui'];449 450 // If not set, default to the setting for public.451 if ( null === $args['show_in_nav_menus'] )452 $args['show_in_nav_menus'] = $args['public'];453 454 // If not set, default to the setting for show_ui.455 if ( null === $args['show_tagcloud'] )456 $args['show_tagcloud'] = $args['show_ui'];457 458 // If not set, default to the setting for show_ui.459 if ( null === $args['show_in_quick_edit'] ) {460 $args['show_in_quick_edit'] = $args['show_ui'];461 }462 463 $default_caps = array(464 'manage_terms' => 'manage_categories',465 'edit_terms' => 'manage_categories',466 'delete_terms' => 'manage_categories',467 'assign_terms' => 'edit_posts',468 );469 $args['cap'] = (object) array_merge( $default_caps, $args['capabilities'] );470 unset( $args['capabilities'] );471 472 $args['name'] = $taxonomy;473 $args['object_type'] = array_unique( (array) $object_type );474 475 $args['labels'] = get_taxonomy_labels( (object) $args );476 $args['label'] = $args['labels']->name;477 478 // If not set, use the default meta box479 if ( null === $args['meta_box_cb'] ) {480 if ( $args['hierarchical'] )481 $args['meta_box_cb'] = 'post_categories_meta_box';482 else483 $args['meta_box_cb'] = 'post_tags_meta_box';484 }485 486 $wp_taxonomies[ $taxonomy ] = (object) $args;487 488 // Register callback handling for meta box.489 add_filter( 'wp_ajax_add-' . $taxonomy, '_wp_ajax_add_hierarchical_term' );490 380 491 381 /** 492 382 * Fires after a taxonomy is registered. … … function unregister_taxonomy( $taxonomy ) { 518 408 return new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) ); 519 409 } 520 410 521 $taxonomy_ args= get_taxonomy( $taxonomy );411 $taxonomy_object = get_taxonomy( $taxonomy ); 522 412 523 413 // Do not allow unregistering internal taxonomies. 524 if ( $taxonomy_ args->_builtin ) {414 if ( $taxonomy_object->_builtin ) { 525 415 return new WP_Error( 'invalid_taxonomy', __( 'Unregistering a built-in taxonomy is not allowed' ) ); 526 416 } 527 417 528 global $wp, $wp_taxonomies; 529 530 // Remove query var. 531 if ( false !== $taxonomy_args->query_var ) { 532 $wp->remove_query_var( $taxonomy_args->query_var ); 533 } 534 535 // Remove rewrite tags and permastructs. 536 if ( false !== $taxonomy_args->rewrite ) { 537 remove_rewrite_tag( "%$taxonomy%" ); 538 remove_permastruct( $taxonomy ); 539 } 418 global $wp_taxonomies; 540 419 541 // Unregister callback handling for meta box.542 remove_filter( 'wp_ajax_add-' . $taxonomy, '_wp_ajax_add_hierarchical_term');420 $taxonomy_object->remove_rewrite_rules(); 421 $taxonomy_object->remove_hooks(); 543 422 544 423 // Remove the taxonomy. 545 424 unset( $wp_taxonomies[ $taxonomy ] ); … … function unregister_taxonomy( $taxonomy ) { 589 468 * @since 4.3.0 Added the `no_terms` label. 590 469 * @since 4.4.0 Added the `items_list_navigation` and `items_list` labels. 591 470 * 592 * @param object$tax Taxonomy object.471 * @param WP_Taxonomy $tax Taxonomy object. 593 472 * @return object object with all the labels as member variables. 594 473 */ 595 474 function get_taxonomy_labels( $tax ) { -
src/wp-settings.php
diff --git src/wp-settings.php src/wp-settings.php index 80f556c..6ff4ab4 100644
require( ABSPATH . WPINC . '/cron.php' ); 187 187 require( ABSPATH . WPINC . '/deprecated.php' ); 188 188 require( ABSPATH . WPINC . '/script-loader.php' ); 189 189 require( ABSPATH . WPINC . '/taxonomy.php' ); 190 require( ABSPATH . WPINC . '/class-wp-taxonomy.php' ); 190 191 require( ABSPATH . WPINC . '/class-wp-term.php' ); 191 192 require( ABSPATH . WPINC . '/class-wp-term-query.php' ); 192 193 require( ABSPATH . WPINC . '/class-wp-tax-query.php' ); -
new file tests/phpunit/tests/term/wpTaxonomy.php
diff --git tests/phpunit/tests/term/wpTaxonomy.php tests/phpunit/tests/term/wpTaxonomy.php new file mode 100644 index 0000000..377808c
- + 1 <?php 2 3 /** 4 * @group taxonomy 5 */ 6 class Tests_WP_Taxonomy extends WP_UnitTestCase { 7 public function test_instances() { 8 global $wp_taxonomies; 9 10 foreach ( $wp_taxonomies as $taxonomy ) { 11 $this->assertInstanceOf( 'WP_Taxonomy', $taxonomy ); 12 } 13 } 14 15 public function test_does_not_add_query_var_if_not_public() { 16 $this->set_permalink_structure( '/%postname%' ); 17 18 /* @var WP $wp */ 19 global $wp; 20 21 $taxonomy = rand_str(); 22 $taxonomy_object = new WP_Taxonomy( $taxonomy, 'post' ); 23 24 $taxonomy_object->add_rewrite_rules(); 25 $this->assertFalse( in_array( 'foobar', $wp->public_query_vars ) ); 26 } 27 28 public function test_adds_query_var_if_public() { 29 $this->set_permalink_structure( '/%postname%' ); 30 31 /* @var WP $wp */ 32 global $wp; 33 34 $taxonomy = rand_str(); 35 $taxonomy_object = new WP_Taxonomy( $taxonomy, 'post', array( 36 'public' => true, 37 'rewrite' => false, 38 'query_var' => 'foobar', 39 ) ); 40 41 $taxonomy_object->add_rewrite_rules(); 42 $in_array = in_array( 'foobar', $wp->public_query_vars ); 43 44 $taxonomy_object->remove_rewrite_rules(); 45 $in_array_after = in_array( 'foobar', $wp->public_query_vars ); 46 47 $this->assertTrue( $in_array ); 48 $this->assertFalse( $in_array_after ); 49 } 50 51 public function test_adds_rewrite_rules() { 52 $this->set_permalink_structure( '/%postname%' ); 53 54 /* @var WP_Rewrite $wp_rewrite */ 55 global $wp_rewrite; 56 57 $taxonomy = rand_str(); 58 $taxonomy_object = new WP_Taxonomy( $taxonomy, 'post', array( 59 'public' => true, 60 'rewrite' => true, 61 ) ); 62 63 $taxonomy_object->add_rewrite_rules(); 64 $rewrite_tags = $wp_rewrite->rewritecode; 65 66 $taxonomy_object->remove_rewrite_rules(); 67 $rewrite_tags_after = $wp_rewrite->rewritecode; 68 69 $this->assertTrue( false !== array_search( "%$taxonomy%", $rewrite_tags ) ); 70 $this->assertFalse( array_search( "%$taxonomy%", $rewrite_tags_after ) ); 71 } 72 73 public function test_adds_ajax_callback() { 74 $taxonomy = rand_str(); 75 $taxonomy_object = new WP_Taxonomy( $taxonomy, 'post', array( 76 'public' => true, 77 'rewrite' => true, 78 ) ); 79 80 $taxonomy_object->add_hooks(); 81 $has_action = has_action( "wp_ajax_add-$taxonomy", '_wp_ajax_add_hierarchical_term' ); 82 83 $taxonomy_object->remove_hooks(); 84 $has_action_after = has_action( "wp_ajax_add-$taxonomy", '_wp_ajax_add_hierarchical_term' ); 85 86 $this->assertSame( 10, $has_action ); 87 $this->assertFalse( $has_action_after ); 88 89 } 90 }