One of the solutions that I’ve found, is to store the set get_theme_mod($name)
into a PHP $_SESSION["$name"]
. If the session exist, compare the new get_theme_mod($name)
to that old $_SESSION["$name"]
, if they’re not the same then // do something..
:
// Check if the user is an admin for validation to improve performance.
if (current_user_can( 'manage_options' )) {
session_start();
// If the session is not set, the OLD is not equal to the NEW.
if (!isset($_SESSION['theme_mod_name']) {
// do something..
$_SESSION['theme_mod_name'] = get_theme_mod('theme_mod_name');
} else {
$theme_mod_name = get_theme_mod('theme_mod_name');
$theme_mod_name_s = $_SESSION['theme_mod_name'];
// Check if the OLD is equal to the NEW.
if ($theme_mod_name !== $theme_mod_name_s) {
// do something..
// Override the existing session for future validation.
$_SESSION['theme_mod_name'] = get_theme_mod('theme_mod_name');
}
}
}
But it have a little con, an admin needs to visit its own site or perform a refresh
setting transport to perform the validation.