[wp-trac] [WordPress Trac] #42834: Doc mismatch between developer. and codex., codex appears to be more correct

WordPress Trac noreply at wordpress.org
Thu Jul 28 18:00:10 UTC 2022


#42834: Doc mismatch between developer. and codex., codex appears to be more
correct
--------------------------+----------------------------
 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


Old description:

> I’m looking at some code that uses the switch_theme hook. The docs are
> quite different between the
> (current)[https://developer.wordpress.org/reference/hooks/switch_theme/]
> docs and the old
> (codex)[https://codex.wordpress.org/Plugin_API/Action_Reference/switch_theme].
>
> 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?

New description:

 I’m looking at some code that uses the `switch_theme` hook. The docs are
 quite different between the
 [https://developer.wordpress.org/reference/hooks/switch_theme/ current
 docs] and the
 [https://codex.wordpress.org/Plugin_API/Action_Reference/switch_theme old
 codex].

 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?

--

Comment:

 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
 [https://developer.wordpress.org/reference/hooks/switch_theme/
 after_switch_theme].
 >
 > 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 mailing list