I am working on a plugin that will be using custom fields, but was curious if there was a way to tell which plugin/library created those custom fields. The reason I am trying to find this distinction is so I can use the correct function when getting the data for these fields, so for ACF I'd use get_field()
for Metabox.io I would use rwmb_meta
and if they were custom built I would use get_post_meta()
. I was looking in my database to see if I could find anything that was distinctive for each custom field, but nothing jumped out at me.
Is there any way to tell what plugin/library created a specific custom field?
I am working on a plugin that will be using custom fields, but was curious if there was a way to tell which plugin/library created those custom fields. The reason I am trying to find this distinction is so I can use the correct function when getting the data for these fields, so for ACF I'd use get_field()
for Metabox.io I would use rwmb_meta
and if they were custom built I would use get_post_meta()
. I was looking in my database to see if I could find anything that was distinctive for each custom field, but nothing jumped out at me.
Is there any way to tell what plugin/library created a specific custom field?
Share Improve this question asked Jul 6, 2019 at 23:34 user9664977user9664977 3875 silver badges12 bronze badges1 Answer
Reset to default 0I am working on a plugin that will be using custom fields, but was curious if there was a way to tell which plugin/library created those custom fields.
WP doesn't store any meta information in the database about post meta and what plugins touched it. WP doesn't sandbox plugins at all, so once they're loaded it's all considered code. As such WP core code is on an equal footing with any plugin code
The reason I am trying to find this distinction is so I can use the correct function when getting the data for these fields, so for ACF I'd use get_field() for Metabox.io I would use rwmb_meta and if they were custom built I would use get_post_meta().
You may be able to use the APIs of each respective plugin to fetch the fields registered and compare them, but you would need to write code that relies on knowing internals of how those plugins store data. You would need to raise this with dev support for each plugin you hope to support.
I was looking in my database to see if I could find anything that was distinctive for each custom field, but nothing jumped out at me.
That data simply isn't stored in the database, and WP itself makes no attempt to store it. You would have to ask the plugin authors via their support channels.
Is there any way to tell what plugin/library created a specific custom field?
No, not using WP functions and APIs.
It might be that ABC Example metabox library uses post meta keys prefixed with abc_
that you could use, but that's if you're lucky. Or that XYZ library makes you register fields via PHP, and their keys and values have predictable formats. You'd have to ask them.
Sadly you didn't provide any context as to why you're trying to do this, so it's difficult to advise what to do. Just keep in mind that all of them are readable using get_post_meta
. The APIs such as get_field
are all wrapper functions around get_post_meta
that add extra logic.
Keep in mind though, that 3rd party plugins are offtopic here, you can't ask ACF specific questions etc, and this wouldn't be the best place to ask those questions either
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745340123a4623287.html
评论列表(0条)