Make WordPress Core

Ticket #31135: 31135.patch

File 31135.patch, 1.1 KB (added by tyxla, 10 years ago)

Adding a _doing_it_wrong() when register_taxonomy() is called with an empty taxonomy name.

  • src/wp-includes/taxonomy.php

     
    341341        );
    342342        $args = wp_parse_args( $args, $defaults );
    343343
    344         if ( strlen( $taxonomy ) > 32 ) {
    345                 _doing_it_wrong( __FUNCTION__, __( 'Taxonomies cannot exceed 32 characters in length' ), '4.0' );
    346                 return new WP_Error( 'taxonomy_too_long', __( 'Taxonomies cannot exceed 32 characters in length' ) );
     344        $taxonomy_length = strlen( $taxonomy );
     345        if ( $taxonomy_length > 32 ) {
     346                _doing_it_wrong( __FUNCTION__, __( 'Taxonomies cannot exceed 32 characters in length.' ), '4.0' );
     347                return new WP_Error( 'taxonomy_too_long', __( 'Taxonomies cannot exceed 32 characters in length.' ) );
     348        } elseif ( $taxonomy_length === 0 ) {
     349                _doing_it_wrong( __FUNCTION__, __( 'Cannot register a taxonomy with an empty name.' ), '4.2' );
     350                return new WP_Error( 'taxonomy_empty_name', __( 'Cannot register a taxonomy with an empty name.' ) );
    347351        }
    348352
    349353        if ( false !== $args['query_var'] && ! empty( $wp ) ) {