Last active
October 13, 2015 18:17
-
-
Save markoheijnen/4236025 to your computer and use it in GitHub Desktop.
WordPress Engine shortcode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Marko_Shortcodes { | |
public function __construct() { | |
add_shortcode( 'engine_info', array( $this, 'engine_info' ) ); | |
} | |
public function engine_info( $atts ) { | |
global $wp_version, $wpdb, $batcache, $wp_object_cache; | |
$html = '<table style="max-width: 400px; width: 100%;">'; | |
$html .= '<tr><td>WordPress version</td><td>' . $wp_version . '</td></tr>'; | |
if( is_multisite() ) { | |
$html .= '<tr><td>WordPress type</td><td>Network installation</td></tr>'; | |
} | |
else { | |
$html .= '<tr><td>WordPress type</td><td>Single installation</td></tr>'; | |
} | |
$html .= '<tr><td>Image manipulator</td><td>' . _wp_image_editor_choose() . '</td></tr>'; | |
if ( isset( $batcache ) && is_object( $batcache ) && method_exists( $wp_object_cache, 'incr' ) ) { | |
$html .= '<tr><td>Advanced cache</td><td>Batcache</td></tr>'; | |
} | |
if( class_exists( 'APC_Object_Cache' ) ) { | |
$html .= '<tr><td>Object cache</td><td>APC Object Cache</td></tr>'; | |
} | |
$html .= '<tr><td style="height:10px"></td></tr>'; | |
$html .= '<tr><td>OS type</td><td>' . php_uname('s') . '</td></tr>'; | |
$html .= '<tr><td>Linux distro</td><td>' . $this->get_linux_distro() . '</td></tr>'; | |
$html .= '<tr><td>Webserver</td><td>' . $_SERVER["SERVER_SOFTWARE"] . '</td></tr>'; | |
$html .= '<tr><td>MySQL</td><td>' . $wpdb->db_version() . '</td></tr>'; | |
$html .= '<tr><td>PHP type</td><td>' . php_sapi_name() . '</td></tr>'; | |
$html .= '<tr><td>PHP version</td><td>' . phpversion() . '</td></tr>'; | |
$html .= '<tr><td>APC cache</td><td>' . phpversion( 'apc' ) . '</td></tr>'; | |
$html .= '<tr><td>GD version</td><td>' . gd_info()['GD Version'] . '</td></tr>'; | |
if( phpversion( 'imagick' ) ) { | |
$html .= '<tr><td>Imagick version</td><td>' . phpversion( 'imagick' ) . '</td></tr>'; | |
} | |
if( phpversion( 'gmagick' ) ) { | |
$html .= '<tr><td>Gmagick version</td><td>' . phpversion( 'gmagick' ) . '</td></tr>'; | |
} | |
$html .= '</table>'; | |
return $html; | |
} | |
private function get_linux_distro() { | |
$distros = array( | |
'Arch' => 'arch-release', | |
'Debian' => 'debian_version', | |
'Fedora' => 'fedora-release', | |
'Ubuntu' => 'lsb-release', | |
'Redhat' => 'redhat-release', | |
'CentOS' => 'centos-release' | |
); | |
foreach ( $distros as $distro => $release_file ) { | |
if ( file_exists( '/etc/' . $release_file ) ) { | |
return $distro . ' ' . file_get_contents( '/etc/' . $release_file ); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment