Ticket #47573: 47573.diff
| File 47573.diff, 8.8 KB (added by , 7 years ago) |
|---|
-
src/wp-includes/taxonomy.php
193 193 function get_taxonomies( $args = array(), $output = 'names', $operator = 'and' ) { 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 ); 199 199 } … … 223 223 global $wp_taxonomies; 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 } 229 229 $object = $object->post_type; … … 234 234 $taxonomies = array(); 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 { 240 240 $taxonomies[ $tax_name ] = $tax_obj; … … 725 725 $defaults = array( 'order' => 'ASC' ); 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 ); 731 731 … … 876 876 // Sanitize term, according to the specified filter. 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 } 884 884 … … 1014 1014 $children = $terms[ $term_id ]; 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 } 1020 1020 … … 1371 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 1372 1373 1373 if ( is_int( $term ) ) { 1374 if ( 0 == $term ) {1374 if ( 0 === $term ) { 1375 1375 return 0; 1376 1376 } 1377 1377 $where = 't.term_id = %d'; … … 1440 1440 if ( empty( $term1->term_id ) || empty( $term2->parent ) ) { 1441 1441 return false; 1442 1442 } 1443 if ( $term2->parent == $term1->term_id ) {1443 if ( $term2->parent === $term1->term_id ) { 1444 1444 return true; 1445 1445 } 1446 1446 … … 1517 1517 */ 1518 1518 function sanitize_term_field( $field, $value, $term_id, $taxonomy, $context ) { 1519 1519 $int_fields = array( 'parent', 'term_id', 'count', 'term_group', 'term_taxonomy_id', 'object_id' ); 1520 $context = strtolower( $context ); 1520 1521 if ( in_array( $field, $int_fields ) ) { 1521 1522 $value = (int) $value; 1522 1523 if ( $value < 0 ) { … … 1524 1525 } 1525 1526 } 1526 1527 1527 if ( 'raw' == $context ) {1528 if ( 'raw' === $context ) { 1528 1529 return $value; 1529 1530 } 1530 1531 1531 if ( 'edit' == $context ) {1532 if ( 'edit' === $context ) { 1532 1533 1533 1534 /** 1534 1535 * Filters a term field to edit before it is sanitized. … … 1556 1557 */ 1557 1558 $value = apply_filters( "edit_{$taxonomy}_{$field}", $value, $term_id ); 1558 1559 1559 if ( 'description' == $field ) {1560 if ( 'description' === $field ) { 1560 1561 $value = esc_html( $value ); // textarea_escaped 1561 1562 } else { 1562 1563 $value = esc_attr( $value ); 1563 1564 } 1564 } elseif ( 'db' == $context ) {1565 } elseif ( 'db' === $context ) { 1565 1566 1566 1567 /** 1567 1568 * Filters a term field value before it is sanitized. … … 1588 1589 $value = apply_filters( "pre_{$taxonomy}_{$field}", $value ); 1589 1590 1590 1591 // Back compat filters 1591 if ( 'slug' == $field ) {1592 if ( 'slug' === $field ) { 1592 1593 /** 1593 1594 * Filters the category nicename before it is sanitized. 1594 1595 * … … 1600 1601 */ 1601 1602 $value = apply_filters( 'pre_category_nicename', $value ); 1602 1603 } 1603 } elseif ( 'rss' == $context ) {1604 } elseif ( 'rss' === $context ) { 1604 1605 1605 1606 /** 1606 1607 * Filters the term field for use in RSS. … … 1657 1658 $value = apply_filters( "{$taxonomy}_{$field}", $value, $term_id, $context ); 1658 1659 } 1659 1660 1660 if ( 'attribute' == $context ) {1661 if ( 'attribute' === $context ) { 1661 1662 $value = esc_attr( $value ); 1662 } elseif ( 'js' == $context ) {1663 } elseif ( 'js' === $context ) { 1663 1664 $value = esc_js( $value ); 1664 1665 } 1665 1666 return $value; … … 1761 1762 1762 1763 $defaults = array(); 1763 1764 1764 if ( 'category' == $taxonomy ) {1765 if ( 'category' === $taxonomy ) { 1765 1766 $defaults['default'] = get_option( 'default_category' ); 1766 if ( $defaults['default'] == $term ) {1767 if ( $defaults['default'] === $term ) { 1767 1768 return 0; // Don't delete the default category 1768 1769 } 1769 1770 } … … 1841 1842 'orderby' => 'none', 1842 1843 ) 1843 1844 ); 1844 if ( 1 == count( $terms ) && isset( $default ) ) {1845 if ( 1 === count( $terms ) && isset( $default ) ) { 1845 1846 $terms = array( $default ); 1846 1847 } else { 1847 1848 $terms = array_diff( $terms, array( $term ) ); … … 2117 2118 if ( is_wp_error( $term ) ) { 2118 2119 return $term; 2119 2120 } 2120 if ( is_int( $term ) && 0 == $term ) {2121 if ( is_int( $term ) && 0 === $term ) { 2121 2122 return new WP_Error( 'invalid_term_id', __( 'Invalid term ID.' ) ); 2122 2123 } 2123 if ( '' == trim( $term ) ) {2124 if ( '' === trim( $term ) ) { 2124 2125 return new WP_Error( 'empty_term_name', __( 'A name is required for this term.' ) ); 2125 2126 } 2126 2127 $defaults = array( … … 2444 2445 $new_tt_ids = array(); 2445 2446 2446 2447 foreach ( (array) $terms as $term ) { 2447 if ( ! strlen( trim( $term )) ) {2448 if ( '' === trim( $term ) ) { 2448 2449 continue; 2449 2450 } 2450 2451 … … 2603 2604 $tt_ids = array(); 2604 2605 2605 2606 foreach ( (array) $terms as $term ) { 2606 if ( ! strlen( trim( $term )) ) {2607 if ( '' === trim( $term ) ) { 2607 2608 continue; 2608 2609 } 2609 2610 … … 2838 2839 $parsed_args['name'] = $name; 2839 2840 $parsed_args['description'] = $description; 2840 2841 2841 if ( '' == trim( $name ) ) {2842 if ( '' === trim( $name ) ) { 2842 2843 return new WP_Error( 'empty_term_name', __( 'A name is required for this term.' ) ); 2843 2844 } 2844 2845 … … 2898 2899 2899 2900 // Check for duplicate slug 2900 2901 $duplicate = get_term_by( 'slug', $slug, $taxonomy ); 2901 if ( $duplicate && $duplicate->term_id != $term_id ) {2902 if ( $duplicate && $duplicate->term_id !== $term_id ) { 2902 2903 // If an empty slug was passed or the parent changed, reset the slug to something unique. 2903 2904 // Otherwise, bail. 2904 if ( $empty_slug || ( $parent != $term['parent'] ) ) {2905 if ( $empty_slug || ( $parent !== $term['parent'] ) ) { 2905 2906 $slug = wp_unique_term_slug( $slug, (object) $args ); 2906 2907 } else { 2907 2908 /* translators: %s: taxonomy term slug */ … … 3506 3507 $term_list = array(); 3507 3508 $has_children = _get_term_hierarchy( $taxonomy ); 3508 3509 3509 if ( ( 0 != $term_id ) && ! isset( $has_children[ $term_id ] ) ) {3510 if ( ( 0 !== $term_id ) && ! isset( $has_children[ $term_id ] ) ) { 3510 3511 return $empty_array; 3511 3512 } 3512 3513 … … 3530 3531 continue; 3531 3532 } 3532 3533 3533 if ( $term->parent == $term_id ) {3534 if ( $term->parent === $term_id ) { 3534 3535 if ( $use_id ) { 3535 3536 $term_list[] = $term->term_id; 3536 3537 } else { … … 3785 3786 * If there's a mismatch, it may mean that the term is already split. Return the actual term_id from the db. 3786 3787 */ 3787 3788 $check_term_id = $wpdb->get_var( $wpdb->prepare( "SELECT term_id FROM $wpdb->term_taxonomy WHERE term_taxonomy_id = %d", $term_taxonomy_id ) ); 3788 if ( $check_term_id != $term_id ) {3789 if ( $check_term_id !== $term_id ) { 3789 3790 return $check_term_id; 3790 3791 } 3791 3792 … … 4007 4008 * @param string $taxonomy Taxonomy for the split term. 4008 4009 */ 4009 4010 function _wp_check_split_default_terms( $term_id, $new_term_id, $term_taxonomy_id, $taxonomy ) { 4010 if ( 'category' != $taxonomy ) {4011 if ( 'category' !== $taxonomy ) { 4011 4012 return; 4012 4013 } 4013 4014 4014 4015 foreach ( array( 'default_category', 'default_link_category', 'default_email_category' ) as $option ) { 4015 if ( $term_id == get_option( $option, -1 ) ) {4016 if ( $term_id === get_option( $option, -1 ) ) { 4016 4017 update_option( $option, $new_term_id ); 4017 4018 } 4018 4019 } … … 4073 4074 // Update menu locations. 4074 4075 $locations = get_nav_menu_locations(); 4075 4076 foreach ( $locations as $location => $menu_id ) { 4076 if ( $term_id == $menu_id ) {4077 if ( $term_id === $menu_id ) { 4077 4078 $locations[ $location ] = $new_term_id; 4078 4079 } 4079 4080 } … … 4193 4194 $t = get_taxonomy( $taxonomy ); 4194 4195 4195 4196 if ( empty( $termlink ) ) { 4196 if ( 'category' == $taxonomy ) {4197 if ( 'category' === $taxonomy ) { 4197 4198 $termlink = '?cat=' . $term->term_id; 4198 4199 } elseif ( $t->query_var ) { 4199 4200 $termlink = "?$t->query_var=$slug"; … … 4218 4219 $termlink = home_url( user_trailingslashit( $termlink, 'category' ) ); 4219 4220 } 4220 4221 // Back Compat filters. 4221 if ( 'post_tag' == $taxonomy ) {4222 if ( 'post_tag' === $taxonomy ) { 4222 4223 4223 4224 /** 4224 4225 * Filters the tag link. … … 4230 4231 * @param int $term_id Term ID. 4231 4232 */ 4232 4233 $termlink = apply_filters( 'tag_link', $termlink, $term->term_id ); 4233 } elseif ( 'category' == $taxonomy ) {4234 } elseif ( 'category' === $taxonomy ) { 4234 4235 4235 4236 /** 4236 4237 * Filters the category link. … … 4553 4554 } 4554 4555 4555 4556 // Can't be its own parent. 4556 if ( $parent == $term_id ) {4557 if ( $parent === $term_id ) { 4557 4558 return 0; 4558 4559 } 4559 4560
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)