Created
March 8, 2012 09:34
-
-
Save sercomi/1999938 to your computer and use it in GitHub Desktop.
WP: Run once function
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 | |
/** | |
* The main template file. | |
* | |
* @package WordPress | |
*/ | |
function run_once($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; | |
} | |
} | |
/** | |
* Funciones que sólo se ejecutarán una vez | |
*/ | |
if (run_once('add_user_role')){ | |
//do you stuff and it will only run once | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment