upgradeDb(); $this->upgradeCore(); } public function upgradeCore() { $this->backwardCompat(); $this->updatePluginVersion(); } function buildCssFile(){ Campaign::buildCss(); } /** * Upgrade or created table. * * @return void */ private function upgradeDb() { $ver = $this->getInstalledDbVersion(); if ( ! $ver || $ver != HURRYT_DB_VERSION) { $this->createTables(); $this->updateDbVersion(); } } public function createTables() { global $wpdb; $table = "{$wpdb->prefix}hurrytimer_evergreen"; $charset_collate = $wpdb->get_charset_collate(); $sql = "CREATE TABLE {$table} ( id bigint(20) NOT NULL AUTO_INCREMENT, countdown_id bigint(20) unsigned NOT NULL, client_ip_address varchar(50) NOT NULL, expired tinyint(1) unsigned DEFAULT NULL, client_expires_at bigint(20) unsigned NOT NULL, destroy_at timestamp NULL DEFAULT NULL, PRIMARY KEY (id) ) {$charset_collate}"; require_once ABSPATH . 'wp-admin/includes/upgrade.php'; dbDelta($sql); } /** * Returns installed plugin version. * * @return string */ private function getInstalledPluginVersion() { return get_option('hurrytimer_version'); } /** * Update plugin version. * * @return void */ private function updatePluginVersion() { update_option('hurrytimer_version', HURRYT_VERSION); } /** * Returns installed db version. * * @return string */ private function getInstalledDbVersion() { return get_option('hurrytimer_db_version'); } /** * Save new db version. * * @return void */ private function updateDbVersion() { update_option('hurrytimer_db_version', HURRYT_DB_VERSION); } /** * Run global backward compatibility if applicable. * * @return void */ private function backwardCompat() { $ver = $this->getInstalledPluginVersion(); // Clean up unused `_htmr_reset_cookie` option. if (version_compare($ver, '1.1.3', '<=')) { delete_option('_htmr_reset_cookie'); } // Legacy code for some features. if (version_compare($ver, '2.0.0', '<')) { update_option('hurrytimer_legacy', 'yes'); $this->buildCssFile(); } } }