public static function on_activate() { global $wpdb; if (WebPush_DB::getInstance()->version === get_option('webpush_db_version')) { return; } $table_name = $wpdb->prefix . 'webpush_subscription'; $sql = 'CREATE TABLE ' . $table_name . ' ( `id` INT NOT NULL AUTO_INCREMENT, `endpoint` VARCHAR(300) NOT NULL, `userKey` VARCHAR(300) NOT NULL, PRIMARY KEY (`id`), UNIQUE (`endpoint`) );'; require_once ABSPATH . 'wp-admin/includes/upgrade.php'; dbDelta($sql); update_option('webpush_db_version', WebPush_DB::getInstance()->version); // Set default options. update_option('webpush_title', 'blog_title'); update_option('webpush_icon', function_exists('get_site_icon_url') ? 'blog_icon' : ''); update_option('webpush_min_visits', 3); update_option('webpush_gcm_key', ''); update_option('webpush_gcm_sender_id', ''); update_option('webpush_notification_count', 0); update_option('webpush_opened_notification_count', 0); $default_triggers = WebPush_Main::get_triggers_by_key_value('enable_by_default', true); $default_triggers_keys = array(); foreach ($default_triggers as $trigger) { $default_triggers_keys[] = $trigger['key']; } update_option('webpush_triggers', $default_triggers_keys); }
public static function on_activate() { global $wpdb; if (WebPush_DB::getInstance()->version === get_option('webpush_db_version')) { return; } $table_name = $wpdb->prefix . 'webpush_subscription'; $sql = 'CREATE TABLE ' . $table_name . ' ( `id` INT NOT NULL AUTO_INCREMENT, `endpoint` VARCHAR(300) NOT NULL, `userKey` VARCHAR(300) NOT NULL, PRIMARY KEY (`id`), UNIQUE (`endpoint`) );'; require_once ABSPATH . 'wp-admin/includes/upgrade.php'; dbDelta($sql); update_option('webpush_db_version', WebPush_DB::getInstance()->version); // Set default options. update_option('webpush_title', 'blog_title'); update_option('webpush_min_visits', 3); }