| @@ -2,9 +2,8 @@ | ||
| 2 | 2 | namespace Elementor\Core\Logger; |
| 3 | 3 | |
| 4 | 4 | use Elementor\Core\Base\Module as BaseModule; |
| 5 | 5 | use Elementor\Core\Common\Modules\Ajax\Module; |
| 6 | -use Elementor\Core\Editor\Editor; | |
| 7 | 6 | use Elementor\Core\Logger\Loggers\Logger_Interface; |
| 8 | 7 | use Elementor\Core\Logger\Items\PHP; |
| 9 | 8 | use Elementor\Core\Logger\Items\JS; |
| 10 | 9 | use Elementor\Plugin; |
| @@ -11,9 +10,9 @@ | ||
| 11 | 10 | use Elementor\Modules\System_Info\Module as System_Info; |
| 12 | 11 | use Elementor\Utils; |
| 13 | 12 | |
| 14 | 13 | if ( ! defined( 'ABSPATH' ) ) { |
| 15 | - exit; // Exit if accessed directly. | |
| 14 | + exit; // Exit if accessed directly | |
| 16 | 15 | } |
| 17 | 16 | |
| 18 | 17 | class Manager extends BaseModule { |
| 19 | 18 | |
| @@ -117,8 +116,9 @@ | ||
| 117 | 116 | * |
| 118 | 117 | * Log Elementor errors and save them in the database. |
| 119 | 118 | * |
| 120 | 119 | * Fired by `wp_ajax_elementor_js_log` action. |
| 120 | + * | |
| 121 | 121 | */ |
| 122 | 122 | public function js_log() { |
| 123 | 123 | /** @var Module $ajax */ |
| 124 | 124 | $ajax = Plugin::$instance->common->get_component( 'ajax' ); |
| @@ -127,21 +127,15 @@ | ||
| 127 | 127 | if ( ! $ajax->verify_request_nonce() || empty( $_POST['data'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing |
| 128 | 128 | wp_send_json_error(); |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { | |
| 132 | - wp_send_json_error( 'Permission denied' ); | |
| 133 | - } | |
| 134 | - | |
| 135 | 131 | // PHPCS - See comment above. |
| 136 | - $data = Utils::get_super_global_value( $_POST, 'data' ) ?? []; // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 137 | - | |
| 138 | - array_walk_recursive( $data, function( &$value ) { | |
| 132 | + array_walk_recursive( $_POST['data'], function( &$value ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 139 | 133 | $value = sanitize_text_field( $value ); |
| 140 | 134 | } ); |
| 141 | 135 | |
| 142 | 136 | // PHPCS - See comment above. |
| 143 | - foreach ( $data as $error ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 137 | + foreach ( $_POST['data'] as $error ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 144 | 138 | $error['type'] = Logger_Interface::LEVEL_ERROR; |
| 145 | 139 | |
| 146 | 140 | if ( ! empty( $error['customFields'] ) ) { |
| 147 | 141 | $error['meta'] = $error['customFields']; |
| @@ -153,10 +147,10 @@ | ||
| 153 | 147 | |
| 154 | 148 | wp_send_json_success(); |
| 155 | 149 | } |
| 156 | 150 | |
| 157 | - public function register_logger( $name, $class_name ) { | |
| 158 | - $this->loggers[ $name ] = $class_name; | |
| 151 | + public function register_logger( $name, $class ) { | |
| 152 | + $this->loggers[ $name ] = $class; | |
| 159 | 153 | } |
| 160 | 154 | |
| 161 | 155 | public function set_default_logger( $name ) { |
| 162 | 156 | if ( ! empty( $this->loggers[ $name ] ) ) { |
| @@ -199,9 +193,9 @@ | ||
| 199 | 193 | } |
| 200 | 194 | |
| 201 | 195 | /** |
| 202 | 196 | * @param string $message |
| 203 | - * @param array $args | |
| 197 | + * @param array $args | |
| 204 | 198 | * |
| 205 | 199 | * @return void |
| 206 | 200 | */ |
| 207 | 201 | public function info( $message, $args = [] ) { |
| @@ -209,9 +203,9 @@ | ||
| 209 | 203 | } |
| 210 | 204 | |
| 211 | 205 | /** |
| 212 | 206 | * @param string $message |
| 213 | - * @param array $args | |
| 207 | + * @param array $args | |
| 214 | 208 | * |
| 215 | 209 | * @return void |
| 216 | 210 | */ |
| 217 | 211 | public function notice( $message, $args = [] ) { |
| @@ -219,9 +213,9 @@ | ||
| 219 | 213 | } |
| 220 | 214 | |
| 221 | 215 | /** |
| 222 | 216 | * @param string $message |
| 223 | - * @param array $args | |
| 217 | + * @param array $args | |
| 224 | 218 | * |
| 225 | 219 | * @return void |
| 226 | 220 | */ |
| 227 | 221 | public function warning( $message, $args = [] ) { |
| @@ -229,9 +223,9 @@ | ||
| 229 | 223 | } |
| 230 | 224 | |
| 231 | 225 | /** |
| 232 | 226 | * @param string $message |
| 233 | - * @param array $args | |
| 227 | + * @param array $args | |
| 234 | 228 | * |
| 235 | 229 | * @return void |
| 236 | 230 | */ |
| 237 | 231 | public function error( $message, $args = [] ) { |
| @@ -245,8 +239,9 @@ | ||
| 245 | 239 | E_USER_ERROR => Logger_Interface::LEVEL_ERROR, |
| 246 | 240 | E_COMPILE_ERROR => Logger_Interface::LEVEL_ERROR, |
| 247 | 241 | E_RECOVERABLE_ERROR => Logger_Interface::LEVEL_ERROR, |
| 248 | 242 | E_PARSE => Logger_Interface::LEVEL_ERROR, |
| 243 | + E_STRICT => Logger_Interface::LEVEL_ERROR, | |
| 249 | 244 | |
| 250 | 245 | E_WARNING => Logger_Interface::LEVEL_WARNING, |
| 251 | 246 | E_USER_WARNING => Logger_Interface::LEVEL_WARNING, |
| 252 | 247 | E_CORE_WARNING => Logger_Interface::LEVEL_WARNING, |