Changeset 863

Show
Ignore:
Timestamp:
02/09/08 10:58:13 (10 months ago)
Author:
_ck_
Message:

v1.10 now returns to original page after theme change

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • bbpress-theme-switcher/trunk/bb-theme-switcher.php

    r787 r863  
    11<?php 
    2  
    32/* 
    43Plugin Name: bbPress Theme Switcher 
    5 Plugin URI: http://bbpress.org/ 
    6 Description: Allows your users and guests to switch themes
    7 Version: 1.09 
     4Plugin URI: http://bbpress.org/plugins/topic/70 
     5Description: Allows your members and guests to switch between themes. Optional timer to return to default theme
     6Version: 1.10 
    87Author: _ck_ 
    98Author URI:  http://bbshowcase.org 
     9Donate: http://amazon.com/paypage/P2FBORKDEFQIVM 
    1010 
    11 Adapted from Ryan Boren WordPress theme switcher which was adapted from Alex King's WordPress style switcher http://www.alexking.org/software/wordpress/ 
     11Inspired by Ryan Boren's WordPress theme switcher which was adapted from Alex King's WordPress style switcher http://www.alexking.org/software/wordpress/ 
    1212 
    13 To use, add the following to your sidebar menu
     13To use, add the following to your footer
    1414 
    1515  <li>Themes: 
     
    2727*/  
    2828 
     29$bbhash=$bb->wp_siteurl ? md5($bb->wp_siteurl) : md5($bb_table_prefix);   // $bbhash is not available before plugins load in 0.8.2.x :-( 
     30bb_ts_set_theme_cookie(180);    //  60 seconds * 3 = 180. Set for 3 minute demo timeout - increase if you want a longer timeout  
     31 
     32if (!(strpos("bbshowcase.org",$GLOBALS["HTTP_SERVER_VARS"]["SERVER_NAME"])===false)) { 
     33$bb_ts_optional_text = '<b><font color=red style="size:24px">keep _ck_ coding</font> >> <a style="color:blue;text-decoration:underline;" target=_blank href="http://amazon.com/paypage/P2FBORKDEFQIVM">donate $1</a> << </b> &nbsp;&nbsp;&nbsp;&nbsp;'; 
     34} 
     35 
    2936add_filter('bb_template','bb_ts_add_dropdown',100,2);    //  disable this line if you don't want the switcher inserted automatically 
    3037add_filter('bb_get_active_theme_folder','bb_ts_get_template'); 
    3138add_filter('bb_get_active_theme_uri', 'bb_ts_get_active_theme_uri'); 
    3239 
    33 $bbhash=$bb->wp_siteurl ? md5($bb->wp_siteurl) : md5($bb_table_prefix);   // $bbhash is not available before plugins load in 0.8.2.x :-( 
    34 bb_ts_set_theme_cookie(); 
    35  
    3640function bb_ts_add_dropdown($template='',$file='') { 
    37 global $bb_ts_add_dropdown;  
     41global $bb_ts_add_dropdown, $bb_ts_optional_text;  
    3842if ($file=='' || ($file=="footer.php" && !$bb_ts_add_dropdown)){ 
    3943$bb_ts_add_dropdown=true; 
    40 echo '<div style="position:relative;clear:right;padding-right:1em;white-space:nowrap;text-align:right;">'.__('Theme Switcher').': ';bb_theme_switcher('dropdown'); echo '</div>'; 
     44echo '<form style="float:right;position:relative;clear:both;padding:5px;white-space:nowrap;text-align:right;">' 
     45.$bb_ts_optional_text.__('Theme Switcher').': ';bb_theme_switcher('dropdown'); echo '</form>; 
    4146} 
    4247return $template;        
    4348}  
    4449 
    45 function bb_ts_set_theme_cookie() { global $bbhash; 
    46         $expire = time() + 180;                                // 180 set for 3 minute demo timeout - increase  want a longer timeout  
     50function bb_ts_set_theme_cookie($timeout=180) { global $bbhash; 
     51        $expire = time() + $timeout;    
    4752        if (!empty($_GET["bbtheme"])) {          
    4853                if ( bb_get_option( 'cookiedomain' ) ) { 
     
    5055                else {setcookie( "bb_theme_".$bbhash, stripslashes($_GET["bbtheme"]), $expire, bb_get_option( 'cookiepath' ) );} 
    5156                                 
    52                 $redirect = bb_get_option( 'uri' ); 
     57                $redirect = remove_query_arg('bbtheme'); 
    5358                if (function_exists('bb_redirect')) 
    5459                        bb_redirect($redirect); 
     
    129134 
    130135                        $ts .=  // '<li>'."\n" 
    131                                  '      <select style="width:150px;" name="themeswitcher" onchange="location.href=\''.bb_get_option( 'uri' ).'?bbtheme=\' + this.options[this.selectedIndex].value;">'."\n"   ; 
     136                                 '      <select style="width:150px;" name="themeswitcher" onchange="location.href=\''.add_query_arg('bbtheme','',remove_query_arg('bbtheme')).'=\' + this.options[this.selectedIndex].value;">'."\n"  ; 
    132137 
    133138                        foreach ($theme_names as $theme_name) { 
     
    142147                                $display = explode("/",trim($theme_name," /")); $display = end($display);       // lazy fix for build >1000 with full path names                                                                 
    143148                                $display = str_replace(array("Bb ","Bbpress"," For "),array("bb ","bbPress"," for "),htmlspecialchars(ucwords(str_replace("-"," ",$display)))); 
    144                                                                                                  
    145                                 $ts .= '<option style="text-indent: 1em;padding:2px" value="'.$theme_name.'"'.$selected.'>'. $display.'</option>'."\n"; 
     149                                if ($display=="Futurekind") {$bk="background:#CBD7E2;font-weight:bold;";} else {$bk="";} 
     150                                 
     151                                $ts .= '<option style="padding:2px;'.$bk.'" value="'.$theme_name.'"'.$selected.'>&nbsp;'.$display.'</option>'."\n"; 
    146152                                                                 
    147153                        } 
  • bbpress-theme-switcher/trunk/readme.txt

    r785 r863  
    55Tested up to: trunk 
    66Stable tag: trunk 
     7Donate link: http://amazon.com/paypage/P2FBORKDEFQIVM 
    78 
    8 Allow your forum visitors to switch between any themes you have installed. Automatically/optionally inserts dropdown in bottom right of all themes. 
     9Allow your forum visitors to switch between any themes you have installed.  
     10Automatically (optionally) inserts dropdown in bottom right of all themes.  
     11Optional timer to return to default theme. 
    912 
    1013== Description == 
    1114 
    12 Adapted from Ryan Boren WordPress theme switcher which was adapted from Alex King's WordPress style switcher http://www.alexking.org/software/wordpress/ 
     15Inspired by Ryan Boren's WordPress theme switcher which was adapted from Alex King's WordPress style switcher http://www.alexking.org/software/wordpress/ 
    1316 
    14 == Instructions == 
     17== Installation == 
    1518 
    16 Install, activate.  
     19* Install, activate. Look in the bottom right hand corner to see the drop-down switcher.  Read FAQ for customization abilities. 
    1720 
    18 Optionally add the following to your sidebar menu for manually placement of the switcher (or use the automatically dropdown in the bottom right). 
     21== Frequently Asked Questions == 
    1922 
    20   <li>Themes: 
     23* Optionally add the following to your sidebar menu for manually placement of the switcher (or use the automatically dropdown in the bottom right). 
     24 
     25  `<li>Themes: 
    2126        <?php bb_theme_switcher(); ?> 
    22   </li> 
     27  </li>` 
    2328 
    2429This will create a list of themes for your readers to select. 
    2530 
    26 If you would like a dropdown box rather than a list, add this: 
     31* If you would like a dropdown box rather than a list, add this: 
    2732 
    28   <li>Themes: 
     33  `<li>Themes: 
    2934        <?php bb_theme_switcher('dropdown'); ?> 
    30   </li> 
     35  </li>` 
     36 
     37* Theme timeout is set to 3 minutes (180 seconds) by default.  Look around line 31 to change this to however long you'd like, ie. 999999 = virtually forever, 30 = half-minute. 
    3138 
    3239== License == 
    3340 
    34 CC-GNU-GPL http://creativecommons.org/licenses/GPL/2.0/ 
     41* CC-GNU-GPL http://creativecommons.org/licenses/GPL/2.0/ 
    3542 
    36 == Version History == 
     43== Donate == 
    3744 
    38 Version 1.05 (2007-08-06) 
     45* http://amazon.com/paypage/P2FBORKDEFQIVM 
     46 
     47== History == 
     48 
     49= Version 1.05 (2007-08-06) = 
    3950 
    4051*   bb-theme-switcher is born 
    4152 
    42 Version 1.06 (2007-10-05) 
     53= Version 1.06 (2007-10-05) = 
    4354 
    4455*   update for first public release 
    4556 
    46 Version 1.08 (2007-1-25) 
     57= Version 1.08 (2007-1-25) = 
    4758 
    4859*   update for alpha 0.8.4 builds >981 (backward compatible) 
    4960 
     61= Version 1.10 (2008-2-09) = 
     62 
     63* enhanced to return to original location after theme switch instead of front page, also small bug fixes/tweaks 
     64