Skip to content

Instantly share code, notes, and snippets.

@web-dev-media
Last active August 29, 2015 14:09
Show Gist options
  • Save web-dev-media/0b34ab44eb3d1aeee7ae to your computer and use it in GitHub Desktop.
Save web-dev-media/0b34ab44eb3d1aeee7ae to your computer and use it in GitHub Desktop.
<?php
/**
* Validat the last Modifikation of this File
* on modification flush the rewrite rules
*
* @return void
**/
public function flush_rules() {
$o = __NAMESPACE__;
$v = filemtime( __FILE__ );
$d = array( 'version' => 0, 'time' => time() );
$r = wp_parse_args( get_option( $o, array() ), $d );
if ( $r['version'] != $v ) {
flush_rewrite_rules();
$a = array( 'version' => $v, 'time' => time() );
if ( ! update_option( $o , $a ) ) {
add_option( $o , $a );
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment