Beispiel #1
0
 function content($block)
 {
     //Use header image if there is one
     if ($header_image_src = parent::get_setting($block, 'header-image')) {
         do_action('headway_before_header_link');
         if (parent::get_setting($block, 'resize-header-image', true)) {
             $block_width = HeadwayBlocksData::get_block_width($block);
             $block_height = HeadwayBlocksData::get_block_height($block);
             $header_image_url = headway_resize_image($header_image_src, $block_width, $block_height);
         } else {
             $header_image_url = $header_image_src;
         }
         echo '<a href="' . home_url() . '" class="banner-image"><img src="' . $header_image_url . '" alt="' . get_bloginfo('name') . '" /></a>';
         do_action('headway_after_header_link');
         //No image present
     } else {
         do_action('headway_before_header_link');
         echo '<span class="banner"><a href="' . home_url() . '">' . get_bloginfo('name') . '</a></span>';
         do_action('headway_after_header_link');
         if (!parent::get_setting($block, 'hide-tagline', false)) {
             if ((is_front_page() || is_home()) && get_option('show_on_front') != 'page') {
                 echo '<h1 class="tagline">' . get_bloginfo('description') . '</h1>' . "\n";
             } else {
                 echo '<span class="tagline">' . get_bloginfo('description') . '</span>' . "\n";
             }
             do_action('headway_after_tagline');
         }
     }
 }
Beispiel #2
0
 /**
  * Over time, there may be issues to be corrected between updates or naming conventions to be changed between updates.
  * All of that will be processed here.
  **/
 public static function db_upgrade($db_version)
 {
     /* Pre-3.0.3 */
     if (version_compare($db_version, '3.0.3', '<')) {
         self::fix_serialization_in_db();
         self::repair_blocks();
     }
     /**
      * Pre-3.2.3
      * 
      * Change the old wrapper-horizontal-padding and wrapper-vertical-padding to design editor values
      **/
     if (version_compare($db_version, '3.2.3', '<')) {
         $horizontal_padding = HeadwayOption::get('wrapper-horizontal-padding', 'general', 15);
         $vertical_padding = HeadwayOption::get('wrapper-vertical-padding', 'general', 15);
         HeadwayElementsData::set_property('structure', 'wrapper', 'padding-top', $vertical_padding);
         HeadwayElementsData::set_property('structure', 'wrapper', 'padding-bottom', $vertical_padding);
         HeadwayElementsData::set_property('structure', 'wrapper', 'padding-left', $horizontal_padding);
         HeadwayElementsData::set_property('structure', 'wrapper', 'padding-right', $horizontal_padding);
     }
     /**
      * Pre-3.4
      * 
      * - Change block and wrapper margins to Design Editor values
      * - Convert Media blocks to Slider or Embed blocks
      **/
     if (version_compare($db_version, '3.4', '<')) {
         /* Change block and wrapper margins to Design Editor values */
         HeadwayElementsData::set_property('structure', 'wrapper', 'margin-top', HeadwayOption::get('wrapper-top-margin', 'general', 30));
         HeadwayElementsData::set_property('structure', 'wrapper', 'margin-bottom', HeadwayOption::get('wrapper-bottom-margin', 'general', 30));
         HeadwayElementsData::set_property('default-elements', 'default-block', 'margin-bottom', HeadwayOption::get('block-bottom-margin', 'general', 10));
         /* Convert Media blocks to Slider or Embed blocks */
         $media_blocks = HeadwayBlocksData::get_blocks_by_type('media');
         if (is_array($media_blocks) && count($media_blocks)) {
             foreach ($media_blocks as $media_block_id => $media_block_layout_id) {
                 $media_block = HeadwayBlocksData::get_block($media_block_id);
                 $media_block_mode = headway_get('mode', $media_block['settings'], 'embed');
                 switch ($media_block_mode) {
                     case 'embed':
                         HeadwayBlocksData::update_block($media_block['layout'], $media_block['id'], array('type' => 'embed'));
                         break;
                     case 'image-rotator':
                         $slider_images = array();
                         foreach (headway_get('images', $media_block['settings'], array()) as $media_block_image) {
                             $slider_images[] = array('image' => $media_block_image, 'image-description' => null, 'image-hyperlink' => null);
                         }
                         HeadwayBlocksData::update_block($media_block['layout'], $media_block['id'], array('type' => 'slider', 'settings' => array('images' => $slider_images)));
                         break;
                 }
             }
         }
     }
     /* Add action to flush caches */
     do_action('headway_db_upgrade');
     /* Update the version here. */
     $headway_settings = get_option('headway', array('version' => 0));
     $headway_settings['version'] = HEADWAY_VERSION;
     update_option('headway', $headway_settings);
     return true;
 }
Beispiel #3
0
 public static function delete_post($postid)
 {
     $post = get_post($postid);
     $post_type = get_post_type_object($post->post_type);
     /* If the post type is a revision then don't do anything. */
     if ($post->post_type == 'revision') {
         return false;
     }
     /* Figure out the layout ID */
     //If it has no parents, just stop.
     if ($post->post_parent === 0) {
         $layout_id = 'single-' . $post_type->name . '-' . $post->ID;
         //Otherwise, figure out parents and grandparents
     } else {
         //Set up variables
         $posts = array($post->ID);
         $parents_str = '';
         //Get to business
         while ($post->post_parent != 0) {
             $posts[] = $post->post_parent;
             $post = get_post($post->post_parent);
         }
         foreach (array_reverse($posts) as $post_id) {
             $layout_id = 'single-' . $post_type->name . '-' . $parents_str . $post_id;
             $parents_str .= $post_id . '-';
         }
     }
     //Delete the blocks for the page/post
     HeadwayBlocksData::delete_by_layout($layout_id);
 }
Beispiel #4
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);
            }
        }
    }
}
Beispiel #5
0
 function content($block)
 {
     $images = parent::get_setting($block, 'images', array());
     $block_width = HeadwayBlocksData::get_block_width($block);
     $block_height = HeadwayBlocksData::get_block_height($block);
     $has_images = false;
     foreach ($images as $image) {
         if ($image['image']) {
             $has_images = true;
             break;
         }
     }
     if (!$has_images) {
         echo '<div class="alert alert-yellow"><p>There are no images to display.</p></div>';
         return;
     }
     $no_slide_class = count($images) === 1 ? ' flexslider-no-slide' : '';
     echo '<div class="flexslider' . $no_slide_class . '">';
     /* Put in viewport div for sliders that only have 1 image and don't slide */
     if (count($images) === 1) {
         echo '<div class="flex-viewport">';
     }
     echo '<ul class="slides">';
     foreach ($images as $image) {
         if (!$image['image']) {
             continue;
         }
         $output = array('image' => array('src' => parent::get_setting($block, 'crop-resize-images', true) ? headway_resize_image($image['image'], $block_width, $block_height) : $image['image'], 'alt' => headway_fix_data_type(headway_get('image-alt', $image)), 'title' => headway_fix_data_type(headway_get('image-title', $image)), 'caption' => headway_fix_data_type(headway_get('image-description', $image))), 'hyperlink' => array('href' => headway_fix_data_type(headway_get('image-hyperlink', $image)), 'target' => headway_fix_data_type(headway_get('image-open-link-in-new-window', $image, false)) ? ' target="_blank"' : null));
         echo '<li>';
         /* Open hyperlink if user added one for image */
         if ($output['hyperlink']['href']) {
             echo '<a href="' . $output['hyperlink']['href'] . '"' . $output['hyperlink']['target'] . '>';
         }
         /* Don't forget to display the ACTUAL IMAGE */
         echo '<img src="' . $output['image']['src'] . '" alt="' . $output['image']['alt'] . '" title="' . $output['image']['title'] . '" />';
         /* Closing tag for hyperlink */
         if ($output['hyperlink']['href']) {
             echo '</a>';
         }
         /* Caption */
         if (!empty($output['image']['caption'])) {
             echo '<p class="flex-caption">' . $output['image']['caption'] . '</p>';
         }
         echo '</li>';
     }
     echo '</ul>';
     /* Put in viewport div for sliders that only have 1 image and don't slide */
     if (count($images) === 1) {
         echo '</div><!-- .flex-viewport -->';
     }
     echo '</div><!-- .flexslider -->';
 }
Beispiel #6
0
 function content($block)
 {
     if ($embed_url = parent::get_setting($block, 'embed-url', false)) {
         $block_width = HeadwayBlocksData::get_block_width($block);
         $block_height = HeadwayBlocksData::get_block_height($block);
         $embed_code = wp_oembed_get($embed_url, array('width' => $block_width, 'height' => $block_height));
         //Make the width and height exactly what the block's dimensions are.
         $embed_code = preg_replace(array('/width="\\d+"/i', '/height="\\d+"/i'), array('width="' . $block_width . '"', 'height="' . $block_height . '"'), $embed_code);
         echo $embed_code;
     } else {
         echo '<div class="alert alert-yellow"><p>There is no content to display.  Please enter a valid embed URL in the visual editor.</p></div>';
     }
 }
Beispiel #7
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 */
 }
Beispiel #8
0
 static function block_heights()
 {
     if (!($blocks = HeadwayBlocksData::get_all_blocks())) {
         return false;
     }
     $return = '';
     //Retrieve the blocks so we can check if the block type is fixed or fluid height
     $block_types = HeadwayBlocks::get_block_types();
     foreach ($blocks as $block) {
         $selector = '#block-' . $block['id'];
         /* If the block is mirrored then change the selector */
         if ($mirrored_block_id = HeadwayBlocksData::is_block_mirrored($block, true)) {
             $selector = '#block-' . $mirrored_block_id . '.block-original-' . $block['id'];
         }
         //If it's a fluid block (which blocks ARE by default), then we need to use min-height.  Otherwise, if it's fixed, we use height.
         if (headway_get('fixed-height', headway_get($block['type'], $block_types), false) !== true) {
             $return .= $selector . ' { min-height: ' . $block['dimensions']['height'] . 'px; }';
         } else {
             $return .= $selector . ' { height: ' . $block['dimensions']['height'] . 'px; }';
         }
     }
     return $return;
 }
Beispiel #9
0
 static function get_blocks_select_options_for_mirroring($block_type)
 {
     $return = '';
     $blocks = HeadwayBlocksData::get_blocks_by_type($block_type);
     //If there are no blocks, then just return the Do Not Mirror option.
     if (!isset($blocks) || !is_array($blocks)) {
         return $return;
     }
     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 (headway_get('mirror-block', $block['settings'], false)) {
             continue;
         }
         //If the block is in the same layout as the current block, then do not allow it to be used as a block to mirror.
         if ($layout_id == headway_post('layout')) {
             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;
         }
         //Get alias if it exists, otherwise use the default name
         $return .= '<option value="' . $block['id'] . '">' . headway_get('alias', $block['settings'], $default_name) . ' &ndash; ' . $layout_name . '</option>';
     }
     return $return;
 }
Beispiel #10
0
 function modify_arguments($args = false)
 {
     $this->tab_notices['widget-area-content'] = 'To add widgets to this widget area, go to <a href="' . admin_url('widgets.php') . '" target="_blank">WordPress Admin &raquo; Appearance &raquo; Widgets</a> and add the widgets to <em>' . HeadwayBlocksData::get_block_name($args['block_id']) . ' &mdash; ' . 'ID: ' . $args['blockID'] . '</em>.';
 }
 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 */
     }
 }
Beispiel #12
0
 function modify_arguments($args = false)
 {
     $this->tab_notices['nav-menu-content'] = 'To add items to this navigation menu, go to <a href="' . admin_url('nav-menus.php') . '" target="_blank">WordPress Admin &raquo; Appearance &raquo; Menus</a>.  Then, create a menu and assign it to <em>' . HeadwayBlocksData::get_block_name($args['blockID']) . '</em> in the <strong>Theme Locations</strong> box.';
 }
    function display_thumbnail($post, $area = 'above-title')
    {
        if (!has_post_thumbnail() || !$this->get_setting('show-post-thumbnails', true) || !apply_filters('headway_featured_image_src', wp_get_attachment_image_src(get_post_thumbnail_id(), 'full'))) {
            return;
        }
        $entry_thumbnail_position = $this->get_setting('use-entry-thumbnail-position', true) ? HeadwayLayoutOption::get($post->ID, 'position', 'post-thumbnail') : false;
        $position = $entry_thumbnail_position ? $entry_thumbnail_position : $this->get_setting('post-thumbnail-position', 'left');
        if ($area == 'above-content' && $position != 'above-content' || $area == 'above-title' && $position == 'above-content') {
            return;
        }
        /* Get the size for cropping */
        if ($position == 'left' || $position == 'right') {
            $thumbnail_width = $this->get_setting('post-thumbnail-size', 125);
            $thumbnail_height = $thumbnail_width;
        } else {
            $thumbnail_width = HeadwayBlocksData::get_block_width($this->block);
            $thumbnail_height = $thumbnail_width * ($this->get_setting('post-thumbnail-height-ratio', 35) * 0.01);
        }
        /* Get the image URL */
        if ($this->get_setting('crop-post-thumbnails', true)) {
            $thumbnail = apply_filters('headway_featured_image_src', wp_get_attachment_image_src(get_post_thumbnail_id(), 'full'));
            $thumbnail_url = apply_filters('headway_featured_image_url', headway_resize_image($thumbnail[0], $thumbnail_width, $thumbnail_height));
        } else {
            $thumbnail = apply_filters('headway_featured_image_src', wp_get_attachment_image_src(get_post_thumbnail_id(), array($thumbnail_width, $thumbnail_height)));
            $thumbnail_url = apply_filters('headway_featured_image_url', $thumbnail[0]);
            $thumbnail_width = $thumbnail[1];
            $thumbnail_height = $thumbnail[2];
        }
        echo '
			<a href="' . get_permalink() . '" class="post-thumbnail post-thumbnail-' . $position . '">
				<img src="' . esc_url($thumbnail_url) . '" alt="' . get_the_title() . '" width="' . $thumbnail_width . '" height="' . $thumbnail_height . '" />
			</a>
		';
    }
Beispiel #14
0
 public static function list_pages($pages = null)
 {
     //Since this function is recursive, we must designate the default like this
     if ($pages === null) {
         $pages = HeadwayLayout::get_pages();
         $root_pages = true;
     }
     $return = '';
     $return .= '<ul>' . "\n";
     /**
      * Only show the message the function is being called for the first time (not showing children) and that the 
      * mode is NOT the grid and the grid is supported still.
      **/
     if (isset($root_pages) && HeadwayVisualEditor::get_current_mode() !== 'grid' && current_theme_supports('headway-grid')) {
         $return .= '<li class="layout-item info-layout-item"><span class="layout"><strong>To add blocks to a new layout, please switch to the Grid mode.</strong></span></li>';
     }
     foreach ($pages as $id => $children) {
         $layout_id_fragments = explode('-', $id);
         $status = HeadwayLayout::get_status($id, true);
         $class = array('layout-item');
         if (is_array($children) && count($children) !== 0 && headway_post('mode') === 'grid') {
             $class[] = 'has-children';
         }
         if ($status['customized'] === true && !$status['template'] && count(HeadwayBlocksData::get_blocks_by_layout($id)) > 0) {
             $class[] = 'layout-item-customized';
         }
         if ($status['template']) {
             $class[] = 'layout-item-template-used';
         }
         if ($id === headway_post('currentLayout')) {
             $class[] = 'layout-selected';
         }
         $template_id = $status['template'] ? 'template-' . $status['template'] : 'none';
         $template_name = $status['template'] ? HeadwayLayout::get_name('template-' . $status['template']) : null;
         /* Take care of layouts that are the front page or blog index */
         if (get_option('show_on_front') === 'page' && (isset($layout_id_fragments[1]) && $layout_id_fragments[1] == 'page') || apply_filters('headway_layout_selector_no_edit_item_' . $id, false)) {
             /* If the page is set as the static homepage or blog page, hide it if they don't have children.  The Blog Index and Front Page layouts will override them. */
             if (end($layout_id_fragments) == get_option('page_on_front') || end($layout_id_fragments) == get_option('page_for_posts') || apply_filters('headway_layout_selector_no_edit_item_' . $id, false)) {
                 /* Layout has children--add the no edit class and has children class. */
                 if (is_array($children) && count($children) !== 0) {
                     $class[] = 'layout-item-no-edit';
                     /* If the layout doesn't have children, then just hide it. */
                 } else {
                     continue;
                 }
             }
         }
         /* Set layouts that aren't customized in the DE to no edit */
         if (headway_post('mode') === 'design') {
             /* Handle layouts that aren't customized or have a template */
             if (headway_get('customized', $status, false) === false || headway_get('template', $status, false) !== false) {
                 /* If there ARE customized children, add the no-edit class */
                 if (is_array($children) && count($children) !== 0) {
                     $show_node = false;
                     //Get the variable ready
                     /* Check if the children are customized. */
                     if (self::is_any_layout_child_customized($children)) {
                         $class[] = 'layout-item-no-edit';
                         $class[] = 'has-children';
                         $class[] = 'has-customized-children';
                         $show_node = true;
                     }
                     /* If the children aren't customized, then don't display it at all */
                     if (!isset($show_node) || !$show_node) {
                         continue;
                     }
                     /* If there aren't any children, do not display the node at all */
                 } else {
                     continue;
                 }
                 /* Handle layouts that are customized */
             }
         }
         /* Add other classes */
         if (is_array($children) && count($children) && self::is_any_layout_child_customized($children)) {
             $class[] = 'has-children';
             $class[] = 'has-customized-children';
         }
         /* Get post status */
         $post_status = headway_get('post_status', $status);
         $formatted_post_status = $post_status && $post_status != 'Published' ? '<span class="status status-post-status">(' . $post_status . ')</span>' : null;
         /* Output Stuff */
         $return .= '<li class="' . implode(' ', array_filter($class)) . '">';
         $return .= '<span class="layout-has-customized-children tooltip" title="This layout has customized children.">&deg;</span>';
         $return .= '<span data-layout-id="' . $id . '" data-layout-url="' . HeadwayLayout::get_url($id) . '" class="layout layout-page">';
         $return .= '<strong>' . htmlspecialchars(HeadwayLayout::get_name($id)) . '</strong>';
         $return .= $formatted_post_status;
         $return .= '<span class="status status-template" data-template-id="' . $template_id . '">' . $template_name . '</span>';
         $return .= '<span class="status status-customized">Customized</span>';
         $return .= '<span class="status status-currently-editing">Currently Editing</span>';
         $return .= '<span class="remove-template layout-selector-button">Remove Template</span>';
         if (HeadwayVisualEditor::get_current_mode() !== 'design') {
             $return .= '<span class="edit layout-selector-button">Edit</span>';
         } else {
             $return .= '<span class="edit layout-selector-button">View</span>';
         }
         $return .= '<span class="revert layout-selector-button tooltip" title="Resetting a layout will remove all of its blocks&lt;br /&gt;so it inherits the blocks of a parent layout.">Reset</span>';
         $return .= '</span>' . "\n";
         if (is_array($children) && count($children) !== 0) {
             $return .= self::list_pages($children);
         }
         $return .= '</li>' . "\n";
     }
     $return .= '</ul>' . "\n";
     return $return;
 }
Beispiel #15
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'];
 }
Beispiel #16
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;
 }
Beispiel #17
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>';
    }
Beispiel #18
0
 public function render_input($input)
 {
     //Fill defaults
     $defaults = array('tooltip' => false, 'default' => false, 'callback' => null);
     //Merge defaults
     $input = array_merge($defaults, $input);
     //Fix up inputs
     $input = $this->parse_function_args($input);
     if (!isset($input['name']) || !isset($input['type'])) {
         return;
     }
     /* Set up main input variables */
     $input['name'] = strtolower($input['name']);
     $input['group'] = isset($input['group']) ? $input['group'] : $this->options_group;
     $input['tooltip'] = isset($input['tooltip']) && $input['tooltip'] != false ? $input['tooltip'] : false;
     /* Populate the value */
     $input['default'] = isset($input['default']) ? $input['default'] : null;
     if (isset($this->wrapper) && $this->wrapper && !isset($input['value'])) {
         $input['value'] = HeadwayWrappers::get_wrapper_setting($this->wrapper, $input['name'], $input['default']);
     } else {
         if (isset($this->block) && $this->block && !isset($input['value'])) {
             $input['value'] = HeadwayBlocksData::get_block_setting($this->block, $input['name'], $input['default']);
         } else {
             if (!isset($input['value'])) {
                 $input['value'] = HeadwayOption::get($input['name'], $input['group'], $input['default']);
             }
         }
     }
     /* Setup Attributes */
     $attributes_array = array('id' => isset($this->block) && $this->block ? 'input-' . $this->block['id'] . '-' . $input['name'] : 'input-' . $input['group'] . '-' . $input['name'], 'name' => $input['name'], 'data-group' => $input['group']);
     /* Set up the callback attribute */
     $attributes_array['data-callback'] = htmlspecialchars('(function(args){var input=args.input;var value=args.value;var block=args.block || null;' . $input['callback'] . '})');
     /* Set up data handler override if it's used */
     if (headway_get('data-handler-callback', $input)) {
         $attributes_array['data-data-handler-callback'] = htmlspecialchars('(function(args){' . $input['data-handler-callback'] . '})');
     }
     /* Set up toggle attribute */
     if (headway_get('toggle', $input)) {
         $attributes_array['data-toggle'] = htmlspecialchars(json_encode($input['toggle']));
     }
     /* No save attribute */
     if (headway_get('no-save', $input, false)) {
         $attributes_array['data-no-save'] = 'true';
     }
     /* Turn attributes array into a string for HTML */
     $input['attributes'] = '';
     foreach ($attributes_array as $attribute => $attribute_value) {
         $input['attributes'] .= $attribute . '="' . $attribute_value . '" ';
     }
     $input['attributes'] = trim($input['attributes']);
     /* If it's a repeater then handle it before it's handled as an input */
     if ($input['type'] == 'repeater') {
         return $this->repeater($input);
     }
     /* Handle regular input */
     if (method_exists($this, 'input_' . str_replace('-', '_', $input['type']))) {
         /* Handle all types except for raw HTML input */
         if ($input['type'] != 'raw-html') {
             echo '<div class="input input-' . $input['type'] . '" id="input-' . $input['name'] . '">';
             if ($input['tooltip']) {
                 echo '<div class="tooltip-button" title="' . htmlspecialchars($input['tooltip']) . '"></div>';
             }
             call_user_func(array($this, 'input_' . str_replace('-', '_', $input['type'])), $input);
             echo '</div><!-- #input-' . $input['name'] . ' -->';
         } else {
             call_user_func(array($this, 'input_' . str_replace('-', '_', $input['type'])), $input);
         }
     }
     /* End regular input handling */
 }
Beispiel #19
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;
 }
Beispiel #20
0
 public static function enqueue_action($block_id)
 {
     $block = HeadwayBlocksData::get_block($block_id);
     return gravity_form_enqueue_scripts(parent::get_setting($block, 'form-id', null), parent::get_setting($block, 'use-ajax', false));
 }
Beispiel #21
0
 /**
  * Use this to enqueue styles or scripts for your block.  This method will be execute when the block type is on 
  * the current page you are viewing.  Also, not only is it page-specific, the method will execute for every instance
  * of that block type on the current page.
  * 
  * This method will be executed at the WordPress 'wp' hook
  *
  * REMOVE THIS METHOD IF NOT USING IT
  **/
 function enqueue_action($block_id)
 {
     $block = HeadwayBlocksData::get_block($block_id);
     return;
 }
Beispiel #22
0
 public static function add_template($template_name = null, $blocks = null, $wrappers = null)
 {
     $templates = HeadwayOption::get('list', 'templates', array());
     $last_template_id = HeadwayOption::get('last-id', 'templates', 0);
     /* These  two variables be used for when a blocks/wrappers imported ID is different than the one that it ends up with... i.g. skin importing to line up instances */
     $block_id_translations = array();
     $wrapper_id_translations = array();
     /* Build name */
     $id = $last_template_id + 1;
     $template_name = $template_name ? $template_name : 'Template ' . $id;
     /* Add template to templates array so it can be sent to DB */
     $templates[$id] = $template_name;
     /* Send array to DB */
     HeadwayOption::set('list', $templates, 'templates');
     HeadwayOption::set('last-id', $id, 'templates');
     /* Add blocks and wrappers */
     if ($blocks && $wrappers) {
         /* Format wrappers */
         foreach ($wrappers as $wrapper_id => $wrapper_settings) {
             $old_wrapper_id = $wrapper_id;
             $new_wrapper = HeadwayWrappers::add_wrapper('template-' . $id, $wrapper_settings);
             $wrapper_id_translations[str_replace('wrapper-', '', $old_wrapper_id)] = array('id' => $new_wrapper['id'], 'layout' => 'template-' . $id);
         }
         /* Add blocks */
         foreach ($blocks as $block) {
             $old_block_id = $block['id'];
             unset($block['id']);
             unset($block['layout']);
             /* Update block's wrapper ID to match the real ID of the imported wrapper because if you link to the old ID from the export file then it won't match up */
             $block['wrapper'] = 'wrapper-' . $wrapper_id_translations[str_replace('wrapper-', '', $block['wrapper'])]['id'];
             $new_block_id = HeadwayBlocksData::add_block('template-' . $id, $block);
             $block_id_translations[$old_block_id] = $new_block_id;
         }
     }
     /* End adding wrappers and blocks */
     return array('id' => $id, 'name' => $template_name, 'block-id-translations' => $block_id_translations, 'wrapper-id-translations' => $wrapper_id_translations);
 }
Beispiel #23
0
    public static function notice_no_widgets_or_menus()
    {
        global $pagenow;
        if ($pagenow != 'widgets.php' && $pagenow != 'nav-menus.php') {
            return false;
        }
        $grid_mode_url = add_query_arg(array('visual-editor' => 'true', 'visual-editor-mode' => 'grid'), home_url());
        //Show the widgets message if no widget blocks exist.
        if ($pagenow == 'widgets.php') {
            $widget_area_blocks = HeadwayBlocksData::get_blocks_by_type('widget-area');
            if (!empty($widget_area_blocks)) {
                return;
            }
            if (!current_theme_supports('headway-grid')) {
                return;
            }
            echo '<div class="updated" style="margin-top: 15px;">
			       <p>Headway has detected that you have no Widget Area blocks.  If you wish to use the WordPress widgets system with Headway, please add a Widget Area block in the <a href="' . $grid_mode_url . '" target="_blank">Visual Editor: Grid</a>.</p>
			
					<style type="text/css">
						div.error.below-h2 { display: none; }
						div.error.below-h2 + p { display: none; }
					</style>
			    </div>';
        }
        //Show the navigation menus message if no navigation blocks exist.
        if ($pagenow == 'nav-menus.php') {
            $navigation_blocks = HeadwayBlocksData::get_blocks_by_type('navigation');
            if (!empty($navigation_blocks)) {
                return;
            }
            if (!current_theme_supports('headway-grid')) {
                return;
            }
            echo '<div class="updated">
			       <p>Headway has detected that you have no Navigation blocks.  If you wish to use the WordPress menus system with Headway, please add a Navigation block in the <a href="' . $grid_mode_url . '" target="_blank">Visual Editor: Grid</a>.</p>
			    </div>';
        }
    }
 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);
 }
Beispiel #25
0
?>
	Page For Posts: 	<?php 
echo get_option('page_for_posts') . "\n";
?>

	<?php 
if (!headway_get('exclude-counts')) {
    ?>
	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";
?>
 public static function secure_method_delete_template()
 {
     //Retreive templates
     $templates = HeadwayOption::get('list', 'templates', array());
     //Unset the deleted ID
     $id = headway_post('template_to_delete');
     //Delete template if it exists and send array back to DB
     if (isset($templates[$id])) {
         unset($templates[$id]);
         //Delete the blocks from the template
         HeadwayBlocksData::delete_by_layout('template-' . $id);
         //Delete all options from the template
         HeadwayLayoutOption::delete_all_from_layout('template-' . $id);
         //Delete template from templates list
         HeadwayOption::set('list', $templates, 'templates');
         do_action('headway_visual_editor_delete_template');
         echo 'success';
     } else {
         echo 'failure';
     }
 }