Post type name should be limited to 20 chars in register_post_type()
|Reported by:||phrostypoison||Owned by:|
I was in the process of making a plugin for WordPress 3.0 that utilizes a custom post_type with the name 'designtags_stylesheet', but when I activated the plugin, although the UI would show up properly, the publish button showed 'Submit for Review' instead of the usual 'publish'. Furthermore, if I do click on the button, WordPress spits out an error and does nothing.
The same situation didn't occur with kovshenin.org's Podcasts post_type plugin example (see http://kovshenin.com/archives/extending-custom-post-types-in-wordpress-3-0/).
It turns out the cause of the problem was the length of the post_type name. After looking into the database schema of the wp_posts table, the post_type column has a 20-character limit. 'designtags_stylesheet' is more than 20 chars long, so WordPress refuses to publish.
If the post_type column is to stay as a varchar(20) after custom post_type support, register_post_type() should spit an error if a plugin attempts to register a post_type that has a name over 20 chars long.
Maybe change these lines
$post_type = sanitize_user($post_type, true); $args->name = $post_type;
$post_type = sanitize_user($post_type, true); if ( strlen($post_type) > 20) return new WP_Error('invalid_post_type', __('Invalid post type name.')); $args->name = $post_type;