2021-03-03 18:58:03 +00:00
< ? php // phpcs:disable WordPress.Files.FileName.InvalidClassFileName, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.EscapeOutput.OutputNotEscaped
2021-03-03 15:15:55 +00:00
/**
* Includes the Plugin Class to display Diagnostics .
*
* @ filesource
2021-03-03 18:58:03 +00:00
* @ package footnotes
* @ since 1.5 . 0
2021-03-03 15:15:55 +00:00
*/
/**
* Displays Diagnostics of the web server , PHP and WordPress .
*
* @ since 1.5 . 0
*/
2021-03-03 18:58:03 +00:00
class MCI_Footnotes_Layout_Diagnostics extends MCI_Footnotes_Layout_Engine {
2021-03-03 15:15:55 +00:00
/**
* Returns a Priority index . Lower numbers have a higher Priority .
*
* @ since 1.5 . 0
* @ return int
*/
2021-03-03 18:58:03 +00:00
public function get_priority () {
2021-03-03 15:15:55 +00:00
return 999 ;
}
/**
* Returns the unique slug of the sub page .
*
* @ since 1.5 . 0
* @ return string
*/
2021-03-03 18:58:03 +00:00
protected function get_sub_page_slug () {
return '-diagnostics' ;
2021-03-03 15:15:55 +00:00
}
/**
* Returns the title of the sub page .
*
* @ since 1.5 . 0
* @ return string
*/
2021-03-03 18:58:03 +00:00
protected function get_sub_page_title () {
return __ ( 'Diagnostics' , 'footnotes' );
2021-03-03 15:15:55 +00:00
}
/**
* Returns an array of all registered sections for the sub page .
*
* @ since 1.5 . 0
* @ return array
*/
2021-03-03 18:58:03 +00:00
protected function get_sections () {
2021-03-03 15:15:55 +00:00
return array (
2021-03-03 18:58:03 +00:00
$this -> add_section ( 'diagnostics' , __ ( 'Diagnostics' , 'footnotes' ), null , false ),
2021-03-03 15:15:55 +00:00
);
}
/**
* Returns an array of all registered meta boxes for each section of the sub page .
*
* @ since 1.5 . 0
* @ return array
*/
2021-03-03 18:58:03 +00:00
protected function get_meta_boxes () {
2021-03-03 15:15:55 +00:00
return array (
2021-03-03 18:58:03 +00:00
$this -> add_meta_box ( 'diagnostics' , 'diagnostics' , __ ( 'Displays information about the web server, PHP and WordPress' , 'footnotes' ), 'Diagnostics' ),
2021-03-03 15:15:55 +00:00
);
}
/**
* Displays a diagnostics about the web server , php and WordPress .
*
* @ since 1.5 . 0
*/
public function Diagnostics () {
global $wp_version ;
2021-03-03 18:58:03 +00:00
$l_str_php_extensions = '' ;
// Iterate through each PHP extension.
foreach ( get_loaded_extensions () as $l_int_index => $l_str_extension ) {
if ( $l_int_index > 0 ) {
$l_str_php_extensions .= ' | ' ;
2021-03-03 15:15:55 +00:00
}
2021-03-03 18:58:03 +00:00
$l_str_php_extensions .= $l_str_extension . ' ' . phpversion ( $l_str_extension );
2021-03-03 15:15:55 +00:00
}
2021-03-03 18:58:03 +00:00
$l_obj_current_theme = wp_get_theme ();
$l_str_wordpress_plugins = '' ;
// Iterate through each installed WordPress Plugin.
foreach ( get_plugins () as $l_arr_plugin ) {
$l_str_wordpress_plugins .= '<tr>' ;
$l_str_wordpress_plugins .= '<td>' . $l_arr_plugin [ 'Name' ] . '</td>' ;
// phpcs:disable Generic.Strings.UnnecessaryStringConcat.Found
$l_str_wordpress_plugins .= '<td>' . $l_arr_plugin [ 'Version' ] . ' [' . $l_arr_plugin [ 'PluginURI' ] . ']' . '</td>' ;
// phpcs:enable Generic.Strings.UnnecessaryStringConcat.Found
$l_str_wordpress_plugins .= '</tr>' ;
}
// Load template file.
$l_obj_template = new MCI_Footnotes_Template ( MCI_Footnotes_Template :: C_STR_DASHBOARD , 'diagnostics' );
2021-03-03 15:15:55 +00:00
2021-03-03 18:58:03 +00:00
if ( ! isset ( $_SERVER [ 'SERVER_NAME' ] ) ) {
die ;
} else {
$l_str_server_name = wp_unslash ( $_SERVER [ 'SERVER_NAME' ] );
2021-03-03 15:15:55 +00:00
}
2021-03-03 18:58:03 +00:00
if ( ! isset ( $_SERVER [ 'HTTP_USER_AGENT' ] ) ) {
die ;
} else {
$l_str_http_user_agent = wp_unslash ( $_SERVER [ 'HTTP_USER_AGENT' ] );
}
// Replace all placeholders.
$l_obj_template -> replace (
2021-03-03 15:15:55 +00:00
array (
2021-03-03 18:58:03 +00:00
'label-server' => __ ( 'Server name' , 'footnotes' ),
'server' => $l_str_server_name ,
2021-03-03 15:15:55 +00:00
2021-03-03 18:58:03 +00:00
'label-php' => __ ( 'PHP version' , 'footnotes' ),
'php' => phpversion (),
2021-03-03 15:15:55 +00:00
2021-03-03 18:58:03 +00:00
'label-user-agent' => __ ( 'User agent' , 'footnotes' ),
'user-agent' => $l_str_http_user_agent ,
2021-03-03 15:15:55 +00:00
2021-03-03 18:58:03 +00:00
'label-max-execution-time' => __ ( 'Max execution time' , 'footnotes' ),
'max-execution-time' => ini_get ( 'max_execution_time' ) . ' ' . __ ( 'seconds' , 'footnotes' ),
2021-03-03 15:15:55 +00:00
2021-03-03 18:58:03 +00:00
'label-memory-limit' => __ ( 'Memory limit' , 'footnotes' ),
'memory-limit' => ini_get ( 'memory_limit' ),
2021-03-03 15:15:55 +00:00
2021-03-03 18:58:03 +00:00
'label-php-extensions' => __ ( 'PHP extensions' , 'footnotes' ),
'php-extensions' => $l_str_php_extensions ,
2021-03-03 15:15:55 +00:00
2021-03-03 18:58:03 +00:00
'label-wordpress' => __ ( 'WordPress version' , 'footnotes' ),
'wordpress' => $wp_version ,
2021-03-03 15:15:55 +00:00
2021-03-03 18:58:03 +00:00
'label-theme' => __ ( 'Active Theme' , 'footnotes' ),
'theme' => $l_obj_current_theme -> get ( 'Name' ) . ' ' . $l_obj_current_theme -> get ( 'Version' ) . ', ' . $l_obj_current_theme -> get ( 'Author' ) . ' [' . $l_obj_current_theme -> get ( 'AuthorURI' ) . ']' ,
2021-03-03 15:15:55 +00:00
2021-03-03 18:58:03 +00:00
'plugins' => $l_str_wordpress_plugins ,
2021-03-03 15:15:55 +00:00
)
);
2021-03-03 18:58:03 +00:00
// Display template with replaced placeholders.
echo $l_obj_template -> get_content ();
2021-03-03 15:15:55 +00:00
}
}