/
wp-cli-updates-command.php
55 lines (42 loc) · 1011 Bytes
/
wp-cli-updates-command.php
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
<?php
/**
* @author aaemnnosttv
*/
if ( class_exists('WP_CLI_Command') ) :
class Updates_Command extends WP_CLI_Command
{
/**
* Updates
*
* @subcommand check
*/
public function check( $args, $assoc_args ) {
do_action('load-update-core.php');
$this->check_plugins();
$this->check_themes();
}
function check_plugins()
{
require_once(ABSPATH . 'wp-admin/includes/plugin-install.php');
$plugins = get_plugin_updates();
if ( ! empty( $plugins ) )
{
foreach ( (array) $plugins as $plugin_file => $plugin_data )
plugins_api('plugin_information', array('slug' => $plugin_data->update->slug ));
WP_CLI::success('Plugin updates refreshed.');
}
else
WP_CLI::log('All plugins are up to date.');
}
function check_themes()
{
$themes = get_theme_updates();
if ( ! empty( $themes ) ) {
WP_CLI::success('Theme updates refreshed.');
}
else
WP_CLI::log('Themes are up to date.');
}
}
WP_CLI::add_command( 'updates', 'Updates_Command' );
endif;