/** * 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 */ }
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 */ } }
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'))); } }
/** * 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>'); } }
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; }
/** * 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; }