Skip to content

Instantly share code, notes, and snippets.

@rmccue
Last active August 29, 2015 14:02
Show Gist options
  • Save rmccue/667e8d35a2d6ef32eacb to your computer and use it in GitHub Desktop.
Save rmccue/667e8d35a2d6ef32eacb to your computer and use it in GitHub Desktop.
<?php
add_action( 'wp_loaded', function() {
global $wp_rewrite;
$wp_rewrite->matches = 'matches';
$rules = $wp_rewrite->rewrite_rules( true );
if ( update_option('rewrite_rules', $rules) ) {
$title = 'Rewrites: Flushed';
}
else {
$title = 'Rewrites: Cached';
}
add_action( 'admin_bar_menu', function ( $wp_admin_bar ) use ( $title ) {
$wp_admin_bar->add_menu( array(
'id' => 'rewrite-flush',
'title' => $title,
'parent' => 'top-secondary',
) );
}, 150 );
}, 9999 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment