Changeset 32532
- Timestamp:
- 05/21/2015 09:17:42 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/category.php
r32116 r32532 69 69 * @param string $output Optional. Constant OBJECT, ARRAY_A, or ARRAY_N 70 70 * @param string $filter Optional. Default is raw or no WordPress defined filter will applied. 71 * @return object|array|WP_Error|null Category data in type defined by $output parameter. WP_Error if $category is empty, null if it does not exist. 71 * @return object|array|WP_Error|null Category data in type defined by $output parameter. 72 * WP_Error if $category is empty, null if it does not exist. 72 73 */ 73 74 function get_category( $category, $output = OBJECT, $filter = 'raw' ) { … … 99 100 * @param bool $full_match Optional. Whether full path should be matched. 100 101 * @param string $output Optional. Constant OBJECT, ARRAY_A, or ARRAY_N 101 * @return null|object|array Null on failure. Type is based on $output value.102 * @return null|object|array|WP_Error Null on failure. Type is based on $output value. 102 103 */ 103 104 function get_category_by_path( $category_path, $full_match = true, $output = OBJECT ) { … … 109 110 $category_paths = explode( '/', $category_paths ); 110 111 $full_path = ''; 111 foreach ( (array) $category_paths as $pathdir ) 112 foreach ( (array) $category_paths as $pathdir ) { 112 113 $full_path .= ( $pathdir != '' ? '/' : '' ) . sanitize_title( $pathdir ); 113 114 } 114 115 $categories = get_terms( 'category', array('get' => 'all', 'slug' => $leaf_path) ); 115 116 116 if ( empty( $categories ) ) 117 return null; 117 if ( empty( $categories ) ) { 118 return; 119 } 118 120 119 121 foreach ( $categories as $category ) { … … 122 124 while ( ( $curcategory->parent != 0 ) && ( $curcategory->parent != $curcategory->term_id ) ) { 123 125 $curcategory = get_term( $curcategory->parent, 'category' ); 124 if ( is_wp_error( $curcategory ) ) 126 if ( is_wp_error( $curcategory ) ) { 125 127 return $curcategory; 128 } 126 129 $path = '/' . $curcategory->slug . $path; 127 130 } … … 140 143 return $category; 141 144 } 142 143 return null;144 145 } 145 146 … … 322 323 */ 323 324 function _make_cat_compat( &$category ) { 324 if ( is_object( $category ) ) {325 if ( is_object( $category ) && ! is_wp_error( $category ) ) { 325 326 $category->cat_ID = &$category->term_id; 326 327 $category->category_count = &$category->count;
Note: See TracChangeset
for help on using the changeset viewer.