Last active
November 20, 2023 19:02
-
-
Save alexstandiford/ed9137a7cf5472c86f1d24cb1f3e46b8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action('after_switch_theme', function(){ | |
// Set a flag indicating a new installation | |
set_theme_mod('theme_version', '1.2.3'); | |
}); | |
// Upgrade routine for backwards compatibility with pre-existing home screen setup. | |
add_action('init', function() { | |
// Check if the update logic has already been executed | |
if (version_compare(get_theme_mod('theme_version'), '1.2.3', '<')) { | |
// This is either a first run or a theme update | |
set_theme_mod('is_backcompat_home_screen', true); | |
// Set the flag to indicate that update logic has been executed | |
set_theme_mod('theme_version', '1.2.3'); | |
} | |
}); | |
add_filter('template_include', function($template){ | |
if(get_theme_mod('is_backcompat_home_screen') && is_home()){ | |
$template = locate_template(['index.php']); | |
} | |
return $template; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment