Making WordPress.org

Ticket #1070: rosetta_dynamic_sidebar.patch

File rosetta_dynamic_sidebar.patch, 2.3 KB (added by ramiy, 10 years ago)
  • functions.php

     
    3232}
    3333add_action( 'after_setup_theme', 'rosetta_after_setup_theme' );
    3434
     35
    3536/**
     37 * Set the sidebar widget aries
     38 */
     39function rosetta_sidebars() {
     40
     41        // Blog
     42        $args = array(
     43                'id'            => 'blog_sidebar_widget',
     44                'name'          => __( 'Blog sidebar widget', 'rosetta' ),
     45                'description'   => __( 'Add widgets here to appear in blog sidebar.', 'rosetta' ),
     46                'before_widget' => '<div id="%1$s" class="widget %2$s">',
     47                'after_widget'  => '</div>',
     48                'before_title'  => '<h4 class="widget-title">',
     49                'after_title'   => '</h4>'
     50        );
     51        register_sidebar( $args );
     52
     53        // Pages
     54        $args = array(
     55                'id'            => 'pages_sidebar_widget',
     56                'name'          => __( 'Pages sidebar widget', 'rosetta' ),
     57                'description'   => __( 'Add widgets here to appear in pages sidebar.', 'rosetta' ),
     58                'before_widget' => '<div id="%1$s" class="widget %2$s">',
     59                'after_widget'  => '</div>',
     60                'before_title'  => '<h3 class="widget-title">',
     61                'after_title'   => '</h3>'
     62        );
     63        register_sidebar( $args );
     64
     65}
     66add_action( 'widgets_init', 'rosetta_sidebars' );
     67
     68/**
    3669 * Prints a hint, which explains that that support questions belong
    3770 * to the forums, on top of the comment form.
    3871 */
  • sidebar-blog.php

     
    77<ul>
    88        <?php wp_get_archives( 'type=monthly&limit=12' ); ?>
    99</ul>
     10
     11<?php
     12if ( is_active_sidebar( 'blog_sidebar_widget' ) ) {
     13        dynamic_sidebar( 'blog_sidebar_widget' );
     14}
     15?>
  • sidebar-page.php

     
    3434endif;
    3535?>
    3636
     37<?php
     38if ( is_active_sidebar( 'pages_sidebar_widget' ) ) {
     39        dynamic_sidebar( 'pages_sidebar_widget' );
     40} else {
     41?>
    3742<h3><?php _e( 'Resources', 'rosetta' ); ?></h3>
    38 
    3943<p><?php _e( 'For help with installing or using WordPress, consult our documentation in your language.', 'rosetta' ); ?></p>
    40 
    4144<ul>
    4245        <?php wp_list_bookmarks( 'categorize=0&category_before=&category_after=&title_li=&' ); ?>
    4346</ul>
     47<?php
     48}
     49?>