Make WordPress Core

Opened 12 years ago

Closed 11 years ago

#28627 closed enhancement (fixed)

wp_prepare_revisions_for_js Should have more hooks/filters.

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

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 12 years ago.
Proposed filter
28627-2.diff (1.1 KB ) - added by jtsternberg 12 years ago.
Filter revision array
28627.2.diff (1.0 KB ) - added by adamsilverstein 12 years ago.

Download all attachments as: .zip

Change History (13)

@jtsternberg
12 years ago

Proposed filter

#1 follow-up: @ericlewis
12 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
12 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
12 years ago

Filter revision array

#3 @adamsilverstein
12 years ago

Great suggestion!

See also some additional revisions filter ideas in #24908.

#4 @helen
12 years ago

  • Version trunk3.6

#5 @adamsilverstein
12 years ago

  • Keywords has-patch dev-feedback added
  • Owner set to adamsilverstein
  • Status newassigned

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

#6 @wonderboymusic
11 years ago

  • Keywords dev-feedback removed
  • Milestone Awaiting Review4.4
  • Owner changed from adamsilverstein to wonderboymusic

#7 @wonderboymusic
11 years ago

  • Resolutionfixed
  • Status assignedclosed

In 34541:

Revisions: add a 'wp_prepare_revision_for_js' filter.

Props jtsternberg, adamsilverstein.
Fixes #28627.

#8 @helen
11 years ago

  • Resolution fixed
  • Status closedreopened

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
11 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
11 years ago

  • Resolutionfixed
  • Status reopenedclosed

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.