Opened 3 years ago

Last modified 4 months ago

#13382 new enhancement

_wp_post_revision_fields filter is not very useful

Reported by: mdawaffe Owned by:
Priority: normal Milestone: Future Release
Component: Revisions Version: 3.0
Severity: normal Keywords: needs-patch
Cc:

Description

The _wp_post_revision_fields filter allows plugins to modify which post fields get revisioned (the default is title, content, excerpt).

It's pretty useless, though, since it's only run once and can't be changed by post_type. A custom post type, for example, might only want to enable revisions on the content.

The _wp_post_revision_fields() is also a variation on the getter/setter pattern (static variable) we use in a few places to avoid globals. It makes the function kind of crazy.

Proposal: Split into two functions

@var int|object|array $post post_id or post object or post array
@return array Fields to revision: array( field => i18n'd label )
function wp_get_post_revision_fields( $post ) {
    // filter with _wp_post_revision_fields: pass post_id, post_type, ...?
    // don't cache results
}

@internal
@var array $past post array
@return array Filled $post array with revision info
function _wp_post_revision_fields( $post ) {
    $revisionable = wp_get_post_revision_fields( $post )
    // ...
}

I'd like to see this in 3.0 if we can, but marking as 3.1 for now.

Change History (3)

  • Keywords needs-patch added
  • Milestone changed from Awaiting Triage to Future Release
  • Keywords revisions-3.6 added

Adding to the candidate list for review in the 3.6 Revisions Feature work

  • Keywords revisions-3.6 removed

After chatting as a group we feel this is best addressed at the same time as revisioning postmeta etc.

Related #20564

Note: See TracTickets for help on using tickets.