PluginProbe
Elementor Website Builder – more than just a page builder / 3.5.6
Elementor Website Builder – more than just a page builder v3.5.6
4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 All 452 releases
← All changes | modules/system-info/reporters/server.php +27 -149 4.3.0-beta33.5.6 View file →
@@ -1,9 +1,8 @@
1 1 <?php
2 2 namespace Elementor\Modules\System_Info\Reporters;
3 3
4 4 use Elementor\Api;
5 -use Elementor\Utils;
6 5
7 6 if ( ! defined( 'ABSPATH' ) ) {
8 7 exit; // Exit if accessed directly.
9 8 }
@@ -17,13 +16,8 @@
17 16 * @since 1.0.0
18 17 */
19 18 class Server extends Base {
20 19
21 - const KEY_PATH_WP_CONTENT_DIR = 'wp_content';
22 - const KEY_PATH_UPLOADS_DIR = 'uploads';
23 - const KEY_PATH_ELEMENTOR_UPLOADS_DIR = 'elementor_uploads';
24 - const KEY_PATH_HTACCESS_FILE = '.htaccess';
25 -
26 20 /**
27 21 * Get server environment reporter title.
28 22 *
29 23 * Retrieve server environment reporter title.
@@ -52,9 +46,8 @@
52 46 'os' => 'Operating System',
53 47 'software' => 'Software',
54 48 'mysql_version' => 'MySQL version',
55 49 'php_version' => 'PHP Version',
56 - 'php_memory_limit' => 'PHP Memory Limit',
57 50 'php_max_input_vars' => 'PHP Max Input Vars',
58 51 'php_max_post_size' => 'PHP Max Post Size',
59 52 'gd_installed' => 'GD Installed',
60 53 'zip_installed' => 'ZIP Installed',
@@ -98,9 +91,9 @@
98 91 * }
99 92 */
100 93 public function get_software() {
101 94 return [
102 - 'value' => Utils::get_super_global_value( $_SERVER, 'SERVER_SOFTWARE' ),
95 + 'value' => $_SERVER['SERVER_SOFTWARE'],
103 96 ];
104 97 }
105 98
106 99 /**
@@ -122,16 +115,11 @@
122 115 public function get_php_version() {
123 116 $result = [
124 117 'value' => PHP_VERSION,
125 118 ];
126 - $recommended_php_version = '7.4';
127 119
128 - if ( version_compare( $result['value'], $recommended_php_version, '<' ) ) {
129 - $result['recommendation'] = sprintf(
130 - /* translators: %s: Recommended PHP version. */
131 - esc_html__( 'We recommend using PHP version %s or higher.', 'elementor' ),
132 - $recommended_php_version
133 - );
120 + if ( version_compare( $result['value'], '5.4', '<' ) ) {
121 + $result['recommendation'] = _x( 'We recommend to use php 5.4 or higher', 'System Info', 'elementor' );
134 122
135 123 $result['warning'] = true;
136 124 }
137 125
@@ -138,49 +126,8 @@
138 126 return $result;
139 127 }
140 128
141 129 /**
142 - * Get PHP memory limit.
143 - *
144 - * Retrieve the PHP memory limit.
145 - *
146 - * @return array {
147 - * Report data.
148 - *
149 - * @type string $value PHP memory limit.
150 - * @type string $recommendation Recommendation memory limit.
151 - * @type bool $warning Whether to display a warning. True if the limit
152 - * is below the recommended 128M, False otherwise.
153 - * }
154 - */
155 - public function get_php_memory_limit() {
156 - $result = [
157 - 'value' => (string) ini_get( 'memory_limit' ),
158 - ];
159 -
160 - $min_recommended_memory = '128M';
161 - $preferred_memory = '256M';
162 -
163 - $memory_limit_bytes = wp_convert_hr_to_bytes( $result['value'] );
164 -
165 - $min_recommended_bytes = wp_convert_hr_to_bytes( $min_recommended_memory );
166 -
167 - if ( $memory_limit_bytes < $min_recommended_bytes ) {
168 - $result['recommendation'] = sprintf(
169 - /* translators: 1: Minimum recommended_memory, 2: Preferred memory, 3: WordPress wp-config memory documentation. */
170 - __( 'We recommend setting memory to at least %1$s. (%2$s or higher is preferred) For more information, read about <a href="%3$s">how to increase memory allocated to PHP</a>.', 'elementor' ),
171 - $min_recommended_memory,
172 - $preferred_memory,
173 - 'https://go.elementor.com/wordpress-wp-config-memory/'
174 - );
175 -
176 - $result['warning'] = true;
177 - }
178 -
179 - return $result;
180 - }
181 -
182 - /**
183 130 * Get PHP `max_input_vars`.
184 131 *
185 132 * Retrieve the value of `max_input_vars` from `php.ini` configuration file.
186 133 *
@@ -285,26 +232,18 @@
285 232 global $wpdb;
286 233
287 234 $db_server_version = $wpdb->get_results( "SHOW VARIABLES WHERE `Variable_name` IN ( 'version_comment', 'innodb_version' )", OBJECT_K );
288 235
289 - $db_server_version_string = $db_server_version['version_comment']->Value . ' v';
290 -
291 - // On some hosts, `innodb_version` is empty, in PHP 8.1.
292 - if ( isset( $db_server_version['innodb_version'] ) ) {
293 - $db_server_version_string .= $db_server_version['innodb_version']->Value;
294 - } else {
295 - $db_server_version_string .= $wpdb->get_var( 'SELECT VERSION() AS version' );
296 - }
297 -
298 236 return [
299 - 'value' => $db_server_version_string,
237 + 'value' => $db_server_version['version_comment']->Value . ' v' . $db_server_version['innodb_version']->Value,
300 238 ];
301 239 }
302 240
303 241 /**
304 242 * Get write permissions.
305 - * Check whether the required paths for have writing permissions.
306 243 *
244 + * Check whether the required folders has writing permissions.
245 + *
307 246 * @since 1.9.0
308 247 * @access public
309 248 *
310 249 * @return array {
@@ -314,31 +253,39 @@
314 253 * @type bool $warning Whether to display a warning. True if some required
315 254 * folders don't have writing permissions, False otherwise.
316 255 * }
317 256 */
318 - public function get_write_permissions(): array {
257 + public function get_write_permissions() {
319 258 $paths_to_check = [
320 - static::KEY_PATH_HTACCESS_FILE => $this->get_system_path( static::KEY_PATH_HTACCESS_FILE ),
321 - static::KEY_PATH_UPLOADS_DIR => $this->get_system_path( static::KEY_PATH_UPLOADS_DIR ),
322 - static::KEY_PATH_ELEMENTOR_UPLOADS_DIR => $this->get_system_path( static::KEY_PATH_ELEMENTOR_UPLOADS_DIR ),
259 + ABSPATH => 'WordPress root directory',
323 260 ];
324 261
325 - $paths_permissions = $this->get_paths_permissions( $paths_to_check );
262 + $write_problems = [];
326 263
327 - $write_problems = [];
264 + $wp_upload_dir = wp_upload_dir();
328 265
329 - if ( ! $paths_permissions[ static::KEY_PATH_UPLOADS_DIR ]['write'] ) {
330 - $write_problems[] = 'WordPress uploads directory';
266 + if ( $wp_upload_dir['error'] ) {
267 + $write_problems[] = 'WordPress root uploads directory';
331 268 }
332 269
333 - if ( $paths_permissions[ self::KEY_PATH_ELEMENTOR_UPLOADS_DIR ]['exists'] && ! $paths_permissions[ self::KEY_PATH_ELEMENTOR_UPLOADS_DIR ]['write'] ) {
334 - $write_problems[] = 'Elementor uploads directory';
270 + $elementor_uploads_path = $wp_upload_dir['basedir'] . '/elementor';
271 +
272 + if ( is_dir( $elementor_uploads_path ) ) {
273 + $paths_to_check[ $elementor_uploads_path ] = 'Elementor uploads directory';
335 274 }
336 275
337 - if ( $paths_permissions[ self::KEY_PATH_HTACCESS_FILE ]['exists'] && ! $paths_permissions[ self::KEY_PATH_HTACCESS_FILE ]['write'] ) {
338 - $write_problems[] = '.htaccess file';
276 + $htaccess_file = ABSPATH . '/.htaccess';
277 +
278 + if ( file_exists( $htaccess_file ) ) {
279 + $paths_to_check[ $htaccess_file ] = '.htaccess file';
339 280 }
340 281
282 + foreach ( $paths_to_check as $dir => $description ) {
283 + if ( ! is_writable( $dir ) ) {
284 + $write_problems[] = $description;
285 + }
286 + }
287 +
341 288 if ( $write_problems ) {
342 289 $value = 'There are some writing permissions issues with the following directories/files:' . "\n\t\t - ";
343 290
344 291 $value .= implode( "\n\t\t - ", $write_problems );
@@ -347,9 +294,9 @@
347 294 }
348 295
349 296 return [
350 297 'value' => $value,
351 - 'warning' => (bool) $write_problems,
298 + 'warning' => ! ! $write_problems,
352 299 ];
353 300 }
354 301
355 302 /**
@@ -409,76 +356,7 @@
409 356 }
410 357
411 358 return [
412 359 'value' => 'Connected',
413 - ];
414 - }
415 -
416 - /**
417 - * @param $paths [] Paths to check permissions.
418 - * @return array []{exists: bool, read: bool, write: bool, execute: bool}
419 - */
420 - public function get_paths_permissions( $paths ): array {
421 - $permissions = [];
422 -
423 - foreach ( $paths as $key_path => $path ) {
424 - $permissions[ $key_path ] = $this->get_path_permissions( $path );
425 - }
426 -
427 - return $permissions;
428 - }
429 -
430 - /**
431 - * Get path by path key.
432 - *
433 - * @param $path_key
434 - * @return string
435 - */
436 - public function get_system_path( $path_key ): string {
437 - switch ( $path_key ) {
438 - case static::KEY_PATH_WP_CONTENT_DIR:
439 - return WP_CONTENT_DIR;
440 -
441 - case static::KEY_PATH_HTACCESS_FILE:
442 - return file_exists( ABSPATH . '/.htaccess' ) ? ABSPATH . '/.htaccess' : '';
443 -
444 - case static::KEY_PATH_UPLOADS_DIR:
445 - return wp_upload_dir()['basedir'] ?? '';
446 -
447 - case static::KEY_PATH_ELEMENTOR_UPLOADS_DIR:
448 - if ( empty( wp_upload_dir()['basedir'] ) ) {
449 - return '';
450 - }
451 -
452 - $elementor_uploads_dir = wp_upload_dir()['basedir'] . '/elementor';
453 -
454 - return is_dir( $elementor_uploads_dir ) ? $elementor_uploads_dir : '';
455 -
456 - default:
457 - return '';
458 - }
459 - }
460 -
461 - /**
462 - * Check the permissions of a path.
463 - *
464 - * @param $path
465 - * @return array{exists: bool, read: bool, write: bool, execute: bool}
466 - */
467 - public function get_path_permissions( $path ): array {
468 - if ( empty( $path ) ) {
469 - return [
470 - 'exists' => false,
471 - 'read' => false,
472 - 'write' => false,
473 - 'execute' => false,
474 - ];
475 - }
476 -
477 - return [
478 - 'exists' => true,
479 - 'read' => is_readable( $path ),
480 - 'write' => is_writeable( $path ),
481 - 'execute' => is_executable( $path ),
482 360 ];
483 361 }
484 362 }