Make WordPress Core

Changeset 39462 for trunk


Ignore:
Timestamp:
12/03/2016 04:47:58 AM (8 years ago)
Author:
pento
Message:

Docs: Add missing REST API-related args to register_post_type() and register_taxonomy().

These functions now accept the show_in_rest, rest_base, and rest_controller_class args.

Props ketuchetan, rahulsprajapati.
Fixes #39023.

Location:
trunk/src/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/post.php

    r39411 r39462  
    986986 *              screen and post editing screen.
    987987 * @since 4.6.0 Post type object returned is now an instance of WP_Post_Type.
     988 * @since 4.7.0 Introduced `show_in_rest`, 'rest_base' and 'rest_controller_class'
     989 *              arguments to register the post type in REST API.
    988990 *
    989991 * @global array $wp_post_types List of post types.
     
    995997 *     Array or string of arguments for registering a post type.
    996998 *
    997  *     @type string      $label                Name of the post type shown in the menu. Usually plural.
    998  *                                             Default is value of $labels['name'].
    999  *     @type array       $labels               An array of labels for this post type. If not set, post
    1000  *                                             labels are inherited for non-hierarchical types and page
    1001  *                                             labels for hierarchical ones. See get_post_type_labels() for a full
    1002  *                                             list of supported labels.
    1003  *     @type string      $description          A short descriptive summary of what the post type is.
    1004  *                                             Default empty.
    1005  *     @type bool        $public               Whether a post type is intended for use publicly either via
    1006  *                                             the admin interface or by front-end users. While the default
    1007  *                                             settings of $exclude_from_search, $publicly_queryable, $show_ui,
    1008  *                                             and $show_in_nav_menus are inherited from public, each does not
    1009  *                                             rely on this relationship and controls a very specific intention.
    1010  *                                             Default false.
    1011  *     @type bool        $hierarchical         Whether the post type is hierarchical (e.g. page). Default false.
    1012  *     @type bool        $exclude_from_search  Whether to exclude posts with this post type from front end search
    1013  *                                             results. Default is the opposite value of $public.
    1014  *     @type bool        $publicly_queryable   Whether queries can be performed on the front end for the post type
    1015  *                                             as part of parse_request(). Endpoints would include:
    1016  *                                             * ?post_type={post_type_key}
    1017  *                                             * ?{post_type_key}={single_post_slug}
    1018  *                                             * ?{post_type_query_var}={single_post_slug}
    1019  *                                             If not set, the default is inherited from $public.
    1020  *     @type bool        $show_ui              Whether to generate and allow a UI for managing this post type in the
    1021  *                                             admin. Default is value of $public.
    1022  *     @type bool        $show_in_menu         Where to show the post type in the admin menu. To work, $show_ui
    1023  *                                             must be true. If true, the post type is shown in its own top level
    1024  *                                             menu. If false, no menu is shown. If a string of an existing top
    1025  *                                             level menu (eg. 'tools.php' or 'edit.php?post_type=page'), the post
    1026  *                                             type will be placed as a sub-menu of that.
    1027  *                                             Default is value of $show_ui.
    1028  *     @type bool        $show_in_nav_menus    Makes this post type available for selection in navigation menus.
    1029  *                                             Default is value $public.
    1030  *     @type bool        $show_in_admin_bar    Makes this post type available via the admin bar. Default is value
    1031  *                                             of $show_in_menu.
    1032  *     @type int         $menu_position        The position in the menu order the post type should appear. To work,
    1033  *                                             $show_in_menu must be true. Default null (at the bottom).
    1034  *     @type string      $menu_icon            The url to the icon to be used for this menu. Pass a base64-encoded
    1035  *                                             SVG using a data URI, which will be colored to match the color scheme
    1036  *                                             -- this should begin with 'data:image/svg+xml;base64,'. Pass the name
    1037  *                                             of a Dashicons helper class to use a font icon, e.g.
    1038  *                                             'dashicons-chart-pie'. Pass 'none' to leave div.wp-menu-image empty
    1039  *                                             so an icon can be added via CSS. Defaults to use the posts icon.
    1040  *     @type string      $capability_type      The string to use to build the read, edit, and delete capabilities.
    1041  *                                             May be passed as an array to allow for alternative plurals when using
    1042  *                                             this argument as a base to construct the capabilities, e.g.
    1043  *                                             array('story', 'stories'). Default 'post'.
    1044  *     @type array       $capabilities         Array of capabilities for this post type. $capability_type is used
    1045  *                                             as a base to construct capabilities by default.
    1046  *                                             See get_post_type_capabilities().
    1047  *     @type bool        $map_meta_cap         Whether to use the internal default meta capability handling.
    1048  *                                             Default false.
    1049  *     @type array       $supports             Core feature(s) the post type supports. Serves as an alias for calling
    1050  *                                             add_post_type_support() directly. Core features include 'title',
    1051  *                                             'editor', 'comments', 'revisions', 'trackbacks', 'author', 'excerpt',
    1052  *                                             'page-attributes', 'thumbnail', 'custom-fields', and 'post-formats'.
    1053  *                                             Additionally, the 'revisions' feature dictates whether the post type
    1054  *                                             will store revisions, and the 'comments' feature dictates whether the
    1055  *                                             comments count will show on the edit screen. Defaults is an array
    1056  *                                             containing 'title' and 'editor'.
    1057  *     @type callable    $register_meta_box_cb Provide a callback function that sets up the meta boxes for the
    1058  *                                             edit form. Do remove_meta_box() and add_meta_box() calls in the
    1059  *                                             callback. Default null.
    1060  *     @type array       $taxonomies           An array of taxonomy identifiers that will be registered for the
    1061  *                                             post type. Taxonomies can be registered later with register_taxonomy()
    1062  *                                             or register_taxonomy_for_object_type().
    1063  *                                             Default empty array.
    1064  *     @type bool|string $has_archive          Whether there should be post type archives, or if a string, the
    1065  *                                             archive slug to use. Will generate the proper rewrite rules if
    1066  *                                             $rewrite is enabled. Default false.
     999 *     @type string      $label                 Name of the post type shown in the menu. Usually plural.
     1000 *                                              Default is value of $labels['name'].
     1001 *     @type array       $labels                An array of labels for this post type. If not set, post
     1002 *                                              labels are inherited for non-hierarchical types and page
     1003 *                                              labels for hierarchical ones. See get_post_type_labels() for a full
     1004 *                                              list of supported labels.
     1005 *     @type string      $description           A short descriptive summary of what the post type is.
     1006 *                                              Default empty.
     1007 *     @type bool        $public                Whether a post type is intended for use publicly either via
     1008 *                                              the admin interface or by front-end users. While the default
     1009 *                                              settings of $exclude_from_search, $publicly_queryable, $show_ui,
     1010 *                                              and $show_in_nav_menus are inherited from public, each does not
     1011 *                                              rely on this relationship and controls a very specific intention.
     1012 *                                              Default false.
     1013 *     @type bool        $hierarchical          Whether the post type is hierarchical (e.g. page). Default false.
     1014 *     @type bool        $exclude_from_search   Whether to exclude posts with this post type from front end search
     1015 *                                              results. Default is the opposite value of $public.
     1016 *     @type bool        $publicly_queryable    Whether queries can be performed on the front end for the post type
     1017 *                                              as part of parse_request(). Endpoints would include:
     1018 *                                              * ?post_type={post_type_key}
     1019 *                                              * ?{post_type_key}={single_post_slug}
     1020 *                                              * ?{post_type_query_var}={single_post_slug}
     1021 *                                              If not set, the default is inherited from $public.
     1022 *     @type bool        $show_ui               Whether to generate and allow a UI for managing this post type in the
     1023 *                                              admin. Default is value of $public.
     1024 *     @type bool        $show_in_menu          Where to show the post type in the admin menu. To work, $show_ui
     1025 *                                              must be true. If true, the post type is shown in its own top level
     1026 *                                              menu. If false, no menu is shown. If a string of an existing top
     1027 *                                              level menu (eg. 'tools.php' or 'edit.php?post_type=page'), the post
     1028 *                                              type will be placed as a sub-menu of that.
     1029 *                                              Default is value of $show_ui.
     1030 *     @type bool        $show_in_nav_menus     Makes this post type available for selection in navigation menus.
     1031 *                                              Default is value $public.
     1032 *     @type bool        $show_in_admin_bar     Makes this post type available via the admin bar. Default is value
     1033 *                                              of $show_in_menu.
     1034 *     @type bool        $show_in_rest          Whether to add the post type route in the REST API 'wp/v2' namespace.
     1035 *     @type string      $rest_base             To change the base url of REST API route. Default is $post_type.
     1036 *     @type string      $rest_controller_class REST API Controller class name. Default is 'WP_REST_Posts_Controller'.
     1037 *     @type int         $menu_position         The position in the menu order the post type should appear. To work,
     1038 *                                              $show_in_menu must be true. Default null (at the bottom).
     1039 *     @type string      $menu_icon             The url to the icon to be used for this menu. Pass a base64-encoded
     1040 *                                              SVG using a data URI, which will be colored to match the color scheme
     1041 *                                              -- this should begin with 'data:image/svg+xml;base64,'. Pass the name
     1042 *                                              of a Dashicons helper class to use a font icon, e.g.
     1043 *                                              'dashicons-chart-pie'. Pass 'none' to leave div.wp-menu-image empty
     1044 *                                              so an icon can be added via CSS. Defaults to use the posts icon.
     1045 *     @type string      $capability_type       The string to use to build the read, edit, and delete capabilities.
     1046 *                                              May be passed as an array to allow for alternative plurals when using
     1047 *                                              this argument as a base to construct the capabilities, e.g.
     1048 *                                              array('story', 'stories'). Default 'post'.
     1049 *     @type array       $capabilities          Array of capabilities for this post type. $capability_type is used
     1050 *                                              as a base to construct capabilities by default.
     1051 *                                              See get_post_type_capabilities().
     1052 *     @type bool        $map_meta_cap          Whether to use the internal default meta capability handling.
     1053 *                                              Default false.
     1054 *     @type array       $supports              Core feature(s) the post type supports. Serves as an alias for calling
     1055 *                                              add_post_type_support() directly. Core features include 'title',
     1056 *                                              'editor', 'comments', 'revisions', 'trackbacks', 'author', 'excerpt',
     1057 *                                              'page-attributes', 'thumbnail', 'custom-fields', and 'post-formats'.
     1058 *                                              Additionally, the 'revisions' feature dictates whether the post type
     1059 *                                              will store revisions, and the 'comments' feature dictates whether the
     1060 *                                              comments count will show on the edit screen. Defaults is an array
     1061 *                                              containing 'title' and 'editor'.
     1062 *     @type callable    $register_meta_box_cb  Provide a callback function that sets up the meta boxes for the
     1063 *                                              edit form. Do remove_meta_box() and add_meta_box() calls in the
     1064 *                                              callback. Default null.
     1065 *     @type array       $taxonomies            An array of taxonomy identifiers that will be registered for the
     1066 *                                              post type. Taxonomies can be registered later with register_taxonomy()
     1067 *                                              or register_taxonomy_for_object_type().
     1068 *                                              Default empty array.
     1069 *     @type bool|string $has_archive           Whether there should be post type archives, or if a string, the
     1070 *                                              archive slug to use. Will generate the proper rewrite rules if
     1071 *                                              $rewrite is enabled. Default false.
    10671072 *     @type bool|array  $rewrite              {
    10681073 *         Triggers the handling of rewrites for this post type. To prevent rewrite, set to false.
     
    10801085 *                                  is not set, defaults to EP_PERMALINK.
    10811086 *     }
    1082  *     @type string|bool $query_var            Sets the query_var key for this post type. Defaults to $post_type
    1083  *                                             key. If false, a post type cannot be loaded at
    1084  *                                             ?{query_var}={post_slug}. If specified as a string, the query
    1085  *                                             ?{query_var_string}={post_slug} will be valid.
    1086  *     @type bool        $can_export           Whether to allow this post type to be exported. Default true.
    1087  *     @type bool        $delete_with_user     Whether to delete posts of this type when deleting a user. If true,
    1088  *                                             posts of this type belonging to the user will be moved to trash
    1089  *                                             when then user is deleted. If false, posts of this type belonging
    1090  *                                             to the user will *not* be trashed or deleted. If not set (the default),
    1091  *                                             posts are trashed if post_type_supports('author'). Otherwise posts
    1092  *                                             are not trashed or deleted. Default null.
    1093  *     @type bool        $_builtin             FOR INTERNAL USE ONLY! True if this post type is a native or
    1094  *                                             "built-in" post_type. Default false.
    1095  *     @type string      $_edit_link           FOR INTERNAL USE ONLY! URL segment to use for edit link of
    1096  *                                             this post type. Default 'post.php?post=%d'.
     1087 *     @type string|bool $query_var             Sets the query_var key for this post type. Defaults to $post_type
     1088 *                                              key. If false, a post type cannot be loaded at
     1089 *                                              ?{query_var}={post_slug}. If specified as a string, the query
     1090 *                                              ?{query_var_string}={post_slug} will be valid.
     1091 *     @type bool        $can_export            Whether to allow this post type to be exported. Default true.
     1092 *     @type bool        $delete_with_user      Whether to delete posts of this type when deleting a user. If true,
     1093 *                                              posts of this type belonging to the user will be moved to trash
     1094 *                                              when then user is deleted. If false, posts of this type belonging
     1095 *                                              to the user will *not* be trashed or deleted. If not set (the default),
     1096 *                                              posts are trashed if post_type_supports('author'). Otherwise posts
     1097 *                                              are not trashed or deleted. Default null.
     1098 *     @type bool        $_builtin              FOR INTERNAL USE ONLY! True if this post type is a native or
     1099 *                                              "built-in" post_type. Default false.
     1100 *     @type string      $_edit_link            FOR INTERNAL USE ONLY! URL segment to use for edit link of
     1101 *                                              this post type. Default 'post.php?post=%d'.
    10971102 * }
    10981103 * @return WP_Post_Type|WP_Error The registered post type object, or an error object.
  • trunk/src/wp-includes/taxonomy.php

    r39326 r39462  
    295295 * @since 4.4.0 The `public` argument now controls whether the taxonomy can be queried on the front end.
    296296 * @since 4.5.0 Introduced `publicly_queryable` argument.
     297 * @since 4.7.0 Introduced `show_in_rest`, 'rest_base' and 'rest_controller_class'
     298 *              arguments to register the Taxonomy in REST API.
    297299 *
    298300 * @global array $wp_taxonomies Registered taxonomies.
     
    324326 *     @type bool          $show_in_nav_menus     Makes this taxonomy available for selection in navigation menus. If not
    325327 *                                                set, the default is inherited from `$public` (default true).
     328 *     @type bool          $show_in_rest          Whether to include the taxonomy in the REST API.
     329 *     @type string        $rest_base             To change the base url of REST API route. Default is $taxonomy.
     330 *     @type string        $rest_controller_class REST API Controller class name. Default is 'WP_REST_Terms_Controller'.
    326331 *     @type bool          $show_tagcloud         Whether to list the taxonomy in the Tag Cloud Widget controls. If not set,
    327332 *                                                the default is inherited from `$show_ui` (default true).
Note: See TracChangeset for help on using the changeset viewer.