PluginProbe
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance / 4.7.0
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance v4.7.0
4.7.0 4.6.1 4.6.0 4.5.5 4.5.4 4.5.3 4.5.2 3.2.20 3.2.21 3.2.22 3.2.3 3.2.5 3.2.6 3.2.7 3.2.9 3.3.0 3.3.1 3.3.2 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.7.0 3.7.1 All 111 releases
wp-optimize / includes / updraftcentral / class-updraftcentral-wp-optimize-commands.php

class-updraftcentral-wp-optimize-commands.php in WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance 4.7.0, at includes/updraftcentral/class-updraftcentral-wp-optimize-commands.php

50 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if (!defined('ABSPATH')) die('No direct access allowed');
3
4 /**
5 * This is a small glue class, which makes available all the commands in WP_Optimize_Commands, and translates the response from WP_Optimize_Commands (which is either data to return, or a WP_Error) into the format used by UpdraftCentral.
6 */
7 class UpdraftCentral_WP_Optimize_Commands extends UpdraftCentral_Commands {
8
9 private $commands;
10
11 private $wp_optimize_updraftcentral_commands;
12
13 /**
14 * Class constructor
15 */
16 public function __construct() {
17 $this->commands = new WP_Optimize_Commands();
18 $this->wp_optimize_updraftcentral_commands = new WP_Optimize_UpdraftCentral_Commands();
19 }
20
21 /**
22 * Magic method to pass on the command to WP_Optimize_Commands
23 *
24 * @param string $name - command name
25 * @param array $arguments - command parameters
26 *
27 * @return array - response
28 */
29 public function __call($name, $arguments) {
30
31 if (is_callable(array($this->wp_optimize_updraftcentral_commands, $name))) {
32 $this->commands = $this->wp_optimize_updraftcentral_commands;
33 } elseif (!is_callable(array($this->commands, $name))) {
34 return $this->_generic_error_response('wp_optimize_no_such_command', $name);
35 }
36
37 if (count($arguments) > 0) {
38 $arguments[0] = $arguments[0] ?? array();
39 }
40
41 $result = call_user_func_array(array($this->commands, $name), $arguments);
42
43 if (is_wp_error($result)) {
44 return $this->_generic_error_response($result->get_error_code(), $result->get_error_data());
45 } else {
46 return $this->_response($result);
47 }
48 }
49 }
50