[wp-trac] [WordPress Trac] #13709: Post type name should be limited to 20 chars in register_post_type()
WordPress Trac
wp-trac at lists.automattic.com
Thu Jun 3 04:55:23 UTC 2010
#13709: Post type name should be limited to 20 chars in register_post_type()
---------------------------+------------------------------------------------
Reporter: phrostypoison | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Unassigned
Component: Post Types | Version:
Severity: normal | Keywords:
---------------------------+------------------------------------------------
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;
}}}
into
{{{
$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;
}}}
Thank you!
--
Ticket URL: <http://core.trac.wordpress.org/ticket/13709>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list