Insert Software Version in Post or Page
-
I could not find similar functionality, so I wrote a short plugin that looks for a [version:?] tag in a post or page and insert the detected server software version. The plugin supports the following:
[version:wordpress]
— WordPress
[version:mysql]
— MySQL
[version:php]
— PHP— [software_versions.php] —
<?php /* Plugin Name: Software Versions Version: 0.1 Plugin URI: http://stephenyeargin.com/blog/tag/plugins/ Description: Versions of server software returned in post or page content if [version:{software}] tag included. Available software: php, mysql, wordpress. Author: Stephen Yeargin Author URI: http://stephenyeargin.com */ /* * Get Software Version * * Get current versions of your server software * * @param string Software to check * @return string Version number */ function get_software_version($type) { $ver = '???'; switch($type) { // MySQL case 'mysql': global $wpdb; $ver = $wpdb->get_var("SELECT VERSION() AS version;"); break; // PHP case 'php': $ver = phpversion(); break; // WordPress case 'wordpress': $ver = get_bloginfo('version'); break; } return $ver; } /* * Software Version * * Filter given text for software version tag, return if requested * * @param string Text of entry * @return string Filtered text */ function software_version($text) { $text = str_replace( array('[version:wordpress]', '[version:mysql]', '[version:php]'), array(get_software_version('wordpress'), get_software_version('mysql'), get_software_version('php')), $text); return $text; } add_filter('the_content', 'software_version');
Hope someone finds this useful. A bit cleaner than using RunPHP().
– Stephen
- The topic ‘Insert Software Version in Post or Page’ is closed to new replies.