Make WordPress Core


Ignore:
Timestamp:
03/12/2015 04:27:06 PM (11 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/tests/phpunit/tests/query/conditionals.php

    r31622 r31754  
    961961                $this->assertFalse( $q->is_page( $p2 ) );
    962962        }
     963
     964        function test_is_page_template() {
     965                $post_id = $this->factory->post->create( array( 'post_type' => 'page' ) );
     966                update_post_meta($post_id, '_wp_page_template', 'example.php');
     967                $this->go_to( "/?page_id=$post_id" );
     968                $this->assertTrue( is_page_template( 'example.php' ) );
     969        }
     970
     971        /**
     972         * @ticket 31271
     973         */
     974        function test_is_page_template_default() {
     975                $post_id = $this->factory->post->create( array( 'post_type' => 'page' ) );
     976                $this->go_to( "/?page_id=$post_id" );
     977                $this->assertTrue( is_page_template( 'default' ) );
     978                $this->assertTrue( is_page_template( array( 'random', 'default' ) ) );
     979        }
     980
     981        /**
     982         * @ticket 31271
     983         */
     984        function test_is_page_template_array() {
     985                $post_id = $this->factory->post->create( array( 'post_type' => 'page' ) );
     986                update_post_meta($post_id, '_wp_page_template', 'example.php');
     987                $this->go_to( "/?page_id=$post_id" );
     988                $this->assertFalse( is_page_template( array( 'test.php' ) ) );
     989                $this->assertTrue( is_page_template( array('test.php', 'example.php') ) );
     990        }
    963991}
Note: See TracChangeset for help on using the changeset viewer.