Return a WP_Error if an empty name is provided when registering a post type.

Fixes #31134
Props tyxla, MikeHansenMe

Built from https://develop.svn.wordpress.org/trunk@31450


git-svn-id: http://core.svn.wordpress.org/trunk@31431 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
John Blackbourn 2015-02-13 16:43:26 +00:00
parent 948f657ea3
commit 7520057038
2 changed files with 4 additions and 4 deletions

View File

@ -1342,9 +1342,9 @@ function register_post_type( $post_type, $args = array() ) {
$post_type = sanitize_key( $post_type );
$args->name = $post_type;
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' ) );
if ( empty( $post_type ) || strlen( $post_type ) > 20 ) {
_doing_it_wrong( __FUNCTION__, __( 'Post type names must be between 1 and 20 characters in length.' ), '4.2' );
return new WP_Error( 'post_type_length_invalid', __( 'Post type names must be between 1 and 20 characters in length.' ) );
}
// If not set, default to the setting for public.

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.2-alpha-31449';
$wp_version = '4.2-alpha-31450';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.