Ejemplo n.º 1
0
 /**
  * Make any needed modifications to the main query
  * via pre_get_posts for the homepage or frontpage
  *
  * @since 2.3.0
  *
  * @param WP_Query $q Current WP_Query object at the time of pre_get_posts
  */
 public function pre_get_posts($q)
 {
     if (!$q->is_main_query() || !$q->is_home() && !$q->is_page() && !$q->is_archive()) {
         return;
     }
     // Static frontpage
     if ($q->is_page() && get_option('show_on_front') == 'page' && get_option('page_on_front') == $q->get('page_id')) {
         $templates = apply_filters('themeblvd_paginated_templates', array('template_list.php', 'template_list.php', 'template_builder.php'));
         $template = get_post_meta($q->get('page_id'), '_wp_page_template', true);
         if (in_array($template, $templates) && isset($q->query['paged'])) {
             $q->set('paged', $q->query['paged']);
         }
     }
     // Adjust posts_per_page if framework is in grid mode
     if ($q->is_archive() || $this->is_blog($q)) {
         // Check to make sure we're in grid mode
         if (themeblvd_is_grid_mode()) {
             $key = 'archive';
             if ($this->is_blog($q)) {
                 $key = 'index';
             }
             $columns = themeblvd_get_option("{$key}_grid_columns");
             if (!$columns) {
                 $columns = apply_filters('themeblvd_default_grid_columns', 3);
             }
             $rows = themeblvd_get_option("{$key}_grid_rows");
             if (!$rows) {
                 $rows = apply_filters('themeblvd_default_grid_rows', 4);
             }
             // Posts per page = $columns x $rows
             $q->set('posts_per_page', $columns * $rows);
         }
     }
     // Exclude any categories from posts page
     if ($this->is_blog($q)) {
         $cat = '';
         if (themeblvd_is_grid_mode()) {
             $exclude = themeblvd_get_option('grid_categories');
         } else {
             $exclude = themeblvd_get_option('blog_categories');
         }
         if ($exclude) {
             foreach ($exclude as $key => $value) {
                 if ($value) {
                     $cat .= sprintf('-%s,', $key);
                 }
             }
         }
         if ($cat) {
             $cat = themeblvd_remove_trailing_char($cat, ',');
             $q->set('cat', $cat);
         }
     }
     // Apply pagination fix when homepage custom layout
     // set over home "posts page"
     if (defined('TB_BUILDER_PLUGIN_VERSION') && $q->is_home() && 'custom_layout' == themeblvd_get_option('homepage_content')) {
         // Layout info
         $kayout_name = themeblvd_get_option('homepage_custom_layout');
         $layout_post_id = themeblvd_post_id_by_name($kayout_name, 'tb_layout');
         if ($layout_post_id) {
             $elements = get_post_meta($layout_post_id, 'elements', true);
         }
         // Loop through elements and look for that single
         // paginated element (there can only be one in a layout).
         if (!empty($elements) && is_array($elements)) {
             foreach ($elements as $area) {
                 if (!empty($area) && is_array($area)) {
                     foreach ($area as $element) {
                         switch ($element['type']) {
                             case 'post_grid_paginated':
                                 if (!empty($element['options']['rows']) && !empty($element['options']['columns'])) {
                                     $posts_per_page = intval($element['options']['rows']) * intval($element['options']['columns']);
                                 }
                                 $q->set('posts_per_page', $posts_per_page);
                                 break;
                             case 'post_list_paginated':
                                 if (isset($element['options']['source']) && 'query' == $element['options']['source']) {
                                     if (!empty($element['options']['query'])) {
                                         $custom_q = wp_parse_args(htmlspecialchars_decode($element['options']['query']));
                                     }
                                     if (isset($custom_q['posts_per_page'])) {
                                         $q->set('posts_per_page', $custom_q['posts_per_page']);
                                     }
                                 } else {
                                     if (!empty($element['options']['posts_per_page'])) {
                                         $q->set('posts_per_page', $element['options']['posts_per_page']);
                                     }
                                 }
                                 break;
                         }
                     }
                 }
             }
         }
     }
     do_action('themeblvd_pre_get_posts', $q, $this);
 }
/**
 * Conditionals
 *
 * @since 2.2.0
 */
function themeblvd_sanitize_conditionals($input, $sidebar_slug = null, $sidebar_id = null)
{
    $conditionals = themeblvd_conditionals_config();
    $output = array();
    // Prepare items that weren't straight-up arrays
    // gifted on a platter for us.
    if (!empty($input['post'])) {
        $input['post'] = str_replace(' ', '', $input['post']);
        $input['post'] = explode(',', $input['post']);
    }
    if (!empty($input['tag'])) {
        $input['tag'] = str_replace(' ', '', $input['tag']);
        $input['tag'] = explode(',', $input['tag']);
    }
    // Now loop through each group and then each item
    foreach ($input as $type => $group) {
        if (is_array($group) && !empty($group)) {
            foreach ($group as $item_id) {
                $name = '';
                switch ($type) {
                    case 'page':
                        $page_id = themeblvd_post_id_by_name($item_id, 'page');
                        $page = get_page($page_id);
                        if ($page) {
                            $name = $page->post_title;
                        }
                        break;
                    case 'post':
                        $post_id = themeblvd_post_id_by_name($item_id);
                        $post = get_post($post_id);
                        if ($post) {
                            $name = $post->post_title;
                        }
                        break;
                    case 'posts_in_category':
                        $category = get_category_by_slug($item_id);
                        if ($category) {
                            $name = $category->slug;
                        }
                        break;
                    case 'category':
                        $category = get_category_by_slug($item_id);
                        if ($category) {
                            $name = $category->slug;
                        }
                        break;
                    case 'tag':
                        $tag = get_term_by('slug', $item_id, 'post_tag');
                        if ($tag) {
                            $name = $tag->name;
                        }
                        break;
                    case 'top':
                        $name = $conditionals['top']['items'][$item_id];
                        break;
                }
                if ($name) {
                    $output[$type . '_' . $item_id] = array('type' => $type, 'id' => $item_id, 'name' => $name, 'post_slug' => $sidebar_slug, 'post_id' => $sidebar_id);
                }
            }
        }
    }
    // Add in cusotm conditional
    if (!empty($input['custom'])) {
        $output['custom'] = array('type' => 'custom', 'id' => themeblvd_sanitize_text($input['custom']), 'name' => themeblvd_sanitize_text($input['custom']), 'post_slug' => $sidebar_slug, 'post_id' => $sidebar_id);
    }
    return $output;
}
Ejemplo n.º 3
0
 /**
  * Display set of tabs.
  *
  * @since 2.0.0
  *
  * @param array $id unique ID for tab set
  * @param array $options all options for tabs
  * @return string $output HTML output for tabs
  */
 function themeblvd_tabs($id, $options)
 {
     $nav = array('tabs', 'above');
     // Backup for someone updating who doesn't have this saved yet.
     $navigation = '';
     $content = '';
     $output = '';
     // Tabs or pills?
     if (!empty($options['setup']['nav'])) {
         $nav = explode('_', $options['setup']['nav']);
     }
     $nav_type = $nav[0];
     $nav_location = $nav[1];
     // Container classes
     $classes = 'tabbable';
     if ($options['height']) {
         $classes .= ' fixed-height';
     }
     if ($nav_type == 'tabs') {
         $classes .= ' tabs-' . $nav_location;
     }
     $classes .= ' tb-tabs-' . $options['setup']['style'];
     // Navigation
     $i = 0;
     $class = null;
     $navigation .= '<ul class="nav nav-' . $nav_type . '">';
     foreach ($options['setup']['names'] as $key => $name) {
         if ($i == 0) {
             $class = 'active';
         }
         $navigation .= '<li class="' . $class . '"><a href="#' . $id . '-' . $key . '" data-toggle="' . str_replace('s', '', $nav_type) . '" title="' . stripslashes($name) . '">' . stripslashes($name) . '</a></li>';
         $class = null;
         $i++;
     }
     $navigation .= '</ul>';
     // Tab content
     $i = 0;
     $content = '<div class="tab-content">';
     foreach ($options['setup']['names'] as $key => $name) {
         $class = '';
         if ($i == '0') {
             $class = ' active';
         }
         $content .= '<div id="' . $id . '-' . $key . '" class="tab-pane fade' . $class . ' in clearfix">';
         switch ($options[$key]['type']) {
             // External Page
             case 'page':
                 // Get WP internal ID for the page
                 $page_id = themeblvd_post_id_by_name($options[$key]['page'], 'page');
                 // Use WP_Query to retrieve external page. We do it
                 // this way to allow certain primary query-dependent
                 // items such as galleries to work properly.
                 $the_query = new WP_Query('page_id=' . $page_id);
                 // Standard WP loop, even though there should only be
                 // a single post (i.e. our external page).
                 while ($the_query->have_posts()) {
                     $the_query->the_post();
                     $content .= apply_filters('themeblvd_the_content', get_the_content());
                 }
                 // Reset Post Data
                 wp_reset_postdata();
                 break;
                 // Raw content textarea
             // Raw content textarea
             case 'raw':
                 // Only negate simulated the_content filter if the option exists AND it's
                 // been unchecked. This is for legacy purposes, as this feature
                 // was added in v2.1.0
                 if (isset($options[$key]['raw_format']) && !$options[$key]['raw_format']) {
                     $content .= do_shortcode(stripslashes($options[$key]['raw']));
                     // Shortcodes only
                 } else {
                     $content .= apply_filters('themeblvd_the_content', stripslashes($options[$key]['raw']));
                 }
                 break;
                 // Floating Widget Area
             // Floating Widget Area
             case 'widget':
                 if (!empty($options[$key]['sidebar'])) {
                     $content .= '<div class="widget-area">';
                     ob_start();
                     dynamic_sidebar($options[$key]['sidebar']);
                     $content .= ob_get_clean();
                     $content .= '</div><!-- .widget-area (end) -->';
                 }
                 break;
         }
         $content .= '</div><!-- #' . $id . '-' . $key . ' (end) -->';
         $i++;
     }
     $content .= '</div><!-- .tab-content (end) -->';
     // Construct final output
     $output = '<div class="' . $classes . '">';
     if ($nav_location != 'below') {
         $output .= $navigation;
     }
     $output .= $content;
     if ($nav_location == 'below') {
         $output .= $navigation;
     }
     $output .= '</div><!-- .tabbable (end) -->';
     return $output;
 }
    /**
     * Builds out the meta box to edit a page's custom layout.
     *
     * @since 1.1.0
     */
    public function meta_box()
    {
        global $post;
        $current_layout = get_post_meta($post->ID, '_tb_custom_layout', true);
        ?>
		<div id="builder_blvd">
			<div id="optionsframework" class="tb-options-js">

				<!-- HEADER (start) -->

				<div class="meta-box-nav">
					<div class="select-layout">
						<div class="ajax-overlay"></div>
						<div class="icon-holder">
							<span class="tb-loader ajax-loading"></span>
							<i class="tb-icon-commercial-building"></i>
						</div>
						<?php 
        echo $this->layout_select($current_layout);
        ?>
						<span class="note"><?php 
        _e('Select a custom layout.', 'themeblvd_builder');
        ?>
</span>
					</div>
					<ul>
						<li><a href="#edit_layout"><?php 
        _e('Edit Layout', 'themeblvd_builder');
        ?>
</a></li>
						<li><a href="#add_layout"><?php 
        _e('Add New', 'themeblvd_builder');
        ?>
</a></li>
					</ul>
					<div class="clear"></div>
				</div><!-- .meta-box-nav (end) -->

				<!-- HEADER (end) -->

				<!-- EDIT LAYOUT (start) -->

				<div id="edit_layout" class="group">
					<?php 
        $edit_nonce = wp_create_nonce('themeblvd_save_builder');
        echo '<input type="hidden" name="_tb_save_builder_nonce" value="' . $edit_nonce . '" />';
        ?>
					<div class="ajax-mitt">
						<?php 
        $this->mini_edit_layout(themeblvd_post_id_by_name($current_layout, 'tb_layout'));
        ?>
					</div><!-- .ajax-mitt (end) -->
				</div><!-- #edit_layout (end) -->

				<!-- EDIT LAYOUT (end) -->

				<!-- ADD LAYOUT (start) -->

				<div id="add_layout" class="group">
					<?php 
        $add_nonce = wp_create_nonce('themeblvd_new_builder');
        echo '<input type="hidden" name="_tb_new_builder_nonce" value="' . $add_nonce . '" />';
        $this->add_layout(null);
        ?>
				</div><!-- #manage (end) -->

				<!-- ADD LAYOUT (end) -->

			</div><!-- #optionsframework (end) -->
		</div><!-- #builder_blvd (end) -->
		<?php 
    }
 /**
  * Set primary configuration array.
  *
  * @since 2.3.0
  */
 public function set_config()
 {
     global $post;
     $this->config = array('id' => 0, 'builder' => false, 'builder_post_id' => 0, 'sidebar_layout' => '', 'featured' => array(), 'featured_below' => array(), 'sidebars' => array());
     /*------------------------------------------------------*/
     /* Primary Post ID
     		/*------------------------------------------------------*/
     // Store the ID of the original $post object in case
     // we modify the main query or need to ever access it.
     if (is_object($post)) {
         $this->config['id'] = $post->ID;
     }
     /*------------------------------------------------------*/
     /* Custom Layout, Builder Name/ID
     		/*------------------------------------------------------*/
     if (defined('TB_BUILDER_PLUGIN_VERSION')) {
         $layout_name = '';
         // Custom Layout on static page
         if (is_page_template('template_builder.php')) {
             if (post_password_required() || 'private' == get_post_status() && !current_user_can('edit_posts')) {
                 // Password is currently required and so
                 // the custom layout doesn't get used.
                 $layout_name = 'wp-private';
             } else {
                 $layout_name = get_post_meta($this->config['id'], '_tb_custom_layout', true);
                 if (!$layout_name) {
                     $layout_name = 'error';
                 }
             }
         }
         // Custom Layout over home "posts page"
         if (is_home() && get_option('show_on_front') == 'posts') {
             if ('custom_layout' == themeblvd_get_option('homepage_content')) {
                 $layout_name = themeblvd_get_option('homepage_custom_layout');
                 if (!$layout_name) {
                     $layout_name = 'error';
                 }
             }
         }
         // Set name, which can also be "error" or "wp-private"
         $this->config['builder'] = $layout_name;
         // If we have a layout name, setup it's ID and sidebar layout
         if ($layout_name && $layout_name != 'error' && $layout_name != 'wp-private') {
             // Set ID
             $this->config['builder_post_id'] = themeblvd_post_id_by_name($layout_name, 'tb_layout');
             // Sidebar layout
             $layout_settings = get_post_meta($this->config['builder_post_id'], 'settings', true);
             $this->config['sidebar_layout'] = $layout_settings['sidebar_layout'];
         }
     }
     /*------------------------------------------------------*/
     /* Featured Area
     		/*------------------------------------------------------*/
     // For the featured area above or below the content to be
     // enabled, it must contain at least one CSS class or else
     // it won't be displayed for the current page.
     if ($this->config['builder'] && $this->config['builder'] != 'error' && $this->config['builder'] != 'wp-private') {
         $elements = get_post_meta($this->config['builder_post_id'], 'elements', true);
         $this->config['featured'] = $this->featured_builder_classes($elements, 'featured');
         $this->config['featured_below'] = $this->featured_builder_classes($elements, 'featured_below');
     }
     if (is_home()) {
         if ('custom_layout' != themeblvd_get_option('homepage_content')) {
             if (themeblvd_get_option('blog_featured') || themeblvd_supports('featured', 'blog')) {
                 $this->config['featured'][] = 'has_blog_featured';
             }
             if (themeblvd_supports('featured_below', 'blog')) {
                 $this->config['featured_below'][] = 'has_blog_featured_below';
             }
         }
     }
     if (is_page_template('template_list.php')) {
         if (themeblvd_get_option('blog_featured') || themeblvd_supports('featured', 'blog')) {
             $this->config['featured'][] = 'has_blog_featured';
         }
         if (themeblvd_supports('featured_below', 'blog')) {
             $this->config['featured_below'][] = 'has_blog_featured_below';
         }
     }
     if (is_page_template('template_grid.php')) {
         if (themeblvd_supports('featured', 'grid')) {
             $this->config['featured'][] = 'has_grid_featured';
         }
         if (themeblvd_supports('featured_below', 'grid')) {
             $this->config['featured_below'][] = 'has_grid_featured_below';
         }
     }
     if (is_archive() || is_search()) {
         if (themeblvd_supports('featured', 'archive')) {
             $this->config['featured'][] = 'has_archive_featured';
         }
         if (themeblvd_supports('featured_below', 'archive')) {
             $this->config['featured_below'][] = 'has_archive_featured_below';
         }
     }
     if (is_page() && !is_page_template('template_builder.php')) {
         if (themeblvd_supports('featured', 'page')) {
             $this->config['featured'][] = 'has_page_featured';
         }
         if (themeblvd_supports('featured_below', 'page')) {
             $this->config['featured_below'][] = 'has_page_featured_below';
         }
     }
     if (is_single()) {
         if (themeblvd_supports('featured', 'single')) {
             $this->config['featured'][] = 'has_single_featured';
         }
         if (themeblvd_supports('featured_below', 'single')) {
             $this->config['featured_below'][] = 'has_single_featured_below';
         }
     }
     /*------------------------------------------------------*/
     /* Sidebar Layout
     		/*------------------------------------------------------*/
     // The sidebar layout is how the left and right sidebar will
     // be displayed on the current page.
     if (!$this->config['sidebar_layout'] && (is_page() || is_single())) {
         $this->config['sidebar_layout'] = get_post_meta($this->config['id'], '_tb_sidebar_layout', true);
     }
     if (!$this->config['sidebar_layout'] || 'default' == $this->config['sidebar_layout']) {
         $this->config['sidebar_layout'] = themeblvd_get_option('sidebar_layout');
     }
     if (!$this->config['sidebar_layout']) {
         $this->config['sidebar_layout'] = apply_filters('themeblvd_default_sidebar_layout', 'sidebar_right', $this->config['sidebar_layout']);
         // Keeping for backwards compatibility, although is redundant with next filter.
     }
     $this->config['sidebar_layout'] = apply_filters('themeblvd_sidebar_layout', $this->config['sidebar_layout']);
     /*------------------------------------------------------*/
     /* Sidebar ID's
     		/*------------------------------------------------------*/
     // Determine which sidebar ID's belong to each sidebar location
     // on the current page. For each location, this will be the
     // framework's cooresponding default sidebar, unless something
     // else is filtered in. -- Note: The Widget Areas plugin filters
     // into this.
     $locations = themeblvd_get_sidebar_locations();
     $custom_sidebars = defined('TB_SIDEBARS_PLUGIN_VERSION') ? get_posts('post_type=tb_sidebar&numberposts=-1') : null;
     $sidebar_overrides = defined('TB_SIDEBARS_PLUGIN_VERSION') ? get_post_meta($this->config['id'], '_tb_sidebars', true) : null;
     foreach ($locations as $location_id => $default_sidebar) {
         // By default, the sidebar ID will match the ID of the
         // current location.
         $sidebar_id = apply_filters('themeblvd_custom_sidebar_id', $location_id, $custom_sidebars, $sidebar_overrides, $this->config['id']);
         // Set current sidebar ID
         $this->config['sidebars'][$location_id]['id'] = $sidebar_id;
         $this->config['sidebars'][$location_id]['error'] = false;
         // Determine sidebar error (i.e. sidebar is empty)
         if (!is_active_sidebar($sidebar_id)) {
             if ($default_sidebar['type'] == 'collapsible') {
                 // Only an error if collapsible sidebar is custom.
                 if ($sidebar_id != $location_id) {
                     $this->config['sidebars'][$location_id]['error'] = true;
                 }
             } else {
                 // Custom or not, we need to tell the user if a
                 // fixed sidebar is empty.
                 $this->config['sidebars'][$location_id]['error'] = true;
             }
         }
     }
     /*------------------------------------------------------*/
     /* Extend
     		/*------------------------------------------------------*/
     $this->config = apply_filters('themeblvd_frontend_config', $this->config);
 }
 /**
  * Edit a layout from a meta box on
  * Edit Page screen.
  *
  * @since 1.1.0
  */
 public function mini_edit_layout()
 {
     // Security
     check_ajax_referer('themeblvd_save_builder', 'security');
     // Send back interface to edit layout
     $layout_id = themeblvd_post_id_by_name($_POST['data'], 'tb_layout');
     $this->admin_page->mini_edit_layout($layout_id);
     die;
 }
/**
 * Filter TB Framework's frontend config.
 *
 * Whenever a page loads, there is global primary config
 * array that gets generated. This sets up many things when
 * determining the structure of every page WP outputs.
 * So, within this array, we want to add a filter that
 * will now modify the following.
 *
 * (1) Current custom layout ID
 * (2) Whether the featured areas show, based on if we found a custom layout
 * (3) What the sidebar layout is, if we found a custom layout
 *
 * @since 1.0.0
 */
function themeblvd_ltp_frontend_config($config)
{
    global $post;
    // If any single post type
    if (is_single()) {
        // Get layout name if its been saved to this post.
        $layout_name = get_post_meta($post->ID, '_tb_custom_layout', true);
        // Only continue if a custom layout was selected
        if ($layout_name) {
            if (post_password_required() || 'private' == get_post_status() && !current_user_can('edit_posts')) {
                // Password is currently required or status
                // is private and this isn't an admin. So the
                // custom layout doesn't get used.
                $layout_name = 'wp-private';
            } else {
                // Get custom layout's settings and elements
                $config['builder_post_id'] = themeblvd_post_id_by_name($layout_name, 'tb_layout');
                // Needed in framework v2.2.1+
                if ($config['builder_post_id'] && version_compare(TB_FRAMEWORK_VERSION, '2.5.0', '<')) {
                    // Setup featured area classes
                    $layout_elements = get_post_meta($config['builder_post_id'], '_tb_builder_elements', true);
                    if (!$layout_elements) {
                        // This shouldn't happen if they're using Layout Builder 2.0+
                        $layout_elements = get_post_meta($config['builder_post_id'], 'elements', true);
                    }
                    if (function_exists('themeblvd_featured_builder_classes')) {
                        // Theme Blvd Framework v2-2.2
                        $config['featured'] = themeblvd_featured_builder_classes($layout_elements, 'featured');
                        $config['featured_below'] = themeblvd_featured_builder_classes($layout_elements, 'featured_below');
                    } else {
                        // Theme Blvd Framework v2.3+
                        $frontent_init = Theme_Blvd_Frontend_Init::get_instance();
                        $config['featured'] = $frontent_init->featured_builder_classes($layout_elements, 'featured');
                        $config['featured_below'] = $frontent_init->featured_builder_classes($layout_elements, 'featured_below');
                    }
                    // Sidebar Layout
                    $layout_settings = get_post_meta($config['builder_post_id'], 'settings', true);
                    $config['sidebar_layout'] = $layout_settings['sidebar_layout'];
                    if ('default' == $config['sidebar_layout']) {
                        $config['sidebar_layout'] = themeblvd_get_option('sidebar_layout', null, apply_filters('themeblvd_default_sidebar_layout', 'sidebar_right'));
                    }
                }
            }
            // Set layout name
            $config['builder'] = $layout_name;
        }
    }
    return $config;
}
Ejemplo n.º 8
0
/**
 * Display custom layout within template_builder.php
 * page template.
 *
 * When each element is displayed, it is done so with
 * an external function. This will allow some elements
 * to be used for other things such as shortcodes.
 * However, even elements that shouldn't have an external
 * function do to allow those elements to be indidivually
 * edited from a child theme.
 *
 * @since 1.0.0
 *
 * @param string $layout_id Post ID for custom layout
 * @param string $location Location of elements, featured or primary
 */
function themeblvd_builder_elements($layout_id, $location)
{
    $api = Theme_Blvd_Builder_API::get_instance();
    // Setup
    $counter = 0;
    $primary_query = false;
    if (!$layout_id) {
        // This should rarely happen. A common scenario might
        // be the user setup a page with a layout, but then
        // deleted the layout after page was already published.
        echo themeblvd_get_local('invalid_layout');
        return;
    }
    // Gather elements and only move forward if we have elements to show.
    $elements = get_post_meta($layout_id, 'elements', true);
    if (!empty($elements) && !empty($elements[$location])) {
        $elements = $elements[$location];
        $num_elements = count($elements);
    } else {
        // If there are no elements in this location,
        // get us out of here!
        return;
    }
    // Loop through elements
    foreach ($elements as $id => $element) {
        // Skip element if its type isn't registered
        if (!$api->is_element($element['type'])) {
            continue;
        }
        // Increase counter
        $counter++;
        // CSS classes for element
        $classes = 'element ' . $location . '-element-' . $counter . ' element-' . $element['type'];
        if ($counter == 1) {
            $classes .= ' first-element';
        }
        if ($num_elements == $counter) {
            $classes .= ' last-element';
        }
        if ($element['type'] == 'slider') {
            if (isset($element['options']['slider_id'])) {
                $slider_id = themeblvd_post_id_by_name($element['options']['slider_id'], 'tb_slider');
                $type = get_post_meta($slider_id, 'type', true);
                $classes .= ' element-slider-' . $type;
            }
        }
        if ($element['type'] == 'paginated_post_lst' || $element['type'] == 'paginated_post_grid') {
            $classes .= $element['type'];
        }
        if (!empty($element['options']['classes'])) {
            $classes .= ' ' . $element['options']['classes'];
        }
        if (isset($element['options']['visibility'])) {
            $classes .= themeblvd_responsive_visibility_class($element['options']['visibility'], true);
        }
        $classes .= themeblvd_get_classes('element_' . $element['type'], true, false, $element['type'], $element['options'], $location);
        // Start ouput
        do_action('themeblvd_element_' . $element['type'] . '_before', $id, $element['options'], $location);
        // Before element: themeblvd_element_{type}_before
        do_action('themeblvd_element_open', $element['type'], $location, $classes);
        do_action('themeblvd_element_' . $element['type'] . '_top', $id, $element['options'], $location);
        // Top of element: themeblvd_element_{type}_top
        echo '<div class="grid-protection">';
        switch ($element['type']) {
            /*------------------------------------------------------*/
            /* Columns
            			/*------------------------------------------------------*/
            case 'columns':
                if (!function_exists('themeblvd_columns')) {
                    _e('Columns element not supported.', 'themeblvd_builder');
                    break;
                }
                $i = 1;
                $columns = array();
                $num = $element['options']['setup']['num'];
                while ($i <= $num) {
                    $columns[] = $element['options']['col_' . $i];
                    $i++;
                }
                themeblvd_columns($num, $element['options']['setup']['width'][$num], $columns);
                break;
                /*------------------------------------------------------*/
                /* Content
                			/*------------------------------------------------------*/
            /*------------------------------------------------------*/
            /* Content
            			/*------------------------------------------------------*/
            case 'content':
                if (!function_exists('themeblvd_content')) {
                    _e('Content element not supported.', 'themeblvd_builder');
                    break;
                }
                echo themeblvd_content($element['options']);
                break;
                /*------------------------------------------------------*/
                /* Divider
                			/*------------------------------------------------------*/
            /*------------------------------------------------------*/
            /* Divider
            			/*------------------------------------------------------*/
            case 'divider':
                if (!function_exists('themeblvd_divider')) {
                    _e('Divider element not supported.', 'themeblvd_builder');
                    break;
                }
                echo themeblvd_divider($element['options']['type']);
                break;
                /*------------------------------------------------------*/
                /* Headline
                			/*------------------------------------------------------*/
            /*------------------------------------------------------*/
            /* Headline
            			/*------------------------------------------------------*/
            case 'headline':
                if (!function_exists('themeblvd_headline')) {
                    _e('Headline element not supported.', 'themeblvd_builder');
                    break;
                }
                echo themeblvd_headline($element['options']);
                break;
                /*------------------------------------------------------*/
                /* Jumbotron
                			/*------------------------------------------------------*/
            /*------------------------------------------------------*/
            /* Jumbotron
            			/*------------------------------------------------------*/
            case 'jumbotron':
                if (!function_exists('themeblvd_jumbotron')) {
                    _e('Jumbotron element not supported.', 'themeblvd_builder');
                    break;
                }
                themeblvd_jumbotron($element['options']);
                break;
                /*------------------------------------------------------*/
                /* Post Grid
                			/*------------------------------------------------------*/
            /*------------------------------------------------------*/
            /* Post Grid
            			/*------------------------------------------------------*/
            case 'post_grid':
                if (!function_exists('themeblvd_posts')) {
                    _e('Post Grid element not supported.', 'themeblvd_builder');
                    break;
                }
                themeblvd_posts($element['options'], 'grid', $location, 'secondary');
                break;
                /*------------------------------------------------------*/
                /* Post Grid (paginated)
                			/*------------------------------------------------------*/
            /*------------------------------------------------------*/
            /* Post Grid (paginated)
            			/*------------------------------------------------------*/
            case 'post_grid_paginated':
                if (!function_exists('themeblvd_posts_paginated')) {
                    _e('Paginated Post Grid element not supported.', 'themeblvd_builder');
                    break;
                }
                if (!$primary_query) {
                    themeblvd_posts_paginated($element['options'], 'grid', $location);
                    $primary_query = true;
                }
                break;
                /*------------------------------------------------------*/
                /* Post Grid Slider
                			/*------------------------------------------------------*/
            /*------------------------------------------------------*/
            /* Post Grid Slider
            			/*------------------------------------------------------*/
            case 'post_grid_slider':
                if (!function_exists('themeblvd_post_slider')) {
                    _e('Post Grid Slider element not supported.', 'themeblvd_builder');
                    break;
                }
                themeblvd_post_slider($id, $element['options'], 'grid', $location);
                break;
                /*------------------------------------------------------*/
                /* Post List
                			/*------------------------------------------------------*/
            /*------------------------------------------------------*/
            /* Post List
            			/*------------------------------------------------------*/
            case 'post_list':
                if (!function_exists('themeblvd_posts')) {
                    _e('Post List element not supported.', 'themeblvd_builder');
                    break;
                }
                themeblvd_posts($element['options'], 'list', $location, 'secondary');
                break;
                /*------------------------------------------------------*/
                /* Post List (paginated)
                			/*------------------------------------------------------*/
            /*------------------------------------------------------*/
            /* Post List (paginated)
            			/*------------------------------------------------------*/
            case 'post_list_paginated':
                if (!function_exists('themeblvd_posts_paginated')) {
                    _e('Paginated Post List element not supported.', 'themeblvd_builder');
                    break;
                }
                if (!$primary_query) {
                    themeblvd_posts_paginated($element['options'], 'list', $location);
                    $primary_query = true;
                }
                break;
                /*------------------------------------------------------*/
                /* Post List Slider
                			/*------------------------------------------------------*/
            /*------------------------------------------------------*/
            /* Post List Slider
            			/*------------------------------------------------------*/
            case 'post_list_slider':
                if (!function_exists('themeblvd_post_slider')) {
                    _e('Post List Slider element not supported.', 'themeblvd_builder');
                    break;
                }
                themeblvd_post_slider($id, $element['options'], 'list', $location);
                break;
                /*------------------------------------------------------*/
                /* Post Slider (mimics standard slider)
                			/*------------------------------------------------------*/
            /*------------------------------------------------------*/
            /* Post Slider (mimics standard slider)
            			/*------------------------------------------------------*/
            case 'post_slider':
                if (!function_exists('themeblvd_slider_auto')) {
                    _e('Post Slider element not supported.', 'themeblvd_builder');
                    break;
                }
                themeblvd_slider_auto($id, $element['options']);
                break;
                /*------------------------------------------------------*/
                /* Slider
                			/*------------------------------------------------------*/
            /*------------------------------------------------------*/
            /* Slider
            			/*------------------------------------------------------*/
            case 'slider':
                if (!function_exists('themeblvd_slider')) {
                    _e('Slider element not supported.', 'themeblvd_builder');
                    break;
                }
                themeblvd_slider($element['options']['slider_id']);
                break;
                /*------------------------------------------------------*/
                /* Slogan
                			/*------------------------------------------------------*/
            /*------------------------------------------------------*/
            /* Slogan
            			/*------------------------------------------------------*/
            case 'slogan':
                if (!function_exists('themeblvd_slogan')) {
                    _e('Slogan element not supported.', 'themeblvd_builder');
                    break;
                }
                echo themeblvd_slogan($element['options']);
                break;
                /*------------------------------------------------------*/
                /* Tabs
                			/*------------------------------------------------------*/
            /*------------------------------------------------------*/
            /* Tabs
            			/*------------------------------------------------------*/
            case 'tabs':
                if (!function_exists('themeblvd_tabs')) {
                    _e('Tabs element not supported.', 'themeblvd_builder');
                    break;
                }
                echo themeblvd_tabs($id, $element['options']);
                break;
        }
        // End switch
        // Allow to add on custom element that's
        // not in the framework
        do_action('themeblvd_' . $element['type'], $id, $element['options'], $location);
        // End output
        echo '<div class="clear"></div>';
        echo '</div><!-- .grid-protection (end) -->';
        do_action('themeblvd_element_' . $element['type'] . '_bottom', $id, $element['options'], $location);
        // Bottom of element: themeblvd_element_{type}_bottom
        do_action('themeblvd_element_close', $element['type'], $location, $classes);
        do_action('themeblvd_element_' . $element['type'] . '_after', $id, $element['options'], $location);
        // Below element: themeblvd_element_{type}_bottom
    }
    // End foreach
}
Ejemplo n.º 9
0
/**
 * Custom slider
 *
 * @since 1.0.0
 *
 * @param array $atts Standard WordPress shortcode attributes
 */
function themeblvd_shortcode_slider($atts)
{
    $default = array('id' => '');
    extract(shortcode_atts($default, $atts));
    // CSS classes for element
    $slider_id = themeblvd_post_id_by_name($id, 'tb_slider');
    $type = get_post_meta($slider_id, 'type', true);
    $classes = 'element element-slider element-slider-' . $type . themeblvd_get_classes('element_slider', true);
    // Output
    ob_start();
    echo '<div class="' . $classes . '">';
    echo '<div class="element-inner">';
    echo '<div class="element-inner-wrap">';
    echo '<div class="grid-protection">';
    themeblvd_slider($id);
    echo '</div><!-- .grid-protection (end) -->';
    echo '</div><!-- .element-inner-wrap (end) -->';
    echo '</div><!-- .element-inner (end) -->';
    echo '</div><!-- .element (end) -->';
    return ob_get_clean();
}