Opened 3 years ago

Last modified 14 months ago

#14849 new enhancement

Rewrite rules should be flushed when you switch themes

Reported by: jorbin Owned by:
Priority: normal Milestone: Future Release
Component: Permalinks Version: 3.0
Severity: normal Keywords: needs-patch
Cc: johnpbloch, Ken@…

Description

@nacin said so at WCMA, so here's a patch to do it.

Attachments (1)

theme.php.15608.diff (380 bytes) - added by jorbin 3 years ago.

Download all attachments as: .zip

Change History (13)

jorbin3 years ago

Why should rewrite rules be flushed when switching themes?

comment:2 follow-up: ↓ 3   filosofo3 years ago

I suppose in case a theme is using custom post types. But it seems that, like plugins, themes that need flushed rules should handle it themselves.

comment:3 in reply to: ↑ 2   nacin3 years ago

Replying to filosofo:

But it seems that, like plugins, themes that need flushed rules should handle it themselves.

Unfortunately, there's no activation hook for them to do so. (For example P2 uses an option to store whether rules have been flushed.) I suggested this in response to a question for how to handle things that add rewrite rules...

I don't think this patch will work, though, because the new theme isn't included on that pageload so the old rules will still be regenerated. Sounds to me that to do an activation hook for themes, we need to add an autoloaded option to keep track.

Adding an activation hook sounds like the best solution for this. We have switch_theme, which works on deactivation. Themes that add custom post types and taxonomies should be flushing the rewrite rules themselves.

+1 for theme activation hook.

comment:6   dd323 years ago

  • Keywords needs-patch added; has-patch removed

resetting keywords since the attached patch will not work as intended.

comment:7   jane3 years ago

  • Version set to 3.0

If anyone would like to get this in for 3.1, there are a few days left to submit patches for enhancements before freeze.

  • Cc johnpbloch added
  • Milestone changed from 3.1 to Future Release

This is done in 3.1 on wp-admin/themes.php. We should do this better, in conjunction with a real theme activation hook, in the future.

Last edited 2 years ago by nacin (previous) (diff)

FYI, the jank was removed in 3.1. [17241]. Need to do this properly in 3.2.

  • Cc Ken@… added

Related: #7795

Note: See TracTickets for help on using tickets.