Skip to content

Instantly share code, notes, and snippets.

@radarin radarin/wp.php-version.php
Last active Sep 18, 2018

Embed
What would you like to do?
PHP Version im Wordpress Backend anzeigen
<?php
/*
Plugin Name: Show PHP Version
Description: Shows the current PHP version in the "At a Glance" admin dashboard widget.
Version: 1.1
Requires at least: 3.8
Author: Torsten Landsiedel
Author URI: http://torstenlandsiedel.de
*/
/**
* Add locations to the new "At a glance" dashboard widget (WP 3.8+).
*
* @param array $items
* @return array
*/
function add_to_glance( Array $items ) {
$php_version = phpversion();
$bit_mode = (PHP_INT_SIZE * 8);
if ( version_compare( $php_version, '5.5', '<' ) ) {
$color = 'red';
}
elseif ( version_compare( $php_version, '5.5', '=' ) || $bit_mode == 32 ) {
$color = 'orange';
}
else {
$color = 'green';
}
$items[] = sprintf(
'<a class="showphpversion %s" href="%s">%s %s (%s-bit)</a>',
$color,
esc_html__( 'http://php.net/supported-versions.php', 'tl-show-php-version' ),
esc_html__( 'PHP version:', 'tl-show-php-version' ),
$php_version,
$bit_mode
);
return $items;
}
add_filter( 'dashboard_glance_items', 'add_to_glance' );
function add_to_glance_styles() {
echo '<style>
#dashboard_right_now .showphpversion.green:before {
color: green;
content:"\f147"; /* Dashicon YES */
}
#dashboard_right_now .showphpversion.red:before {
color: red;
content: "\f158"; /* Dashicon NO */
}
#dashboard_right_now .showphpversion.orange:before {
color: orange;
content: "\f534"; /* Dashicon WARNING */
}
</style>';
}
add_action('admin_head', 'add_to_glance_styles');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.