wp_post_revision_meta_keys( string $post_type ): array
- Since
- 6.4.0
- Source
wp-includes/revision.php:574
Compatibility
- WordPress
- since 6.4.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Parameters
$post_typestring- The post type being revisioned.
Return value
array- An array of meta keys to be revisioned.
Performance profile
How much work a call to wp_post_revision_meta_keys() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Light
- Scaling
- Scales with input
- Instructions
- 26–27
- Plugin surface
- 1 hook
- Called by
- 6
Touches nothing outside its own arguments.
The body loops, so the work grows with what you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 33.
Third-party callbacks on 'wp_post_revision_meta_keys' run inside this call, and their cost is not bounded by anything here.
6 places in core call this, so the cost is paid more often than your own code shows.
What it touches
- hookthird-party callbacks
apply_filters()called directly
What one call costs · 1 distinct outcome
One number would be a lie: the work depends on which branch runs. These are every distinct cost wp_post_revision_meta_keys() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 26–27 | get_registered_meta_keys(), get_registered_meta_keys(), array_merge(), array_keys(), apply_filters() |
Across PHP versions
Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 33 instructions, 26–27 executed per call, 3 branches. The work does not change between versions.
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Hooks and filters fired · 1
One hook fires while wp_post_revision_meta_keys() runs, in this order:
- apply_filters( wp_post_revision_meta_keys )filterline 598 (+24 into the body)
Filter the list of post meta keys to be revisioned.
Uses · 2
- get_registered_meta_keys()Retrieves a list of registered metadata args for an object type, keyed by their meta keys.
- apply_filters()Calls the callback functions that have been added to a filter hook.
Used by · 6
- WP_REST_Autosaves_Controller::create_post_autosave()Creates autosave for the specified post.
- _wp_preview_meta_filter()Filters preview post meta retrieval to get values from the autosave.
- wp_autosave_post_revisioned_meta_fields()Autosaves the revisioned meta fields.
- wp_check_revisioned_meta_fields_have_changed()Check whether revisioned post meta fields have changed.
- wp_restore_post_revision_meta()Restore the revisioned meta values for a post.
- wp_save_revisioned_meta_fields()Save the revisioned meta fields.
Source code
function wp_post_revision_meta_keys( $post_type ) { $registered_meta = array_merge( get_registered_meta_keys( 'post' ), get_registered_meta_keys( 'post', $post_type ) ); $wp_revisioned_meta_keys = array(); foreach ( $registered_meta as $name => $args ) { if ( $args['revisions_enabled'] ) { $wp_revisioned_meta_keys[ $name ] = true; } } $wp_revisioned_meta_keys = array_keys( $wp_revisioned_meta_keys ); /** * Filter the list of post meta keys to be revisioned. * * @since 6.4.0 * * @param array $keys An array of meta fields to be revisioned. * @param string $post_type The post type being revisioned. */ return apply_filters( 'wp_post_revision_meta_keys', $wp_revisioned_meta_keys, $post_type );}Changelog
Introduced in 6.4.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-includes/revision.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.