Exemple #1
0
    static function wrapper()
    {
        $layout_id = headway_get('layout-in-use');
        $wrappers = HeadwayWrappers::get_layout_wrappers($layout_id);
        $return = '';
        /* Default Wrapper Margins */
        if (headway_get('file') == 've-iframe-grid-dynamic' && headway_get('visual-editor-open')) {
            $return .= HeadwayElementProperties::output_css('div.wrapper', array('margin-top' => HeadwayElementsData::get_property('wrapper', 'margin-top', HeadwayWrappers::$default_wrapper_margin_top, 'structure'), 'margin-bottom' => HeadwayElementsData::get_property('wrapper', 'margin-bottom', HeadwayWrappers::$default_wrapper_margin_bottom, 'structure'), 'padding-top' => HeadwayElementsData::get_property('wrapper', 'padding-top', null, 'structure'), 'padding-right' => HeadwayElementsData::get_property('wrapper', 'padding-right', null, 'structure'), 'padding-bottom' => HeadwayElementsData::get_property('wrapper', 'padding-bottom', null, 'structure'), 'padding-left' => HeadwayElementsData::get_property('wrapper', 'padding-left', null, 'structure')));
        }
        /* Wrappers for Layout */
        foreach ($wrappers as $wrapper_id => $wrapper_settings) {
            $wrapper_grid_width = HeadwayWrappers::get_grid_width($wrapper_settings);
            /* Set up variables for wrapper */
            $wrapper_selector = 'div#' . $wrapper_id;
            /* Fixed Wrapper */
            if (!$wrapper_settings['fluid']) {
                /* Wrapper */
                $return .= $wrapper_selector . ' {
							width: ' . $wrapper_grid_width . 'px;
						}';
                if (HeadwayResponsiveGrid::is_enabled()) {
                    $return .= $wrapper_selector . '.responsive-grid {
								width: auto !important;
								max-width: ' . $wrapper_grid_width . 'px;
							}';
                }
                /* Grid */
                if (headway_get('file') != 've-iframe-grid-dynamic' || !headway_get('visual-editor-open')) {
                    $return .= HeadwayResponsiveGrid::is_enabled() ? self::responsive_grid($wrapper_settings) : self::fixed_grid($wrapper_settings);
                }
                /* Fluid Wrapper */
            } else {
                /* Grid Container */
                /* Fixed Grid */
                if (!$wrapper_settings['fluid-grid']) {
                    $return .= $wrapper_selector . ' div.grid-container {
									width: ' . $wrapper_grid_width . 'px;
								}';
                    if (HeadwayResponsiveGrid::is_enabled()) {
                        $return .= $wrapper_selector . '.responsive-grid div.grid-container {
										width: auto !important;
										max-width: ' . $wrapper_grid_width . 'px;
									}';
                    }
                }
                /* Grid */
                if (headway_get('file') != 've-iframe-grid-dynamic' || !headway_get('visual-editor-open')) {
                    $return .= HeadwayResponsiveGrid::is_enabled() || $wrapper_settings['fluid-grid'] ? self::responsive_grid($wrapper_settings) : self::fixed_grid($wrapper_settings);
                }
            }
            /* Both Fixed and Fluid: Margin in Grid Mode */
            if (headway_get('file') == 've-iframe-grid-dynamic' && headway_get('visual-editor-open')) {
                $wrapper_instance_id = $wrapper_settings['id'] . '-layout-' . $wrapper_settings['layout'];
                $return .= HeadwayElementProperties::output_css($wrapper_selector, array('margin-top' => HeadwayElementsData::get_special_element_property('wrapper', 'instance', $wrapper_instance_id, 'margin-top', null, 'structure'), 'margin-bottom' => HeadwayElementsData::get_special_element_property('wrapper', 'instance', $wrapper_instance_id, 'margin-bottom', null, 'structure'), 'padding-top' => HeadwayElementsData::get_special_element_property('wrapper', 'instance', $wrapper_instance_id, 'padding-top', null, 'structure'), 'padding-right' => HeadwayElementsData::get_special_element_property('wrapper', 'instance', $wrapper_instance_id, 'padding-right', null, 'structure'), 'padding-bottom' => HeadwayElementsData::get_special_element_property('wrapper', 'instance', $wrapper_instance_id, 'padding-bottom', null, 'structure'), 'padding-left' => HeadwayElementsData::get_special_element_property('wrapper', 'instance', $wrapper_instance_id, 'padding-left', null, 'structure')));
            }
        }
        return $return;
    }
 public static function method_get_layout_blocks_in_json()
 {
     $layout = headway_post('layout', false);
     $layout_status = HeadwayLayout::get_status($layout);
     if ($layout_status['customized'] != true) {
         return false;
     }
     self::json_encode(array('blocks' => HeadwayBlocksData::get_blocks_by_layout($layout, true), 'wrappers' => HeadwayWrappers::get_layout_wrappers($layout, true)));
 }
 public function __construct()
 {
     $this->id = HeadwayLayout::get_current_in_use();
     $this->blocks = HeadwayBlocksData::get_blocks_by_layout($this->id);
     $this->wrappers = HeadwayWrappers::get_layout_wrappers($this->id);
 }
Exemple #4
0
 public static function get_block_actions_from_mirrored_wrappers($layout_id, $block_action)
 {
     $wrappers_on_layout = HeadwayWrappers::get_layout_wrappers($layout_id);
     $blocks = array();
     foreach ($wrappers_on_layout as $wrapper_id => $wrapper_settings) {
         if (!($wrapper_being_mirrored = HeadwayWrappers::get_wrapper_mirror($wrapper_settings))) {
             continue;
         }
         foreach (headway_get($wrapper_being_mirrored['layout'], self::$block_actions[$block_action], array()) as $block_id_on_layout_of_mirrored_wrapper) {
             /* Make sure the block on the layout from the mirrored wrapper is in the actual wrapper that's mirrored otherwise potentially a ton of extra CSS/JS will be loaded from blocks not in use */
             if (headway_get('wrapper', headway_get($block_id_on_layout_of_mirrored_wrapper, self::$block_actions['block-objects'])) == $wrapper_being_mirrored['id']) {
                 $blocks[] = $block_id_on_layout_of_mirrored_wrapper;
             }
         }
     }
     return $blocks;
 }
 public static function export_skin($skin_name = 'Unnamed', $include_live_css = false, $included_templates = false)
 {
     do_action('headway_before_export_skin');
     /* Set up variables */
     $element_data = HeadwayElementsData::get_all_elements();
     $skin = array('name' => $skin_name, 'element-data' => $element_data);
     if ($include_live_css) {
         $skin['live-css'] = HeadwayOption::get('live-css');
     }
     /* If templates are to be included then query for them and convert all mirrored blocks into original blocks by pulling their mirror target's settings */
     if (is_array($included_templates)) {
         $skin['templates'] = array();
         $white_listed_block_instances = array();
         $white_listed_wrapper_instances = array();
         foreach ($included_templates as $template_id) {
             $template_name = HeadwayLayout::get_name('template-' . $template_id);
             $template_blocks = HeadwayBlocksData::get_blocks_by_layout('template-' . $template_id);
             $template_wrappers = HeadwayWrappers::get_layout_wrappers('template-' . $template_id);
             /* 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 ($template_blocks as $template_block_index => $template_block) {
                 if (!($mirrored_block = HeadwayBlocksData::is_block_mirrored($template_block))) {
                     /* Allow this block's instances to be in the skin */
                     $white_listed_block_instances[] = $template_block['id'];
                     /* Delete mirror option in case it's present */
                     if (isset($template_blocks[$template_block_index]['settings']['mirror-block'])) {
                         unset($template_blocks[$template_block_index]['settings']['mirror-block']);
                     }
                     continue;
                 }
                 $template_blocks[$template_block_index]['id'] = $mirrored_block['id'];
                 $template_blocks[$template_block_index]['settings'] = $mirrored_block['settings'];
                 /* Allow this block's instances to be in the skin */
                 $white_listed_block_instances[] = $mirrored_block['id'];
             }
             /* Whitelist wrapper instances */
             foreach ($template_wrappers as $template_wrapper_id => $template_wrapper_settings) {
                 $white_listed_wrapper_instances[] = $template_wrapper_id;
             }
             $skin['templates'][$template_name] = $template_blocks;
             $skin['templates'][$template_name]['wrappers'] = $template_wrappers;
         }
     }
     /* Need to remove instances that aren't in the included templates and layout specific customizations from $element_data here */
     foreach ($skin['element-data'] as $element_id => $element) {
         /* Add in the element group that way it can be saved @since 3.4.8 */
         $element_registration = HeadwayElementAPI::get_element($element_id);
         $skin['element-data'][$element_id]['group'] = $element_registration['group'];
         /* Remove instances that aren't in this skin's templates */
         if (isset($element['special-element-instance'])) {
             /* White list doesn't exist, just remove all instances */
             if (!isset($white_listed_block_instances)) {
                 unset($skin['element-data'][$element_id]['special-element-instance']);
                 /* White List Exists, loop through each instance and check its ID */
             } else {
                 foreach ($skin['element-data'][$element_id]['special-element-instance'] as $instance_id => $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[0] . '-' . $instance_id_fragments[1];
                     /* Wrapper instance conditional.  If a positive match, CONTINUE that way the unset doesn't happen */
                     if (strpos($instance_id, 'wrapper-') === 0 && in_array($instance_potential_wrapper_id, $white_listed_wrapper_instances)) {
                         continue;
                     } else {
                         if (strpos($instance_id, 'block-') !== false && is_numeric($instance_potential_block_id) && in_array($instance_potential_block_id, $white_listed_block_instances)) {
                             continue;
                         }
                     }
                     /* Delete the instance if it doesn't match the block OR wrapper whitelist */
                     unset($skin['element-data'][$element_id]['special-element-instance'][$instance_id]);
                 }
             }
         }
         /* Remove layout-specific customizations from the skin */
         if (isset($element['special-element-layout'])) {
             unset($skin['element-data'][$element_id]['special-element-layout']);
         }
     }
     /* Spit the file out */
     return self::to_json('Headway Skin - ' . $skin_name, 'skin', $skin);
 }
    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>';
    }