/** * found current template file * @param $file */ public function _hw_get_template_include($file) { if (is_admin()) { return $file; } $GLOBALS['hw_current_theme_template'] = basename($file); //save current theme template file //get templates dynamic $dynamic_settings = HW__Template_Condition::get_active_templates_settings(); $setting_conditions = HW__Template_Condition::parse_template_conditions($dynamic_settings); $pages_condition_and = $setting_conditions['pages_condition_and']; $pages_condition_or = $setting_conditions['pages_condition_or']; //match occurence condition $match_occurence = hw_get_setting('match_occurence'); //get cache result for first #$data = get_transient('hw_dynamic_template'); #if(empty($data) ) $data = array(); foreach ($setting_conditions as $pages_condition) { //and, or condition if (isset($pages_condition) && is_array($pages_condition)) { //get template alternate with AND relation foreach ($pages_condition as $temp => $meet_condition) { if ($meet_condition['result']) { #$_name = HW_Validation::valid_objname($file); //get active template $template = get_post_meta($meet_condition['setting']['post_ID'], 'template', true); if (trim($template) != "" && file_exists(get_stylesheet_directory() . '/' . $template)) { //check new template for exists $file = locate_template($template); //change template file if ($match_occurence == 'first_occurence') { break; } } } } if ($match_occurence == 'first_occurence') { break; } } } //cache result to database /*if($detect_addition_sidebar == true) { set_transient('hw_dynamic_sidebar', $data); }*/ return $file; }