IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
|
|
|
1210 | 1210 | '_edit_link' => 'post.php?post=%d', |
1211 | 1211 | ); |
1212 | 1212 | $args = wp_parse_args( $args, $defaults ); |
| 1213 | |
| 1214 | $args['name'] = sanitize_key( $post_type ); |
| 1215 | |
| 1216 | if ( ! apply_filters( 'do_register_post_type', true, $args, $post_type ) ) { |
| 1217 | return false; |
| 1218 | } |
| 1219 | |
1213 | 1220 | $args = (object) $args; |
1214 | 1221 | |
1215 | | $post_type = sanitize_key( $post_type ); |
1216 | | $args->name = $post_type; |
| 1222 | $post_type = $args['name'] = apply_filters( 'register_post_type_name', $args['name'], $args, $post_type ); |
1217 | 1223 | |
| 1224 | $args = (object) $args; |
| 1225 | |
| 1226 | list( |
| 1227 | $args->publicly_queryable, |
| 1228 | $args->show_ui, |
| 1229 | $args->show_in_menu, |
| 1230 | $args->show_in_admin_bar, |
| 1231 | $args->show_in_nav_menus, |
| 1232 | $args->exclude_from_search, |
| 1233 | ) = apply_filters( 'register_post_type_flags', array( |
| 1234 | 'publicly_queryable' => $args->publicly_queryable, |
| 1235 | 'show_ui' => $args->show_ui, |
| 1236 | 'show_in_menu' => $args->show_in_menu, |
| 1237 | 'show_in_admin_bar' => $args->show_in_admin_bar, |
| 1238 | 'show_in_nav_menus' => $args->show_in_nav_menus, |
| 1239 | 'exclude_from_search' => $args->exclude_from_search, |
| 1240 | ), $args, $post_type ); |
| 1241 | |
1218 | 1242 | if ( strlen( $post_type ) > 20 ) |
1219 | 1243 | return new WP_Error( 'post_type_too_long', __( 'Post types cannot exceed 20 characters in length' ) ); |
1220 | 1244 | |
… |
… |
|
1242 | 1266 | if ( null === $args->exclude_from_search ) |
1243 | 1267 | $args->exclude_from_search = !$args->public; |
1244 | 1268 | |
| 1269 | list( |
| 1270 | $args->capabilities, |
| 1271 | $args->map_meta_cap, |
| 1272 | $args->capability_type |
| 1273 | ) = apply_filters( 'register_post_type_capabilities', array( |
| 1274 | 'capabilities' => $args->capabilities, |
| 1275 | 'map_meta_cap' => $args->map_meta_cap, |
| 1276 | 'capability_type' => $args->capability_type |
| 1277 | ), $args, $post_type ); |
| 1278 | |
| 1279 | |
1245 | 1280 | // Back compat with quirky handling in version 3.0. #14122 |
1246 | 1281 | if ( empty( $args->capabilities ) && null === $args->map_meta_cap && in_array( $args->capability_type, array( 'post', 'page' ) ) ) |
1247 | 1282 | $args->map_meta_cap = true; |
… |
… |
|
1272 | 1307 | $wp->add_query_var( $args->query_var ); |
1273 | 1308 | } |
1274 | 1309 | |
| 1310 | $args->rewrite = apply_filters( 'register_post_type_rewrite', $args->rewrite, $args, $post_type ); |
| 1311 | |
1275 | 1312 | if ( false !== $args->rewrite && ( is_admin() || '' != get_option( 'permalink_structure' ) ) ) { |
1276 | 1313 | if ( ! is_array( $args->rewrite ) ) |
1277 | 1314 | $args->rewrite = array(); |
… |
… |
|
1290 | 1327 | $args->rewrite['ep_mask'] = EP_PERMALINK; |
1291 | 1328 | } |
1292 | 1329 | |
| 1330 | $args->hierarchical = apply_filters( 'register_post_type_hierarchical', $args->hierarchical, $args, $post_type ); |
| 1331 | |
1293 | 1332 | if ( $args->hierarchical ) |
1294 | 1333 | add_rewrite_tag( "%$post_type%", '(.+?)', $args->query_var ? "{$args->query_var}=" : "post_type=$post_type&pagename=" ); |
1295 | 1334 | else |
1296 | 1335 | add_rewrite_tag( "%$post_type%", '([^/]+)', $args->query_var ? "{$args->query_var}=" : "post_type=$post_type&name=" ); |
1297 | 1336 | |
| 1337 | $args->has_archive = apply_filters( 'register_post_type_has_archive', $args->has_archive, $args, $post_type ); |
| 1338 | |
1298 | 1339 | if ( $args->has_archive ) { |
1299 | 1340 | $archive_slug = $args->has_archive === true ? $args->rewrite['slug'] : $args->has_archive; |
1300 | 1341 | if ( $args->rewrite['with_front'] ) |
… |
… |
|
1302 | 1343 | else |
1303 | 1344 | $archive_slug = $wp_rewrite->root . $archive_slug; |
1304 | 1345 | |
| 1346 | $archive_slug = apply_filters( 'register_post_type_archive_slug', $archive_slug, $args, $post_type ); |
| 1347 | |
1305 | 1348 | add_rewrite_rule( "{$archive_slug}/?$", "index.php?post_type=$post_type", 'top' ); |
1306 | 1349 | if ( $args->rewrite['feeds'] && $wp_rewrite->feeds ) { |
1307 | 1350 | $feeds = '(' . trim( implode( '|', $wp_rewrite->feeds ) ) . ')'; |
… |
… |
|
1314 | 1357 | |
1315 | 1358 | $permastruct_args = $args->rewrite; |
1316 | 1359 | $permastruct_args['feed'] = $permastruct_args['feeds']; |
| 1360 | $permastruct_args = apply_filters( 'register_post_type_permastruct_args', $permastruct_args, $args, $post_type ); |
1317 | 1361 | add_permastruct( $post_type, "{$args->rewrite['slug']}/%$post_type%", $permastruct_args ); |
1318 | 1362 | } |
1319 | 1363 | |
| 1364 | $args->register_meta_box_cb = apply_filters( 'register_post_type_meta_box_cb', $args->register_meta_box_cb, $args, $post_type ); |
1320 | 1365 | if ( $args->register_meta_box_cb ) |
1321 | 1366 | add_action( 'add_meta_boxes_' . $post_type, $args->register_meta_box_cb, 10, 1 ); |
1322 | 1367 | |
1323 | | $args->labels = get_post_type_labels( $args ); |
| 1368 | $args->labels = get_post_type_labels( apply_filters( 'register_post_type_labels', $args, $post_type ) ); |
1324 | 1369 | $args->label = $args->labels->name; |
1325 | 1370 | |
1326 | 1371 | $wp_post_types[ $post_type ] = $args; |
1327 | 1372 | |
1328 | 1373 | add_action( 'future_' . $post_type, '_future_post_hook', 5, 2 ); |
1329 | 1374 | |
| 1375 | $args->taxonomies = apply_filters( 'register_post_type_taxonomies', $args->taxonomies, $post_type ); |
1330 | 1376 | foreach ( $args->taxonomies as $taxonomy ) { |
1331 | 1377 | register_taxonomy_for_object_type( $taxonomy, $post_type ); |
1332 | 1378 | } |
… |
… |
|
1432 | 1478 | if ( $args->map_meta_cap ) |
1433 | 1479 | _post_type_meta_capabilities( $capabilities ); |
1434 | 1480 | |
1435 | | return (object) $capabilities; |
| 1481 | return (object) apply_filters( 'get_post_type_capabilities', $capabilities, $args ); |
1436 | 1482 | } |
1437 | 1483 | |
1438 | 1484 | /** |