You appear to be a bot. Output may be restricted
Description
Display post_type argsUsed for add and edit fields. For the early version we only handle the "most important" fields; anything else can be created in a custom plugin.
args supported/not supported – if not supported the default value is used Y public Y hierarchical Y has_archive Y exclude_from_search Y publicly_queryable Y show_ui Y show_in_nav_menus Y show_in_menu Y rewrite Y supports array Y show_in_admin_bar added 2014/07/11 Y show_in_rest added 2018/02/02 N menu_position N menu_icon N capability_type default post N capabilities array default edit, read, delete, edit_posts, edit_others_posts, publish_posts, read_private_posts etcetera N map_meta_cap Y _builtin added 2019/1028
If you assign a 'capability_type' and then take a look into the $GLOBALS['wp_post_types']['your_cpt_name'] array, then you'll see the following:
[cap] => stdClass Object ( [edit_post] => "edit_{$capability_type}" [read_post] => "read_{$capability_type}" [delete_post] => "delete_{$capability_type}" [edit_posts] => "edit_{$capability_type}s" [edit_others_posts] => "edit_others_{$capability_type}s" [publish_posts] => "publish_{$capability_type}s" [read_private_posts] => "read_private_{$capability_type}s" [delete_posts] => "delete_{$capability_type}s" [delete_private_posts] => "delete_private_{$capability_type}s" [delete_published_posts] => "delete_published_{$capability_type}s" [delete_others_posts] => "delete_others_{$capability_type}s" [edit_private_posts] => "edit_private_{$capability_type}s" [edit_published_posts] => "edit_published_{$capability_type}s" ) Note the "s" at the end of plural capabilities.
hierarchical (boolean) (optional) Whether the post type is hierarchical (e.g. page). Allows Parent to be specified. The 'supports' parameter should contain 'page-attributes' to show the parent select box on the editor page. Default: false Note: this parameter was planned for Pages. Be careful, when choosing it for your custom post type – if you are planning to have many entries (say – over 100), you will run into memory issue. With this parameter set to true WordPress will fetch all entries of that particular post type, together with all meta data, on each administration page load for your post type. supports (array/boolean) (optional) An alias for calling add_post_type_support() directly. As of 3.5, boolean false can be passed as value instead of an array to prevent default (title and editor) behavior. Default: title and editor 'title' 'editor' (content) 'author' 'thumbnail' (featured image, current theme must also support post-thumbnails) 'excerpt' 'trackbacks' 'custom-fields' 'comments' (also will see comment count balloon on edit screen) 'revisions' (will store revisions) 'page-attributes' (menu order, hierarchical must be true to show Parent option) 'post-formats' add post formats, see Post Formats Note: When you use custom post type that use thumbnails remember to check that the theme also supports thumbnails or use add_theme_support function. register_meta_box_cb (string) (optional) Provide a callback function that will be called when setting up the meta boxes for the edit form. Do remove_meta_box() and add_meta_box() calls in the callback. Default: None taxonomies (array) (optional) An array of registered taxonomies like category or post_tag that will be used with this post type. This can be used in lieu of calling register_taxonomy_for_object_type() directly. Custom taxonomies still need to be registered with register_taxonomy(). Default: no taxonomies has_archive (boolean or string) (optional) Enables post type archives. Will use $post_type as archive slug by default. Default: false Note: Will generate the proper rewrite rules if rewrite is enabled. Also use rewrite to change the slug used. permalink_epmask (string) (optional) The default rewrite endpoint bitmasks. For more info see Trac Ticket 12605 and this Make WordPress Plugins summary of endpoints. Default: EP_PERMALINK Note: In 3.4, this argument is effectively replaced by the 'ep_mask' argument under rewrite. rewrite (boolean or array) (optional) Triggers the handling of rewrites for this post type. To prevent rewrites, set to false. Default: true and use $post_type as slug $args array 'slug' => string Customize the permastruct slug. Defaults to the $post_type value. Should be translatable. 'with_front' => bool Should the permastruct be prepended with the front base. (example: if your permalink structure is /blog/, then your links will be: false->/news/, true->/blog/news/). Defaults to true 'feeds' => bool Should a feed permastruct be built for this post type. Defaults to has_archive value. 'pages' => bool Should the permastruct provide for pagination. Defaults to true 'ep_mask' => const As of 3.4 Assign an endpoint mask for this post type. For more info see Trac Ticket 19275 and this Make WordPress Plugins summary of endpoints. If not specified and permalink_epmask is set, inherits from permalink_epmask If not specified and permalink_epmask is not set, defaults to EP_PERMALINK Note: If registering a post type inside of a plugin, call flush_rewrite_rules() in your activation and deactivation hook (see Flushing Rewrite on Activation below). If flush_rewrite_rules() is not used, then you will have to manually go to Settings > Permalinks and refresh your permalink structure before your custom post type will show the correct structure. query_var (boolean or string) (optional) Sets the query_var key for this post type. Default: true – set to $post_type 'false' – Disables query_var key use. A post type cannot be loaded at /?{query_var}={single_post_slug} 'string' – /?{query_var_string}={single_post_slug} will work as intended. Note: The query_var parameter has no effect if the publicly_queryable
parameter is set to false. query_var adds the custom post type's query var to the built-in query_vars array so that WordPress will recognize it. WordPress removes any query var not included in that array. If set to true it allow you to request a custom posts type (book) using this: example.com/?book=life-of-pi If set to a string rather than true (for example 'publication'), you can do: example.com/?publication=life-of-pi
can_export (boolean) (optional) Can this post_type be exported. Default: true _builtin (boolean) (not for general use) Whether this post type is a native or "built-in" post_type. Note: this Codex entry is for documentation – core developers recommend you don't use this when registering your own post type Default: false 'false' – default this is a custom post type 'true' – this is a built-in native post type (post, page, attachment, revision, nav_menu_item) _edit_link (boolean) (not for general use) Link to edit an entry with this post type. Note: this Codex entry is for documentation '-' core developers recommend you don't use this when registering your own post type Default: 'post.php?post=%d'
Usage
oik_cpt_edit_type_fields( $bw_type );
Parameters
- $bw_type
- ( mixed ) required –
Returns
voidSource
File name: oik-types/admin/oik-types.phpLines:
function oik_cpt_edit_type_fields( $bw_type ) { bw_checkbox( "hierarchical", "Hierarchical type?", $bw_type['args']["hierarchical"] ); oik_cpt_edit_has_archive( $bw_type) ; bw_checkbox( "public", "Public", $bw_type['args']["public"] ); bw_checkbox( "exclude_from_search", "Exclude from search", $bw_type['args']["exclude_from_search"] ); bw_checkbox( "publicly_queryable", "Publicly queryable", $bw_type['args']["publicly_queryable"] ); bw_checkbox( "show_ui", "Show UI", $bw_type['args']["show_ui"] ); bw_checkbox( "show_in_nav_menus", "Show in nav menus", $bw_type['args']["show_in_nav_menus"] ); bw_checkbox( "show_in_menu", "Show in menu", $bw_type['args']["show_in_menu"] ); bw_checkbox( "show_in_admin_bar", "Show in admin bar", bw_array_get( $bw_type['args'], "show_in_admin_bar", true ) ); bw_checkbox( "show_in_rest", "Show in REST", bw_array_get( $bw_type['args'], "show_in_rest", false ) ); // bw_checkbox( "rewrite", "Rewrite", $bw_type['args']["rewrite"] ); oik_cpt_edit_rewrite( $bw_type['args']['rewrite'] ); //bw_checkbox( "", "", $bw_type['args'][""] ); //bw_checkbox( "", "", $bw_type['args'][""] ); //bw_checkbox( "", "", $bw_type['args'][""] ); //bw_checkbox( "", "", $bw_type['args'][""] ); //bw_checkbox( "", "", $bw_type['args'][""] ); //bw_checkbox( "", "", $bw_type['args'][""] ); //bw_checkbox( "", "", $bw_type['args'][""] ); oik_cpt_edit_supports( $bw_type['args']['supports'] ); BW_::bw_textfield( "archive_sort", 30, __( "Archive sort", "oik-types" ), bw_array_get( $bw_type['args'], "archive_sort", null ) ); BW_::bw_textfield( "archive_posts_per_page", 4, __( "Archive posts per page", "oik-types" ), bw_array_get( $bw_type['args'], "archive_posts_per_page", null ) ); bw_checkbox( '_builtin', 'Builtin ( Internal Use )', bw_array_get( $bw_type['args'], '_builtin', false ) ); }View on GitHub