/** * Get information about the licensing add-on. */ public function info() { $settings = it_exchange_get_option('addon_itelic'); if ($settings['renewal-discount-type'] == 'percent') { $discount = $settings['renewal-discount-amount'] . '%'; } else { $discount = it_exchange_format_price($settings['renewal-discount-amount']); } $info = array('version' => ITELIC\Plugin::VERSION, 'online_software_enabled' => $settings['sell-online-software'] ? 'yes' : 'no', 'remote_activation_enabled' => $settings['enable-remote-activation'] ? 'yes' : 'no', 'remote_deactivation_enabled' => $settings['enable-remote-deactivation'] ? 'yes' : 'no', 'renewal_discounts_enabled' => $settings['enable-renewal-discounts'] ? 'yes' : 'no', 'renewal_discount' => $discount, 'renewal_discount_expiry' => sprintf("%d days", $settings['renewal-discount-expiry'])); $args = array('fields' => array_keys($info)); $formatter = new \WP_CLI\Formatter($args); $formatter->display_item($info); }
/** * Provide details on the Redis connection. * * ## OPTIONS * * [--reset] * : Reset Redis stats. Only affects `lifetime_hitrate` currently. * * [--field=<field>] * : Get the value of a particular field. * * [--format=<format>] * : Render results in a particular format. * --- * default: table * options: * - table * - json * - yaml * --- * * ## EXAMPLES * * $ wp redis info * +-------------------+-----------+ * | Field | Value | * +-------------------+-----------+ * | status | connected | * | used_memory | 529.25K | * | uptime | 0 days | * | key_count | 20 | * | instantaneous_ops | 9/sec | * | lifetime_hitrate | 53.42% | * | redis_host | 127.0.0.1 | * | redis_port | 6379 | * | redis_auth | | * | redis_database | 0 | * +-------------------+-----------+ * * $ wp redis info --field=used_memory * 529.38K * * $ wp redis info --reset * Success: Redis stats reset. */ public function info($_, $assoc_args) { global $wp_object_cache, $redis_server; if (!defined('WP_REDIS_OBJECT_CACHE') || !WP_REDIS_OBJECT_CACHE) { WP_CLI::error('WP Redis object-cache.php file is missing from the wp-content/ directory.'); } if ($wp_object_cache->is_redis_connected && WP_CLI\Utils\get_flag_value($assoc_args, 'reset')) { // Redis::resetStat() isn't functional, see https://github.com/phpredis/phpredis/issues/928 if ($wp_object_cache->redis->eval("return redis.call('CONFIG','RESETSTAT')")) { WP_CLI::success('Redis stats reset.'); } else { WP_CLI::error("Couldn't reset Redis stats."); } } else { $data = wp_redis_get_info(); if (is_wp_error($data)) { WP_CLI::error($data); } $formatter = new \WP_CLI\Formatter($assoc_args, array_keys($data)); $formatter->display_item($data); } }