/**
  * Checks if the responsive grid is active or not.
  * 
  * Will check against the main option that's set in the Grid mode of the visual editor 
  * and the cookie that disables the responsive grid if the visitor wishes to do so.
  **/
 public static function is_active()
 {
     //If the responsive grid isn't enabled then don't bother.
     if (!self::is_enabled()) {
         return false;
     }
     //If the user has clicked on the full site link in the footer block then it'll set this cookie that's being checked.
     if (self::is_user_disabled()) {
         return false;
     }
     //If it's the visual editor or the visual editor iframe
     if (HeadwayRoute::is_visual_editor() || HeadwayRoute::is_visual_editor_iframe() || headway_get('visual-editor-open')) {
         return false;
     }
     return true;
 }
Example #2
0
 /**
  * Traverses up the hierarchy tree to figure out which layout is being used.
  * 
  * @return mixed
  **/
 public static function get_current_in_use()
 {
     //If the user is viewing the site through the iframe and the mode is set to Layout, then display that exact layout.
     if (headway_get('ve-layout') && (HeadwayRoute::is_visual_editor_iframe() || HeadwayRoute::is_visual_editor())) {
         return headway_get('ve-layout');
     }
     //Get hierarchy
     $hierarchy = array_reverse(self::get_current_hierarchy());
     //Loop through entire hierarchy to find which one is customized or has a template
     foreach ($hierarchy as $layout) {
         $status = self::get_status($layout);
         //If the layout isn't customized or using a template, skip to next, otherwise we return the current layout in the next line.
         if ($status['customized'] === false && $status['template'] === false) {
             continue;
         }
         //If the layout has a template assigned to it, use the template.  Templates will take precedence over customized status.
         if ($status['template']) {
             return 'template-' . $status['template'];
         }
         //If it's a customized layout, then use the layout itself after making sure there are blocks on the layout
         if ($status['customized'] && count(HeadwayBlocksData::get_blocks_by_layout($layout)) > 0) {
             return $layout;
         }
     }
     //If there's still not a customized layout, loop through the top-level layouts and find the first one that's customized.
     $top_level_layouts = array('index', 'single', 'archive', 'four04');
     if (get_option('show_on_front') == 'page') {
         $top_level_layouts[] = 'front_page';
     }
     foreach ($top_level_layouts as $top_level_layout) {
         $status = self::get_status($top_level_layout);
         if ($status['customized'] === false && $status['template'] === false) {
             continue;
         }
         //If the layout has a template assigned to it, use the template.  Templates will take precedence over customized status.
         if ($status['template']) {
             return 'template-' . $status['template'];
         }
         //If it's a customized layout and the layout has blocks, then use the layout itself
         if ($status['customized'] && count(HeadwayBlocksData::get_blocks_by_layout($top_level_layout)) > 0) {
             return $top_level_layout;
         }
     }
     //If there STILL isn't a customized layout, just return the top level of the current layout.
     return end($hierarchy);
 }
Example #3
0
 /**
  * Loads all of the required core classes and initiates them.
  * 
  * Dependency array setup: class (string) => init (bool)
  **/
 public static function load_dependencies()
 {
     //Load route right away so we can optimize dependency loading below
     Headway::load(array('common/route' => true));
     //Core loading set
     $dependencies = array('defaults/default-design-settings', 'data/data-options' => 'Option', 'data/data-layout-options', 'data/data-blocks', 'common/layout', 'common/capabilities' => true, 'common/responsive-grid' => true, 'common/seo' => true, 'common/social-optimization' => true, 'common/feed' => true, 'common/compiler' => true, 'admin/admin-bar' => true, 'api/api-panel', 'api/api-updater', 'blocks' => true, 'elements' => true, 'fonts/web-fonts-api', 'fonts/web-fonts-loader' => true, 'fonts/traditional-fonts', 'fonts/google-fonts', 'display' => true, 'display/wrappers' => true, 'widgets' => true);
     //Child theme API
     if (HEADWAY_CHILD_THEME_ACTIVE === true) {
         $dependencies['api/api-child-theme'] = 'ChildThemeAPI';
     }
     //Visual editor classes
     if (HeadwayRoute::is_visual_editor() || defined('DOING_AJAX') && DOING_AJAX) {
         $dependencies['visual-editor'] = true;
     }
     //Admin classes
     if (is_admin()) {
         $dependencies['admin'] = true;
     }
     //Load stuff now
     Headway::load(apply_filters('headway_dependencies', $dependencies));
     do_action('headway_setup');
 }
Example #4
0
 public static function enqueue_block_dynamic_js_file()
 {
     //Do not run these if it's the admin page or the visual editor is open
     if (is_admin() || HeadwayRoute::is_visual_editor()) {
         return false;
     }
     $current_layout_in_use = HeadwayLayout::get_current_in_use();
     $script_name = 'block-dynamic-js-layout-' . HeadwayLayout::get_current_in_use();
     $block_actions = self::get_blocks_for_dynamic_asset('js', $current_layout_in_use);
     if (empty($block_actions)) {
         return;
     }
     HeadwayCompiler::register_file(array('name' => $script_name, 'format' => 'js', 'fragments' => array(array('HeadwayBlocks', 'output_block_dynamic_js')), 'enqueue' => false));
     if (strlen((string) self::output_block_dynamic_js($current_layout_in_use)) > 0) {
         wp_enqueue_script($script_name, HeadwayCompiler::get_url($script_name), array('jquery'));
     }
 }