[wp-trac] [WordPress Trac] #5430: Change is_page() to accept array
as argument
WordPress Trac
wp-trac at lists.automattic.com
Thu Dec 6 23:33:54 GMT 2007
#5430: Change is_page() to accept array as argument
-------------------------+--------------------------------------------------
Reporter: azaozz | Owner: anonymous
Type: enhancement | Status: new
Priority: normal | Milestone: 2.5
Component: Template | Version:
Severity: normal | Keywords:
-------------------------+--------------------------------------------------
I often see
{{{
if ( is_page(3) || is_page(8) || is_page(15) )
}}}
... etc. in templates. Same goes for is_single(), is_author(),
is_category() and perhaps is_tag(). It would be much cleaner/easier if
these conditional tags can accept an array as argument as well. The
attached patch changes the is_page() function to accept an array of page
IDs, page slugs or page titles and can be used like this:
{{{
$my_pages = array ( 3, 'another-page', 'Special Page' );
if ( is_page( $my_pages ) )
$do_something...
}}}
It is (of course) backwards compatible and there's no noticeable
performance hit at all, as is_page() is called just once instead of
several times.
--
Ticket URL: <http://trac.wordpress.org/ticket/5430>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list