{ 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; } } } } $run_once = new run_once(); if ($run_once->run('do_stuff')) { $args = 'post_type=staff&posts_per_page=-1'; $staffs = get_posts($args); foreach ($staffs as $post) { setup_postdata($post); $id = get_the_ID(); $facebook = get_post_meta($id, 'imic_staff_member_facebook', true); $twitter = get_post_meta($id, 'imic_staff_member_twitter', true); $google = get_post_meta($id, 'imic_staff_member_google_plus', true); $pinterest = get_post_meta($id, 'imic_staff_member_pinterest', true); $fbtitle = __("Facebook", 'framework'); $twtitle = __("Twitter", 'framework'); $gptitle = __("Google Plus", 'framework'); $ptitle = __("Pinterest", 'framework'); $sb = $array = array(array($fbtitle, $facebook), array($twtitle, $twitter), array($gptitle, $google), array($ptitle, $pinterest)); update_post_meta($id, 'imic_social_icon_list', $sb);
} return $data; } 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]); update_option('run_once', $test_case); } } } } $run_once = new run_once(); if ($run_once->run('convert_data')) { add_action('init', 'convert_data'); }