分享一个让wordpress代码只运行一次的办法,可以用来激活主题
//只会运行一次
if (run_once('open_page_comment')){
global $wpdb;
$wpdb->query( "UPDATE wp_posts SET comment_status='open';" );
}
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;
}
}


