[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-includes/rest-api/fields/ -> class-wp-rest-term-meta-fields.php (source)

   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 term 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 term meta subtype.
  51       *
  52       * @since 4.9.8
  53       *
  54       * @return string Subtype for the meta type, or empty string if no specific subtype.
  55       */
  56  	protected function get_meta_subtype() {
  57          return $this->taxonomy;
  58      }
  59  
  60      /**
  61       * Retrieves the type for register_rest_field().
  62       *
  63       * @since 4.7.0
  64       *
  65       * @return string The REST field type.
  66       */
  67  	public function get_rest_field_type() {
  68          return 'post_tag' === $this->taxonomy ? 'tag' : $this->taxonomy;
  69      }
  70  }


Generated: Fri Mar 29 01:00:02 2024 Cross-referenced by PHPXref 0.7.1