From 00678ab0df0ad8b8bc750d5b9633703ffd972132 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sun, 29 Jun 2014 21:53:35 +0000 Subject: [PATCH] Notify developers when register_post_type() or register_taxonomy() fails because of post type or taxonomy key length. props mattheweppelsheimer. fixes #28683. git-svn-id: https://develop.svn.wordpress.org/trunk@28902 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/post.php | 4 +++- src/wp-includes/taxonomy.php | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php index 9194c78df7..669026ecf0 100644 --- a/src/wp-includes/post.php +++ b/src/wp-includes/post.php @@ -1243,8 +1243,10 @@ function register_post_type( $post_type, $args = array() ) { $post_type = sanitize_key( $post_type ); $args->name = $post_type; - if ( strlen( $post_type ) > 20 ) + 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 not set, default to the setting for public. if ( null === $args->publicly_queryable ) diff --git a/src/wp-includes/taxonomy.php b/src/wp-includes/taxonomy.php index 1f91f27def..426e8decce 100644 --- a/src/wp-includes/taxonomy.php +++ b/src/wp-includes/taxonomy.php @@ -346,8 +346,10 @@ function register_taxonomy( $taxonomy, $object_type, $args = array() ) { ); $args = wp_parse_args( $args, $defaults ); - if ( strlen( $taxonomy ) > 32 ) + if ( strlen( $taxonomy ) > 32 ) { + _doing_it_wrong( __FUNCTION__, __( 'Taxonomies cannot exceed 32 characters in length' ), '4.0' ); return new WP_Error( 'taxonomy_too_long', __( 'Taxonomies cannot exceed 32 characters in length' ) ); + } if ( false !== $args['query_var'] && ! empty( $wp ) ) { if ( true === $args['query_var'] )