function slideshow_block_register()
{
    if (!class_exists('Headway')) {
        return;
    }
    require_once 'block.php';
    require_once 'block-options.php';
    return headway_register_block('HeadwaySlideshowBlock', plugins_url(false, __FILE__));
}
function example_block_register()
{
    /* Make sure that Headway is activated, otherwise don't register the block because errors will be thrown. */
    if (!class_exists('Headway')) {
        return;
    }
    require_once 'block.php';
    require_once 'block-options.php';
    /**
     * @param Class name in block.php.  
     * @param Path to the folder that contains the block icons.  In this example block it's this plugin's folder.
     **/
    return headway_register_block('HeadwayExampleBlock', plugins_url(false, __FILE__));
}
Example #3
0
<?php

headway_register_block('HeadwayTextBlock', headway_url() . '/library/blocks/text');
class HeadwayTextBlock extends HeadwayBlockAPI
{
    public $id = 'text';
    public $name = 'Text';
    public $options_class = 'HeadwayTextBlockOptions';
    public $description = 'Use the built-in rich text editor to insert titles, text, and more!';
    function content($block)
    {
        $content = parent::get_setting($block, 'content');
        echo '<div class="entry-content">';
        if ($content != null) {
            echo do_shortcode(stripslashes($content));
        } else {
            echo '<p>There is no content to display.</p>';
        }
        echo '</div><!-- .entry-content -->';
    }
    function setup_elements()
    {
        $this->register_block_element(array('id' => 'text', 'name' => 'Text', 'selector' => '.entry-content', 'properties' => array('fonts', 'padding', 'text-shadow'), 'inherit-location' => 'default-text'));
        $this->register_block_element(array('id' => 'hyperlinks', 'name' => 'Hyperlinks', 'selector' => '.entry-content a', 'properties' => array('fonts', 'text-shadow'), 'inherit-location' => 'default-text', 'states' => array('Hover' => '.entry-content a:hover', 'Clicked' => '.entry-content a:active')));
        $this->register_block_element(array('id' => 'heading', 'name' => 'Heading <small>&lt;H3&gt;, &lt;H2&gt;, &lt;H1&gt;</small>', 'selector' => '.entry-content h3, div.entry-content h2, div.entry-content h1', 'inherit-location' => 'default-heading'));
        $this->register_block_element(array('id' => 'sub-heading', 'name' => 'Sub Heading <small>&lt;H4&gt;</small>', 'selector' => '.entry-content h4', 'inherit-location' => 'default-sub-heading'));
    }
}
class HeadwayTextBlockOptions extends HeadwayBlockOptionsAPI
{
    public $tabs = array('content' => 'Content');
Example #4
0
<?php

if (isset($GLOBALS['SlideDeckPlugin']) && is_object($GLOBALS['SlideDeckPlugin'])) {
    headway_register_block('HeadwaySlideDeckBlock', headway_url() . '/library/blocks/slidedeck');
}
class HeadwaySlideDeckBlock extends HeadwayBlockAPI
{
    public $id = 'slidedeck';
    public $name = 'SlideDeck 2';
    public $options_class = 'HeadwaySlideDeckBlockOptions';
    public $description = 'Conveniently add SlideDecks anywhere on any layout.';
    /* This will be shown in the block type selector */
    /** 
     * 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);
Example #5
0
<?php

headway_register_block('HeadwayCustomCodeBlock', headway_url() . '/library/blocks/custom-code');
class HeadwayCustomCodeBlock extends HeadwayBlockAPI
{
    public $id = 'custom-code';
    public $name = 'Custom Code';
    public $options_class = 'HeadwayCustomCodeBlockOptions';
    public $description = 'Place in custom HTML, PHP, or even WordPress shortcodes into this block.';
    function content($block)
    {
        $content = parent::get_setting($block, 'content');
        if ($content != null) {
            echo headway_parse_php(do_shortcode(stripslashes($content)));
        } else {
            echo '<p>There is no custom code to display.</p>';
        }
    }
}
class HeadwayCustomCodeBlockOptions extends HeadwayBlockOptionsAPI
{
    public $tabs = array('content' => 'Content');
    public $inputs = array('content' => array('content' => array('type' => 'textarea', 'name' => 'content', 'label' => 'Content', 'default' => null)));
}
Example #6
0
<?php

headway_register_block('HeadwayWidgetAreaBlock', headway_url() . '/library/blocks/widget-area');
class HeadwayWidgetAreaBlock extends HeadwayBlockAPI
{
    public $id = 'widget-area';
    public $name = 'Widget Area';
    public $options_class = 'HeadwayWidgetAreaBlockOptions';
    public $html_tag = 'aside';
    public $description = 'Used typically as a sidebar or to aid the footer.  The widget area will display WordPress widgets which are managed in the WordPress Appearance &raquo; Widgets panel.';
    protected $show_content_in_grid = true;
    public static function init_action($block_id, $block)
    {
        $widget_area_name = HeadwayBlocksData::get_block_name($block) . ' &mdash; ' . 'Layout: ' . HeadwayLayout::get_name($block['layout']);
        $widget_area = array('name' => $widget_area_name, 'id' => 'widget-area-' . $block['id'], 'before_widget' => '<li id="%1$s" class="widget %2$s">' . "\n", 'after_widget' => '</li><!-- .widget -->' . "\n", 'before_title' => '<span class="widget-title">', 'after_title' => '</span>' . "\n");
        register_sidebar($widget_area);
    }
    function setup_elements()
    {
        $this->register_block_element(array('id' => 'widget', 'name' => 'Widget', 'selector' => 'li.widget'));
        $this->register_block_element(array('id' => 'widget-title', 'name' => 'Widget Title', 'selector' => 'li.widget span.widget-title', 'inherit-location' => 'default-heading'));
        $this->register_block_element(array('id' => 'widget-links', 'name' => 'Widget Links', 'selector' => 'li.widget a', 'states' => array('Selected' => 'ul li.current_page_item a', 'Hover' => 'ul li a:hover', 'Clicked' => 'ul li a:active'), 'inherit-location' => 'default-hyperlink'));
        $this->register_block_element(array('id' => 'widget-lists', 'name' => 'Widget Lists <small>&lt;UL&gt;</small>', 'selector' => 'li.widget ul', 'properties' => array('fonts', 'lists', 'background', 'borders', 'padding', 'rounded-corners', 'box-shadow', 'text-shadow')));
        $this->register_block_element(array('id' => 'widget-list-items', 'name' => 'Widget List Items <small>&lt;LI&gt;</small>', 'selector' => 'li.widget ul li'));
    }
    function content($block)
    {
        echo parent::get_setting($block, 'horizontal-widgets') == true ? '<ul class="widget-area horizontal-sidebar">' : '<ul class="widget-area">';
        if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('widget-area-' . $block['id'])) {
            echo '<li class="widget widget-no-widgets">';
            echo '<span class="widget-title">No widgets!</span>';
Example #7
0
<?php

headway_register_block('HeadwayFooterBlock', headway_url() . '/library/blocks/footer');
class HeadwayFooterBlock extends HeadwayBlockAPI
{
    public $id = 'footer';
    public $name = 'Footer';
    public $options_class = 'HeadwayFooterBlockOptions';
    public $html_tag = 'footer';
    public $description = 'This typically goes at the bottom of your site and will display the copyright, and miscellaneous links.';
    public $allow_titles = false;
    protected $show_content_in_grid = true;
    function setup_elements()
    {
        $this->register_block_element(array('id' => 'copyright', 'name' => 'Copyright', 'selector' => 'p.copyright', 'properties' => array('fonts', 'text-shadow'), 'inherit-location' => 'default-text'));
        $this->register_block_element(array('id' => 'headway-attribution', 'name' => 'Headway Attribution', 'selector' => 'p.footer-headway-link', 'properties' => array('fonts', 'text-shadow'), 'inherit-location' => 'default-text'));
        $this->register_block_element(array('id' => 'administration-panel', 'name' => 'Administration Panel', 'selector' => 'a.footer-admin-link', 'properties' => array('fonts', 'text-shadow'), 'inherit-location' => 'default-text'));
        $this->register_block_element(array('id' => 'go-to-top', 'name' => 'Go To Top Link', 'selector' => 'a.footer-go-to-top-link', 'inherit-location' => 'default-text'));
        $this->register_block_element(array('id' => 'responsive-grid-link', 'name' => 'Responsive Grid Toggle Link', 'selector' => 'a.footer-responsive-grid-link', 'properties' => array('fonts', 'text-shadow'), 'inherit-location' => 'default-text'));
    }
    function content($block)
    {
        //Add action for footer
        do_action('headway_before_footer');
        echo "\n" . '<div class="footer-container">' . "\n";
        echo "\n" . '<div class="footer">' . "\n";
        do_action('headway_footer_open');
        //Headway Attribution
        if (parent::get_setting($block, 'hide-headway-attribution', false) == false) {
            self::show_headway_link();
        }
Example #8
0
<?php

headway_register_block('HeadwayNavigationBlock', headway_url() . '/library/blocks/navigation');
class HeadwayNavigationBlock extends HeadwayBlockAPI
{
    public $id = 'navigation';
    public $name = 'Navigation';
    public $options_class = 'HeadwayNavigationBlockOptions';
    public $fixed_height = false;
    public $html_tag = 'nav';
    public $description = 'The navigation is the menu that will display all of the pages in your site.';
    protected $show_content_in_grid = true;
    /* Use this to pass the block from static function to static function */
    public static $block = null;
    private static $menu_sub_check_cache = array();
    public static function init_action($block_id, $block = false)
    {
        if (!$block) {
            $block = HeadwayBlocksData::get_block($block_id);
        }
        $name = HeadwayBlocksData::get_block_name($block) . ' &mdash; ' . 'Layout: ' . HeadwayLayout::get_name($block['layout']);
        register_nav_menu('navigation_block_' . $block_id, $name);
        wp_register_script('jquery-hoverintent', headway_url() . '/library/media/js/jquery.hoverintent.js', array('jquery'));
    }
    public static function enqueue_action($block_id, $block, $original_block = null)
    {
        $dependencies = array();
        /* Handle sub menus with super fish */
        if (self::does_menu_have_subs('navigation_block_' . $block_id)) {
            $dependencies[] = 'jquery';
            if (parent::get_setting($block_id, 'hover-intent', true)) {
Example #9
0
<?php

headway_register_block('HeadwayHeaderBlock', headway_url() . '/library/blocks/header');
class HeadwayHeaderBlock extends HeadwayBlockAPI
{
    public $id = 'header';
    public $name = 'Header';
    public $options_class = 'HeadwayHeaderBlockOptions';
    public $fixed_height = true;
    public $html_tag = 'header';
    public $description = 'Display your banner, logo, or site title and tagline.  This typically goes at the top of your website.';
    public $allow_titles = false;
    protected $show_content_in_grid = true;
    function setup_elements()
    {
        $this->register_block_element(array('id' => 'site-title', 'name' => 'Site Title', 'selector' => 'span.banner a', 'inherit-location' => 'default-heading', 'states' => array('Hover' => 'span.banner a:hover', 'Clicked' => 'span.banner a:active')));
        $this->register_block_element(array('id' => 'site-tagline', 'name' => 'Site Tagline', 'selector' => '.tagline', 'inherit-location' => 'default-sub-heading'));
    }
    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>';
Example #10
0
<?php

headway_register_block('HeadwayEmbedBlock', headway_url() . '/library/blocks/embed');
class HeadwayEmbedBlock extends HeadwayBlockAPI
{
    public $id = 'embed';
    public $name = 'Embed';
    public $options_class = 'HeadwayEmbedBlockOptions';
    public $fixed_height = true;
    public $description = 'The Embed block allows you to embed YouTube, Vimeo, or any other popular oEmbed supported service.';
    function init()
    {
        add_filter('oembed_result', array(__CLASS__, 'add_embed_wmode_transparent'));
        add_filter('oembed_result', array(__CLASS__, 'add_iframe_wmode_transparent'));
    }
    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>';
        }
    }
    /**
     * Added to fix the issue of Flash appearing over drop down menus.
     **/
Example #11
0
<?php

//Check that Gravity Forms is even enabled
if (class_exists('RGForms')) {
    headway_register_block('HeadwayGravityFormsBlock', headway_url() . '/library/blocks/gravity-forms');
}
class HeadwayGravityFormsBlock extends HeadwayBlockAPI
{
    public $id = 'gravity-forms';
    public $name = 'Gravity Forms';
    public $options_class = 'HeadwayGravityFormsBlockOptions';
    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));
    }
    function content($block)
    {
        $form_id = parent::get_setting($block, 'form-id', null);
        //If no form ID is present, display the message and stop this function.
        if (!$form_id) {
            echo '<p>There is no form to display.</p>';
            return;
        }
        $display_title = parent::get_setting($block, 'display-title', true);
        $display_description = parent::get_setting($block, 'display-description', true);
        $force_display = true;
        $field_values = null;
        $use_ajax = parent::get_setting($block, 'use-ajax', false);
        echo RGForms::get_form($form_id, $display_title, $display_description, $force_display, null, $use_ajax);
    }
Example #12
0
<?php

headway_register_block('HeadwayContentBlock', headway_url() . '/library/blocks/content');
class HeadwayContentBlock extends HeadwayBlockAPI
{
    public $id = 'content';
    public $name = 'Content';
    public $options_class = 'HeadwayContentBlockOptions';
    public $description = 'Main content area to show the current page\'s content or the latest posts.  This is considered the "Loop" in other themes.';
    protected $show_content_in_grid = true;
    function init()
    {
        /* Load dependencies */
        require_once HEADWAY_LIBRARY_DIR . '/blocks/content/content-display.php';
        /* Set up the comments template */
        add_filter('comments_template', array(__CLASS__, 'add_blank_comments_template'));
        /* Set up editor style */
        add_filter('mce_css', array(__CLASS__, 'add_editor_style'));
        /* Add .comment class to all pingbacks */
        add_filter('comment_class', array(__CLASS__, 'add_comment_class_to_all_types'));
    }
    public static function add_blank_comments_template()
    {
        return HEADWAY_LIBRARY_DIR . '/blocks/content/comments-template.php';
    }
    public static function add_comment_class_to_all_types($classes)
    {
        if (!is_array($classes)) {
            $classes = implode(' ', trim($classes));
        }
        $classes[] = 'comment';
Example #13
0
<?php

headway_register_block('HeadwayBreadcrumbsBlock', headway_url() . '/library/blocks/breadcrumbs');
class HeadwayBreadcrumbsBlock extends HeadwayBlockAPI
{
    public $id = 'breadcrumbs';
    public $name = 'Breadcrumbs';
    public $fixed_height = true;
    public $description = 'Breadcrumbs aid in the navigation of your site by showing a visual hierarchy of where your visitor is.<br /><strong>Example:</strong> Home &raquo; Blog &raquo; Sample Blog Post';
    public $options_class = 'HeadwayBreadcrumbsBlockOptions';
    protected $show_content_in_grid = true;
    function setup_elements()
    {
        $this->register_block_element(array('id' => 'text', 'name' => 'Text', 'selector' => 'p', 'inherit-location' => 'default-text'));
        $this->register_block_element(array('id' => 'hyperlinks', 'name' => 'Hyperlinks', 'selector' => 'p a', 'inherit-location' => 'default-hyperlink'));
        $this->register_block_element(array('id' => 'separators', 'name' => 'Separators', 'selector' => 'span.sep'));
    }
    function content($block)
    {
        /* If Yoast's breadcrumbs are activated then use them instead */
        if (function_exists('yoast_breadcrumb')) {
            return yoast_breadcrumb('<p class="breadcrumbs yoastbreadcrumb">', '</p>');
        }
        wp_reset_query();
        /* Set up variables */
        global $post;
        $breadcrumbs = array();
        $breadcrumbs[home_url()] = __('Home', 'headway');
        /* Handle blogs that aren't set to the homepage */
        if (get_option('show_on_front') == 'page' && get_option('page_for_posts') !== get_option('page_on_front')) {
            /* If the blog is set to a page rather than homepage, then don't show that fragment if it's a 404, search, or non-post singular */