Skip to content

Instantly share code, notes, and snippets.

@rmccue
Last active Aug 29, 2015
Embed
What would you like to do?
<?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