Example #1
0
 /** 
  * Anything in here will be displayed when the block is being displayed.
  **/
 function content($block)
 {
     global $SlideDeckPlugin;
     /* Make sure SlideDeck is activated and working */
     if (!is_object($SlideDeckPlugin)) {
         echo '<div class="alert alert-red"><p>SlideDeck must be installed and activated in order for the SlideDeck block to work properly.</p></div>';
         return;
     }
     /* Get the chosen SlideDeck ID */
     $slidedeck_id = parent::get_setting($block, 'slidedeck-id', null);
     /* Make sure that there's a selected SlideDeck */
     if (empty($slidedeck_id)) {
         echo '<div class="alert alert-red"><p>Please choose a SlideDeck to display.</p></div>';
         return;
     }
     $slidedeck_query = $SlideDeckPlugin->SlideDeck->get($slidedeck_id);
     if (empty($slidedeck_query)) {
         echo '<div class="alert alert-red"><p>The SlideDeck you previously chose must\'ve been deleted or moved elsewhere.  Please select another SlideDeck to display.</p></div>';
         return;
     }
     /* Setup arguments */
     $args = array('id' => $slidedeck_id, 'width' => null, 'height' => null);
     if (parent::get_setting($block, 'use-block-size', true)) {
         $args['width'] = HeadwayBlocksData::get_block_width($block);
         $args['height'] = HeadwayBlocksData::get_block_height($block);
         $args['proportional'] = false;
     }
     if (HeadwayRoute::is_visual_editor_iframe()) {
         $args['iframe'] = true;
     }
     if (!HeadwayRoute::is_visual_editor_iframe() && HeadwayResponsiveGrid::is_active()) {
         $args['ress'] = true;
     }
     /* Work around for iframe dimensions */
     $GLOBALS['slidedeck-width'] = $args['width'];
     $GLOBALS['slidedeck-height'] = $args['height'];
     add_filter('slidedeck_dimensions', array(__CLASS__, 'modify_slidedeck_iframe_size_for_ajax'), 10, 5);
     /* End work around for iframe dimensions */
     /* Show the SlideDeck! */
     echo $SlideDeckPlugin->shortcode($args);
     /* Remove any filters if necessary */
     remove_filter('slidedeck_dimensions', array(__CLASS__, 'modify_slidedeck_iframe_size_for_ajax'));
     if (isset($GLOBALS['slidedeck-width'])) {
         unset($GLOBALS['slidedeck-width']);
     }
     if (isset($GLOBALS['slidedeck-height'])) {
         unset($GLOBALS['slidedeck-height']);
     }
     /* End removing filters */
 }
Example #2
0
 public function add_standard_block_config()
 {
     if (!isset($this->tabs)) {
         $this->tabs = array();
     }
     if (!isset($this->inputs)) {
         $this->inputs = array();
     }
     //Add the tab
     $this->tabs['config'] = 'Config';
     /* Add the inputs */
     $this->inputs['config']['mirror-block'] = array('type' => 'select', 'name' => 'mirror-block', 'label' => 'Mirror Block', 'default' => '', 'tooltip' => 'By using this option, you can tell a block to "mirror" another block and its content.  This option is useful if you are wanting to share a block&mdash;such as a header&mdash;across layouts on your site.  Select the block you wish to mirror the content from in the select box to the right.', 'options' => 'get_blocks_select_options_for_mirroring()', 'callback' => 'updateBlockMirrorStatus(input, block.id, value);');
     $this->inputs['config']['alias'] = array('type' => 'text', 'name' => 'alias', 'label' => 'Block Alias', 'default' => '', 'tooltip' => 'Enter an easily recognizable name for the block alias and it will be used throughout your site admin.  For instance, if you add an alias to a widget area block, that alias will be used in the Widgets panel.');
     if (HeadwayResponsiveGrid::is_enabled()) {
         $this->inputs['config']['responsive-block-hiding'] = array('type' => 'multi-select', 'name' => 'responsive-block-hiding', 'label' => 'Responsive Grid Block Hiding', 'default' => '', 'tooltip' => 'If you have the responsive grid enabled and the user views your website on an iPhone (or equivalent device), the grid may be cluttered do to so many blocks being in a small area.  If you wish to limit the blocks that are shown on mobile devices, you can use this setting to hide certain blocks for the devices you choose.  <strong>If no options are selected, then responsive block hiding will not be active for this block.</strong>', 'options' => array('smartphones' => 'iPhone/Smartphones', 'tablets-landscape' => 'iPad/Tablets (Landscape)', 'tablets-portrait' => 'iPad/Tablets (Portrait)', 'computers' => 'Laptops & Desktops (Not Recommended)'));
     }
     /* Block Styles */
     if (HEADWAY_CHILD_THEME_ACTIVE) {
         $block_style_options = array('' => '&ndash; No Style &ndash;');
         foreach (HeadwayChildThemeAPI::$block_styles as $block_style_id => $block_style) {
             if (is_array($block_style['block-types']) && !in_array($this->block['type'], $block_style['block-types'])) {
                 continue;
             }
             if (is_string($block_style['block-types']) && $block_style['block-types'] != 'all' && $block_style['block-types'] != $this->block['type']) {
                 continue;
             }
             $block_style_options[$block_style_id] = $block_style['name'];
         }
         if (count($block_style_options) > 1) {
             $this->inputs['config'][HEADWAY_CHILD_THEME_ID . '-block-style'] = array('type' => 'select', 'name' => HEADWAY_CHILD_THEME_ID . '-block-style', 'label' => 'Block Styles', 'default' => '', 'tooltip' => '', 'options' => $block_style_options, 'callback' => '$.each(Headway.blockStyles, function(key, value) { block.removeClass(value); }); if ( value ) { block.addClass(Headway.blockStyles[value]); }');
         }
     }
     /* End Block Styles */
     $this->inputs['config']['css-classes'] = array('type' => 'text', 'name' => 'css-classes', 'label' => 'Custom CSS Class(es)', 'default' => '', 'tooltip' => 'Need more finite control?  Enter the custom CSS class selectors here and they will be added to the block\'s class attribute. <strong>DO NOT</strong> put regular CSS in here.  Use the Live CSS editor for that.');
     $this->inputs['config']['css-classes-bubble'] = array('type' => 'checkbox', 'name' => 'css-classes-bubble', 'label' => '<em style="color: #666; font-style: italic;">Advanced:</em> Add Custom CSS Class(es) to Row/Column', 'default' => '', 'tooltip' => 'Copy any custom CSS classes added to this block and add them to the parent row and column &lt;section&gt;\'s');
     /* Titles */
     if (isset($this->block_type_object->allow_titles) && $this->block_type_object->allow_titles) {
         $this->inputs['config']['titles-heading'] = array('name' => 'titles-heading', 'type' => 'heading', 'label' => 'Block Title');
         $this->inputs['config']['block-title'] = array('name' => 'block-title', 'type' => 'text', 'label' => 'Block Title', 'tooltip' => 'Add a custom title above the block content.');
         $this->inputs['config']['block-subtitle'] = array('name' => 'block-subtitle', 'type' => 'text', 'label' => 'Block Subtitle', 'tooltip' => 'Add a custom sub title above the block content and below the block title.');
     }
     /* End Titles */
 }
 public function display()
 {
     if (!$this->blocks) {
         return $this->display_no_blocks_message();
     }
     foreach ($this->wrappers as $wrapper_id => $wrapper_settings) {
         $wrapper_id_for_blocks = $wrapper_id;
         /* Check if mirroring.  If mirroring, change wrapper ID to the wrapper being mirrored and preserve original ID for a later class */
         if ($wrapper_being_mirrored = HeadwayWrappers::get_wrapper_mirror($wrapper_settings)) {
             $mirrored_wrapper_id = $wrapper_being_mirrored['id'];
             $wrapper_id_for_blocks = $mirrored_wrapper_id;
             foreach (HeadwayBlocksData::get_blocks_by_wrapper($wrapper_being_mirrored['layout'], $mirrored_wrapper_id) as $block_from_mirrored_wrapper) {
                 $this->blocks[$block_from_mirrored_wrapper['id']] = $block_from_mirrored_wrapper;
             }
         }
         /* Grab blocks belonging to this wrapper */
         $wrapper_blocks = array();
         foreach ($this->blocks as $block_id => $block) {
             if (headway_get('wrapper', $block, HeadwayWrappers::$default_wrapper_id) === $wrapper_id_for_blocks) {
                 $wrapper_blocks[$block_id] = $block;
             }
             /* If there's only one wrapper and the block does not have a proper ID or is default, move it to that wrapper */
             if (count($this->wrappers) === 1 && (headway_get('wrapper', $block) === null || headway_get('wrapper', $block) == 'wrapper-default' || !isset($this->wrappers[headway_get('wrapper', $block)]))) {
                 $wrapper_blocks[$block_id] = $block;
             }
         }
         /* Setup wrapper classes */
         $wrapper_column_width = headway_get('use-independent-grid', $wrapper_settings) ? headway_get('column-width', $wrapper_settings) : HeadwayOption::get('column-width', false, HeadwayWrappers::$default_column_width);
         $wrapper_gutter_width = headway_get('use-independent-grid', $wrapper_settings) ? headway_get('gutter-width', $wrapper_settings) : HeadwayOption::get('gutter-width', false, HeadwayWrappers::$default_gutter_width);
         $wrapper_classes = array('wrapper');
         $wrapper_classes[] = $wrapper_settings['fluid'] ? 'wrapper-fluid' : 'wrapper-fixed';
         $wrapper_classes[] = HeadwayResponsiveGrid::is_active() ? 'responsive-grid' : null;
         $wrapper_classes[] = headway_get('use-independent-grid', $wrapper_settings) ? 'independent-grid' : null;
         $wrapper_classes[] = 'grid-' . ($wrapper_settings['fluid-grid'] || HeadwayResponsiveGrid::is_enabled() ? 'fluid' : 'fixed') . '-' . $wrapper_settings['columns'] . '-' . $wrapper_column_width . '-' . $wrapper_gutter_width;
         $wrapper_classes[] = $wrapper_being_mirrored ? 'wrapper-mirroring-' . HeadwayWrappers::format_wrapper_id($mirrored_wrapper_id) : null;
         $last_wrapper_id = array_slice(array_keys($this->wrappers), -1, 1);
         $last_wrapper_id = $last_wrapper_id[0];
         $first_wrapper_id = array_keys($this->wrappers);
         $first_wrapper_id = $first_wrapper_id[0];
         if ($last_wrapper_id == $wrapper_id) {
             $wrapper_classes[] = 'wrapper-last';
         } else {
             if ($first_wrapper_id == $wrapper_id) {
                 $wrapper_classes[] = 'wrapper-first';
             }
         }
         /* Custom wrapper classes */
         $custom_css_classes = explode(' ', str_replace('  ', ' ', str_replace(',', ' ', htmlspecialchars(strip_tags(headway_get('css-classes', $wrapper_settings, ''))))));
         $wrapper_classes = array_merge($wrapper_classes, $custom_css_classes);
         /* Display the wrapper */
         do_action('headway_before_wrapper');
         echo '<div id="' . $wrapper_id . '" class="' . implode(' ', array_unique(array_filter($wrapper_classes))) . '">' . "\n\n";
         do_action('headway_wrapper_open');
         $wrapper = new HeadwayGridRenderer($wrapper_blocks, $wrapper_settings);
         $wrapper->render_grid();
         do_action('headway_wrapper_close');
         echo '</div><!-- .wrapper -->' . "\n\n";
         do_action('headway_after_wrapper');
         /* End displaying wrapper */
     }
 }
Example #4
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;
    }
Example #5
0
 /**
  * Shows a link to either view the full site or view the mobile site.
  * 
  * This will only show if the responsive grid is enabled.
  **/
 public static function show_responsive_grid_toggle_link()
 {
     if (!HeadwayResponsiveGrid::is_enabled()) {
         return false;
     }
     $current_url = headway_get_current_url();
     if (HeadwayResponsiveGrid::is_active()) {
         $url = add_query_arg(array('full-site' => 'true'), $current_url);
         $classes = 'footer-responsive-grid-link footer-responsive-grid-disable footer-link';
         echo apply_filters('headway_responsive_disable_link', '<p class="footer-responsive-grid-link-container footer-responsive-grid-link-disable-container"><a href="' . $url . '" rel="nofollow" class="' . $classes . '">' . __('View Full Site', 'headway') . '</a></p>');
     } elseif (HeadwayResponsiveGrid::is_user_disabled()) {
         $url = add_query_arg(array('full-site' => 'false'), $current_url);
         $classes = 'footer-responsive-grid-link footer-responsive-grid-enable footer-link';
         echo apply_filters('headway_responsive_enable_link', '<p class="footer-responsive-grid-link-container footer-responsive-grid-link-enable-container"><a href="' . $url . '" rel="nofollow" class="' . $classes . '">' . __('View Mobile Site', 'headway') . '</a></p>');
     }
 }
Example #6
0
 public static function register_responsive_css()
 {
     if (!HeadwayResponsiveGrid::is_enabled()) {
         return;
     }
     /* CSS */
     HeadwayCompiler::register_file(array('name' => 'responsive-grid', 'format' => 'css', 'fragments' => array(array('HeadwayResponsiveGridDynamicMedia', 'content')), 'dependencies' => array(HEADWAY_LIBRARY_DIR . '/media/dynamic/responsive-grid.php')));
     /* JS */
     if (HeadwayResponsiveGrid::is_active() && apply_filters('headway_responsive_fitvids', HeadwayOption::get('responsive-video-resizing', false, true))) {
         wp_enqueue_script('fitvids', headway_url() . '/library/media/js/jquery.fitvids.js', array('jquery'));
         HeadwayCompiler::register_file(array('name' => 'responsive-grid-js', 'format' => 'js', 'fragments' => array(array('HeadwayResponsiveGridDynamicMedia', 'fitvids')), 'dependencies' => array(HEADWAY_LIBRARY_DIR . '/media/dynamic/responsive-grid.php')));
     }
 }
Example #7
0
    public static function dynamic_js($block_id, $block, $original_block = null)
    {
        $js = null;
        /* Superfish */
        if (self::does_menu_have_subs('navigation_block_' . $block_id)) {
            switch (parent::get_setting($block, 'effect', 'fade')) {
                case 'none':
                    $animation = '{height:"show"}';
                    $speed = '0';
                    break;
                case 'fade':
                    $animation = '{opacity:"show"}';
                    $speed = "'fast'";
                    break;
                case 'slide':
                    $animation = '{height:"show"}';
                    $speed = "'fast'";
                    break;
            }
            $js .= 'jQuery(document).ready(function(){ 
					if ( typeof jQuery().superfish != "function" )
						return false;

					jQuery("#block-' . $block_id . '").find("ul.menu").superfish({
						delay: 200,
						animation: ' . $animation . ',
						speed: ' . $speed . ',
						onBeforeShow: function() {
							var parent = jQuery(this).parent();
							
							var subMenuParentLink = jQuery(this).siblings(\'a\');
							var subMenuParents = jQuery(this).parents(\'.sub-menu\');

							if ( subMenuParents.length > 0 || jQuery(this).parents(\'.nav-vertical\').length > 0 ) {
								jQuery(this).css(\'marginLeft\',  parent.outerWidth());
								jQuery(this).css(\'marginTop\',  -subMenuParentLink.outerHeight());
							}
						}
					});		
				});' . "\n\n";
        }
        /* SelectNav */
        if (HeadwayResponsiveGrid::is_active() && parent::get_setting($block, 'responsive-select', true)) {
            $js .= 'jQuery(document).ready(function(){

					if ( typeof window.selectnav != "function" )
						return false;

					selectnav(jQuery("#block-' . $block_id . '").find("ul.menu")[0], {
						label: "-- ' . __('Navigation', 'headway') . ' --",
						nested: true,
						indent: "-",
						activeclass: "current-menu-item"
					});

					jQuery("#block-' . $block_id . '").find("ul.menu").addClass("selectnav-active");

				});' . "\n\n";
        }
        return $js;
    }
Example #8
0
    ?>
	Amount of Posts:	~<?php 
    echo $post_count->publish . "\n";
    ?>
	Amount of Pages:	~<?php 
    echo $page_count->publish . "\n";
    ?>
	Amount of Blocks: 	~<?php 
    echo count(HeadwayBlocksData::get_all_blocks()) . "\n";
    ?>
	<?php 
}
?>
    
    Responsive Grid: 	<?php 
echo HeadwayResponsiveGrid::is_enabled() ? 'Enabled' . "\n" : 'Disabled' . "\n";
?>
    
    Caching Allowed: 	<?php 
echo HeadwayCompiler::can_cache() ? 'Yes' . "\n" : 'No' . "\n";
?>
    Caching Enabled: 	<?php 
echo HeadwayCompiler::caching_enabled() ? 'Yes' . "\n" : 'No' . "\n";
?>
    Caching Plugin: 	<?php 
echo HeadwayCompiler::is_plugin_caching() ? HeadwayCompiler::is_plugin_caching() . "\n" : 'No caching plugin active' . "\n";
?>
    
	SEO Plugin: 		<?php 
echo HeadwaySEO::plugin_active() ? HeadwaySEO::plugin_active() . "\n" : 'No SEO plugin active' . "\n";
?>
Example #9
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 #10
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'];
 }
Example #11
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));
 }