From 5b37b224f87f74f8f03371cc39de35764afbc1f4 Mon Sep 17 00:00:00 2001 From: markjaquith Date: Wed, 1 Dec 2010 20:43:39 +0000 Subject: [PATCH] Throw WP_Error if post_type passed to register_post_type() is longer than schema allows. props phrostypoison. fixes #13709 git-svn-id: http://svn.automattic.com/wordpress/trunk@16670 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/post.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/wp-includes/post.php b/wp-includes/post.php index e80250deb9..100ef7aa16 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -884,7 +884,7 @@ function get_post_types( $args = array(), $output = 'names', $operator = 'and' ) * * @param string $post_type Name of the post type. * @param array|string $args See above description. - * @return object the registered post type object + * @return object|WP_Error the registered post type object, or an error object */ function register_post_type($post_type, $args = array()) { global $wp_post_types, $wp_rewrite, $wp; @@ -908,6 +908,9 @@ function register_post_type($post_type, $args = array()) { $post_type = sanitize_key($post_type); $args->name = $post_type; + if ( strlen( $post_type ) > 20 ) + return new WP_Error( 'post_type_too_long', __( 'Post types cannot exceed 20 characters in length' ) ); + // If not set, default to the setting for public. if ( null === $args->publicly_queryable ) $args->publicly_queryable = $args->public;