Ticket #18450: rewrite.diff
File rewrite.diff, 1.8 KB (added by , 13 years ago) |
---|
-
wp-includes/rewrite.php
1927 1927 } 1928 1928 1929 1929 /** 1930 * Schedules a flush of the rewrite rules. 1931 * 1932 * @since 2.0.1 1933 * @access public 1934 * @param bool $hard Whether to update .htaccess (hard flush) or just update rewrite_rules option (soft flush). Default is true (hard). 1935 */ 1936 function flush_rules( $hard = true ) { 1937 if ( !did_action( 'admin_init' ) ) { 1938 _doing_it_wrong( __( 'Never flush rules before admin_init, and NEVER on a front-end page load! Do it on plugin activation instead.' ) ); 1939 return false; 1940 } 1941 if ( $hard ) 1942 add_filter( 'shutdown_filter_rewrite_rules_hard', '__return_true' ); 1943 add_action( 'shutdown', '_wp_shutdown_flush_rules' ); 1944 } 1945 1946 /** 1930 1947 * Remove rewrite rules and then recreate rewrite rules. 1931 1948 * 1932 1949 * Calls {@link WP_Rewrite::wp_rewrite_rules()} after removing the 1933 1950 * 'rewrite_rules' option. If the function named 'save_mod_rewrite_rules' 1934 1951 * exists, it will be called. 1935 1952 * 1936 * @since 2.0.1 1937 * @access public 1938 * @param bool $hard Whether to update .htaccess (hard flush) or just update rewrite_rules option (soft flush). Default is true (hard). 1953 * @since 3.4 1954 * @access private 1939 1955 */ 1940 function flush_rules($hard = true) { 1956 function _wp_shutdown_flush_rules() { 1957 if ( !did_action( 'shutdown' ) ) { 1958 _doing_it_wrong( __( 'Do not call this function directly, use flush_rules instead.' ) ); 1959 return false; 1960 } 1941 1961 delete_option('rewrite_rules'); 1942 1962 $this->wp_rewrite_rules(); 1963 1964 $hard = apply_filters( 'shutdown_filter_rewrite_rules_hard', false ); 1965 1943 1966 if ( $hard && function_exists('save_mod_rewrite_rules') ) 1944 1967 save_mod_rewrite_rules(); 1945 1968 if ( $hard && function_exists('iis7_save_url_rewrite_rules') )