WordPress.org

Plugin Directory

Changeset 511863


Ignore:
Timestamp:
02/28/12 18:40:48 (2 years ago)
Author:
MadtownLems
Message:

bug fix for extra conditional checks with some settings. added debugging statements when WP_DEBUG is on

Location:
conditional-widgets/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • conditional-widgets/trunk/cets_conditional_widgets.php

    r428160 r511863  
    44Plugin URI: http://wordpress.org/extend/plugins/conditional-widgets/ 
    55Description: Grants users advanced control over which pages and categories each widget is displayed on 
    6 Version: 1.4 
     6Version: 1.5 
    77Author: Jason Lemahieu and Kevin Graeme 
    88Author URI:  
     
    220220    */ 
    221221     
     222    if (WP_DEBUG) { 
     223        $debug = true; 
     224    } else { 
     225        $debug = false; 
     226    } 
    222227    global $wp_query; 
    223228    $qvars = $wp_query->query_vars; 
     
    230235            case 0: //hide if front page 
    231236                if (is_front_page()) { 
     237                    if ($debug) {echo "[Widget hidden because front page.]<br/><br/>"; } 
    232238                    return false; 
    233239                } 
     
    235241            case 1: //show if front page 
    236242                if (is_front_page()) { 
     243                    if ($debug) {echo "Showing because front page:<br/>"; } 
    237244                    return $instance; 
    238245                } 
     
    240247            case 2: //only show on front, hide otherwise 
    241248                if (is_front_page()) { 
     249                    if ($debug) {echo "Showing because front page:<br/>"; } 
    242250                    return $instance; 
    243251                } else { 
     252                    if ($debug) {echo "[ Widget hidden because not front page]<br/><br/>"; } 
    244253                    return false; 
    245254                } 
     
    276285            if ($instance['cw_select_pages'] == 1) { 
    277286                //and we're showing on matched pages - SHOW 
     287                if ($debug) {echo "Showing because we're set to show on this page:<br/>"; } 
    278288                return $instance; 
    279289            } else { 
    280290                //and we're hiding on matched pages - so HIDE 
     291                if ($debug) {echo "[Widget hidden because this page wasnt chosen to have this widget displayed.]<br/><br/>"; } 
    281292                return false; 
    282293            } 
     
    285296            if ($instance['cw_select_pages'] == 1) { 
    286297                //and we're telling it to show on matched pages - so HIDE 
     298                if ($debug) {echo "[Widget hidden because this is a page you told me to hid it on.]<br/><br/>"; } 
    287299                return false; 
    288300            } else { 
    289301                //we didn't match a page, and we told it to hide on those pages - so SHOW 
     302                if ($debug) {echo "Showing because front page:<br/>"; } 
    290303                return $instance; 
    291304            } 
     
    293306    } //is_page && we care 
    294307     
    295     //see if we care about categories... 
    296     if ($instance['cw_cats_enable_checkbox']) { 
     308    //see if we care about categories...   (2/28/2012: AND if this page is related to categories...) 
     309    $match = false; 
     310    if ($instance['cw_cats_enable_checkbox'] && (is_single() || is_category())) { 
    297311        //starting point. haven't matched yet - checked categories. 
    298         $match = false; 
     312         
    299313        $arr_cats = $instance['cw_selected_cats']; 
    300314 
     
    338352        // Logic Processing now that we've determined whether or now we're a match 
    339353        if ($match) { 
     354                     
    340355            //we matched a cat 
    341356            if ($instance['cw_select_cats'] == 1) { 
    342357                //and we're showing on matched cats 
     358                if ($debug) {echo "Showing because I was told to show this on this category:<br/>"; } 
    343359                return $instance; 
    344360            } else { 
    345361                //and we're hiding on matched cats 
     362                if ($debug) {echo "[Widget hidden because I was told to show on certain categories - and this isn't one of em.]<br/><br/>"; } 
    346363                return false; 
    347364            } 
     
    350367            if ($instance['cw_select_cats'] == 1) { 
    351368                //and we're telling it to show on matched cats - so HIDE 
     369                if ($debug) {echo "[Widget hidden because this category doesn't match ones we were told to show on.]<br/><br/>"; } 
    352370                return false; 
    353371            } else { 
    354372                //we didn't match a cat, and we told it to hide on those cats - so SHOW 
     373                if ($debug) {echo "Showing because this isn't one of the categories we were told to hide on:<br/>"; } 
    355374                return $instance; 
    356375            } 
     
    358377         
    359378    } //if we care about categories 
    360      
     379         
    361380    //since 1.4 
    362381    if (is_home()) { 
    363382        if ($instance['cw_posts_page_hide'] == 1) { 
     383            if ($debug) {echo "[Widget hidden because this is the home page.]<br/><br/>"; } 
    364384            return false; 
    365385        } 
     
    369389    if (is_404()) { 
    370390        if ($instance['cw_404_hide'] == 1) { 
     391            if ($debug) {echo "[Widget hidden because this is the 404 page.]<br/><br/>"; } 
    371392            return false; 
    372393        } 
     
    376397    if (is_search()) {       
    377398        if ($instance['cw_search_hide'] == 1) { 
     399            if ($debug) {echo "[Widget hidden because this is the search page.]<br/><br/>"; } 
    378400            return false; 
    379401        } 
     
    383405    if (is_author()) { 
    384406        if ($instance['cw_author_archive_hide'] == 1) { 
     407            if ($debug) {echo "[Widget hidden because this is an author archive page.]<br/><br/>"; } 
    385408            return false; 
    386409        } 
     
    390413    if (is_date()) { 
    391414        if ($instance['cw_date_archive_hide'] == 1) { 
     415            if ($debug) {echo "[Widget hidden because this is a date archive page.]<br/><br/>"; } 
    392416            return false; 
    393417        } 
     
    397421    if (is_tag()) { 
    398422        if ($instance['cw_tag_archive_hide'] == 1) { 
     423            if ($debug) {echo "[Widget hidden because this is a tag archive.]<br/><br/>"; } 
    399424            return false; 
    400425        } 
     426 
    401427    } 
    402428     
  • conditional-widgets/trunk/readme.txt

    r472495 r511863  
    33Tags: media, files 
    44Requires at least: 2.8.6 
    5 Tested up to: 3.3 
     5Tested up to: 3.3.1 
    66Stable tag: trunk 
    77 
     
    3030== Changelog == 
    3131 
     32= 1.5 = 
     33* Fixed a bug surrounding the extra conditional checks on some configurations 
     34* Added debugging and informative statements while WP_DEBUG is enabled 
     35 
    3236= 1.4 = 
    3337* Added support for Posts Pages (when using Static Front Page) 
Note: See TracChangeset for help on using the changeset viewer.