Last active

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

WordPress Engine shortcode

View gist:4236025
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
<?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
Something went wrong with that request. Please try again.