-
Notifications
You must be signed in to change notification settings - Fork 0
/
mangapress.php
251 lines (214 loc) · 6.99 KB
/
mangapress.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
<?php
/**
* @package Manga_Press
* @version $Id$
* @author Jessica Green <jgreen@psy-dreamer.com>
*
* @todo Update screenshots
* @todo Update PHPDoc comments
*/
/*
Plugin Name: Manga+Press Comic Manager
Plugin URI: http://www.manga-press.com/
Description: Turns WordPress into a full-featured Webcomic Manager. Be sure to visit <a href="http://www.manga-press.com/">Manga+Press</a> for more info.
Version: 2.8-alpha-$Rev$
Author: Jessica Green
Author URI: http://www.jes.gs
*/
/*
* (c) 2008 - 2012 Jessica C Green
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF']))
die('You are not allowed to call this page directly.');
$plugin_folder = plugin_basename(dirname(__FILE__));
if (!defined('MP_VERSION'))
define('MP_VERSION', '2.8-alpha-$Rev$');
if (!defined('MP_DB_VERSION'))
define('MP_DB_VERSION', '1.1');
if (!defined('MP_FOLDER'))
define('MP_FOLDER', $plugin_folder);
if (!defined('MP_ABSPATH'))
define('MP_ABSPATH', plugin_dir_path(__FILE__));
if (!defined('MP_URLPATH'))
define('MP_URLPATH', plugin_dir_url(__FILE__));
if (!defined('MP_LANG'))
define('MP_LANG', $plugin_folder . '/lang');
if (!defined('MP_DOMAIN'))
define('MP_DOMAIN', $plugin_folder);
include_once('framework/FrameworkHelper.php');
include_once('framework/PostType.php');
include_once('framework/Taxonomy.php');
include_once('framework/View.php');
include_once('framework/Options.php');
include_once('framework/Form/Element.php');
include_once('includes/functions.php');
include_once('includes/template-functions.php');
include_once('mangapress-comic.php');
include_once('mangapress-install.php');
include_once('mangapress-posts.php');
include_once('mangapress-options.php');
register_activation_hook(__FILE__, array('MangaPress_Install', 'do_activate'));
register_deactivation_hook( __FILE__, array('MangaPress_Install', 'do_deactivate'));
add_action('init', array('MangaPress_Bootstrap', 'init'));
add_action('setup_theme', array('MangaPress_Bootstrap', 'setup_theme'));
/**
* Plugin bootstrap class.
*
* @package MangaPress
* @subpackage MangaPress_Bootstrap
* @author Jess Green <jgreen@psy-dreamer.com>
*/
class MangaPress_Bootstrap
{
protected static $_options;
/**
* MangaPress Posts object
*
* @var \MangaPress_Posts
*/
protected $_posts;
/**
* Static function used to initialize Bootstrap
*
* @return void
*/
public static function init()
{
global $mp, $options_page;
self::set_options();
load_plugin_textdomain(MP_DOMAIN, false, MP_LANG);
$mp = new MangaPress_Bootstrap();
$mp->_posts = new MangaPress_Posts();
$options_page = new MangaPress_Options();
}
/**
* Because register_theme_directory() can't run on init.
*
* @return void
*/
public static function setup_theme()
{
register_theme_directory('plugins/' . MP_FOLDER . '/themes');
}
/**
* 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();
}
}
/**
* Set MangaPress options. This method should run every time
* MangaPress options are updated.
*
* @uses init()
* @see MangaPress_Bootstrap::init()
*
* @return void
*/
public static function set_options()
{
self::$_options = maybe_unserialize(get_option('mangapress_options'));
}
/**
* Get MangaPress options
*
* @return array
*/
public function get_options()
{
return self::$_options;
}
/**
* Enqueue Scripts/Styles
*
* @return void
*/
public function wp_enqueue_scripts()
{
wp_enqueue_style('mangapress-nav');
}
}