public function get_default_layout($cascade, $layout_slug = "", $add_global_regions = false) { $regions = new Upfront_Layout_Maker(); $template_path = $this->find_default_layout($cascade, $layout_slug); $current_theme = Upfront_ChildTheme::get_instance(); if ($add_global_regions && $current_theme && $current_theme->has_global_region('header')) { include get_stylesheet_directory() . DIRECTORY_SEPARATOR . 'global-regions' . DIRECTORY_SEPARATOR . 'header.php'; } require $template_path; if ($add_global_regions && $current_theme && $current_theme->has_global_region('footer')) { include get_stylesheet_directory() . DIRECTORY_SEPARATOR . 'global-regions' . DIRECTORY_SEPARATOR . 'footer.php'; } $layout = $regions->create_layout(); return $layout; }
public function getGlobalRegions($global_regions = array()) { if (empty($global_regions) === false) { return $global_regions; } // A bit reasoning about this. In global regions layout templates i.e. header & footer // there can be more than one region since if there is element in header/footer region // that links to lightbox, that lightbox is also included in layout template thus // making layout template have more than one region. For this reason regions must be // parsed to get actual global regions. This function needs to return just actual // global regions if they exist i.e. header & footer. $global_layouts = array(); $global_layouts_paths = glob(get_stylesheet_directory() . DIRECTORY_SEPARATOR . 'global-regions' . DIRECTORY_SEPARATOR . '*.php'); foreach ($global_layouts_paths as $path) { $regions = new Upfront_Layout_Maker(); require $path; $global_layouts[] = $regions->create_layout(); } $global_regions = array(); foreach ($global_layouts as $layout) { foreach ($layout as $region) { if ($region['scope'] == 'global' && $region['name'] != 'lightbox') { $global_regions[] = $region; } } } return $global_regions; }