/**
* Plugin Name: WP-Autocyler
* Plugin URI: http://www.0xfefefe.info/
* Description: Checks post/page expiry time and possibly sets 301 redirect, using post meta.
* Version: 0.1a
* License: GPLv2
*/
/**
* Load WP-Config file if this file is called directly
*/
if (!function_exists('add_action')) {
include_once('../../../wp-config.php');
}
add_action('get_header','autocycler');
function autocycler() {
if ( is_home() || is_category() || is_archive() || is_tag() ) return;
$post_id = url_to_postid($_SERVER['REQUEST_URI']);
$post_expire = get_post_meta($post_id, 'post_expiry', true);
if ($post_expire) {
$now = time();
if ($now > $post_expire) {
$redirect_url = get_post_meta($post_id, 'redirect_url', true);
header("HTTP/1.1 301 Moved Permanently");
header("Location: " . $redirect_url);
exit();
}
}
}
?>