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

  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 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 'post';
  47.     }
  48.  
  49.     /**
  50.      * Retrieves the type for register_rest_field().
  51.      *
  52.      * @since 4.7.0
  53.      *
  54.      * @see register_rest_field()
  55.      *
  56.      * @return string The REST field type.
  57.      */
  58.     public function get_rest_field_type() {
  59.         return $this->post_type;
  60.     }
  61. }
  62.