Make WordPress Core

Opened 15 years ago

Closed 15 years ago

#10804 closed enhancement (duplicate)

New action activate_theme

Reported by: chrisjean's profile chrisjean Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.9
Component: Themes Keywords: has-patch
Focuses: Cc:

Description

The switch_theme action can be used as a (poorly named) theme deactivation action, but there isn't an action to latch into when a new theme is activated.

This results in people using code that watches for themes.php?activated=true in order to latch their theme activation code to. While this is functional, it has two primary problems:

  • It is highly-unnecessary to run that check on every admin page (I've even seen some not limit that check to admin only) when a simple action would be easier to use and wouldn't rely on all that consistent checking.
  • While the way the themes.php page may not change, it is still poor practice to tie important code to something that could easily change in the future.

I have a simple patch that adds an activate_theme action. This action passes along the name of the activated theme in case any non-theme code may be interested.

Attachments (1)

activate_theme_patch.diff (568 bytes) - added by chrisbliss18 15 years ago.

Download all attachments as: .zip

Change History (7)

#1 @scribu
15 years ago

  • Keywords theme activation action removed
  • Milestone changed from Unassigned to 2.9

#2 @dd32
15 years ago

  • Milestone 2.9 deleted
  • Resolution set to duplicate
  • Status changed from new to closed

See #7795: enhancement: Activate and Deactivate Theme hooks

#3 @chrisbliss18
15 years ago

  • Resolution duplicate deleted
  • Status changed from closed to reopened

The search on Trac really needs work. I dug around for a while and never found that.

Putting that aside, you're seriously going to close this out dd32? You submitted a patch, it got stale and marked as needs-patch, it stalled, and apparently people can't agree if your changes (which quick frankly are a bit over-the-top by comparison to my simple one-liner) are appropriate or not.

So, why not just have my patch go in, and then people can hash out a rewrite of the system if they want? For now, we need to get a hook in there.

#4 @dd32
15 years ago

  • Milestone set to 2.9
  • Version set to 2.9

It was not due to me previously submitting a patch, It was due to the fact a existing ticket exists with prior talk already.

I meant to add, Please do post your thoughts and/or patch there, As its relevant to that ticket, And not worth having 2 seperate discussions on trac.

I do agree about the search sucking, But "Theme Activation" brings it up.. Not too hard to look through half a dozen items.

Not going to get into a closing war however, Leaving this for someone else. I'd prefer to push for a full implementation rather than a single hook however..

#5 follow-up: @chrisbliss18
15 years ago

I'll go ahead and leave it open for now. In my opinion, we're going for two different things. I'm just wanting a quick fix that provides a solid, supported method of doing something without a "hack" job. Your solution is a change that will modify the existing API in an attempt to supersede it.

If the devs decide to go for your option over mine, I'll have no beef with that. I just want a solution that provides both deactivation and activation action ability for themes.

#6 in reply to: ↑ 5 @westi
15 years ago

  • Milestone 2.9 deleted
  • Resolution set to duplicate
  • Status changed from reopened to closed

Replying to chrisbliss18:

I'll go ahead and leave it open for now. In my opinion, we're going for two different things. I'm just wanting a quick fix that provides a solid, supported method of doing something without a "hack" job. Your solution is a change that will modify the existing API in an attempt to supersede it.

If the devs decide to go for your option over mine, I'll have no beef with that. I just want a solution that provides both deactivation and activation action ability for themes.

Please move all discussion and patches to the original ticket.

Many Thanks

Note: See TracTickets for help on using tickets.