How to write a #WordPress #plugin with an #expiration #date.

glassy-smiley-badToday we want to cover something which recently come into our focus. We needed a plugin with an expiration date. A plugin which it literally retires itself. The plugin should work on older posts but the new ones shouldn’t be affected. The question remains how to do this per post basis?

We made an example which retired last monday.

global $post; //to get the current post or page
$local_timestamp = get_post_time('U',true,$post->ID); //get timestamp of current post
$retired_time="1403095251"; //the timestamp when it retires

if($local_timestamp < $retired_time){
$retired=true;
}else{$retired=false;}

/*this is exaclty the other way round. because when you type now */
if($retired) {//do something
/*because it is only doing that if $retired = true but of course it is already retired and in natural speking it is retired and we would say $retired=false. */
}

This is pretty awesome and easy. Stay tuned!