| 1 |
<?php |
| 2 |
namespace Elementor\Modules\System_Info\Reporters; |
| 3 |
|
| 4 |
if ( ! defined( 'ABSPATH' ) ) { |
| 5 |
exit; // Exit if accessed directly. |
| 6 |
} |
| 7 |
|
| 8 |
/** |
| 9 |
* Elementor WordPress environment report. |
| 10 |
* |
| 11 |
* Elementor system report handler class responsible for generating a report for |
| 12 |
* the WordPress environment. |
| 13 |
* |
| 14 |
* @since 1.0.0 |
| 15 |
*/ |
| 16 |
class WordPress extends Base { |
| 17 |
|
| 18 |
/** |
| 19 |
* Get WordPress environment reporter title. |
| 20 |
* |
| 21 |
* Retrieve WordPress environment reporter title. |
| 22 |
* |
| 23 |
* @since 1.0.0 |
| 24 |
* @access public |
| 25 |
* |
| 26 |
* @return string Reporter title. |
| 27 |
*/ |
| 28 |
public function get_title() { |
| 29 |
return 'WordPress Environment'; |
| 30 |
} |
| 31 |
|
| 32 |
/** |
| 33 |
* Get WordPress environment report fields. |
| 34 |
* |
| 35 |
* Retrieve the required fields for the WordPress environment report. |
| 36 |
* |
| 37 |
* @since 1.0.0 |
| 38 |
* @access public |
| 39 |
* |
| 40 |
* @return array Required report fields with field ID and field label. |
| 41 |
*/ |
| 42 |
public function get_fields() { |
| 43 |
return [ |
| 44 |
'version' => 'Version', |
| 45 |
'site_url' => 'Site URL', |
| 46 |
'home_url' => 'Home URL', |
| 47 |
'is_multisite' => 'WP Multisite', |
| 48 |
'max_upload_size' => 'Max Upload Size', |
| 49 |
'memory_limit' => 'Memory limit', |
| 50 |
'max_memory_limit' => 'Max Memory limit', |
| 51 |
'permalink_structure' => 'Permalink Structure', |
| 52 |
'language' => 'Language', |
| 53 |
'timezone' => 'Timezone', |
| 54 |
'admin_email' => 'Admin Email', |
| 55 |
'debug_mode' => 'Debug Mode', |
| 56 |
]; |
| 57 |
} |
| 58 |
|
| 59 |
/** |
| 60 |
* Get WordPress memory limit. |
| 61 |
* |
| 62 |
* Retrieve the WordPress memory limit. |
| 63 |
* |
| 64 |
* @since 1.0.0 |
| 65 |
* @access public |
| 66 |
* |
| 67 |
* @return array { |
| 68 |
* Report data. |
| 69 |
* |
| 70 |
* @type string $value WordPress memory limit. |
| 71 |
* } |
| 72 |
*/ |
| 73 |
public function get_memory_limit() { |
| 74 |
return [ |
| 75 |
'value' => (string) WP_MEMORY_LIMIT, |
| 76 |
]; |
| 77 |
} |
| 78 |
|
| 79 |
/** |
| 80 |
* Get WordPress max memory limit. |
| 81 |
* |
| 82 |
* Retrieve the WordPress max memory limit. |
| 83 |
* |
| 84 |
* @return array { |
| 85 |
* Report data. |
| 86 |
* |
| 87 |
* @type string $value WordPress max memory limit. |
| 88 |
* } |
| 89 |
*/ |
| 90 |
public function get_max_memory_limit() { |
| 91 |
return [ |
| 92 |
'value' => (string) WP_MAX_MEMORY_LIMIT, |
| 93 |
]; |
| 94 |
} |
| 95 |
|
| 96 |
/** |
| 97 |
* Get WordPress version. |
| 98 |
* |
| 99 |
* Retrieve the WordPress version. |
| 100 |
* |
| 101 |
* @since 1.0.0 |
| 102 |
* @access public |
| 103 |
* |
| 104 |
* @return array { |
| 105 |
* Report data. |
| 106 |
* |
| 107 |
* @type string $value WordPress version. |
| 108 |
* } |
| 109 |
*/ |
| 110 |
public function get_version() { |
| 111 |
return [ |
| 112 |
'value' => get_bloginfo( 'version' ), |
| 113 |
]; |
| 114 |
} |
| 115 |
|
| 116 |
/** |
| 117 |
* Is multisite. |
| 118 |
* |
| 119 |
* Whether multisite is enabled or not. |
| 120 |
* |
| 121 |
* @since 1.0.0 |
| 122 |
* @access public |
| 123 |
* |
| 124 |
* @return array { |
| 125 |
* Report data. |
| 126 |
* |
| 127 |
* @type string $value Yes if multisite is enabled, No otherwise. |
| 128 |
* } |
| 129 |
*/ |
| 130 |
public function get_is_multisite() { |
| 131 |
return [ |
| 132 |
'value' => is_multisite() ? 'Yes' : 'No', |
| 133 |
]; |
| 134 |
} |
| 135 |
|
| 136 |
/** |
| 137 |
* Get site URL. |
| 138 |
* |
| 139 |
* Retrieve WordPress site URL. |
| 140 |
* |
| 141 |
* @since 1.0.0 |
| 142 |
* @access public |
| 143 |
* |
| 144 |
* @return array { |
| 145 |
* Report data. |
| 146 |
* |
| 147 |
* @type string $value WordPress site URL. |
| 148 |
* } |
| 149 |
*/ |
| 150 |
public function get_site_url() { |
| 151 |
return [ |
| 152 |
'value' => get_site_url(), |
| 153 |
]; |
| 154 |
} |
| 155 |
|
| 156 |
/** |
| 157 |
* Get home URL. |
| 158 |
* |
| 159 |
* Retrieve WordPress home URL. |
| 160 |
* |
| 161 |
* @since 1.0.0 |
| 162 |
* @access public |
| 163 |
* |
| 164 |
* @return array { |
| 165 |
* Report data. |
| 166 |
* |
| 167 |
* @type string $value WordPress home URL. |
| 168 |
* } |
| 169 |
*/ |
| 170 |
public function get_home_url() { |
| 171 |
return [ |
| 172 |
'value' => get_home_url(), |
| 173 |
]; |
| 174 |
} |
| 175 |
|
| 176 |
/** |
| 177 |
* Get permalink structure. |
| 178 |
* |
| 179 |
* Retrieve the permalink structure |
| 180 |
* |
| 181 |
* @since 1.0.0 |
| 182 |
* @access public |
| 183 |
* |
| 184 |
* @return array { |
| 185 |
* Report data. |
| 186 |
* |
| 187 |
* @type string $value WordPress permalink structure. |
| 188 |
* } |
| 189 |
*/ |
| 190 |
public function get_permalink_structure() { |
| 191 |
global $wp_rewrite; |
| 192 |
|
| 193 |
$structure = $wp_rewrite->permalink_structure; |
| 194 |
|
| 195 |
if ( ! $structure ) { |
| 196 |
$structure = 'Plain'; |
| 197 |
} |
| 198 |
|
| 199 |
return [ |
| 200 |
'value' => $structure, |
| 201 |
]; |
| 202 |
} |
| 203 |
|
| 204 |
/** |
| 205 |
* Get site language. |
| 206 |
* |
| 207 |
* Retrieve the site language. |
| 208 |
* |
| 209 |
* @since 1.0.0 |
| 210 |
* @access public |
| 211 |
* |
| 212 |
* @return array { |
| 213 |
* Report data. |
| 214 |
* |
| 215 |
* @type string $value WordPress site language. |
| 216 |
* } |
| 217 |
*/ |
| 218 |
public function get_language() { |
| 219 |
return [ |
| 220 |
'value' => get_locale(), |
| 221 |
]; |
| 222 |
} |
| 223 |
|
| 224 |
/** |
| 225 |
* Get PHP `max_upload_size`. |
| 226 |
* |
| 227 |
* Retrieve the value of maximum upload file size defined in `php.ini` configuration file. |
| 228 |
* |
| 229 |
* @since 1.0.0 |
| 230 |
* @access public |
| 231 |
* |
| 232 |
* @return array { |
| 233 |
* Report data. |
| 234 |
* |
| 235 |
* @type string $value Maximum upload file size allowed. |
| 236 |
* } |
| 237 |
*/ |
| 238 |
public function get_max_upload_size() { |
| 239 |
return [ |
| 240 |
'value' => size_format( wp_max_upload_size() ), |
| 241 |
]; |
| 242 |
} |
| 243 |
|
| 244 |
/** |
| 245 |
* Get WordPress timezone. |
| 246 |
* |
| 247 |
* Retrieve WordPress timezone. |
| 248 |
* |
| 249 |
* @since 1.0.0 |
| 250 |
* @access public |
| 251 |
* |
| 252 |
* @return array { |
| 253 |
* Report data. |
| 254 |
* |
| 255 |
* @type string $value WordPress timezone. |
| 256 |
* } |
| 257 |
*/ |
| 258 |
public function get_timezone() { |
| 259 |
$timezone = get_option( 'timezone_string' ); |
| 260 |
if ( ! $timezone ) { |
| 261 |
$timezone = get_option( 'gmt_offset' ); |
| 262 |
} |
| 263 |
|
| 264 |
return [ |
| 265 |
'value' => $timezone, |
| 266 |
]; |
| 267 |
} |
| 268 |
|
| 269 |
/** |
| 270 |
* Get WordPress administrator email. |
| 271 |
* |
| 272 |
* Retrieve WordPress administrator email. |
| 273 |
* |
| 274 |
* @since 1.0.0 |
| 275 |
* @access public |
| 276 |
* |
| 277 |
* @return array { |
| 278 |
* Report data. |
| 279 |
* |
| 280 |
* @type string $value WordPress administrator email. |
| 281 |
* } |
| 282 |
*/ |
| 283 |
public function get_admin_email() { |
| 284 |
return [ |
| 285 |
'value' => get_option( 'admin_email' ), |
| 286 |
]; |
| 287 |
} |
| 288 |
|
| 289 |
/** |
| 290 |
* Get debug mode. |
| 291 |
* |
| 292 |
* Whether WordPress debug mode is enabled or not. |
| 293 |
* |
| 294 |
* @since 1.0.0 |
| 295 |
* @access public |
| 296 |
* |
| 297 |
* @return array { |
| 298 |
* Report data. |
| 299 |
* |
| 300 |
* @type string $value Active if debug mode is enabled, Inactive otherwise. |
| 301 |
* } |
| 302 |
*/ |
| 303 |
public function get_debug_mode() { |
| 304 |
return [ |
| 305 |
'value' => WP_DEBUG ? 'Active' : 'Inactive', |
| 306 |
]; |
| 307 |
} |
| 308 |
} |
| 309 |
|