Changeset 29091
- Timestamp:
- 07/11/2014 07:55:38 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/post.php
r29090 r29091 1190 1190 * parameter), along with a string for the post type name. 1191 1191 * 1192 * Optional $args contents:1193 *1194 * - label - Name of the post type shown in the menu. Usually plural. If not set, labels['name'] will be used.1195 * - labels - An array of labels for this post type.1196 * * If not set, post labels are inherited for non-hierarchical types and page labels for hierarchical ones.1197 * * You can see accepted values in {@link get_post_type_labels()}.1198 * - description - A short descriptive summary of what the post type is. Defaults to blank.1199 * - public - Whether a post type is intended for use publicly either via the admin interface or by front-end users.1200 * * Defaults to false.1201 * * While the default settings of exclude_from_search, publicly_queryable, show_ui, and show_in_nav_menus are1202 * inherited from public, each does not rely on this relationship and controls a very specific intention.1203 * - hierarchical - Whether the post type is hierarchical (e.g. page). Defaults to false.1204 * - exclude_from_search - Whether to exclude posts with this post type from front end search results.1205 * * If not set, the opposite of public's current value is used.1206 * - publicly_queryable - Whether queries can be performed on the front end for the post type as part of parse_request().1207 * * ?post_type={post_type_key}1208 * * ?{post_type_key}={single_post_slug}1209 * * ?{post_type_query_var}={single_post_slug}1210 * * If not set, the default is inherited from public.1211 * - show_ui - Whether to generate a default UI for managing this post type in the admin.1212 * * If not set, the default is inherited from public.1213 * - show_in_menu - Where to show the post type in the admin menu.1214 * * If true, the post type is shown in its own top level menu.1215 * * If false, no menu is shown1216 * * If a string of an existing top level menu (eg. 'tools.php' or 'edit.php?post_type=page'), the post type will1217 * be placed as a sub menu of that.1218 * * show_ui must be true.1219 * * If not set, the default is inherited from show_ui1220 * - show_in_nav_menus - Makes this post type available for selection in navigation menus.1221 * * If not set, the default is inherited from public.1222 * - show_in_admin_bar - Makes this post type available via the admin bar.1223 * * If not set, the default is inherited from show_in_menu1224 * - menu_position - The position in the menu order the post type should appear.1225 * * show_in_menu must be true1226 * * Defaults to null, which places it at the bottom of its area.1227 * - menu_icon - The url to the icon to be used for this menu. Defaults to use the posts icon.1228 * * Pass a base64-encoded SVG using a data URI, which will be colored to match the color scheme.1229 * This should begin with 'data:image/svg+xml;base64,'.1230 * * Pass the name of a Dashicons helper class to use a font icon, e.g. 'dashicons-chart-pie'.1231 * * Pass 'none' to leave div.wp-menu-image empty so an icon can be added via CSS.1232 * - capability_type - The string to use to build the read, edit, and delete capabilities. Defaults to 'post'.1233 * * May be passed as an array to allow for alternative plurals when using this argument as a base to construct the1234 * capabilities, e.g. array('story', 'stories').1235 * - capabilities - Array of capabilities for this post type.1236 * * By default the capability_type is used as a base to construct capabilities.1237 * * You can see accepted values in {@link get_post_type_capabilities()}.1238 * - map_meta_cap - Whether to use the internal default meta capability handling. Defaults to false.1239 * - supports - An alias for calling add_post_type_support() directly. Defaults to title and editor.1240 * * See {@link add_post_type_support()} for documentation.1241 * - register_meta_box_cb - Provide a callback function that sets up the meta boxes1242 * for the edit form. Do remove_meta_box() and add_meta_box() calls in the callback.1243 * - taxonomies - An array of taxonomy identifiers that will be registered for the post type.1244 * * Default is no taxonomies.1245 * * Taxonomies can be registered later with register_taxonomy() or register_taxonomy_for_object_type().1246 * - has_archive - True to enable post type archives. Default is false.1247 * * Will generate the proper rewrite rules if rewrite is enabled.1248 * - rewrite - Triggers the handling of rewrites for this post type. Defaults to true, using $post_type as slug.1249 * * To prevent rewrite, set to false.1250 * * To specify rewrite rules, an array can be passed with any of these keys1251 * * 'slug' => string Customize the permastruct slug. Defaults to $post_type key1252 * * 'with_front' => bool Should the permastruct be prepended with WP_Rewrite::$front. Defaults to true.1253 * * 'feeds' => bool Should a feed permastruct be built for this post type. Inherits default from has_archive.1254 * * 'pages' => bool Should the permastruct provide for pagination. Defaults to true.1255 * * 'ep_mask' => const Assign an endpoint mask.1256 * * If not specified and permalink_epmask is set, inherits from permalink_epmask.1257 * * If not specified and permalink_epmask is not set, defaults to EP_PERMALINK1258 * - query_var - Sets the query_var key for this post type. Defaults to $post_type key1259 * * If false, a post type cannot be loaded at ?{query_var}={post_slug}1260 * * If specified as a string, the query ?{query_var_string}={post_slug} will be valid.1261 * - can_export - Allows this post type to be exported. Defaults to true.1262 * - delete_with_user - Whether to delete posts of this type when deleting a user.1263 * * If true, posts of this type belonging to the user will be moved to trash when then user is deleted.1264 * * If false, posts of this type belonging to the user will *not* be trashed or deleted.1265 * * If not set (the default), posts are trashed if post_type_supports('author'). Otherwise posts are not trashed or deleted.1266 * - _builtin - true if this post type is a native or "built-in" post_type. THIS IS FOR INTERNAL USE ONLY!1267 * - _edit_link - URL segement to use for edit link of this post type. THIS IS FOR INTERNAL USE ONLY!1268 *1269 1192 * @since 2.9.0 1270 * @uses $wp_post_types Inserts new post type object into the list 1271 * @uses $wp_rewrite Gets default feeds 1272 * @uses $wp Adds query vars 1193 * 1194 * @global array $wp_post_types List of post types. 1195 * @global WP_Rewrite $wp_rewrite Used for default feeds. 1196 * @global WP $wp Used to add query vars. 1273 1197 * 1274 1198 * @param string $post_type Post type key, must not exceed 20 characters. 1275 * @param array|string $args See optional args description above. 1276 * @return object|WP_Error the registered post type object, or an error object. 1199 * @param array|string $args { 1200 * Array or string of arguments for registering a post type. 1201 * 1202 * @type string $label Name of the post type shown in the menu. Usually plural. 1203 * Default is value of $labels['name']. 1204 * @type array $labels An array of labels for this post type. If not set, post 1205 * labels are inherited for non-hierarchical types and page 1206 * labels for hierarchical ones. {@see get_post_type_labels()}. 1207 * @type string $description A short descriptive summary of what the post type is. 1208 * Default empty. 1209 * @type bool $public Whether a post type is intended for use publicly either via 1210 * the admin interface or by front-end users. While the default 1211 * settings of $exclude_from_search, $publicly_queryable, $show_ui, 1212 * and $show_in_nav_menus are inherited from public, each does not 1213 * rely on this relationship and controls a very specific intention. 1214 * Default false. 1215 * @type bool $hierarchical Whether the post type is hierarchical (e.g. page). Default false. 1216 * @type bool $exclude_from_search Whether to exclude posts with this post type from front end search 1217 * results. Default is the opposite value of $public. 1218 * @type bool $publicly_queryable Whether queries can be performed on the front end for the post type 1219 * as part of {@see parse_request()}. Endpoints would include: 1220 * * ?post_type={post_type_key} 1221 * * ?{post_type_key}={single_post_slug} 1222 * * ?{post_type_query_var}={single_post_slug} 1223 * If not set, the default is inherited from $public. 1224 * @type bool $show_ui Whether to generate a default UI for managing this post type in the 1225 * admin. Default is value of $public. 1226 * @type bool $show_in_menu Where to show the post type in the admin menu. To work, $show_ui 1227 * must be true. If true, the post type is shown in its own top level 1228 * menu. If false, no menu is shown. If a string of an existing top 1229 * level menu (eg. 'tools.php' or 'edit.php?post_type=page'), the post 1230 * type will be placed as a sub-menu of that. 1231 * Default is value of $show_ui. 1232 * @type bool $show_in_nav_menus Makes this post type available for selection in navigation menus. 1233 * Default is value $public. 1234 * @type bool $show_in_admin_bar Makes this post type available via the admin bar. Default is value 1235 * of $show_in_menu. 1236 * @type int $menu_position The position in the menu order the post type should appear. To work, 1237 * $show_in_menu must be true. Default null (at the bottom). 1238 * @type string $menu_icon The url to the icon to be used for this menu. Pass a base64-encoded 1239 * SVG using a data URI, which will be colored to match the color scheme 1240 * -- this should begin with 'data:image/svg+xml;base64,'. Pass the name 1241 * of a Dashicons helper class to use a font icon, e.g. 1242 * 'dashicons-chart-pie'. Pass 'none' to leave div.wp-menu-image empty 1243 * so an icon can be added via CSS. Defaults to use the posts icon. 1244 * @type string $capability_type The string to use to build the read, edit, and delete capabilities. 1245 * May be passed as an array to allow for alternative plurals when using 1246 * this argument as a base to construct the capabilities, e.g. 1247 * array('story', 'stories'). Default 'post'. 1248 * @type array $capabilities Array of capabilities for this post type. $capability_type is used 1249 * as a base to construct capabilities by default. 1250 * {@see get_post_type_capabilities()}. 1251 * @type bool $map_meta_cap Whether to use the internal default meta capability handling. 1252 * Default false. 1253 * @type array $supports An alias for calling {@see add_post_type_support()} directly. 1254 * Defaults to array containing 'title' & 'editor'. 1255 * @type callback $register_meta_box_cb Provide a callback function that sets up the meta boxes for the 1256 * edit form. Do remove_meta_box() and add_meta_box() calls in the 1257 * callback. Default null. 1258 * @type array $taxonomies An array of taxonomy identifiers that will be registered for the 1259 * post type. Taxonomies can be registered later with 1260 * {@see register_taxonomy()} or {@see register_taxonomy_for_object_type()}. 1261 * Default empty array. 1262 * @type bool|string $has_archive Whether there should be post type archives, or if a string, the 1263 * archive slug to use. Will generate the proper rewrite rules if 1264 * $rewrite is enabled. Default false. 1265 * @type bool|array $rewrite { 1266 * Triggers the handling of rewrites for this post type. To prevent rewrite, set to false. 1267 * Defaults to true, using $post_type as slug. To specify rewrite rules, an array can be 1268 * passed with any of these keys: 1269 * 1270 * @type string $slug Customize the permastruct slug. Defaults to $post_type key. 1271 * @type bool $with_front Whether the permastruct should be prepended with WP_Rewrite::$front. 1272 * Default true. 1273 * @type bool $feeds Whether the feed permastruct should be built for this post type. 1274 * Default is value of $has_archive. 1275 * @type bool $pages Whether the permastruct should provide for pagination. Default true. 1276 * @type const $ep_mask Endpoint mask to assign. If not specified and permalink_epmask is set, 1277 * inherits from $permalink_epmask. If not specified and permalink_epmask 1278 * is not set, defaults to EP_PERMALINK. 1279 * } 1280 * @type string|bool $query_var Sets the query_var key for this post type. Defaults to $post_type 1281 * key. If false, a post type cannot be loaded at 1282 * ?{query_var}={post_slug}. If specified as a string, the query 1283 * ?{query_var_string}={post_slug} will be valid. 1284 * @type bool $can_export Whether to allow this post type to be exported. Default true. 1285 * @type bool $delete_with_user Whether to delete posts of this type when deleting a user. If true, 1286 * posts of this type belonging to the user will be moved to trash 1287 * when then user is deleted. If false, posts of this type belonging 1288 * to the user will *not* be trashed or deleted. If not set (the default), 1289 * posts are trashed if post_type_supports('author'). Otherwise posts 1290 * are not trashed or deleted. Default null. 1291 * @type bool $_builtin FOR INTERNAL USE ONLY! True if this post type is a native or 1292 * "built-in" post_type. Default false. 1293 * @type string $_edit_link FOR INTERNAL USE ONLY! URL segment to use for edit link of 1294 * this post type. Default 'post.php?post=%d'. 1295 * } 1296 * @return object|WP_Error The registered post type object, or an error object. 1277 1297 */ 1278 1298 function register_post_type( $post_type, $args = array() ) {
Note: See TracChangeset
for help on using the changeset viewer.