<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[38578] trunk: Themes: Improve child theme file inheritance by introducing functions for locating and fetching the URL or path to files within child and parent themes.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/38578">38578</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/38578","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>johnbillion</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2016-09-08 22:53:57 +0000 (Thu, 08 Sep 2016)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Themes: Improve child theme file inheritance by introducing functions for locating and fetching the URL or path to files within child and parent themes.

The most useful function this introduces is `get_theme_file_uri()`, which returns the URL to the specified file in the child theme if it exists, and falls back to the URL to the specified file in the parent theme. This allows parent themes to reference files (including enqueuing CSS and JavaScript files) that can be overridden by the child theme simply by existing.

This change also introduces `get_theme_file_path()`, which is the file path equivalent of `get_theme_file_uri()`.

Finally, `get_parent_theme_file_uri()` and `get_parent_theme_file_path()` are also introduced, which allow a theme to specifically reference a file URL or file path in the parent theme. These can be used as replacements for `get_template_directory_uri()` and `get_template_directory()` respectively, for consistency.

Props johnbillion, georgestephanis, gma992.
Fixes <a href="https://core.trac.wordpress.org/ticket/18302">#18302</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludeslinktemplatephp">trunk/src/wp-includes/link-template.php</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li>trunk/tests/phpunit/data/theme-file-child/</li>
<li><a href="#trunktestsphpunitdatathemefilechildchildonlyphp">trunk/tests/phpunit/data/theme-file-child/child-only.php</a></li>
<li><a href="#trunktestsphpunitdatathemefilechildparentandchildphp">trunk/tests/phpunit/data/theme-file-child/parent-and-child.php</a></li>
<li><a href="#trunktestsphpunitdatathemefilechildstylecss">trunk/tests/phpunit/data/theme-file-child/style.css</a></li>
<li>trunk/tests/phpunit/data/theme-file-parent/</li>
<li><a href="#trunktestsphpunitdatathemefileparentparentandchildphp">trunk/tests/phpunit/data/theme-file-parent/parent-and-child.php</a></li>
<li><a href="#trunktestsphpunitdatathemefileparentparentonlyphp">trunk/tests/phpunit/data/theme-file-parent/parent-only.php</a></li>
<li><a href="#trunktestsphpunitdatathemefileparentstylecss">trunk/tests/phpunit/data/theme-file-parent/style.css</a></li>
<li><a href="#trunktestsphpunittestslinkthemeFilephp">trunk/tests/phpunit/tests/link/themeFile.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludeslinktemplatephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/link-template.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/link-template.php   2016-09-08 15:44:08 UTC (rev 38577)
+++ trunk/src/wp-includes/link-template.php     2016-09-08 22:53:57 UTC (rev 38578)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -930,7 +930,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        $tax = get_taxonomy( $term->taxonomy );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        if ( ! $tax || ! current_user_can( $tax->cap->edit_terms ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! $tax || ! current_user_can( 'edit_term', $term->term_id ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                 return;
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -984,8 +984,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">                return;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        $tax = get_taxonomy( $term->taxonomy );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        if ( ! current_user_can( $tax->cap->edit_terms ) )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! current_user_can( 'edit_term', $term->term_id ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                 return;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        }
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        if ( empty( $link ) )
</span><span class="cx" style="display: block; padding: 0 10px">                $link = __('Edit This');
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4023,3 +4024,125 @@
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        return apply_filters( 'get_avatar_data', $args, $id_or_email );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+/**
+ * Retrieve the URL of a file in the theme.
+ *
+ * Searches in the stylesheet directory before the template directory so themes
+ * which inherit from a parent theme can just override one file.
+ *
+ * @since 4.7.0
+ *
+ * @param string $file Optional. File to search for in the stylesheet directory.
+ * @return string The URL of the file.
+ */
+function get_theme_file_uri( $file = '' ) {
+       $file = ltrim( $file, '/' );
+
+       if ( empty( $file ) ) {
+               $url = get_stylesheet_directory_uri();
+       } elseif ( file_exists( get_stylesheet_directory() . '/' . $file ) ) {
+               $url = get_stylesheet_directory_uri() . '/' . $file;
+       } else {
+               $url = get_template_directory_uri() . '/' . $file;
+       }
+
+       /**
+        * Filter the URL to a file in the theme.
+        *
+        * @since 4.7.0
+        *
+        * @param string $url  The file URL.
+        * @param string $file The requested file to search for.
+        */
+       return apply_filters( 'theme_file_uri', $url, $file );
+}
+
+/**
+ * Retrieve the URL of a file in the parent theme.
+ *
+ * @since 4.7.0
+ *
+ * @param string $file Optional. File to return the URL for in the template directory.
+ * @return string The URL of the file.
+ */
+function get_parent_theme_file_uri( $file = '' ) {
+       $file = ltrim( $file, '/' );
+
+       if ( empty( $file ) ) {
+               $url = get_template_directory_uri();
+       } else {
+               $url = get_template_directory_uri() . '/' . $file;
+       }
+
+       /**
+        * Filter the URL to a file in the parent theme.
+        *
+        * @since 4.7.0
+        *
+        * @param string $url  The file URL.
+        * @param string $file The requested file to search for.
+        */
+       return apply_filters( 'parent_theme_file_uri', $url, $file );
+}
+
+/**
+ * Retrieve the path of a file in the theme.
+ *
+ * Searches in the stylesheet directory before the template directory so themes
+ * which inherit from a parent theme can just override one file.
+ *
+ * @since 4.7.0
+ *
+ * @param string $file Optional. File to search for in the stylesheet directory.
+ * @return string The path of the file.
+ */
+function get_theme_file_path( $file = '' ) {
+       $file = ltrim( $file, '/' );
+
+       if ( empty( $file ) ) {
+               $path = get_stylesheet_directory();
+       } elseif ( file_exists( get_stylesheet_directory() . '/' . $file ) ) {
+               $path = get_stylesheet_directory() . '/' . $file;
+       } else {
+               $path = get_template_directory() . '/' . $file;
+       }
+
+       /**
+        * Filter the path to a file in the theme.
+        *
+        * @since 4.7.0
+        *
+        * @param string $path The file path.
+        * @param string $file The requested file to search for.
+        */
+       return apply_filters( 'theme_file_path', $path, $file );
+}
+
+/**
+ * Retrieve the path of a file in the parent theme.
+ *
+ * @since 4.7.0
+ *
+ * @param string $file Optional. File to return the path for in the template directory.
+ * @return string The path of the file.
+ */
+function get_parent_theme_file_path( $file = '' ) {
+       $file = ltrim( $file, '/' );
+
+       if ( empty( $file ) ) {
+               $path = get_template_directory();
+       } else {
+               $path = get_template_directory() . '/' . $file;
+       }
+
+       /**
+        * Filter the path to a file in the parent theme.
+        *
+        * @since 4.7.0
+        *
+        * @param string $path The file path.
+        * @param string $file The requested file to search for.
+        */
+       return apply_filters( 'parent_theme_file_path', $path, $file );
+}
</ins></span></pre></div>
<a id="trunktestsphpunitdatathemefilechildchildonlyphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/tests/phpunit/data/theme-file-child/child-only.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/data/theme-file-child/child-only.php                          (rev 0)
+++ trunk/tests/phpunit/data/theme-file-child/child-only.php    2016-09-08 22:53:57 UTC (rev 38578)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<!-- child only -->
</ins></span></pre></div>
<a id="trunktestsphpunitdatathemefilechildparentandchildphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/tests/phpunit/data/theme-file-child/parent-and-child.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/data/theme-file-child/parent-and-child.php                            (rev 0)
+++ trunk/tests/phpunit/data/theme-file-child/parent-and-child.php      2016-09-08 22:53:57 UTC (rev 38578)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<!-- parent and child -->
</ins></span></pre></div>
<a id="trunktestsphpunitdatathemefilechildstylecss"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/tests/phpunit/data/theme-file-child/style.css</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/data/theme-file-child/style.css                               (rev 0)
+++ trunk/tests/phpunit/data/theme-file-child/style.css 2016-09-08 22:53:57 UTC (rev 38578)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,4 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/*
+Theme Name: Child Theme
+Template: theme-file-parent
+*/
</ins></span></pre></div>
<a id="trunktestsphpunitdatathemefileparentparentandchildphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/tests/phpunit/data/theme-file-parent/parent-and-child.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/data/theme-file-parent/parent-and-child.php                           (rev 0)
+++ trunk/tests/phpunit/data/theme-file-parent/parent-and-child.php     2016-09-08 22:53:57 UTC (rev 38578)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<!-- parent and child -->
</ins></span></pre></div>
<a id="trunktestsphpunitdatathemefileparentparentonlyphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/tests/phpunit/data/theme-file-parent/parent-only.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/data/theme-file-parent/parent-only.php                                (rev 0)
+++ trunk/tests/phpunit/data/theme-file-parent/parent-only.php  2016-09-08 22:53:57 UTC (rev 38578)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<!-- parent only -->
</ins></span></pre></div>
<a id="trunktestsphpunitdatathemefileparentstylecss"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/tests/phpunit/data/theme-file-parent/style.css</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/data/theme-file-parent/style.css                              (rev 0)
+++ trunk/tests/phpunit/data/theme-file-parent/style.css        2016-09-08 22:53:57 UTC (rev 38578)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,3 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/*
+Theme Name: Parent Theme
+*/
</ins></span></pre></div>
<a id="trunktestsphpunittestslinkthemeFilephp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/tests/phpunit/tests/link/themeFile.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/link/themeFile.php                              (rev 0)
+++ trunk/tests/phpunit/tests/link/themeFile.php        2016-09-08 22:53:57 UTC (rev 38578)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,146 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+<?php
+/**
+ * @group link
+ */
+class Test_Theme_File extends WP_UnitTestCase {
+
+       public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+               symlink( DIR_TESTDATA . '/theme-file-parent', WP_CONTENT_DIR . '/themes/theme-file-parent' );
+               symlink( DIR_TESTDATA . '/theme-file-child', WP_CONTENT_DIR . '/themes/theme-file-child' );
+       }
+
+       public static function wpTearDownAfterClass() {
+               unlink( WP_CONTENT_DIR . '/themes/theme-file-parent' );
+               unlink( WP_CONTENT_DIR . '/themes/theme-file-child' );
+       }
+
+       /**
+        * @ticket 18302
+        *
+        * @dataProvider data_theme_files
+        */
+       public function test_theme_file_uri_with_parent_theme( $file, $expected_theme, $existence ) {
+               switch_theme( 'theme-file-parent' );
+
+               // Ensure the returned URL always uses the parent theme:
+               $this->assertSame( content_url( "themes/theme-file-parent/{$file}" ), get_theme_file_uri( $file ) );
+               $this->assertSame( content_url( "themes/theme-file-parent/{$file}" ), get_parent_theme_file_uri( $file ) );
+       }
+
+       /**
+        * @ticket 18302
+        *
+        * @dataProvider data_theme_files
+        */
+       public function test_theme_file_uri_with_child_theme( $file, $expected_theme, $existence ) {
+               switch_theme( 'theme-file-child' );
+
+               // Ensure the returned URL uses the expected theme:
+               $this->assertSame( content_url( "themes/{$expected_theme}/{$file}" ), get_theme_file_uri( $file ) );
+
+               // Ensure the returned URL always uses the parent theme:
+               $this->assertSame( content_url( "themes/theme-file-parent/{$file}" ), get_parent_theme_file_uri( $file ) );
+       }
+
+       /**
+        * @ticket 18302
+        *
+        * @dataProvider data_theme_files
+        */
+       public function test_theme_file_path_with_parent_theme( $file, $expected_theme, $existence ) {
+               switch_theme( 'theme-file-parent' );
+
+               // Ensure the returned path always uses the parent theme:
+               $this->assertSame( WP_CONTENT_DIR . "/themes/theme-file-parent/{$file}", get_theme_file_path( $file ) );
+               $this->assertSame( WP_CONTENT_DIR . "/themes/theme-file-parent/{$file}", get_parent_theme_file_path( $file ) );
+       }
+
+       /**
+        * @ticket 18302
+        *
+        * @dataProvider data_theme_files
+        */
+       public function test_theme_file_path_with_child_theme( $file, $expected_theme, $existence ) {
+               switch_theme( 'theme-file-child' );
+
+               // Ensure the returned path uses the expected theme:
+               $this->assertSame( WP_CONTENT_DIR . "/themes/{$expected_theme}/{$file}", get_theme_file_path( $file ) );
+
+               // Ensure the returned path always uses the parent theme:
+               $this->assertSame( WP_CONTENT_DIR . "/themes/theme-file-parent/{$file}", get_parent_theme_file_path( $file ) );
+       }
+
+       /**
+        * Test the tests.
+        *
+        * @ticket 18302
+        *
+        * @dataProvider data_theme_files
+        */
+       public function test_theme_file_existance( $file, $expected_theme, $existence ) {
+
+               if ( in_array( 'theme-file-child', $existence, true ) ) {
+                       $this->assertFileExists( WP_CONTENT_DIR . "/themes/theme-file-child/{$file}" );
+               } else {
+                       $this->assertFileNotExists( WP_CONTENT_DIR . "/themes/theme-file-child/{$file}" );
+               }
+
+               if ( in_array( 'theme-file-parent', $existence, true ) ) {
+                       $this->assertFileExists( WP_CONTENT_DIR . "/themes/theme-file-parent/{$file}" );
+               } else {
+                       $this->assertFileNotExists( WP_CONTENT_DIR . "/themes/theme-file-parent/{$file}" );
+               }
+
+       }
+
+       /**
+        * @ticket 18302
+        *
+        * @dataProvider data_theme_files
+        */
+       public function test_theme_file_uri_returns_valid_uri( $file, $expected_theme, $existence ) {
+               $uri = get_theme_file_uri( $file );
+               $parent_uri = get_parent_theme_file_uri( $file );
+
+               $this->assertSame( esc_url_raw( $uri ), $uri );
+               $this->assertSame( esc_url_raw( $parent_uri ), $parent_uri );
+       }
+
+       public function data_theme_files() {
+               $parent = 'theme-file-parent';
+               $child  = 'theme-file-child';
+
+               return array(
+                       array(
+                               'parent-only.php',
+                               $parent,
+                               array(
+                                       $parent,
+                               ),
+                       ),
+                       array(
+                               'child-only.php',
+                               $child,
+                               array(
+                                       $child,
+                               ),
+                       ),
+                       array(
+                               'parent-and-child.php',
+                               $child,
+                               array(
+                                       $parent,
+                                       $child,
+                               ),
+                       ),
+                       array(
+                               'neither.php',
+                               $parent,
+                               array(
+                               ),
+                       ),
+               );
+       }
+
+}
</ins></span></pre>
</div>
</div>

</body>
</html>