Make WordPress Core

Opened 7 months ago

Closed 5 months ago

#59698 closed defect (bug) (fixed)

Incorrect docs for `wp_attachment_is()`

Reported by: joedolson's profile joedolson Owned by: joedolson's profile joedolson
Milestone: 6.5 Priority: normal
Severity: normal Version: 4.2
Component: Media Keywords: good-first-bug has-patch
Focuses: docs Cc:

Description

The documentation for wp_attachment_is() states that the function accepts only 'image', 'audio', or 'video' for the $type parameter, but the default case in the switch block is a comparison of the type passed to the file extension. The function actually accepts those three values or any file extension.

Attachments (1)

59698.2.diff (797 bytes) - added by joedolson 5 months ago.
Updates return docs as requested in PR

Download all attachments as: .zip

Change History (5)

This ticket was mentioned in PR #5578 on WordPress/wordpress-develop by nirav7707.


7 months ago
#1

  • Keywords has-patch added; needs-patch removed

This pull request updates the wp_attachment_is() function documentation to reflect the fact that the function can now be used to check if an attachment is of any type, not just image, audio, or video.

This change is necessary because the wp_attachment_is() function has been updated in recent versions of WordPress to support more types of attachments, such as PDFs, documents, and archives. However, the function documentation has not been updated to reflect this change.

This pull request updates the function documentation to reflect the current capabilities of the function and to make it more accurate and informative for users.

#2 in reply to: ↑ description @matiasrecondo77
7 months ago

  • Resolution set to worksforme
  • Status changed from new to closed

Replying to joedolson:

The documentation for wp_attachment_is() states that the function accepts only 'image', 'audio', or 'video' for the $type parameter, but the default case in the switch block is a comparison of the type passed to the file extension. The function actually accepts those three values or any file extension.

@joedolson i checked your pull request and in my opinion the correction is valid.

#3 @joedolson
7 months ago

  • Resolution worksforme deleted
  • Status changed from closed to reopened

I'm assuming that what you're saying is that @nirav7707's PR solves the problem, and that closing the ticket was an error. If the PR is a valid solution, then the next steps would be to review or commit. Thanks for contributing!

@joedolson
5 months ago

Updates return docs as requested in PR

#4 @joedolson
5 months ago

  • Owner set to joedolson
  • Resolution set to fixed
  • Status changed from reopened to closed

In 57273:

Media: Fix inaccurate docs for wp_attachment_is().

Correct the documentation for the $type parameter to accept file extensions as well as attachment type groups. Also fix the return description to reflect the change.

Props nirav7707, joedolson.
Fixes #59698.

Note: See TracTickets for help on using tickets.