[wp-trac] [WordPress Trac] #26064: Twenty Fourteen: Correct $query usage in Featured_Content::pre_get_posts()

WordPress Trac noreply at wordpress.org
Sat Nov 16 13:32:53 UTC 2013


#26064: Twenty Fourteen: Correct $query usage in Featured_Content::pre_get_posts()
----------------------------+------------------------------
 Reporter:  SergeyBiryukov  |      Owner:
     Type:  defect (bug)    |     Status:  new
 Priority:  normal          |  Milestone:  3.8
Component:  Bundled Theme   |    Version:  trunk
 Severity:  normal          |   Keywords:  has-patch commit
----------------------------+------------------------------
 Background: [26189] (which should have had a ticket).

 `Featured_Content::pre_get_posts()` has some issues:
 1. No need to set the default `$query` value to false. The method is
 hooked to `pre_get_posts` action and is not called separately, so a
 `WP_Query` object is always passed.
 2. The `is_a( $query, 'WP_Query' )` check is redundant for the same
 reason.
 3. `$query->is_home()` method should be used instead of the `is_home()`
 template tag. Before [26189], this was causing a `_doing_it_wrong()`
 notice in unit tests. [26189] avoided the notice by moving `is_home()` to
 the end of the condition. I guess using `$query->is_home()` would be the
 more correct fix.

--
Ticket URL: <http://core.trac.wordpress.org/ticket/26064>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list