/** * 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); }
/** * Run init functionality * * @see init() hook * @return void */ public function init() { $this->set_options(); $this->_posts_helper = new MangaPress_Posts(); $this->_admin_helper = new MangaPress_Admin(); $this->_options_helper = new MangaPress_Options(); $this->flashmessages_helper = new MangaPress_FlashMessages(array('transient_name' => 'mangapress_messages')); $this->_load_current_options(); add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts')); add_filter('single_template', 'mangapress_single_comic_template'); add_filter('template_include', 'mangapress_latestcomic_template'); add_filter('template_include', 'mangapress_latestcomic_page_template'); add_filter('template_include', 'mangapress_comicarchive_template'); add_filter('template_include', 'mangapress_comicarchive_page_template'); if (get_option('mangapress_upgrade') == 'yes') { MangaPress_Install::get_instance()->do_upgrade(); } }
/** * PHP5 Constructor function * * @return void */ public function __construct() { $mp_options = $this->get_options(); /* * Navigation style */ wp_register_style('mangapress-nav', MP_URLPATH . 'css/nav.css', null, MP_VERSION, 'screen'); add_action('template_include', 'mpp_comic_single_page'); /* * Disable/Enable Default Navigation CSS */ if ($mp_options['nav']['nav_css'] == 'default_css') { add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts')); } /* * Comic Navigation */ if ($mp_options['nav']['insert_nav']) { add_action('the_content', 'mpp_comic_insert_navigation'); } /* * Lastest Comic Page */ if ((bool) $mp_options['basic']['latestcomic_page'] && !(bool) $mp_options['basic']['latestcomic_page_template']) { add_filter('the_content', 'mpp_filter_latest_comic'); } /* * Latest Comic Page template override */ if ((bool) $mp_options['basic']['latestcomic_page_template']) { add_filter('template_include', 'mpp_latest_comic_page'); } /* * Comic Archive Page */ if ((bool) $mp_options['basic']['comicarchive_page'] && !(bool) $mp_options['basic']['comicarchive_page_template']) { add_filter('the_content', 'mpp_filter_comic_archivepage'); } /* * Comic Archive Page template override */ if ((bool) $mp_options['basic']['comicarchive_page_template']) { add_filter('template_include', 'mpp_comic_archivepage'); } /* * Comic Thumbnail Banner */ add_image_size('comic-banner', $mp_options['comic_page']['banner_width'], $mp_options['comic_page']['banner_height'], true); /* * Comic Thumbnail size for Comics Listing screen */ add_image_size('comic-admin-thumb', 60, 80, true); /* * Comic Page size */ if ($mp_options['comic_page']['generate_comic_page']) { add_image_size('comic-page', $mp_options['comic_page']['comic_page_width'], $mp_options['comic_page']['comic_page_height'], false); } if (get_option('mangapress_upgrade') == 'yes') { MangaPress_Install::do_upgrade(); } }