Last active
September 18, 2018 18:38
-
-
Save radarin/6c7e85ad5e0f2b61325484c6f368d04c to your computer and use it in GitHub Desktop.
PHP Version im Wordpress Backend anzeigen
This file contains 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 | |
/* | |
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