home *** CD-ROM | disk | FTP | other *** search
/ HTML Examples / WP.iso / wordpress / wp-includes / rest-api / fields / class-wp-rest-term-meta-fields.php < prev    next >
Encoding:
PHP Script  |  2017-07-26  |  1014 b   |  60 lines

  1. <?php
  2. /**
  3.  * REST API: WP_REST_Term_Meta_Fields class
  4.  *
  5.  * @package WordPress
  6.  * @subpackage REST_API
  7.  * @since 4.7.0
  8.  */
  9.  
  10. /**
  11.  * Core class used to manage meta values for terms via the REST API.
  12.  *
  13.  * @since 4.7.0
  14.  *
  15.  * @see WP_REST_Meta_Fields
  16.  */
  17. class WP_REST_Term_Meta_Fields extends WP_REST_Meta_Fields {
  18.  
  19.     /**
  20.      * Taxonomy to register fields for.
  21.      *
  22.      * @since 4.7.0
  23.      * @var string
  24.      */
  25.     protected $taxonomy;
  26.  
  27.     /**
  28.      * Constructor.
  29.      *
  30.      * @since 4.7.0
  31.      *
  32.      * @param string $taxonomy Taxonomy to register fields for.
  33.      */
  34.     public function __construct( $taxonomy ) {
  35.         $this->taxonomy = $taxonomy;
  36.     }
  37.  
  38.     /**
  39.      * Retrieves the object meta type.
  40.      *
  41.      * @since 4.7.0
  42.      *
  43.      * @return string The meta type.
  44.      */
  45.     protected function get_meta_type() {
  46.         return 'term';
  47.     }
  48.  
  49.     /**
  50.      * Retrieves the type for register_rest_field().
  51.      *
  52.      * @since 4.7.0
  53.      *
  54.      * @return string The REST field type.
  55.      */
  56.     public function get_rest_field_type() {
  57.         return 'post_tag' === $this->taxonomy ? 'tag' : $this->taxonomy;
  58.     }
  59. }
  60.