Skip to content

Instantly share code, notes, and snippets.

@Irfan-Ansari
Forked from mjangda/dump-rewrite-rules.php
Created March 12, 2014 11:45
Show Gist options
  • Save Irfan-Ansari/9505275 to your computer and use it in GitHub Desktop.
Save Irfan-Ansari/9505275 to your computer and use it in GitHub Desktop.
<?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