-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcommand.php
More file actions
56 lines (45 loc) · 1.28 KB
/
command.php
File metadata and controls
56 lines (45 loc) · 1.28 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
55
56
<?php
/**
* Registers the Soter command with WP-CLI.
*
* @package soter-command
*/
if ( ! class_exists( 'WP_CLI' ) ) {
return;
}
if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) {
require_once __DIR__ . '/vendor/autoload.php';
}
// Need function_exists() check because this file is loaded twice in earlier versions of WP-CLI.
if ( ! function_exists( '_soter_command_init' ) ) {
/**
* Create a Soter_Command instance and register it with WP-CLI.
*
* @return void
*/
function _soter_command_init() {
// Just in case...
static $initialized = false;
if ( $initialized ) {
return;
}
$ua = sprintf(
'%s (%s) | Soter CLI | v0.1.0 | https://github.com/ssnepenthe/soter-command',
get_bloginfo( 'name' ),
get_home_url()
);
$http = new Soter_Core\Cached_Http_Client(
new Soter_Core\WP_Http_Client( $ua ),
new Soter_Core\WP_Transient_Cache( 'soter', HOUR_IN_SECONDS )
);
$checker = new Soter_Core\Checker(
new Soter_Core\Api_Client( $http ),
new Soter_Core\WP_Package_Manager()
);
$command = new Soter_Command\Soter_Command( $checker );
WP_CLI::add_command( 'soter', $command );
$initialized = true;
}
// Delay command registration so we can use get_bloginfo(), get_home_url().
WP_CLI::add_hook( 'after_wp_load', '_soter_command_init' );
}