forked from slimndap/wp-theatre
-
Notifications
You must be signed in to change notification settings - Fork 0
/
theater.php
275 lines (213 loc) · 8.19 KB
/
theater.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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
<?php
/*
Plugin Name: Theater
Plugin URI: https://wp.theater/
Description: Turn your Wordpress website into a theater website.
Author: Jeroen Schmit
Version: 0.15.15
Author URI: http://slimndap.com/
Text Domain: theatre
Domain Path: /lang
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 2 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, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
$wpt_version = '0.15.15';
class WP_Theatre {
function __construct() {
// Set version
global $wpt_version;
$this->wpt_version = $wpt_version;
// Includes
$this->includes();
// Setup
$this->setup = new WPT_Setup();
$this->admin = new WPT_Admin();
Theater_Event_Order::init();
$this->status = new WPT_Status();
$this->feeds = new WPT_Feeds();
$this->transient = new WPT_Transient();
$this->listing_page = new WPT_Listing_Page();
Theater_Event_Archive::init();
$this->calendar = new WPT_Calendar();
$this->context = new WPT_Context();
$this->filter = new WPT_Filter();
$this->event_admin = new WPT_Event_Admin();
$this->event_editor = new WPT_Event_Editor();
$this->events = new WPT_Events();
$this->production_permalink = new WPT_Production_Permalink();
$this->productions = new WPT_Productions();
$this->productions_admin = new WPT_Productions_Admin();
$this->cart = new WPT_Cart();
$this->tags = new WPT_Tags();
$this->extensions_updater= new WPT_Extensions_Updater();
$this->extensions_promo= new WPT_Extensions_Promo();
if (is_admin()) {
} else {
$this->frontend = new WPT_Frontend();
}
// Deprecated properties
$this->order = new WPT_Order();
// Options
$this->wpt_language_options = get_option( 'wpt_language' );
$this->wpt_listing_page_options = get_option( 'wpt_listing_page' );
$this->wpt_style_options = get_option( 'wpt_style' );
$this->wpt_tickets_options = get_option( 'wpt_tickets' );
$this->deprecated_options();
// Hooks
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this->setup, 'plugin_action_links' ) );
// Plugin (de)activation hooks
register_activation_hook( __FILE__, array($this, 'activate' ));
register_deactivation_hook( __FILE__, array($this, 'deactivate' ));
// Plugin update hooks
if ($wpt_version!=get_option('wpt_version')) {
update_option('wpt_version', $wpt_version);
add_action('admin_init',array($this,'update'));
}
// Hook wpt_loaded action.
add_action ('plugins_loaded', array($this,'wpt_loaded') );
}
/**
* Include required core files used in admin and on the frontend.
*
* @access public
* @return void
*/
function includes() {
require_once(dirname(__FILE__) . '/functions/helpers/class-theater-helpers-time.php');
require_once(dirname(__FILE__) . '/functions/wpt_listing.php');
require_once(dirname(__FILE__) . '/functions/event/class-theater-event-archive.php');
require_once(dirname(__FILE__) . '/functions/event/class-theater-event-order.php');
require_once(dirname(__FILE__) . '/functions/template/wpt_template.php');
require_once(dirname(__FILE__) . '/functions/template/wpt_template_placeholder.php');
require_once(dirname(__FILE__) . '/functions/template/wpt_template_placeholder_filter.php');
require_once(dirname(__FILE__) . '/functions/wpt_production.php');
require_once(dirname(__FILE__) . '/functions/wpt_production_permalink.php');
require_once(dirname(__FILE__) . '/functions/wpt_production_template.php');
require_once(dirname(__FILE__) . '/functions/wpt_production_widget.php');
require_once(dirname(__FILE__) . '/functions/wpt_productions.php');
require_once(dirname(__FILE__) . '/functions/wpt_productions_admin.php');
require_once(dirname(__FILE__) . '/functions/wpt_productions_list_table.php');
require_once(dirname(__FILE__) . '/functions/wpt_event.php');
require_once(dirname(__FILE__) . '/functions/wpt_event_admin.php');
require_once(dirname(__FILE__) . '/functions/wpt_event_editor.php');
require_once(dirname(__FILE__) . '/functions/wpt_event_template.php');
require_once(dirname(__FILE__) . '/functions/wpt_events.php');
require_once(dirname(__FILE__) . '/functions/wpt_events_widget.php');
require_once(dirname(__FILE__) . '/functions/wpt_setup.php');
require_once(dirname(__FILE__) . '/functions/wpt_season.php');
require_once(dirname(__FILE__) . '/functions/wpt_widget.php');
require_once(dirname(__FILE__) . '/functions/wpt_admin.php');
require_once(dirname(__FILE__) . '/functions/wpt_status.php');
require_once(dirname(__FILE__) . '/functions/wpt_feeds.php');
require_once(dirname(__FILE__) . '/functions/wpt_transient.php');
require_once(dirname(__FILE__) . '/functions/wpt_listing_page.php');
require_once(dirname(__FILE__) . '/functions/wpt_calendar.php');
require_once(dirname(__FILE__) . '/functions/wpt_context.php');
require_once(dirname(__FILE__) . '/functions/wpt_filter.php');
require_once(dirname(__FILE__) . '/functions/wpt_cart.php');
require_once(dirname(__FILE__) . '/functions/wpt_tags.php');
require_once(dirname(__FILE__) . '/functions/extensions/wpt_extensions_updater.php');
require_once(dirname(__FILE__) . '/functions/extensions/wpt_extensions_promo.php');
require_once(dirname(__FILE__) . '/functions/wpt_importer.php');
if (is_admin()) {
} else {
require_once(dirname(__FILE__) . '/functions/wpt_frontend.php');
}
require_once(dirname(__FILE__) . '/integrations/wordpress-seo.php');
require_once(dirname(__FILE__) . '/integrations/jetpack-featured-content.php');
require_once(dirname(__FILE__) . '/functions/deprecated/class-wpt-order.php');
}
public function seasons($PostClass = false) {
return $this->get_seasons($PostClass);
}
function activate() {
wp_schedule_event( time(), 'wpt_schedule', 'wpt_cron');
//defines the post types so the rules can be flushed.
$this->setup->init();
//and flush the rules.
flush_rewrite_rules();
}
function deactivate() {
wp_clear_scheduled_hook('wpt_cron');
delete_post_meta_by_key($this->order->meta_key);
flush_rewrite_rules();
}
function update() {
$this->activate();
}
/**
* Fires the `wpt_loaded` action.
*
* Use this to safely load plugins that depend on Theater.
*
* @access public
* @return void
*/
function wpt_loaded() {
do_action('wpt_loaded');
}
/*
* Private functions.
*/
private function get_seasons($PostClass=false) {
$args = array(
'post_type'=>WPT_Season::post_type_name,
'posts_per_page' => -1,
'orderby' => 'title'
);
$posts = get_posts($args);
$seasons = array();
for ($i=0;$i<count($posts);$i++) {
$seasons[] = new WPT_Season($posts[$i], $PostClass);
}
return $seasons;
}
/**
* Deprecated functions.
*
* @deprecated 0.4.
*/
function compile_events($args=array()) {
return $this->events->html($args);
}
private function get_events($PostClass = false) {
return $this->events();
}
function render_events($args=array()) {
echo $this->compile_events($args);
}
private function get_productions($PostClass = false) {
return $this->productions();
}
function render_productions($args=array()) {
return $this->productions->html_listing();
}
/*
* For backward compatibility purposes
* Use old theatre options for style options and tickets options.
* As of v0.8 style options and tickets options are stored seperately.
*/
function deprecated_options() {
if (empty($this->wpt_style_options)) {
$this->wpt_style_options = get_option( 'theatre' );
}
if (empty($this->wpt_tickets_options)) {
$this->wpt_tickets_options = get_option( 'theatre' );
}
}
}
/**
* Init WP_Theatre class
*/
$wp_theatre = new WP_Theatre();
?>