Example #1
0
/**
 * Include a specific file based on directory and filename
 * 
 * @param string $dir Directory the file will be in
 * @param string $file Filename
 * @param array $data pass in data to be extracted for use by the template
 * 
**/
function cfct_template_file($dir, $file, $data = array())
{
    $path = '';
    if (!empty($file)) {
        $file = basename($file, '.php');
        /* Check for file in the child theme first
        		var name is deliberately funny. Avoids inadvertantly
        		overwriting path variable with extract() below. */
        $_cfct_filepath = STYLESHEETPATH . '/' . $dir . '/' . $file . '.php';
        if (!file_exists($_cfct_filepath)) {
            $_cfct_filepath = CFCT_PATH . $dir . '/' . $file . '.php';
        }
    }
    if (file_exists($_cfct_filepath)) {
        /* Extract $data as late as possible, so we don't accidentally overwrite
        		local function vars */
        extract($data);
        include $_cfct_filepath;
    } else {
        cfct_die('Error loading ' . $file . ' ' . __LINE__);
    }
}
Example #2
0
function cfct_template_file($dir, $file, $data = null)
{
    $path = '';
    if (!empty($file)) {
        $file = basename($file, '.php');
        // child theme support
        $path = STYLESHEETPATH . '/' . $dir . '/' . $file . '.php';
        if (!file_exists($path)) {
            $path = CFCT_PATH . $dir . '/' . $file . '.php';
        }
    }
    if (file_exists($path)) {
        include $path;
    } else {
        cfct_die('Error loading ' . $file . ' ' . __LINE__);
    }
}
Example #3
0
function cfct_template_file($dir, $file)
{
    $path = '';
    global $tpl_set;
    if (!empty($file)) {
        $file = basename($file, '.php');
        $path = CFCT_PATH . $tpl_set . $dir . '/' . $file . '.php';
    }
    if (file_exists($path)) {
        include $path;
    } else {
        cfct_die('Error loading ' . $file . ' ' . __LINE__);
    }
}
/**
 * Include a specific file based on directory and filename
 * 
 * @param string $dir Directory the file will be in
 * @param string $file Filename
 * @param array $data pass in data to be extracted for use by the template
 * 
**/
function cfct_template_file($dir, $file, $data = array())
{
    // bring in expected globals so that templates don't need to bring them in
    // added in version 3.4 - can be overridden via filter
    $global_vars = apply_filters('cfct_template_file_globals', array('posts', 'post', 'wp_did_header', 'wp_did_template_redirect', 'wp_query', 'wp_rewrite', 'wpdb', 'wp_version', 'wp', 'id', 'comment', 'user_ID'));
    if (is_array($global_vars)) {
        foreach ($global_vars as $global_var) {
            global ${$global_var};
        }
    }
    $path = '';
    if (!empty($file)) {
        $file = basename($file, '.php');
        /* Check for file in the child theme first
        		var name is deliberately funny. Avoids inadvertantly
        		overwriting path variable with extract() below. */
        $_cfct_filepath = STYLESHEETPATH . '/' . $dir . '/' . $file . '.php';
        if (!file_exists($_cfct_filepath)) {
            $_cfct_filepath = CFCT_PATH . $dir . '/' . $file . '.php';
        }
    }
    if (file_exists($_cfct_filepath)) {
        /* Extract $data as late as possible, so we don't accidentally overwrite
        		local function vars */
        extract($data);
        include $_cfct_filepath;
    } else {
        cfct_die('Error loading ' . $file . ' ' . __LINE__);
    }
}