prefix . "nb_data"; $nb_installed_ver = get_option( "pd_nb_db_version" ); if( $nb_installed_ver != NB_DB_VERSION ) { $sql = "CREATE TABLE " . $table_name . " ( id mediumint(2) NOT NULL AUTO_INCREMENT, timecreated datetime NOT NULL, name tinytext CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, content text CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, timebegin datetime DEFAULT NULL, timeend datetime DEFAULT NULL, status tinyint(1) NOT NULL, PRIMARY KEY (id) );"; require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); dbDelta($sql); update_option("pd_nb_db_version", NB_DB_VERSION); } } function nb_update_db_check() { global $pd_nb_db_version; if (get_site_option('pd_nb_db_version') != NB_DB_VERSION) { nb_install(); } } add_action('plugins_loaded', 'nb_update_db_check'); function nb_install_data() { global $wpdb; $table_name = $wpdb->prefix . "nb_data"; $nb_name = __('Notification example','attention-bar'); $nb_content = __('Congratulations, you have just installed Attention Bar !','attention-bar'); $rows_affected = $wpdb->insert( $table_name, array( 'status' => 0, 'timecreated' => current_time('mysql'), 'name' => $nb_name, 'content' => $nb_content ) ); } ?>