Skip to content

Instantly share code, notes, and snippets.

@bainternet
Created August 23, 2011 11:08
Show Gist options
  • Save bainternet/1164863 to your computer and use it in GitHub Desktop.
Save bainternet/1164863 to your computer and use it in GitHub Desktop.
WordPress run once class
<?php
/*
* run Once class
*
*/
if (!class_exists('run_once')){
class run_once{
function run($key){
$test_case = get_option('run_once');
if (isset($test_case[$key]) && $test_case[$key]){
return false;
}else{
$test_case[$key] = true;
update_option('run_once',$test_case);
return true;
}
}
function clear($key){
$test_case = get_option('run_once');
if (isset($test_case[$key])){
unset($test_case[$key]);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment