Changeset 45710
- Timestamp:
- 08/01/2019 01:44:04 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/taxonomy.php
r45702 r45710 194 194 global $wp_taxonomies; 195 195 196 $field = ( 'names' == $output ) ? 'name' : false;196 $field = ( 'names' === $output ) ? 'name' : false; 197 197 198 198 return wp_filter_object_list( $wp_taxonomies, $args, $operator, $field ); … … 224 224 225 225 if ( is_object( $object ) ) { 226 if ( $object->post_type == 'attachment' ) {226 if ( $object->post_type === 'attachment' ) { 227 227 return get_attachment_taxonomies( $object, $output ); 228 228 } … … 235 235 foreach ( (array) $wp_taxonomies as $tax_name => $tax_obj ) { 236 236 if ( array_intersect( $object, (array) $tax_obj->object_type ) ) { 237 if ( 'names' == $output ) {237 if ( 'names' === $output ) { 238 238 $taxonomies[] = $tax_name; 239 239 } else { … … 726 726 $args = wp_parse_args( $args, $defaults ); 727 727 728 $order = ( 'desc' == strtolower( $args['order'] ) ) ? 'DESC' : 'ASC';728 $order = ( 'desc' === strtolower( $args['order'] ) ) ? 'DESC' : 'ASC'; 729 729 730 730 $term_ids = array_map( 'intval', $term_ids ); … … 877 877 $_term->filter( $filter ); 878 878 879 if ( $output == ARRAY_A ) {879 if ( $output === ARRAY_A ) { 880 880 return $_term->to_array(); 881 } elseif ( $output == ARRAY_N ) {881 } elseif ( $output === ARRAY_N ) { 882 882 return array_values( $_term->to_array() ); 883 883 } … … 1015 1015 1016 1016 foreach ( (array) $terms[ $term_id ] as $child ) { 1017 if ( $term_id == $child ) {1017 if ( $term_id === $child ) { 1018 1018 continue; 1019 1019 } … … 1372 1372 1373 1373 if ( is_int( $term ) ) { 1374 if ( 0 == $term ) {1374 if ( 0 === $term ) { 1375 1375 return 0; 1376 1376 } … … 1446 1446 return false; 1447 1447 } 1448 if ( $term2->parent == $term1->term_id ) {1448 if ( $term2->parent === $term1->term_id ) { 1449 1449 return true; 1450 1450 } … … 1530 1530 } 1531 1531 1532 if ( 'raw' == $context ) { 1532 $context = strtolower( $context ); 1533 1534 if ( 'raw' === $context ) { 1533 1535 return $value; 1534 1536 } 1535 1537 1536 if ( 'edit' == $context ) {1538 if ( 'edit' === $context ) { 1537 1539 1538 1540 /** … … 1562 1564 $value = apply_filters( "edit_{$taxonomy}_{$field}", $value, $term_id ); 1563 1565 1564 if ( 'description' == $field ) {1566 if ( 'description' === $field ) { 1565 1567 $value = esc_html( $value ); // textarea_escaped 1566 1568 } else { 1567 1569 $value = esc_attr( $value ); 1568 1570 } 1569 } elseif ( 'db' == $context ) {1571 } elseif ( 'db' === $context ) { 1570 1572 1571 1573 /** … … 1594 1596 1595 1597 // Back compat filters 1596 if ( 'slug' == $field ) {1598 if ( 'slug' === $field ) { 1597 1599 /** 1598 1600 * Filters the category nicename before it is sanitized. … … 1606 1608 $value = apply_filters( 'pre_category_nicename', $value ); 1607 1609 } 1608 } elseif ( 'rss' == $context ) {1610 } elseif ( 'rss' === $context ) { 1609 1611 1610 1612 /** … … 1663 1665 } 1664 1666 1665 if ( 'attribute' == $context ) {1667 if ( 'attribute' === $context ) { 1666 1668 $value = esc_attr( $value ); 1667 } elseif ( 'js' == $context ) {1669 } elseif ( 'js' === $context ) { 1668 1670 $value = esc_js( $value ); 1669 1671 } … … 1768 1770 $defaults = array(); 1769 1771 1770 if ( 'category' == $taxonomy ) {1772 if ( 'category' === $taxonomy ) { 1771 1773 $defaults['default'] = get_option( 'default_category' ); 1772 if ( $defaults['default'] == $term ) {1774 if ( $defaults['default'] === $term ) { 1773 1775 return 0; // Don't delete the default category 1774 1776 } … … 1848 1850 ) 1849 1851 ); 1850 if ( 1 == count( $terms ) && isset( $default ) ) {1852 if ( 1 === count( $terms ) && isset( $default ) ) { 1851 1853 $terms = array( $default ); 1852 1854 } else { … … 2124 2126 return $term; 2125 2127 } 2126 if ( is_int( $term ) && 0 == $term ) {2128 if ( is_int( $term ) && 0 === $term ) { 2127 2129 return new WP_Error( 'invalid_term_id', __( 'Invalid term ID.' ) ); 2128 2130 } 2129 if ( '' == trim( $term ) ) {2131 if ( '' === trim( $term ) ) { 2130 2132 return new WP_Error( 'empty_term_name', __( 'A name is required for this term.' ) ); 2131 2133 } … … 2451 2453 2452 2454 foreach ( (array) $terms as $term ) { 2453 if ( ! strlen( trim( $term )) ) {2455 if ( '' === trim( $term ) ) { 2454 2456 continue; 2455 2457 } … … 2611 2613 2612 2614 foreach ( (array) $terms as $term ) { 2613 if ( ! strlen( trim( $term )) ) {2615 if ( '' === trim( $term ) ) { 2614 2616 continue; 2615 2617 } … … 2847 2849 $parsed_args['description'] = $description; 2848 2850 2849 if ( '' == trim( $name ) ) {2851 if ( '' === trim( $name ) ) { 2850 2852 return new WP_Error( 'empty_term_name', __( 'A name is required for this term.' ) ); 2851 2853 } … … 2903 2905 * @param array $args An array of update arguments for the given term. 2904 2906 */ 2905 $parent = apply_filters( 'wp_update_term_parent', $args['parent'], $term_id, $taxonomy, $parsed_args, $args );2907 $parent = (int) apply_filters( 'wp_update_term_parent', $args['parent'], $term_id, $taxonomy, $parsed_args, $args ); 2906 2908 2907 2909 // Check for duplicate slug 2908 2910 $duplicate = get_term_by( 'slug', $slug, $taxonomy ); 2909 if ( $duplicate && $duplicate->term_id != $term_id ) {2911 if ( $duplicate && $duplicate->term_id !== $term_id ) { 2910 2912 // If an empty slug was passed or the parent changed, reset the slug to something unique. 2911 2913 // Otherwise, bail. 2912 if ( $empty_slug || ( $parent != $term['parent'] ) ) {2914 if ( $empty_slug || ( $parent !== (int) $term['parent'] ) ) { 2913 2915 $slug = wp_unique_term_slug( $slug, (object) $args ); 2914 2916 } else { … … 3512 3514 } 3513 3515 3516 $term_id = (int) $term_id; 3514 3517 $term_list = array(); 3515 3518 $has_children = _get_term_hierarchy( $taxonomy ); 3516 3519 3517 if ( ( 0 != $term_id )&& ! isset( $has_children[ $term_id ] ) ) {3520 if ( $term_id && ! isset( $has_children[ $term_id ] ) ) { 3518 3521 return $empty_array; 3519 3522 } … … 3539 3542 } 3540 3543 3541 if ( $term->parent == $term_id ) {3544 if ( $term->parent === $term_id ) { 3542 3545 if ( $use_id ) { 3543 3546 $term_list[] = $term->term_id; … … 3786 3789 3787 3790 // If there are no shared term_taxonomy rows, there's nothing to do here. 3788 $shared_tt_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_taxonomy tt WHERE tt.term_id = %d AND tt.term_taxonomy_id != %d", $term_id, $term_taxonomy_id ) );3791 $shared_tt_count = (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_taxonomy tt WHERE tt.term_id = %d AND tt.term_taxonomy_id != %d", $term_id, $term_taxonomy_id ) ); 3789 3792 3790 3793 if ( ! $shared_tt_count ) { … … 3796 3799 * If there's a mismatch, it may mean that the term is already split. Return the actual term_id from the db. 3797 3800 */ 3798 $check_term_id = $wpdb->get_var( $wpdb->prepare( "SELECT term_id FROM $wpdb->term_taxonomy WHERE term_taxonomy_id = %d", $term_taxonomy_id ) );3799 if ( $check_term_id != $term_id ) {3801 $check_term_id = (int) $wpdb->get_var( $wpdb->prepare( "SELECT term_id FROM $wpdb->term_taxonomy WHERE term_taxonomy_id = %d", $term_taxonomy_id ) ); 3802 if ( $check_term_id !== $term_id ) { 3800 3803 return $check_term_id; 3801 3804 } … … 4020 4023 */ 4021 4024 function _wp_check_split_default_terms( $term_id, $new_term_id, $term_taxonomy_id, $taxonomy ) { 4022 if ( 'category' != $taxonomy ) {4025 if ( 'category' !== $taxonomy ) { 4023 4026 return; 4024 4027 } 4025 4028 4026 4029 foreach ( array( 'default_category', 'default_link_category', 'default_email_category' ) as $option ) { 4027 if ( $term_id == get_option( $option, -1 ) ) {4030 if ( $term_id === (int) get_option( $option, -1 ) ) { 4028 4031 update_option( $option, $new_term_id ); 4029 4032 } … … 4086 4089 $locations = get_nav_menu_locations(); 4087 4090 foreach ( $locations as $location => $menu_id ) { 4088 if ( $term_id == $menu_id ) {4091 if ( $term_id === $menu_id ) { 4089 4092 $locations[ $location ] = $new_term_id; 4090 4093 } … … 4206 4209 4207 4210 if ( empty( $termlink ) ) { 4208 if ( 'category' == $taxonomy ) {4211 if ( 'category' === $taxonomy ) { 4209 4212 $termlink = '?cat=' . $term->term_id; 4210 4213 } elseif ( $t->query_var ) { … … 4231 4234 } 4232 4235 // Back Compat filters. 4233 if ( 'post_tag' == $taxonomy ) {4236 if ( 'post_tag' === $taxonomy ) { 4234 4237 4235 4238 /** … … 4243 4246 */ 4244 4247 $termlink = apply_filters( 'tag_link', $termlink, $term->term_id ); 4245 } elseif ( 'category' == $taxonomy ) {4248 } elseif ( 'category' === $taxonomy ) { 4246 4249 4247 4250 /** … … 4568 4571 4569 4572 // Can't be its own parent. 4570 if ( $parent == $term_id ) {4573 if ( $parent === $term_id ) { 4571 4574 return 0; 4572 4575 }
Note: See TracChangeset
for help on using the changeset viewer.