Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#12482 closed defect (bug) (fixed)

Correction to wp_insert_term() documentation

Reported by: prettyboymp Owned by: dd32
Priority: normal Milestone: 3.0
Component: Taxonomy Version:
Severity: normal Keywords: has-patch
Cc:

Description

After tracing through the code to see if I actually could use the wp_insert_term() method to add an existing term in a new taxonomy by it's id, I found that the method's documentation for its $term was incorrect in accepting an INT value for the $term parameter. It is cast as a string within the function so a term_id can't be passed in for this param as one would suspect given the docs.

Attachments (1)

12482.diff (710 bytes) - added by prettyboymp 3 years ago.

Download all attachments as: .zip

Change History (7)

  • Component changed from General to Inline Docs
  • Milestone changed from 3.1 to 3.0
  • Owner set to nacin

Inline docs remain fine for 3.0, in fact they are encouraged.

  • Component changed from Inline Docs to Taxonomy
  • Owner changed from nacin to filosofo

This also reveals some dead code in there:

if ( is_int($term) && 0 == $term )
	return new WP_Error('invalid_term_id', __('Invalid term ID'));

That should be removed if the rest of the function doesn't support term IDs.

  • Owner changed from filosofo to nacin
  • Status changed from new to assigned
  • Owner changed from nacin to dd32

I'm going to pass this off to dd32 for a review. I think we're good to both fix the docs and remove the dead code.

comment:5   ryan3 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [14785]) Update phpdoc for wp_insert_term(). Props prettyboymp. fixes #12482

comment:6   dd323 years ago

I'm going to pass this off to dd32 for a review.

And i've only just got to the wp-trac email to see this.

I remember seeing that same code and questioning what it did, But left it for lack of knowledge of what it did.. So your guess is as good as mine in this case.

Note: See TracTickets for help on using tickets.