IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
|
|
|
253 | 253 | $query['child_of'] = false; |
254 | 254 | } |
255 | 255 | |
| 256 | // If importing, change cache domain, so all calls are uncached. |
| 257 | if ( defined( 'WP_IMPORTING' ) ) { |
| 258 | $query['cache_domain'] = microtime( true ); |
| 259 | } |
| 260 | |
256 | 261 | if ( 'all' == $query['get'] ) { |
257 | 262 | $query['childless'] = false; |
258 | 263 | $query['child_of'] = 0; |
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
|
|
|
1354 | 1354 | * |
1355 | 1355 | * @since 3.0.0 |
1356 | 1356 | * |
1357 | | * @global wpdb $wpdb WordPress database abstraction object. |
1358 | 1357 | * |
1359 | 1358 | * @param int|string $term The term to check. Accepts term ID, slug, or name. |
1360 | 1359 | * @param string $taxonomy The taxonomy name to use |
… |
… |
|
1365 | 1364 | * is specified and the pairing exists. |
1366 | 1365 | */ |
1367 | 1366 | function term_exists( $term, $taxonomy = '', $parent = null ) { |
1368 | | global $wpdb; |
1369 | | |
1370 | | $select = "SELECT term_id FROM $wpdb->terms as t WHERE "; |
1371 | | $tax_select = "SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE "; |
1372 | | |
1373 | 1367 | if ( is_int( $term ) ) { |
1374 | 1368 | if ( 0 == $term ) { |
1375 | 1369 | return 0; |
1376 | 1370 | } |
1377 | | $where = 't.term_id = %d'; |
| 1371 | $_term = get_term( $term, $taxonomy ); |
| 1372 | if ( is_wp_error( $_term ) || is_null( $_term ) ) { |
| 1373 | return null; |
| 1374 | } |
1378 | 1375 | if ( ! empty( $taxonomy ) ) { |
1379 | | return $wpdb->get_row( $wpdb->prepare( $tax_select . $where . ' AND tt.taxonomy = %s', $term, $taxonomy ), ARRAY_A ); |
1380 | | } else { |
1381 | | return $wpdb->get_var( $wpdb->prepare( $select . $where, $term ) ); |
| 1376 | return array( |
| 1377 | 'term_id' => (string) $_term->term_id, |
| 1378 | 'term_taxonomy_id' => (string) $_term->term_taxonomy_id, |
| 1379 | ); |
1382 | 1380 | } |
| 1381 | return (string) $_term->term_id; |
1383 | 1382 | } |
1384 | 1383 | |
1385 | 1384 | $term = trim( wp_unslash( $term ) ); |
1386 | | $slug = sanitize_title( $term ); |
| 1385 | if ( empty( $term ) ) { |
| 1386 | return null; |
| 1387 | } |
1387 | 1388 | |
1388 | | $where = 't.slug = %s'; |
1389 | | $else_where = 't.name = %s'; |
1390 | | $where_fields = array( $slug ); |
1391 | | $else_where_fields = array( $term ); |
1392 | | $orderby = 'ORDER BY t.term_id ASC'; |
1393 | | $limit = 'LIMIT 1'; |
| 1389 | $defaults = array( |
| 1390 | 'get' => 'all', |
| 1391 | 'hide_empty' => false, |
| 1392 | 'number' => 1, |
| 1393 | 'update_term_meta_cache' => false, |
| 1394 | 'orderby' => 'term_id', |
| 1395 | 'suppress_filter' => true, |
| 1396 | ); |
| 1397 | |
| 1398 | if ( is_numeric( $parent ) ) { |
| 1399 | $defaults['parent'] = (int) $parent; |
| 1400 | } |
1394 | 1401 | if ( ! empty( $taxonomy ) ) { |
1395 | | if ( is_numeric( $parent ) ) { |
1396 | | $parent = (int) $parent; |
1397 | | $where_fields[] = $parent; |
1398 | | $else_where_fields[] = $parent; |
1399 | | $where .= ' AND tt.parent = %d'; |
1400 | | $else_where .= ' AND tt.parent = %d'; |
1401 | | } |
1402 | | |
1403 | | $where_fields[] = $taxonomy; |
1404 | | $else_where_fields[] = $taxonomy; |
1405 | | |
1406 | | if ( $result = $wpdb->get_row( $wpdb->prepare( "SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = %s $orderby $limit", $where_fields ), ARRAY_A ) ) { |
1407 | | return $result; |
| 1402 | $defaults['taxonomy'] = $taxonomy; |
| 1403 | } |
| 1404 | $args = wp_parse_args( array( 'slug' => $term ), $defaults ); |
| 1405 | $terms = get_terms( $args ); |
| 1406 | if ( empty( $terms ) || is_wp_error( $terms ) ) { |
| 1407 | $args = wp_parse_args( array( 'name' => $term ), $defaults ); |
| 1408 | $terms = get_terms( $args ); |
| 1409 | if ( empty( $terms ) || is_wp_error( $terms ) ) { |
| 1410 | return null; |
1408 | 1411 | } |
1409 | | |
1410 | | return $wpdb->get_row( $wpdb->prepare( "SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $else_where AND tt.taxonomy = %s $orderby $limit", $else_where_fields ), ARRAY_A ); |
1411 | 1412 | } |
| 1413 | $_term = array_shift( $terms ); |
1412 | 1414 | |
1413 | | if ( $result = $wpdb->get_var( $wpdb->prepare( "SELECT term_id FROM $wpdb->terms as t WHERE $where $orderby $limit", $where_fields ) ) ) { |
1414 | | return $result; |
| 1415 | if ( ! empty( $taxonomy ) ) { |
| 1416 | return array( |
| 1417 | 'term_id' => (string) $_term->term_id, |
| 1418 | 'term_taxonomy_id' => (string) $_term->term_taxonomy_id, |
| 1419 | ); |
1415 | 1420 | } |
1416 | 1421 | |
1417 | | return $wpdb->get_var( $wpdb->prepare( "SELECT term_id FROM $wpdb->terms as t WHERE $else_where $orderby $limit", $else_where_fields ) ); |
| 1422 | return (string) $_term->term_id; |
1418 | 1423 | } |
1419 | 1424 | |
1420 | 1425 | /** |
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
|
|
|
31 | 31 | array( '%d' ) |
32 | 32 | ); |
33 | 33 | |
| 34 | clean_term_cache( $t1['term_id'], 'wptests_tax' ); |
| 35 | |
34 | 36 | return array( |
35 | 37 | array( |
36 | 38 | 'term_id' => $t1['term_id'], |
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
|
|
|
447 | 447 | $wpdb->update( $wpdb->term_taxonomy, array( 'term_taxonomy_id' => 100006 ), array( 'term_taxonomy_id' => $term_2->term_taxonomy_id ) ); |
448 | 448 | $wpdb->update( $wpdb->term_taxonomy, array( 'term_taxonomy_id' => 100005 ), array( 'term_taxonomy_id' => $term_3->term_taxonomy_id ) ); |
449 | 449 | |
| 450 | // After update, clear caches. |
| 451 | clean_term_cache( array( $term_1->term_id, $term_2->term_id, $term_3->term_id ), $this->taxonomy ); |
| 452 | |
450 | 453 | $set = wp_set_object_terms( $p, array( $t1, $t2, $t3 ), $this->taxonomy ); |
451 | 454 | |
452 | 455 | $found = wp_get_object_terms( |