mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-20 19:56:49 +01:00
Default $parent in category_exists() should default to null rather than 0.
[29863] made the corresponding change in `term_exists()`. Failure to change the default value in `category_exists()` meant that an unspecified value for `$parent` would limit results to top-level categories. Includes unit tests and corrected function documentation. Props hissy. Merges [31140] to the 4.1 branch. Fixes #30975. Built from https://develop.svn.wordpress.org/branches/4.1@31376 git-svn-id: http://core.svn.wordpress.org/branches/4.1@31357 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
6f1a6f77e8
commit
ab103b5bf9
|
|
@ -11,14 +11,17 @@
|
|||
//
|
||||
|
||||
/**
|
||||
* {@internal Missing Short Description}}
|
||||
* Check whether a category exists.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*
|
||||
* @param int|string $cat_name
|
||||
* @return int
|
||||
* @see term_exists()
|
||||
*
|
||||
* @param int|string $cat_name Category name.
|
||||
* @param int $parent Optional. ID of parent term.
|
||||
* @return mixed
|
||||
*/
|
||||
function category_exists($cat_name, $parent = 0) {
|
||||
function category_exists( $cat_name, $parent = null ) {
|
||||
$id = term_exists($cat_name, 'category', $parent);
|
||||
if ( is_array($id) )
|
||||
$id = $id['term_id'];
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user