(This script has been written in ~1 hour, as a challenge.)
Do you want to test new themes on some users? Do you want to create new themes in 2 seconds? This PHP script is perfect for you! Multith is able to load theme from a database and apply it to the page.
It's simple: in a database, there is projects. For each project, there is themes that can be called whatever you want (ex.: v1, v2, v3, etc.). A default theme is set in a table, so that users that don't have a custom token will get the default theme choosed by the server administrator. You can add stylesheets and javascript scripts simply by adding them in the appropriate column of the 'multith_themes' table. Just don't forget to separate your links by ";" so that the script will know that it's a new resource to get!
Do you want to enable or disable a theme? No problem! Just change the column 'enable' to the appropriate value.
Simply add a new row in the 'multith_tokens' table. Set the project column to your project name, the theme column to the theme you want the token to use, and add a name to the token! After inserting the row in the table, every user with the cookie 'theme' containing the token you just set will have the theme you selected.
- You need to create the database. To do so, create a database with the name you want (default is multith), then import the .sql included in
this repository;
- Fill any informations you want in the database;
- Enter the credentials to access the database in the file 'multith-php-master/multith/Multith.php';
- Initiate the PHP script on your website like so:
require_once('multith-php-master/autoload.php'); # The path to the autoloader of the plugin
$multith->Initiate('{PROJECT NAME}', '{THEME YOU WANT} (OPTIONAL)');
You are good to go!
Fortunaly, Multith contains a simple interface that ables you to create a class to get informations from your database. See the file 'multith-php-master/multith/Database/DatabaseType.php' for more informations.