Skip to content

Instantly share code, notes, and snippets.

@nomisoft
Created April 29, 2014 15:16
Show Gist options
  • Save nomisoft/11403388 to your computer and use it in GitHub Desktop.
Save nomisoft/11403388 to your computer and use it in GitHub Desktop.
WHM WordPress Versions Plugin
#!/usr/bin/php -q
<?
#WHMADDON:wordpressversions:WordPress Versions
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>WordPress Versions</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<link rel='stylesheet' type='text/css' href='/cPanel_magic_revision_0/combined_optimized.css' /><link rel='stylesheet' type='text/css' href='/cPanel_magic_revision_0/themes/x/style_optimized.css' /><link rel='stylesheet' type='text/css' href='/cPanel_magic_revision_0/yui/datatable/assets/skins/sam/datatable.css' /><style>.sortable th, .sortable td { padding: 5px; }</style>
</head>
<body>
<div id="doctitle"><h1>WordPress Versions</h1></div>
<div style="margin: 10px 20px">
<?
$latest_version = file_get_contents("http://api.wordpress.org/core/version-check/1.3/");
preg_match("{(\d\.\d)}",$latest_version,$latest_version);
$latest_version = $latest_version[1];
echo "<h2>Latest Version: ".$latest_version."</h2>";
echo '<table class="sortable">';
echo "<tr><th></th><th>Account</th><th>Version</th></tr>";
$wordpress = glob("/home/*/public_html/wp-includes/version.php");
foreach( $wordpress as $w ) {
$file = file_get_contents($w);
$pattern = "{wp_version = '([0-9\.]*)'}";
preg_match($pattern,$file,$version);
$pattern = "{/([a-zA-Z0-9\-]*)\/public_html}";
preg_match($pattern,$w,$account);
echo '<tr class="tdshade1"><td>';
if( $version[1] == $latest_version ) {
echo '<img src="/cPanel_magic_revision_0/cjt/images/icons/success.png" alt="Success" />';
} else {
echo '<img src="/cPanel_magic_revision_0/cjt/images/icons/error.png" alt="Error" />';
}
echo '</td><td>'.$account[1].'</td><td>'.$version[1]."</td></tr>";
}
echo "</table></div>";
?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment