PeriodicUpdateCheck.php
805 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
<?php
namespace ACP\Updates;
use AC\Asset;
use AC\Registerable;
use ACP\Asset\Script\PluginUpdatesCheck;
use ACP\Transient\UpdateCheckTransient;
class PeriodicUpdateCheck implements Registerable {
/**
* @var Asset\Location\Absolute
*/
private $location;
/**
* @var UpdateCheckTransient
*/
private $cache;
public function __construct( Asset\Location\Absolute $location, UpdateCheckTransient $cache ) {
$this->location = $location;
$this->cache = $cache;
}
public function register() {
add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_scripts' ] );
}
public function enqueue_scripts() {
if ( $this->cache->is_expired() ) {
$script = new PluginUpdatesCheck( $this->location->with_suffix( 'assets/core/js/update-plugins-check.js' ) );
$script->enqueue();
}
}
}