Validate post type slugs

The post type slug used in register_post_type() must be between 1 and 20 characters.

Valid: short post type slug.

register_post_type( <em>'my_short_slug'</em>, array() );

Invalid: too long post type slug.

register_post_type( <em>'my_own_post_type_too_long'</em>, array() );
The post type slug used in register_post_type() can only contain lowercase alphanumeric characters, dashes and underscores.

Valid: no special characters in post type slug.

register_post_type( <em>'my_post_type_slug'</em>, array() );

Invalid: invalid characters in post type slug.

register_post_type( <em>'my/post/type/slug'</em>, array() );
One should be careful with passing dynamic slug names to "register_post_type()", as the slug may become too long and could contain invalid characters.

Valid: static post type slug.

register_post_type( <em>'my_post_active'</em>, array() );

Invalid: dynamic post type slug.

register_post_type( <em>"my_post_{$status}"</em>, array() );
The post type slug used in register_post_type() can not use reserved keywords, such as the ones used by WordPress itself.

Valid: prefixed post slug.

register_post_type( <em>'prefixed_author'</em>, array() );

Invalid: using a reserved keyword as slug.

register_post_type( <em>'author'</em>, array() );
The post type slug used in register_post_type() can not use reserved prefixes, such as 'wp_', which is used by WordPress itself.

Valid: custom prefix post slug.

register_post_type( <em>'prefixed_author'</em>, array() );

Invalid: using a reserved prefix.

register_post_type( <em>'wp_author'</em>, array() );