/**
  * Creates or returns an instance of this class.
  *
  * @since 2.3.0
  *
  * @return Theme_Blvd_Frontend_Init A single instance of this class.
  */
 public static function get_instance()
 {
     if (self::$instance == null) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Example #2
0
/**
 * Retrieve a single attribute set with
 * themeblvd_set_atts()
 *
 * @since 2.2.0
 *
 * @param string $key Key in $atts array to retrieve
 * @return mixed Value of attribute
 */
function themeblvd_get_att($key)
{
    $config = Theme_Blvd_Frontend_Init::get_instance();
    return $config->get_att($key);
}
/**
 * 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;
}