我找到的解决方案之一是存储集合get_theme_mod($name)
进入PHP$_SESSION["$name"]
. 如果会话存在,请比较新的get_theme_mod($name)
给那个老人$_SESSION["$name"]
, 如果他们不一样的话// 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\');
}
}
}
但它有一个小缺点,管理员需要访问自己的网站或执行
refresh
正在设置传输以执行验证。