Plugin Directory

Changeset 431162


Ignore:
Timestamp:
08/31/2011 10:37:14 AM (15 years ago)
Author:
bechster
Message:

Fixes an issue: Optionally display widgets on the home page, whether it is set up to be a static page or the blog posts page.

Location:
flexible-widgets/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • flexible-widgets/trunk/flexible-widgets.php

    r423639 r431162  
    44Plugin URI: http://www.netsans.dk/flexible-widgets-for-wordpress.html
    55Description: This plugin lets you display a widget on any category or page you wish. When setting up the widget, you are able to select the categories and/or pages where you want to display the widget. If none are selected, the widget will be displayed globally on your site, exactly like a default WordPress widget. 
    6 Version: 0.2
     6Version: 0.3
    77Author: Morten Brunbjerg Bech
    88Author URI: http://www.netsans.dk/about/
     
    2828        $sortby = empty( $instance['sortby'] ) ? 'menu_order' : $instance['sortby'];
    2929        $exclude = empty( $instance['exclude'] ) ? '' : $instance['exclude'];
     30        $blogpage = $instance['blogpage'] ? '1' : '0';
    3031        $checkCats = $instance['checkCats'];
    3132        $checkPages = $instance['checkPages'];
    32        
     33
    3334        if (
    34         $checkCats !=0 && is_category($checkCats) // ...................... Selected categories only.
    35         || ($checkCats !=0 && is_single() && in_category($checkCats)) // .. Single posts in selected categories only.
    36         || ($checkPages !=0 && is_page($checkPages)) // ................... Selected pages only.
    37         || ($checkCats == 0 && $checkPages == 0 && (is_single()
     35        $blogpage != 0 && is_home() // ----------------------------------- On the blog page only.
     36        || ($checkCats !=0 && is_category($checkCats)) // ---------------- Selected categories only.
     37        || ($checkCats !=0 && is_single() && in_category($checkCats)) // - Single posts in selected categories only.
     38        || ($checkPages !=0 && is_page($checkPages)) // ------------------ Selected pages only.
     39        || ($checkCats == 0 && $checkPages == 0 && $blogpage == 0 &&
     40            (is_single()
    3841            || is_category()
    39             || is_page())) // ............................................. All single posts, pages & categories.
     42            || is_page()
     43            || is_home())) // -------------------------------------------- All single posts, pages & categories.
    4044        ) {
    41 
    4245            if ( $sortby == 'menu_order' )
    4346                $sortby = 'menu_order, post_title';
     
    6972
    7073        $instance['exclude'] = strip_tags( $new_instance['exclude'] );
     74       
     75        $instance['blogpage'] = $new_instance['blogpage'] ? 1 : 0;
    7176        $instance['checkCats'] = $new_instance['checkCats'];
    7277        $instance['checkPages'] = $new_instance['checkPages'];
     
    8085        $title = esc_attr( $instance['title'] );
    8186        $exclude = esc_attr( $instance['exclude'] );
     87       
     88        $blogpage = $instance['blogpage'] ? 'checked="checked"' : '';
    8289        $checkCats = $intance['checkCats'];
    8390        $checkPages = $intance['checkPages'];
     
    142149                    <?php
    143150                    // Above - hidden input: Allows for an empty term set to be sent. 0 is an invalid Term ID and will be ignored by empty() checks.               
    144                     // Solution for saving checkboxes: http://wordpress.org/support/topic/widget-checkbox-group-not-registering?replies=3
     151                    // Solution for saving checkboxes: http://wordpress.org/support/topic/widget-checkbox-group-not-registering?replies=3
     152                    ?>
     153                    <li>
     154                        <input class="checkbox" type="checkbox" <?php echo $blogpage; ?> id="<?php echo $this->get_field_id('blogpage'); ?>" name="<?php echo $this->get_field_name('blogpage'); ?>" /> <label for="<?php echo $this->get_field_id('blogpage'); ?>"><?php _e('The Blog Page'); ?></label>
     155                    </li>
     156                   
     157                    <?php
    145158                    foreach ($pages as $page) {
    146159                    ?>
     
    148161                    <li>                         
    149162                        <label for="<?php $this->get_field_id( 'checkPages' ) .'[]'; ?>"><?php
    150                         $option='<input type="checkbox" id="'. $this->get_field_id( 'checkPages' ) .'[]" name="'. $this->get_field_name( 'checkPages' ) .'[]"';
     163                        $option='<input class="checkbox" type="checkbox" id="'. $this->get_field_id( 'checkPages' ) .'[]" name="'. $this->get_field_name( 'checkPages' ) .'[]"';
    151164                        if (is_array($instance['checkPages'])) {
    152165                            foreach ($instance['checkPages'] as $pages) {
     
    195208        $show_images = isset($instance['images']) ? $instance['images'] : true;
    196209        $category = isset($instance['category']) ? $instance['category'] : false;
     210        $blogpage = $instance['blogpage'] ? '1' : '0';
    197211        $checkCats = $instance['checkCats'];
    198212        $checkPages = $instance['checkPages'];
    199213
    200214        if (
    201         $checkCats !=0 && is_category($checkCats) // ...................... Selected categories only.
    202         || ($checkCats !=0 && is_single() && in_category($checkCats)) // .. Single posts in selected categories only.
    203         || ($checkPages !=0 && is_page($checkPages)) // ................... Selected pages only.
    204         || ($checkCats == 0 && $checkPages == 0 && (is_single()
     215        $blogpage != 0 && is_home() // ----------------------------------- On the blog page only.
     216        || ($checkCats !=0 && is_category($checkCats)) // ---------------- Selected categories only.
     217        || ($checkCats !=0 && is_single() && in_category($checkCats)) // - Single posts in selected categories only.
     218        || ($checkPages !=0 && is_page($checkPages)) // ------------------ Selected pages only.
     219        || ($checkCats == 0 && $checkPages == 0 && $blogpage == 0 &&
     220            (is_single()
    205221            || is_category()
    206             || is_page())) // ............................................. All single posts, pages & categories.
     222            || is_page()
     223            || is_home())) // -------------------------------------------- All single posts, pages & categories.
    207224        ) {
    208225
     
    231248                $instance[$field] = 1;
    232249        }
    233         $instance['category'] = intval($new_instance['category']);
     250        $instance['category'] = intval($new_instance['category']);     
     251        $instance['blogpage'] = $new_instance['blogpage'] ? 1 : 0;
    234252        $instance['checkCats'] = $new_instance['checkCats'];
    235253        $instance['checkPages'] = $new_instance['checkPages'];
     
    243261        $instance = wp_parse_args( (array) $instance, array( 'images' => true, 'name' => true, 'description' => false, 'rating' => false, 'category' => false ) );
    244262        $link_cats = get_terms( 'link_category');
     263        $blogpage = $instance['blogpage'] ? 'checked="checked"' : '';
    245264        $checkCats = $intance['checkCats'];
    246265        $checkPages = $intance['checkPages'];
     
    313332                    <?php
    314333                    // Above - hidden input: Allows for an empty term set to be sent. 0 is an invalid Term ID and will be ignored by empty() checks.               
    315                     // Solution for saving checkboxes: http://wordpress.org/support/topic/widget-checkbox-group-not-registering?replies=3
     334                    // Solution for saving checkboxes: http://wordpress.org/support/topic/widget-checkbox-group-not-registering?replies=3
     335                    ?>
     336                    <li>
     337                        <input class="checkbox" type="checkbox" <?php echo $blogpage; ?> id="<?php echo $this->get_field_id('blogpage'); ?>" name="<?php echo $this->get_field_name('blogpage'); ?>" /> <label for="<?php echo $this->get_field_id('blogpage'); ?>"><?php _e('The Blog Page'); ?></label>
     338                    </li>
     339                   
     340                    <?php
    316341                    foreach ($pages as $page) {
    317342                    ?>
     
    360385        extract($args);
    361386        $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
     387        $blogpage = $instance['blogpage'] ? '1' : '0';
    362388        $checkCats = $instance['checkCats'];
    363         $checkPages = $instance['checkPages'];     
    364        
     389        $checkPages = $instance['checkPages'];
     390
    365391        if (
    366         $checkCats !=0 && is_category($checkCats) // ...................... Selected categories only.
    367         || ($checkCats !=0 && is_single() && in_category($checkCats)) // .. Single posts in selected categories only.
    368         || ($checkPages !=0 && is_page($checkPages)) // ................... Selected pages only.
    369         || ($checkCats == 0 && $checkPages == 0 && (is_single()
     392        $blogpage != 0 && is_home() // ----------------------------------- On the blog page only.
     393        || ($checkCats !=0 && is_category($checkCats)) // ---------------- Selected categories only.
     394        || ($checkCats !=0 && is_single() && in_category($checkCats)) // - Single posts in selected categories only.
     395        || ($checkPages !=0 && is_page($checkPages)) // ------------------ Selected pages only.
     396        || ($checkCats == 0 && $checkPages == 0 && $blogpage == 0 &&
     397            (is_single()
    370398            || is_category()
    371             || is_page())) // ............................................. All single posts, pages & categories.
     399            || is_page()
     400            || is_home())) // -------------------------------------------- All single posts, pages & categories.
    372401        ) {
    373402
     
    386415        $instance = wp_parse_args( (array) $instance, array( 'title' => '') );
    387416        $title = $instance['title'];
     417        $blogpage = $instance['blogpage'] ? 'checked="checked"' : '';
    388418        $checkCats = $intance['checkCats'];
    389419        $checkPages = $intance['checkPages'];
     
    435465                    <?php
    436466                    // Above - hidden input: Allows for an empty term set to be sent. 0 is an invalid Term ID and will be ignored by empty() checks.               
    437                     // Solution for saving checkboxes: http://wordpress.org/support/topic/widget-checkbox-group-not-registering?replies=3
     467                    // Solution for saving checkboxes: http://wordpress.org/support/topic/widget-checkbox-group-not-registering?replies=3
     468                    ?>
     469                    <li>
     470                        <input class="checkbox" type="checkbox" <?php echo $blogpage; ?> id="<?php echo $this->get_field_id('blogpage'); ?>" name="<?php echo $this->get_field_name('blogpage'); ?>" /> <label for="<?php echo $this->get_field_id('blogpage'); ?>"><?php _e('The Blog Page'); ?></label>
     471                    </li>
     472                   
     473                    <?php
    438474                    foreach ($pages as $page) {
    439475                    ?>
     
    468504        $instance = $old_instance;
    469505        $new_instance = wp_parse_args((array) $new_instance, array( 'title' => ''));
    470         $instance['title'] = strip_tags($new_instance['title']);
     506        $instance['title'] = strip_tags($new_instance['title']);   
     507        $instance['blogpage'] = $new_instance['blogpage'] ? 1 : 0;
    471508        $instance['checkCats'] = $new_instance['checkCats'];
    472509        $instance['checkPages'] = $new_instance['checkPages'];
     
    494531        $d = $instance['dropdown'] ? '1' : '0';
    495532        $title = apply_filters('widget_title', empty($instance['title']) ? __('Archives') : $instance['title'], $instance, $this->id_base);
     533        $blogpage = $instance['blogpage'] ? '1' : '0';
    496534        $checkCats = $instance['checkCats'];
    497535        $checkPages = $instance['checkPages'];
    498        
     536
    499537        if (
    500         $checkCats !=0 && is_category($checkCats) // ...................... Selected categories only.
    501         || ($checkCats !=0 && is_single() && in_category($checkCats)) // .. Single posts in selected categories only.
    502         || ($checkPages !=0 && is_page($checkPages)) // ................... Selected pages only.
    503         || ($checkCats == 0 && $checkPages == 0 && (is_single()
     538        $blogpage != 0 && is_home() // ----------------------------------- On the blog page only.
     539        || ($checkCats !=0 && is_category($checkCats)) // ---------------- Selected categories only.
     540        || ($checkCats !=0 && is_single() && in_category($checkCats)) // - Single posts in selected categories only.
     541        || ($checkPages !=0 && is_page($checkPages)) // ------------------ Selected pages only.
     542        || ($checkCats == 0 && $checkPages == 0 && $blogpage == 0 &&
     543            (is_single()
    504544            || is_category()
    505             || is_page())) // ............................................. All single posts, pages & categories.
     545            || is_page()
     546            || is_home())) // -------------------------------------------- All single posts, pages & categories.
    506547        ) {
    507548
     
    531572        $instance['title'] = strip_tags($new_instance['title']);
    532573        $instance['count'] = $new_instance['count'] ? 1 : 0;
    533         $instance['dropdown'] = $new_instance['dropdown'] ? 1 : 0;
     574        $instance['dropdown'] = $new_instance['dropdown'] ? 1 : 0; 
     575        $instance['blogpage'] = $new_instance['blogpage'] ? 1 : 0;
    534576        $instance['checkCats'] = $new_instance['checkCats'];
    535577        $instance['checkPages'] = $new_instance['checkPages'];
     
    543585        $count = $instance['count'] ? 'checked="checked"' : '';
    544586        $dropdown = $instance['dropdown'] ? 'checked="checked"' : '';
     587        $blogpage = $instance['blogpage'] ? 'checked="checked"' : '';
    545588        $checkCats = $intance['checkCats'];
    546589        $checkPages = $intance['checkPages'];
     
    597640                    <?php
    598641                    // Above - hidden input: Allows for an empty term set to be sent. 0 is an invalid Term ID and will be ignored by empty() checks.               
    599                     // Solution for saving checkboxes: http://wordpress.org/support/topic/widget-checkbox-group-not-registering?replies=3
     642                    // Solution for saving checkboxes: http://wordpress.org/support/topic/widget-checkbox-group-not-registering?replies=3
     643                    ?>
     644                    <li>
     645                        <input class="checkbox" type="checkbox" <?php echo $blogpage; ?> id="<?php echo $this->get_field_id('blogpage'); ?>" name="<?php echo $this->get_field_name('blogpage'); ?>" /> <label for="<?php echo $this->get_field_id('blogpage'); ?>"><?php _e('The Blog Page'); ?></label>
     646                    </li>
     647                   
     648                    <?php
    600649                    foreach ($pages as $page) {
    601650                    ?>
     
    646695        extract($args);
    647696        $title = apply_filters('widget_title', empty($instance['title']) ? __('Meta') : $instance['title'], $instance, $this->id_base);
     697        $blogpage = $instance['blogpage'] ? '1' : '0';
    648698        $checkCats = $instance['checkCats'];
    649699        $checkPages = $instance['checkPages'];
    650        
     700
    651701        if (
    652         $checkCats !=0 && is_category($checkCats) // ...................... Selected categories only.
    653         || ($checkCats !=0 && is_single() && in_category($checkCats)) // .. Single posts in selected categories only.
    654         || ($checkPages !=0 && is_page($checkPages)) // ................... Selected pages only.
    655         || ($checkCats == 0 && $checkPages == 0 && (is_single()
     702        $blogpage != 0 && is_home() // ----------------------------------- On the blog page only.
     703        || ($checkCats !=0 && is_category($checkCats)) // ---------------- Selected categories only.
     704        || ($checkCats !=0 && is_single() && in_category($checkCats)) // - Single posts in selected categories only.
     705        || ($checkPages !=0 && is_page($checkPages)) // ------------------ Selected pages only.
     706        || ($checkCats == 0 && $checkPages == 0 && $blogpage == 0 &&
     707            (is_single()
    656708            || is_category()
    657             || is_page())) // ............................................. All single posts, pages & categories.
     709            || is_page()
     710            || is_home())) // -------------------------------------------- All single posts, pages & categories.
    658711        ) {
    659712
     
    677730    function update( $new_instance, $old_instance ) {
    678731        $instance = $old_instance;
    679         $instance['title'] = strip_tags($new_instance['title']);
     732        $instance['title'] = strip_tags($new_instance['title']);   
     733        $instance['blogpage'] = $new_instance['blogpage'] ? 1 : 0;
    680734        $instance['checkCats'] = $new_instance['checkCats'];
    681735        $instance['checkPages'] = $new_instance['checkPages'];
     
    687741        $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
    688742        $title = strip_tags($instance['title']);
     743        $blogpage = $instance['blogpage'] ? 'checked="checked"' : '';
    689744        $checkCats = $intance['checkCats'];
    690745        $checkPages = $intance['checkPages'];
     
    736791                    <?php
    737792                    // Above - hidden input: Allows for an empty term set to be sent. 0 is an invalid Term ID and will be ignored by empty() checks.               
    738                     // Solution for saving checkboxes: http://wordpress.org/support/topic/widget-checkbox-group-not-registering?replies=3
     793                    // Solution for saving checkboxes: http://wordpress.org/support/topic/widget-checkbox-group-not-registering?replies=3
     794                    ?>
     795                    <li>
     796                        <input class="checkbox" type="checkbox" <?php echo $blogpage; ?> id="<?php echo $this->get_field_id('blogpage'); ?>" name="<?php echo $this->get_field_name('blogpage'); ?>" /> <label for="<?php echo $this->get_field_id('blogpage'); ?>"><?php _e('The Blog Page'); ?></label>
     797                    </li>
     798                   
     799                    <?php
    739800                    foreach ($pages as $page) {
    740801                    ?>
     
    783844        extract($args);
    784845        $title = apply_filters('widget_title', empty($instance['title']) ? '&nbsp;' : $instance['title'], $instance, $this->id_base);
     846        $blogpage = $instance['blogpage'] ? '1' : '0';
    785847        $checkCats = $instance['checkCats'];
    786848        $checkPages = $instance['checkPages'];
    787        
     849
    788850        if (
    789         $checkCats !=0 && is_category($checkCats) // ...................... Selected categories only.
    790         || ($checkCats !=0 && is_single() && in_category($checkCats)) // .. Single posts in selected categories only.
    791         || ($checkPages !=0 && is_page($checkPages)) // ................... Selected pages only.
    792         || ($checkCats == 0 && $checkPages == 0 && (is_single()
     851        $blogpage != 0 && is_home() // ----------------------------------- On the blog page only.
     852        || ($checkCats !=0 && is_category($checkCats)) // ---------------- Selected categories only.
     853        || ($checkCats !=0 && is_single() && in_category($checkCats)) // - Single posts in selected categories only.
     854        || ($checkPages !=0 && is_page($checkPages)) // ------------------ Selected pages only.
     855        || ($checkCats == 0 && $checkPages == 0 && $blogpage == 0 &&
     856            (is_single()
    793857            || is_category()
    794             || is_page())) // ............................................. All single posts, pages & categories.
     858            || is_page()
     859            || is_home())) // -------------------------------------------- All single posts, pages & categories.
    795860        ) {
    796861       
     
    807872    function update( $new_instance, $old_instance ) {
    808873        $instance = $old_instance;
    809         $instance['title'] = strip_tags($new_instance['title']);
     874        $instance['title'] = strip_tags($new_instance['title']);   
     875        $instance['blogpage'] = $new_instance['blogpage'] ? 1 : 0;
    810876        $instance['checkCats'] = $new_instance['checkCats'];
    811877        $instance['checkPages'] = $new_instance['checkPages'];
     
    817883        $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
    818884        $title = strip_tags($instance['title']);
     885        $blogpage = $instance['blogpage'] ? 'checked="checked"' : '';
    819886        $checkCats = $intance['checkCats'];
    820887        $checkPages = $intance['checkPages'];
     
    867934                    <?php
    868935                    // Above - hidden input: Allows for an empty term set to be sent. 0 is an invalid Term ID and will be ignored by empty() checks.               
    869                     // Solution for saving checkboxes: http://wordpress.org/support/topic/widget-checkbox-group-not-registering?replies=3
     936                    // Solution for saving checkboxes: http://wordpress.org/support/topic/widget-checkbox-group-not-registering?replies=3
     937                    ?>
     938                    <li>
     939                        <input class="checkbox" type="checkbox" <?php echo $blogpage; ?> id="<?php echo $this->get_field_id('blogpage'); ?>" name="<?php echo $this->get_field_name('blogpage'); ?>" /> <label for="<?php echo $this->get_field_id('blogpage'); ?>"><?php _e('The Blog Page'); ?></label>
     940                    </li>
     941                   
     942                    <?php
    870943                    foreach ($pages as $page) {
    871944                    ?>
     
    915988        $title = apply_filters( 'widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
    916989        $text = apply_filters( 'widget_text', $instance['text'], $instance );
     990        $blogpage = $instance['blogpage'] ? '1' : '0';
    917991        $checkCats = $instance['checkCats'];
    918992        $checkPages = $instance['checkPages'];
    919        
     993
    920994        if (
    921         $checkCats !=0 && is_category($checkCats) // ...................... Selected categories only.
    922         || ($checkCats !=0 && is_single() && in_category($checkCats)) // .. Single posts in selected categories only.
    923         || ($checkPages !=0 && is_page($checkPages)) // ................... Selected pages only.
    924         || ($checkCats == 0 && $checkPages == 0 && (is_single()
     995        $blogpage != 0 && is_home() // ----------------------------------- On the blog page only.
     996        || ($checkCats !=0 && is_category($checkCats)) // ---------------- Selected categories only.
     997        || ($checkCats !=0 && is_single() && in_category($checkCats)) // - Single posts in selected categories only.
     998        || ($checkPages !=0 && is_page($checkPages)) // ------------------ Selected pages only.
     999        || ($checkCats == 0 && $checkPages == 0 && $blogpage == 0 &&
     1000            (is_single()
    9251001            || is_category()
    926             || is_page())) // ............................................. All single posts, pages & categories.
     1002            || is_page()
     1003            || is_home())) // -------------------------------------------- All single posts, pages & categories.
    9271004        ) {
    9281005       
     
    9421019        else
    9431020            $instance['text'] = stripslashes( wp_filter_post_kses( addslashes($new_instance['text']) ) ); // wp_filter_post_kses() expects slashed
    944         $instance['filter'] = isset($new_instance['filter']);
     1021        $instance['filter'] = isset($new_instance['filter']);   
     1022        $instance['blogpage'] = $new_instance['blogpage'] ? 1 : 0;
    9451023        $instance['checkCats'] = $new_instance['checkCats'];
    9461024        $instance['checkPages'] = $new_instance['checkPages'];
     
    9521030        $title = strip_tags($instance['title']);
    9531031        $text = esc_textarea($instance['text']);
     1032        $blogpage = $instance['blogpage'] ? 'checked="checked"' : '';
    9541033        $checkCats = $intance['checkCats'];
    9551034        $checkPages = $intance['checkPages'];
     
    10061085                    <?php
    10071086                    // Above - hidden input: Allows for an empty term set to be sent. 0 is an invalid Term ID and will be ignored by empty() checks.               
    1008                     // Solution for saving checkboxes: http://wordpress.org/support/topic/widget-checkbox-group-not-registering?replies=3
     1087                    // Solution for saving checkboxes: http://wordpress.org/support/topic/widget-checkbox-group-not-registering?replies=3
     1088                    ?>
     1089                    <li>
     1090                        <input class="checkbox" type="checkbox" <?php echo $blogpage; ?> id="<?php echo $this->get_field_id('blogpage'); ?>" name="<?php echo $this->get_field_name('blogpage'); ?>" /> <label for="<?php echo $this->get_field_id('blogpage'); ?>"><?php _e('The Blog Page'); ?></label>
     1091                    </li>
     1092                   
     1093                    <?php
    10091094                    foreach ($pages as $page) {
    10101095                    ?>
     
    10571142        $h = $instance['hierarchical'] ? '1' : '0';
    10581143        $d = $instance['dropdown'] ? '1' : '0';
     1144        $blogpage = $instance['blogpage'] ? '1' : '0';
    10591145        $checkCats = $instance['checkCats'];
    10601146        $checkPages = $instance['checkPages'];
    1061        
     1147
    10621148        if (
    1063         $checkCats !=0 && is_category($checkCats) // ...................... Selected categories only.
    1064         || ($checkCats !=0 && is_single() && in_category($checkCats)) // .. Single posts in selected categories only.
    1065         || ($checkPages !=0 && is_page($checkPages)) // ................... Selected pages only.
    1066         || ($checkCats == 0 && $checkPages == 0 && (is_single()
     1149        $blogpage != 0 && is_home() // ----------------------------------- On the blog page only.
     1150        || ($checkCats !=0 && is_category($checkCats)) // ---------------- Selected categories only.
     1151        || ($checkCats !=0 && is_single() && in_category($checkCats)) // - Single posts in selected categories only.
     1152        || ($checkPages !=0 && is_page($checkPages)) // ------------------ Selected pages only.
     1153        || ($checkCats == 0 && $checkPages == 0 && $blogpage == 0 &&
     1154            (is_single()
    10671155            || is_category()
    1068             || is_page())) // ............................................. All single posts, pages & categories.
     1156            || is_page()
     1157            || is_home())) // -------------------------------------------- All single posts, pages & categories.
    10691158        ) {
    10701159
     
    11131202        $instance['count'] = !empty($new_instance['count']) ? 1 : 0;
    11141203        $instance['hierarchical'] = !empty($new_instance['hierarchical']) ? 1 : 0;
    1115         $instance['dropdown'] = !empty($new_instance['dropdown']) ? 1 : 0;
     1204        $instance['dropdown'] = !empty($new_instance['dropdown']) ? 1 : 0; 
     1205        $instance['blogpage'] = $new_instance['blogpage'] ? 1 : 0;
    11161206        $instance['checkCats'] = $new_instance['checkCats'];
    11171207        $instance['checkPages'] = $new_instance['checkPages'];
     
    11271217        $hierarchical = isset( $instance['hierarchical'] ) ? (bool) $instance['hierarchical'] : false;
    11281218        $dropdown = isset( $instance['dropdown'] ) ? (bool) $instance['dropdown'] : false;
     1219        $blogpage = $instance['blogpage'] ? 'checked="checked"' : '';
    11291220        $checkCats = $intance['checkCats'];
    11301221        $checkPages = $intance['checkPages'];
     
    11861277                    <?php
    11871278                    // Above - hidden input: Allows for an empty term set to be sent. 0 is an invalid Term ID and will be ignored by empty() checks.               
    1188                     // Solution for saving checkboxes: http://wordpress.org/support/topic/widget-checkbox-group-not-registering?replies=3
     1279                    // Solution for saving checkboxes: http://wordpress.org/support/topic/widget-checkbox-group-not-registering?replies=3
     1280                    ?>
     1281                    <li>
     1282                        <input class="checkbox" type="checkbox" <?php echo $blogpage; ?> id="<?php echo $this->get_field_id('blogpage'); ?>" name="<?php echo $this->get_field_name('blogpage'); ?>" /> <label for="<?php echo $this->get_field_id('blogpage'); ?>"><?php _e('The Blog Page'); ?></label>
     1283                    </li>
     1284                   
     1285                    <?php
    11891286                    foreach ($pages as $page) {
    11901287                    ?>
     
    12381335    function widget($args, $instance) {
    12391336        $cache = wp_cache_get('widget_recent_posts', 'widget');
     1337        $blogpage = $instance['blogpage'] ? '1' : '0';
    12401338        $checkCats = $instance['checkCats'];
    12411339        $checkPages = $instance['checkPages'];
     
    12551353        if ( ! $number = absint( $instance['number'] ) )
    12561354            $number = 10;
    1257        
     1355
    12581356        if (
    1259         $checkCats !=0 && is_category($checkCats) // ...................... Selected categories only.
    1260         || ($checkCats !=0 && is_single() && in_category($checkCats)) // .. Single posts in selected categories only.
    1261         || ($checkPages !=0 && is_page($checkPages)) // ................... Selected pages only.
    1262         || ($checkCats == 0 && $checkPages == 0 && (is_single()
     1357        $blogpage != 0 && is_home() // ----------------------------------- On the blog page only.
     1358        || ($checkCats !=0 && is_category($checkCats)) // ---------------- Selected categories only.
     1359        || ($checkCats !=0 && is_single() && in_category($checkCats)) // - Single posts in selected categories only.
     1360        || ($checkPages !=0 && is_page($checkPages)) // ------------------ Selected pages only.
     1361        || ($checkCats == 0 && $checkPages == 0 && $blogpage == 0 &&
     1362            (is_single()
    12631363            || is_category()
    1264             || is_page())) // ............................................. All single posts, pages & categories.
     1364            || is_page()
     1365            || is_home())) // -------------------------------------------- All single posts, pages & categories.
    12651366        ) {
    12661367
     
    12901391        $instance = $old_instance;
    12911392        $instance['title'] = strip_tags($new_instance['title']);
    1292         $instance['number'] = (int) $new_instance['number'];
     1393        $instance['number'] = (int) $new_instance['number'];   
     1394        $instance['blogpage'] = $new_instance['blogpage'] ? 1 : 0;
    12931395        $instance['checkCats'] = $new_instance['checkCats'];
    12941396        $instance['checkPages'] = $new_instance['checkPages'];
     
    13091411        $title = isset($instance['title']) ? esc_attr($instance['title']) : '';
    13101412        $number = isset($instance['number']) ? absint($instance['number']) : 5;
     1413        $blogpage = $instance['blogpage'] ? 'checked="checked"' : '';
    13111414        $checkCats = $intance['checkCats'];
    13121415        $checkPages = $intance['checkPages'];
     
    13621465                    <?php
    13631466                    // Above - hidden input: Allows for an empty term set to be sent. 0 is an invalid Term ID and will be ignored by empty() checks.               
    1364                     // Solution for saving checkboxes: http://wordpress.org/support/topic/widget-checkbox-group-not-registering?replies=3
     1467                    // Solution for saving checkboxes: http://wordpress.org/support/topic/widget-checkbox-group-not-registering?replies=3
     1468                    ?>
     1469                    <li>
     1470                        <input class="checkbox" type="checkbox" <?php echo $blogpage; ?> id="<?php echo $this->get_field_id('blogpage'); ?>" name="<?php echo $this->get_field_name('blogpage'); ?>" /> <label for="<?php echo $this->get_field_id('blogpage'); ?>"><?php _e('The Blog Page'); ?></label>
     1471                    </li>
     1472                   
     1473                    <?php
    13651474                    foreach ($pages as $page) {
    13661475                    ?>
     
    14301539
    14311540        $cache = wp_cache_get('widget_recent_comments', 'widget');
     1541        $blogpage = $instance['blogpage'] ? '1' : '0';
    14321542        $checkCats = $instance['checkCats'];
    14331543        $checkPages = $instance['checkPages'];
     
    14471557        if ( ! $number = absint( $instance['number'] ) )
    14481558            $number = 5;
    1449        
     1559
    14501560        if (
    1451         $checkCats !=0 && is_category($checkCats) // ...................... Selected categories only.
    1452         || ($checkCats !=0 && is_single() && in_category($checkCats)) // .. Single posts in selected categories only.
    1453         || ($checkPages !=0 && is_page($checkPages)) // ................... Selected pages only.
    1454         || ($checkCats == 0 && $checkPages == 0 && (is_single()
     1561        $blogpage != 0 && is_home() // ----------------------------------- On the blog page only.
     1562        || ($checkCats !=0 && is_category($checkCats)) // ---------------- Selected categories only.
     1563        || ($checkCats !=0 && is_single() && in_category($checkCats)) // - Single posts in selected categories only.
     1564        || ($checkPages !=0 && is_page($checkPages)) // ------------------ Selected pages only.
     1565        || ($checkCats == 0 && $checkPages == 0 && $blogpage == 0 &&
     1566            (is_single()
    14551567            || is_category()
    1456             || is_page())) // ............................................. All single posts, pages & categories.
     1568            || is_page()
     1569            || is_home())) // -------------------------------------------- All single posts, pages & categories.
    14571570        ) {
    14581571
     
    14801593        $instance = $old_instance;
    14811594        $instance['title'] = strip_tags($new_instance['title']);
    1482         $instance['number'] = absint( $new_instance['number'] );
     1595        $instance['number'] = absint( $new_instance['number'] );   
     1596        $instance['blogpage'] = $new_instance['blogpage'] ? 1 : 0;
    14831597        $instance['checkCats'] = $new_instance['checkCats'];
    14841598        $instance['checkPages'] = $new_instance['checkPages'];
     
    14951609        $title = isset($instance['title']) ? esc_attr($instance['title']) : '';
    14961610        $number = isset($instance['number']) ? absint($instance['number']) : 5;
     1611        $blogpage = $instance['blogpage'] ? 'checked="checked"' : '';
    14971612        $checkCats = $intance['checkCats'];
    14981613        $checkPages = $intance['checkPages'];
     
    15481663                    <?php
    15491664                    // Above - hidden input: Allows for an empty term set to be sent. 0 is an invalid Term ID and will be ignored by empty() checks.               
    1550                     // Solution for saving checkboxes: http://wordpress.org/support/topic/widget-checkbox-group-not-registering?replies=3
     1665                    // Solution for saving checkboxes: http://wordpress.org/support/topic/widget-checkbox-group-not-registering?replies=3
     1666                    ?>
     1667                    <li>
     1668                        <input class="checkbox" type="checkbox" <?php echo $blogpage; ?> id="<?php echo $this->get_field_id('blogpage'); ?>" name="<?php echo $this->get_field_name('blogpage'); ?>" /> <label for="<?php echo $this->get_field_id('blogpage'); ?>"><?php _e('The Blog Page'); ?></label>
     1669                    </li>
     1670                   
     1671                    <?php
    15511672                    foreach ($pages as $page) {
    15521673                    ?>
     
    15941715        $instance['checkExcerpt'] = $new_instance['checkExcerpt'];
    15951716        $instance['checkAuthor'] = $new_instance['checkAuthor'];   
    1596         $instance['checkDate'] = $new_instance['checkDate'];       
     1717        $instance['checkDate'] = $new_instance['checkDate'];   
     1718        $instance['blogpage'] = $new_instance['blogpage'] ? 1 : 0;     
    15971719        $instance['checkCats'] = $new_instance['checkCats'];
    15981720        $instance['checkPages'] = $new_instance['checkPages'];
     
    16081730        $checkAuthor = $instance['checkAuthor'];
    16091731        $checkDate = $instance['checkDate'];
     1732        $blogpage = $instance['blogpage'] ? 'checked="checked"' : '';
    16101733        $checkCats = $instance['checkCats'];
    16111734        $checkPages = $instance['checkPages'];
     
    17311854                        <?php
    17321855                        // Above - hidden input: Allows for an empty term set to be sent. 0 is an invalid Term ID and will be ignored by empty() checks.               
    1733                         // Solution for saving checkboxes: http://wordpress.org/support/topic/widget-checkbox-group-not-registering?replies=3
     1856                        // Solution for saving checkboxes: http://wordpress.org/support/topic/widget-checkbox-group-not-registering?replies=3
     1857                        ?>
     1858                        <li>
     1859                            <input class="checkbox" type="checkbox" <?php echo $blogpage; ?> id="<?php echo $this->get_field_id('blogpage'); ?>" name="<?php echo $this->get_field_name('blogpage'); ?>" /> <label for="<?php echo $this->get_field_id('blogpage'); ?>"><?php _e('The Blog Page'); ?></label>
     1860                        </li>
     1861                   
     1862                        <?php
    17341863                        foreach ($pages as $page) {
    17351864                        ?>
     
    17771906        $checkAuthor = $instance['checkAuthor'];
    17781907        $checkDate = $instance['checkDate'];
     1908        $blogpage = $instance['blogpage'] ? '1' : '0';
    17791909        $checkCats = $instance['checkCats'];
    17801910        $checkPages = $instance['checkPages'];
     
    17861916       
    17871917        $items = array_slice($feed->items, 0, $number);
    1788        
     1918
    17891919        if (
    1790         $checkCats !=0 && is_category($checkCats) // ............................................... Selected categories only.
    1791         || ($checkCats !=0 && is_single() && in_category($checkCats)) // ........................... Single posts in selected categories only.
    1792         || ($checkPages !=0 && is_page($checkPages)) // ............................................ Selected pages only.
    1793         || ($checkCats == 0 && $checkPages == 0 && (is_single()
    1794             || is_singular('anbefalinger')
     1920        $blogpage != 0 && is_home() // ----------------------------------- On the blog page only.
     1921        || ($checkCats !=0 && is_category($checkCats)) // ---------------- Selected categories only.
     1922        || ($checkCats !=0 && is_single() && in_category($checkCats)) // - Single posts in selected categories only.
     1923        || ($checkPages !=0 && is_page($checkPages)) // ------------------ Selected pages only.
     1924        || ($checkCats == 0 && $checkPages == 0 && $blogpage == 0 &&
     1925            (is_single()
    17951926            || is_category()
    1796             || is_tax('materialetyper')
    1797             || is_page())) // ...................................................................... All single posts, pages & categories.
     1927            || is_page()
     1928            || is_home())) // -------------------------------------------- All single posts, pages & categories.
    17981929        ) {
    17991930            echo $before_widget;
     
    18651996        }
    18661997        $title = apply_filters('widget_title', $title, $instance, $this->id_base);
     1998        $blogpage = $instance['blogpage'] ? '1' : '0';
    18671999        $checkCats = $instance['checkCats'];
    18682000        $checkPages = $instance['checkPages'];
    1869        
     2001
    18702002        if (
    1871         $checkCats !=0 && is_category($checkCats) // ...................... Selected categories only.
    1872         || ($checkCats !=0 && is_single() && in_category($checkCats)) // .. Single posts in selected categories only.
    1873         || ($checkPages !=0 && is_page($checkPages)) // ................... Selected pages only.
    1874         || ($checkCats == 0 && $checkPages == 0 && (is_single()
     2003        $blogpage != 0 && is_home() // ----------------------------------- On the blog page only.
     2004        || ($checkCats !=0 && is_category($checkCats)) // ---------------- Selected categories only.
     2005        || ($checkCats !=0 && is_single() && in_category($checkCats)) // - Single posts in selected categories only.
     2006        || ($checkPages !=0 && is_page($checkPages)) // ------------------ Selected pages only.
     2007        || ($checkCats == 0 && $checkPages == 0 && $blogpage == 0 &&
     2008            (is_single()
    18752009            || is_category()
    1876             || is_page())) // ............................................. All single posts, pages & categories.
     2010            || is_page()
     2011            || is_home())) // -------------------------------------------- All single posts, pages & categories.
    18772012        ) {
    18782013
     
    18892024    function update( $new_instance, $old_instance ) {
    18902025        $instance['title'] = strip_tags(stripslashes($new_instance['title']));
    1891         $instance['taxonomy'] = stripslashes($new_instance['taxonomy']);
     2026        $instance['taxonomy'] = stripslashes($new_instance['taxonomy']);   
     2027        $instance['blogpage'] = $new_instance['blogpage'] ? 1 : 0;
    18922028        $instance['checkCats'] = $new_instance['checkCats'];
    18932029        $instance['checkPages'] = $new_instance['checkPages'];
     
    18972033    function form( $instance ) {
    18982034        $current_taxonomy = $this->_get_current_taxonomy($instance);
     2035        $blogpage = $instance['blogpage'] ? 'checked="checked"' : '';
    18992036        $checkCats = $intance['checkCats'];
    19002037        $checkPages = $intance['checkPages'];
     
    19582095                    <?php
    19592096                    // Above - hidden input: Allows for an empty term set to be sent. 0 is an invalid Term ID and will be ignored by empty() checks.               
    1960                     // Solution for saving checkboxes: http://wordpress.org/support/topic/widget-checkbox-group-not-registering?replies=3
     2097                    // Solution for saving checkboxes: http://wordpress.org/support/topic/widget-checkbox-group-not-registering?replies=3
     2098                    ?>
     2099                    <li>
     2100                        <input class="checkbox" type="checkbox" <?php echo $blogpage; ?> id="<?php echo $this->get_field_id('blogpage'); ?>" name="<?php echo $this->get_field_name('blogpage'); ?>" /> <label for="<?php echo $this->get_field_id('blogpage'); ?>"><?php _e('The Blog Page'); ?></label>
     2101                    </li>
     2102                   
     2103                    <?php
    19612104                    foreach ($pages as $page) {
    19622105                    ?>
     
    20142157        // Get menu
    20152158        $nav_menu = wp_get_nav_menu_object( $instance['nav_menu'] );
     2159        $blogpage = $instance['blogpage'] ? '1' : '0';
    20162160        $checkCats = $instance['checkCats'];
    20172161        $checkPages = $instance['checkPages'];
     
    20212165
    20222166        $instance['title'] = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
    2023        
     2167
    20242168        if (
    2025         $checkCats !=0 && is_category($checkCats) // ...................... Selected categories only.
    2026         || ($checkCats !=0 && is_single() && in_category($checkCats)) // .. Single posts in selected categories only.
    2027         || ($checkPages !=0 && is_page($checkPages)) // ................... Selected pages only.
    2028         || ($checkCats == 0 && $checkPages == 0 && (is_single()
     2169        $blogpage != 0 && is_home() // ----------------------------------- On the blog page only.
     2170        || ($checkCats !=0 && is_category($checkCats)) // ---------------- Selected categories only.
     2171        || ($checkCats !=0 && is_single() && in_category($checkCats)) // - Single posts in selected categories only.
     2172        || ($checkPages !=0 && is_page($checkPages)) // ------------------ Selected pages only.
     2173        || ($checkCats == 0 && $checkPages == 0 && $blogpage == 0 &&
     2174            (is_single()
    20292175            || is_category()
    2030             || is_page())) // ............................................. All single posts, pages & categories.
     2176            || is_page()
     2177            || is_home())) // -------------------------------------------- All single posts, pages & categories.
    20312178        ) {
    20322179
     
    20442191    function update( $new_instance, $old_instance ) {
    20452192        $instance['title'] = strip_tags( stripslashes($new_instance['title']) );
    2046         $instance['nav_menu'] = (int) $new_instance['nav_menu'];
     2193        $instance['nav_menu'] = (int) $new_instance['nav_menu'];   
     2194        $instance['blogpage'] = $new_instance['blogpage'] ? 1 : 0;
    20472195        $instance['checkCats'] = $new_instance['checkCats'];
    20482196        $instance['checkPages'] = $new_instance['checkPages'];
     
    20532201        $title = isset( $instance['title'] ) ? $instance['title'] : '';
    20542202        $nav_menu = isset( $instance['nav_menu'] ) ? $instance['nav_menu'] : '';
     2203        $blogpage = $instance['blogpage'] ? 'checked="checked"' : '';
    20552204        $checkCats = $intance['checkCats'];
    20562205        $checkPages = $intance['checkPages'];
     
    21252274                    <?php
    21262275                    // Above - hidden input: Allows for an empty term set to be sent. 0 is an invalid Term ID and will be ignored by empty() checks.               
    2127                     // Solution for saving checkboxes: http://wordpress.org/support/topic/widget-checkbox-group-not-registering?replies=3
     2276                    // Solution for saving checkboxes: http://wordpress.org/support/topic/widget-checkbox-group-not-registering?replies=3
     2277                    ?>
     2278                    <li>
     2279                        <input class="checkbox" type="checkbox" <?php echo $blogpage; ?> id="<?php echo $this->get_field_id('blogpage'); ?>" name="<?php echo $this->get_field_name('blogpage'); ?>" /> <label for="<?php echo $this->get_field_id('blogpage'); ?>"><?php _e('The Blog Page'); ?></label>
     2280                    </li>
     2281                   
     2282                    <?php
    21282283                    foreach ($pages as $page) {
    21292284                    ?>
  • flexible-widgets/trunk/readme.txt

    r423642 r431162  
    55Requires at least: 3.0
    66Tested up to: 3.2.1
    7 Stable tag: 0.2
     7Stable tag: 0.3
    88
    99This plugin makes it possible to display a widget on selected categories and/or pages only.
     
    1616
    1717Flexible Widgets will replace the default WordPress widgets.
     18
     19=Known issues=
     20May conflict with themes or plugins which include custom widgets. Please see [the plugin support forum](http://wordpress.org/tags/flexible-widgets?forum_id=10).
     21
     22=Background=
     23The Flexible Widgets plugin consists of a collection of classes originally written for the WordPress theme in use at the website of [Horsens Public Library](http://horsensbibliotek.dk/ "Horsens kommunes biblioteker - a public library in Denmark").
    1824
    1925== Installation ==
     
    3642== Changelog ==
    3743
     44= 0.3 =
     45* Fixes an issue: Optionally display widgets on the home page, whether it is set up to be a static page or the blog posts page.
     46
    3847= 0.2 =
    3948* Tiny update to get the plugin and author URIs right.
Note: See TracChangeset for help on using the changeset viewer.