WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 4 years ago

#28627 closed enhancement (fixed)

wp_prepare_revisions_for_js Should have more hooks/filters.

Reported by: jtsternberg Owned by: wonderboymusic
Milestone: 4.4 Priority: normal
Severity: normal Version: 3.6
Component: Revisions Keywords: has-patch
Focuses: javascript, administration Cc:

Description

Specifically, the array at the end should be passed through a filter then use wp_parse_args to ensure the correct parameters are correct. This would be useful for infusing more data to the models (i.e. post-meta for revisions, see this stackexchange: http://wordpress.stackexchange.com/questions/151630/how-to-hook-in-and-modify-the-new-revisions-ui-3-6). We still need a more WordPress way to tap into the Backbone views for the revisions UI as well.

Attachments (3)

28627.diff (1.1 KB) - added by jtsternberg 5 years ago.
Proposed filter
28627-2.diff (1.1 KB) - added by jtsternberg 5 years ago.
Filter revision array
28627.2.diff (1.0 KB) - added by adamsilverstein 5 years ago.

Download all attachments as: .zip

Change History (13)

@jtsternberg
5 years ago

Proposed filter

#1 follow-up: @ericlewis
5 years ago

Into it.

I don't see an immediate use case for overriding the settings array. For the use case suggested (adding data to a revision model), I could see a more specific filter applied when the data's array is built.

a la

<?php
$revisions[$revision->ID] = apply_filters( 'wp_prepare_revision_for_js', array( /* revision data */ ) ); 

The filter naming is for parity with the wp_prepare_attachment_for_js filter.

#2 in reply to: ↑ 1 @jtsternberg
5 years ago

Replying to ericlewis:

For the use case suggested (adding data to a revision model), I could see a more specific filter applied when the revision data's array is built.

That makes sense to me.

@jtsternberg
5 years ago

Filter revision array

#3 @adamsilverstein
5 years ago

Great suggestion!

See also some additional revisions filter ideas in #24908.

#4 @helen
5 years ago

  • Version changed from trunk to 3.6

#5 @adamsilverstein
5 years ago

  • Keywords has-patch dev-feedback added
  • Owner set to adamsilverstein
  • Status changed from new to assigned

Did a little freshening and hook docs cleanup in 28627.2.diff - curious to hear the use case!

#6 @wonderboymusic
4 years ago

  • Keywords dev-feedback removed
  • Milestone changed from Awaiting Review to 4.4
  • Owner changed from adamsilverstein to wonderboymusic

#7 @wonderboymusic
4 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 34541:

Revisions: add a 'wp_prepare_revision_for_js' filter.

Props jtsternberg, adamsilverstein.
Fixes #28627.

#8 @helen
4 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

This hook really also needs either the revision's ID or the entire revision object passed to it as well, and probably before the parent post arg.

#9 @DrewAPicture
4 years ago

In 34831:

Docs: Document the $revision_data parameter passed to the wp_prepare_revision_for_js filter with a hash notation.

The hook was introduced in [34541].

See #28627.

#10 @DrewAPicture
4 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 34832:

Revisions: Also pass the $revision post object to the wp_prepare_revision_for_js filter, introduced in [34541].

Props helen.
Fixes #28627.

Note: See TracTickets for help on using tickets.