Forked from web-dev-media/flush_rewrite_rules.php
Last active
August 29, 2015 14:09
-
-
Save derpixler/4318433a3edf6167ed61 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
/** | |
* Validat the last Modifikation of this File | |
* on modification flush the rewrite rules | |
* | |
* @return void | |
*/ | |
function flush_rules() { | |
$o = 'my-custom-flash-key'; | |
$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