Wordpress - What is the difference between update_post_meta and update_postmeta hooks?
They were both introduced in version 2.9, but were done so in different files.
update_postmeta
went into /wp-admin/includes/post.php
While...
update_{$meta_type}_meta
went into /wp-includes/meta.php
It was only later that update_postmeta
was shifted into /wp-includes/meta.php
.
So I believe it was for backward compatability, where by because the update_postmeta
hook was always receiving the value of maybe_serialize()
then it should continue to do so, despite later being moved into /wp-includes/meta.php
.
Furthermore, which you may already know, but for the sake of others reading, the update_postmeta
hook returns data from the $_POST['meta']
superglobal and key which holds data from the custom fields panel.
Could this just have been a poor design decision? Looks like it.
I thought I recalled some other reason surrounding this very question in relation to double serialization of data, however I could be getting mixed up with something else.
Interestingly, if you store already serialized data in the Custom Field UI textarea, WordPress will serialize it again before storing it, which supports the notion of backward compatability in relation to:
- https://core.trac.wordpress.org/ticket/12930
- https://nacin.com/2010/04/18/wordpress-serializing-data/
Note: this answer is not neccessarily complete.