Core_Command::check_update PHP Method

check_update() public method

Lists the most recent versions when there are updates available, or success message when up to date. ## OPTIONS [--minor] : Compare only the first two parts of the version number. [--major] : Compare only the first part of the version number. [--field=] : Prints the value of a single field for each update. [--fields=] : Limit the output to specific object fields. Defaults to version,update_type,package_url. [--format=] : Render output in a particular format. --- default: table options: - table - csv - count - json - yaml --- ## EXAMPLES $ wp core check-update +---------+-------------+-------------------------------------------------------------+ | version | update_type | package_url | +---------+-------------+-------------------------------------------------------------+ | 4.5.2 | major | https://downloads.wordpress.org/release/wordpress-4.5.2.zip | +---------+-------------+-------------------------------------------------------------+
public check_update ( $_, $assoc_args )
    function check_update($_, $assoc_args)
    {
        $updates = $this->get_updates($assoc_args);
        if ($updates) {
            $updates = array_reverse($updates);
            $formatter = new \WP_CLI\Formatter($assoc_args, array('version', 'update_type', 'package_url'));
            $formatter->display_items($updates);
        } else {
            if (empty($assoc_args['format']) || 'table' == $assoc_args['format']) {
                WP_CLI::success("WordPress is at the latest version.");
            }
        }
    }