Revisions.php
1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
namespace ACP\Column\Post;
use AC;
/**
* @since 4.0.12
*/
class Revisions extends AC\Column
implements AC\Column\AjaxValue {
public function __construct() {
$this->set_type( 'column-revisions' );
$this->set_label( __( 'Revisions', 'codepress-admin-columns' ) );
}
public function get_value( $post_id ) {
$value = $this->get_raw_value( $post_id );
if ( ! $value ) {
return $this->get_empty_char();
}
return ac_helper()->html->get_ajax_modal_link(
sprintf( _n( '%s revision', '%s revisions', $value, 'codepress-admin-columns' ), $value ),
[
'title' => __( 'Revisions', 'codepress-admin-columns' ) . ': ' . get_the_title( $post_id ),
'edit_link' => get_edit_post_link( $post_id ),
'id' => $post_id,
] );
}
public function get_raw_value( $post_id ) {
$revisions = wp_get_post_revisions( $post_id );
return count( $revisions );
}
public function get_ajax_value( $post_id ) {
$result = [];
foreach ( wp_get_post_revisions( $post_id ) as $revision ) {
$result[] = '<div class="acp-row-revision">' . wp_post_revision_title_expanded( $revision ) . '</div>';
}
return implode( '', $result );
}
public function is_valid() {
return post_type_supports( $this->get_post_type(), 'revisions' );
}
}