[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

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

   1  <?php
   2  /**
   3   * REST API: WP_REST_Post_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 posts via the REST API.
  12   *
  13   * @since 4.7.0
  14   *
  15   * @see WP_REST_Meta_Fields
  16   */
  17  class WP_REST_Post_Meta_Fields extends WP_REST_Meta_Fields {
  18  
  19      /**
  20       * Post type to register fields for.
  21       *
  22       * @since 4.7.0
  23       * @var string
  24       */
  25      protected $post_type;
  26  
  27      /**
  28       * Constructor.
  29       *
  30       * @since 4.7.0
  31       *
  32       * @param string $post_type Post type to register fields for.
  33       */
  34  	public function __construct( $post_type ) {
  35          $this->post_type = $post_type;
  36      }
  37  
  38      /**
  39       * Retrieves the post meta type.
  40       *
  41       * @since 4.7.0
  42       *
  43       * @return string The meta type.
  44       */
  45  	protected function get_meta_type() {
  46          return 'post';
  47      }
  48  
  49      /**
  50       * Retrieves the post 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->post_type;
  58      }
  59  
  60      /**
  61       * Retrieves the type for register_rest_field().
  62       *
  63       * @since 4.7.0
  64       *
  65       * @see register_rest_field()
  66       *
  67       * @return string The REST field type.
  68       */
  69  	public function get_rest_field_type() {
  70          return $this->post_type;
  71      }
  72  }


Generated: Sun Nov 24 01:00:02 2024 Cross-referenced by PHPXref 0.7.1