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
*/
function post_revisions_meta_box($post) {
wp_list_post_revisions();
function post_revisions_meta_box( $post ) {
wp_list_post_revisions( $post );
}
// -- Page related Meta Boxes
@ -979,4 +979,4 @@ function link_advanced_meta_box($link) {
function post_thumbnail_meta_box( $post ) {
$thumbnail_id = get_post_meta( $post->ID, '_thumbnail_id', true );
echo _wp_post_thumbnail_html( $thumbnail_id, $post->ID );
}
}

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
* 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
* @subpackage Post_Revisions
* @since 2.6.0
@ -1404,25 +1393,26 @@ function wp_post_revision_title_expanded( $revision, $link = true ) {
* @uses get_edit_post_link()
* @uses get_the_author_meta()
*
* @todo split into two functions (list, form-table) ?
*
* @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
*/
function wp_list_post_revisions( $post_id = 0, $args = null ) {
if ( !$post = get_post( $post_id ) )
function wp_list_post_revisions( $post_id = 0, $type = 'all' ) {
if ( ! $post = get_post( $post_id ) )
return;
$defaults = array( 'right' => false, 'left' => false, 'format' => 'list', 'type' => 'all' );
extract( wp_parse_args( $args, $defaults ), EXTR_SKIP );
// $args array with (parent, format, right, left, type) deprecated since 3.6
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;
$rows = '';
foreach ( $revisions as $revision ) {
if ( !current_user_can( 'read_post', $revision->ID ) )
if ( ! current_user_can( 'read_post', $revision->ID ) )
continue;
$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";
}
if ( 'form-table' == $format ) : ?>
echo "<ul class='post-revisions'>\n";
echo $rows;
<form action="revision.php" method="get">
<div class="tablenav">
<div class="alignleft">
<input type="submit" class="button-secondary" value="<?php esc_attr_e( 'Compare Revisions' ); ?>" />
<input type="hidden" name="action" value="diff" />
<input type="hidden" name="post_type" value="<?php echo esc_attr($post->post_type); ?>" />
</div>
</div>
<br class="clear" />
<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>
// 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
echo "</ul>";
}
}
endif;
}