Opened 6 years ago
Closed 10 months ago
#51365 closed enhancement (wontfix)
Introduce dedicated function to check if post meta exists
| Reported by: | DaveyJake | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Posts, Post Types | Version: | |
| Severity: | normal | Keywords: | dev-feedback close |
| Cc: | Focuses: |
Description
Just wanted to suggest a simple function that checks for pre-existing metadata for the native post post type.
Looking forward to getting more involved and collaborating with everyone!
<?php /** * Check if post has pre-existing metadata. * * @since 5.5.2 * * @see metadata_exists() * * @param int $post_id The post ID. * @param string $meta_key The meta key to look for. * * @return bool True if key is found. False if not. */ function post_meta_exists( $post_id, $meta_key ) { if ( metadata_exists( 'post', $post_id, $meta_key ) ) { return true; } return false; }
Change History (4)
#1
@
6 years ago
- Focuses administration template removed
- Keywords dev-feedback added
- Summary This is my very first suggestion. I hope I'm in the right place? → Introduce dedicated function to check if post meta exists
#2
@
15 months ago
- Keywords close added
Hi @DaveyJake,
I have taken a look into this, and I am not sure there is much need for this wrapper function within core. My reasoning is that your function can be condensed down to the following:
<?php function post_meta_exists( $post_id, $meta_key ) { return metadata_exists( 'post', $post_id, $meta_key ); }
From the above code it raises the question why not just use metadata_exists()?
As I am not sure the reason to add this wrapper function in to core, I am going to mark this ticket with the close tag. However, please feel free to reopen this ticket if you wish to continue this ticket further. 😃
This ticket was mentioned in Slack in #core by sirlouen. View the logs.
10 months ago
#4
@
10 months ago
- Milestone Awaiting Review
- Resolution → wontfix
- Status new → closed
Following the suggestion by @callumbw95 I think its time to close this as 5 months have passed and there have not been any additional feedback provided
@DaveyJake feel free to comment whenever you want and provide more information and me or Callum, will be happy to continue digging into this problem if it still exists
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
@DaveyJake Yes, this is the right place! Thanks for the ticket. I'm updating the title of the ticket to reflect its nature. Marking this for
dev-feedbackto see if we can gather some opinions on whether this is needed.