Exemplo n.º 1
0
/**
 * Setup JavaScript localized strings for
 * themeblvd.js
 *
 * The filter "themeblvd_js_locals"
 * can be used to add/remove strings or other
 * variables we want to pass through to our primary
 * "themeblvd" script.
 *
 * @since 2.2.0
 */
function themeblvd_get_js_locals()
{
    // Start $locals array with any miscellaneous stuff
    $locals = array('thumb_animations' => 'true', 'featured_animations' => 'true', 'image_slide_animations' => 'true', 'retina_logo' => 'true');
    // Extend $locals to accomodate scripts being included
    // through our "themeblvd_global_config" filter.
    // This allows people to remove jQuery plugin files
    // w/out having to also remove functions from themeblvd.js.
    if (themeblvd_supports('assets', 'bootstrap')) {
        $locals['bootstrap'] = 'true';
    }
    // Magnific Popup Lightbox integration
    if (themeblvd_supports('assets', 'magnific_popup')) {
        $locals['magnific_popup'] = 'true';
        // Magnific Popup animation
        $locals['lightbox_animation'] = themeblvd_get_option('lightbox_animation');
        // Disable standard lightbox on mobile?
        if ('yes' == themeblvd_get_option('lightbox_mobile')) {
            $locals['lightbox_mobile'] = '768';
        } else {
            $locals['lightbox_mobile'] = '0';
        }
        // Disable iframe lightboxes (i.e. video, google maps) on mobile?
        if ('yes' == themeblvd_get_option('lightbox_mobile_iframe')) {
            $locals['lightbox_mobile_iframe'] = '768';
        } else {
            $locals['lightbox_mobile_iframe'] = '0';
        }
        // Disable gallery lightboxes on mobile?
        if ('yes' == themeblvd_get_option('lightbox_mobile_gallery')) {
            $locals['lightbox_mobile_gallery'] = '768';
        } else {
            $locals['lightbox_mobile_gallery'] = '0';
        }
        // Text strings
        $locals['lightbox_error'] = themeblvd_get_local('lightbox_error');
        $locals['lightbox_close'] = themeblvd_get_local('close');
        $locals['lightbox_loading'] = themeblvd_get_local('loading');
        $locals['lightbox_counter'] = themeblvd_get_local('lightbox_counter');
        $locals['lightbox_next'] = themeblvd_get_local('next');
        $locals['lightbox_previous'] = themeblvd_get_local('previous');
    }
    // Superfish for drop down menus
    if (themeblvd_supports('assets', 'superfish')) {
        $locals['superfish'] = 'true';
    }
    // Return with framework's filter applied
    return apply_filters('themeblvd_js_locals', $locals);
}
Exemplo n.º 2
0
 /**
  * Contact button bar
  *
  * @since 2.0.0
  *
  * @param array $buttons icons to use - array( 'twitter' => 'http://twitter.com/whatever', 'facebook' => 'http://facebook.com/whatever' )
  * @param string $style Style of buttons - dark, grey, light, color
  */
 function themeblvd_contact_bar($buttons = array(), $style = null)
 {
     // Set up buttons
     if (!$buttons) {
         $buttons = themeblvd_get_option('social_media');
     }
     // If buttons haven't been sanitized return nothing
     if (is_array($buttons) && isset($buttons['includes'])) {
         return null;
     }
     // Set up style
     if (!$style) {
         $style = themeblvd_get_option('social_media_style', null, 'grey');
     }
     // Social media sources
     $sources = themeblvd_get_social_media_sources();
     // Start output
     $output = null;
     if (is_array($buttons) && !empty($buttons)) {
         $output = '<div class="themeblvd-contact-bar">';
         $output .= '<ul class="social-media-' . $style . '">';
         foreach ($buttons as $id => $url) {
             // Link target
             $target = '_blank';
             if (strpos($url, 'mailto:') !== false) {
                 $target = '_self';
             }
             // Link Title
             $title = '';
             if (isset($sources[$id])) {
                 $title = $sources[$id];
             }
             $output .= sprintf('<li><a href="%s" title="%s" class="%s" target="%s">%s</a></li>', $url, $title, $id, $target, $title);
         }
         $output .= '</ul>';
         $output .= '<div class="clear"></div>';
         $output .= '</div><!-- .themeblvd-contact-bar (end) -->';
     }
     return apply_filters('themeblvd_contact_bar', $output);
 }
Exemplo n.º 3
0
    /**
     * Font Prep for customizer preview
     *
     * Since the Javascript for fonts will get repeated in
     * many themes, its being placed here so it can be easily
     * placed in each theme that requires it.
     *
     * This function sets up some objects we can use throughout
     * all of our font options.
     *
     * @since 2.1.0
     */
    function themeblvd_customizer_preview_font_prep()
    {
        // Global option name
        $option_name = themeblvd_get_option_name();
        // Setup font stacks
        $font_stacks = themeblvd_font_stacks();
        unset($font_stacks['google']);
        // Determine current google fonts with fake
        // booleans to be used in printed JS object.
        $types = array('body', 'header', 'special');
        $google_fonts = array();
        foreach ($types as $type) {
            $font = themeblvd_get_option('typography_' . $type);
            $google_fonts[$type . 'Name'] = !empty($font['google']) && $font['google'] ? $font['google'] : '';
            $google_fonts[$type . 'Toggle'] = !empty($font['face']) && $font['face'] == 'google' ? 'true' : 'false';
        }
        ?>
	// Font stacks
	fontStacks = <?php 
        echo json_encode($font_stacks);
        ?>
;

	// Google font toggles
	googleFonts = <?php 
        echo json_encode($google_fonts);
        ?>
;
	<?php 
    }
Exemplo n.º 4
0
 /**
  * If this is the home posts page; this will return
  * false if the framework has swapped it out for a
  * homepage layout from theme options. Checks against
  * current WP_Query object at pre_get_posts.
  *
  * @since 2.3.0
  *
  * @param WP_Query $q Current WP_Query object being worked with
  * @return bool
  */
 private function is_blog($q)
 {
     if (!$q->is_home()) {
         return false;
     }
     if (themeblvd_get_option('homepage_content') == 'posts') {
         return true;
     }
     if (get_option('show_on_front') == 'page' && get_option('page_for_posts')) {
         return true;
     }
     return false;
     // Shouldn't get this far
 }
Exemplo n.º 5
0
/**
 * Get thumbnail size based on passed in size and/or
 * framework options.
 *
 * @since 2.3.0
 *
 * @param $size string Optional current size of image
 * @param $location string Optional location for thumbnail
 * @param $sidebar_layout string Optional current sidebar layout
 * @return $size Size after it's been formatted
 */
function themeblvd_get_thumbnail_size($size = '', $location = 'primary', $sidebar_layout = 'full_width')
{
    // If no $size was passed in, we'll use the framework's options
    // to determine one for different scenarios.
    if (!$size) {
        if (themeblvd_was('home') || themeblvd_was('page_template', 'template_list.php')) {
            // "Primary Posts Display" (i.e. homepage or post list template)
            $size = themeblvd_get_option('blog_thumbs');
        } else {
            if (themeblvd_was('search') || themeblvd_was('archive')) {
                // Search results and archives
                $size = themeblvd_get_option('archive_thumbs');
            } else {
                if (themeblvd_was('single')) {
                    // Single posts. First check for overrding meta value, then
                    // move to default option from theme options page.
                    $size_meta = get_post_meta(get_the_ID(), '_tb_thumb', true);
                    if ($size_meta == 'full' || $size_meta == 'small' || $size_meta == 'hide') {
                        $size = $size_meta;
                    } else {
                        $size = themeblvd_get_option('single_thumbs');
                    }
                }
            }
        }
    }
    if ($size == 'hide') {
        $size = null;
    }
    if ($size == 'full') {
        $location == 'featured' || $sidebar_layout == 'full_width' ? $size = 'tb_large' : ($size = 'tb_medium');
    }
    if ($size == 'small') {
        $size = 'tb_small';
    }
    return apply_filters('themeblvd_get_thumbnail_size', $size, $location, $sidebar_layout);
}
Exemplo n.º 6
0
 /**
  * Display paginated post list or post grid
  *
  * @since 2.0.0
  *
  * @param array $options all options for posts
  * @param string $type Type of posts, grid or list
  * @param string $current_location Current location of element, featured or primary
  */
 function themeblvd_posts_paginated($args = array(), $type = 'list', $current_location = 'primary')
 {
     global $more;
     // Current location if relevant
     $location = themeblvd_set_att('location', $current_location);
     // Setup and extract $args
     $defaults = array('source' => '', 'categories' => array('all' => 1), 'tag' => '', 'thumbs' => 'default', 'content' => 'default', 'columns' => '3', 'rows' => '3', 'posts_per_page' => '6', 'orderby' => 'date', 'order' => 'DESC', 'offset' => '0', 'query' => '', 'crop' => '');
     $args = wp_parse_args($args, $defaults);
     extract($args, EXTR_OVERWRITE);
     // Config before query string
     if ($type == 'grid') {
         $columns = themeblvd_set_att('columns', $columns);
         $posts_per_page = $rows ? $columns * $rows : '-1';
         $args['posts_per_page'] = $posts_per_page;
         // Set new value to $args for parsing query
         $size = themeblvd_set_att('size', themeblvd_grid_class($columns));
         $crop = !empty($crop) ? $crop : $size;
         $crop = themeblvd_set_att('crop', $crop);
     } else {
         $posts_per_page = themeblvd_set_att('posts_per_page', $posts_per_page);
         $content = $content == 'default' ? themeblvd_get_option('blog_content', null, 'content') : $content;
         $content = themeblvd_set_att('content', $content);
         $size = $thumbs == 'default' ? themeblvd_get_option('blog_thumbs', null, 'small') : $thumbs;
         $size = themeblvd_set_att('size', $size);
     }
     /*------------------------------------------------------*/
     /* Query Args
     	/*------------------------------------------------------*/
     // Set the second query in global $themeblvd_query.
     // We only do this for paginated queries.
     $query_args = themeblvd_set_second_query($args, $type);
     // Sets global var and gets for local var
     // Apply filters
     $query_args = apply_filters('themeblvd_posts_args', $query_args, $args, $type, $current_location);
     /*------------------------------------------------------*/
     /* The Loop
     	/*------------------------------------------------------*/
     // Query posts
     $posts = new WP_Query($query_args);
     // Start output
     echo '<div class="post_' . $type . '">';
     if ($posts->have_posts()) {
         do_action('themeblvd_post_' . $type . '_paginated_before_loop', $args);
         if ($type == 'grid') {
             // Loop for post grid
             $counter = themeblvd_set_att('counter', 1);
             while ($posts->have_posts()) {
                 $posts->the_post();
                 $more = 0;
                 // If this is the very first post, open the first row
                 if ($counter == 1) {
                     themeblvd_open_row();
                 }
                 // Get template part, framework default is content-grid.php
                 get_template_part('content', themeblvd_get_part('grid_paginated'));
                 // If last post in a row, close the row
                 if ($counter % $columns == 0) {
                     themeblvd_close_row();
                 }
                 // If first post in a row, open the row
                 if ($counter % $columns == 0 && $posts_per_page != $counter) {
                     themeblvd_open_row();
                 }
                 // Increment the counter with global template attribute accounted for
                 $counter = themeblvd_set_att('counter', $counter + 1);
             }
             // In case the last row wasn't filled, close it now
             if ($counter - 1 != $posts_per_page) {
                 themeblvd_close_row();
             }
         } else {
             // Loop for post list
             while ($posts->have_posts()) {
                 $posts->the_post();
                 $more = 0;
                 // Get template part, framework default is content-list.php
                 get_template_part('content', themeblvd_get_part('list_paginated'));
             }
         }
         do_action('themeblvd_post_' . $type . '_paginated_after_loop', $args);
     } else {
         // No posts to display
         printf('<p>%s</p>', themeblvd_get_local('archive_no_posts'));
     }
     // Pagination
     themeblvd_pagination($posts->max_num_pages);
     echo '</div><!-- .post_' . $type . ' (end) -->';
     // Reset Post Data
     wp_reset_postdata();
 }
 /**
  * Generate default template attributes for post grid pages.
  *
  * @since 2.3.0
  *
  * @return array $atts Default template attributes for post list page
  */
 private function get_default_grid_atts()
 {
     global $post;
     // Columns and rows
     $columns = '';
     $rows = '';
     if (is_home()) {
         $columns = themeblvd_get_option('index_grid_columns');
         $rows = themeblvd_get_option('index_grid_rows');
     } elseif (is_archive() || is_search()) {
         $columns = themeblvd_get_option('archive_grid_columns');
         $rows = themeblvd_get_option('archive_grid_rows');
     } elseif (is_page_template('template_grid.php')) {
         $possible_column_nums = array(1, 2, 3, 4, 5);
         $custom_columns = get_post_meta($this->config['id'], 'columns', true);
         if (in_array(intval($custom_columns), $possible_column_nums)) {
             $columns = $custom_columns;
         }
         $rows = get_post_meta($this->config['id'], 'rows', true);
     }
     if (!$columns) {
         $columns = apply_filters('themeblvd_default_grid_columns', 3);
     }
     if (!$rows) {
         $rows = apply_filters('themeblvd_default_grid_rows', 4);
     }
     // Posts per page, used for the grid display and not
     // the actual main query of posts.
     $posts_per_page = intval($columns) * intval($rows);
     // Thumbnail size
     $size = themeblvd_grid_class($columns);
     if (is_home()) {
         $crop = apply_filters('themeblvd_index_grid_crop_size', $size);
     } elseif (is_archive() || is_search()) {
         $crop = apply_filters('themeblvd_archive_grid_crop_size', $size);
     } elseif (is_page_template('template_grid.php')) {
         $crop = get_post_meta($this->config['id'], 'crop', true);
         if (!$crop) {
             $crop = apply_filters('themeblvd_template_grid_crop_size', $size);
         }
     }
     if (empty($crop)) {
         $crop = $size;
     }
     // Setup attributes
     $atts = array('columns' => $columns, 'rows' => $rows, 'posts_per_page' => $posts_per_page, 'counter' => 0, 'size' => $size, 'crop' => $crop);
     return apply_filters('themeblvd_grid_atts', $atts);
 }
Exemplo n.º 8
0
/**
 * Determine if breadcrumbs should show or not.
 *
 * @since 2.2.1
 *
 * @return boolean $show Whether breadcrumbs should show or not
 */
function themeblvd_show_breadcrumbs()
{
    global $post;
    $display = '';
    // Pages and Posts
    if (is_page() || is_single()) {
        $display = get_post_meta($post->ID, '_tb_breadcrumbs', true);
    }
    // Standard site-wide option
    if (!$display || $display == 'default') {
        $display = themeblvd_get_option('breadcrumbs', null, 'show');
    }
    // Disable on posts homepage
    if (is_home()) {
        $display = 'hide';
    }
    // Convert to boolean
    $show = false;
    if ($display == 'show') {
        $show = true;
    }
    return apply_filters('themeblvd_show_breadcrumbs', $show, $display);
}
/**
 * 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;
}
Exemplo n.º 10
0
/**
 * Redirect homepage to index.php to the custom
 * layout template if option is set. This is
 * filtered to template_include.
 *
 * @since 1.0.1
 */
function themeblvd_builder_homepage($template)
{
    // If this is the homepage (but NOT the "posts page")
    // and the user has selected to show a custom layout,
    // redirect index.php to template_builder.php
    if (is_home() && 'posts' == get_option('show_on_front') && 'custom_layout' == themeblvd_get_option('homepage_content', null, 'posts')) {
        $template = locate_template('template_builder.php');
    }
    return $template;
}
Exemplo n.º 11
0
 /**
  * Default display for action: themeblvd_content_top
  *
  * @since 2.1.0
  */
 function themeblvd_content_top_default()
 {
     if (is_archive()) {
         if (themeblvd_get_option('archive_title', null, 'false') != 'false') {
             echo '<div class="element element-headline primary-entry-title">';
             echo '<h1 class="entry-title">';
             themeblvd_archive_title();
             echo '</h1>';
             echo '</div><!-- .element (end) -->';
         }
     }
     if (is_page_template('template_list.php') || is_page_template('template_grid.php')) {
         global $post;
         if ('hide' != get_post_meta($post->ID, '_tb_title', true)) {
             echo '<div class="element element-headline primary-entry-title">';
             echo '<h1 class="entry-title">';
             the_title();
             echo '</h1>';
             echo '</div><!-- .element (end) -->';
         }
         the_content();
     }
 }