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
← All changes | includes/class-wp-optimize-heartbeat.php +7 -3 4.5.2 → 4.7.0 View file →
@@ -64,9 +64,9 @@
64 64 * @return array|void
65 65 */
66 66 public function receive_heartbeat($response, $data) {
67 67 $allowed_smush_commands = Updraft_Smush_Manager_Commands::get_allowed_ajax_commands();
68 - $capability_required = current_user_can(WP_Optimize()->capability_required());
68 + $user_can = WP_Optimize()->current_user_can();
69 69 $commands = new Updraft_Smush_Manager_Commands(Updraft_Smush_Manager::instance());
70 70 $commands->heartbeat_command = true;
71 71
72 72 foreach ($data as $uid => $command) {
@@ -81,9 +81,9 @@
81 81 } else {
82 82 $command_name = key($command);
83 83 if ('updraft_smush_ajax' === $command_name) {
84 84
85 - if (!$capability_required) {
85 + if (!$user_can) {
86 86 continue;
87 87 }
88 88
89 89 $command_data = current($command);
@@ -111,9 +111,13 @@
111 111 ob_start();
112 112
113 113 $method = new ReflectionMethod($commands, $command_data['subaction']);
114 114
115 - $command_response = $method->invokeArgs($commands, array($command_data_param));
115 + try {
116 + $command_response = $method->invokeArgs($commands, array($command_data_param));
117 + } catch (Exception $e) {
118 + $command_response = new WP_Error($e->getCode() ? $e->getCode() : 1, $e->getMessage());
119 + }
116 120
117 121 if (is_array($command_response)) {
118 122 $response['callbacks'][$uid] = $command_response;
119 123 ob_end_clean();