Example #1
0
/**
 * Register our sidebars and other widget areas
 *
 * @todo move the taxonomy landing page sidebar registration here
 *  (currently in inc/wp-taxonomy-landing/functions/cftl-admin.php)
 * @since 0.3
 */
function largo_register_sidebars()
{
    $sidebars = array(array('name' => __('Main Sidebar', 'largo'), 'desc' => __('The sidebar for the homepage. If you do not add widgets to any of the other sidebars, this will also be used on all of the other pages of your site.', 'largo'), 'id' => 'sidebar-main'), array('name' => __('Single Sidebar', 'largo'), 'desc' => __('The sidebar for posts and pages', 'largo'), 'id' => 'sidebar-single'), array('name' => __('Article Bottom', 'largo'), 'desc' => __('Footer widget area for posts', 'largo'), 'id' => 'article-bottom'), array('name' => __('Homepage Alert', 'largo'), 'desc' => __('Region atop homepage reserved for breaking news and announcements', 'largo'), 'id' => 'homepage-alert'), array('name' => __('Footer 1', 'largo'), 'desc' => __('The first footer widget area.', 'largo'), 'id' => 'footer-1'));
    if (of_get_option('footer_layout') !== '1col') {
        $sidebars[] = array('name' => __('Footer 2', 'largo'), 'desc' => __('The second footer widget area.', 'largo'), 'id' => 'footer-2');
        $sidebars[] = array('name' => __('Footer 3', 'largo'), 'desc' => __('The third footer widget area.', 'largo'), 'id' => 'footer-3');
    }
    if (of_get_option('footer_layout') == '4col' || of_get_option('footer_layout') == '4col-asymm') {
        $sidebars[] = array('name' => __('Footer 4', 'largo'), 'desc' => __('The fourth footer widget area.', 'largo'), 'id' => 'footer-4');
    }
    if (of_get_option('use_topic_sidebar')) {
        $sidebars[] = array('name' => __('Archive/Topic Sidebar', 'largo'), 'desc' => __('The sidebar for category, tag and other archive pages', 'largo'), 'id' => 'topic-sidebar');
    }
    if (of_get_option('use_before_footer_sidebar')) {
        $sidebars[] = array('name' => __('Before Footer', 'largo'), 'desc' => __('Full-width area immediately above footer', 'largo'), 'id' => 'before-footer');
    }
    if (of_get_option('homepage_bottom') == 'widgets') {
        $sidebars[] = array('name' => __('Homepage Bottom', 'largo'), 'desc' => __('An optional widget area at the bottom of the homepage', 'largo'), 'id' => 'homepage-bottom');
    }
    if (of_get_option('leaderboard_enabled')) {
        $sidebars[] = array('name' => __('Header Ad Zone', 'largo'), 'desc' => __('An optional leaderboard (728x90) ad zone above the main site header', 'largo'), 'id' => 'header-ads');
    }
    // user-defined custom widget areas
    $custom_sidebars = preg_split('/$\\R?^/m', of_get_option('custom_sidebars'));
    if (is_array($custom_sidebars)) {
        foreach ($custom_sidebars as $sidebar) {
            $sidebar_slug = largo_make_slug($sidebar);
            if ($sidebar_slug) {
                $sidebars[] = array('name' => __($sidebar, 'largo'), 'desc' => '', 'id' => $sidebar_slug);
            }
        }
    }
    // register the active widget areas
    foreach ($sidebars as $sidebar) {
        register_sidebar(array('name' => $sidebar['name'], 'description' => $sidebar['desc'], 'id' => $sidebar['id'], 'before_widget' => '<aside id="%1$s" class="%2$s clearfix">', 'after_widget' => "</aside>", 'before_title' => '<h3 class="widgettitle">', 'after_title' => '</h3>'));
    }
}
Example #2
0
 public function registerSidebars()
 {
     foreach ($this->sidebars as $sidebar) {
         preg_match('|^(.*?)(\\((.*)\\))?$|', trim($sidebar), $sb);
         register_sidebar(array('name' => trim($sb[1]), 'id' => largo_make_slug(trim($sb[1])), 'description' => isset($sb[3]) ? trim($sb[3]) : __('Auto-generated by current homepage template'), 'before_widget' => '<aside id="%1$s" class="%2$s clearfix">', 'after_widget' => "</aside>", 'before_title' => '<h3 class="widgettitle">', 'after_title' => '</h3>'));
     }
 }
Example #3
0
/**
 * Instantiate all our necessary widget regions
 */
function cftl_custom_sidebars()
{
    //get all the footer ones and the titles they connect to
    $footer_widgets = cftl_get_meta_values('footer_style', 'widget');
    foreach ($footer_widgets as $widget) {
        $sidebar_slug = largo_make_slug($widget->post_title);
        if ($sidebar_slug) {
            register_sidebar(array('name' => __('Series ' . $widget->post_title . ": Footer", 'largo'), 'id' => $sidebar_slug . "_footer", 'before_widget' => '<aside id="%1$s" class="%2$s clearfix">', 'after_widget' => '</aside>', 'before_title' => '<h3 class="widgettitle">', 'after_title' => '</h3>'));
        }
    }
}