Example #1
0
 public static function add_admin_bar_nodes()
 {
     if (!HeadwayCapabilities::can_user_visually_edit()) {
         return;
     }
     global $wp_admin_bar;
     $default_visual_editor_mode = current_theme_supports('headway-grid') ? 'grid' : 'design';
     //Headway Root
     $wp_admin_bar->add_menu(array('id' => 'headway', 'title' => 'Headway', 'href' => add_query_arg(array('visual-editor' => 'true', 'visual-editor-mode' => $default_visual_editor_mode, 've-layout' => HeadwayLayout::get_current()), home_url())));
     //Visual Editor
     $wp_admin_bar->add_menu(array('parent' => 'headway', 'id' => 'headway-ve', 'title' => 'Visual Editor', 'href' => add_query_arg(array('visual-editor' => 'true', 'visual-editor-mode' => $default_visual_editor_mode, 've-layout' => HeadwayLayout::get_current()), home_url())));
     //Grid
     if (current_theme_supports('headway-grid')) {
         $wp_admin_bar->add_menu(array('parent' => 'headway-ve', 'id' => 'headway-ve-grid', 'title' => 'Grid', 'href' => add_query_arg(array('visual-editor' => 'true', 'visual-editor-mode' => 'grid', 've-layout' => HeadwayLayout::get_current()), home_url())));
     }
     //Design Editor
     $wp_admin_bar->add_menu(array('parent' => 'headway-ve', 'id' => 'headway-ve-design', 'title' => 'Design', 'href' => add_query_arg(array('visual-editor' => 'true', 'visual-editor-mode' => 'design', 've-layout' => HeadwayLayout::get_current()), home_url())));
     //Extend
     $wp_admin_bar->add_menu(array('parent' => 'headway', 'id' => 'headway-admin-extend', 'title' => 'Extend', 'href' => admin_url('admin.php?page=headway-extend')));
     //Admin Options
     $wp_admin_bar->add_menu(array('parent' => 'headway', 'id' => 'headway-admin-options', 'title' => 'Options', 'href' => admin_url('admin.php?page=headway-options')));
     $wp_admin_bar->add_menu(array('parent' => 'headway-admin-options', 'id' => 'headway-admin-options-general', 'title' => 'General', 'href' => admin_url('admin.php?page=headway-options#tab-general')));
     $wp_admin_bar->add_menu(array('parent' => 'headway-admin-options', 'id' => 'headway-admin-options-seo', 'title' => 'Search Engine Optimization', 'href' => admin_url('admin.php?page=headway-options#tab-seo')));
     $wp_admin_bar->add_menu(array('parent' => 'headway-admin-options', 'id' => 'headway-admin-options-scripts', 'title' => 'Scripts/Analytics', 'href' => admin_url('admin.php?page=headway-options#tab-scripts')));
     $wp_admin_bar->add_menu(array('parent' => 'headway-admin-options', 'id' => 'headway-admin-options-visual-editor', 'title' => 'Visual Editor', 'href' => admin_url('admin.php?page=headway-options#tab-visual-editor')));
     $wp_admin_bar->add_menu(array('parent' => 'headway-admin-options', 'id' => 'headway-admin-options-advanced', 'title' => 'Advanced', 'href' => admin_url('admin.php?page=headway-options#tab-advanced')));
     //Admin Tools
     $wp_admin_bar->add_menu(array('parent' => 'headway', 'id' => 'headway-admin-tools', 'title' => 'Tools', 'href' => admin_url('admin.php?page=headway-tools')));
     $wp_admin_bar->add_menu(array('parent' => 'headway-admin-tools', 'id' => 'headway-admin-tools-system-info', 'title' => 'System Info', 'href' => admin_url('admin.php?page=headway-tools#tab-system-info')));
     $wp_admin_bar->add_menu(array('parent' => 'headway-admin-tools', 'id' => 'headway-admin-tools-maintenance', 'title' => 'Maintenance', 'href' => admin_url('admin.php?page=headway-tools#tab-maintenance')));
     $wp_admin_bar->add_menu(array('parent' => 'headway-admin-tools', 'id' => 'headway-admin-tools-reset', 'title' => 'Reset', 'href' => admin_url('admin.php?page=headway-tools#tab-reset')));
 }
 public function get_wrappers_select_options_for_mirroring()
 {
     $wrappers = HeadwayWrappers::get_all_wrappers();
     $options = array('' => '– Do Not Mirror –');
     //If there are no blocks, then just return the Do Not Mirror option.
     if (empty($wrappers) || !is_array($wrappers)) {
         return $options;
     }
     foreach ($wrappers as $wrapper_id => $wrapper_settings) {
         /* If we can't get a name for the layout, then things probably aren't looking good.  Just skip this wrapper. */
         if (!($layout_name = HeadwayLayout::get_name($wrapper_settings['layout']))) {
             continue;
         }
         /* Check for mirroring here */
         if (HeadwayWrappers::get_wrapper_mirror($wrapper_settings)) {
             continue;
         }
         $current_layout_suffix = $this->wrapper['layout'] == $wrapper_settings['layout'] ? ' (Warning: Same Layout)' : null;
         $wrapper_alias = headway_get('alias', $wrapper_settings) ? ' – ' . headway_get('alias', $wrapper_settings) : null;
         //Get alias if it exists, otherwise use the default name
         $options[$wrapper_id] = 'Wrapper #' . HeadwayWrappers::format_wrapper_id($wrapper_id) . $wrapper_alias . ' – ' . $layout_name . $current_layout_suffix;
     }
     //Remove the current wrapper from the list
     unset($options[$this->wrapper['id']]);
     return $options;
 }
Example #3
0
function motopressCERemoveHeadwayFix($post_id, $post_type)
{
    if (defined('HEADWAY_VERSION')) {
        global $wpdb;
        if (version_compare(HEADWAY_VERSION, '3.7.10', '>=') || property_exists($wpdb, 'hw_wrappers')) {
            global $wp_query;
            $originalWpQuery = $wp_query;
            $key = $post_type === 'page' ? 'page_id' : 'p';
            $wp_query = new WP_Query($key . '=' . $post_id);
            if (have_posts()) {
                while (have_posts()) {
                    the_post();
                }
            }
            $layoutId = HeadwayLayout::get_current_in_use();
            HeadwayWrappersData::delete_by_layout($layoutId);
            $transient_id_customized_layouts = 'hw_customized_layouts_template_' . HeadwayOption::$current_skin;
            $customized_layouts = get_transient($transient_id_customized_layouts);
            if ($customized_layouts) {
                $index = array_search($layoutId, $customized_layouts);
                if ($index !== false) {
                    unset($customized_layouts[$layoutId]);
                    set_transient($transient_id_customized_layouts, $customized_layouts);
                }
            }
            wp_reset_postdata();
            $wp_query = $originalWpQuery;
        }
    }
}
Example #4
0
 public static function init_action($block_id, $block = false)
 {
     if (!$block) {
         $block = HeadwayBlocksData::get_block($block_id);
     }
     $name = HeadwayBlocksData::get_block_name($block) . ' — ' . 'Layout: ' . HeadwayLayout::get_name($block['layout']);
     register_nav_menu('navigation_block_' . $block_id, $name);
     wp_register_script('jquery-hoverintent', headway_url() . '/library/media/js/jquery.hoverintent.js', array('jquery'));
 }
Example #5
0
function motopressCEAddHeadwayFix($post_id, $tmp_post_id, $post_type)
{
    if (defined('HEADWAY_VERSION')) {
        global $wpdb;
        if (version_compare(HEADWAY_VERSION, '3.7.10', '>=') || property_exists($wpdb, 'hw_wrappers')) {
            global $wp_query;
            $originalWpQuery = $wp_query;
            $key = $post_type === 'page' ? 'page_id' : 'p';
            $wp_query = new WP_Query($key . '=' . $post_id);
            if (have_posts()) {
                while (have_posts()) {
                    the_post();
                }
            }
            $layoutId = HeadwayLayout::get_current_in_use();
            $wrappers = HeadwayWrappersData::get_wrappers_by_layout($layoutId);
            //            if ($wrappers[0]['id'] !== 'default') {
            if (!array_key_exists('default', $wrappers)) {
                $sep = preg_quote(HeadwayLayout::$sep);
                if (preg_match('/^single' . $sep . '[a-z]+' . $sep . '\\d+$/is', $layoutId)) {
                    $layoutTmpId = str_replace($post_id, $tmp_post_id, $layoutId);
                } else {
                    $layoutTmpId = 'single' . HeadwayLayout::$sep . $post_type . HeadwayLayout::$sep . $tmp_post_id;
                }
                update_option('motopress-ce-hw-layout', $layoutTmpId);
                foreach ($wrappers as $wrapper_id => $wrapper) {
                    $wrapperId = HeadwayWrappersData::add_wrapper($layoutTmpId, $wrapper);
                    $blocks = HeadwayBlocksData::get_blocks_by_wrapper($layoutId, $wrapper_id);
                    foreach ($blocks as $block_id => &$block) {
                        $block['wrapper_id'] = $wrapperId;
                        $block['wrapper'] = $wrapperId;
                        HeadwayBlocksData::add_block($layoutTmpId, $block);
                    }
                    unset($block);
                }
                $transient_id_customized_layouts = 'hw_customized_layouts_template_' . HeadwayOption::$current_skin;
                $customized_layouts = get_transient($transient_id_customized_layouts);
                if (!$customized_layouts) {
                    $customized_layouts = array_unique($wpdb->get_col($wpdb->prepare("SELECT layout FROM {$wpdb->hw_blocks} WHERE template = '%s'", HeadwayOption::$current_skin)));
                }
                if (!in_array($layoutTmpId, $customized_layouts)) {
                    $customized_layouts[] = $layoutTmpId;
                    set_transient($transient_id_customized_layouts, $customized_layouts);
                }
            }
            wp_reset_postdata();
            $wp_query = $originalWpQuery;
        } else {
            $layout = get_option('headway_layout_options_' . $post_id);
            if ($layout) {
                update_option('headway_layout_options_' . $tmp_post_id, $layout);
            } else {
                delete_option('headway_layout_options_' . $tmp_post_id);
            }
        }
    }
}
 private function display_no_blocks_message()
 {
     echo '<div class="wrapper wrapper-no-blocks wrapper-fixed" id="wrapper-default">' . "\n\n";
     echo '<div class="block-type-content">';
     echo '<div class="entry-content">';
     echo '<h1 class="entry-title">' . __('No Content to Display', 'headway') . '</h1>';
     $visual_editor_url = add_query_arg(array('visual-editor' => 'true', 'visual-editor-mode' => 'grid', 've-layout' => HeadwayLayout::get_current()), home_url());
     if (HeadwayCapabilities::can_user_visually_edit()) {
         echo sprintf(__('<p>There are no blocks to display.  Add some by going to the <a href="%s">Headway Grid</a>!</p>', 'headway'), $visual_editor_url);
     } else {
         echo sprintf(__('<p>There is no content to display.  Please notify the site administrator or <a href="%s">login</a>.</p>', 'headway'), $visual_editor_url);
     }
     echo '</div><!-- .entry-content -->';
     echo '</div><!-- .block-type-content -->';
     echo '</div><!-- .wrapper -->';
     return false;
 }
 public static function delete($layout, $option = null, $group_name = false)
 {
     //No deleting to be done if we don't have an option to delete
     if ($option === null) {
         return false;
     }
     //If there's no group defined, define it using the default
     if (!$group_name) {
         $group_name = self::$default_group;
     }
     //Make sure there is a layout to use
     if (!$layout) {
         $layout = HeadwayLayout::get_current();
     }
     //Format layout ID
     $layout = self::format_layout_id($layout);
     //Retrieve options array from DB
     $options = get_option('headway_layout_options_' . str_replace('-', '_', $layout));
     //If DB option doesn't exist, make a default array
     if (!is_array($options)) {
         $options = array();
     }
     //Option or group doesn't exist
     if (!isset($options[$group_name]) || !isset($options[$group_name][$option])) {
         return false;
     }
     //If option exists, delete the sucker
     unset($options[$group_name][$option]);
     //If group is empty, delete it too
     if (count($options[$group_name]) === 0) {
         unset($options[$group_name]);
     }
     //If the options array is empty, delete the entire option and remove it from catalog
     if (count($options) === 0 && !HeadwayOption::$group_suffix) {
         $removal = array($layout);
         $catalog = array_diff(get_option('headway_layout_options_catalog'), $removal);
         delete_option('headway_layout_options_' . $layout);
         update_option('headway_layout_options_catalog', $catalog);
         return true;
     }
     update_option('headway_layout_options_' . $layout . HeadwayOption::$group_suffix, $options);
     return true;
 }
Example #8
0
 public static function register_layout_css()
 {
     $current_layout_in_use = HeadwayLayout::get_current_in_use();
     $css_name = 'layout-' . HeadwayLayout::get_current_in_use();
     $fragments = array();
     /* If the grid is supported, then include the wrapper, grid, and block heights */
     if (current_theme_supports('headway-grid')) {
         $fragments['dynamic-wrapper'] = array('HeadwayDynamicStyle', 'wrapper');
     }
     /* Include dynamic CSS from blocks such as navigation block or any block that has per-block CSS */
     $fragments['dynamic-block-css'] = array('HeadwayBlocks', 'output_block_dynamic_css');
     return HeadwayCompiler::register_file(array('name' => $css_name, 'format' => 'css', 'fragments' => $fragments, 'dependencies' => array(HEADWAY_LIBRARY_DIR . '/media/dynamic/style.php')));
 }
Example #9
0
 public static function register_element_instance($args)
 {
     if (!is_array($args)) {
         return new WP_Error('hw_elements_register_element_instance_args_not_array', __('Error: Arguments must be an array for this element instance.', 'headway'), $args);
     }
     $defaults = array('group' => null, 'grandparent' => null, 'element' => null, 'id' => null, 'name' => null, 'selector' => null, 'layout' => null, 'state-of' => null);
     $item = array_merge($defaults, $args);
     //If requirements are not met, throw errors
     if (!$item['id']) {
         return new WP_Error('hw_elements_register_element_instance_no_id', __('Error: An ID is required for this element instance.', 'headway'), $item);
     }
     if (!$item['name']) {
         return new WP_Error('hw_elements_register_element_instance_no_name', __('Error: A name is required for this element instance.', 'headway'), $item);
     }
     if ($item['group'] === null) {
         return new WP_Error('hw_elements_register_element_instance_no_group', __('Error: A group is required for this element instance.', 'headway'), $item);
     }
     if ($item['element'] === null) {
         return new WP_Error('hw_elements_register_element_instance_no_parent', __('Error: A parent element is required for this element instance.', 'headway'), $item);
     }
     if ($item['selector'] === null) {
         return new WP_Error('hw_elements_register_element_instance_no_selector', __('Error: A CSS selector is required for this element instance.', 'headway'), $item);
     }
     //If layout is set, then set layout-name as well
     if ($item['layout']) {
         $item['layout-name'] = HeadwayLayout::get_name($item['layout']);
     }
     //Figure out where the element will go in the elements array
     if ($item['grandparent'] !== null && isset(self::$elements[$item['group']][$item['grandparent']]['children'][$item['element']])) {
         $destination =& self::$elements[$item['group']][$item['grandparent']]['children'][$item['element']];
     } else {
         if (isset(self::$elements[$item['group']][$item['element']])) {
             $destination =& self::$elements[$item['group']][$item['element']];
         } else {
             return false;
         }
     }
     //Make sure that the element supports instances
     if (!headway_get('supports-instances', $destination)) {
         return false;
     }
     $destination =& $destination['instances'][$item['id']];
     //Add the guts
     $destination = $item;
     //Add the instance to element paths so we can look the parent, grandparent and group up
     self::$element_paths[$item['id']] = array('group' => $item['group'], 'parent' => $item['element'], 'grandparent' => $item['grandparent']);
     //Remove the extra options
     unset($destination['element']);
     unset($destination['grandparent']);
     unset($destination['group']);
     //The element instance is now registered!
     return $destination;
 }
Example #10
0
 public static function init_action($block_id, $block)
 {
     $widget_area_name = HeadwayBlocksData::get_block_name($block) . ' &mdash; ' . 'Layout: ' . HeadwayLayout::get_name($block['layout']);
     $widget_area = array('name' => $widget_area_name, 'id' => 'widget-area-' . $block['id'], 'before_widget' => '<li id="%1$s" class="widget %2$s">' . "\n", 'after_widget' => '</li><!-- .widget -->' . "\n", 'before_title' => '<span class="widget-title">', 'after_title' => '</span>' . "\n");
     register_sidebar($widget_area);
 }
Example #11
0
 public static function save_preview_options()
 {
     //Set up options
     parse_str(headway_get('unsaved'), $options);
     return HeadwayVisualEditor::save($options, HeadwayLayout::get_current(), 'grid');
 }
Example #12
0
 public function get_blocks_select_options_for_mirroring()
 {
     $block_type = $this->block['type'];
     $blocks = HeadwayBlocksData::get_blocks_by_type($block_type);
     $options = array('' => '&ndash; Do Not Mirror &ndash;');
     //If there are no blocks, then just return the Do Not Mirror option.
     if (!isset($blocks) || !is_array($blocks)) {
         return $options;
     }
     foreach ($blocks as $block_id => $layout_id) {
         //Get the block instance
         $block = HeadwayBlocksData::get_block($block_id);
         //If the block is mirrored, skip it
         if (HeadwayBlocksData::is_block_mirrored($block)) {
             continue;
         }
         /* Do not show block that's in a mirrored wrapper */
         if (HeadwayWrappers::get_wrapper_mirror(HeadwayWrappers::get_wrapper(headway_get('wrapper', $block)))) {
             continue;
         }
         //Create the default name by using the block type and ID
         $default_name = HeadwayBlocks::block_type_nice($block['type']) . ' #' . $block['id'];
         //If we can't get a name for the layout, then things probably aren't looking good.  Just skip this block.
         if (!($layout_name = HeadwayLayout::get_name($layout_id))) {
             continue;
         }
         //Make sure the block exists
         if (!HeadwayBlocksData::block_exists($block['id'])) {
             continue;
         }
         $current_layout_suffix = $this->block['layout'] == $layout_id ? ' (Warning: Same Layout)' : null;
         //Get alias if it exists, otherwise use the default name
         $options[$block['id']] = headway_get('alias', $block['settings'], $default_name) . ' &ndash; ' . $layout_name . $current_layout_suffix;
     }
     //Remove the current block from the list
     unset($options[$this->block['id']]);
     return $options;
 }
Example #13
0
 public static function save($options, $current_layout = false, $mode = false)
 {
     if (!$current_layout) {
         $current_layout = headway_post('layout');
     }
     if (!$mode) {
         $mode = headway_post('mode');
     }
     //Handle triple slash bullshit
     if (get_magic_quotes_gpc() === 1) {
         $options = array_map('stripslashes_deep', $options);
     }
     $blocks = isset($options['blocks']) ? $options['blocks'] : null;
     $wrappers = isset($options['wrappers']) ? $options['wrappers'] : null;
     $layout_options = isset($options['layout-options']) ? $options['layout-options'] : null;
     $options_inputs = isset($options['options']) ? $options['options'] : null;
     $design_editor_inputs = isset($options['design-editor']) ? $options['design-editor'] : null;
     //Set the current layout to customized if it's the grid mode
     if ($mode == 'grid') {
         HeadwayLayoutOption::set($current_layout, 'customized', true);
     }
     /* Blocks */
     if ($blocks) {
         foreach ($blocks as $id => $methods) {
             foreach ($methods as $method => $value) {
                 switch ($method) {
                     case 'new':
                         if (HeadwayBlocksData::get_block($id)) {
                             continue;
                         }
                         $dimensions = explode(',', $blocks[$id]['dimensions']);
                         $position = explode(',', $blocks[$id]['position']);
                         $settings = isset($blocks[$id]['settings']) ? $blocks[$id]['settings'] : array();
                         $args = array('id' => $id, 'type' => $value, 'position' => array('left' => $position[0], 'top' => $position[1]), 'dimensions' => array('width' => $dimensions[0], 'height' => $dimensions[1]), 'settings' => $settings);
                         HeadwayBlocksData::add_block($current_layout, $args);
                         break;
                     case 'delete':
                         HeadwayBlocksData::delete_block($current_layout, $id);
                         break;
                     case 'dimensions':
                         $dimensions = explode(',', $value);
                         $args = array('dimensions' => array('width' => $dimensions[0], 'height' => $dimensions[1]));
                         HeadwayBlocksData::update_block($current_layout, $id, $args);
                         break;
                     case 'position':
                         $position = explode(',', $value);
                         $args = array('position' => array('left' => $position[0], 'top' => $position[1]));
                         HeadwayBlocksData::update_block($current_layout, $id, $args);
                         break;
                     case 'wrapper':
                         $args = array('wrapper' => $value);
                         HeadwayBlocksData::update_block($current_layout, $id, $args);
                         break;
                     case 'settings':
                         //Retrieve all blocks from layout
                         $layout_blocks = HeadwayBlocksData::get_blocks_by_layout($current_layout);
                         //Get the block from the layout
                         $block = headway_get($id, $layout_blocks);
                         //If block doesn't exist, we can't do anything.
                         if (!$block) {
                             continue;
                         }
                         //If there aren't any options, then don't do anything either
                         if (!is_array($value) || count($value) === 0) {
                             continue;
                         }
                         $block['settings'] = array_merge($block['settings'], $value);
                         HeadwayBlocksData::update_block($current_layout, $id, $block);
                         break;
                 }
             }
         }
     }
     /* End Blocks */
     /* Wrappers */
     if ($wrappers) {
         /* Pluck last-id out of wrappers and send it to DB */
         if (headway_get('last-id', $wrappers)) {
             $last_id = $wrappers['last-id'];
             unset($wrappers['last-id']);
             HeadwayOption::set('last-id', $last_id, 'wrappers');
         }
         /* Save layout wrappers to dB */
         HeadwayOption::set($current_layout, $wrappers, 'wrappers');
     }
     /* End Wrappers */
     /* Layout Options */
     if ($layout_options) {
         foreach ($layout_options as $group => $options) {
             foreach ($options as $option => $value) {
                 HeadwayLayoutOption::set($current_layout, $option, $value, $group);
             }
         }
     }
     /* End Layout Options */
     /* Options */
     if ($options_inputs) {
         foreach ($options_inputs as $group => $options) {
             foreach ($options as $option => $value) {
                 HeadwayOption::set($option, $value, $group);
             }
         }
     }
     /* End Options */
     /* Design Editor Inputs */
     if ($design_editor_inputs) {
         /* If skin import is set to true then nuke all design settings to prevent overlapping settings */
         if (headway_get('skin-import', $design_editor_inputs)) {
             HeadwayElementsData::delete_all();
         }
         /* End skin import nuke */
         /* Handle skin templates */
         $skin_templates = headway_get('skin-import-templates', $design_editor_inputs);
         if (is_array($skin_templates) && count($skin_templates)) {
             $skin_template_block_id_translations = array();
             $skin_template_wrapper_id_translations = array();
             foreach ($skin_templates as $skin_template_name => $skin_template_blocks) {
                 /* Pluck wrappers array out of blocks array */
                 $skin_template_wrappers = $skin_template_blocks['wrappers'];
                 unset($skin_template_blocks['wrappers']);
                 $template = HeadwayLayout::add_template($skin_template_name, $skin_template_blocks, $skin_template_wrappers);
                 /* Use + rather than array_merge because + preserves numeric keys */
                 $skin_template_block_id_translations = $skin_template_block_id_translations + $template['block-id-translations'];
                 $skin_template_wrapper_id_translations = $skin_template_wrapper_id_translations + $template['wrapper-id-translations'];
             }
             /* Re-map block IDs in instances according to block ID translations */
             foreach ($design_editor_inputs as $element_id => $element_data) {
                 if (!is_array($element_data) || !isset($element_data['special-element-instance'])) {
                     continue;
                 }
                 foreach ($element_data['special-element-instance'] as $instance_id => $instance_properties) {
                     $instance_id_fragments = explode('-', $instance_id);
                     $instance_potential_block_id_search = preg_match('/\\bblock\\b\\-[0-9]+/', $instance_id, $instance_potential_block_id_search_results);
                     $instance_potential_block_id = str_replace('block-', '', end($instance_potential_block_id_search_results));
                     $instance_potential_wrapper_id = $instance_id_fragments[1];
                     /* Wrapper instance conditional. Modify new instance ID accordingly */
                     if (strpos($instance_id, 'wrapper-') === 0 && isset($skin_template_wrapper_id_translations[intval($instance_potential_wrapper_id)])) {
                         $new_wrapper_id = $skin_template_wrapper_id_translations[intval($instance_potential_wrapper_id)]['id'];
                         $new_wrapper_layout = $skin_template_wrapper_id_translations[intval($instance_potential_wrapper_id)]['layout'];
                         $new_instance_id = 'wrapper-' . $new_wrapper_id . '-layout-' . $new_wrapper_layout;
                         /* Block instance conditional.  Modify new instance ID accordingly */
                     } else {
                         if (strpos($instance_id, 'block-') !== false && is_numeric($instance_potential_block_id) && isset($skin_template_block_id_translations[intval($instance_potential_block_id)])) {
                             $new_block_id = $skin_template_block_id_translations[intval($instance_potential_block_id)];
                             $new_instance_id = str_replace('block-' . $instance_potential_block_id, 'block-' . $new_block_id, $instance_id);
                             /* Not a proper block or wrapper instance, just skip it */
                         } else {
                             continue;
                         }
                     }
                     /* Remove existing instance key/value pair */
                     unset($design_editor_inputs[$element_id]['special-element-instance'][$instance_id]);
                     /* Add new instance key/value pair with new instance ID */
                     $design_editor_inputs[$element_id]['special-element-instance'][$new_instance_id] = $instance_properties;
                 }
             }
         }
         /* End skin template handling */
         /* Loop through to get every element and its properties */
         foreach ($design_editor_inputs as $element_id => $element_data) {
             if (!is_array($element_data) || !isset($element_data['group'])) {
                 continue;
             }
             $element_group = $element_data['group'];
             //Dispatch depending on type of element data
             foreach ($element_data as $element_data_node => $element_data_node_data) {
                 //Handle different nodes depending on what they are
                 if ($element_data_node == 'properties') {
                     //Set each property for the regular element
                     foreach ($element_data_node_data as $property_id => $property_value) {
                         HeadwayElementsData::set_property($element_group, $element_id, $property_id, $property_value);
                     }
                     //Handle instances, states, etc.
                 } else {
                     if (strpos($element_data_node, 'special-element-') === 0) {
                         $special_element_type = str_replace('special-element-', '', $element_data_node);
                         //Loop through the special elements
                         foreach ($element_data_node_data as $special_element => $special_element_properties) {
                             //Set the special element properties now
                             foreach ($special_element_properties as $special_element_property => $special_element_property_value) {
                                 HeadwayElementsData::set_special_element_property($element_group, $element_id, $special_element_type, $special_element, $special_element_property, $special_element_property_value);
                             }
                         }
                     }
                 }
             }
         }
         /* End loop */
     }
     /* End Design Editor Inputs */
     //This hook is used by cache flushing, plugins, etc.  Do not fire on preview save because it'll flush preview options
     if (!headway_get('ve-preview')) {
         do_action('headway_visual_editor_save');
     }
     return true;
 }
Example #14
0
 /**
  * Assembles the classes for the body element.
  **/
 public static function body_class($c)
 {
     global $wp_query, $authordata;
     $c[] = 'custom';
     /* User Agents */
     if (!HeadwayCompiler::is_plugin_caching()) {
         $user_agent = $_SERVER['HTTP_USER_AGENT'];
         /* IE */
         if ($ie_version = headway_is_ie()) {
             $c[] = 'ie';
             $c[] = 'ie' . $ie_version;
         }
         /* Modern Browsers */
         if (stripos($user_agent, 'Safari') !== false) {
             $c[] = 'safari';
         } elseif (stripos($user_agent, 'Firefox') !== false) {
             $c[] = 'firefox';
         } elseif (stripos($user_agent, 'Chrome') !== false) {
             $c[] = 'chrome';
         } elseif (stripos($user_agent, 'Opera') !== false) {
             $c[] = 'opera';
         }
         /* Rendering Engines */
         if (stripos($user_agent, 'WebKit') !== false) {
             $c[] = 'webkit';
         } elseif (stripos($user_agent, 'Gecko') !== false) {
             $c[] = 'gecko';
         }
         /* Mobile */
         if (stripos($user_agent, 'iPhone') !== false) {
             $c[] = 'iphone';
         } elseif (stripos($user_agent, 'iPod') !== false) {
             $c[] = 'ipod';
         } elseif (stripos($user_agent, 'iPad') !== false) {
             $c[] = 'ipad';
         } elseif (stripos($user_agent, 'Android') !== false) {
             $c[] = 'android';
         }
     }
     /* End User Agents */
     /* Responsive Grid */
     if (HeadwayResponsiveGrid::is_enabled()) {
         $c[] = 'responsive-grid-enabled';
     }
     if (HeadwayResponsiveGrid::is_active()) {
         $c[] = 'responsive-grid-active';
     }
     /* Pages */
     if (is_page() && isset($wp_query->post) && isset($wp_query->post->ID)) {
         $c[] = 'pageid-' . $wp_query->post->ID;
         $c[] = 'page-slug-' . $wp_query->post->post_name;
     }
     /* Posts & Pages */
     if (is_singular() && isset($wp_query->post) && isset($wp_query->post->ID)) {
         //Add the custom classes from the meta box
         if ($custom_css_class = HeadwayLayoutOption::get($wp_query->post->ID, 'css-class', null)) {
             $custom_css_classes = str_replace('  ', ' ', str_replace(',', ' ', htmlspecialchars(strip_tags($custom_css_class))));
             $c = array_merge($c, array_filter(explode(' ', $custom_css_classes)));
         }
     }
     /* Layout IDs, etc */
     $c[] = 'layout-' . HeadwayLayout::get_current();
     $c[] = 'layout-using-' . HeadwayLayout::get_current_in_use();
     if (HeadwayRoute::is_visual_editor_iframe()) {
         $c[] = 've-iframe';
     }
     if (headway_get('ve-iframe-mode') && HeadwayRoute::is_visual_editor_iframe()) {
         $c[] = 'visual-editor-mode-' . headway_get('ve-iframe-mode');
     }
     if (!current_theme_supports('headway-design-editor')) {
         $c[] = 'design-editor-disabled';
     }
     $c = array_unique(array_filter($c));
     return $c;
 }
Example #15
0
 function get_templates()
 {
     return HeadwayLayout::get_templates();
 }
Example #16
0
 public static function display_block($block, $where = null)
 {
     //We'll allow this function to take either an integer argument to look up the block or to use the existing
     if (!is_array($block)) {
         $block = HeadwayBlocksData::get_block($block);
     }
     //Check that the block exists
     if (!is_array($block) || !$block) {
         return false;
     }
     $block_types = HeadwayBlocks::get_block_types();
     //Set the original block for future use
     $original_block = $block;
     $original_block_id = $block['id'];
     //Set the block style to null so we don't get an ugly notice down the road if it's not used.
     $block_style_attr = null;
     //Check if the block type exists
     if (!($block_type_settings = headway_get($block['type'], $block_types, array()))) {
         $block['requested-type'] = $block['type'];
         $block['type'] = 'unknown';
     }
     //Get the custom CSS classes and change commas to spaces and remove double spaces and remove HTML
     $custom_css_classes = str_replace('  ', ' ', str_replace(',', ' ', htmlspecialchars(strip_tags(headway_get('css-classes', $block['settings'], '')))));
     $block_classes = array_unique(array_filter(explode(' ', $custom_css_classes)));
     $block_classes[] = 'block';
     $block_classes[] = 'block-type-' . $block['type'];
     $block_classes[] = headway_get('fixed-height', $block_type_settings, false) !== true ? 'block-fluid-height' : 'block-fixed-height';
     //Block Styles
     if (HEADWAY_CHILD_THEME_ACTIVE && ($block_style = headway_get(HEADWAY_CHILD_THEME_ID . '-block-style', $block['settings']))) {
         $block_style_classes = explode(' ', headway_get('class', headway_get($block_style, HeadwayChildThemeAPI::$block_styles)));
         foreach ($block_style_classes as $block_style_class) {
             $block_classes[] = $block_style_class;
         }
     }
     //If the block is being displayed in the Grid, then we need to make it work with absolute positioning.
     if ($where == 'grid') {
         $block_classes[] = 'grid-width-' . $original_block['dimensions']['width'];
         $block_classes[] = 'grid-left-' . $original_block['position']['left'];
         $block_style_attr = ' style="height: ' . $original_block['dimensions']['height'] . 'px; top: ' . $original_block['position']['top'] . 'px;"';
     }
     //If the responsive grid is active, then add the responsive block hiding classes
     if (HeadwayResponsiveGrid::is_enabled()) {
         $responsive_block_hiding = headway_get('responsive-block-hiding', $block['settings'], array());
         if (is_array($responsive_block_hiding) && count($responsive_block_hiding) > 0) {
             foreach ($responsive_block_hiding as $device) {
                 $block_classes[] = 'responsive-block-hiding-device-' . $device;
             }
         }
     }
     //If it's a mirrored block, change $block to the mirrored block
     if ($mirrored_block = HeadwayBlocksData::is_block_mirrored($block)) {
         $block = $mirrored_block;
         $block['original'] = $original_block;
         //Add Classes for the mirroring
         $block_classes[] = 'block-mirrored';
         if ($where != 'grid') {
             $block_classes[] = 'block-mirroring-' . $mirrored_block['id'];
             $block_classes[] = 'block-original-' . $original_block_id;
         }
     }
     //Fetch the HTML tag for the block
     $block_tag = ($html_tag = headway_get('html-tag', $block_type_settings)) ? $html_tag : 'div';
     //The ID attribute for the block.  This will change if mirrored.
     $block_id_for_id_attr = $block['id'];
     //Original block ID to be used in the Visual Editor
     if (HeadwayRoute::is_visual_editor_iframe()) {
         $block_data_attrs = implode(' ', array('data-id="' . str_replace('block-', '', $original_block_id) . '"', 'data-block-mirror="' . (isset($mirrored_block) ? $mirrored_block['id'] : '') . '"', 'data-block-mirror-layout-name="' . (isset($mirrored_block) ? HeadwayLayout::get_name($mirrored_block['layout']) : '') . '"', 'data-grid-left="' . $original_block['position']['left'] . '"', 'data-grid-top="' . $original_block['position']['top'] . '"', 'data-width="' . $original_block['dimensions']['width'] . '"', 'data-height="' . $original_block['dimensions']['height'] . '"', 'data-alias="' . headway_get('alias', headway_get('settings', $original_block, array())) . '"'));
     } else {
         $block_data_attrs = null;
     }
     //The grid will display blocks entirely differently and not use hooks.
     if ($where != 'grid') {
         do_action('headway_before_block', $block);
         do_action('headway_before_block_' . $block['id'], $block);
         echo '<' . $block_tag . ' id="block-' . $block_id_for_id_attr . '" class="' . implode(' ', array_filter(apply_filters('headway_block_class', $block_classes, $block))) . '"' . $block_style_attr . $block_data_attrs . '>';
         do_action('headway_block_open', $block);
         do_action('headway_block_open_' . $block['id'], $block);
         echo '<div class="block-content">';
         do_action('headway_block_content_open', $block);
         do_action('headway_block_content_open_' . $block['id'], $block);
         do_action('headway_block_content_' . $block['type'], $block);
         do_action('headway_block_content_close', $block);
         do_action('headway_block_content_close_' . $block['id'], $block);
         echo '</div><!-- .block-content -->' . "\n";
         do_action('headway_block_close', $block);
         do_action('headway_block_close_' . $block['id'], $block);
         echo '</' . $block_tag . '><!-- #block-' . $block_id_for_id_attr . ' -->' . "\n";
         do_action('headway_after_block', $block);
         do_action('headway_after_block_' . $block['id'], $block);
         //Show the block in the grid
     } else {
         $show_content_in_grid = self::block_type_exists($block['type']) ? headway_get('show-content-in-grid', $block_type_settings, false) : false;
         if (!$show_content_in_grid) {
             $block_classes[] = 'hide-content-in-grid';
         }
         if (!self::block_type_exists($block['type'])) {
             $block_classes[] = 'block-error';
         }
         echo '<' . $block_tag . ' id="block-' . $block_id_for_id_attr . '" class="' . implode(' ', array_filter($block_classes)) . '"' . $block_style_attr . $block_data_attrs . '>';
         echo '<div class="block-content-fade block-content">';
         if (!self::block_type_exists($block['type'])) {
             self::unknown_block_content($block);
         } else {
             if (!$show_content_in_grid) {
                 echo '<p class="hide-content-in-grid-notice"><strong>Notice:</strong> <em>' . self::block_type_nice($block['type']) . '</em> blocks do not display in the Grid Mode.  Please switch to the Design mode to see the content in this block.</p>';
             }
         }
         echo '</div><!-- .block-content-fade -->' . "\n";
         echo '</' . $block_tag . '><!-- #block-' . $block_id_for_id_attr . ' -->' . "\n";
     }
     //Spit the ID back out
     return $block['id'];
 }
 protected function modify_arguments($post = false)
 {
     $this->inputs['template']['options'] = HeadwayLayout::get_templates();
 }
 public static function export_layout($layout_id)
 {
     /* Set up variables */
     if (!($layout_name = HeadwayLayout::get_name($layout_id))) {
         die('Error: Invalid layout.');
     }
     $layout = array('name' => $layout_name, 'blocks' => HeadwayBlocksData::get_blocks_by_layout($layout_id));
     /* Convert all mirrored blocks into original blocks by pulling their mirror target's settings */
     /* Loop through each block in the template and check if it's mirrored.  If it is, replace it with the block that it's mirroring */
     foreach ($layout['blocks'] as $layout_block_index => $layout_block) {
         if (!($mirrored_block = HeadwayBlocksData::is_block_mirrored($layout_block))) {
             continue;
         }
         $layout['blocks'][$layout_block_index] = $mirrored_block;
     }
     /* Spit the file out */
     return self::to_json('Headway Layout - ' . $layout_name, 'layout', $layout);
 }
Example #19
0
 static function templates_to_assign_select_options()
 {
     $templates = HeadwayLayout::get_templates();
     $return = '';
     foreach ($templates as $id => $name) {
         $return .= '<option value="template-' . $id . '">' . $name . '</option>';
     }
     return $return;
 }
Example #20
0
    public static function display_canvas()
    {
        echo '<!DOCTYPE HTML>
		<html lang="en">

		<head>

			<meta charset="' . get_bloginfo('charset') . '" />
			<link rel="profile" href="http://gmpg.org/xfn/11" />

			<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
			<meta http-equiv="cache-control" content="no-cache" />

			<title>Visual Editor Grid: ' . wp_title(false, false) . '</title>';
        do_action('headway_grid_iframe_head');
        echo '</head><!-- /head -->

		<body class="visual-editor-iframe-grid ' . join(' ', get_body_class()) . '">';
        $wrappers = HeadwayWrappers::get_layout_wrappers(HeadwayLayout::get_current_in_use());
        $blocks = HeadwayBlocksData::get_blocks_by_layout(HeadwayLayout::get_current_in_use());
        echo '<div id="whitewrap" data-wrappers="' . htmlspecialchars(json_encode($wrappers)) . '">';
        foreach ($wrappers as $wrapper_id => $wrapper_settings) {
            /* Setup wrapper classes */
            $wrapper_classes = array('wrapper');
            $wrapper_classes[] = headway_get('use-independent-grid', $wrapper_settings) ? 'independent-grid' : null;
            $wrapper_classes[] = $wrapper_settings['fluid'] ? 'wrapper-fluid' : 'wrapper-fixed';
            $wrapper_classes[] = $wrapper_settings['fluid'] && $wrapper_settings['fluid-grid'] ? 'wrapper-fluid-grid' : 'wrapper-fixed-grid';
            if (HeadwayWrappers::get_wrapper_mirror($wrapper_settings)) {
                $wrapper_classes[] = 'wrapper-mirrored';
            }
            /* Populate wrapper with its blocks */
            $wrapper_blocks = array();
            foreach ($blocks as $block_id => $block) {
                /* Grab blocks belonging to this wrapper */
                if (headway_get('wrapper', $block, HeadwayWrappers::$default_wrapper_id) === $wrapper_id) {
                    $wrapper_blocks[$block_id] = $block;
                }
                /* If last wrapper, grab all blocks on this layout with invalid wrapper IDs to make sure they're editable somewhere */
                $last_wrapper_id = array_slice(array_keys($wrappers), -1, 1);
                $last_wrapper_id = $last_wrapper_id[0];
                if ($last_wrapper_id == $wrapper_id && !headway_get(headway_get('wrapper', $block, HeadwayWrappers::$default_wrapper_id), $wrappers)) {
                    $wrapper_blocks[$block_id] = $block;
                }
            }
            /* Output the wrapper */
            echo '<div id="' . $wrapper_id . '" class="' . implode(' ', array_filter($wrapper_classes)) . '">';
            echo '<div class="wrapper-mirror-overlay"></div><!-- .wrapper-mirror-overlay -->';
            self::display_grid_blocks($wrapper_blocks, $wrapper_settings);
            echo '</div><!-- #wrapper-' . $wrapper_id . ' -->';
        }
        echo '<div id="wrapper-buttons-template">';
        echo '<div class="wrapper-top-margin-handle wrapper-handle wrapper-margin-handle" title="Drag to change wrapper top margin"><span></span><span></span><span></span></div>';
        echo '<div class="wrapper-drag-handle wrapper-handle tooltip tooltip-right" title="Drag to change wrapper order"><span></span><span></span><span></span></div>';
        echo '<div class="wrapper-bottom-margin-handle wrapper-handle wrapper-margin-handle" title="Drag to change wrapper bottom margin"><span></span><span></span><span></span></div>';
        echo '<div class="wrapper-options tooltip tooltip-right" title="Click to open wrapper options"><span></span></div>';
        echo '</div><!-- .wrapper-buttons -->';
        do_action('headway_grid_iframe_footer');
        echo '</div><!-- #whitewrap -->
		</body>
		</html>';
    }
Example #21
0
 public static function current_seo_layout()
 {
     /* Since the SEO templates are only at a certain level, checking the real layout against the SEO templates would not work. */
     $layout_hierarchy = HeadwayLayout::get_current_hierarchy();
     if (count($layout_hierarchy) === 1) {
         return $layout_hierarchy[0];
     } elseif (count($layout_hierarchy) > 1) {
         return $layout_hierarchy[1];
     }
     return null;
 }
Example #22
0
 public static function page_switcher_page()
 {
     echo '<strong>Currently Editing: <span>' . HeadwayLayout::get_current_name() . '</span></strong>';
 }
Example #23
0
			<div id="preview-button-container" class="save-button-container">
				<span class="save-button preview-button tooltip-top-right" id="preview-button" title="Click to hide the grid and show how the website looks before saving.">Preview</span>
				<span class="save-button preview-button" id="inactive-preview-button">Preview</span>
			</div>
			';
}
?>
		
	</div><!-- #menu-right -->
</div><!-- #menu -->

<!-- Big Boy iframe -->
<div id="iframe-container">
	<?php 
$layout_url = HeadwayVisualEditor::get_current_mode() == 'grid' ? home_url() : HeadwayLayout::get_url(HeadwayLayout::get_current());
$iframe_url = add_query_arg(array('ve-iframe' => 'true', 've-layout' => HeadwayLayout::get_current(), 've-iframe-mode' => HeadwayVisualEditor::get_current_mode(), 'rand' => rand(1, 999999)), $layout_url);
echo '<iframe id="content" class="content" src="' . $iframe_url . '" scrolling="no"></iframe>';
if (HeadwayVisualEditor::is_mode('grid')) {
    echo '<iframe id="preview" class="content" src="" style="display: none;" scrolling="no"></iframe>';
}
echo '<div id="iframe-overlay"></div>';
echo '<div id="iframe-loading-overlay"><div class="cog-container"><div class="cog-bottom-left"></div><div class="cog-top-right"></div></div></div>';
?>
</div>
<!-- #iframe#content -->

<div id="panel">
				
	<ul id="panel-top">
				
		<?php 
Example #24
0
 /**
  * @param string
  * 
  * @return bool
  **/
 public static function cache_file($file)
 {
     $cache = HeadwayOption::get('cache', false, array());
     //Get the current layout here directly and set is as GET since the output trigger can use POST, but this cannot.
     $_GET['layout-in-use'] = HeadwayLayout::get_current_in_use();
     $_GET['compiler-cache'] = true;
     $content = self::combine_fragments($cache[$file]);
     //If existing cache file exists, delete it.
     self::delete_cache_file($cache[$file]['filename']);
     //Change LESS extension to CSS
     $extension = $cache[$file]['format'] != 'less' ? $cache[$file]['format'] : 'css';
     //If the file is set to only clear on a hard flush, then add that to the filename
     $hard_cache_suffix = $cache[$file]['require-hard-flush'] ? '-hard-cache' : null;
     //MD5 the contents that way we can check for differences down the road
     $cache[$file]['hash'] = md5($content);
     $cache[$file]['filename'] = $file . '-' . substr($cache[$file]['hash'], 0, 7) . $hard_cache_suffix . '.' . $extension;
     //Build file
     $file_handle = @fopen(HEADWAY_CACHE_DIR . '/' . $cache[$file]['filename'], 'w');
     if (!@fwrite($file_handle, $content)) {
         return false;
     }
     @chmod(HEADWAY_CACHE_DIR . '/' . $cache[$file]['filename'], 0755);
     @fclose($file_handle);
     HeadwayOption::set('cache', $cache);
     return true;
 }
Example #25
0
 /**
  * Used for when a user clicks View Site in the Visual Editor
  **/
 public static function redirect_to_layout()
 {
     remove_filter('wp_redirect', '__return_false', 12);
     if (headway_get('debug') && HeadwayCapabilities::can_user_visually_edit()) {
         wp_die(HeadwayLayout::get_url(headway_get('layout')));
     }
     return wp_safe_redirect(HeadwayLayout::get_url(headway_get('layout')));
 }
 public static function secure_method_assign_template()
 {
     $layout = headway_post('layout');
     $template = str_replace('template-', '', headway_post('template'));
     //Add the template flag
     HeadwayLayoutOption::set($layout, 'template', $template);
     do_action('headway_visual_editor_assign_template');
     echo HeadwayLayout::get_name('template-' . $template);
 }