admin管理员组

文章数量:1122832

I've inherited a site from another company recently and found this in their functions.php file:

function themeLoader()
{
  locate_template(include('inc/wp_reset.php'), true, true);
  locate_template(include('inc/acf_options.php'), true, true);
  locate_template(require('inc/bem_menu.php' ), true, true);
  locate_template(require('inc/menus.php' ), true, true);
  locate_template(require('inc/custom_wysiwyg_styles.php' ), true, true);
  locate_template(require('inc/custom_functions.php' ), true, true);
  locate_template(require('inc/resources-post-type.php' ), true, true);
  locate_template(require('inc/careers-post-type.php' ), true, true);
}

I've not seen require used as a function before like this, however after looking it up it seems that it can be used in either way.

However, each require is wrapped in a locate_template() call. Would I be right in assuming this locate_template() call does nothing and silently fails? If it was the other way round, require(locate_template('...')) it would make sense to me.

I think the developer got lucky and the folder structure of the theme just happened to match with their referenced paths.

本文标签: phprequire used as a function to load theme dependencies