Make WordPress Core

Changeset 49495


Ignore:
Timestamp:
11/04/2020 02:30:24 AM (4 years ago)
Author:
SergeyBiryukov
Message:

Docs: Add documentation for the template_lock argument to register_post_type().

Add a @since entry for template and template_lock arguments.

Follow-up to [49041], [49492], [49494].

See #46261.

File:
1 edited

Legend:

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

    r49493 r49495  
    12961296 *              arguments to register the post type in REST API.
    12971297 * @since 5.3.0 The `supports` argument will now accept an array of arguments for a feature.
    1298  * .
     1298 * @since 5.6.0 The `template` and `template_lock` arguments were added.
     1299 *
    12991300 * @global array $wp_post_types List of post types.
    13001301 *
     
    13051306 *     Array or string of arguments for registering a post type.
    13061307 *
    1307  *     @type string      $label                 Name of the post type shown in the menu. Usually plural.
    1308  *                                              Default is value of $labels['name'].
    1309  *     @type array       $labels                An array of labels for this post type. If not set, post
    1310  *                                              labels are inherited for non-hierarchical types and page
    1311  *                                              labels for hierarchical ones. See get_post_type_labels() for a full
    1312  *                                              list of supported labels.
    1313  *     @type string      $description           A short descriptive summary of what the post type is.
    1314  *                                              Default empty.
    1315  *     @type bool        $public                Whether a post type is intended for use publicly either via
    1316  *                                              the admin interface or by front-end users. While the default
    1317  *                                              settings of $exclude_from_search, $publicly_queryable, $show_ui,
    1318  *                                              and $show_in_nav_menus are inherited from public, each does not
    1319  *                                              rely on this relationship and controls a very specific intention.
    1320  *                                              Default false.
    1321  *     @type bool        $hierarchical          Whether the post type is hierarchical (e.g. page). Default false.
    1322  *     @type bool        $exclude_from_search   Whether to exclude posts with this post type from front end search
    1323  *                                              results. Default is the opposite value of $public.
    1324  *     @type bool        $publicly_queryable    Whether queries can be performed on the front end for the post type
    1325  *                                              as part of parse_request(). Endpoints would include:
    1326  *                                              * ?post_type={post_type_key}
    1327  *                                              * ?{post_type_key}={single_post_slug}
    1328  *                                              * ?{post_type_query_var}={single_post_slug}
    1329  *                                              If not set, the default is inherited from $public.
    1330  *     @type bool        $show_ui               Whether to generate and allow a UI for managing this post type in the
    1331  *                                              admin. Default is value of $public.
    1332  *     @type bool|string $show_in_menu          Where to show the post type in the admin menu. To work, $show_ui
    1333  *                                              must be true. If true, the post type is shown in its own top level
    1334  *                                              menu. If false, no menu is shown. If a string of an existing top
    1335  *                                              level menu (eg. 'tools.php' or 'edit.php?post_type=page'), the post
    1336  *                                              type will be placed as a sub-menu of that.
    1337  *                                              Default is value of $show_ui.
    1338  *     @type bool        $show_in_nav_menus     Makes this post type available for selection in navigation menus.
    1339  *                                              Default is value of $public.
    1340  *     @type bool        $show_in_admin_bar     Makes this post type available via the admin bar. Default is value
    1341  *                                              of $show_in_menu.
    1342  *     @type bool        $show_in_rest          Whether to include the post type in the REST API. Set this to true
    1343  *                                              for the post type to be available in the block editor.
    1344  *     @type string      $rest_base             To change the base url of REST API route. Default is $post_type.
    1345  *     @type string      $rest_controller_class REST API Controller class name. Default is 'WP_REST_Posts_Controller'.
    1346  *     @type int         $menu_position         The position in the menu order the post type should appear. To work,
    1347  *                                              $show_in_menu must be true. Default null (at the bottom).
    1348  *     @type string      $menu_icon             The url to the icon to be used for this menu. Pass a base64-encoded
    1349  *                                              SVG using a data URI, which will be colored to match the color scheme
    1350  *                                              -- this should begin with 'data:image/svg+xml;base64,'. Pass the name
    1351  *                                              of a Dashicons helper class to use a font icon, e.g.
    1352  *                                              'dashicons-chart-pie'. Pass 'none' to leave div.wp-menu-image empty
    1353  *                                              so an icon can be added via CSS. Defaults to use the posts icon.
    1354  *     @type string      $capability_type       The string to use to build the read, edit, and delete capabilities.
    1355  *                                              May be passed as an array to allow for alternative plurals when using
    1356  *                                              this argument as a base to construct the capabilities, e.g.
    1357  *                                              array('story', 'stories'). Default 'post'.
    1358  *     @type array       $capabilities          Array of capabilities for this post type. $capability_type is used
    1359  *                                              as a base to construct capabilities by default.
    1360  *                                              See get_post_type_capabilities().
    1361  *     @type bool        $map_meta_cap          Whether to use the internal default meta capability handling.
    1362  *                                              Default false.
    1363  *     @type array       $supports              Core feature(s) the post type supports. Serves as an alias for calling
    1364  *                                              add_post_type_support() directly. Core features include 'title',
    1365  *                                              'editor', 'comments', 'revisions', 'trackbacks', 'author', 'excerpt',
    1366  *                                              'page-attributes', 'thumbnail', 'custom-fields', and 'post-formats'.
    1367  *                                              Additionally, the 'revisions' feature dictates whether the post type
    1368  *                                              will store revisions, and the 'comments' feature dictates whether the
    1369  *                                              comments count will show on the edit screen. A feature can also be
    1370  *                                              specified as an array of arguments to provide additional information
    1371  *                                              about supporting that feature.
    1372  *                                              Example: `array( 'my_feature', array( 'field' => 'value' ) )`.
    1373  *                                              Default is an array containing 'title' and 'editor'.
    1374  *     @type callable    $register_meta_box_cb  Provide a callback function that sets up the meta boxes for the
    1375  *                                              edit form. Do remove_meta_box() and add_meta_box() calls in the
    1376  *                                              callback. Default null.
    1377  *     @type array       $taxonomies            An array of taxonomy identifiers that will be registered for the
    1378  *                                              post type. Taxonomies can be registered later with register_taxonomy()
    1379  *                                              or register_taxonomy_for_object_type().
    1380  *                                              Default empty array.
    1381  *     @type bool|string $has_archive           Whether there should be post type archives, or if a string, the
    1382  *                                              archive slug to use. Will generate the proper rewrite rules if
    1383  *                                              $rewrite is enabled. Default false.
    1384  *     @type bool|array  $rewrite              {
     1308 *     @type string       $label                 Name of the post type shown in the menu. Usually plural.
     1309 *                                               Default is value of $labels['name'].
     1310 *     @type array        $labels                An array of labels for this post type. If not set, post
     1311 *                                               labels are inherited for non-hierarchical types and page
     1312 *                                               labels for hierarchical ones. See get_post_type_labels() for a full
     1313 *                                               list of supported labels.
     1314 *     @type string       $description           A short descriptive summary of what the post type is.
     1315 *                                               Default empty.
     1316 *     @type bool         $public                Whether a post type is intended for use publicly either via
     1317 *                                               the admin interface or by front-end users. While the default
     1318 *                                               settings of $exclude_from_search, $publicly_queryable, $show_ui,
     1319 *                                               and $show_in_nav_menus are inherited from public, each does not
     1320 *                                               rely on this relationship and controls a very specific intention.
     1321 *                                               Default false.
     1322 *     @type bool         $hierarchical          Whether the post type is hierarchical (e.g. page). Default false.
     1323 *     @type bool         $exclude_from_search   Whether to exclude posts with this post type from front end search
     1324 *                                               results. Default is the opposite value of $public.
     1325 *     @type bool         $publicly_queryable    Whether queries can be performed on the front end for the post type
     1326 *                                               as part of parse_request(). Endpoints would include:
     1327 *                                               * ?post_type={post_type_key}
     1328 *                                               * ?{post_type_key}={single_post_slug}
     1329 *                                               * ?{post_type_query_var}={single_post_slug}
     1330 *                                               If not set, the default is inherited from $public.
     1331 *     @type bool         $show_ui               Whether to generate and allow a UI for managing this post type in the
     1332 *                                               admin. Default is value of $public.
     1333 *     @type bool|string  $show_in_menu          Where to show the post type in the admin menu. To work, $show_ui
     1334 *                                               must be true. If true, the post type is shown in its own top level
     1335 *                                               menu. If false, no menu is shown. If a string of an existing top
     1336 *                                               level menu (eg. 'tools.php' or 'edit.php?post_type=page'), the post
     1337 *                                               type will be placed as a sub-menu of that.
     1338 *                                               Default is value of $show_ui.
     1339 *     @type bool         $show_in_nav_menus     Makes this post type available for selection in navigation menus.
     1340 *                                               Default is value of $public.
     1341 *     @type bool         $show_in_admin_bar     Makes this post type available via the admin bar. Default is value
     1342 *                                               of $show_in_menu.
     1343 *     @type bool         $show_in_rest          Whether to include the post type in the REST API. Set this to true
     1344 *                                               for the post type to be available in the block editor.
     1345 *     @type string       $rest_base             To change the base url of REST API route. Default is $post_type.
     1346 *     @type string       $rest_controller_class REST API Controller class name. Default is 'WP_REST_Posts_Controller'.
     1347 *     @type int          $menu_position         The position in the menu order the post type should appear. To work,
     1348 *                                               $show_in_menu must be true. Default null (at the bottom).
     1349 *     @type string       $menu_icon             The url to the icon to be used for this menu. Pass a base64-encoded
     1350 *                                               SVG using a data URI, which will be colored to match the color scheme
     1351 *                                               -- this should begin with 'data:image/svg+xml;base64,'. Pass the name
     1352 *                                               of a Dashicons helper class to use a font icon, e.g.
     1353 *                                               'dashicons-chart-pie'. Pass 'none' to leave div.wp-menu-image empty
     1354 *                                               so an icon can be added via CSS. Defaults to use the posts icon.
     1355 *     @type string       $capability_type       The string to use to build the read, edit, and delete capabilities.
     1356 *                                               May be passed as an array to allow for alternative plurals when using
     1357 *                                               this argument as a base to construct the capabilities, e.g.
     1358 *                                               array('story', 'stories'). Default 'post'.
     1359 *     @type array        $capabilities          Array of capabilities for this post type. $capability_type is used
     1360 *                                               as a base to construct capabilities by default.
     1361 *                                               See get_post_type_capabilities().
     1362 *     @type bool         $map_meta_cap          Whether to use the internal default meta capability handling.
     1363 *                                               Default false.
     1364 *     @type array        $supports              Core feature(s) the post type supports. Serves as an alias for calling
     1365 *                                               add_post_type_support() directly. Core features include 'title',
     1366 *                                               'editor', 'comments', 'revisions', 'trackbacks', 'author', 'excerpt',
     1367 *                                               'page-attributes', 'thumbnail', 'custom-fields', and 'post-formats'.
     1368 *                                               Additionally, the 'revisions' feature dictates whether the post type
     1369 *                                               will store revisions, and the 'comments' feature dictates whether the
     1370 *                                               comments count will show on the edit screen. A feature can also be
     1371 *                                               specified as an array of arguments to provide additional information
     1372 *                                               about supporting that feature.
     1373 *                                               Example: `array( 'my_feature', array( 'field' => 'value' ) )`.
     1374 *                                               Default is an array containing 'title' and 'editor'.
     1375 *     @type callable     $register_meta_box_cb  Provide a callback function that sets up the meta boxes for the
     1376 *                                               edit form. Do remove_meta_box() and add_meta_box() calls in the
     1377 *                                               callback. Default null.
     1378 *     @type array        $taxonomies            An array of taxonomy identifiers that will be registered for the
     1379 *                                               post type. Taxonomies can be registered later with register_taxonomy()
     1380 *                                               or register_taxonomy_for_object_type().
     1381 *                                               Default empty array.
     1382 *     @type bool|string  $has_archive           Whether there should be post type archives, or if a string, the
     1383 *                                               archive slug to use. Will generate the proper rewrite rules if
     1384 *                                               $rewrite is enabled. Default false.
     1385 *     @type bool|array   $rewrite               {
    13851386 *         Triggers the handling of rewrites for this post type. To prevent rewrite, set to false.
    13861387 *         Defaults to true, using $post_type as slug. To specify rewrite rules, an array can be
     
    13971398 *                                  is not set, defaults to EP_PERMALINK.
    13981399 *     }
    1399  *     @type string|bool $query_var             Sets the query_var key for this post type. Defaults to $post_type
    1400  *                                              key. If false, a post type cannot be loaded at
    1401  *                                              ?{query_var}={post_slug}. If specified as a string, the query
    1402  *                                              ?{query_var_string}={post_slug} will be valid.
    1403  *     @type bool        $can_export            Whether to allow this post type to be exported. Default true.
    1404  *     @type bool        $delete_with_user      Whether to delete posts of this type when deleting a user. If true,
    1405  *                                              posts of this type belonging to the user will be moved to Trash
    1406  *                                              when then user is deleted. If false, posts of this type belonging
    1407  *                                              to the user will *not* be trashed or deleted. If not set (the default),
    1408  *                                              posts are trashed if post_type_supports('author'). Otherwise posts
    1409  *                                              are not trashed or deleted. Default null.
    1410  *     @type array       $template              Array of blocks to use as the default initial state for an editor
    1411  *                                              session. Each item should be an array containing block name and
    1412  *                                              optional attributes.
    1413  *     @type bool        $_builtin              FOR INTERNAL USE ONLY! True if this post type is a native or
    1414  *                                              "built-in" post_type. Default false.
    1415  *     @type string      $_edit_link            FOR INTERNAL USE ONLY! URL segment to use for edit link of
    1416  *                                              this post type. Default 'post.php?post=%d'.
     1400 *     @type string|bool  $query_var             Sets the query_var key for this post type. Defaults to $post_type
     1401 *                                               key. If false, a post type cannot be loaded at
     1402 *                                               ?{query_var}={post_slug}. If specified as a string, the query
     1403 *                                               ?{query_var_string}={post_slug} will be valid.
     1404 *     @type bool         $can_export            Whether to allow this post type to be exported. Default true.
     1405 *     @type bool         $delete_with_user      Whether to delete posts of this type when deleting a user.
     1406 *                                               - If true, posts of this type belonging to the user will be moved
     1407 *                                                 to Trash when the user is deleted.
     1408 *                                               - If false, posts of this type belonging to the user will *not*
     1409 *                                                 be trashed or deleted.
     1410 *                                               - If not set (the default), posts are trashed if post type supports
     1411 *                                                 the 'author' feature. Otherwise posts are not trashed or deleted.
     1412 *                                               Default null.
     1413 *     @type array        $template              Array of blocks to use as the default initial state for an editor
     1414 *                                               session. Each item should be an array containing block name and
     1415 *                                               optional attributes. Default empty array.
     1416 *     @type string|false $template_lock         Whether the block template should be locked if $template is set.
     1417 *                                               - If set to 'all', the user is unable to insert new blocks,
     1418 *                                                 move existing blocks and delete blocks.
     1419 *                                               - If set to 'insert', the user is able to move existing blocks
     1420 *                                                 but is unable to insert new blocks and delete blocks.
     1421 *                                               Default false.
     1422 *     @type bool         $_builtin              FOR INTERNAL USE ONLY! True if this post type is a native or
     1423 *                                               "built-in" post_type. Default false.
     1424 *     @type string       $_edit_link            FOR INTERNAL USE ONLY! URL segment to use for edit link of
     1425 *                                               this post type. Default 'post.php?post=%d'.
    14171426 * }
    14181427 * @return WP_Post_Type|WP_Error The registered post type object on success,
Note: See TracChangeset for help on using the changeset viewer.