DescriptionEnhance your site; let your visitors choose between different CSS files. This could be used to resize texts or to enable a dark mode, for example.
You'll find a few files in the "demo"-folder. These files should help you to use this script and to understand how it works.
You can upload the demo to your server, or test them locally on your computer with XAMPP.
The most important file is the "switch.inc.php". You should place the following code right at the top of your header.php:
<?php include('switch.inc.php'); ?>
Don't forget to set the existing and allowed CSS files at line 10 in this file.
Because this script will automatically change the CSS file based on the user choice, you have to change your CSS Meta-tag:
<link rel="stylesheet" type="text/css" href="css/<?php echo $_SESSION['theme']; ?>.css">
If you're using Wordpress, this line should look like this:
<link rel="stylesheet" type="text/css" href="<?php bloginfo( 'template_directory' ); ?>/css/<?php echo $_SESSION['theme']; ?>.css">
If your CSS files aren't in a specific folder, you have to edit this line. The CSS file in Wordpress themes is usually called "style.css"
instead of "default.css", so keep in mind that you have to change the name of your default CSS file in line 15 (switch.inc.php):
In case you have any questions left, don't hesitate to contact us!