1 <?php
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 if ( ! defined( 'ABSPATH' ) ) exit;
29
30 $wpt_version = '0.16';
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 class Theater {
96
97 98 99 100 101 102 103
104 protected static $_instance = null;
105
106 function __construct() {
107
108 }
109
110 111 112 113 114 115 116 117 118 119
120 static function instance() {
121 if ( is_null( self::$_instance ) ) {
122 self::$_instance = new self();
123 }
124 return self::$_instance;
125 }
126
127 128 129 130 131 132 133
134 function init() {
135
136 global $wpt_version;
137 $this->wpt_version = $wpt_version;
138
139 $this->define_constants();
140
141
142 $this->includes();
143
144
145 Theater_Setup::init();
146
147 $this->admin = new WPT_Admin();
148 Theater_Admin_Plugins::init();
149
150 $this->order = new WPT_Order();
151 $this->status = new WPT_Status();
152 $this->feeds = new WPT_Feeds();
153 $this->transient = new WPT_Transient();
154 $this->listing_page = new WPT_Listing_Page();
155 $this->calendar = new WPT_Calendar();
156 $this->context = new WPT_Context();
157 $this->filter = new WPT_Filter();
158
159 $this->event_admin = new WPT_Event_Admin();
160 $this->event_editor = new WPT_Event_Editor();
161
162 $this->production_permalink = new WPT_Production_Permalink();
163 Theater_Event_Date_Link::init();
164
165 Theater_Widgets::init();
166
167 $this->productions_admin = new WPT_Productions_Admin();
168
169 $this->cart = new WPT_Cart();
170 $this->tags = new WPT_Tags();
171 $this->extensions_updater= new WPT_Extensions_Updater();
172 $this->extensions_promo= new WPT_Extensions_Promo();
173 if (is_admin()) {
174 } else {
175 $this->frontend = new WPT_Frontend();
176 }
177
178 $this->deprecated_properties();
179
180
181 $this->wpt_language_options = get_option( 'wpt_language' );
182 $this->wpt_Listing_page_options = get_option( 'wpt_Listing_page' );
183 $this->wpt_style_options = get_option( 'wpt_style' );
184 $this->wpt_tickets_options = get_option( 'wpt_tickets' );
185 $this->deprecated_options();
186
187
188 register_activation_hook( __FILE__, array($this, 'activate' ));
189 register_deactivation_hook( __FILE__, array($this, 'deactivate' ));
190
191
192 if ($wpt_version!=get_option('wpt_version')) {
193 update_option('wpt_version', $wpt_version);
194 add_action('admin_init',array($this,'update'));
195 }
196
197
198 add_action ('plugins_loaded', array($this,'do_theater_loaded_action') );
199
200 }
201
202 203 204 205 206 207 208
209 protected function define_constants() {
210 if ( ! defined( 'THEATER_PLUGIN_BASENAME' ) ) {
211 define( 'THEATER_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
212 }
213 if ( ! defined( 'THEATER_VERSION' ) ) {
214 define( 'THEATER_VERSION', $this->wpt_version );
215 }
216 }
217
218 219 220 221 222 223 224
225 function includes() {
226 require_once(dirname(__FILE__) . '/functions/abstract/class-theater-item.php');
227 require_once(dirname(__FILE__) . '/functions/abstract/class-theater-list.php');
228
229 require_once(dirname(__FILE__) . '/functions/template/wpt_template.php');
230 require_once(dirname(__FILE__) . '/functions/template/wpt_template_placeholder.php');
231 require_once(dirname(__FILE__) . '/functions/template/wpt_template_placeholder_filter.php');
232
233 require_once(dirname(__FILE__) . '/functions/event/class-theater-event.php');
234 require_once(dirname(__FILE__) . '/functions/event/class-theater-event-field.php');
235 require_once(dirname(__FILE__) . '/functions/event/class-theater-event-date.php');
236 require_once(dirname(__FILE__) . '/functions/event/class-theater-event-date-link.php');
237 require_once(dirname(__FILE__) . '/functions/event/class-theater-event-list.php');
238 require_once(dirname(__FILE__) . '/functions/event/class-theater-event-date-list.php');
239
240
241 require_once(dirname(__FILE__) . '/functions/wpt_production_permalink.php');
242 require_once(dirname(__FILE__) . '/functions/wpt_production_template.php');
243 require_once(dirname(__FILE__) . '/functions/wpt_production_widget.php');
244
245 require_once(dirname(__FILE__) . '/functions/wpt_productions_admin.php');
246 require_once(dirname(__FILE__) . '/functions/wpt_productions_list_table.php');
247
248 require_once(dirname(__FILE__) . '/functions/deprecated/class-wp-theatre.php');
249 require_once(dirname(__FILE__) . '/functions/deprecated/class-wpt-production.php');
250 require_once(dirname(__FILE__) . '/functions/deprecated/class-wpt-event.php');
251 require_once(dirname(__FILE__) . '/functions/wpt_event_admin.php');
252 require_once(dirname(__FILE__) . '/functions/wpt_event_editor.php');
253 require_once(dirname(__FILE__) . '/functions/wpt_event_template.php');
254
255 require_once(dirname(__FILE__) . '/functions/wpt_events_widget.php');
256
257 require_once(dirname(__FILE__) . '/functions/setup/class-theater-setup.php');
258 require_once(dirname(__FILE__) . '/functions/wpt_season.php');
259
260 require_once(dirname(__FILE__) . '/functions/wpt_widget.php');
261 require_once(dirname(__FILE__) . '/functions/widgets/class-theater-widgets.php');
262
263 require_once(dirname(__FILE__) . '/functions/wpt_admin.php');
264 require_once(dirname(__FILE__) . '/functions/admin/class-theater-admin-plugins.php');
265
266 require_once(dirname(__FILE__) . '/functions/wpt_order.php');
267 require_once(dirname(__FILE__) . '/functions/wpt_status.php');
268 require_once(dirname(__FILE__) . '/functions/wpt_feeds.php');
269 require_once(dirname(__FILE__) . '/functions/wpt_transient.php');
270 require_once(dirname(__FILE__) . '/functions/wpt_listing_page.php');
271 require_once(dirname(__FILE__) . '/functions/wpt_calendar.php');
272 require_once(dirname(__FILE__) . '/functions/wpt_context.php');
273 require_once(dirname(__FILE__) . '/functions/wpt_filter.php');
274 require_once(dirname(__FILE__) . '/functions/wpt_cart.php');
275 require_once(dirname(__FILE__) . '/functions/wpt_tags.php');
276
277 require_once(dirname(__FILE__) . '/functions/extensions/wpt_extensions_updater.php');
278 require_once(dirname(__FILE__) . '/functions/extensions/wpt_extensions_promo.php');
279
280 require_once(dirname(__FILE__) . '/functions/wpt_importer.php');
281
282
283 if (is_admin()) {
284 } else {
285 require_once(dirname(__FILE__) . '/functions/wpt_frontend.php');
286 }
287 require_once(dirname(__FILE__) . '/integrations/wordpress-seo.php');
288 require_once(dirname(__FILE__) . '/integrations/jetpack-featured-content.php');
289
290 }
291
292 293 294 295
296 public function seasons($PostClass = false) {
297 return $this->get_seasons($PostClass);
298 }
299
300 301 302 303 304 305 306
307 function activate() {
308 wp_schedule_event( time(), 'wpt_schedule', 'wpt_cron');
309
310
311 $this->setup->init();
312
313
314 flush_rewrite_rules();
315 }
316
317 318 319 320 321 322 323
324 function deactivate() {
325 wp_clear_scheduled_hook('wpt_cron');
326 delete_post_meta_by_key($this->order->meta_key);
327 flush_rewrite_rules();
328 }
329
330 331 332 333 334 335 336
337 function update() {
338 $this->activate();
339 }
340
341
342
343 344 345 346 347 348 349 350
351 function do_theater_loaded_action() {
352 353 354 355
356 do_action('theater/loaded');
357
358 359 360
361 do_action('wpt_loaded');
362 }
363
364 365 366
367
368 369 370
371 private function get_seasons($PostClass=false) {
372 $args = array(
373 'post_type'=>WPT_Season::post_type_name,
374 'posts_per_page' => -1,
375 'orderby' => 'title'
376 );
377
378 $posts = get_posts($args);
379
380 $seasons = array();
381 for ($i=0;$i<count($posts);$i++) {
382 $seasons[] = new WPT_Season($posts[$i], $PostClass);
383 }
384 return $seasons;
385 }
386
387
388 389 390 391
392 function compile_events($args=array()) {
393 return $this->events->html($args);
394 }
395
396 397 398 399
400 private function get_events($PostClass = false) {
401 return $this->events();
402 }
403
404 405 406 407
408 function render_events($args=array()) {
409 echo $this->compile_events($args);
410 }
411
412 413 414 415
416 private function get_productions($PostClass = false) {
417 return $this->productions();
418 }
419
420 421 422 423
424 function render_productions($args=array()) {
425 return $this->productions->html_Listing();
426 }
427
428 429 430 431 432
433
434 435 436 437
438 function deprecated_options() {
439 if (empty($this->wpt_style_options)) {
440 $this->wpt_style_options = get_option( 'theatre' );
441 }
442 if (empty($this->wpt_tickets_options)) {
443 $this->wpt_tickets_options = get_option( 'theatre' );
444 }
445 }
446
447 448 449 450
451 protected function deprecated_properties() {
452 $this->productions = new Theater_Event_List;
453 $this->events = new Theater_Event_Date_List;
454 }
455 }
456
457 458 459 460 461 462 463
464 function Theater() {
465 return Theater::instance();
466 }
467
468 Theater()->init();
469 ?>
470