WordPress.org

Make WordPress Core


Ignore:
Timestamp:
03/12/2015 04:27:06 PM (5 years ago)
Author:
helen
Message:

Allow is_page_template() to accept an array, as many other conditional tags do.

props morganestes, tyxla, DrewAPicture.
fixes #31271.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/post-template.php

    r31726 r31754  
    16301630 *
    16311631 * This template tag allows you to determine if you are in a page template.
    1632  * You can optionally provide a template name and then the check will be
    1633  * specific to that template.
     1632 * You can optionally provide a template name or array of template names
     1633 * and then the check will be specific to that template.
    16341634 *
    16351635 * @since 2.5.0
    1636  *
    1637  * @param string $template The specific template name if specific matching is required.
     1636 * @since 4.2.0 The `$template` parameter was changed to accept an array of page templates.
     1637 *
     1638 * @param string|array $template The specific template name or array of templates to match.
    16381639 * @return bool True on success, false on failure.
    16391640 */
     
    16491650    if ( $template == $page_template )
    16501651        return true;
     1652
     1653    if ( is_array( $template ) ) {
     1654        if ( ( in_array( 'default', $template, true ) && ! $page_template )
     1655            || in_array( $page_template, $template, true )
     1656        ) {
     1657            return true;
     1658        }
     1659    }
    16511660
    16521661    if ( 'default' == $template && ! $page_template )
Note: See TracChangeset for help on using the changeset viewer.