Skip to content

Instantly share code, notes, and snippets.

@developdaly
Created November 28, 2012 03:25
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save developdaly/4158855 to your computer and use it in GitHub Desktop.
Save developdaly/4158855 to your computer and use it in GitHub Desktop.
This function gets the latest Beanstalk SVN/Git revision number for use in your theme/plugin
<?php
/**
* This function looks for the directory that "wp-config.php" resides in
* and then looks for a file named ".revision", the content of which is a
* single integer set by Beanstalk upon deployment.
*
* The purpose is to version static resources so that browsers will
* re-download any cached, outdated versions with the newer version.
*
* This will only work in environments that Beanstak deploys to.
*/
function get_beanstalk_revision() {
if (file_exists(dirname(ABSPATH) . '/wp-config.php')) {
$filename = dirname(ABSPATH) . '/.revision';
} else {
$filename = ABSPATH . '/.revision';
}
if (file_exists($filename)) {
$output = file_get_contents($filename);
} else {
return false;
}
return $output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment