Skip to content

Instantly share code, notes, and snippets.

@tommcfarlin

tommcfarlin/00-init.php Secret

Created Jan 24, 2017
Embed
What would you like to do?
[WordPress] Temporary Options in WordPress
<?php
public function init() {
add_action(
'update_option',
array( $this, 'manage_temporary_option' ),
10, 3
);
}
<?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
You can’t perform that action at this time.