balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

wordpress.php (6056B)


      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 			'permalink_structure' => 'Permalink Structure',
     51 			'language' => 'Language',
     52 			'timezone' => 'Timezone',
     53 			'admin_email' => 'Admin Email',
     54 			'debug_mode' => 'Debug Mode',
     55 		];
     56 	}
     57 
     58 	/**
     59 	 * Get WordPress memory limit.
     60 	 *
     61 	 * Retrieve the WordPress memory limit.
     62 	 *
     63 	 * @since 1.0.0
     64 	 * @access public
     65 	 *
     66 	 * @return array {
     67 	 *    Report data.
     68 	 *
     69 	 *    @type string $value          WordPress memory limit.
     70 	 *    @type string $recommendation Recommendation memory limit.
     71 	 *    @type bool   $warning        Whether to display a warning. True if the limit
     72 	 *                                 is below the recommended 64M, False otherwise.
     73 	 * }
     74 	 */
     75 	public function get_memory_limit() {
     76 		$result = [
     77 			'value' => ini_get( 'memory_limit' ),
     78 		];
     79 
     80 		$min_recommended_memory = '64M';
     81 
     82 		$memory_limit_bytes = wp_convert_hr_to_bytes( $result['value'] );
     83 
     84 		$min_recommended_bytes = wp_convert_hr_to_bytes( $min_recommended_memory );
     85 
     86 		if ( $memory_limit_bytes < $min_recommended_bytes ) {
     87 			$result['recommendation'] = sprintf(
     88 				/* translators: 1: Minimum recommended_memory, 2: Codex URL */
     89 				_x( 'We recommend setting memory to at least %1$s. For more information, read about <a href="%2$s">how to Increase memory allocated to PHP</a>.', 'System Info', 'elementor' ),
     90 				$min_recommended_memory,
     91 				'https://go.elementor.com/wordpress-wp-config-memory/'
     92 			);
     93 
     94 			$result['warning'] = true;
     95 		}
     96 
     97 		return $result;
     98 	}
     99 
    100 	/**
    101 	 * Get WordPress version.
    102 	 *
    103 	 * Retrieve the WordPress version.
    104 	 *
    105 	 * @since 1.0.0
    106 	 * @access public
    107 	 *
    108 	 * @return array {
    109 	 *    Report data.
    110 	 *
    111 	 *    @type string $value WordPress version.
    112 	 * }
    113 	 */
    114 	public function get_version() {
    115 		return [
    116 			'value' => get_bloginfo( 'version' ),
    117 		];
    118 	}
    119 
    120 	/**
    121 	 * Is multisite.
    122 	 *
    123 	 * Whether multisite is enabled or not.
    124 	 *
    125 	 * @since 1.0.0
    126 	 * @access public
    127 	 *
    128 	 * @return array {
    129 	 *    Report data.
    130 	 *
    131 	 *    @type string $value Yes if multisite is enabled, No otherwise.
    132 	 * }
    133 	 */
    134 	public function get_is_multisite() {
    135 		return [
    136 			'value' => is_multisite() ? 'Yes' : 'No',
    137 		];
    138 	}
    139 
    140 	/**
    141 	 * Get site URL.
    142 	 *
    143 	 * Retrieve WordPress site URL.
    144 	 *
    145 	 * @since 1.0.0
    146 	 * @access public
    147 	 *
    148 	 * @return array {
    149 	 *    Report data.
    150 	 *
    151 	 *    @type string $value WordPress site URL.
    152 	 * }
    153 	 */
    154 	public function get_site_url() {
    155 		return [
    156 			'value' => get_site_url(),
    157 		];
    158 	}
    159 
    160 	/**
    161 	 * Get home URL.
    162 	 *
    163 	 * Retrieve WordPress home URL.
    164 	 *
    165 	 * @since 1.0.0
    166 	 * @access public
    167 	 *
    168 	 * @return array {
    169 	 *    Report data.
    170 	 *
    171 	 *    @type string $value WordPress home URL.
    172 	 * }
    173 	 */
    174 	public function get_home_url() {
    175 		return [
    176 			'value' => get_home_url(),
    177 		];
    178 	}
    179 
    180 	/**
    181 	 * Get permalink structure.
    182 	 *
    183 	 * Retrieve the permalink structure
    184 	 *
    185 	 * @since 1.0.0
    186 	 * @access public
    187 	 *
    188 	 * @return array {
    189 	 *    Report data.
    190 	 *
    191 	 *    @type string $value WordPress permalink structure.
    192 	 * }
    193 	 */
    194 	public function get_permalink_structure() {
    195 		global $wp_rewrite;
    196 
    197 		$structure = $wp_rewrite->permalink_structure;
    198 
    199 		if ( ! $structure ) {
    200 			$structure = 'Plain';
    201 		}
    202 
    203 		return [
    204 			'value' => $structure,
    205 		];
    206 	}
    207 
    208 	/**
    209 	 * Get site language.
    210 	 *
    211 	 * Retrieve the site language.
    212 	 *
    213 	 * @since 1.0.0
    214 	 * @access public
    215 	 *
    216 	 * @return array {
    217 	 *    Report data.
    218 	 *
    219 	 *    @type string $value WordPress site language.
    220 	 * }
    221 	 */
    222 	public function get_language() {
    223 		return [
    224 			'value' => get_bloginfo( 'language' ),
    225 		];
    226 	}
    227 
    228 	/**
    229 	 * Get PHP `max_upload_size`.
    230 	 *
    231 	 * Retrieve the value of maximum upload file size defined in `php.ini` configuration file.
    232 	 *
    233 	 * @since 1.0.0
    234 	 * @access public
    235 	 *
    236 	 * @return array {
    237 	 *    Report data.
    238 	 *
    239 	 *    @type string $value Maximum upload file size allowed.
    240 	 * }
    241 	 */
    242 	public function get_max_upload_size() {
    243 		return [
    244 			'value' => size_format( wp_max_upload_size() ),
    245 		];
    246 	}
    247 
    248 	/**
    249 	 * Get WordPress timezone.
    250 	 *
    251 	 * Retrieve WordPress timezone.
    252 	 *
    253 	 * @since 1.0.0
    254 	 * @access public
    255 	 *
    256 	 * @return array {
    257 	 *    Report data.
    258 	 *
    259 	 *    @type string $value WordPress timezone.
    260 	 * }
    261 	 */
    262 	public function get_timezone() {
    263 		$timezone = get_option( 'timezone_string' );
    264 		if ( ! $timezone ) {
    265 			$timezone = get_option( 'gmt_offset' );
    266 		}
    267 
    268 		return [
    269 			'value' => $timezone,
    270 		];
    271 	}
    272 
    273 	/**
    274 	 * Get WordPress administrator email.
    275 	 *
    276 	 * Retrieve WordPress administrator email.
    277 	 *
    278 	 * @since 1.0.0
    279 	 * @access public
    280 	 *
    281 	 * @return array {
    282 	 *    Report data.
    283 	 *
    284 	 *    @type string $value WordPress administrator email.
    285 	 * }
    286 	 */
    287 	public function get_admin_email() {
    288 		return [
    289 			'value' => get_option( 'admin_email' ),
    290 		];
    291 	}
    292 
    293 	/**
    294 	 * Get debug mode.
    295 	 *
    296 	 * Whether WordPress debug mode is enabled or not.
    297 	 *
    298 	 * @since 1.0.0
    299 	 * @access public
    300 	 *
    301 	 * @return array {
    302 	 *    Report data.
    303 	 *
    304 	 *    @type string $value Active if debug mode is enabled, Inactive otherwise.
    305 	 * }
    306 	 */
    307 	public function get_debug_mode() {
    308 		return [
    309 			'value' => WP_DEBUG ? 'Active' : 'Inactive',
    310 		];
    311 	}
    312 }