Skip to content

Instantly share code, notes, and snippets.

@ellefsen
Forked from developdaly/get_beanstalk_revision.php
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ellefsen/3ab1a80e125f2f869cf8 to your computer and use it in GitHub Desktop.
Save ellefsen/3ab1a80e125f2f869cf8 to your computer and use it in GitHub Desktop.
<?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