[wp-trac] [WordPress Trac] #41152: New Function to Require a file
WordPress Trac
noreply at wordpress.org
Sat Jun 24 15:32:11 UTC 2017
#41152: New Function to Require a file
-----------------------------+-----------------------------
Reporter: rinkuyadav999 | Owner:
Type: feature request | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Themes | Version: trunk
Severity: normal | Keywords:
Focuses: |
-----------------------------+-----------------------------
Right now theme developers need to use php require and file path to
require a file. It will better, WordPress code provide a function to
supply path of file in a function and it will do reset of work. Like:
{{{#!php
<?php
/**
* Require the file of parent theme.
*
* @since 4.9.0
*
* @param string $file Required. File to require.
* @return required the file.
*/
function wp_require_parent_theme_file( $file = '' ) {
$file = ltrim( $file, '/' );
if ( ! empty( $file ) ) {
$path = get_template_directory() . '/' . $file;
} else {
return;
}
require $path;
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/41152>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list