#31073 closed enhancement (duplicate)
Add new filter on function register_post_type
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | 4.1 |
| Component: | Posts, Post Types | Keywords: | |
| Focuses: | Cc: |
Description
Hi guys, i'm implementing a plugin for rewriting post slugs.
i noticed that reading the source code of the register_post_type function, there is no filter before the args are parsed. It could be usefull to have the filter to modify some custom post types on the fly. The 'registered_post_type' filter act only after the permastruct and the rewrite rules are done.
So for example you could act as above inside the register_post_type function:
if ( strlen( $post_type ) > 20 ) {
_doing_it_wrong( __FUNCTION__, __( 'Post types cannot exceed 20 characters in length' ), '4.0' );
return new WP_Error( 'post_type_too_long', __( 'Post types cannot exceed 20 characters in length' ) );
}
apply_filters( "registering_post_type", $post_type, $args);
// If not set, default to the setting for public.
if ( null === $args->publicly_queryable )
$args->publicly_queryable = $args->public;
Change History (2)
Note: See
TracTickets for help on using
tickets.
FIY
the filter needs to return the $args modified;
so the correct line is