Completed
Pull Request — master (#1436)
by Darren
10:07
created
modules/ticket_selector/EED_Ticket_Selector.module.php 2 patches
Indentation   +438 added lines, -438 removed lines patch added patch discarded remove patch
@@ -17,442 +17,442 @@
 block discarded – undo
17 17
 class EED_Ticket_Selector extends EED_Module
18 18
 {
19 19
 
20
-    /**
21
-     * @var DisplayTicketSelector $ticket_selector
22
-     */
23
-    private static $ticket_selector;
24
-
25
-    /**
26
-     * @var TicketSelectorIframeEmbedButton $iframe_embed_button
27
-     */
28
-    private static $iframe_embed_button;
29
-
30
-
31
-    /**
32
-     * @return EED_Module|EED_Ticket_Selector
33
-     */
34
-    public static function instance()
35
-    {
36
-        return parent::get_instance(__CLASS__);
37
-    }
38
-
39
-
40
-    /**
41
-     * @return void
42
-     */
43
-    protected function set_config()
44
-    {
45
-        $this->set_config_section('template_settings');
46
-        $this->set_config_class('EE_Ticket_Selector_Config');
47
-        $this->set_config_name('EED_Ticket_Selector');
48
-    }
49
-
50
-
51
-    /**
52
-     *    set_hooks - for hooking into EE Core, other modules, etc
53
-     *
54
-     * @return void
55
-     */
56
-    public static function set_hooks()
57
-    {
58
-        // routing
59
-        EE_Config::register_route(
60
-            'iframe',
61
-            'EED_Ticket_Selector',
62
-            'ticket_selector_iframe',
63
-            'ticket_selector'
64
-        );
65
-        EE_Config::register_route(
66
-            'process_ticket_selections',
67
-            'EED_Ticket_Selector',
68
-            'process_ticket_selections'
69
-        );
70
-        EE_Config::register_route(
71
-            'cancel_ticket_selections',
72
-            'EED_Ticket_Selector',
73
-            'cancel_ticket_selections'
74
-        );
75
-        add_action('wp_loaded', array('EED_Ticket_Selector', 'set_definitions'), 2);
76
-        add_action('AHEE_event_details_header_bottom', array('EED_Ticket_Selector', 'display_ticket_selector'), 10, 1);
77
-        add_action('wp_enqueue_scripts', array('EED_Ticket_Selector', 'translate_js_strings'), 0);
78
-        add_action('wp_enqueue_scripts', array('EED_Ticket_Selector', 'load_tckt_slctr_assets'), 10);
79
-        EED_Ticket_Selector::loadIframeAssets();
80
-    }
81
-
82
-
83
-    /**
84
-     *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
85
-     *
86
-     * @return void
87
-     */
88
-    public static function set_hooks_admin()
89
-    {
90
-        // hook into the end of the \EE_Admin_Page::_load_page_dependencies()
91
-        // to load assets for "espresso_events" page on the "edit" route (action)
92
-        add_action(
93
-            'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_events__edit',
94
-            array('EED_Ticket_Selector', 'ticket_selector_iframe_embed_button'),
95
-            10
96
-        );
97
-        /**
98
-         * Make sure assets for the ticket selector are loaded on the espresso registrations route so  admin side
99
-         * registrations work.
100
-         */
101
-        add_action(
102
-            'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_registrations__new_registration',
103
-            array('EED_Ticket_Selector', 'set_definitions'),
104
-            10
105
-        );
106
-    }
107
-
108
-
109
-    /**
110
-     *    set_definitions
111
-     *
112
-     * @return void
113
-     * @throws InvalidArgumentException
114
-     * @throws InvalidDataTypeException
115
-     * @throws InvalidInterfaceException
116
-     */
117
-    public static function set_definitions()
118
-    {
119
-        // don't do this twice
120
-        if (defined('TICKET_SELECTOR_ASSETS_URL')) {
121
-            return;
122
-        }
123
-        define('TICKET_SELECTOR_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/');
124
-        define(
125
-            'TICKET_SELECTOR_TEMPLATES_PATH',
126
-            str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/'
127
-        );
128
-        // if config is not set, initialize
129
-        if (! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config
130
-        ) {
131
-            EED_Ticket_Selector::instance()->set_config();
132
-            EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = EED_Ticket_Selector::instance(
133
-            )->config();
134
-        }
135
-    }
136
-
137
-
138
-    /**
139
-     * @return DisplayTicketSelector
140
-     */
141
-    public static function ticketSelector()
142
-    {
143
-        if (! EED_Ticket_Selector::$ticket_selector instanceof DisplayTicketSelector) {
144
-            EED_Ticket_Selector::$ticket_selector = new DisplayTicketSelector(EED_Events_Archive::is_iframe());
145
-        }
146
-        return EED_Ticket_Selector::$ticket_selector;
147
-    }
148
-
149
-
150
-    /**
151
-     * gets the ball rolling
152
-     *
153
-     * @param WP $WP
154
-     * @return void
155
-     */
156
-    public function run($WP)
157
-    {
158
-    }
159
-
160
-
161
-    /**
162
-     * @return TicketSelectorIframeEmbedButton
163
-     */
164
-    public static function getIframeEmbedButton()
165
-    {
166
-        if (! self::$iframe_embed_button instanceof TicketSelectorIframeEmbedButton) {
167
-            self::$iframe_embed_button = new TicketSelectorIframeEmbedButton();
168
-        }
169
-        return self::$iframe_embed_button;
170
-    }
171
-
172
-
173
-    /**
174
-     * ticket_selector_iframe_embed_button
175
-     *
176
-     * @return void
177
-     * @throws EE_Error
178
-     */
179
-    public static function ticket_selector_iframe_embed_button()
180
-    {
181
-        $iframe_embed_button = EED_Ticket_Selector::getIframeEmbedButton();
182
-        $iframe_embed_button->addEventEditorIframeEmbedButton();
183
-    }
184
-
185
-
186
-    /**
187
-     * ticket_selector_iframe
188
-     *
189
-     * @return void
190
-     * @throws DomainException
191
-     * @throws EE_Error
192
-     */
193
-    public function ticket_selector_iframe()
194
-    {
195
-        $ticket_selector_iframe = new TicketSelectorIframe();
196
-        $ticket_selector_iframe->display();
197
-    }
198
-
199
-
200
-    /**
201
-     * creates buttons for selecting number of attendees for an event
202
-     *
203
-     * @param  WP_Post|int $event
204
-     * @param  bool        $view_details
205
-     * @return string
206
-     * @throws EE_Error
207
-     */
208
-    public static function display_ticket_selector($event = null, $view_details = false)
209
-    {
210
-        return EED_Ticket_Selector::ticketSelector()->display($event, $view_details);
211
-    }
212
-
213
-
214
-    /**
215
-     * @return array  or FALSE
216
-     * @throws \ReflectionException
217
-     * @throws \EE_Error
218
-     * @throws InvalidArgumentException
219
-     * @throws InvalidInterfaceException
220
-     * @throws InvalidDataTypeException
221
-     */
222
-    public function process_ticket_selections()
223
-    {
224
-        /** @var EventEspresso\modules\ticket_selector\ProcessTicketSelector $form */
225
-        $form = LoaderFactory::getLoader()->getShared('EventEspresso\modules\ticket_selector\ProcessTicketSelector');
226
-        return $form->processTicketSelections();
227
-    }
228
-
229
-
230
-    /**
231
-     * @return string
232
-     * @throws InvalidArgumentException
233
-     * @throws InvalidInterfaceException
234
-     * @throws InvalidDataTypeException
235
-     * @throws EE_Error
236
-     */
237
-    public static function cancel_ticket_selections()
238
-    {
239
-        /** @var EventEspresso\modules\ticket_selector\ProcessTicketSelector $form */
240
-        $form = LoaderFactory::getLoader()->getShared('EventEspresso\modules\ticket_selector\ProcessTicketSelector');
241
-        return $form->cancelTicketSelections();
242
-    }
243
-
244
-
245
-    /**
246
-     * @return void
247
-     */
248
-    public static function translate_js_strings()
249
-    {
250
-        EE_Registry::$i18n_js_strings['please_select_date_filter_notice'] = esc_html__(
251
-            'please select a datetime',
252
-            'event_espresso'
253
-        );
254
-    }
255
-
256
-
257
-    /**
258
-     * @return void
259
-     */
260
-    public static function load_tckt_slctr_assets()
261
-    {
262
-        if (apply_filters('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', false)) {
263
-            // add some style
264
-            wp_register_style(
265
-                'ticket_selector',
266
-                TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css',
267
-                array(),
268
-                EVENT_ESPRESSO_VERSION
269
-            );
270
-            wp_enqueue_style('ticket_selector');
271
-            // make it dance
272
-            wp_register_script(
273
-                'ticket_selector',
274
-                TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js',
275
-                array('espresso_core'),
276
-                EVENT_ESPRESSO_VERSION,
277
-                true
278
-            );
279
-            wp_enqueue_script('ticket_selector');
280
-            require_once EE_LIBRARIES
281
-                         . 'form_sections/strategies/display/EE_Checkbox_Dropdown_Selector_Display_Strategy.strategy.php';
282
-            \EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts();
283
-        }
284
-    }
285
-
286
-
287
-    /**
288
-     * @return void
289
-     */
290
-    public static function loadIframeAssets()
291
-    {
292
-        // for event lists
293
-        add_filter(
294
-            'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
295
-            array('EED_Ticket_Selector', 'iframeCss')
296
-        );
297
-        add_filter(
298
-            'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js',
299
-            array('EED_Ticket_Selector', 'iframeJs')
300
-        );
301
-        // for ticket selectors
302
-        add_filter(
303
-            'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css',
304
-            array('EED_Ticket_Selector', 'iframeCss')
305
-        );
306
-        add_filter(
307
-            'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
308
-            array('EED_Ticket_Selector', 'iframeJs')
309
-        );
310
-    }
311
-
312
-
313
-    /**
314
-     * Informs the rest of the forms system what CSS and JS is needed to display the input
315
-     *
316
-     * @param array $iframe_css
317
-     * @return array
318
-     */
319
-    public static function iframeCss(array $iframe_css)
320
-    {
321
-        $iframe_css['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css';
322
-        return $iframe_css;
323
-    }
324
-
325
-
326
-    /**
327
-     * Informs the rest of the forms system what CSS and JS is needed to display the input
328
-     *
329
-     * @param array $iframe_js
330
-     * @return array
331
-     */
332
-    public static function iframeJs(array $iframe_js)
333
-    {
334
-        $iframe_js['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js';
335
-        return $iframe_js;
336
-    }
337
-
338
-
339
-    /****************************** DEPRECATED ******************************/
340
-
341
-
342
-    /**
343
-     * @deprecated
344
-     * @return string
345
-     * @throws EE_Error
346
-     */
347
-    public static function display_view_details_btn()
348
-    {
349
-        // todo add doing_it_wrong() notice during next major version
350
-        return EED_Ticket_Selector::ticketSelector()->displayViewDetailsButton();
351
-    }
352
-
353
-
354
-    /**
355
-     * @deprecated
356
-     * @return string
357
-     * @throws EE_Error
358
-     */
359
-    public static function display_ticket_selector_submit()
360
-    {
361
-        // todo add doing_it_wrong() notice during next major version
362
-        return EED_Ticket_Selector::ticketSelector()->displaySubmitButton();
363
-    }
364
-
365
-
366
-    /**
367
-     * @deprecated
368
-     * @param string $permalink_string
369
-     * @param int    $id
370
-     * @param string $new_title
371
-     * @param string $new_slug
372
-     * @return string
373
-     * @throws InvalidArgumentException
374
-     * @throws InvalidDataTypeException
375
-     * @throws InvalidInterfaceException
376
-     */
377
-    public static function iframe_code_button($permalink_string, $id, $new_title = '', $new_slug = '')
378
-    {
379
-        // todo add doing_it_wrong() notice during next major version
380
-        if (EE_Registry::instance()->REQ->get('page') === 'espresso_events'
381
-            && EE_Registry::instance()->REQ->get('action') === 'edit'
382
-        ) {
383
-            $iframe_embed_button = EED_Ticket_Selector::getIframeEmbedButton();
384
-            $iframe_embed_button->addEventEditorIframeEmbedButton();
385
-        }
386
-        return '';
387
-    }
388
-
389
-
390
-    /**
391
-     * @deprecated
392
-     * @param int    $ID
393
-     * @param string $external_url
394
-     * @return string
395
-     */
396
-    public static function ticket_selector_form_open($ID = 0, $external_url = '')
397
-    {
398
-        // todo add doing_it_wrong() notice during next major version
399
-        return EED_Ticket_Selector::ticketSelector()->formOpen($ID, $external_url);
400
-    }
401
-
402
-
403
-    /**
404
-     * @deprecated
405
-     * @return string
406
-     */
407
-    public static function ticket_selector_form_close()
408
-    {
409
-        // todo add doing_it_wrong() notice during next major version
410
-        return EED_Ticket_Selector::ticketSelector()->formClose();
411
-    }
412
-
413
-
414
-    /**
415
-     * @deprecated
416
-     * @return string
417
-     */
418
-    public static function no_tkt_slctr_end_dv()
419
-    {
420
-        // todo add doing_it_wrong() notice during next major version
421
-        return EED_Ticket_Selector::ticketSelector()->ticketSelectorEndDiv();
422
-    }
423
-
424
-
425
-    /**
426
-     * @deprecated 4.9.13
427
-     * @return string
428
-     */
429
-    public static function tkt_slctr_end_dv()
430
-    {
431
-        return EED_Ticket_Selector::ticketSelector()->clearTicketSelector();
432
-    }
433
-
434
-
435
-    /**
436
-     * @deprecated
437
-     * @return string
438
-     */
439
-    public static function clear_tkt_slctr()
440
-    {
441
-        return EED_Ticket_Selector::ticketSelector()->clearTicketSelector();
442
-    }
443
-
444
-
445
-    /**
446
-     * @deprecated
447
-     */
448
-    public static function load_tckt_slctr_assets_admin()
449
-    {
450
-        // todo add doing_it_wrong() notice during next major version
451
-        if (EE_Registry::instance()->REQ->get('page') === 'espresso_events'
452
-            && EE_Registry::instance()->REQ->get('action') === 'edit'
453
-        ) {
454
-            $iframe_embed_button = EED_Ticket_Selector::getIframeEmbedButton();
455
-            $iframe_embed_button->embedButtonAssets();
456
-        }
457
-    }
20
+	/**
21
+	 * @var DisplayTicketSelector $ticket_selector
22
+	 */
23
+	private static $ticket_selector;
24
+
25
+	/**
26
+	 * @var TicketSelectorIframeEmbedButton $iframe_embed_button
27
+	 */
28
+	private static $iframe_embed_button;
29
+
30
+
31
+	/**
32
+	 * @return EED_Module|EED_Ticket_Selector
33
+	 */
34
+	public static function instance()
35
+	{
36
+		return parent::get_instance(__CLASS__);
37
+	}
38
+
39
+
40
+	/**
41
+	 * @return void
42
+	 */
43
+	protected function set_config()
44
+	{
45
+		$this->set_config_section('template_settings');
46
+		$this->set_config_class('EE_Ticket_Selector_Config');
47
+		$this->set_config_name('EED_Ticket_Selector');
48
+	}
49
+
50
+
51
+	/**
52
+	 *    set_hooks - for hooking into EE Core, other modules, etc
53
+	 *
54
+	 * @return void
55
+	 */
56
+	public static function set_hooks()
57
+	{
58
+		// routing
59
+		EE_Config::register_route(
60
+			'iframe',
61
+			'EED_Ticket_Selector',
62
+			'ticket_selector_iframe',
63
+			'ticket_selector'
64
+		);
65
+		EE_Config::register_route(
66
+			'process_ticket_selections',
67
+			'EED_Ticket_Selector',
68
+			'process_ticket_selections'
69
+		);
70
+		EE_Config::register_route(
71
+			'cancel_ticket_selections',
72
+			'EED_Ticket_Selector',
73
+			'cancel_ticket_selections'
74
+		);
75
+		add_action('wp_loaded', array('EED_Ticket_Selector', 'set_definitions'), 2);
76
+		add_action('AHEE_event_details_header_bottom', array('EED_Ticket_Selector', 'display_ticket_selector'), 10, 1);
77
+		add_action('wp_enqueue_scripts', array('EED_Ticket_Selector', 'translate_js_strings'), 0);
78
+		add_action('wp_enqueue_scripts', array('EED_Ticket_Selector', 'load_tckt_slctr_assets'), 10);
79
+		EED_Ticket_Selector::loadIframeAssets();
80
+	}
81
+
82
+
83
+	/**
84
+	 *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
85
+	 *
86
+	 * @return void
87
+	 */
88
+	public static function set_hooks_admin()
89
+	{
90
+		// hook into the end of the \EE_Admin_Page::_load_page_dependencies()
91
+		// to load assets for "espresso_events" page on the "edit" route (action)
92
+		add_action(
93
+			'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_events__edit',
94
+			array('EED_Ticket_Selector', 'ticket_selector_iframe_embed_button'),
95
+			10
96
+		);
97
+		/**
98
+		 * Make sure assets for the ticket selector are loaded on the espresso registrations route so  admin side
99
+		 * registrations work.
100
+		 */
101
+		add_action(
102
+			'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_registrations__new_registration',
103
+			array('EED_Ticket_Selector', 'set_definitions'),
104
+			10
105
+		);
106
+	}
107
+
108
+
109
+	/**
110
+	 *    set_definitions
111
+	 *
112
+	 * @return void
113
+	 * @throws InvalidArgumentException
114
+	 * @throws InvalidDataTypeException
115
+	 * @throws InvalidInterfaceException
116
+	 */
117
+	public static function set_definitions()
118
+	{
119
+		// don't do this twice
120
+		if (defined('TICKET_SELECTOR_ASSETS_URL')) {
121
+			return;
122
+		}
123
+		define('TICKET_SELECTOR_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/');
124
+		define(
125
+			'TICKET_SELECTOR_TEMPLATES_PATH',
126
+			str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/'
127
+		);
128
+		// if config is not set, initialize
129
+		if (! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config
130
+		) {
131
+			EED_Ticket_Selector::instance()->set_config();
132
+			EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = EED_Ticket_Selector::instance(
133
+			)->config();
134
+		}
135
+	}
136
+
137
+
138
+	/**
139
+	 * @return DisplayTicketSelector
140
+	 */
141
+	public static function ticketSelector()
142
+	{
143
+		if (! EED_Ticket_Selector::$ticket_selector instanceof DisplayTicketSelector) {
144
+			EED_Ticket_Selector::$ticket_selector = new DisplayTicketSelector(EED_Events_Archive::is_iframe());
145
+		}
146
+		return EED_Ticket_Selector::$ticket_selector;
147
+	}
148
+
149
+
150
+	/**
151
+	 * gets the ball rolling
152
+	 *
153
+	 * @param WP $WP
154
+	 * @return void
155
+	 */
156
+	public function run($WP)
157
+	{
158
+	}
159
+
160
+
161
+	/**
162
+	 * @return TicketSelectorIframeEmbedButton
163
+	 */
164
+	public static function getIframeEmbedButton()
165
+	{
166
+		if (! self::$iframe_embed_button instanceof TicketSelectorIframeEmbedButton) {
167
+			self::$iframe_embed_button = new TicketSelectorIframeEmbedButton();
168
+		}
169
+		return self::$iframe_embed_button;
170
+	}
171
+
172
+
173
+	/**
174
+	 * ticket_selector_iframe_embed_button
175
+	 *
176
+	 * @return void
177
+	 * @throws EE_Error
178
+	 */
179
+	public static function ticket_selector_iframe_embed_button()
180
+	{
181
+		$iframe_embed_button = EED_Ticket_Selector::getIframeEmbedButton();
182
+		$iframe_embed_button->addEventEditorIframeEmbedButton();
183
+	}
184
+
185
+
186
+	/**
187
+	 * ticket_selector_iframe
188
+	 *
189
+	 * @return void
190
+	 * @throws DomainException
191
+	 * @throws EE_Error
192
+	 */
193
+	public function ticket_selector_iframe()
194
+	{
195
+		$ticket_selector_iframe = new TicketSelectorIframe();
196
+		$ticket_selector_iframe->display();
197
+	}
198
+
199
+
200
+	/**
201
+	 * creates buttons for selecting number of attendees for an event
202
+	 *
203
+	 * @param  WP_Post|int $event
204
+	 * @param  bool        $view_details
205
+	 * @return string
206
+	 * @throws EE_Error
207
+	 */
208
+	public static function display_ticket_selector($event = null, $view_details = false)
209
+	{
210
+		return EED_Ticket_Selector::ticketSelector()->display($event, $view_details);
211
+	}
212
+
213
+
214
+	/**
215
+	 * @return array  or FALSE
216
+	 * @throws \ReflectionException
217
+	 * @throws \EE_Error
218
+	 * @throws InvalidArgumentException
219
+	 * @throws InvalidInterfaceException
220
+	 * @throws InvalidDataTypeException
221
+	 */
222
+	public function process_ticket_selections()
223
+	{
224
+		/** @var EventEspresso\modules\ticket_selector\ProcessTicketSelector $form */
225
+		$form = LoaderFactory::getLoader()->getShared('EventEspresso\modules\ticket_selector\ProcessTicketSelector');
226
+		return $form->processTicketSelections();
227
+	}
228
+
229
+
230
+	/**
231
+	 * @return string
232
+	 * @throws InvalidArgumentException
233
+	 * @throws InvalidInterfaceException
234
+	 * @throws InvalidDataTypeException
235
+	 * @throws EE_Error
236
+	 */
237
+	public static function cancel_ticket_selections()
238
+	{
239
+		/** @var EventEspresso\modules\ticket_selector\ProcessTicketSelector $form */
240
+		$form = LoaderFactory::getLoader()->getShared('EventEspresso\modules\ticket_selector\ProcessTicketSelector');
241
+		return $form->cancelTicketSelections();
242
+	}
243
+
244
+
245
+	/**
246
+	 * @return void
247
+	 */
248
+	public static function translate_js_strings()
249
+	{
250
+		EE_Registry::$i18n_js_strings['please_select_date_filter_notice'] = esc_html__(
251
+			'please select a datetime',
252
+			'event_espresso'
253
+		);
254
+	}
255
+
256
+
257
+	/**
258
+	 * @return void
259
+	 */
260
+	public static function load_tckt_slctr_assets()
261
+	{
262
+		if (apply_filters('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', false)) {
263
+			// add some style
264
+			wp_register_style(
265
+				'ticket_selector',
266
+				TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css',
267
+				array(),
268
+				EVENT_ESPRESSO_VERSION
269
+			);
270
+			wp_enqueue_style('ticket_selector');
271
+			// make it dance
272
+			wp_register_script(
273
+				'ticket_selector',
274
+				TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js',
275
+				array('espresso_core'),
276
+				EVENT_ESPRESSO_VERSION,
277
+				true
278
+			);
279
+			wp_enqueue_script('ticket_selector');
280
+			require_once EE_LIBRARIES
281
+						 . 'form_sections/strategies/display/EE_Checkbox_Dropdown_Selector_Display_Strategy.strategy.php';
282
+			\EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts();
283
+		}
284
+	}
285
+
286
+
287
+	/**
288
+	 * @return void
289
+	 */
290
+	public static function loadIframeAssets()
291
+	{
292
+		// for event lists
293
+		add_filter(
294
+			'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
295
+			array('EED_Ticket_Selector', 'iframeCss')
296
+		);
297
+		add_filter(
298
+			'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js',
299
+			array('EED_Ticket_Selector', 'iframeJs')
300
+		);
301
+		// for ticket selectors
302
+		add_filter(
303
+			'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css',
304
+			array('EED_Ticket_Selector', 'iframeCss')
305
+		);
306
+		add_filter(
307
+			'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
308
+			array('EED_Ticket_Selector', 'iframeJs')
309
+		);
310
+	}
311
+
312
+
313
+	/**
314
+	 * Informs the rest of the forms system what CSS and JS is needed to display the input
315
+	 *
316
+	 * @param array $iframe_css
317
+	 * @return array
318
+	 */
319
+	public static function iframeCss(array $iframe_css)
320
+	{
321
+		$iframe_css['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css';
322
+		return $iframe_css;
323
+	}
324
+
325
+
326
+	/**
327
+	 * Informs the rest of the forms system what CSS and JS is needed to display the input
328
+	 *
329
+	 * @param array $iframe_js
330
+	 * @return array
331
+	 */
332
+	public static function iframeJs(array $iframe_js)
333
+	{
334
+		$iframe_js['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js';
335
+		return $iframe_js;
336
+	}
337
+
338
+
339
+	/****************************** DEPRECATED ******************************/
340
+
341
+
342
+	/**
343
+	 * @deprecated
344
+	 * @return string
345
+	 * @throws EE_Error
346
+	 */
347
+	public static function display_view_details_btn()
348
+	{
349
+		// todo add doing_it_wrong() notice during next major version
350
+		return EED_Ticket_Selector::ticketSelector()->displayViewDetailsButton();
351
+	}
352
+
353
+
354
+	/**
355
+	 * @deprecated
356
+	 * @return string
357
+	 * @throws EE_Error
358
+	 */
359
+	public static function display_ticket_selector_submit()
360
+	{
361
+		// todo add doing_it_wrong() notice during next major version
362
+		return EED_Ticket_Selector::ticketSelector()->displaySubmitButton();
363
+	}
364
+
365
+
366
+	/**
367
+	 * @deprecated
368
+	 * @param string $permalink_string
369
+	 * @param int    $id
370
+	 * @param string $new_title
371
+	 * @param string $new_slug
372
+	 * @return string
373
+	 * @throws InvalidArgumentException
374
+	 * @throws InvalidDataTypeException
375
+	 * @throws InvalidInterfaceException
376
+	 */
377
+	public static function iframe_code_button($permalink_string, $id, $new_title = '', $new_slug = '')
378
+	{
379
+		// todo add doing_it_wrong() notice during next major version
380
+		if (EE_Registry::instance()->REQ->get('page') === 'espresso_events'
381
+			&& EE_Registry::instance()->REQ->get('action') === 'edit'
382
+		) {
383
+			$iframe_embed_button = EED_Ticket_Selector::getIframeEmbedButton();
384
+			$iframe_embed_button->addEventEditorIframeEmbedButton();
385
+		}
386
+		return '';
387
+	}
388
+
389
+
390
+	/**
391
+	 * @deprecated
392
+	 * @param int    $ID
393
+	 * @param string $external_url
394
+	 * @return string
395
+	 */
396
+	public static function ticket_selector_form_open($ID = 0, $external_url = '')
397
+	{
398
+		// todo add doing_it_wrong() notice during next major version
399
+		return EED_Ticket_Selector::ticketSelector()->formOpen($ID, $external_url);
400
+	}
401
+
402
+
403
+	/**
404
+	 * @deprecated
405
+	 * @return string
406
+	 */
407
+	public static function ticket_selector_form_close()
408
+	{
409
+		// todo add doing_it_wrong() notice during next major version
410
+		return EED_Ticket_Selector::ticketSelector()->formClose();
411
+	}
412
+
413
+
414
+	/**
415
+	 * @deprecated
416
+	 * @return string
417
+	 */
418
+	public static function no_tkt_slctr_end_dv()
419
+	{
420
+		// todo add doing_it_wrong() notice during next major version
421
+		return EED_Ticket_Selector::ticketSelector()->ticketSelectorEndDiv();
422
+	}
423
+
424
+
425
+	/**
426
+	 * @deprecated 4.9.13
427
+	 * @return string
428
+	 */
429
+	public static function tkt_slctr_end_dv()
430
+	{
431
+		return EED_Ticket_Selector::ticketSelector()->clearTicketSelector();
432
+	}
433
+
434
+
435
+	/**
436
+	 * @deprecated
437
+	 * @return string
438
+	 */
439
+	public static function clear_tkt_slctr()
440
+	{
441
+		return EED_Ticket_Selector::ticketSelector()->clearTicketSelector();
442
+	}
443
+
444
+
445
+	/**
446
+	 * @deprecated
447
+	 */
448
+	public static function load_tckt_slctr_assets_admin()
449
+	{
450
+		// todo add doing_it_wrong() notice during next major version
451
+		if (EE_Registry::instance()->REQ->get('page') === 'espresso_events'
452
+			&& EE_Registry::instance()->REQ->get('action') === 'edit'
453
+		) {
454
+			$iframe_embed_button = EED_Ticket_Selector::getIframeEmbedButton();
455
+			$iframe_embed_button->embedButtonAssets();
456
+		}
457
+	}
458 458
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -120,13 +120,13 @@  discard block
 block discarded – undo
120 120
         if (defined('TICKET_SELECTOR_ASSETS_URL')) {
121 121
             return;
122 122
         }
123
-        define('TICKET_SELECTOR_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/');
123
+        define('TICKET_SELECTOR_ASSETS_URL', plugin_dir_url(__FILE__).'assets/');
124 124
         define(
125 125
             'TICKET_SELECTOR_TEMPLATES_PATH',
126
-            str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/'
126
+            str_replace('\\', '/', plugin_dir_path(__FILE__)).'templates/'
127 127
         );
128 128
         // if config is not set, initialize
129
-        if (! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config
129
+        if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config
130 130
         ) {
131 131
             EED_Ticket_Selector::instance()->set_config();
132 132
             EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = EED_Ticket_Selector::instance(
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
      */
141 141
     public static function ticketSelector()
142 142
     {
143
-        if (! EED_Ticket_Selector::$ticket_selector instanceof DisplayTicketSelector) {
143
+        if ( ! EED_Ticket_Selector::$ticket_selector instanceof DisplayTicketSelector) {
144 144
             EED_Ticket_Selector::$ticket_selector = new DisplayTicketSelector(EED_Events_Archive::is_iframe());
145 145
         }
146 146
         return EED_Ticket_Selector::$ticket_selector;
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
      */
164 164
     public static function getIframeEmbedButton()
165 165
     {
166
-        if (! self::$iframe_embed_button instanceof TicketSelectorIframeEmbedButton) {
166
+        if ( ! self::$iframe_embed_button instanceof TicketSelectorIframeEmbedButton) {
167 167
             self::$iframe_embed_button = new TicketSelectorIframeEmbedButton();
168 168
         }
169 169
         return self::$iframe_embed_button;
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
             // add some style
264 264
             wp_register_style(
265 265
                 'ticket_selector',
266
-                TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css',
266
+                TICKET_SELECTOR_ASSETS_URL.'ticket_selector.css',
267 267
                 array(),
268 268
                 EVENT_ESPRESSO_VERSION
269 269
             );
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
             // make it dance
272 272
             wp_register_script(
273 273
                 'ticket_selector',
274
-                TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js',
274
+                TICKET_SELECTOR_ASSETS_URL.'ticket_selector.js',
275 275
                 array('espresso_core'),
276 276
                 EVENT_ESPRESSO_VERSION,
277 277
                 true
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
      */
319 319
     public static function iframeCss(array $iframe_css)
320 320
     {
321
-        $iframe_css['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css';
321
+        $iframe_css['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL.'ticket_selector.css';
322 322
         return $iframe_css;
323 323
     }
324 324
 
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
      */
332 332
     public static function iframeJs(array $iframe_js)
333 333
     {
334
-        $iframe_js['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js';
334
+        $iframe_js['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL.'ticket_selector.js';
335 335
         return $iframe_js;
336 336
     }
337 337
 
Please login to merge, or discard this patch.