| 1 |
<?php |
| 2 |
/** |
| 3 |
* Elasticsearch Server report class |
| 4 |
* |
| 5 |
* @since 4.4.0 |
| 6 |
* @package elasticpress |
| 7 |
*/ |
| 8 |
|
| 9 |
namespace ElasticPress\StatusReport; |
| 10 |
|
| 11 |
defined( 'ABSPATH' ) || exit; |
| 12 |
|
| 13 |
/** |
| 14 |
* ElasticsearchServer report class |
| 15 |
* |
| 16 |
* @package ElasticPress |
| 17 |
*/ |
| 18 |
class WordPress extends Report { |
| 19 |
|
| 20 |
/** |
| 21 |
* Return the report title |
| 22 |
* |
| 23 |
* @return string |
| 24 |
*/ |
| 25 |
public function get_title() : string { |
| 26 |
return __( 'WordPress', 'elasticpress' ); |
| 27 |
} |
| 28 |
|
| 29 |
/** |
| 30 |
* Return the report fields |
| 31 |
* |
| 32 |
* @return array |
| 33 |
*/ |
| 34 |
public function get_groups() : array { |
| 35 |
return [ |
| 36 |
$this->get_wp_basic_group(), |
| 37 |
$this->get_server_group(), |
| 38 |
]; |
| 39 |
} |
| 40 |
|
| 41 |
/** |
| 42 |
* Process basic WordPress info |
| 43 |
* |
| 44 |
* @return array |
| 45 |
*/ |
| 46 |
protected function get_wp_basic_group() : array { |
| 47 |
global $wp_version; |
| 48 |
|
| 49 |
$fields = []; |
| 50 |
|
| 51 |
$fields['wp_version'] = [ |
| 52 |
'label' => __( 'WordPress Version', 'elasticpress' ), |
| 53 |
'value' => $wp_version, |
| 54 |
]; |
| 55 |
|
| 56 |
$fields['home_url'] = [ |
| 57 |
'label' => __( 'Home URL', 'elasticpress' ), |
| 58 |
'value' => get_home_url(), |
| 59 |
]; |
| 60 |
|
| 61 |
$fields['site_url'] = [ |
| 62 |
'label' => __( 'Site URL', 'elasticpress' ), |
| 63 |
'value' => get_site_url(), |
| 64 |
]; |
| 65 |
|
| 66 |
$fields['is_multisite'] = [ |
| 67 |
'label' => __( 'Multisite', 'elasticpress' ), |
| 68 |
'value' => is_multisite(), |
| 69 |
]; |
| 70 |
|
| 71 |
$active_theme = wp_get_theme(); |
| 72 |
$theme_name = wp_strip_all_tags( $active_theme->get( 'Name' ) ); |
| 73 |
$theme_version = wp_strip_all_tags( $active_theme->get( 'Version' ) ); |
| 74 |
|
| 75 |
$fields['theme'] = [ |
| 76 |
'label' => __( 'Theme', 'elasticpress' ), |
| 77 |
'value' => sprintf( '%s (%s)', $theme_name, $theme_version ), |
| 78 |
]; |
| 79 |
|
| 80 |
if ( is_child_theme() ) { |
| 81 |
$parent_theme = wp_get_theme( $active_theme->get( 'Template' ) ); |
| 82 |
$parent_name = wp_strip_all_tags( $parent_theme->get( 'Name' ) ); |
| 83 |
$parent_version = wp_strip_all_tags( $parent_theme->get( 'Version' ) ); |
| 84 |
|
| 85 |
$fields['parent_theme'] = [ |
| 86 |
'label' => __( 'Parent Theme', 'elasticpress' ), |
| 87 |
'value' => sprintf( '%s (%s)', $parent_name, $parent_version ), |
| 88 |
]; |
| 89 |
} |
| 90 |
|
| 91 |
$plugins = []; |
| 92 |
foreach ( get_plugins() as $plugin_path => $plugin ) { |
| 93 |
// If plugin is not active, skip it. |
| 94 |
if ( ! is_plugin_active( $plugin_path ) ) { |
| 95 |
continue; |
| 96 |
} |
| 97 |
|
| 98 |
$plugins[] = sprintf( '%s (%s)', $plugin['Name'], $plugin['Version'] ); |
| 99 |
} |
| 100 |
$fields['plugins'] = [ |
| 101 |
'label' => __( 'Active Plugins', 'elasticpress' ), |
| 102 |
'value' => wp_sprintf( '%l', $plugins ), |
| 103 |
]; |
| 104 |
|
| 105 |
$fields['revisions'] = [ |
| 106 |
'label' => __( 'Revisions allowed', 'elasticpress' ), |
| 107 |
'value' => WP_POST_REVISIONS === true ? 'all' : (int) WP_POST_REVISIONS, |
| 108 |
]; |
| 109 |
|
| 110 |
return [ |
| 111 |
'title' => __( 'WordPress Environment', 'elasticpress' ), |
| 112 |
'fields' => $fields, |
| 113 |
]; |
| 114 |
} |
| 115 |
|
| 116 |
/** |
| 117 |
* Process the info about the server |
| 118 |
* |
| 119 |
* @return array |
| 120 |
*/ |
| 121 |
protected function get_server_group() : array { |
| 122 |
$fields = []; |
| 123 |
|
| 124 |
$fields['php_version'] = [ |
| 125 |
'label' => __( 'PHP Version', 'elasticpress' ), |
| 126 |
'value' => phpversion(), |
| 127 |
]; |
| 128 |
|
| 129 |
$fields['memory_limit'] = [ |
| 130 |
'label' => __( 'Memory Limit', 'elasticpress' ), |
| 131 |
'value' => WP_MEMORY_LIMIT, |
| 132 |
]; |
| 133 |
|
| 134 |
$fields['timeout'] = [ |
| 135 |
'label' => __( 'Maximum Execution Time', 'elasticpress' ), |
| 136 |
'value' => (int) ini_get( 'max_execution_time' ), |
| 137 |
]; |
| 138 |
|
| 139 |
return [ |
| 140 |
'title' => __( 'Server Environment', 'elasticpress' ), |
| 141 |
'fields' => $fields, |
| 142 |
]; |
| 143 |
} |
| 144 |
} |
| 145 |
|