Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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/branches/3.0@16650 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information...
commit b100afd5103e9a0b0f54e63b7707ff3e4f52db3b 1 parent 9d18117
markjaquith authored
Showing with 4 additions and 1 deletion.
  1. +4 −1 wp-includes/post.php
View
5 wp-includes/post.php
@@ -800,7 +800,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;
@@ -822,6 +822,9 @@ function register_post_type($post_type, $args = array()) {
$post_type = sanitize_user($post_type, true);
$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;

0 comments on commit b100afd

Please sign in to comment.
Something went wrong with that request. Please try again.