WordPress.org

Make WordPress Core

Ticket #18450: doing_it_wrong.18450.diff

File doing_it_wrong.18450.diff, 710 bytes (added by scribu, 22 months ago)
  • wp-includes/rewrite.php

    diff --git a/wp-includes/rewrite.php b/wp-includes/rewrite.php
    index a7349ab..ebc42c1 100644
    a b class WP_Rewrite { 
    18571857         * @param bool $hard Whether to update .htaccess (hard flush) or just update rewrite_rules option (soft flush). Default is true (hard). 
    18581858         */ 
    18591859        function flush_rules($hard = true) { 
     1860                if ( !did_action( 'admin_init' ) ) { 
     1861                        _doing_it_wrong( __( 'Never flush rules before admin_init, and NEVER on a front-end page load! Do it on plugin activation instead.' ) ); 
     1862                        return false; 
     1863                } 
     1864 
    18601865                delete_option('rewrite_rules'); 
    18611866                $this->wp_rewrite_rules(); 
    18621867                if ( $hard && function_exists('save_mod_rewrite_rules') )