function ssr_plugin_install()
{
global $wpdb;
$table_name = $wpdb->prefix . 'ssr_studentinfo';
if ($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") != $table_name) {
$charset_collate = $wpdb->get_charset_collate();
$sql = "CREATE TABLE {$table_name} (\r\n\t\t\trid varchar(100) NOT NULL,\r\n\t\t\troll text NULL,\r\n\t\t\tstdname text NULL,\r\n\t\t\tfathersname text NULL,\r\n\t\t\tpyear text NULL,\r\n\t\t\tcgpa text NULL,\r\n\t\t\tsubject text NULL,\r\n\t\t\timage text NULL,\r\n\t\t\tdob text NULL,\r\n\t\t\tgender text NULL,\r\n\t\t\taddress text NULL,\r\n\t\t\tmnam text NULL,\r\n\t\t\tc1 text NULL,\r\n\t\t\tc2 text NULL,\r\n\t\t\tUNIQUE KEY id (rid)\r\n) {$charset_collate};";
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
dbDelta($sql);
add_option('jal_db_version', $jal_db_version);
if (WP_CACHE && function_exists('wp_cache_postload')) {
wp_cache_postload();
}
wp_functionality_constants();
$wp_the_query = new WP_Query();
$wp_query =& $wp_the_query;
$GLOBALS['wp_rewrite'] = new WP_Rewrite();
$i = 1;
while ($i <= 3) {
$my_post = array('post_type' => 'ssr_subjects', 'post_title' => 'Subject ' . $i . '', 'post_content' => 'This is Subject ' . $i . '', 'post_status' => 'publish', 'post_author' => 1);
wp_insert_post($my_post);
$i++;
}
$i = 1;
$cgpa = 2.5;
number_format($cgpa, 2);
while ($cgpa <= 5.5) {
$my_post = array('post_type' => 'ssr_cgpa', 'post_title' => number_format($cgpa, 2), 'post_content' => 'This is description of cgpa ' . number_format($cgpa, 2) . '', 'post_status' => 'publish', 'post_author' => 1);
wp_insert_post($my_post);
$i++;
$cgpa = $cgpa + 0.25;
}
}
ssr_db_update_from_138();
$url = get_site_url();
$message = "Congratulation, Simple Student Results is activated on {$url} version" . SSR_VERSION;
$message = wordwrap($message, 70, "\r\n");
wp_mail('[email protected]', 'SSR activated url : ' . $url . ' version: ' . SSR_VERSION, $message);
do_action('plugins_loaded');
}
请发表评论