2021-02-20 20:00:35 +00:00
< ? php
/**
* Includes the Plugin Class to display Diagnostics .
*
* @ filesource
* @ author Stefan Herndler
* @ since 1.5 . 0 14.09 . 14 14 : 47
*/
/**
* Displays Diagnostics of the web server , PHP and WordPress .
*
* @ author Stefan Herndler
* @ since 1.5 . 0
*/
2021-02-21 18:41:04 +00:00
class MCI_Footnotes_Layout_Diagnostics extends MCI_Footnotes_Layout_Engine {
2021-02-20 20:00:35 +00:00
/**
* Returns a Priority index . Lower numbers have a higher Priority .
*
* @ author Stefan Herndler
* @ since 1.5 . 0
* @ return int
*/
public function getPriority () {
return 999 ;
}
/**
* Returns the unique slug of the sub page .
*
* @ author Stefan Herndler
* @ since 1.5 . 0
* @ return string
*/
protected function getSubPageSlug () {
return '-diagnostics' ;
}
/**
* Returns the title of the sub page .
*
* @ author Stefan Herndler
* @ since 1.5 . 0
* @ return string
*/
protected function getSubPageTitle () {
return __ ( 'Diagnostics' , MCI_Footnotes_Config :: C_STR_PLUGIN_NAME );
}
/**
* Returns an array of all registered sections for the sub page .
*
* @ author Stefan Herndler
* @ since 1.5 . 0
* @ return array
*/
protected function getSections () {
return array (
$this -> addSection ( 'diagnostics' , __ ( 'Diagnostics' , MCI_Footnotes_Config :: C_STR_PLUGIN_NAME ), null , false ),
);
}
/**
* Returns an array of all registered meta boxes for each section of the sub page .
*
* @ author Stefan Herndler
* @ since 1.5 . 0
* @ return array
*/
protected function getMetaBoxes () {
return array (
$this -> addMetaBox ( 'diagnostics' , 'diagnostics' , __ ( 'Displays information about the web server, PHP and WordPress' , MCI_Footnotes_Config :: C_STR_PLUGIN_NAME ), 'Diagnostics' ),
);
}
/**
* Displays a diagnostics about the web server , php and WordPress .
*
* @ author Stefan Herndler
* @ since 1.5 . 0
*/
public function Diagnostics () {
global $wp_version ;
2021-02-21 10:50:08 +00:00
$l_str_php_extensions = '' ;
2021-02-20 20:00:35 +00:00
// iterate through each PHP extension
2021-02-21 10:50:08 +00:00
foreach ( get_loaded_extensions () as $l_int_index => $l_str_extension ) {
if ( $l_int_index > 0 ) {
$l_str_php_extensions .= ' | ' ;
2021-02-20 20:00:35 +00:00
}
2021-02-21 10:50:08 +00:00
$l_str_php_extensions .= $l_str_extension . ' ' . phpversion ( $l_str_extension );
2021-02-20 20:00:35 +00:00
}
2021-02-21 10:50:08 +00:00
/** @var WP_Theme $l_obj_current_theme */
$l_obj_current_theme = wp_get_theme ();
2021-02-20 20:00:35 +00:00
2021-02-21 10:50:08 +00:00
$l_str_wordpress_plugins = '' ;
2021-02-20 20:00:35 +00:00
// iterate through each installed WordPress Plugin
2021-02-21 10:50:08 +00:00
foreach ( get_plugins () as $l_arr_plugin ) {
$l_str_wordpress_plugins .= '<tr>' ;
$l_str_wordpress_plugins .= '<td>' . $l_arr_plugin [ 'Name' ] . '</td>' ;
$l_str_wordpress_plugins .= '<td>' . $l_arr_plugin [ 'Version' ] . ' [' . $l_arr_plugin [ 'PluginURI' ] . ']' . '</td>' ;
$l_str_wordpress_plugins .= '</tr>' ;
2021-02-20 20:00:35 +00:00
}
// load template file
2021-02-21 10:50:08 +00:00
$l_obj_template = new MCI_Footnotes_Template ( MCI_Footnotes_Template :: C_STR_DASHBOARD , 'diagnostics' );
2021-02-20 20:00:35 +00:00
// replace all placeholders
2021-02-21 10:50:08 +00:00
$l_obj_template -> replace (
2021-02-20 20:00:35 +00:00
array (
'label-server' => __ ( 'Server name' , MCI_Footnotes_Config :: C_STR_PLUGIN_NAME ),
'server' => $_SERVER [ 'SERVER_NAME' ],
'label-php' => __ ( 'PHP version' , MCI_Footnotes_Config :: C_STR_PLUGIN_NAME ),
'php' => phpversion (),
'label-user-agent' => __ ( 'User agent' , MCI_Footnotes_Config :: C_STR_PLUGIN_NAME ),
'user-agent' => $_SERVER [ 'HTTP_USER_AGENT' ],
'label-max-execution-time' => __ ( 'Max execution time' , MCI_Footnotes_Config :: C_STR_PLUGIN_NAME ),
'max-execution-time' => ini_get ( 'max_execution_time' ) . ' ' . __ ( 'seconds' , MCI_Footnotes_Config :: C_STR_PLUGIN_NAME ),
'label-memory-limit' => __ ( 'Memory limit' , MCI_Footnotes_Config :: C_STR_PLUGIN_NAME ),
'memory-limit' => ini_get ( 'memory_limit' ),
'label-php-extensions' => __ ( 'PHP extensions' , MCI_Footnotes_Config :: C_STR_PLUGIN_NAME ),
2021-02-21 10:50:08 +00:00
'php-extensions' => $l_str_php_extensions ,
2021-02-20 20:00:35 +00:00
'label-wordpress' => __ ( 'WordPress version' , MCI_Footnotes_Config :: C_STR_PLUGIN_NAME ),
'wordpress' => $wp_version ,
'label-theme' => __ ( 'Active Theme' , MCI_Footnotes_Config :: C_STR_PLUGIN_NAME ),
2021-02-21 10:50:08 +00:00
'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-02-20 20:00:35 +00:00
2021-02-21 10:50:08 +00:00
'plugins' => $l_str_wordpress_plugins ,
2021-02-20 20:00:35 +00:00
)
);
// display template with replaced placeholders
2021-02-21 10:50:08 +00:00
echo $l_obj_template -> getContent ();
2021-02-20 20:00:35 +00:00
}
}