Skip to content

Instantly share code, notes, and snippets.

@sercomi
Created March 8, 2012 09:34
Show Gist options
  • Save sercomi/1999938 to your computer and use it in GitHub Desktop.
Save sercomi/1999938 to your computer and use it in GitHub Desktop.
WP: Run once function
<?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