Changeset 863
- Timestamp:
- 02/09/08 10:58:13 (10 months ago)
- Files:
-
- bbpress-theme-switcher/trunk/bb-theme-switcher.php (modified) (5 diffs)
- bbpress-theme-switcher/trunk/readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
bbpress-theme-switcher/trunk/bb-theme-switcher.php
r787 r863 1 1 <?php 2 3 2 /* 4 3 Plugin Name: bbPress Theme Switcher 5 Plugin URI: http://bbpress.org/ 6 Description: Allows your users and guests to switch themes.7 Version: 1. 094 Plugin URI: http://bbpress.org/plugins/topic/70 5 Description: Allows your members and guests to switch between themes. Optional timer to return to default theme. 6 Version: 1.10 8 7 Author: _ck_ 9 8 Author URI: http://bbshowcase.org 9 Donate: http://amazon.com/paypage/P2FBORKDEFQIVM 10 10 11 Adapted from Ryan BorenWordPress theme switcher which was adapted from Alex King's WordPress style switcher http://www.alexking.org/software/wordpress/11 Inspired by Ryan Boren's WordPress theme switcher which was adapted from Alex King's WordPress style switcher http://www.alexking.org/software/wordpress/ 12 12 13 To use, add the following to your sidebar menu:13 To use, add the following to your footer: 14 14 15 15 <li>Themes: … … 27 27 */ 28 28 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 :-( 30 bb_ts_set_theme_cookie(180); // 60 seconds * 3 = 180. Set for 3 minute demo timeout - increase if you want a longer timeout 31 32 if (!(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> '; 34 } 35 29 36 add_filter('bb_template','bb_ts_add_dropdown',100,2); // disable this line if you don't want the switcher inserted automatically 30 37 add_filter('bb_get_active_theme_folder','bb_ts_get_template'); 31 38 add_filter('bb_get_active_theme_uri', 'bb_ts_get_active_theme_uri'); 32 39 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 36 40 function bb_ts_add_dropdown($template='',$file='') { 37 global $bb_ts_add_dropdown ;41 global $bb_ts_add_dropdown, $bb_ts_optional_text; 38 42 if ($file=='' || ($file=="footer.php" && !$bb_ts_add_dropdown)){ 39 43 $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>'; 44 echo '<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>; 41 46 } 42 47 return $template; 43 48 } 44 49 45 function bb_ts_set_theme_cookie( ) { global $bbhash;46 $expire = time() + 180; // 180 set for 3 minute demo timeout - increase want a longer timeout50 function bb_ts_set_theme_cookie($timeout=180) { global $bbhash; 51 $expire = time() + $timeout; 47 52 if (!empty($_GET["bbtheme"])) { 48 53 if ( bb_get_option( 'cookiedomain' ) ) { … … 50 55 else {setcookie( "bb_theme_".$bbhash, stripslashes($_GET["bbtheme"]), $expire, bb_get_option( 'cookiepath' ) );} 51 56 52 $redirect = bb_get_option( 'uri');57 $redirect = remove_query_arg('bbtheme'); 53 58 if (function_exists('bb_redirect')) 54 59 bb_redirect($redirect); … … 129 134 130 135 $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" ; 132 137 133 138 foreach ($theme_names as $theme_name) { … … 142 147 $display = explode("/",trim($theme_name," /")); $display = end($display); // lazy fix for build >1000 with full path names 143 148 $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.'> '.$display.'</option>'."\n"; 146 152 147 153 } bbpress-theme-switcher/trunk/readme.txt
r785 r863 5 5 Tested up to: trunk 6 6 Stable tag: trunk 7 Donate link: http://amazon.com/paypage/P2FBORKDEFQIVM 7 8 8 Allow your forum visitors to switch between any themes you have installed. Automatically/optionally inserts dropdown in bottom right of all themes. 9 Allow your forum visitors to switch between any themes you have installed. 10 Automatically (optionally) inserts dropdown in bottom right of all themes. 11 Optional timer to return to default theme. 9 12 10 13 == Description == 11 14 12 Adapted from Ryan BorenWordPress theme switcher which was adapted from Alex King's WordPress style switcher http://www.alexking.org/software/wordpress/15 Inspired by Ryan Boren's WordPress theme switcher which was adapted from Alex King's WordPress style switcher http://www.alexking.org/software/wordpress/ 13 16 14 == Inst ructions==17 == Installation == 15 18 16 Install, activate. 19 * Install, activate. Look in the bottom right hand corner to see the drop-down switcher. Read FAQ for customization abilities. 17 20 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 == 19 22 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: 21 26 <?php bb_theme_switcher(); ?> 22 </li> 27 </li>` 23 28 24 29 This will create a list of themes for your readers to select. 25 30 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: 27 32 28 <li>Themes:33 `<li>Themes: 29 34 <?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. 31 38 32 39 == License == 33 40 34 CC-GNU-GPL http://creativecommons.org/licenses/GPL/2.0/41 * CC-GNU-GPL http://creativecommons.org/licenses/GPL/2.0/ 35 42 36 == Version History==43 == Donate == 37 44 38 Version 1.05 (2007-08-06) 45 * http://amazon.com/paypage/P2FBORKDEFQIVM 46 47 == History == 48 49 = Version 1.05 (2007-08-06) = 39 50 40 51 * bb-theme-switcher is born 41 52 42 Version 1.06 (2007-10-05) 53 = Version 1.06 (2007-10-05) = 43 54 44 55 * update for first public release 45 56 46 Version 1.08 (2007-1-25) 57 = Version 1.08 (2007-1-25) = 47 58 48 59 * update for alpha 0.8.4 builds >981 (backward compatible) 49 60 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
