function builder_is_page() { if (builder_is_signup_page()) { return false; } if (builder_is_blog()) { return true; } return is_page(); }
function setup_layout() { global $post, $wp_the_query; if (!builder_is_signup_page() && (is_single() || is_page())) { if (is_object($post)) { $this->_layout_id = get_post_meta($post->ID, '_custom_layout', true); if (!empty($this->_layout_id) && (!isset($this->_layout_settings['layouts'][$this->_layout_id]) || !is_array($this->_layout_settings['layouts'][$this->_layout_id]))) { $this->_layout_id = null; } if (!empty($this->_layout_id)) { $this->_layout_functions[] = 'custom_layout'; $this->_layout_views = array($post->post_type, "{$post->post_type}-{$post->ID}"); $this->_view_id = "post:{$post->ID}"; } } } if (empty($this->_layout_id) || !is_array($this->_layout_settings['layouts'][$this->_layout_id])) { $available_views = apply_filters('builder_get_available_views', array()); $priority = 0; foreach ($available_views as $function => $view) { if ($this->_is_current_view($function)) { if ($view['priority'] > $priority && !empty($this->_layout_settings['views'][$function]) && '//INHERIT//' != $this->_layout_settings['views'][$function]['layout']) { $this->_layout_id = $this->_layout_settings['views'][$function]['layout']; $this->_view_id = $function; $priority = $view['priority']; } $this->_layout_functions[] = $function; $this->_layout_views[] = strtolower(str_replace(' ', '-', $available_views[$function]['name'])); } } } if (!empty($wp_the_query->query_vars['cat'])) { $this->_layout_functions[] = "is_category__{$wp_the_query->query_vars['cat']}"; $this->_layout_views[] = "category-{$wp_the_query->query_vars['cat']}"; if (isset($this->_layout_settings['views']["is_category__{$wp_the_query->query_vars['cat']}"]) && '//INHERIT//' != $this->_layout_settings['views']["is_category__{$wp_the_query->query_vars['cat']}"]['layout']) { $this->_layout_id = $this->_layout_settings['views']["is_category__{$wp_the_query->query_vars['cat']}"]['layout']; $this->_view_id = "is_category__{$wp_the_query->query_vars['cat']}"; } } else { if (!empty($wp_the_query->query_vars['tag_id'])) { $this->_layout_functions[] = "is_tag__{$wp_the_query->query_vars['tag_id']}"; $this->_layout_views[] = "tag-{$wp_the_query->query_vars['tag_id']}"; if (isset($this->_layout_settings['views']["is_tag__{$wp_the_query->query_vars['tag_id']}"]) && '//INHERIT//' != $this->_layout_settings['views']["is_tag__{$wp_the_query->query_vars['tag_id']}"]['layout']) { $this->_layout_id = $this->_layout_settings['views']["is_tag__{$wp_the_query->query_vars['tag_id']}"]['layout']; $this->_view_id = "is_tag__{$wp_the_query->query_vars['tag_id']}"; } } else { if (!empty($wp_the_query->query_vars['author'])) { $this->_layout_functions[] = "is_author__{$wp_the_query->query_vars['author']}"; $this->_layout_views[] = "author-{$wp_the_query->query_vars['author']}"; if (isset($this->_layout_settings['views']["is_author__{$wp_the_query->query_vars['author']}"]) && '//INHERIT//' != $this->_layout_settings['views']["is_author__{$wp_the_query->query_vars['author']}"]['layout']) { $this->_layout_id = $this->_layout_settings['views']["is_author__{$wp_the_query->query_vars['author']}"]['layout']; $this->_view_id = "is_author__{$wp_the_query->query_vars['author']}"; } } else { if (!builder_is_signup_page() && isset($post) && !empty($post->post_type)) { $this->_layout_functions[] = "builder_is_custom_post_type__{$post->post_type}"; $this->_layout_views[] = "{$post->post_type}-{$post->ID}"; if (isset($this->_layout_settings['views']["builder_is_custom_post_type__{$post->post_type}"]) && '//INHERIT//' != $this->_layout_settings['views']["builder_is_custom_post_type__{$post->post_type}"]['layout']) { $this->_layout_id = $this->_layout_settings['views']["builder_is_custom_post_type__{$post->post_type}"]['layout']; $this->_view_id = "builder_is_custom_post_type__{$post->post_type}"; } } } } } $original_layout_id = $this->_layout_id; $this->_layout_id = apply_filters('builder_filter_current_layout', $this->_layout_id); if ($this->_layout_id !== $original_layout_id) { $this->_layout_functions[] = 'filter'; } if (empty($this->_layout_settings['layouts'][$this->_layout_id])) { $this->_layout_id = $this->_layout_settings['default']; $this->_layout_functions[] = 'default'; } if (empty($this->_layout_views)) { $this->_layout_views[] = 'default'; } do_action_ref_array('builder_layout_engine_identified_view', array($this->_view_id, $this->_layout_settings, $this->_layout_views, $this->_layout_functions)); do_action_ref_array('builder_layout_engine_identified_layout', array($this->_layout_id, $this->_layout_settings, $this->_layout_views, $this->_layout_functions)); do_action('builder_sidebar_register_layout_sidebars', $this->_layout_id); $layout_width = apply_filters('builder_get_container_width', $this->_layout_settings['layouts'][$this->_layout_id]['width']); if (empty($layout_width)) { add_theme_support('builder-full-width-modules'); add_theme_support('builder-full-width-modules-legacy'); } }