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.
require
ends withreturn ...
then require will return this value. but with or without these return,locate_template
will just calculate a path and do nothing more then I'm sure that removinglocate_template
in this code will not alter the website. moreover, managing a CPT in a theme instead of a plugin is a very dangerous way of coding. I wish you good courage to handle this website, you will maybe found other oddity like that.