Modified.php
883 Bytes
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
<?php
namespace ACP\Editing\Service\Post;
use AC\Request;
use ACP\Editing\Service;
use ACP\Editing\View;
class Modified implements Service {
public function get_view( $context ) {
return new View\DateTime();
}
public function get_value( $id ) {
$post = get_post( $id );
if ( ! $post ) {
return false;
}
return $post->post_modified;
}
public function update( Request $request ) {
global $wpdb;
$id = (int) $request->get( 'id' );
$date = (string) $request->get( 'value' );
$date_gmt = get_date_from_gmt( $date );
$result_1 = $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET post_modified = %s WHERE ID = %d", $date, $id ) );
$result_2 = $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET post_modified_gmt = %s WHERE ID = %d", $date_gmt, $id ) );
clean_post_cache( $id );
return $result_1 !== false && $result_2 !== false;
}
}