[wp-trac] [WordPress Trac] #42834: Doc mismatch between developer. and codex., codex appears to be more correct
noreply at wordpress.org
Thu Jul 28 18:00:10 UTC 2022
#42834: Doc mismatch between developer. and codex., codex appears to be more
Reporter: kluny | Owner: (none)
Type: defect (bug) | Status: closed
Priority: normal | Milestone: WordPress.org
Component: Themes | Version:
Severity: normal | Resolution: fixed
Keywords: | Focuses: docs
Changes (by sabernhardt):
* status: new => closed
* resolution: => fixed
* milestone: Awaiting Review => WordPress.org
> I’m looking at some code that uses the switch_theme hook. The docs are
> quite different between the
> docs and the old
> Specifically, the old version specified that switch_theme is best used
> for things that should happen when a theme is *deactivated*, and actions
> related to the new theme should be on after_switch_theme. The new docs
> don’t make the distinction, but the code hasn’t changed since like 4.5.
> I'm wonder whether developer.wordpress.org has the most correct info?
I’m looking at some code that uses the `switch_theme` hook. The docs are
quite different between the
docs] and the
Specifically, the old version specified that `switch_theme` is best used
for things that should happen when a theme is *deactivated*, and actions
related to the new theme should be on `after_switch_theme`. The new docs
don’t make the distinction, but the code hasn’t changed since like 4.5.
I'm wonder whether developer.wordpress.org has the most correct info?
The current "More Information" section seems to have what is mentioned in
this ticket's description, so I'll close as fixed.
> `switch_theme` is triggered when the blog’s theme is changed.
Specifically, it fires after the theme has been switched but before the
next request. Theme developers should use this hook to do things when
their theme is deactivated.
> Theme functions attached to this hook are only triggered in the theme
being deactivated. To do things when your theme is activated, use
> Functions attached to this action hook receive one parameter: a string
with the name of the new theme being activated.
If there is something else to add, feel free to reopen.
Ticket URL: <https://core.trac.wordpress.org/ticket/42834#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac