--- a/wp/wp-includes/category.php Mon Oct 14 18:06:33 2019 +0200
+++ b/wp/wp-includes/category.php Mon Oct 14 18:28:13 2019 +0200
@@ -25,7 +25,7 @@
*/
function get_categories( $args = '' ) {
$defaults = array( 'taxonomy' => 'category' );
- $args = wp_parse_args( $args, $defaults );
+ $args = wp_parse_args( $args, $defaults );
$taxonomy = $args['taxonomy'];
@@ -40,10 +40,13 @@
$taxonomy = apply_filters( 'get_categories_taxonomy', $taxonomy, $args );
// Back compat
- if ( isset($args['type']) && 'link' == $args['type'] ) {
- _deprecated_argument( __FUNCTION__, '3.0.0',
+ if ( isset( $args['type'] ) && 'link' == $args['type'] ) {
+ _deprecated_argument(
+ __FUNCTION__,
+ '3.0.0',
/* translators: 1: "type => link", 2: "taxonomy => link_category" */
- sprintf( __( '%1$s is deprecated. Use %2$s instead.' ),
+ sprintf(
+ __( '%1$s is deprecated. Use %2$s instead.' ),
'<code>type => link</code>',
'<code>taxonomy => link_category</code>'
)
@@ -91,8 +94,9 @@
function get_category( $category, $output = OBJECT, $filter = 'raw' ) {
$category = get_term( $category, 'category', $output, $filter );
- if ( is_wp_error( $category ) )
+ if ( is_wp_error( $category ) ) {
return $category;
+ }
_make_cat_compat( $category );
@@ -120,24 +124,30 @@
* @return WP_Term|array|WP_Error|null Type is based on $output value.
*/
function get_category_by_path( $category_path, $full_match = true, $output = OBJECT ) {
- $category_path = rawurlencode( urldecode( $category_path ) );
- $category_path = str_replace( '%2F', '/', $category_path );
- $category_path = str_replace( '%20', ' ', $category_path );
+ $category_path = rawurlencode( urldecode( $category_path ) );
+ $category_path = str_replace( '%2F', '/', $category_path );
+ $category_path = str_replace( '%20', ' ', $category_path );
$category_paths = '/' . trim( $category_path, '/' );
- $leaf_path = sanitize_title( basename( $category_paths ) );
+ $leaf_path = sanitize_title( basename( $category_paths ) );
$category_paths = explode( '/', $category_paths );
- $full_path = '';
+ $full_path = '';
foreach ( (array) $category_paths as $pathdir ) {
$full_path .= ( $pathdir != '' ? '/' : '' ) . sanitize_title( $pathdir );
}
- $categories = get_terms( 'category', array('get' => 'all', 'slug' => $leaf_path) );
+ $categories = get_terms(
+ 'category',
+ array(
+ 'get' => 'all',
+ 'slug' => $leaf_path,
+ )
+ );
if ( empty( $categories ) ) {
return;
}
foreach ( $categories as $category ) {
- $path = '/' . $leaf_path;
+ $path = '/' . $leaf_path;
$curcategory = $category;
while ( ( $curcategory->parent != 0 ) && ( $curcategory->parent != $curcategory->term_id ) ) {
$curcategory = get_term( $curcategory->parent, 'category' );
@@ -170,10 +180,11 @@
* @param string $slug The category slug.
* @return object Category data object
*/
-function get_category_by_slug( $slug ) {
+function get_category_by_slug( $slug ) {
$category = get_term_by( 'slug', $slug, 'category' );
- if ( $category )
+ if ( $category ) {
_make_cat_compat( $category );
+ }
return $category;
}
@@ -188,8 +199,9 @@
*/
function get_cat_ID( $cat_name ) {
$cat = get_term_by( 'name', $cat_name, 'category' );
- if ( $cat )
+ if ( $cat ) {
return $cat->term_id;
+ }
return 0;
}
@@ -202,10 +214,11 @@
* @return string Category name, or an empty string if category doesn't exist.
*/
function get_cat_name( $cat_id ) {
- $cat_id = (int) $cat_id;
+ $cat_id = (int) $cat_id;
$category = get_term( $cat_id, 'category' );
- if ( ! $category || is_wp_error( $category ) )
+ if ( ! $category || is_wp_error( $category ) ) {
return '';
+ }
return $category->name;
}
@@ -262,7 +275,7 @@
* @see get_terms() For list of arguments to pass.
*
* @param string|array $args Tag arguments to use when retrieving tags.
- * @return array List of tags.
+ * @return WP_Term[]|int $tags Array of 'post_tag' term objects, or a count thereof.
*/
function get_tags( $args = '' ) {
$tags = get_terms( 'post_tag', $args );
@@ -277,8 +290,8 @@
*
* @since 2.3.0
*
- * @param array $tags Array of 'post_tag' term objects.
- * @param array $args An array of arguments. @see get_terms()
+ * @param WP_Term[]|int $tags Array of 'post_tag' term objects, or a count thereof.
+ * @param array $args An array of arguments. @see get_terms()
*/
$tags = apply_filters( 'get_tags', $tags, $args );
return $tags;
@@ -343,18 +356,18 @@
*/
function _make_cat_compat( &$category ) {
if ( is_object( $category ) && ! is_wp_error( $category ) ) {
- $category->cat_ID = $category->term_id;
- $category->category_count = $category->count;
+ $category->cat_ID = $category->term_id;
+ $category->category_count = $category->count;
$category->category_description = $category->description;
- $category->cat_name = $category->name;
- $category->category_nicename = $category->slug;
- $category->category_parent = $category->parent;
+ $category->cat_name = $category->name;
+ $category->category_nicename = $category->slug;
+ $category->category_parent = $category->parent;
} elseif ( is_array( $category ) && isset( $category['term_id'] ) ) {
- $category['cat_ID'] = &$category['term_id'];
- $category['category_count'] = &$category['count'];
+ $category['cat_ID'] = &$category['term_id'];
+ $category['category_count'] = &$category['count'];
$category['category_description'] = &$category['description'];
- $category['cat_name'] = &$category['name'];
- $category['category_nicename'] = &$category['slug'];
- $category['category_parent'] = &$category['parent'];
+ $category['cat_name'] = &$category['name'];
+ $category['category_nicename'] = &$category['slug'];
+ $category['category_parent'] = &$category['parent'];
}
}