ForcePluginUpdates.php
921 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
42
43
44
<?php
namespace ACP\RequestHandler;
use AC\Capabilities;
use AC\Form\Nonce;
use AC\Request;
use ACP\ActivationTokenFactory;
use ACP\RequestHandler;
use ACP\Updates\PluginDataUpdater;
class ForcePluginUpdates implements RequestHandler {
/**
* @var PluginDataUpdater
*/
private $products_updater;
/**
* @var ActivationTokenFactory
*/
private $token_factory;
public function __construct( PluginDataUpdater $products_updater, ActivationTokenFactory $token_factory ) {
$this->products_updater = $products_updater;
$this->token_factory = $token_factory;
}
public function handle( Request $request ) {
if ( ! current_user_can( Capabilities::MANAGE ) ) {
return;
}
if ( ! ( new Nonce( 'acp-force-plugin-update', '_acnonce' ) )->verify( $request ) ) {
return;
}
$this->products_updater->update( $this->token_factory->create() );
wp_clean_plugins_cache();
wp_update_plugins();
}
}