Eliminate use of `extract()` in `wp_update_term()`.
See #22400. Built from https://develop.svn.wordpress.org/trunk@28461 git-svn-id: http://core.svn.wordpress.org/trunk@28288 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
a39aecc9b1
commit
66c3f62a54
|
@ -2888,23 +2888,30 @@ function wp_update_term( $term_id, $taxonomy, $args = array() ) {
|
||||||
$defaults = array( 'alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => '');
|
$defaults = array( 'alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => '');
|
||||||
$args = wp_parse_args($args, $defaults);
|
$args = wp_parse_args($args, $defaults);
|
||||||
$args = sanitize_term($args, $taxonomy, 'db');
|
$args = sanitize_term($args, $taxonomy, 'db');
|
||||||
extract($args, EXTR_SKIP);
|
$parsed_args = $args;
|
||||||
|
|
||||||
// expected_slashed ($name)
|
// expected_slashed ($name)
|
||||||
$name = wp_unslash($name);
|
$name = wp_unslash( $args['name'] );
|
||||||
$description = wp_unslash($description);
|
$description = wp_unslash( $args['description'] );
|
||||||
|
|
||||||
|
$parsed_args['name'] = $name;
|
||||||
|
$parsed_args['description'] = $description;
|
||||||
|
|
||||||
if ( '' == trim($name) )
|
if ( '' == trim($name) )
|
||||||
return new WP_Error('empty_term_name', __('A name is required for this term'));
|
return new WP_Error('empty_term_name', __('A name is required for this term'));
|
||||||
|
|
||||||
$empty_slug = false;
|
$empty_slug = false;
|
||||||
if ( empty($slug) ) {
|
if ( empty( $args['slug'] ) ) {
|
||||||
$empty_slug = true;
|
$empty_slug = true;
|
||||||
$slug = sanitize_title($name);
|
$slug = sanitize_title($name);
|
||||||
|
} else {
|
||||||
|
$slug = $args['slug'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $alias_of ) {
|
$parsed_args['slug'] = $slug;
|
||||||
$alias = $wpdb->get_row( $wpdb->prepare( "SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s", $alias_of) );
|
|
||||||
|
if ( $args['alias_of'] ) {
|
||||||
|
$alias = $wpdb->get_row( $wpdb->prepare( "SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s", $args['alias_of'] ) );
|
||||||
if ( $alias->term_group ) {
|
if ( $alias->term_group ) {
|
||||||
// The alias we want is already in a group, so let's use that one.
|
// The alias we want is already in a group, so let's use that one.
|
||||||
$term_group = $alias->term_group;
|
$term_group = $alias->term_group;
|
||||||
|
@ -2919,6 +2926,8 @@ function wp_update_term( $term_id, $taxonomy, $args = array() ) {
|
||||||
/** This action is documented in wp-includes/taxonomy.php */
|
/** This action is documented in wp-includes/taxonomy.php */
|
||||||
do_action( 'edited_terms', $alias->term_id, $taxonomy );
|
do_action( 'edited_terms', $alias->term_id, $taxonomy );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$parsed_args['term_group'] = $term_group;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2928,13 +2937,13 @@ function wp_update_term( $term_id, $taxonomy, $args = array() ) {
|
||||||
*
|
*
|
||||||
* @since 3.1.0
|
* @since 3.1.0
|
||||||
*
|
*
|
||||||
* @param int $parent ID of the parent term.
|
* @param int $parent ID of the parent term.
|
||||||
* @param int $term_id Term ID.
|
* @param int $term_id Term ID.
|
||||||
* @param string $taxonomy Taxonomy slug.
|
* @param string $taxonomy Taxonomy slug.
|
||||||
* @param array $args Compacted array of update arguments for the given term.
|
* @param array $parsed_args An array of potentially altered update arguments for the given term.
|
||||||
* @param array $args An array of update arguments for the given term.
|
* @param array $args An array of update arguments for the given term.
|
||||||
*/
|
*/
|
||||||
$parent = apply_filters( 'wp_update_term_parent', $parent, $term_id, $taxonomy, compact( array_keys( $args ) ), $args );
|
$parent = apply_filters( 'wp_update_term_parent', $args['parent'], $term_id, $taxonomy, $parsed_args, $args );
|
||||||
|
|
||||||
// Check for duplicate slug
|
// Check for duplicate slug
|
||||||
$id = $wpdb->get_var( $wpdb->prepare( "SELECT term_id FROM $wpdb->terms WHERE slug = %s", $slug ) );
|
$id = $wpdb->get_var( $wpdb->prepare( "SELECT term_id FROM $wpdb->terms WHERE slug = %s", $slug ) );
|
||||||
|
|
Loading…
Reference in New Issue