I am creating a WordPress Framework and within it there is the standard functions.php file. I will create new themes based on the framework which will use the framework functions.php file but have theme specific css/js/functions that will be needed. This is not a child theme. Can I in the main functions.php file call say theme_function.php which will house the theme specific functions,enqueues and other include calls?
2 Answers
The functions.php
is convention for a file that will be automatically loaded by WordPress.
From there it is a normal PHP mechanics. You can further include any other PHP files in it. In some themes it is the only thing that a "root" functions.php
does.
You can include or require other php files in your functions.php file or you could consider using a plugin. Plugins will run on any theme, so if this isn't what you want, you could consider some code in your plugin to check if your theme is active or not, such as:
<?php
$theme = wp_get_theme(); // gets the current theme
if ('twentytwelve' == $theme->name || 'twentytwelve' == $theme->parent_theme) {
// if you're here twenty twelve is the active theme or is
// the current theme's parent theme
// Run your theme specific code here which will be ignored for other themes
}
Note - Code taken/modified from: How to check if a theme is active?
include
statements.