Ejemplo n.º 1
0
    function box($args)
    {
        $defaults = array('group' => null, 'element' => null, 'special_element_type' => false, 'special_element_meta' => false, 'selective_properties' => false, 'property_values' => false, 'property_values_excluding_defaults' => false, 'unsaved_values' => false);
        extract(array_merge($defaults, $args));
        //Format the group name into capitalized and spaced
        $group = ucwords(str_replace('-', ' ', $group));
        //If the group doesn't exist, don't attempt to display it
        if (!($properties = HeadwayElementProperties::get_properties_by_group($group))) {
            return false;
        }
        /* Set up variables */
        $uncustomize_button = '<span class="uncustomize-property tooltip" title="Set the property to inherit."></span>';
        $customize_button = '<div class="customize-property"><span class="tooltip" title="Click to change the value for this property.  If left uncustomized, the property will automatically inherit to the default set for this element type in the defaults tab or the parent element if editing a state, instance, or layout-specific element.">Customize</span></div>';
        $element_selector_attr = isset($element['selector']) ? ' element_selector="' . htmlspecialchars($element['selector']) . '"' : null;
        /* Determine if it's a special element */
        $special_element = !$special_element_type || $special_element_type == 'default' ? false : true;
        /* Custom behaviors for special element types */
        switch ($special_element_type) {
            case 'default':
                $uncustomize_button = null;
                $customize_button = null;
                break;
            case 'instance':
                $instances = headway_get('instances', $element);
                $instance = $instances[$special_element_meta];
                $element_selector_attr = ' element_selector="' . htmlspecialchars($instance['selector']) . '"';
                break;
            case 'state':
                $states = headway_get('states', $element);
                $state = $states[$special_element_meta];
                $element_selector_attr = ' element_selector="' . htmlspecialchars($state['selector']) . '"';
                break;
            case 'layout':
                if (isset($element['selector']) && isset($special_element_meta)) {
                    $element_selector_attr = ' element_selector="' . htmlspecialchars('body.layout-using-' . $special_element_meta . ' ' . $element['selector']) . '"';
                    if ($element['selector'] == 'body') {
                        $element_selector_attr = str_replace(' body', '', $element_selector_attr);
                    }
                }
                break;
        }
        /* Set customized box class flag */
        $customized_box_class = '';
        $property_box_title = '';
        foreach ($property_values_excluding_defaults as $property_id => $property_value) {
            if (!isset($properties[$property_id])) {
                continue;
            }
            $customized_box_class = ' design-editor-box-customized';
            $property_box_title = ' title="' . __('You have customized a property in this property group.', 'headway') . '"';
            break;
        }
        /* Create the box */
        echo '<div class="design-editor-box design-editor-box-' . str_replace(' ', '-', strtolower($group)) . ' design-editor-box-minimized' . $customized_box_class . '">';
        echo '<span class="design-editor-box-title"' . $property_box_title . '>' . $group . '</span>';
        echo '<span class="design-editor-box-toggle"></span>';
        if ($group == 'Rounded Corners' || $group == 'Borders' || $group == 'Padding' || $group == 'Margins') {
            echo '<span class="design-editor-lock-sides" data-locked="false"></span>';
        }
        echo '<ul class="design-editor-box-content">';
        foreach ($properties as $property_id => $options) {
            //If the $selective_properties variable is set, then make sure we're only showing those properties.
            if (is_array($selective_properties)) {
                if (!in_array($property_id, $selective_properties)) {
                    continue;
                }
            }
            //Make sure the input type for the property really exists
            if (!is_callable(array(__CLASS__, 'input_' . str_replace('-', '_', $options['type'])))) {
                continue;
            }
            if (headway_fix_data_type(headway_get($property_id, $property_values)) || headway_fix_data_type(headway_get($property_id, $property_values)) === 0) {
                $options['value'] = $property_values[$property_id];
                $customized = true;
                //If the value isn't set try to get the inherit location value, if not, revert clear back to the default property type value
            } else {
                $property_default = isset($options['default']) ? $options['default'] : null;
                $options['value'] = HeadwayElementsData::get_inherited_property($element['id'], $property_id, $property_default);
                $customized = false;
            }
            $js_callback = htmlspecialchars('
									(function(params){
										' . $options['js-callback'] . '
									})');
            /* Set up attributes */
            $property_title = '';
            $property_classes = array('design-editor-property-' . $property_id);
            if (headway_fix_data_type(headway_get($property_id, $property_values_excluding_defaults)) || headway_fix_data_type(headway_get($property_id, $property_values_excluding_defaults)) === 0) {
                $property_classes[] = 'customized-property-by-user';
                $property_title = ' title="' . __('You have customized this property.', 'headway') . '"';
            } else {
                if (!$customized && $special_element_type !== 'default') {
                    $property_classes[] = 'uncustomized-property';
                }
                if (!$customized && headway_get($property_id, $property_values) === '') {
                    $property_classes[] = 'uncustomized-property-by-user';
                    $property_title = ' title="' . __('You have set this property to inherit.', 'headway') . '"';
                }
            }
            /* add a locked class if it's a lockable element only */
            if ($group == 'Rounded Corners' || $group == 'Padding' || $group == 'Margins' || $property_id == 'border-top-width' || $property_id == 'border-right-width' || $property_id == 'border-bottom-width' || $property_id == 'border-left-width') {
                $property_classes[] = 'lockable';
            }
            if ($property_id == 'border-top-width') {
                echo '<li class="design-property-border-heading"><strong>Border Width</strong></li>';
            }
            echo '<li class="' . implode(' ', array_filter($property_classes)) . '"' . $property_title . '>';
            echo '<strong><span class="property-label">' . $options['name'] . '</span>' . $uncustomize_button . '</strong>';
            echo '<div class="property-' . $options['type'] . ' property">';
            call_user_func(array(__CLASS__, 'input_' . str_replace('-', '_', $options['type'])), $options, $property_id);
            echo '<input ' . $element_selector_attr . ' element="' . $element['id'] . '" property="' . $property_id . '" data-element-group="' . $element['group'] . '" special_element_type="' . $special_element_type . '" special_element_meta="' . $special_element_meta . '" type="hidden" callback="' . $js_callback . '" class="property-hidden-input" value="' . $options['value'] . '" />';
            echo '</div>';
            echo $customize_button;
            echo '</li>';
        }
        echo '</ul><!-- .design-editor-box-content -->';
        echo '</div><!-- .design-editor-box -->';
    }
Ejemplo n.º 2
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;
    }
Ejemplo n.º 3
0
 public static function add_visual_editor_js_vars()
 {
     //Gather the URLs for the block types
     $block_types = HeadwayBlocks::get_block_types();
     $block_type_urls = array();
     foreach ($block_types as $block_type => $block_type_options) {
         $block_type_urls[$block_type] = $block_type_options['url'];
     }
     $block_styles = class_exists('HeadwayChildThemeAPI') ? HeadwayChildThemeAPI::get_block_style_classes() : array();
     $current_layout_status = HeadwayLayout::get_status(HeadwayLayout::get_current());
     $script_name = is_ssl() ? 'headway-ve-js-https' : 'headway-ve-js';
     wp_localize_script($script_name, 'Headway', array('ajaxURL' => admin_url('admin-ajax.php'), 'currentLayout' => HeadwayLayout::get_current(), 'currentLayoutName' => HeadwayLayout::get_name(HeadwayLayout::get_current()), 'currentLayoutCustomized' => $current_layout_status['customized'], 'currentLayoutTemplate' => $current_layout_status['template'], 'availableBlockID' => HeadwayBlocksData::get_available_block_id(), 'availableWrapperID' => HeadwayWrappers::get_available_wrapper_id(), 'headwayURL' => get_template_directory_uri(), 'siteURL' => site_url(), 'homeURL' => home_url(), 'adminURL' => admin_url(), 'mode' => HeadwayVisualEditor::get_current_mode(), 'designEditorSupport' => current_theme_supports('headway-design-editor'), 'siteName' => get_bloginfo('name'), 'siteDescription' => get_bloginfo('description'), 'security' => wp_create_nonce('headway-visual-editor-ajax'), 'ranTour' => json_encode(array('legacy' => HeadwayOption::get('ran-tour', false, false), 'grid' => HeadwayOption::get('ran-tour-grid', false, false), 'design' => HeadwayOption::get('ran-tour-design', false, false))), 'blockTypeURLs' => json_encode($block_type_urls), 'allBlockTypes' => json_encode($block_types), 'disableCodeMirror' => HeadwayOption::get('disable-codemirror', false, false), 'frontPage' => get_option('show_on_front', 'posts'), 'gridSupported' => current_theme_supports('headway-grid'), 'disableTooltips' => HeadwayOption::get('disable-visual-editor-tooltips', false, false), 'blockStyles' => $block_styles, 'responsiveGrid' => HeadwayResponsiveGrid::is_enabled(), 'designEditorProperties' => HeadwayVisualEditor::is_mode('design') ? json_encode(HeadwayElementProperties::get_properties()) : json_encode(array()), 'colorpickerSwatches' => HeadwayOption::get('colorpicker-swatches', false, array()), 'gridSafeMode' => HeadwayOption::get('grid-safe-mode', false, false), 'defaultGridColumnCount' => HeadwayWrappers::$default_columns, 'globalGridColumnWidth' => HeadwayWrappers::$global_grid_column_width, 'globalGridGutterWidth' => HeadwayWrappers::$global_grid_gutter_width, 'touch' => stripos($_SERVER['HTTP_USER_AGENT'], 'iPad') !== false ? true : false));
 }