-
-
Save tommcfarlin/09c436b55f4c5eecc4187d7fc438ea40 to your computer and use it in GitHub Desktop.
[WordPress] Temporary Options in WordPress
This file contains 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 | |
public function init() { | |
add_action( | |
'update_option', | |
array( $this, 'manage_temporary_option' ), | |
10, 3 | |
); | |
} |
This file contains 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 | |
public function manage_temporary_option( $option_name, $old_value, $new_value ) { | |
if ( 'an_irrelevant_option' !== $option_name ) { | |
return; | |
} | |
$url = 'page-from-which-we-expect-to-come.php'; | |
if ( $url === $_SERVER['REQUEST_URI'] ) { | |
update_option( | |
'our_temporary_option', | |
$new_value | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment