Add `register_post_type_args` filter for changing `register_post_type()` arguments before further processing.
Does not apply to built-in post types. Props MikeSchinkel, nickciske, engelen, swissspidy. Fixes #17447. Built from https://develop.svn.wordpress.org/trunk@34242 git-svn-id: http://core.svn.wordpress.org/trunk@34206 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
1e3807c10d
commit
dd11460efa
|
@ -984,8 +984,26 @@ function get_post_types( $args = array(), $output = 'names', $operator = 'and' )
|
|||
function register_post_type( $post_type, $args = array() ) {
|
||||
global $wp_post_types, $wp_rewrite, $wp;
|
||||
|
||||
if ( ! is_array( $wp_post_types ) )
|
||||
if ( ! is_array( $wp_post_types ) ) {
|
||||
$wp_post_types = array();
|
||||
}
|
||||
|
||||
// Sanitize post type name
|
||||
$post_type = sanitize_key( $post_type );
|
||||
|
||||
if ( empty( $args['_builtin'] ) ) {
|
||||
/**
|
||||
* Filter the arguments for registering a post type.
|
||||
*
|
||||
* Not available for built-in post types.
|
||||
*
|
||||
* @since 4.4.0
|
||||
*
|
||||
* @param array|string $args Array or string of arguments for registering a post type.
|
||||
* @param string $post_type Post type key.
|
||||
*/
|
||||
$args = apply_filters( 'register_post_type_args', $args, $post_type );
|
||||
}
|
||||
|
||||
// Args prefixed with an underscore are reserved for internal use.
|
||||
$defaults = array(
|
||||
|
@ -1018,7 +1036,6 @@ function register_post_type( $post_type, $args = array() ) {
|
|||
$args = wp_parse_args( $args, $defaults );
|
||||
$args = (object) $args;
|
||||
|
||||
$post_type = sanitize_key( $post_type );
|
||||
$args->name = $post_type;
|
||||
|
||||
if ( empty( $post_type ) || strlen( $post_type ) > 20 ) {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.4-alpha-34241';
|
||||
$wp_version = '4.4-alpha-34242';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue