/** * Static function for plugin activation. * * @return void */ public function do_activate() { global $wp_version; require_once ABSPATH . 'wp-admin/includes/upgrade.php'; // Check for capability if (!current_user_can('activate_plugins')) { wp_die(__('Sorry, you do not have suffient permissions to activate this plugin.', MP_DOMAIN)); } // Get the capabilities for the administrator $role = get_role('administrator'); // Must have admin privileges in order to activate. if (empty($role)) { wp_die(__('Sorry, you must be an Administrator in order to use Manga+Press', MP_DOMAIN)); } if (version_compare($wp_version, '3.0', '<=')) { wp_die('Sorry, only WordPress 3.0 and later are supported.' . ' Please upgrade to WordPress 3.0', 'Wrong Version'); } self::$_version = strval(get_option('mangapress_ver')); // version_compare will still evaluate against an empty string // so we have to tell it not to. if (version_compare(self::$_version, MP_VERSION, '<') && !(self::$_version == '')) { add_option('mangapress_upgrade', 'yes', '', 'no'); } elseif (self::$_version == '') { add_option('mangapress_ver', MP_VERSION, '', 'no'); add_option('mangapress_options', serialize(MangaPress_Options::get_default_options()), '', 'no'); } $this->_bootstrap = MangaPress_Bootstrap::get_instance(); $this->_bootstrap->init(); $this->after_plugin_activation(); flush_rewrite_rules(false); }