[wp-trac] [WordPress Trac] #31723: is_page( false ) === true ?

WordPress Trac noreply at wordpress.org
Sun Mar 22 14:36:19 UTC 2015


#31723: is_page( false ) === true ?
------------------------------+------------------------------
 Reporter:  Compute           |       Owner:
     Type:  defect (bug)      |      Status:  new
 Priority:  normal            |   Milestone:  Awaiting Review
Component:  Query             |     Version:
 Severity:  normal            |  Resolution:
 Keywords:  needs-unit-tests  |     Focuses:
------------------------------+------------------------------

Comment (by Compute):

 I have an option that filters the query:


 {{{
 if ( is_page( get_option( 'special_filter' ) ) {
     $query->set( 'special_filter', 1 );
 }
 }}}

 Above works if the option has been set (as the ID might be 54).

 But if the option has not been set it returns true on all pages. The fix
 is really to check for the option before passing it into the is_page()
 check:

 {{{
 $option = get_option( 'special_filter' );

 if ( ! $option ) {
     return $query;
 }

 if ( is_page( $option ) {
     $query->set( 'special_filter', 1 );
 }
 }}}

 To me it just seems wierd that is_page( false ) is true. If this is really
 working as intended then the description should be updated.

 I truely understand if it's a wontfix, I was just wondering WHY this makes
 any sense.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/31723#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list