Changeset 48273 for trunk/src/wp-includes/class-wp-taxonomy.php
- Timestamp:
- 07/02/2020 05:55:04 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-taxonomy.php
r47808 r48273 209 209 */ 210 210 public $rest_controller_class; 211 212 /** 213 * The controller instance for this taxonomy's REST API endpoints. 214 * 215 * Lazily computed. Should be accessed using {@see WP_Taxonomy::get_rest_controller()}. 216 * 217 * @since 5.5.0 218 * @var WP_REST_Controller $rest_controller 219 */ 220 public $rest_controller; 211 221 212 222 /** … … 453 463 remove_filter( 'wp_ajax_add-' . $this->name, '_wp_ajax_add_hierarchical_term' ); 454 464 } 465 466 /** 467 * Gets the REST API controller for this taxonomy. 468 * 469 * Will only instantiate the controller class once per request. 470 * 471 * @since 5.5.0 472 * 473 * @return WP_REST_Controller|null The controller instance, or null if the taxonomy 474 * is set not to show in rest. 475 */ 476 public function get_rest_controller() { 477 if ( ! $this->show_in_rest ) { 478 return null; 479 } 480 481 $class = $this->rest_controller_class ? $this->rest_controller_class : WP_REST_Terms_Controller::class; 482 483 if ( ! class_exists( $class ) ) { 484 return null; 485 } 486 487 if ( ! is_subclass_of( $class, WP_REST_Controller::class ) ) { 488 return null; 489 } 490 491 if ( ! $this->rest_controller ) { 492 $this->rest_controller = new $class( $this->name ); 493 } 494 495 if ( ! ( $this->rest_controller instanceof $class ) ) { 496 return null; 497 } 498 499 return $this->rest_controller; 500 } 455 501 }
Note: See TracChangeset
for help on using the changeset viewer.