[wp-trac] [WordPress Trac] #30501: Prevent flushing rewrites during page load
WordPress Trac
noreply at wordpress.org
Fri Jan 9 15:39:12 UTC 2015
#30501: Prevent flushing rewrites during page load
-------------------------------------------------+-------------------------
Reporter: joostdevalk | Owner:
Type: defect (bug) | SergeyBiryukov
Priority: normal | Status: accepted
Component: Permalinks | Milestone: 4.2
Severity: normal | Version:
Keywords: has-patch dev-feedback 4.2-early | Resolution:
commit | Focuses:
-------------------------------------------------+-------------------------
Comment (by pavelevap):
I am not sure if I understand it well, please see example code:
{{{
function some_rewrite() {
global $wp_rewrite;
$wp_rewrite->author_base = 'something';
$wp_rewrite->flush_rules();
}
add_action('init', 'some_rewrite');
}}}
Calling `$wp_rewrite->flush_rules()` is wrong here because it is called
during every page load. What is the right way for users when they want to
change author to something else? And they need only quick hack for
`functions.php` (and not flushing rewrite rules during plugin activation).
I saw many times this piece of code. It will work in 4.2 and only running
`$wp_rewrite->flush_rules()` function will be automatically moved to
`wp_loaded`?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/30501#comment:19>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list