Revisions: Mark deprecated arguments in `wp_list_post_revisions()`.

* Second argument is now a string, which controls the revision type
* Back compat for $args['type']
* Remove lines for the old form-table format, since it's now just a list 

props a.hoereth. fixes #24213.

git-svn-id: http://core.svn.wordpress.org/trunk@24175 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dominik Schilling 2013-05-04 12:54:00 +00:00
parent 2f1777986c
commit 8ebc1c654e
2 changed files with 38 additions and 89 deletions

View File

@ -602,8 +602,8 @@ function post_author_meta_box($post) {
* *
* @param object $post * @param object $post
*/ */
function post_revisions_meta_box($post) { function post_revisions_meta_box( $post ) {
wp_list_post_revisions(); wp_list_post_revisions( $post );
} }
// -- Page related Meta Boxes // -- Page related Meta Boxes

View File

@ -1384,17 +1384,6 @@ function wp_post_revision_title_expanded( $revision, $link = true ) {
* Can output either a UL with edit links or a TABLE with diff interface, and * Can output either a UL with edit links or a TABLE with diff interface, and
* restore action links. * restore action links.
* *
* Second argument controls parameters:
* (bool) parent : include the parent (the "Current Revision") in the list.
* Deprecated (ignored), since 3.6 the revisions always include
* a copy of the current post.
* (string) format : 'list' or 'form-table'. 'list' outputs UL, 'form-table'
* outputs TABLE with UI.
* (int) right : what revision is currently being viewed - used in
* form-table format.
* (int) left : what revision is currently being diffed against right -
* used in form-table format.
*
* @package WordPress * @package WordPress
* @subpackage Post_Revisions * @subpackage Post_Revisions
* @since 2.6.0 * @since 2.6.0
@ -1404,25 +1393,26 @@ function wp_post_revision_title_expanded( $revision, $link = true ) {
* @uses get_edit_post_link() * @uses get_edit_post_link()
* @uses get_the_author_meta() * @uses get_the_author_meta()
* *
* @todo split into two functions (list, form-table) ?
*
* @param int|object $post_id Post ID or post object. * @param int|object $post_id Post ID or post object.
* @param string|array $args See description {@link wp_parse_args()}. * @param string $type 'all' (default), 'revision' or 'autosave'
* @return null * @return null
*/ */
function wp_list_post_revisions( $post_id = 0, $args = null ) { function wp_list_post_revisions( $post_id = 0, $type = 'all' ) {
if ( !$post = get_post( $post_id ) ) if ( ! $post = get_post( $post_id ) )
return; return;
$defaults = array( 'right' => false, 'left' => false, 'format' => 'list', 'type' => 'all' ); // $args array with (parent, format, right, left, type) deprecated since 3.6
extract( wp_parse_args( $args, $defaults ), EXTR_SKIP ); if ( is_array( $type ) ) {
$type = ! empty( $type['type'] ) ? $type['type'] : $type;
_deprecated_argument( __FUNCTION__, '3.6' );
}
if ( !$revisions = wp_get_post_revisions( $post->ID ) ) if ( ! $revisions = wp_get_post_revisions( $post->ID ) )
return; return;
$rows = ''; $rows = '';
foreach ( $revisions as $revision ) { foreach ( $revisions as $revision ) {
if ( !current_user_can( 'read_post', $revision->ID ) ) if ( ! current_user_can( 'read_post', $revision->ID ) )
continue; continue;
$is_autosave = wp_is_post_autosave( $revision ); $is_autosave = wp_is_post_autosave( $revision );
@ -1432,74 +1422,33 @@ function wp_list_post_revisions( $post_id = 0, $args = null ) {
$rows .= "\t<li>" . wp_post_revision_title_expanded( $revision ) . "</li>\n"; $rows .= "\t<li>" . wp_post_revision_title_expanded( $revision ) . "</li>\n";
} }
if ( 'form-table' == $format ) : ?> echo "<ul class='post-revisions'>\n";
echo $rows;
<form action="revision.php" method="get"> // if the post was previously restored from a revision
// show the restore event details
<div class="tablenav"> if ( $restored_from_meta = get_post_meta( $post->ID, '_post_restored_from', true ) ) {
<div class="alignleft"> $author = get_user_by( 'id', $restored_from_meta[ 'restored_by_user' ] );
<input type="submit" class="button-secondary" value="<?php esc_attr_e( 'Compare Revisions' ); ?>" /> /* translators: revision date format, see http://php.net/date */
<input type="hidden" name="action" value="diff" /> $datef = _x( 'j F, Y @ G:i:s', 'revision date format');
<input type="hidden" name="post_type" value="<?php echo esc_attr($post->post_type); ?>" /> $date = date_i18n( $datef, strtotime( $restored_from_meta[ 'restored_time' ] ) );
</div> $time_diff = human_time_diff( $restored_from_meta[ 'restored_time' ] ) ;
</div> ?>
<hr />
<br class="clear" /> <div id="revisions-meta-restored">
<table class="widefat post-revisions" cellspacing="0" id="post-revisions">
<col />
<col />
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
<thead>
<tr>
<th scope="col"><?php /* translators: column name in revisions */ _ex( 'Old', 'revisions column name' ); ?></th>
<th scope="col"><?php /* translators: column name in revisions */ _ex( 'New', 'revisions column name' ); ?></th>
<th scope="col"><?php /* translators: column name in revisions */ _ex( 'Date Created', 'revisions column name' ); ?></th>
<th scope="col"><?php _e( 'Author' ); ?></th>
<th scope="col" class="action-links"><?php _e( 'Actions' ); ?></th>
</tr>
</thead>
<tbody>
<?php echo $rows; ?>
</tbody>
</table>
</form>
<?php
else :
echo "<ul class='post-revisions'>\n";
echo $rows;
// if the post was previously restored from a revision
// show the restore event details
if ( $restored_from_meta = get_post_meta( $post->ID, '_post_restored_from', true ) ) {
$author = get_user_by( 'id', $restored_from_meta[ 'restored_by_user' ] );
/* translators: revision date format, see http://php.net/date */
$datef = _x( 'j F, Y @ G:i:s', 'revision date format');
$date = date_i18n( $datef, strtotime( $restored_from_meta[ 'restored_time' ] ) );
$time_diff = human_time_diff( $restored_from_meta[ 'restored_time' ] ) ;
?>
<hr />
<div id="revisions-meta-restored">
<?php
printf(
/* translators: restored revision details: 1: gravatar image, 2: author name, 3: time ago, 4: date */
__( 'Previously restored by %1$s %2$s, %3$s ago (%4$s)' ),
get_avatar( $author->ID, 24 ),
$author->display_name,
$time_diff,
$date
);
?>
</div>
<?php <?php
printf(
/* translators: restored revision details: 1: gravatar image, 2: author name, 3: time ago, 4: date */
__( 'Previously restored by %1$s %2$s, %3$s ago (%4$s)' ),
get_avatar( $author->ID, 24 ),
$author->display_name,
$time_diff,
$date
);
?>
</div>
<?php
echo "</ul>"; echo "</ul>";
} }
endif;
} }