CSS AJAX Switch to configure your settings and click 'save'. 6. Place the search box where you want by placing into your theme (most likely your sidebar) or simplify your life and use widget sidebars. --How to Use-- Option 1 - Use sidebar Widgets and add CSS Switch to your sidebar Option 2 - Add wherever you'd like CSS AJAX Switch to be. Advanced Setup - Create your own link. Example,TEXT LINK Make sure to change the "CSS NAME" to the name of the CSS provided above. 7. Have fun and if you can contribute (see notes). Version history: -1.5 Resolved prototype dependancy - 1 First Release - .25 My First Save */ /* Widget Icon Provided by http://www.famfamfam.com/lab/icons/silk/ */ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ function csss_header() { $csss_global = get_option("csss_global"); $csss_one = get_option("csss_one"); $csss_one_name = get_option("csss_one_name"); $csss_two = get_option("csss_two"); $csss_two_name = get_option("csss_two_name"); $csss_three = get_option("csss_three"); $csss_three_name = get_option("csss_three_name"); $csss_four = get_option("csss_four"); $csss_four_name = get_option("csss_four_name"); $csss_five = get_option("csss_five"); $csss_five_name = get_option("csss_five_name"); ?> prefStyleSheet = $this->cleanTitle($_GET['css']); if ( isset($_GET['cssJaxy']) && $_GET['cssJaxy'] == true ) { $this->setStyleCookie($this->prefStyleSheet); die(); } } // @public function add($path,$media='',$title='',$alternate=false) { // first grab all global styles if ( !$title ) { $mediaRef = ($media != '' ? 'media="'.$media.'" ' : ''); $styleLink = ''; // add it to our style sheet array array_push($this->styleSheet,$styleLink); } // otherwise we're adding the 'preferred' & 'alternates' else { $this->determinePreferred($path,$title,$media,$alternate); } // now grab our preferred $this->getPreferredStyles(); } // @private function getPreferredStyles() { $this->styleSheets = ''; $totalStyleSheets = count($this->styleSheet); for ( $i = 0; $i < $totalStyleSheets;$i++ ) { $this->styleSheets .= $this->styleSheet[$i]."\n"; } } // @private function determinePreferred($path,$title,$media='',$alternate=false) { // still need that media thing no matter what $mediaRef = ($media != '' ? 'media="'.$media.'" ' : ''); // if $_GET['css'] was set if ( $this->prefStyleSheet ) { $this->setStylecookie($this->prefStyleSheet); if ( $this->prefStyleSheet == $title ) { $styleLink = ''; } else { $styleLink = ''; } } // or we could have set a style sheet from before elseif ( $_COOKIE['PrefStyles'] ) { // odd bug with prototype, php, and cookies....don't ask $cookieCheck = $this->fixOurCookie($_COOKIE['PrefStyles']); if ( $cookieCheck == $title ) { $styleLink = ''; } else { $styleLink = ''; } } // probably just our first time here else { $styleLink = ''; } array_push($this->styleSheet,$styleLink); } // @private function setStyleCookie($value) { setcookie("PrefStyles", $value, time()+(3600*24*365)); /* expires in 1 year */ } // @private function cleanTitle($str) { return str_replace('_',' ',$str); } // @private function fixOurCookie($str) { $c = explode('?',$str); return $c[0]; } // @public function drop() { // watchout! magic may occur echo $this->styleSheets; } } ?> add('/wp-content/themes/'. get_option('csss_global').'','screen,projection'); // [Global Styles] $styleSheet->add('/wp-content/plugins/ajax-css/css-container/'. get_option('csss_one').'','screen,projection',''. get_option('csss_one_name').''); // [Preferred Styles] $styleSheet->add('/wp-content/plugins/ajax-css/css-container/'. get_option('csss_two').'','screen,projection',''. get_option('csss_two_name').'',true); // [Alternate Styles] $styleSheet->add('/wp-content/plugins/ajax-css/css-container/'. get_option('csss_three').'','screen,projection',''. get_option('csss_three_name').'',true); // // [Alternate Styles] $styleSheet->add('/wp-content/plugins/ajax-css/css-container/'. get_option('csss_four').'','screen,projection',''. get_option('csss_four_name').'',true); // // [Alternate Styles] $styleSheet->add('/wp-content/plugins/ajax-css/css-container/'. get_option('csss_five').'','screen,projection',''. get_option('csss_five_name').'',true); // // [Alternate Styles] $styleSheet->getPreferredStyles(); ?> drop(); ?>
" . __("Configuration updated.") . "
"; //updating stuff.. update_option("csss_global", $_POST["global"]); update_option("csss_one", $_POST["one"]); update_option("csss_one_name", $_POST["one_name"]); update_option("csss_two", $_POST["two"]); update_option("csss_two_name", $_POST["two_name"]); update_option("csss_three", $_POST["three"]); update_option("csss_three_name", $_POST["three_name"]); update_option("csss_four", $_POST["four"]); update_option("csss_four_name", $_POST["four_name"]); update_option("csss_five", $_POST["five"]); update_option("csss_five_name", $_POST["five_name"]); update_option("csss_two_option", $_POST["2Option"]); update_option("csss_three_option", $_POST["3Option"]); update_option("csss_four_option", $_POST["4Option"]); update_option("csss_five_option", $_POST["5Option"]); $csss_two_option = get_option("csss_two_option"); $csss_three_option = get_option("csss_three_option"); $csss_four_option = get_option("csss_four_option"); $csss_five_option = get_option("csss_five_option"); $csss_global = get_option("csss_global"); $csss_one = get_option("csss_one"); $csss_one_name = get_option("csss_one_name"); $csss_two = get_option("csss_two"); $csss_two_name = get_option("csss_two_name"); $csss_three = get_option("csss_three"); $csss_three_name = get_option("csss_three_name"); $csss_four = get_option("csss_four"); $csss_four_name = get_option("csss_four_name"); $csss_five = get_option("csss_five"); $csss_five_name = get_option("csss_five_name"); } ?>
'', 'buttontext'=>__('CSS Switch', 'widgets'));
if ( $_POST['csss-submit'] ) {
// Remember to sanitize and format use input appropriately.
$options['title'] = strip_tags(stripslashes($_POST['csss-title']));
update_option('widget_csss', $options);
$buttontext = htmlspecialchars($options['buttontext'], ENT_QUOTES);
}
// Be sure you format your options to be valid HTML attributes.
// Here is our little form segment. Notice that we don't need a
// complete form. This will be embedded into the existing form.
echo '';
echo '';
}
// This registers our widget so it appears with the other available
// widgets and can be dragged and dropped into any active sidebars.
register_sidebar_widget(array('CSS Switch', 'widgets'), 'widget_csss');
// This registers our optional widget control form. Because of this
// our widget will have a button that reveals a 300x100 pixel form.
register_widget_control(array('CSS Switch', 'widgets'), 'widget_csss_control', 300, 100);
}
// For the few without widgets
function csss() {
?>