Opened 10 years ago
Closed 7 years ago
#37629 closed enhancement (fixed)
is_sticky filter hook
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 5.3 | Priority: | normal |
| Severity: | normal | Version: | 4.6 |
| Component: | Posts, Post Types | Keywords: | good-first-bug has-patch |
| Focuses: | Cc: |
Description
The is_sticky() function needs an accompanying filter hook.
This way, plugins that have custom post types with a custom sticky post implementation can simply filter this when necessary. This way, we don't have to roll a custom pluginslug_is_sticky() function every time.
Attachments (1)
Change History (7)
#2
in reply to:
↑ 1
@
9 years ago
Replying to tdmalone:
How about the
pre_option_sticky_postsfilter?
There are other dynamic filters available in `get_option()` as well, which
is_sticky()calls.
By running a filter on that hook, you're filtering an option that's storing sticky posts of the post post type, not the result of the is_sticky() function. There's potential for some unintended consequences here when other code is calling get_option( 'sticky_posts' ).
While the option and the conditional are related by default, this is not necessarily true with custom sticky post implementations. Sticky posts can be stored in a variety of ways. A filter hook for the conditional function makes more sense in those scenarios.
#4
@
7 years ago
- Keywords has-patch added; needs-patch needs-docs removed
Changed conditions to prevent multiple apply_filters row. Made similar to the is_active_sidebar filter.
Enjoy :)
It's my the first contribution made at #WCEU
How about the
pre_option_sticky_postsfilter?There are other dynamic filters available in `get_option()` as well, which
is_sticky()calls.