Skip to content

Instantly share code, notes, and snippets.

@mjangda
Created June 15, 2012 17:43
Show Gist options
  • Save mjangda/2937797 to your computer and use it in GitHub Desktop.
Save mjangda/2937797 to your computer and use it in GitHub Desktop.
Dump a list of your rewrite rules.
<?php
function dump_rewrite_rules() {
$tmp_file = '/tmp/rewrite_rule_dump.txt'; // define filename here if needed
if ( !touch( $tmp_file ) || !is_writeable( $tmp_file ) ) {
error_log( 'dump_rewrite_rules: The file ' . $tmp_file . ' is not writable. Please check the permissions.' );
return;
}
global $wp_rewrite;
$rules = var_export( $wp_rewrite, true );
file_put_contents( $tmp_file, $rules );
error_log( 'dump_rewrite_rules: Your dump is available at ' . $tmp_file );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment