[wp-trac] [WordPress Trac] #38888: Change `init` Priority For Hook: `widgets_init`
WordPress Trac
noreply at wordpress.org
Mon Nov 21 16:21:00 UTC 2016
#38888: Change `init` Priority For Hook: `widgets_init`
-----------------------------+-----------------------------
Reporter: michael.ecklund | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Widgets | Version: 4.6.1
Severity: normal | Keywords:
Focuses: administration |
-----------------------------+-----------------------------
The action/hook `init` is used for Custom Post Types and Custom Taxonomies
to be registered.
Most developers register Custom Post Types and Custom Taxonomies on `init`
with the default priority of (10) -- Especially since that's how the
examples are illustrated in the documentation on how to register Custom
Post Types and Custom Taxonomies.
Action/hook `widgets_init` is fired ON action/hook `init` with a priority
of (1).
You can see this if you look in `default-filters.php` for:
{{{
// Widgets
add_action( 'init', 'wp_widgets_init', 1 );
}}}
'''So what's the problem?'''
Widgets are completely unaware of Custom Post Types and Custom Taxonomies,
since they're registered on `init` with the default priority of (1) BEFORE
the Custom Post Types and Custom Taxonomies are registered for the most
part on `init` with a default priority of (10).
'''How to allow Widgets to be aware of Custom Post Types and Custom
Taxonomies?
'''
Simple. Change the priority from (1) to (10).
{{{
// Widgets
add_action( 'init', 'wp_widgets_init' );
}}}
Thoughts? Would this effect anything else? Why was it initially set to
(1)? Is there a reason for that?
If you want to make a push for the Theme Customizer, don't you think it
would be beneficial for Widgets to be aware of Custom Post Types and
Custom Taxonomies?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/38888>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list