Forked from terryupton/gist:e7637360fedc8e82b43e
Last active
August 29, 2015 14:23
-
-
Save mattclements/f8b8d89968973514b0bd to your computer and use it in GitHub Desktop.
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 | |
//MODIFIED HEADER DATE | |
################################################################################## | |
function set_headerdate() { | |
$format = "%a, %d %b %Y %H:%M:%S %z"; | |
// First check if there is a blog post date | |
if (function_exists('perch_blog_post_field') && function_exists('perch_get') && perch_blog_post_field(perch_get('s'), 'postDateTime', true)) { | |
$result = perch_blog_post_field(perch_get('s'), 'postDateTime', true); | |
header("Last-Modified: ".strftime($format, strtotime($result))); | |
} | |
//If a list and detail page then get the date passed into the template/edited. | |
else if (class_exists('PerchSystem') && PerchSystem::get_var('modified_date')) { | |
header("Last-Modified: ".PerchSystem::get_var('modified_date')); | |
} | |
// If not then is there a perch modified date? | |
else if(function_exists('perch_page_modified') && perch_page_modified(array('format' => $format), true)) { | |
header("Last-Modified: ".perch_page_modified(array('format' => $format), true)); | |
} | |
// Finally if not get the modified time-stamp of the actual file | |
else { | |
header("Last-Modified: ".strftime($format, filemtime($_SERVER['SCRIPT_FILENAME']))); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment