Created
January 18, 2012 00:27
-
-
Save mikeschinkel/1629997 to your computer and use it in GitHub Desktop.
File Changed function from Sunrise.
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 | |
/** | |
* Used where you might want to use an activation function but where it's not convenient or possible (like in a theme.) | |
* Accepts __FILE__ for the a unique key to identify the file. | |
* | |
* @param string $file | |
* @return bool | |
* | |
* Author: Mike Schinkel | |
* Author URI: http://about.me/mikeschinkel/ | |
* | |
*/ | |
function sr_file_changed( $file ) { | |
$file_changed = false; | |
$files_changed = get_option( '_sr_files_last_changed' ); | |
if ( ! is_array( $files_changed ) ) | |
$files_changed = array(); | |
if ( isset($files_changed[$file]) ) { | |
$this_time = filemtime( $file ); | |
$file_changed = ($this_time > $files_changed[$file]); | |
$last_changed = $this_time; | |
} else { | |
$last_changed = filemtime( $file ); | |
$file_changed = true; | |
} | |
if ( $file_changed ) { | |
$files_changed[$file] = $last_changed; | |
update_option( '_sr_files_last_changed', $files_changed ); | |
} | |
return $file_changed; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment