Advertisement
swte

Untitled

Jun 23rd, 2023 (edited)
1,175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.37 KB | None | 0 0
  1. /**
  2.  * Plugin Name: Permalink Reset
  3.  */
  4.  
  5. add_action( 'reset_rewrite_cron', 'reset_rewrites' );
  6.  
  7. add_action('wp', function(){
  8.     if ( !wp_next_scheduled( 'reset_rewrite_cron' ) ) {
  9.         wp_schedule_event( time(), 'hourly', 'reset_rewrite_cron' );
  10.     }
  11.    
  12.     if (is_404()){
  13.         reset_rewrites();
  14.     }
  15. });
  16.  
  17. function reset_rewrites(){
  18.      delete_option('rewrite_rules');
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement