/** * Called on activation of the plugin. */ public function installPlugin() { global $wpdb; // Add Cron Job, the action is added in the Public class. if (!wp_next_scheduled('avhfdas_clean_nonce')) { wp_schedule_event(time(), 'daily', 'avhfdas_clean_nonce'); } // Setup nonces db in options if (!get_option($this->_core->getDbNonces())) { update_option($this->_core->getDbNonces(), $this->_core->getDefaultNonces()); wp_cache_flush(); // Delete cache } // Setup the DB Tables $charset_collate = ''; if (version_compare($wpdb->db_version(), '4.1.0', '>=')) { if (!empty($wpdb->charset)) { $charset_collate = 'DEFAULT CHARACTER SET ' . $wpdb->charset; } if (!empty($wpdb->collate)) { $charset_collate .= ' COLLATE ' . $wpdb->collate; } } if ($wpdb->get_var('show tables like \'' . $wpdb->avhfdasipcache . '\'') === null) { $sql = 'CREATE TABLE `' . $wpdb->avhfdasipcache . '` ( `ip` int(10) unsigned NOT null, `added` datetime NOT null DEFAULT \'0000-00-00 00:00:00\', `lastseen` datetime NOT null DEFAULT \'0000-00-00 00:00:00\', `spam` tinyint(1) NOT null, PRIMARY KEY (`ip`), KEY `added` (`added`), KEY `lastseen` (`lastseen`) ) ' . $charset_collate . ';'; $wpdb->query($sql); } }