[wp-trac] [WordPress Trac] #31073: Add new filter on function register_post_type

WordPress Trac noreply at wordpress.org
Tue Jan 20 12:32:53 UTC 2015


#31073: Add new filter on function register_post_type
-----------------------------+-----------------------------
 Reporter:  teolaz           |      Owner:
     Type:  feature request  |     Status:  new
 Priority:  normal           |  Milestone:  Awaiting Review
Component:  General          |    Version:  4.1
 Severity:  normal           |   Keywords:
  Focuses:                   |
-----------------------------+-----------------------------
 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;

 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/31073>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list