Skip to content

Commit

Permalink
Use our helper function instead of get_term_by() because the former…
Browse files Browse the repository at this point in the history
… is nicely cached
  • Loading branch information
danielbachhuber committed Jan 3, 2014
1 parent 5d74aee commit 2c34229
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions modules/editorial-metadata/editorial-metadata.php
Expand Up @@ -1239,13 +1239,14 @@ function handle_ajax_inline_save_term() {
}

// Check to ensure a term with the same name doesn't exist,
$search_term = get_term_by( 'name', $metadata_name, self::metadata_taxonomy );
$search_term = $this->get_editorial_metadata_term_by( 'name', $metadata_name );
if ( is_object( $search_term ) && $search_term->term_id != $existing_term->term_id ) {
$change_error = new WP_Error( 'invalid', __( 'Name already in use. Please choose another.', 'edit-flow' ) );
die( $change_error->get_error_message() );
}

// or that the term name doesn't map to an existing term's slug
$search_term = get_term_by( 'slug', sanitize_title( $metadata_name ), self::metadata_taxonomy );
$search_term = $this->get_editorial_metadata_term_by( 'slug', sanitize_title( $metadata_name ) );
if ( is_object( $search_term ) && $search_term->term_id != $existing_term->term_id ) {
$change_error = new WP_Error( 'invalid', __( 'Name conflicts with slug for another term. Please choose again.', 'edit-flow' ) );
die( $change_error->get_error_message() );
Expand Down

0 comments on commit 2c34229

Please sign in to comment.