/**
  * Create database table and add default options
  * @static
  */
 public static function install_plugin()
 {
     // get database version from options table
     if (get_option('CTDL_db_version')) {
         $installed_version = get_option('CTDL_db_version');
     } elseif (get_option('cleverness_todo_db_version')) {
         $installed_version = get_option('cleverness_todo_db_version');
     } else {
         $installed_version = 0;
     }
     // check if the db version is the same as the db version constant
     if ($installed_version != CTDL_DB_VERSION) {
         include_once plugin_dir_path(__FILE__) . '/cleverness-to-do-list-loader.class.php';
         if (!post_type_exists('todo')) {
             CTDL_Loader::setup_custom_post_type();
         }
         if (!taxonomy_exists('todocategories')) {
             CTDL_Loader::create_taxonomies();
         }
         // if there was no db version option
         if ($installed_version == 0) {
             // check to see if there are any to-do custom posts
             $existing_todos = self::check_for_todos();
             // if not, add the first to-do item
             if ($existing_todos == 0) {
                 global $current_user;
                 get_currentuserinfo();
                 // add first post
                 $first_post = __('Add your first To-Do List item', 'cleverness-to-do-list');
                 $the_post = array('post_type' => 'todo', 'post_title' => substr($first_post, 0, 100), 'post_content' => $first_post, 'post_status' => 'publish', 'post_author' => $current_user->ID, 'comment_status' => 'closed', 'ping_status' => 'closed');
                 $post_id = wp_insert_post($the_post);
                 add_post_meta($post_id, '_status', 0, true);
                 add_post_meta($post_id, '_priority', 1, true);
                 add_post_meta($post_id, '_assign', -1, true);
                 add_post_meta($post_id, '_deadline', '', true);
                 add_post_meta($post_id, '_progress', 0, true);
             }
             self::set_options($installed_version);
         } else {
             self::set_options($installed_version);
             // update db version to current versions
             update_option('CTDL_db_version', CTDL_DB_VERSION);
             // if the db version is < 3.0
             if ($installed_version < 3) {
                 // check to see if there's existing to-do items. if so, convert them to custom posts
                 $existing_todos = self::check_for_todos();
                 if ($existing_todos == 0) {
                     self::convert_todos();
                 }
             }
             // if db version < 3.2.1, convert deadlines
             if (version_compare($installed_version, '3.21', '<')) {
                 self::convert_deadlines();
             }
             // if db version < 3.4, split taxonomies
             if (version_compare($installed_version, '3.4', '<')) {
                 global $wp_version;
                 if (version_compare($wp_version, '4.2', '>=')) {
                     self::split_taxonomies();
                 }
             }
         }
     }
 }