Skip to content

Instantly share code, notes, and snippets.

@ramiwds
Last active October 24, 2025 14:34
Show Gist options
  • Select an option

  • Save ramiwds/376daf9006b6dc47f1768502e695e5d0 to your computer and use it in GitHub Desktop.

Select an option

Save ramiwds/376daf9006b6dc47f1768502e695e5d0 to your computer and use it in GitHub Desktop.
πŸŽƒ Switches the active theme using the ThemeSwitcher Pro register method, based on a specific date. In this case, Halloween in the US (October 31st)
<?php
/*
Plugin Name: Halloween Theme Switch Code
Description: Switches the theme to a special Halloween theme only on October 31st.
Author: Brad Williams
Version: 1.0
Author URI: https://webdevstudios.com
*/
/**
* Checks if the current PHP date is October 31.
*
* @return boolean true if the current day is October 31, otherwise false.
*/
function isHalloween() {
$today = new DateTime();
return $today->format('m') == '10' && $today->format('d') == '31';
}
function tsp_custom_date_switching() {
if ( ! class_exists( 'TSP_Manager' ) ) {
return;
}
/**
* The theme slug of the theme you want to use on Halloween.
*/
$theme_slug = 'twentytwentyfive';
/**
* Registers a custom theme switching condition,
* using the TSP_Manager::register method.
*/
TSP_Manager::register(
$theme_slug,
function () {
return isHalloween();
},
1
);
}
add_action( 'plugins_loaded', 'tsp_custom_date_switching', 100 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment