Completed
Branch FET-9795-new-interfaces (793e2e)
by
unknown
121:05 queued 108:17
created
modules/bot_trap/EED_Bot_Trap.module.php 2 patches
Indentation   +292 added lines, -292 removed lines patch added patch discarded remove patch
@@ -17,323 +17,323 @@
 block discarded – undo
17 17
 {
18 18
 
19 19
 
20
-    /**
21
-     * @return EED_Bot_Trap|EED_Module
22
-     */
23
-    public static function instance()
24
-    {
25
-        return parent::get_instance(__CLASS__);
26
-    }
20
+	/**
21
+	 * @return EED_Bot_Trap|EED_Module
22
+	 */
23
+	public static function instance()
24
+	{
25
+		return parent::get_instance(__CLASS__);
26
+	}
27 27
 
28 28
 
29
-    /**
30
-     * set_hooks - for hooking into EE Core, other modules, etc
31
-     *
32
-     * @return void
33
-     */
34
-    public static function set_hooks()
35
-    {
36
-        if (
37
-            apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true) &&
38
-            \EE_Registry::instance()->CFG->registration->use_bot_trap
39
-        ) {
40
-            \EED_Bot_Trap::set_trap();
41
-            // redirect bots to bogus success page
42
-            \EE_Config::register_route('ticket_selection_received', 'EED_Bot_Trap', 'display_bot_trap_success');
43
-        }
44
-    }
29
+	/**
30
+	 * set_hooks - for hooking into EE Core, other modules, etc
31
+	 *
32
+	 * @return void
33
+	 */
34
+	public static function set_hooks()
35
+	{
36
+		if (
37
+			apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true) &&
38
+			\EE_Registry::instance()->CFG->registration->use_bot_trap
39
+		) {
40
+			\EED_Bot_Trap::set_trap();
41
+			// redirect bots to bogus success page
42
+			\EE_Config::register_route('ticket_selection_received', 'EED_Bot_Trap', 'display_bot_trap_success');
43
+		}
44
+	}
45 45
 
46 46
 
47
-    /**
48
-     * set_hooks_admin - for hooking into EE Admin Core, other modules, etc
49
-     *
50
-     * @return void
51
-     */
52
-    public static function set_trap()
53
-    {
54
-        define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__) . DS);
55
-        add_action(
56
-            'AHEE__ticket_selector_chart__template__after_ticket_selector',
57
-            array('EED_Bot_Trap', 'generate_bot_trap'),
58
-            10, 2
59
-        );
60
-        add_action(
61
-            'EED_Ticket_Selector__process_ticket_selections__before',
62
-            array('EED_Bot_Trap', 'process_bot_trap'),
63
-            1, 2
64
-        );
65
-    }
47
+	/**
48
+	 * set_hooks_admin - for hooking into EE Admin Core, other modules, etc
49
+	 *
50
+	 * @return void
51
+	 */
52
+	public static function set_trap()
53
+	{
54
+		define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__) . DS);
55
+		add_action(
56
+			'AHEE__ticket_selector_chart__template__after_ticket_selector',
57
+			array('EED_Bot_Trap', 'generate_bot_trap'),
58
+			10, 2
59
+		);
60
+		add_action(
61
+			'EED_Ticket_Selector__process_ticket_selections__before',
62
+			array('EED_Bot_Trap', 'process_bot_trap'),
63
+			1, 2
64
+		);
65
+	}
66 66
 
67 67
 
68
-    /**
69
-     * set_hooks_admin - for hooking into EE Admin Core, other modules, etc
70
-     *
71
-     * @return void
72
-     */
73
-    public static function set_hooks_admin()
74
-    {
75
-        if (
76
-            defined('DOING_AJAX')
77
-            && DOING_AJAX
78
-            && apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true)
79
-            && \EE_Registry::instance()->CFG->registration->use_bot_trap
80
-        ) {
81
-            \EED_Bot_Trap::set_trap();
82
-        }
83
-        add_action(
84
-            'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template',
85
-            array('EED_Bot_Trap', 'bot_trap_settings_form'),
86
-            5
87
-        );
88
-        add_filter(
89
-            'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration',
90
-            array('EED_Bot_Trap', 'update_bot_trap_settings_form'),
91
-            10, 1
92
-        );
93
-    }
68
+	/**
69
+	 * set_hooks_admin - for hooking into EE Admin Core, other modules, etc
70
+	 *
71
+	 * @return void
72
+	 */
73
+	public static function set_hooks_admin()
74
+	{
75
+		if (
76
+			defined('DOING_AJAX')
77
+			&& DOING_AJAX
78
+			&& apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true)
79
+			&& \EE_Registry::instance()->CFG->registration->use_bot_trap
80
+		) {
81
+			\EED_Bot_Trap::set_trap();
82
+		}
83
+		add_action(
84
+			'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template',
85
+			array('EED_Bot_Trap', 'bot_trap_settings_form'),
86
+			5
87
+		);
88
+		add_filter(
89
+			'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration',
90
+			array('EED_Bot_Trap', 'update_bot_trap_settings_form'),
91
+			10, 1
92
+		);
93
+	}
94 94
 
95 95
 
96
-    /**
97
-     * run - initial module setup
98
-     *
99
-     * @param WP $WP
100
-     * @return void
101
-     */
102
-    public function run($WP)
103
-    {
104
-    }
96
+	/**
97
+	 * run - initial module setup
98
+	 *
99
+	 * @param WP $WP
100
+	 * @return void
101
+	 */
102
+	public function run($WP)
103
+	{
104
+	}
105 105
 
106 106
 
107
-    /**
108
-     * generate_bot_trap
109
-     *
110
-     * @return void
111
-     * @throws RuntimeException
112
-     */
113
-    public static function generate_bot_trap()
114
-    {
115
-        $do_not_enter = esc_html__('please do not enter anything in this input', 'event_espresso');
116
-        $time = microtime(true);
117
-        $html = '<div class="tkt-slctr-request-processor-dv" style="float:left; margin:0 0 0 -999em; height: 0;">';
118
-        $html .= '<label for="tkt-slctr-request-processor-email-' . $time . '">' . $do_not_enter . '</label>';
119
-        $html .= '<input type="email" id="tkt-slctr-request-processor-email-';
120
-        $html .= $time . '" name="tkt-slctr-request-processor-email" value=""/>';
121
-        $html .= '<input type="hidden" name="tkt-slctr-request-processor-token" value="';
122
-        if (EE_Registry::instance()->CFG->registration->use_encryption) {
123
-            EE_Registry::instance()->load_core('EE_Encryption');
124
-            $html .= EE_Encryption::instance()->encrypt($time);
125
-        } else {
126
-            $html .= $time;
127
-        }
128
-        $html .= '"/>';
129
-        $html .= '</div><!-- .tkt-slctr-request-processor-dv -->';
130
-        echo $html;
131
-    }
107
+	/**
108
+	 * generate_bot_trap
109
+	 *
110
+	 * @return void
111
+	 * @throws RuntimeException
112
+	 */
113
+	public static function generate_bot_trap()
114
+	{
115
+		$do_not_enter = esc_html__('please do not enter anything in this input', 'event_espresso');
116
+		$time = microtime(true);
117
+		$html = '<div class="tkt-slctr-request-processor-dv" style="float:left; margin:0 0 0 -999em; height: 0;">';
118
+		$html .= '<label for="tkt-slctr-request-processor-email-' . $time . '">' . $do_not_enter . '</label>';
119
+		$html .= '<input type="email" id="tkt-slctr-request-processor-email-';
120
+		$html .= $time . '" name="tkt-slctr-request-processor-email" value=""/>';
121
+		$html .= '<input type="hidden" name="tkt-slctr-request-processor-token" value="';
122
+		if (EE_Registry::instance()->CFG->registration->use_encryption) {
123
+			EE_Registry::instance()->load_core('EE_Encryption');
124
+			$html .= EE_Encryption::instance()->encrypt($time);
125
+		} else {
126
+			$html .= $time;
127
+		}
128
+		$html .= '"/>';
129
+		$html .= '</div><!-- .tkt-slctr-request-processor-dv -->';
130
+		echo $html;
131
+	}
132 132
 
133 133
 
134
-    /**
135
-     * process_bot_trap
136
-     *
137
-     * @param array|string $triggered_trap_callback Callback that will be executed for handling the
138
-     *                                              response if the bot trap is triggered.
139
-     *                                              It should receive one argument: a boolean indicating
140
-     *                                              whether the trap was triggered by suspicious timing or not.
141
-     * @throws RuntimeException
142
-     */
143
-    public static function process_bot_trap($triggered_trap_callback = array())
144
-    {
145
-        // what's your email address Mr. Bot ?
146
-        $empty_trap = isset($_REQUEST['tkt-slctr-request-processor-email'])
147
-            && $_REQUEST['tkt-slctr-request-processor-email'] === '';
148
-        // get encrypted timestamp for when the form was originally displayed
149
-        $bot_trap_timestamp = isset($_REQUEST['tkt-slctr-request-processor-token'])
150
-            ? sanitize_text_field($_REQUEST['tkt-slctr-request-processor-token'])
151
-            : '';
152
-        // decrypt and convert to absolute  integer
153
-        if (EE_Registry::instance()->CFG->registration->use_encryption) {
154
-            EE_Registry::instance()->load_core('EE_Encryption');
155
-            $bot_trap_timestamp = absint(EE_Encryption::instance()->decrypt($bot_trap_timestamp));
156
-        } else {
157
-            $bot_trap_timestamp = absint($bot_trap_timestamp);
158
-        }
159
-        // ticket form submitted too impossibly fast ( after now ) or more than an hour later ???
160
-        $suspicious_timing = $bot_trap_timestamp > time() || $bot_trap_timestamp < (time() - HOUR_IN_SECONDS);
161
-        // are we human ?
162
-        if ($empty_trap && !$suspicious_timing) {
163
-            do_action('AHEE__EED_Bot_Trap__process_bot_trap__trap_not_triggered');
164
-            return;
165
-        }
166
-        // check the given callback is valid first before executing
167
-        if (!is_callable($triggered_trap_callback)) {
168
-            // invalid callback so lets just sub in our default.
169
-            $triggered_trap_callback = array('EED_Bot_Trap', 'triggered_trap_response');
170
-        }
171
-        call_user_func($triggered_trap_callback, $suspicious_timing);
172
-    }
134
+	/**
135
+	 * process_bot_trap
136
+	 *
137
+	 * @param array|string $triggered_trap_callback Callback that will be executed for handling the
138
+	 *                                              response if the bot trap is triggered.
139
+	 *                                              It should receive one argument: a boolean indicating
140
+	 *                                              whether the trap was triggered by suspicious timing or not.
141
+	 * @throws RuntimeException
142
+	 */
143
+	public static function process_bot_trap($triggered_trap_callback = array())
144
+	{
145
+		// what's your email address Mr. Bot ?
146
+		$empty_trap = isset($_REQUEST['tkt-slctr-request-processor-email'])
147
+			&& $_REQUEST['tkt-slctr-request-processor-email'] === '';
148
+		// get encrypted timestamp for when the form was originally displayed
149
+		$bot_trap_timestamp = isset($_REQUEST['tkt-slctr-request-processor-token'])
150
+			? sanitize_text_field($_REQUEST['tkt-slctr-request-processor-token'])
151
+			: '';
152
+		// decrypt and convert to absolute  integer
153
+		if (EE_Registry::instance()->CFG->registration->use_encryption) {
154
+			EE_Registry::instance()->load_core('EE_Encryption');
155
+			$bot_trap_timestamp = absint(EE_Encryption::instance()->decrypt($bot_trap_timestamp));
156
+		} else {
157
+			$bot_trap_timestamp = absint($bot_trap_timestamp);
158
+		}
159
+		// ticket form submitted too impossibly fast ( after now ) or more than an hour later ???
160
+		$suspicious_timing = $bot_trap_timestamp > time() || $bot_trap_timestamp < (time() - HOUR_IN_SECONDS);
161
+		// are we human ?
162
+		if ($empty_trap && !$suspicious_timing) {
163
+			do_action('AHEE__EED_Bot_Trap__process_bot_trap__trap_not_triggered');
164
+			return;
165
+		}
166
+		// check the given callback is valid first before executing
167
+		if (!is_callable($triggered_trap_callback)) {
168
+			// invalid callback so lets just sub in our default.
169
+			$triggered_trap_callback = array('EED_Bot_Trap', 'triggered_trap_response');
170
+		}
171
+		call_user_func($triggered_trap_callback, $suspicious_timing);
172
+	}
173 173
 
174 174
 
175
-    /**
176
-     * This is the default callback executed by EED_Bot_Trap::process_bot_trap that handles the response.
177
-     *
178
-     * @param bool $suspicious_timing If true, then the bot trap was triggered due to the suspicious timing test.
179
-     */
180
-    public static function triggered_trap_response($suspicious_timing)
181
-    {
182
-        // UH OH...
183
-        $redirect_url = add_query_arg(
184
-            array('ee' => 'ticket_selection_received'),
185
-            EE_Registry::instance()->CFG->core->reg_page_url()
186
-        );
187
-        if ($suspicious_timing) {
188
-            $redirect_url = add_query_arg(
189
-                array(
190
-                    'ee-notice' => urlencode(
191
-                        esc_html__(
192
-                            'We\'re sorry, but your ticket selections could not be processed due to a server timing error. Please hit the back button on your browser and try again.',
193
-                            'event_espresso'
194
-                        )
195
-                    )
196
-                ),
197
-                $redirect_url
198
-            );
199
-        }
200
-        $redirect_url = apply_filters('FHEE__EED_Bot_Trap__process_bot_trap__redirect_url', $redirect_url);
201
-        // if AJAX, return the redirect URL
202
-        if (defined('DOING_AJAX') && DOING_AJAX) {
203
-            echo wp_json_encode(
204
-                array_merge(
205
-                    EE_Error::get_notices(false),
206
-                    array(
207
-                        'redirect_url' => $redirect_url
208
-                    )
209
-                )
210
-            );
211
-            exit();
212
-        }
213
-        wp_safe_redirect($redirect_url);
214
-        exit();
215
-    }
175
+	/**
176
+	 * This is the default callback executed by EED_Bot_Trap::process_bot_trap that handles the response.
177
+	 *
178
+	 * @param bool $suspicious_timing If true, then the bot trap was triggered due to the suspicious timing test.
179
+	 */
180
+	public static function triggered_trap_response($suspicious_timing)
181
+	{
182
+		// UH OH...
183
+		$redirect_url = add_query_arg(
184
+			array('ee' => 'ticket_selection_received'),
185
+			EE_Registry::instance()->CFG->core->reg_page_url()
186
+		);
187
+		if ($suspicious_timing) {
188
+			$redirect_url = add_query_arg(
189
+				array(
190
+					'ee-notice' => urlencode(
191
+						esc_html__(
192
+							'We\'re sorry, but your ticket selections could not be processed due to a server timing error. Please hit the back button on your browser and try again.',
193
+							'event_espresso'
194
+						)
195
+					)
196
+				),
197
+				$redirect_url
198
+			);
199
+		}
200
+		$redirect_url = apply_filters('FHEE__EED_Bot_Trap__process_bot_trap__redirect_url', $redirect_url);
201
+		// if AJAX, return the redirect URL
202
+		if (defined('DOING_AJAX') && DOING_AJAX) {
203
+			echo wp_json_encode(
204
+				array_merge(
205
+					EE_Error::get_notices(false),
206
+					array(
207
+						'redirect_url' => $redirect_url
208
+					)
209
+				)
210
+			);
211
+			exit();
212
+		}
213
+		wp_safe_redirect($redirect_url);
214
+		exit();
215
+	}
216 216
 
217 217
 
218
-    /**
219
-     * display_bot_trap_success
220
-     * shows a "success" screen to bots so that they (ie: the ppl managing them)
221
-     * think the form was submitted successfully
222
-     *
223
-     * @return void
224
-     */
225
-    public static function display_bot_trap_success()
226
-    {
227
-        add_filter('FHEE__EED_Single_Page_Checkout__run', '__return_false');
228
-        $bot_notice = esc_html__(
229
-            'Thank you so much. Your ticket selections have been received for consideration.',
230
-            'event_espresso'
231
-        );
232
-        $bot_notice = isset($_REQUEST['ee-notice']) && $_REQUEST['ee-notice'] !== ''
233
-            ? sanitize_text_field(stripslashes($_REQUEST['ee-notice']))
234
-            : $bot_notice;
235
-        EE_Registry::instance()->REQ->add_output(EEH_HTML::div($bot_notice, '', 'ee-attention'));
236
-    }
218
+	/**
219
+	 * display_bot_trap_success
220
+	 * shows a "success" screen to bots so that they (ie: the ppl managing them)
221
+	 * think the form was submitted successfully
222
+	 *
223
+	 * @return void
224
+	 */
225
+	public static function display_bot_trap_success()
226
+	{
227
+		add_filter('FHEE__EED_Single_Page_Checkout__run', '__return_false');
228
+		$bot_notice = esc_html__(
229
+			'Thank you so much. Your ticket selections have been received for consideration.',
230
+			'event_espresso'
231
+		);
232
+		$bot_notice = isset($_REQUEST['ee-notice']) && $_REQUEST['ee-notice'] !== ''
233
+			? sanitize_text_field(stripslashes($_REQUEST['ee-notice']))
234
+			: $bot_notice;
235
+		EE_Registry::instance()->REQ->add_output(EEH_HTML::div($bot_notice, '', 'ee-attention'));
236
+	}
237 237
 
238 238
 
239 239
 
240
-    /***********************************    ADMIN    **********************************/
240
+	/***********************************    ADMIN    **********************************/
241 241
 
242 242
 
243
-    /**
244
-     * bot_trap_settings_form
245
-     *
246
-     * @return void
247
-     * @throws EE_Error
248
-     */
249
-    public static function bot_trap_settings_form()
250
-    {
251
-        EED_Bot_Trap::_bot_trap_settings_form()->enqueue_js();
252
-        echo EED_Bot_Trap::_bot_trap_settings_form()->get_html();
253
-    }
243
+	/**
244
+	 * bot_trap_settings_form
245
+	 *
246
+	 * @return void
247
+	 * @throws EE_Error
248
+	 */
249
+	public static function bot_trap_settings_form()
250
+	{
251
+		EED_Bot_Trap::_bot_trap_settings_form()->enqueue_js();
252
+		echo EED_Bot_Trap::_bot_trap_settings_form()->get_html();
253
+	}
254 254
 
255 255
 
256
-    /**
257
-     * _bot_trap_settings_form
258
-     *
259
-     * @return EE_Form_Section_Proper
260
-     * @throws EE_Error
261
-     */
262
-    protected static function _bot_trap_settings_form()
263
-    {
264
-        return new EE_Form_Section_Proper(
265
-            array(
266
-                'name' => 'bot_trap_settings',
267
-                'html_id' => 'bot_trap_settings',
268
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
269
-                'subsections' => array(
270
-                    'bot_trap_hdr' => new EE_Form_Section_HTML(EEH_HTML::h2(esc_html__('Bot Trap Settings', 'event_espresso'))),
271
-                    'use_bot_trap' => new EE_Yes_No_Input(
272
-                        array(
273
-                            'html_label_text' => esc_html__('Enable Bot Trap', 'event_espresso'),
274
-                            'html_help_text' => esc_html__('The Event Espresso Bot Trap will insert a fake input into your Ticket Selector forms that is hidden from regular site visitors, but visible to spam bots. Because the input asks for an email address, it is irresistible to spam bots who will of course enter text into it. Since regular site visitors can not see this input, any value detected during form submission means a bot has been detected, which will then be blocked from submitting the form.', 'event_espresso'),
275
-                            'default' => EE_Registry::instance()->CFG->registration->use_bot_trap !== null
276
-                                ? EE_Registry::instance()->CFG->registration->use_bot_trap
277
-                                : true,
278
-                            'required' => false
279
-                        )
280
-                    ),
281
-                    'use_encryption' => new EE_Yes_No_Input(
282
-                        array(
283
-                            'html_label_text' => esc_html__('Encrypt Bot Trap Data', 'event_espresso'),
284
-                            'html_help_text' => esc_html__(
285
-                                'One way to detect spam bots is by looking at how long it takes them to submit a form. They are often inhumanly fast, or will submit forms hours, days, or even weeks after the form was first scraped off the web. The Event Espresso Bot Trap will send a timestamp with the Ticket Selector form when it is submitted. By default, this timestamp is encrypted so that the spam bots can not change it, but encryption may cause issues on some servers due to configuration "conflicts". If you continuously get caught in the bot trap, then try setting this option to "No". This may increase the number of spam submissions you receive, but increases server compatibility.',
286
-                                'event_espresso'
287
-                            ),
288
-                            'default' => EE_Registry::instance()->CFG->registration->use_encryption !== null
289
-                                ? EE_Registry::instance()->CFG->registration->use_encryption
290
-                                : true,
291
-                            'required' => false
292
-                        )
293
-                    ),
294
-                )
295
-            )
296
-        );
297
-    }
256
+	/**
257
+	 * _bot_trap_settings_form
258
+	 *
259
+	 * @return EE_Form_Section_Proper
260
+	 * @throws EE_Error
261
+	 */
262
+	protected static function _bot_trap_settings_form()
263
+	{
264
+		return new EE_Form_Section_Proper(
265
+			array(
266
+				'name' => 'bot_trap_settings',
267
+				'html_id' => 'bot_trap_settings',
268
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
269
+				'subsections' => array(
270
+					'bot_trap_hdr' => new EE_Form_Section_HTML(EEH_HTML::h2(esc_html__('Bot Trap Settings', 'event_espresso'))),
271
+					'use_bot_trap' => new EE_Yes_No_Input(
272
+						array(
273
+							'html_label_text' => esc_html__('Enable Bot Trap', 'event_espresso'),
274
+							'html_help_text' => esc_html__('The Event Espresso Bot Trap will insert a fake input into your Ticket Selector forms that is hidden from regular site visitors, but visible to spam bots. Because the input asks for an email address, it is irresistible to spam bots who will of course enter text into it. Since regular site visitors can not see this input, any value detected during form submission means a bot has been detected, which will then be blocked from submitting the form.', 'event_espresso'),
275
+							'default' => EE_Registry::instance()->CFG->registration->use_bot_trap !== null
276
+								? EE_Registry::instance()->CFG->registration->use_bot_trap
277
+								: true,
278
+							'required' => false
279
+						)
280
+					),
281
+					'use_encryption' => new EE_Yes_No_Input(
282
+						array(
283
+							'html_label_text' => esc_html__('Encrypt Bot Trap Data', 'event_espresso'),
284
+							'html_help_text' => esc_html__(
285
+								'One way to detect spam bots is by looking at how long it takes them to submit a form. They are often inhumanly fast, or will submit forms hours, days, or even weeks after the form was first scraped off the web. The Event Espresso Bot Trap will send a timestamp with the Ticket Selector form when it is submitted. By default, this timestamp is encrypted so that the spam bots can not change it, but encryption may cause issues on some servers due to configuration "conflicts". If you continuously get caught in the bot trap, then try setting this option to "No". This may increase the number of spam submissions you receive, but increases server compatibility.',
286
+								'event_espresso'
287
+							),
288
+							'default' => EE_Registry::instance()->CFG->registration->use_encryption !== null
289
+								? EE_Registry::instance()->CFG->registration->use_encryption
290
+								: true,
291
+							'required' => false
292
+						)
293
+					),
294
+				)
295
+			)
296
+		);
297
+	}
298 298
 
299 299
 
300
-    /**
301
-     * update_bot_trap_settings_form
302
-     *
303
-     * @param EE_Registration_Config $EE_Registration_Config
304
-     * @return EE_Registration_Config
305
-     * @throws ReflectionException
306
-     * @throws EE_Error
307
-     */
308
-    public static function update_bot_trap_settings_form(EE_Registration_Config $EE_Registration_Config)
309
-    {
310
-        try {
311
-            $bot_trap_settings_form = EED_Bot_Trap::_bot_trap_settings_form();
312
-            // if not displaying a form, then check for form submission
313
-            if ($bot_trap_settings_form->was_submitted()) {
314
-                // capture form data
315
-                $bot_trap_settings_form->receive_form_submission();
316
-                // validate form data
317
-                if ($bot_trap_settings_form->is_valid()) {
318
-                    // grab validated data from form
319
-                    $valid_data = $bot_trap_settings_form->valid_data();
320
-                    if (isset($valid_data['use_bot_trap'], $valid_data['use_encryption'])) {
321
-                        $EE_Registration_Config->use_bot_trap = $valid_data['use_bot_trap'];
322
-                        $EE_Registration_Config->use_encryption = $valid_data['use_encryption'];
323
-                    } else {
324
-                        EE_Error::add_error(esc_html__('Invalid or missing Bot Trap settings. Please refresh the form and try again.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
325
-                    }
326
-                } else {
327
-                    if ($bot_trap_settings_form->submission_error_message() !== '') {
328
-                        EE_Error::add_error($bot_trap_settings_form->submission_error_message(), __FILE__, __FUNCTION__, __LINE__);
329
-                    }
330
-                }
331
-            }
332
-        } catch (EE_Error $e) {
333
-            $e->get_error();
334
-        }
335
-        return $EE_Registration_Config;
336
-    }
300
+	/**
301
+	 * update_bot_trap_settings_form
302
+	 *
303
+	 * @param EE_Registration_Config $EE_Registration_Config
304
+	 * @return EE_Registration_Config
305
+	 * @throws ReflectionException
306
+	 * @throws EE_Error
307
+	 */
308
+	public static function update_bot_trap_settings_form(EE_Registration_Config $EE_Registration_Config)
309
+	{
310
+		try {
311
+			$bot_trap_settings_form = EED_Bot_Trap::_bot_trap_settings_form();
312
+			// if not displaying a form, then check for form submission
313
+			if ($bot_trap_settings_form->was_submitted()) {
314
+				// capture form data
315
+				$bot_trap_settings_form->receive_form_submission();
316
+				// validate form data
317
+				if ($bot_trap_settings_form->is_valid()) {
318
+					// grab validated data from form
319
+					$valid_data = $bot_trap_settings_form->valid_data();
320
+					if (isset($valid_data['use_bot_trap'], $valid_data['use_encryption'])) {
321
+						$EE_Registration_Config->use_bot_trap = $valid_data['use_bot_trap'];
322
+						$EE_Registration_Config->use_encryption = $valid_data['use_encryption'];
323
+					} else {
324
+						EE_Error::add_error(esc_html__('Invalid or missing Bot Trap settings. Please refresh the form and try again.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
325
+					}
326
+				} else {
327
+					if ($bot_trap_settings_form->submission_error_message() !== '') {
328
+						EE_Error::add_error($bot_trap_settings_form->submission_error_message(), __FILE__, __FUNCTION__, __LINE__);
329
+					}
330
+				}
331
+			}
332
+		} catch (EE_Error $e) {
333
+			$e->get_error();
334
+		}
335
+		return $EE_Registration_Config;
336
+	}
337 337
 
338 338
 
339 339
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
      */
52 52
     public static function set_trap()
53 53
     {
54
-        define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__) . DS);
54
+        define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__).DS);
55 55
         add_action(
56 56
             'AHEE__ticket_selector_chart__template__after_ticket_selector',
57 57
             array('EED_Bot_Trap', 'generate_bot_trap'),
@@ -115,9 +115,9 @@  discard block
 block discarded – undo
115 115
         $do_not_enter = esc_html__('please do not enter anything in this input', 'event_espresso');
116 116
         $time = microtime(true);
117 117
         $html = '<div class="tkt-slctr-request-processor-dv" style="float:left; margin:0 0 0 -999em; height: 0;">';
118
-        $html .= '<label for="tkt-slctr-request-processor-email-' . $time . '">' . $do_not_enter . '</label>';
118
+        $html .= '<label for="tkt-slctr-request-processor-email-'.$time.'">'.$do_not_enter.'</label>';
119 119
         $html .= '<input type="email" id="tkt-slctr-request-processor-email-';
120
-        $html .= $time . '" name="tkt-slctr-request-processor-email" value=""/>';
120
+        $html .= $time.'" name="tkt-slctr-request-processor-email" value=""/>';
121 121
         $html .= '<input type="hidden" name="tkt-slctr-request-processor-token" value="';
122 122
         if (EE_Registry::instance()->CFG->registration->use_encryption) {
123 123
             EE_Registry::instance()->load_core('EE_Encryption');
@@ -159,12 +159,12 @@  discard block
 block discarded – undo
159 159
         // ticket form submitted too impossibly fast ( after now ) or more than an hour later ???
160 160
         $suspicious_timing = $bot_trap_timestamp > time() || $bot_trap_timestamp < (time() - HOUR_IN_SECONDS);
161 161
         // are we human ?
162
-        if ($empty_trap && !$suspicious_timing) {
162
+        if ($empty_trap && ! $suspicious_timing) {
163 163
             do_action('AHEE__EED_Bot_Trap__process_bot_trap__trap_not_triggered');
164 164
             return;
165 165
         }
166 166
         // check the given callback is valid first before executing
167
-        if (!is_callable($triggered_trap_callback)) {
167
+        if ( ! is_callable($triggered_trap_callback)) {
168 168
             // invalid callback so lets just sub in our default.
169 169
             $triggered_trap_callback = array('EED_Bot_Trap', 'triggered_trap_response');
170 170
         }
Please login to merge, or discard this patch.
caffeinated/modules/event_single_caff/EED_Event_Single_Caff.module.php 2 patches
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -118,37 +118,37 @@
 block discarded – undo
118 118
 	 * @return EE_Template_Config
119 119
 	 */
120 120
 	public static function update_template_settings( $CFG, $REQ ) {
121
-        $display_order_event = $CFG->EED_Event_Single->display_order_event !== null
122
-            ? $CFG->EED_Event_Single->display_order_event
123
-            : EED_Event_Single::EVENT_DETAILS_PRIORITY;
121
+		$display_order_event = $CFG->EED_Event_Single->display_order_event !== null
122
+			? $CFG->EED_Event_Single->display_order_event
123
+			: EED_Event_Single::EVENT_DETAILS_PRIORITY;
124 124
 		$display_order_datetimes = $CFG->EED_Event_Single->display_order_datetimes !== null
125
-            ? $CFG->EED_Event_Single->display_order_datetimes
126
-            : EED_Event_Single::EVENT_DATETIMES_PRIORITY;
127
-        $display_order_tickets = $CFG->EED_Event_Single->display_order_tickets !== null
128
-            ? $CFG->EED_Event_Single->display_order_tickets
129
-            : EED_Event_Single::EVENT_TICKETS_PRIORITY;
125
+			? $CFG->EED_Event_Single->display_order_datetimes
126
+			: EED_Event_Single::EVENT_DATETIMES_PRIORITY;
127
+		$display_order_tickets = $CFG->EED_Event_Single->display_order_tickets !== null
128
+			? $CFG->EED_Event_Single->display_order_tickets
129
+			: EED_Event_Single::EVENT_TICKETS_PRIORITY;
130 130
 		$display_order_venue = $CFG->EED_Event_Single->display_order_venue !== null
131
-            ? $CFG->EED_Event_Single->display_order_venue
132
-            : EED_Event_Single::EVENT_VENUES_PRIORITY;
131
+			? $CFG->EED_Event_Single->display_order_venue
132
+			: EED_Event_Single::EVENT_VENUES_PRIORITY;
133 133
 		$CFG->EED_Event_Single = new EE_Event_Single_Config();
134 134
 		$CFG->EED_Event_Single->display_status_banner_single = ! empty( $REQ['display_status_banner_single'] )
135
-            && $REQ['display_status_banner_single'];
135
+			&& $REQ['display_status_banner_single'];
136 136
 		$CFG->EED_Event_Single->display_venue = ! empty( $REQ['display_venue'] ) && $REQ['display_venue'];
137 137
 		$CFG->EED_Event_Single->use_sortable_display_order = ! empty( $REQ[ 'EED_Events_Single_use_sortable_display_order' ] )
138
-            ? absint( $REQ[ 'EED_Events_Single_use_sortable_display_order' ] )
139
-            : 0;
138
+			? absint( $REQ[ 'EED_Events_Single_use_sortable_display_order' ] )
139
+			: 0;
140 140
 		$CFG->EED_Event_Single->display_order_event = $CFG->EED_Event_Single->use_sortable_display_order
141
-            ? $display_order_event
142
-            : EED_Event_Single::EVENT_DETAILS_PRIORITY;
141
+			? $display_order_event
142
+			: EED_Event_Single::EVENT_DETAILS_PRIORITY;
143 143
 		$CFG->EED_Event_Single->display_order_datetimes = $CFG->EED_Event_Single->use_sortable_display_order
144
-            ? $display_order_datetimes
145
-            : EED_Event_Single::EVENT_DATETIMES_PRIORITY;
144
+			? $display_order_datetimes
145
+			: EED_Event_Single::EVENT_DATETIMES_PRIORITY;
146 146
 		$CFG->EED_Event_Single->display_order_tickets = $CFG->EED_Event_Single->use_sortable_display_order
147
-            ? $display_order_tickets
148
-            : EED_Event_Single::EVENT_TICKETS_PRIORITY;
147
+			? $display_order_tickets
148
+			: EED_Event_Single::EVENT_TICKETS_PRIORITY;
149 149
 		$CFG->EED_Event_Single->display_order_venue = $CFG->EED_Event_Single->use_sortable_display_order
150
-            ? $display_order_venue
151
-            : EED_Event_Single::EVENT_VENUES_PRIORITY;
150
+			? $display_order_venue
151
+			: EED_Event_Single::EVENT_VENUES_PRIORITY;
152 152
 		do_action( 'AHEE__EED_Event_Single__update_template_settings__after_update', $CFG, $REQ );
153 153
 		return $CFG;
154 154
 	}
Please login to merge, or discard this patch.
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	 * @return EED_Event_Single_Caff
30 30
 	 */
31 31
 	public static function instance() {
32
-		return parent::get_instance( __CLASS__ );
32
+		return parent::get_instance(__CLASS__);
33 33
 	}
34 34
 
35 35
 
@@ -50,34 +50,34 @@  discard block
 block discarded – undo
50 50
 	 *  @return 	void
51 51
 	 */
52 52
 	public static function set_hooks_admin() {
53
-		define( 'EVENT_SINGLE_CAFF_TEMPLATES_PATH', plugin_dir_path( __FILE__ ) . 'templates' . DS );
54
-		define( 'EVENT_SINGLE_CAFF_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS );
53
+		define('EVENT_SINGLE_CAFF_TEMPLATES_PATH', plugin_dir_path(__FILE__).'templates'.DS);
54
+		define('EVENT_SINGLE_CAFF_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS);
55 55
 		add_action(
56 56
 			'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_events__template_settings',
57
-			array( 'EED_Event_Single_Caff', 'load_scripts_styles' ),
57
+			array('EED_Event_Single_Caff', 'load_scripts_styles'),
58 58
 			10
59 59
 		);
60
-		add_action( 'AHEE__template_settings__template__before_settings_form', array( 'EED_Event_Single_Caff', 'template_settings_form' ), 10 );
61
-		add_filter( 'FHEE__General_Settings_Admin_Page__update_template_settings__data', array( 'EED_Event_Single_Caff', 'update_template_settings' ), 10, 2 );
60
+		add_action('AHEE__template_settings__template__before_settings_form', array('EED_Event_Single_Caff', 'template_settings_form'), 10);
61
+		add_filter('FHEE__General_Settings_Admin_Page__update_template_settings__data', array('EED_Event_Single_Caff', 'update_template_settings'), 10, 2);
62 62
 		// AJAX
63
-		add_action( 'wp_ajax_espresso_update_event_single_order', array( 'EED_Event_Single_Caff', 'update_event_single_order' ) );
64
-		add_action( 'wp_ajax_nopriv_espresso_update_event_single_order', array( 'EED_Event_Single_Caff', 'update_event_single_order' ) );
63
+		add_action('wp_ajax_espresso_update_event_single_order', array('EED_Event_Single_Caff', 'update_event_single_order'));
64
+		add_action('wp_ajax_nopriv_espresso_update_event_single_order', array('EED_Event_Single_Caff', 'update_event_single_order'));
65 65
 
66 66
 	}
67 67
 
68 68
 
69 69
 
70 70
 	public static function load_scripts_styles() {
71
-		add_action( 'admin_enqueue_scripts', array( 'EED_Event_Single_Caff', 'enqueue_scripts_styles' ), 10 );
71
+		add_action('admin_enqueue_scripts', array('EED_Event_Single_Caff', 'enqueue_scripts_styles'), 10);
72 72
 	}
73 73
 
74 74
 
75 75
 
76 76
 	public static function enqueue_scripts_styles() {
77
-		wp_register_style( 'eed-event-single-sortable', EVENT_SINGLE_CAFF_ASSETS_URL . 'eed_event_single_sortable.css', array(), EVENT_ESPRESSO_VERSION );
78
-		wp_enqueue_style( 'eed-event-single-sortable' );
79
-		wp_register_script( 'eed-event-single-sortable', EVENT_SINGLE_CAFF_ASSETS_URL . 'eed_event_single_sortable.js', array( 'jquery-ui-sortable' ), EVENT_ESPRESSO_VERSION, true );
80
-		wp_enqueue_script( 'eed-event-single-sortable' );
77
+		wp_register_style('eed-event-single-sortable', EVENT_SINGLE_CAFF_ASSETS_URL.'eed_event_single_sortable.css', array(), EVENT_ESPRESSO_VERSION);
78
+		wp_enqueue_style('eed-event-single-sortable');
79
+		wp_register_script('eed-event-single-sortable', EVENT_SINGLE_CAFF_ASSETS_URL.'eed_event_single_sortable.js', array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true);
80
+		wp_enqueue_script('eed-event-single-sortable');
81 81
 	}
82 82
 
83 83
 
@@ -91,21 +91,21 @@  discard block
 block discarded – undo
91 91
 	 */
92 92
 	public static function template_settings_form() {
93 93
 		$config = EE_Registry::instance()->CFG->template_settings;
94
-		$config = isset( $config->EED_Event_Single ) && $config->EED_Event_Single instanceof EE_Event_Single_Config ? $config->EED_Event_Single : new EE_Event_Single_Config();
95
-		$config->use_sortable_display_order = isset( $config->use_sortable_display_order ) ? $config->use_sortable_display_order : false;
96
-		$config = apply_filters( 'FHEE__EED_Event_Single__template_settings_form__event_list_config', $config );
94
+		$config = isset($config->EED_Event_Single) && $config->EED_Event_Single instanceof EE_Event_Single_Config ? $config->EED_Event_Single : new EE_Event_Single_Config();
95
+		$config->use_sortable_display_order = isset($config->use_sortable_display_order) ? $config->use_sortable_display_order : false;
96
+		$config = apply_filters('FHEE__EED_Event_Single__template_settings_form__event_list_config', $config);
97 97
 
98 98
 		$event_single_order_array = array();
99
-		$event_single_order_array[ $config->display_order_tickets ] = 'tickets';
100
-		$event_single_order_array[ $config->display_order_datetimes ] = 'datetimes';
101
-		$event_single_order_array[ $config->display_order_event ] = 'event';
102
-		$event_single_order_array[ $config->display_order_venue ] = 'venue';
99
+		$event_single_order_array[$config->display_order_tickets] = 'tickets';
100
+		$event_single_order_array[$config->display_order_datetimes] = 'datetimes';
101
+		$event_single_order_array[$config->display_order_event] = 'event';
102
+		$event_single_order_array[$config->display_order_venue] = 'venue';
103 103
 		// get template parts
104
-		$template_parts = EED_Event_Single::instance()->initialize_template_parts( $config );
104
+		$template_parts = EED_Event_Single::instance()->initialize_template_parts($config);
105 105
 		// convert to array so that we can add more properties
106
-		$config = get_object_vars( $config );
107
-		$config[ 'event_single_display_order' ] = $template_parts->generate_sortable_list_of_template_parts( 'event-single-sortable-js', '', 'single-sortable-li single-sortable-js' );
108
-		EEH_Template::display_template( EVENT_SINGLE_CAFF_TEMPLATES_PATH . 'admin-event-single-settings.template.php', $config );
106
+		$config = get_object_vars($config);
107
+		$config['event_single_display_order'] = $template_parts->generate_sortable_list_of_template_parts('event-single-sortable-js', '', 'single-sortable-li single-sortable-js');
108
+		EEH_Template::display_template(EVENT_SINGLE_CAFF_TEMPLATES_PATH.'admin-event-single-settings.template.php', $config);
109 109
 	}
110 110
 
111 111
 
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 	 * @param array $REQ
118 118
 	 * @return EE_Template_Config
119 119
 	 */
120
-	public static function update_template_settings( $CFG, $REQ ) {
120
+	public static function update_template_settings($CFG, $REQ) {
121 121
         $display_order_event = $CFG->EED_Event_Single->display_order_event !== null
122 122
             ? $CFG->EED_Event_Single->display_order_event
123 123
             : EED_Event_Single::EVENT_DETAILS_PRIORITY;
@@ -131,11 +131,11 @@  discard block
 block discarded – undo
131 131
             ? $CFG->EED_Event_Single->display_order_venue
132 132
             : EED_Event_Single::EVENT_VENUES_PRIORITY;
133 133
 		$CFG->EED_Event_Single = new EE_Event_Single_Config();
134
-		$CFG->EED_Event_Single->display_status_banner_single = ! empty( $REQ['display_status_banner_single'] )
134
+		$CFG->EED_Event_Single->display_status_banner_single = ! empty($REQ['display_status_banner_single'])
135 135
             && $REQ['display_status_banner_single'];
136
-		$CFG->EED_Event_Single->display_venue = ! empty( $REQ['display_venue'] ) && $REQ['display_venue'];
137
-		$CFG->EED_Event_Single->use_sortable_display_order = ! empty( $REQ[ 'EED_Events_Single_use_sortable_display_order' ] )
138
-            ? absint( $REQ[ 'EED_Events_Single_use_sortable_display_order' ] )
136
+		$CFG->EED_Event_Single->display_venue = ! empty($REQ['display_venue']) && $REQ['display_venue'];
137
+		$CFG->EED_Event_Single->use_sortable_display_order = ! empty($REQ['EED_Events_Single_use_sortable_display_order'])
138
+            ? absint($REQ['EED_Events_Single_use_sortable_display_order'])
139 139
             : 0;
140 140
 		$CFG->EED_Event_Single->display_order_event = $CFG->EED_Event_Single->use_sortable_display_order
141 141
             ? $display_order_event
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 		$CFG->EED_Event_Single->display_order_venue = $CFG->EED_Event_Single->use_sortable_display_order
150 150
             ? $display_order_venue
151 151
             : EED_Event_Single::EVENT_VENUES_PRIORITY;
152
-		do_action( 'AHEE__EED_Event_Single__update_template_settings__after_update', $CFG, $REQ );
152
+		do_action('AHEE__EED_Event_Single__update_template_settings__after_update', $CFG, $REQ);
153 153
 		return $CFG;
154 154
 	}
155 155
 
@@ -163,23 +163,23 @@  discard block
 block discarded – undo
163 163
 	 */
164 164
 	public static function update_event_single_order() {
165 165
 		$config_saved = false;
166
-		$template_parts = sanitize_text_field( $_POST[ 'elements' ] );
167
-		if ( ! empty( $template_parts ) ) {
168
-			$template_parts = explode( ',', trim( $template_parts, ',' ) );
169
-			foreach ( $template_parts as $key => $template_part ) {
166
+		$template_parts = sanitize_text_field($_POST['elements']);
167
+		if ( ! empty($template_parts)) {
168
+			$template_parts = explode(',', trim($template_parts, ','));
169
+			foreach ($template_parts as $key => $template_part) {
170 170
 				$template_part = "display_order_$template_part";
171
-				$priority = ( $key * 10 ) + EED_Event_Single::EVENT_DETAILS_PRIORITY;
171
+				$priority = ($key * 10) + EED_Event_Single::EVENT_DETAILS_PRIORITY;
172 172
 				EE_Registry::instance()->CFG->template_settings->EED_Event_Single->{$template_part} = $priority;
173
-				do_action( "AHEE__EED_Event_Single__update_event_single_order__$template_part", $priority );
173
+				do_action("AHEE__EED_Event_Single__update_event_single_order__$template_part", $priority);
174 174
 			}
175
-			$config_saved = EE_Registry::instance()->CFG->update_espresso_config( false, false );
175
+			$config_saved = EE_Registry::instance()->CFG->update_espresso_config(false, false);
176 176
 		}
177
-		if ( $config_saved ) {
178
-			EE_Error::add_success( __( 'Display Order has been successfully updated.', 'event_espresso' ) );
177
+		if ($config_saved) {
178
+			EE_Error::add_success(__('Display Order has been successfully updated.', 'event_espresso'));
179 179
 		} else {
180
-			EE_Error::add_error( __( 'Display Order was not updated.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
180
+			EE_Error::add_error(__('Display Order was not updated.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
181 181
 		}
182
-		echo wp_json_encode( EE_Error::get_notices( false ));
182
+		echo wp_json_encode(EE_Error::get_notices(false));
183 183
 		exit();
184 184
 	}
185 185
 
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 	 * @param WP $WP
193 193
 	 * @return    void
194 194
 	 */
195
-	public function run( $WP ) {
195
+	public function run($WP) {
196 196
 	}
197 197
 
198 198
 
Please login to merge, or discard this patch.
caffeinated/modules/events_archive_caff/EED_Events_Archive_Caff.module.php 2 patches
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -86,52 +86,52 @@  discard block
 block discarded – undo
86 86
 		$gen_set_admin = EE_Registry::instance()->LIB->EE_Admin_Page_Loader->get_admin_page_object( 'general_settings' );
87 87
 		if ( $gen_set_admin instanceof General_Settings_Admin_Page ) {
88 88
 			remove_action(
89
-			    'AHEE__template_settings__template__before_settings_form',
90
-                array( $gen_set_admin, 'template_settings_caff_features' ),
91
-                100
92
-            );
89
+				'AHEE__template_settings__template__before_settings_form',
90
+				array( $gen_set_admin, 'template_settings_caff_features' ),
91
+				100
92
+			);
93 93
 		}
94 94
 		// first just grab the template settings
95 95
 		$config = EE_Registry::instance()->CFG->template_settings;
96 96
 		// then if the Event Archive config is valid, use that, else create a new one
97 97
 		$config = isset( $config->EED_Events_Archive ) && $config->EED_Events_Archive instanceof EE_Events_Archive_Config
98
-            ? $config->EED_Events_Archive
99
-            : new EE_Events_Archive_Config();
98
+			? $config->EED_Events_Archive
99
+			: new EE_Events_Archive_Config();
100 100
 		$config = apply_filters( 'FHEE__EED_Events_Archive__template_settings_form__event_list_config', $config );
101 101
 		$config->display_status_banner = isset( $config->display_status_banner )
102
-            ? $config->display_status_banner
103
-            : 0;
102
+			? $config->display_status_banner
103
+			: 0;
104 104
 		$config->display_description = isset( $config->display_description )
105
-            ? $config->display_description
106
-            : 1;
105
+			? $config->display_description
106
+			: 1;
107 107
 		$config->display_ticket_selector = isset( $config->display_ticket_selector )
108
-            ? $config->display_ticket_selector
109
-            : 0;
108
+			? $config->display_ticket_selector
109
+			: 0;
110 110
 		$config->display_datetimes = isset( $config->display_datetimes )
111
-            ? $config->display_datetimes
112
-            : 1;
111
+			? $config->display_datetimes
112
+			: 1;
113 113
 		$config->display_venue = isset( $config->display_venue )
114
-            ? $config->display_venue
115
-            : 0;
114
+			? $config->display_venue
115
+			: 0;
116 116
 		$config->display_expired_events = isset( $config->display_expired_events )
117
-            ? $config->display_expired_events
118
-            : 0;
117
+			? $config->display_expired_events
118
+			: 0;
119 119
 		// display order options
120 120
 		$config->use_sortable_display_order = isset( $config->use_sortable_display_order  )
121
-            ? $config->use_sortable_display_order
122
-            : false;
121
+			? $config->use_sortable_display_order
122
+			: false;
123 123
 		$config->display_order_tickets = isset( $config->display_order_tickets  )
124
-            ? $config->display_order_tickets
125
-            : 120;
124
+			? $config->display_order_tickets
125
+			: 120;
126 126
 		$config->display_order_datetimes = isset( $config->display_order_datetimes  )
127
-            ? $config->display_order_datetimes
128
-            : 110;
127
+			? $config->display_order_datetimes
128
+			: 110;
129 129
 		$config->display_order_event = isset( $config->display_order_event  )
130
-            ? $config->display_order_event
131
-            : 100;
130
+			? $config->display_order_event
131
+			: 100;
132 132
 		$config->display_order_venue = isset( $config->display_order_venue  )
133
-            ? $config->display_order_venue
134
-            : 130;
133
+			? $config->display_order_venue
134
+			: 130;
135 135
 		// get template parts
136 136
 		$template_parts = EED_Events_Archive::instance()->initialize_template_parts( $config );
137 137
 		// convert to array so that we can add more properties
@@ -165,17 +165,17 @@  discard block
 block discarded – undo
165 165
 			$config->display_expired_events = isset( $REQ['EED_Events_Archive_display_expired_events'] ) ? absint( $REQ['EED_Events_Archive_display_expired_events'] ) : 0;
166 166
 			$config->use_sortable_display_order = isset( $REQ['EED_Events_Archive_use_sortable_display_order'] ) ? absint( $REQ['EED_Events_Archive_use_sortable_display_order'] ) : 0;
167 167
 			$config->display_order_event = isset( $CFG->EED_Events_Archive->display_order_event ) && $config->use_sortable_display_order
168
-                ? $CFG->EED_Events_Archive->display_order_event
169
-                : EED_Events_Archive::EVENT_DETAILS_PRIORITY;
168
+				? $CFG->EED_Events_Archive->display_order_event
169
+				: EED_Events_Archive::EVENT_DETAILS_PRIORITY;
170 170
 			$config->display_order_datetimes = isset( $CFG->EED_Events_Archive->display_order_datetimes ) && $config->use_sortable_display_order
171
-                ? $CFG->EED_Events_Archive->display_order_datetimes
172
-                : EED_Events_Archive::EVENT_DATETIMES_PRIORITY;
171
+				? $CFG->EED_Events_Archive->display_order_datetimes
172
+				: EED_Events_Archive::EVENT_DATETIMES_PRIORITY;
173 173
 			$config->display_order_tickets = isset( $CFG->EED_Events_Archive->display_order_tickets ) && $config->use_sortable_display_order
174
-                ? $CFG->EED_Events_Archive->display_order_tickets
175
-                : EED_Events_Archive::EVENT_TICKETS_PRIORITY;
174
+				? $CFG->EED_Events_Archive->display_order_tickets
175
+				: EED_Events_Archive::EVENT_TICKETS_PRIORITY;
176 176
 			$config->display_order_venue = isset( $CFG->EED_Events_Archive->display_order_venue ) && $config->use_sortable_display_order
177
-                ? $CFG->EED_Events_Archive->display_order_venue
178
-                : EED_Events_Archive::EVENT_VENUES_PRIORITY;
177
+				? $CFG->EED_Events_Archive->display_order_venue
178
+				: EED_Events_Archive::EVENT_VENUES_PRIORITY;
179 179
 		}
180 180
 		$CFG->EED_Events_Archive = $config;
181 181
 		do_action( 'AHEE__EED_Events_Archive__update_template_settings__after_update', $CFG, $REQ );
Please login to merge, or discard this patch.
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 * @return EED_Events_Archive_Caff
29 29
 	 */
30 30
 	public static function instance() {
31
-		return parent::get_instance( __CLASS__ );
31
+		return parent::get_instance(__CLASS__);
32 32
 	}
33 33
 
34 34
 
@@ -49,13 +49,13 @@  discard block
 block discarded – undo
49 49
 	 *  @return 	void
50 50
 	 */
51 51
 	public static function set_hooks_admin() {
52
-		define( 'EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH', str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS );
53
-		define( 'EVENT_ARCHIVE_CAFF_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS );
54
-		add_action( 'AHEE__template_settings__template__before_settings_form', array( 'EED_Events_Archive_Caff', 'template_settings_form' ), 10 );
55
-		add_filter( 'FHEE__General_Settings_Admin_Page__update_template_settings__data', array( 'EED_Events_Archive_Caff', 'update_template_settings' ), 10, 2 );
52
+		define('EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS);
53
+		define('EVENT_ARCHIVE_CAFF_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS);
54
+		add_action('AHEE__template_settings__template__before_settings_form', array('EED_Events_Archive_Caff', 'template_settings_form'), 10);
55
+		add_filter('FHEE__General_Settings_Admin_Page__update_template_settings__data', array('EED_Events_Archive_Caff', 'update_template_settings'), 10, 2);
56 56
 		// AJAX
57
-		add_action( 'wp_ajax_espresso_update_event_archive_order', array( 'EED_Events_Archive_Caff', 'update_event_archive_order' ) );
58
-		add_action( 'wp_ajax_nopriv_espresso_update_event_archive_order', array( 'EED_Events_Archive_Caff', 'update_event_archive_order' ) );
57
+		add_action('wp_ajax_espresso_update_event_archive_order', array('EED_Events_Archive_Caff', 'update_event_archive_order'));
58
+		add_action('wp_ajax_nopriv_espresso_update_event_archive_order', array('EED_Events_Archive_Caff', 'update_event_archive_order'));
59 59
 	}
60 60
 
61 61
 
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	 * @param    WP $WP
69 69
 	 * @return    void
70 70
 	 */
71
-	public function run( $WP ) {
71
+	public function run($WP) {
72 72
 	}
73 73
 
74 74
 
@@ -83,61 +83,61 @@  discard block
 block discarded – undo
83 83
 	 */
84 84
 	public static function template_settings_form() {
85 85
 		// grab general settings admin page and remove the existing hook callback
86
-		$gen_set_admin = EE_Registry::instance()->LIB->EE_Admin_Page_Loader->get_admin_page_object( 'general_settings' );
87
-		if ( $gen_set_admin instanceof General_Settings_Admin_Page ) {
86
+		$gen_set_admin = EE_Registry::instance()->LIB->EE_Admin_Page_Loader->get_admin_page_object('general_settings');
87
+		if ($gen_set_admin instanceof General_Settings_Admin_Page) {
88 88
 			remove_action(
89 89
 			    'AHEE__template_settings__template__before_settings_form',
90
-                array( $gen_set_admin, 'template_settings_caff_features' ),
90
+                array($gen_set_admin, 'template_settings_caff_features'),
91 91
                 100
92 92
             );
93 93
 		}
94 94
 		// first just grab the template settings
95 95
 		$config = EE_Registry::instance()->CFG->template_settings;
96 96
 		// then if the Event Archive config is valid, use that, else create a new one
97
-		$config = isset( $config->EED_Events_Archive ) && $config->EED_Events_Archive instanceof EE_Events_Archive_Config
97
+		$config = isset($config->EED_Events_Archive) && $config->EED_Events_Archive instanceof EE_Events_Archive_Config
98 98
             ? $config->EED_Events_Archive
99 99
             : new EE_Events_Archive_Config();
100
-		$config = apply_filters( 'FHEE__EED_Events_Archive__template_settings_form__event_list_config', $config );
101
-		$config->display_status_banner = isset( $config->display_status_banner )
100
+		$config = apply_filters('FHEE__EED_Events_Archive__template_settings_form__event_list_config', $config);
101
+		$config->display_status_banner = isset($config->display_status_banner)
102 102
             ? $config->display_status_banner
103 103
             : 0;
104
-		$config->display_description = isset( $config->display_description )
104
+		$config->display_description = isset($config->display_description)
105 105
             ? $config->display_description
106 106
             : 1;
107
-		$config->display_ticket_selector = isset( $config->display_ticket_selector )
107
+		$config->display_ticket_selector = isset($config->display_ticket_selector)
108 108
             ? $config->display_ticket_selector
109 109
             : 0;
110
-		$config->display_datetimes = isset( $config->display_datetimes )
110
+		$config->display_datetimes = isset($config->display_datetimes)
111 111
             ? $config->display_datetimes
112 112
             : 1;
113
-		$config->display_venue = isset( $config->display_venue )
113
+		$config->display_venue = isset($config->display_venue)
114 114
             ? $config->display_venue
115 115
             : 0;
116
-		$config->display_expired_events = isset( $config->display_expired_events )
116
+		$config->display_expired_events = isset($config->display_expired_events)
117 117
             ? $config->display_expired_events
118 118
             : 0;
119 119
 		// display order options
120
-		$config->use_sortable_display_order = isset( $config->use_sortable_display_order  )
120
+		$config->use_sortable_display_order = isset($config->use_sortable_display_order)
121 121
             ? $config->use_sortable_display_order
122 122
             : false;
123
-		$config->display_order_tickets = isset( $config->display_order_tickets  )
123
+		$config->display_order_tickets = isset($config->display_order_tickets)
124 124
             ? $config->display_order_tickets
125 125
             : 120;
126
-		$config->display_order_datetimes = isset( $config->display_order_datetimes  )
126
+		$config->display_order_datetimes = isset($config->display_order_datetimes)
127 127
             ? $config->display_order_datetimes
128 128
             : 110;
129
-		$config->display_order_event = isset( $config->display_order_event  )
129
+		$config->display_order_event = isset($config->display_order_event)
130 130
             ? $config->display_order_event
131 131
             : 100;
132
-		$config->display_order_venue = isset( $config->display_order_venue  )
132
+		$config->display_order_venue = isset($config->display_order_venue)
133 133
             ? $config->display_order_venue
134 134
             : 130;
135 135
 		// get template parts
136
-		$template_parts = EED_Events_Archive::instance()->initialize_template_parts( $config );
136
+		$template_parts = EED_Events_Archive::instance()->initialize_template_parts($config);
137 137
 		// convert to array so that we can add more properties
138
-		$config = get_object_vars( $config );
139
-		$config[ 'event_archive_display_order' ] = $template_parts->generate_sortable_list_of_template_parts( 'event-archive-sortable-js', '', 'archive-sortable-li archive-sortable-js' );
140
-		EEH_Template::display_template( EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH . 'admin-event-list-settings.template.php', $config );
138
+		$config = get_object_vars($config);
139
+		$config['event_archive_display_order'] = $template_parts->generate_sortable_list_of_template_parts('event-archive-sortable-js', '', 'archive-sortable-li archive-sortable-js');
140
+		EEH_Template::display_template(EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH.'admin-event-list-settings.template.php', $config);
141 141
 	}
142 142
 
143 143
 
@@ -153,32 +153,32 @@  discard block
 block discarded – undo
153 153
 	 *  @param 	array $REQ
154 154
 	 *  @return    EE_Events_Archive_Config
155 155
 	 */
156
-	public static function update_template_settings( $CFG, $REQ ) {
156
+	public static function update_template_settings($CFG, $REQ) {
157 157
 		$config = new EE_Events_Archive_Config();
158 158
 		// unless we are resetting the config...
159
-		if ( ! isset( $REQ['EED_Events_Archive_reset_event_list_settings'] ) || absint( $REQ['EED_Events_Archive_reset_event_list_settings'] ) !== 1 ) {
160
-			$config->display_status_banner = isset( $REQ['EED_Events_Archive_display_status_banner'] ) ? absint( $REQ['EED_Events_Archive_display_status_banner'] ) : 0;
161
-			$config->display_description = isset( $REQ['EED_Events_Archive_display_description'] ) ? absint( $REQ['EED_Events_Archive_display_description'] ) : 1;
162
-			$config->display_ticket_selector = isset( $REQ['EED_Events_Archive_display_ticket_selector'] ) ? absint( $REQ['EED_Events_Archive_display_ticket_selector'] ) : 0;
163
-			$config->display_datetimes = isset( $REQ['EED_Events_Archive_display_datetimes'] ) ? absint( $REQ['EED_Events_Archive_display_datetimes'] ) : 1;
164
-			$config->display_venue = isset( $REQ['EED_Events_Archive_display_venue'] ) ? absint( $REQ['EED_Events_Archive_display_venue'] ) : 0;
165
-			$config->display_expired_events = isset( $REQ['EED_Events_Archive_display_expired_events'] ) ? absint( $REQ['EED_Events_Archive_display_expired_events'] ) : 0;
166
-			$config->use_sortable_display_order = isset( $REQ['EED_Events_Archive_use_sortable_display_order'] ) ? absint( $REQ['EED_Events_Archive_use_sortable_display_order'] ) : 0;
167
-			$config->display_order_event = isset( $CFG->EED_Events_Archive->display_order_event ) && $config->use_sortable_display_order
159
+		if ( ! isset($REQ['EED_Events_Archive_reset_event_list_settings']) || absint($REQ['EED_Events_Archive_reset_event_list_settings']) !== 1) {
160
+			$config->display_status_banner = isset($REQ['EED_Events_Archive_display_status_banner']) ? absint($REQ['EED_Events_Archive_display_status_banner']) : 0;
161
+			$config->display_description = isset($REQ['EED_Events_Archive_display_description']) ? absint($REQ['EED_Events_Archive_display_description']) : 1;
162
+			$config->display_ticket_selector = isset($REQ['EED_Events_Archive_display_ticket_selector']) ? absint($REQ['EED_Events_Archive_display_ticket_selector']) : 0;
163
+			$config->display_datetimes = isset($REQ['EED_Events_Archive_display_datetimes']) ? absint($REQ['EED_Events_Archive_display_datetimes']) : 1;
164
+			$config->display_venue = isset($REQ['EED_Events_Archive_display_venue']) ? absint($REQ['EED_Events_Archive_display_venue']) : 0;
165
+			$config->display_expired_events = isset($REQ['EED_Events_Archive_display_expired_events']) ? absint($REQ['EED_Events_Archive_display_expired_events']) : 0;
166
+			$config->use_sortable_display_order = isset($REQ['EED_Events_Archive_use_sortable_display_order']) ? absint($REQ['EED_Events_Archive_use_sortable_display_order']) : 0;
167
+			$config->display_order_event = isset($CFG->EED_Events_Archive->display_order_event) && $config->use_sortable_display_order
168 168
                 ? $CFG->EED_Events_Archive->display_order_event
169 169
                 : EED_Events_Archive::EVENT_DETAILS_PRIORITY;
170
-			$config->display_order_datetimes = isset( $CFG->EED_Events_Archive->display_order_datetimes ) && $config->use_sortable_display_order
170
+			$config->display_order_datetimes = isset($CFG->EED_Events_Archive->display_order_datetimes) && $config->use_sortable_display_order
171 171
                 ? $CFG->EED_Events_Archive->display_order_datetimes
172 172
                 : EED_Events_Archive::EVENT_DATETIMES_PRIORITY;
173
-			$config->display_order_tickets = isset( $CFG->EED_Events_Archive->display_order_tickets ) && $config->use_sortable_display_order
173
+			$config->display_order_tickets = isset($CFG->EED_Events_Archive->display_order_tickets) && $config->use_sortable_display_order
174 174
                 ? $CFG->EED_Events_Archive->display_order_tickets
175 175
                 : EED_Events_Archive::EVENT_TICKETS_PRIORITY;
176
-			$config->display_order_venue = isset( $CFG->EED_Events_Archive->display_order_venue ) && $config->use_sortable_display_order
176
+			$config->display_order_venue = isset($CFG->EED_Events_Archive->display_order_venue) && $config->use_sortable_display_order
177 177
                 ? $CFG->EED_Events_Archive->display_order_venue
178 178
                 : EED_Events_Archive::EVENT_VENUES_PRIORITY;
179 179
 		}
180 180
 		$CFG->EED_Events_Archive = $config;
181
-		do_action( 'AHEE__EED_Events_Archive__update_template_settings__after_update', $CFG, $REQ );
181
+		do_action('AHEE__EED_Events_Archive__update_template_settings__after_update', $CFG, $REQ);
182 182
 		return $CFG;
183 183
 	}
184 184
 
@@ -192,12 +192,12 @@  discard block
 block discarded – undo
192 192
 	 */
193 193
 	public static function update_event_archive_order() {
194 194
 		$config_saved = false;
195
-		$template_parts = sanitize_text_field( $_POST[ 'elements' ] );
196
-		if ( ! empty( $template_parts ) ) {
197
-			$template_parts = explode( ',', trim( $template_parts, ',' ) );
198
-			foreach ( $template_parts as $key => $template_part ) {
195
+		$template_parts = sanitize_text_field($_POST['elements']);
196
+		if ( ! empty($template_parts)) {
197
+			$template_parts = explode(',', trim($template_parts, ','));
198
+			foreach ($template_parts as $key => $template_part) {
199 199
 				$template_part = "display_order_$template_part";
200
-				$priority = ( $key * 10 ) + EED_Events_Archive::EVENT_DETAILS_PRIORITY;
200
+				$priority = ($key * 10) + EED_Events_Archive::EVENT_DETAILS_PRIORITY;
201 201
 				if (
202 202
 					property_exists(
203 203
 						EE_Registry::instance()->CFG->template_settings->EED_Events_Archive,
@@ -206,16 +206,16 @@  discard block
 block discarded – undo
206 206
 				) {
207 207
 					EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->{$template_part} = $priority;
208 208
 				}
209
-				do_action( "AHEE__EED_Events_Archive__update_event_archive_order__$template_part", $priority );
209
+				do_action("AHEE__EED_Events_Archive__update_event_archive_order__$template_part", $priority);
210 210
 			}
211
-			$config_saved = EE_Registry::instance()->CFG->update_espresso_config( false, false );
211
+			$config_saved = EE_Registry::instance()->CFG->update_espresso_config(false, false);
212 212
 		}
213
-		if ( $config_saved ) {
214
-			EE_Error::add_success( __( 'Display Order has been successfully updated.', 'event_espresso' ) );
213
+		if ($config_saved) {
214
+			EE_Error::add_success(__('Display Order has been successfully updated.', 'event_espresso'));
215 215
 		} else {
216
-			EE_Error::add_error( __( 'Display Order was not updated.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
216
+			EE_Error::add_error(__('Display Order was not updated.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
217 217
 		}
218
-		echo wp_json_encode( EE_Error::get_notices( false ) );
218
+		echo wp_json_encode(EE_Error::get_notices(false));
219 219
 		exit();
220 220
 	}
221 221
 
Please login to merge, or discard this patch.
core/libraries/template_parts/EE_Template_Part_Manager.class.php 2 patches
Indentation   +193 added lines, -193 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 //namespace EventEspresso\core\libraries\templates;
3 3
 if (!defined('EVENT_ESPRESSO_VERSION')) {
4
-    exit('No direct script access allowed');
4
+	exit('No direct script access allowed');
5 5
 }
6 6
 
7 7
 
@@ -19,198 +19,198 @@  discard block
 block discarded – undo
19 19
 class EE_Template_Part_Manager
20 20
 {
21 21
 
22
-    /**
23
-     * @param EE_Template_Part_PriorityQueue $template_parts
24
-     */
25
-    protected $template_parts;
26
-
27
-    /**
28
-     * @param array $priorities
29
-     */
30
-    protected $priorities = array();
31
-
32
-    /**
33
-     * @param int $event_desc_priority
34
-     */
35
-    protected $event_desc_priority;
36
-
37
-    /**
38
-     * @param string $before_event_content
39
-     */
40
-    protected $before_event_content;
41
-
42
-    /**
43
-     * @param string $event_content
44
-     */
45
-    protected $event_content;
46
-
47
-    /**
48
-     * @param string $after_event_content
49
-     */
50
-    protected $after_event_content;
51
-
52
-
53
-    /**
54
-     *    class constructor
55
-     */
56
-    public function __construct()
57
-    {
58
-        $this->template_parts = new EE_Template_Part_PriorityQueue();
59
-    }
60
-
61
-
62
-    /**
63
-     *    add_template_part
64
-     *
65
-     *    used for setting the details about a particular template part
66
-     *
67
-     * @param string $name - just a simple string identifier - do NOT use 'event'
68
-     * @param string $label - template part label displayed in admin
69
-     * @param string $template - name or path of template to be used by EEH_Template::locate_template()
70
-     * @param int $priority - order in which template parts should be applied
71
-     */
72
-    public function add_template_part($name, $label, $template, $priority)
73
-    {
74
-        // SplPriorityQueue doesn't play nice with multiple items having the same priority
75
-        // so if the incoming priority is already occupied, then let's increment it by one,
76
-        // and then pass everything back into this method and try again with the new priority
77
-        if (isset($this->priorities[$priority])) {
78
-            $priority++;
79
-            $this->add_template_part($name, $label, $template, $priority);
80
-            return;
81
-        }
82
-        // kk now we can mark this priority as being occupied
83
-        $this->priorities[$priority] = true;
84
-        // create the template part and add to the queue
85
-        $this->template_parts->insert(
86
-            new EE_Template_Part($name, $label, $template, $priority),
87
-            $priority
88
-        );
89
-        if ($name === 'event') {
90
-            $this->event_desc_priority = $priority;
91
-        }
92
-    }
93
-
94
-
95
-    /**
96
-     *    apply_template_part_filters
97
-     *
98
-     *    adds template parts to the supplied content
99
-     *    according to the details set when the template parts were added
100
-     *
101
-     * @access public
102
-     * @param string $content
103
-     * @return string
104
-     */
105
-    public function apply_template_part_filters($content = '')
106
-    {
107
-        $this->template_parts->rewind();
108
-        // loop through template parts and position content
109
-        while ($this->template_parts->valid()) {
110
-            $this->_position_template_part(
111
-                $content,
112
-                $this->template_parts->current()->template(),
113
-                $this->template_parts->current()->priority()
114
-            );
115
-            $this->template_parts->next();
116
-        }
117
-        // now simply add our three strings of content together
118
-        return $this->before_event_content . $this->event_content . $this->after_event_content;
119
-    }
120
-
121
-
122
-    /**
123
-     *    position_template_part
124
-     *
125
-     * based on the priority of the incoming template part
126
-     * relative to the known event description template part priority,
127
-     * this method will assign template parts to one of the following:
128
-     *        $this->before_event_content
129
-     *        $this->event_content
130
-     *        $this->after_event_content
131
-     *
132
-     * @access protected
133
-     * @param string $content
134
-     * @param string $template
135
-     * @param int $priority
136
-     * @return void
137
-     */
138
-    protected function _position_template_part($content, $template, $priority)
139
-    {
140
-        // Event Description content is the actual incoming content itself
141
-        if ($priority === $this->event_desc_priority) {
142
-            $this->event_content = $content;
143
-        } else if ($priority < $this->event_desc_priority) {
144
-            // everything BEFORE the Event Description
145
-            $this->before_event_content .= EEH_Template::locate_template($template);
146
-        } else if ($priority > $this->event_desc_priority) {
147
-            // everything AFTER the Event Description
148
-            $this->after_event_content .= EEH_Template::locate_template($template);
149
-        }
150
-    }
151
-
152
-
153
-    /**
154
-     *    generate_sortable_list_of_template_parts
155
-     *
156
-     *    creates an HTML list (<ul>) with list items (<li>) for each template part,
157
-     *    in a format that can be used as a sortable list in the admin
158
-     *
159
-     * @access public
160
-     * @param string $list_css_id
161
-     * @param string $list_css_class
162
-     * @param string $list_item_css_class
163
-     * @param string $list_item_css_id_prefix
164
-     * @return string
165
-     */
166
-    public function generate_sortable_list_of_template_parts(
167
-        $list_css_id = '',
168
-        $list_css_class = '',
169
-        $list_item_css_class = '',
170
-        $list_item_css_id_prefix = ''
171
-    )
172
-    {
173
-        $event_archive_display_order = EEH_HTML::ul($list_css_id, $list_css_class);
174
-        $this->template_parts->rewind();
175
-        // loop through template parts and add template content
176
-        while ($this->template_parts->valid()) {
177
-            $event_archive_display_order .= EEH_HTML::li(
178
-                EEH_HTML::span('', '', 'dashicons dashicons-arrow-up-alt2') .
179
-                EEH_HTML::span('', '', 'dashicons dashicons-arrow-down-alt2') .
180
-                $this->template_parts->current()->label(),
181
-                $list_item_css_id_prefix . $this->template_parts->current()->name(),
182
-                $list_item_css_class
183
-            );
184
-            $this->template_parts->next();
185
-        }
186
-        $event_archive_display_order .= EEH_HTML::ulx();
187
-        return $event_archive_display_order;
188
-    }
189
-
190
-
191
-    /**
192
-     *    display_template_parts
193
-     *
194
-     * just for debugging purposes
195
-     *
196
-     * @access    public
197
-     * @return void
198
-     */
199
-    public function display_template_parts()
200
-    {
201
-        if (WP_DEBUG) {
202
-            $this->template_parts->rewind();
203
-            while ($this->template_parts->valid()) {
204
-                EEH_Debug_Tools::printr(
205
-                    $this->template_parts->current(),
206
-                    'template_part',
207
-                    __FILE__,
208
-                    __LINE__
209
-                );
210
-                $this->template_parts->next();
211
-            }
212
-        }
213
-    }
22
+	/**
23
+	 * @param EE_Template_Part_PriorityQueue $template_parts
24
+	 */
25
+	protected $template_parts;
26
+
27
+	/**
28
+	 * @param array $priorities
29
+	 */
30
+	protected $priorities = array();
31
+
32
+	/**
33
+	 * @param int $event_desc_priority
34
+	 */
35
+	protected $event_desc_priority;
36
+
37
+	/**
38
+	 * @param string $before_event_content
39
+	 */
40
+	protected $before_event_content;
41
+
42
+	/**
43
+	 * @param string $event_content
44
+	 */
45
+	protected $event_content;
46
+
47
+	/**
48
+	 * @param string $after_event_content
49
+	 */
50
+	protected $after_event_content;
51
+
52
+
53
+	/**
54
+	 *    class constructor
55
+	 */
56
+	public function __construct()
57
+	{
58
+		$this->template_parts = new EE_Template_Part_PriorityQueue();
59
+	}
60
+
61
+
62
+	/**
63
+	 *    add_template_part
64
+	 *
65
+	 *    used for setting the details about a particular template part
66
+	 *
67
+	 * @param string $name - just a simple string identifier - do NOT use 'event'
68
+	 * @param string $label - template part label displayed in admin
69
+	 * @param string $template - name or path of template to be used by EEH_Template::locate_template()
70
+	 * @param int $priority - order in which template parts should be applied
71
+	 */
72
+	public function add_template_part($name, $label, $template, $priority)
73
+	{
74
+		// SplPriorityQueue doesn't play nice with multiple items having the same priority
75
+		// so if the incoming priority is already occupied, then let's increment it by one,
76
+		// and then pass everything back into this method and try again with the new priority
77
+		if (isset($this->priorities[$priority])) {
78
+			$priority++;
79
+			$this->add_template_part($name, $label, $template, $priority);
80
+			return;
81
+		}
82
+		// kk now we can mark this priority as being occupied
83
+		$this->priorities[$priority] = true;
84
+		// create the template part and add to the queue
85
+		$this->template_parts->insert(
86
+			new EE_Template_Part($name, $label, $template, $priority),
87
+			$priority
88
+		);
89
+		if ($name === 'event') {
90
+			$this->event_desc_priority = $priority;
91
+		}
92
+	}
93
+
94
+
95
+	/**
96
+	 *    apply_template_part_filters
97
+	 *
98
+	 *    adds template parts to the supplied content
99
+	 *    according to the details set when the template parts were added
100
+	 *
101
+	 * @access public
102
+	 * @param string $content
103
+	 * @return string
104
+	 */
105
+	public function apply_template_part_filters($content = '')
106
+	{
107
+		$this->template_parts->rewind();
108
+		// loop through template parts and position content
109
+		while ($this->template_parts->valid()) {
110
+			$this->_position_template_part(
111
+				$content,
112
+				$this->template_parts->current()->template(),
113
+				$this->template_parts->current()->priority()
114
+			);
115
+			$this->template_parts->next();
116
+		}
117
+		// now simply add our three strings of content together
118
+		return $this->before_event_content . $this->event_content . $this->after_event_content;
119
+	}
120
+
121
+
122
+	/**
123
+	 *    position_template_part
124
+	 *
125
+	 * based on the priority of the incoming template part
126
+	 * relative to the known event description template part priority,
127
+	 * this method will assign template parts to one of the following:
128
+	 *        $this->before_event_content
129
+	 *        $this->event_content
130
+	 *        $this->after_event_content
131
+	 *
132
+	 * @access protected
133
+	 * @param string $content
134
+	 * @param string $template
135
+	 * @param int $priority
136
+	 * @return void
137
+	 */
138
+	protected function _position_template_part($content, $template, $priority)
139
+	{
140
+		// Event Description content is the actual incoming content itself
141
+		if ($priority === $this->event_desc_priority) {
142
+			$this->event_content = $content;
143
+		} else if ($priority < $this->event_desc_priority) {
144
+			// everything BEFORE the Event Description
145
+			$this->before_event_content .= EEH_Template::locate_template($template);
146
+		} else if ($priority > $this->event_desc_priority) {
147
+			// everything AFTER the Event Description
148
+			$this->after_event_content .= EEH_Template::locate_template($template);
149
+		}
150
+	}
151
+
152
+
153
+	/**
154
+	 *    generate_sortable_list_of_template_parts
155
+	 *
156
+	 *    creates an HTML list (<ul>) with list items (<li>) for each template part,
157
+	 *    in a format that can be used as a sortable list in the admin
158
+	 *
159
+	 * @access public
160
+	 * @param string $list_css_id
161
+	 * @param string $list_css_class
162
+	 * @param string $list_item_css_class
163
+	 * @param string $list_item_css_id_prefix
164
+	 * @return string
165
+	 */
166
+	public function generate_sortable_list_of_template_parts(
167
+		$list_css_id = '',
168
+		$list_css_class = '',
169
+		$list_item_css_class = '',
170
+		$list_item_css_id_prefix = ''
171
+	)
172
+	{
173
+		$event_archive_display_order = EEH_HTML::ul($list_css_id, $list_css_class);
174
+		$this->template_parts->rewind();
175
+		// loop through template parts and add template content
176
+		while ($this->template_parts->valid()) {
177
+			$event_archive_display_order .= EEH_HTML::li(
178
+				EEH_HTML::span('', '', 'dashicons dashicons-arrow-up-alt2') .
179
+				EEH_HTML::span('', '', 'dashicons dashicons-arrow-down-alt2') .
180
+				$this->template_parts->current()->label(),
181
+				$list_item_css_id_prefix . $this->template_parts->current()->name(),
182
+				$list_item_css_class
183
+			);
184
+			$this->template_parts->next();
185
+		}
186
+		$event_archive_display_order .= EEH_HTML::ulx();
187
+		return $event_archive_display_order;
188
+	}
189
+
190
+
191
+	/**
192
+	 *    display_template_parts
193
+	 *
194
+	 * just for debugging purposes
195
+	 *
196
+	 * @access    public
197
+	 * @return void
198
+	 */
199
+	public function display_template_parts()
200
+	{
201
+		if (WP_DEBUG) {
202
+			$this->template_parts->rewind();
203
+			while ($this->template_parts->valid()) {
204
+				EEH_Debug_Tools::printr(
205
+					$this->template_parts->current(),
206
+					'template_part',
207
+					__FILE__,
208
+					__LINE__
209
+				);
210
+				$this->template_parts->next();
211
+			}
212
+		}
213
+	}
214 214
 }
215 215
 // End of file EE_Template_Part_Manager.class.php
216 216
 // Location: /EE_Template_Part_Manager.class.php
217 217
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 //namespace EventEspresso\core\libraries\templates;
3
-if (!defined('EVENT_ESPRESSO_VERSION')) {
3
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
4 4
     exit('No direct script access allowed');
5 5
 }
6 6
 
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
             $this->template_parts->next();
116 116
         }
117 117
         // now simply add our three strings of content together
118
-        return $this->before_event_content . $this->event_content . $this->after_event_content;
118
+        return $this->before_event_content.$this->event_content.$this->after_event_content;
119 119
     }
120 120
 
121 121
 
@@ -175,10 +175,10 @@  discard block
 block discarded – undo
175 175
         // loop through template parts and add template content
176 176
         while ($this->template_parts->valid()) {
177 177
             $event_archive_display_order .= EEH_HTML::li(
178
-                EEH_HTML::span('', '', 'dashicons dashicons-arrow-up-alt2') .
179
-                EEH_HTML::span('', '', 'dashicons dashicons-arrow-down-alt2') .
178
+                EEH_HTML::span('', '', 'dashicons dashicons-arrow-up-alt2').
179
+                EEH_HTML::span('', '', 'dashicons dashicons-arrow-down-alt2').
180 180
                 $this->template_parts->current()->label(),
181
-                $list_item_css_id_prefix . $this->template_parts->current()->name(),
181
+                $list_item_css_id_prefix.$this->template_parts->current()->name(),
182 182
                 $list_item_css_class
183 183
             );
184 184
             $this->template_parts->next();
Please login to merge, or discard this patch.
core/EE_Configurable.core.php 2 patches
Indentation   +139 added lines, -139 removed lines patch added patch discarded remove patch
@@ -12,145 +12,145 @@
 block discarded – undo
12 12
 abstract class EE_Configurable extends EE_Base
13 13
 {
14 14
 
15
-    /**
16
-     * @var $_config
17
-     * @type EE_Config_Base
18
-     */
19
-    protected $_config;
20
-
21
-    /**
22
-     * @var $_config_section
23
-     * @type string
24
-     */
25
-    protected $_config_section = '';
26
-
27
-    /**
28
-     * @var $_config_class
29
-     * @type string
30
-     */
31
-    protected $_config_class = '';
32
-
33
-    /**
34
-     * @var $_config_name
35
-     * @type string
36
-     */
37
-    protected $_config_name = '';
38
-
39
-
40
-    /**
41
-     * @param string $config_section
42
-     */
43
-    public function set_config_section($config_section = '')
44
-    {
45
-        $this->_config_section = !empty($config_section) ? $config_section : 'modules';
46
-    }
47
-
48
-
49
-    /**
50
-     * @return mixed
51
-     */
52
-    public function config_section()
53
-    {
54
-        return $this->_config_section;
55
-    }
56
-
57
-
58
-    /**
59
-     * @param string $config_class
60
-     */
61
-    public function set_config_class($config_class = '')
62
-    {
63
-        $this->_config_class = $config_class;
64
-    }
65
-
66
-
67
-    /**
68
-     * @return mixed
69
-     */
70
-    public function config_class()
71
-    {
72
-        return $this->_config_class;
73
-    }
74
-
75
-
76
-    /**
77
-     * @param mixed $config_name
78
-     */
79
-    public function set_config_name($config_name)
80
-    {
81
-        $this->_config_name = !empty($config_name) ? $config_name : get_called_class();
82
-    }
83
-
84
-
85
-    /**
86
-     * @return mixed
87
-     */
88
-    public function config_name()
89
-    {
90
-        return $this->_config_name;
91
-    }
92
-
93
-
94
-    /**
95
-     *    set_config
96
-     *    this method integrates directly with EE_Config to set up the config object for this class
97
-     *
98
-     * @access    protected
99
-     * @param    EE_Config_Base $config_obj
100
-     * @return    mixed    EE_Config_Base | NULL
101
-     */
102
-    protected function _set_config(EE_Config_Base $config_obj = null)
103
-    {
104
-        return EE_Config::instance()->set_config(
105
-            $this->config_section(),
106
-            $this->config_name(),
107
-            $this->config_class(),
108
-            $config_obj
109
-        );
110
-    }
111
-
112
-
113
-    /**
114
-     *    _update_config
115
-     *    this method integrates directly with EE_Config to update an existing config object for this class
116
-     *
117
-     * @access    protected
118
-     * @param    EE_Config_Base $config_obj
119
-     * @throws \EE_Error
120
-     * @return    mixed    EE_Config_Base | NULL
121
-     */
122
-    public function _update_config(EE_Config_Base $config_obj = null)
123
-    {
124
-        $config_class = $this->config_class();
125
-        if (!$config_obj instanceof $config_class) {
126
-            throw new EE_Error(
127
-                sprintf(
128
-                    __('The "%1$s" class is not an instance of %2$s.', 'event_espresso'),
129
-                    print_r($config_obj, true),
130
-                    $config_class
131
-                )
132
-            );
133
-        }
134
-        return EE_Config::instance()->update_config($this->config_section(), $this->config_name(), $config_obj);
135
-    }
136
-
137
-
138
-    /**
139
-     * gets the class's config object
140
-     *
141
-     * @return EE_Config_Base
142
-     */
143
-    public function config()
144
-    {
145
-        if (empty($this->_config)) {
146
-            $this->_config = EE_Config::instance()->get_config(
147
-                $this->config_section(),
148
-                $this->config_name(),
149
-                $this->config_class()
150
-            );
151
-        }
152
-        return $this->_config;
153
-    }
15
+	/**
16
+	 * @var $_config
17
+	 * @type EE_Config_Base
18
+	 */
19
+	protected $_config;
20
+
21
+	/**
22
+	 * @var $_config_section
23
+	 * @type string
24
+	 */
25
+	protected $_config_section = '';
26
+
27
+	/**
28
+	 * @var $_config_class
29
+	 * @type string
30
+	 */
31
+	protected $_config_class = '';
32
+
33
+	/**
34
+	 * @var $_config_name
35
+	 * @type string
36
+	 */
37
+	protected $_config_name = '';
38
+
39
+
40
+	/**
41
+	 * @param string $config_section
42
+	 */
43
+	public function set_config_section($config_section = '')
44
+	{
45
+		$this->_config_section = !empty($config_section) ? $config_section : 'modules';
46
+	}
47
+
48
+
49
+	/**
50
+	 * @return mixed
51
+	 */
52
+	public function config_section()
53
+	{
54
+		return $this->_config_section;
55
+	}
56
+
57
+
58
+	/**
59
+	 * @param string $config_class
60
+	 */
61
+	public function set_config_class($config_class = '')
62
+	{
63
+		$this->_config_class = $config_class;
64
+	}
65
+
66
+
67
+	/**
68
+	 * @return mixed
69
+	 */
70
+	public function config_class()
71
+	{
72
+		return $this->_config_class;
73
+	}
74
+
75
+
76
+	/**
77
+	 * @param mixed $config_name
78
+	 */
79
+	public function set_config_name($config_name)
80
+	{
81
+		$this->_config_name = !empty($config_name) ? $config_name : get_called_class();
82
+	}
83
+
84
+
85
+	/**
86
+	 * @return mixed
87
+	 */
88
+	public function config_name()
89
+	{
90
+		return $this->_config_name;
91
+	}
92
+
93
+
94
+	/**
95
+	 *    set_config
96
+	 *    this method integrates directly with EE_Config to set up the config object for this class
97
+	 *
98
+	 * @access    protected
99
+	 * @param    EE_Config_Base $config_obj
100
+	 * @return    mixed    EE_Config_Base | NULL
101
+	 */
102
+	protected function _set_config(EE_Config_Base $config_obj = null)
103
+	{
104
+		return EE_Config::instance()->set_config(
105
+			$this->config_section(),
106
+			$this->config_name(),
107
+			$this->config_class(),
108
+			$config_obj
109
+		);
110
+	}
111
+
112
+
113
+	/**
114
+	 *    _update_config
115
+	 *    this method integrates directly with EE_Config to update an existing config object for this class
116
+	 *
117
+	 * @access    protected
118
+	 * @param    EE_Config_Base $config_obj
119
+	 * @throws \EE_Error
120
+	 * @return    mixed    EE_Config_Base | NULL
121
+	 */
122
+	public function _update_config(EE_Config_Base $config_obj = null)
123
+	{
124
+		$config_class = $this->config_class();
125
+		if (!$config_obj instanceof $config_class) {
126
+			throw new EE_Error(
127
+				sprintf(
128
+					__('The "%1$s" class is not an instance of %2$s.', 'event_espresso'),
129
+					print_r($config_obj, true),
130
+					$config_class
131
+				)
132
+			);
133
+		}
134
+		return EE_Config::instance()->update_config($this->config_section(), $this->config_name(), $config_obj);
135
+	}
136
+
137
+
138
+	/**
139
+	 * gets the class's config object
140
+	 *
141
+	 * @return EE_Config_Base
142
+	 */
143
+	public function config()
144
+	{
145
+		if (empty($this->_config)) {
146
+			$this->_config = EE_Config::instance()->get_config(
147
+				$this->config_section(),
148
+				$this->config_name(),
149
+				$this->config_class()
150
+			);
151
+		}
152
+		return $this->_config;
153
+	}
154 154
 
155 155
 
156 156
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
      */
43 43
     public function set_config_section($config_section = '')
44 44
     {
45
-        $this->_config_section = !empty($config_section) ? $config_section : 'modules';
45
+        $this->_config_section = ! empty($config_section) ? $config_section : 'modules';
46 46
     }
47 47
 
48 48
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
      */
79 79
     public function set_config_name($config_name)
80 80
     {
81
-        $this->_config_name = !empty($config_name) ? $config_name : get_called_class();
81
+        $this->_config_name = ! empty($config_name) ? $config_name : get_called_class();
82 82
     }
83 83
 
84 84
 
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
     public function _update_config(EE_Config_Base $config_obj = null)
123 123
     {
124 124
         $config_class = $this->config_class();
125
-        if (!$config_obj instanceof $config_class) {
125
+        if ( ! $config_obj instanceof $config_class) {
126 126
             throw new EE_Error(
127 127
                 sprintf(
128 128
                     __('The "%1$s" class is not an instance of %2$s.', 'event_espresso'),
Please login to merge, or discard this patch.
modules/events_archive/EED_Events_Archive.module.php 2 patches
Indentation   +172 added lines, -172 removed lines patch added patch discarded remove patch
@@ -14,13 +14,13 @@  discard block
 block discarded – undo
14 14
  */
15 15
 class EED_Events_Archive  extends EED_Module {
16 16
 
17
-    const EVENT_DETAILS_PRIORITY = 100;
18
-    const EVENT_DATETIMES_PRIORITY = 110;
19
-    const EVENT_TICKETS_PRIORITY = 120;
20
-    const EVENT_VENUES_PRIORITY = 130;
17
+	const EVENT_DETAILS_PRIORITY = 100;
18
+	const EVENT_DATETIMES_PRIORITY = 110;
19
+	const EVENT_TICKETS_PRIORITY = 120;
20
+	const EVENT_VENUES_PRIORITY = 130;
21 21
 
22 22
 
23
-    public static $espresso_event_list_ID = 0;
23
+	public static $espresso_event_list_ID = 0;
24 24
 	public static $espresso_grid_event_lists = array();
25 25
 
26 26
 	/**
@@ -28,19 +28,19 @@  discard block
 block discarded – undo
28 28
 	 */
29 29
 	protected static $using_get_the_excerpt = false;
30 30
 
31
-    /**
32
-     * Used to flag when the event list is being called from an external iframe.
33
-     *
34
-     * @var bool $iframe
35
-     */
36
-    protected static $iframe = false;
31
+	/**
32
+	 * Used to flag when the event list is being called from an external iframe.
33
+	 *
34
+	 * @var bool $iframe
35
+	 */
36
+	protected static $iframe = false;
37 37
 
38
-    /**
38
+	/**
39 39
 	 * @var \EventEspresso\core\libraries\iframe_display\EventListIframeEmbedButton $_iframe_embed_button
40 40
 	 */
41 41
 	private static $_iframe_embed_button;
42 42
 
43
-    /**
43
+	/**
44 44
 	 * @type EE_Template_Part_Manager $template_parts
45 45
 	 */
46 46
 	protected $template_parts;
@@ -210,9 +210,9 @@  discard block
 block discarded – undo
210 210
 
211 211
 
212 212
 	/**
213
-     * most likely called by the ESPRESSO_EVENTS shortcode which uses this module to do some of it's lifting
214
-     *
215
-     * @return    void
213
+	 * most likely called by the ESPRESSO_EVENTS shortcode which uses this module to do some of it's lifting
214
+	 *
215
+	 * @return    void
216 216
 	 */
217 217
 	public function event_list() {
218 218
 		// ensure valid EE_Events_Archive_Config() object exists
@@ -223,36 +223,36 @@  discard block
 block discarded – undo
223 223
 
224 224
 
225 225
 
226
-    /**
227
-     * @access    public
228
-     * @return    void
229
-     * @throws \EE_Error
230
-     * @throws \DomainException
231
-     */
226
+	/**
227
+	 * @access    public
228
+	 * @return    void
229
+	 * @throws \EE_Error
230
+	 * @throws \DomainException
231
+	 */
232 232
 	public function event_list_iframe() {
233
-        \EED_Events_Archive::$iframe = true;
233
+		\EED_Events_Archive::$iframe = true;
234 234
 		$event_list_iframe = new EventsArchiveIframe( $this );
235 235
 		$event_list_iframe->display();
236 236
 	}
237 237
 
238 238
 
239 239
 
240
-    /**
241
-     * @access public
242
-     * @return string
243
-     */
240
+	/**
241
+	 * @access public
242
+	 * @return string
243
+	 */
244 244
 	public static function is_iframe() {
245
-        return \EED_Events_Archive::$iframe;
245
+		return \EED_Events_Archive::$iframe;
246 246
 	}
247 247
 
248 248
 
249 249
 
250
-    /**
251
-     * @access public
252
-     * @return string
253
-     */
250
+	/**
251
+	 * @access public
252
+	 * @return string
253
+	 */
254 254
 	public static function link_target() {
255
-        return \EED_Events_Archive::$iframe ? ' target="_blank"' : '';
255
+		return \EED_Events_Archive::$iframe ? ' target="_blank"' : '';
256 256
 	}
257 257
 
258 258
 
@@ -280,10 +280,10 @@  discard block
 block discarded – undo
280 280
 			}
281 281
 			// if NOT a custom template
282 282
 			if (
283
-                apply_filters('FHEE__EED_Event_Archive__template_include__allow_custom_selected_template', false)
283
+				apply_filters('FHEE__EED_Event_Archive__template_include__allow_custom_selected_template', false)
284 284
 				|| EE_Registry::instance()
285
-                    ->load_core( 'Front_Controller' )
286
-                    ->get_selected_template() !== 'archive-espresso_events.php'
285
+					->load_core( 'Front_Controller' )
286
+					->get_selected_template() !== 'archive-espresso_events.php'
287 287
 			) {
288 288
 				// don't display entry meta because the existing theme will take care of that
289 289
 				add_filter( 'FHEE__EED_Events_Archive__template_include__events_list_active', '__return_true' );
@@ -291,16 +291,16 @@  discard block
 block discarded – undo
291 291
 				EEH_Template::load_espresso_theme_functions();
292 292
 				// because we don't know if the theme is using the_excerpt()
293 293
 				add_filter(
294
-				    'the_excerpt',
295
-                    array( 'EED_Events_Archive', 'event_details' ),
296
-                    EED_Events_Archive::EVENT_DETAILS_PRIORITY
297
-                );
294
+					'the_excerpt',
295
+					array( 'EED_Events_Archive', 'event_details' ),
296
+					EED_Events_Archive::EVENT_DETAILS_PRIORITY
297
+				);
298 298
 				// or the_content
299 299
 				add_filter(
300
-				    'the_content',
301
-                    array( 'EED_Events_Archive', 'event_details' ),
302
-                    EED_Events_Archive::EVENT_DETAILS_PRIORITY
303
-                );
300
+					'the_content',
301
+					array( 'EED_Events_Archive', 'event_details' ),
302
+					EED_Events_Archive::EVENT_DETAILS_PRIORITY
303
+				);
304 304
 				// and just in case they are running get_the_excerpt() which DESTROYS things
305 305
 				add_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1, 1 );
306 306
 				// don't display entry meta because the existing theme will take care of that
@@ -325,15 +325,15 @@  discard block
 block discarded – undo
325 325
 		}
326 326
 		if ( apply_filters( 'FHEE__EED_Events_Archive__get_the_excerpt__theme_uses_get_the_excerpt', false ) ) {
327 327
 			remove_filter(
328
-			    'the_excerpt',
329
-                array( 'EED_Events_Archive', 'event_details' ),
330
-                EED_Events_Archive::EVENT_DETAILS_PRIORITY
331
-            );
328
+				'the_excerpt',
329
+				array( 'EED_Events_Archive', 'event_details' ),
330
+				EED_Events_Archive::EVENT_DETAILS_PRIORITY
331
+			);
332 332
 			remove_filter(
333
-			    'the_content',
334
-                array( 'EED_Events_Archive', 'event_details' ),
335
-                EED_Events_Archive::EVENT_DETAILS_PRIORITY
336
-            );
333
+				'the_content',
334
+				array( 'EED_Events_Archive', 'event_details' ),
335
+				EED_Events_Archive::EVENT_DETAILS_PRIORITY
336
+			);
337 337
 			$excerpt = EED_Events_Archive::event_details( $excerpt );
338 338
 		} else {
339 339
 			EED_Events_Archive::$using_get_the_excerpt = true;
@@ -424,17 +424,17 @@  discard block
 block discarded – undo
424 424
 		// no further password checks required atm
425 425
 		add_filter( 'FHEE__EED_Events_Archive__event_details__no_post_password_required', '__return_true' );
426 426
 		// we need to first remove this callback from being applied to the_content() or the_excerpt()
427
-        // (otherwise it will recurse and blow up the interweb)
427
+		// (otherwise it will recurse and blow up the interweb)
428 428
 		remove_filter(
429
-		    'the_excerpt',
430
-            array( 'EED_Events_Archive', 'event_details' ),
431
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
432
-        );
429
+			'the_excerpt',
430
+			array( 'EED_Events_Archive', 'event_details' ),
431
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
432
+		);
433 433
 		remove_filter(
434
-		    'the_content',
435
-            array( 'EED_Events_Archive', 'event_details' ),
436
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
437
-        );
434
+			'the_content',
435
+			array( 'EED_Events_Archive', 'event_details' ),
436
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
437
+		);
438 438
 		remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 );
439 439
 		// now add additional content depending on whether event is using the_excerpt() or the_content()
440 440
 		EED_Events_Archive::instance()->template_parts = EED_Events_Archive::instance()->initialize_template_parts();
@@ -442,20 +442,20 @@  discard block
 block discarded – undo
442 442
 		$content = EED_Events_Archive::instance()->template_parts->apply_template_part_filters( $content );
443 443
 		// re-add our main filters (or else the next event won't have them)
444 444
 		add_filter(
445
-		    'the_excerpt',
446
-            array( 'EED_Events_Archive', 'event_details' ),
447
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
448
-        );
445
+			'the_excerpt',
446
+			array( 'EED_Events_Archive', 'event_details' ),
447
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
448
+		);
449 449
 		add_filter(
450
-		    'the_content',
451
-            array( 'EED_Events_Archive', 'event_details' ),
452
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
453
-        );
450
+			'the_content',
451
+			array( 'EED_Events_Archive', 'event_details' ),
452
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
453
+		);
454 454
 		add_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1, 1 );
455 455
 		remove_filter(
456
-		    'FHEE__EED_Events_Archive__event_details__no_post_password_required',
457
-            '__return_true'
458
-        );
456
+			'FHEE__EED_Events_Archive__event_details__no_post_password_required',
457
+			'__return_true'
458
+		);
459 459
 		return $content;
460 460
 	}
461 461
 
@@ -471,15 +471,15 @@  discard block
 block discarded – undo
471 471
 		// we need to first remove this callback from being applied to the_content()
472 472
 		// (otherwise it will recurse and blow up the interweb)
473 473
 		remove_filter(
474
-		    'the_excerpt',
475
-            array( 'EED_Events_Archive', 'event_details' ),
476
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
477
-        );
474
+			'the_excerpt',
475
+			array( 'EED_Events_Archive', 'event_details' ),
476
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
477
+		);
478 478
 		remove_filter(
479
-		    'the_content',
480
-            array( 'EED_Events_Archive', 'event_details' ),
481
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
482
-        );
479
+			'the_content',
480
+			array( 'EED_Events_Archive', 'event_details' ),
481
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
482
+		);
483 483
 		remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 );
484 484
 		//now add additional content depending on whether event is using the_excerpt() or the_content()
485 485
 		EED_Events_Archive::_add_additional_excerpt_filters();
@@ -489,15 +489,15 @@  discard block
 block discarded – undo
489 489
 		$content = EEH_Template::locate_template( 'content-espresso_events-details.php' );
490 490
 		// re-add our main filters (or else the next event won't have them)
491 491
 		add_filter(
492
-		    'the_excerpt',
493
-            array( 'EED_Events_Archive', 'event_details' ),
494
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
495
-        );
492
+			'the_excerpt',
493
+			array( 'EED_Events_Archive', 'event_details' ),
494
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
495
+		);
496 496
 		add_filter(
497
-		    'the_content',
498
-            array( 'EED_Events_Archive', 'event_details' ),
499
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
500
-        );
497
+			'the_content',
498
+			array( 'EED_Events_Archive', 'event_details' ),
499
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
500
+		);
501 501
 		add_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1, 1 );
502 502
 		// but remove the other filters so that they don't get applied to the next post
503 503
 		EED_Events_Archive::_remove_additional_events_archive_filters();
@@ -574,20 +574,20 @@  discard block
 block discarded – undo
574 574
 	 */
575 575
 	private static function _add_additional_excerpt_filters() {
576 576
 		add_filter(
577
-		    'the_excerpt',
578
-            array( 'EED_Events_Archive', 'event_datetimes' ),
579
-            EED_Events_Archive::EVENT_DATETIMES_PRIORITY
580
-        );
577
+			'the_excerpt',
578
+			array( 'EED_Events_Archive', 'event_datetimes' ),
579
+			EED_Events_Archive::EVENT_DATETIMES_PRIORITY
580
+		);
581 581
 		add_filter(
582
-		    'the_excerpt',
583
-            array( 'EED_Events_Archive', 'event_tickets' ),
584
-            EED_Events_Archive::EVENT_TICKETS_PRIORITY
585
-        );
582
+			'the_excerpt',
583
+			array( 'EED_Events_Archive', 'event_tickets' ),
584
+			EED_Events_Archive::EVENT_TICKETS_PRIORITY
585
+		);
586 586
 		add_filter(
587
-		    'the_excerpt',
588
-            array( 'EED_Events_Archive', 'event_venues' ),
589
-            EED_Events_Archive::EVENT_VENUES_PRIORITY
590
-        );
587
+			'the_excerpt',
588
+			array( 'EED_Events_Archive', 'event_venues' ),
589
+			EED_Events_Archive::EVENT_VENUES_PRIORITY
590
+		);
591 591
 	}
592 592
 
593 593
 
@@ -600,20 +600,20 @@  discard block
 block discarded – undo
600 600
 	 */
601 601
 	private static function _add_additional_content_filters() {
602 602
 		add_filter(
603
-		    'the_content',
604
-            array( 'EED_Events_Archive', 'event_datetimes' ),
605
-            EED_Events_Archive::EVENT_DATETIMES_PRIORITY
606
-        );
603
+			'the_content',
604
+			array( 'EED_Events_Archive', 'event_datetimes' ),
605
+			EED_Events_Archive::EVENT_DATETIMES_PRIORITY
606
+		);
607 607
 		add_filter(
608
-		    'the_content',
609
-            array( 'EED_Events_Archive', 'event_tickets' ),
610
-            EED_Events_Archive::EVENT_TICKETS_PRIORITY
611
-        );
608
+			'the_content',
609
+			array( 'EED_Events_Archive', 'event_tickets' ),
610
+			EED_Events_Archive::EVENT_TICKETS_PRIORITY
611
+		);
612 612
 		add_filter(
613
-		    'the_content',
614
-            array( 'EED_Events_Archive', 'event_venues' ),
615
-            EED_Events_Archive::EVENT_VENUES_PRIORITY
616
-        );
613
+			'the_content',
614
+			array( 'EED_Events_Archive', 'event_venues' ),
615
+			EED_Events_Archive::EVENT_VENUES_PRIORITY
616
+		);
617 617
 	}
618 618
 
619 619
 
@@ -626,35 +626,35 @@  discard block
 block discarded – undo
626 626
 	 */
627 627
 	private static function _remove_additional_events_archive_filters() {
628 628
 		remove_filter(
629
-		    'the_excerpt',
630
-            array( 'EED_Events_Archive', 'event_datetimes' ),
631
-            EED_Events_Archive::EVENT_DATETIMES_PRIORITY
632
-        );
629
+			'the_excerpt',
630
+			array( 'EED_Events_Archive', 'event_datetimes' ),
631
+			EED_Events_Archive::EVENT_DATETIMES_PRIORITY
632
+		);
633 633
 		remove_filter(
634
-		    'the_excerpt',
635
-            array( 'EED_Events_Archive', 'event_tickets' ),
636
-            EED_Events_Archive::EVENT_TICKETS_PRIORITY
637
-        );
634
+			'the_excerpt',
635
+			array( 'EED_Events_Archive', 'event_tickets' ),
636
+			EED_Events_Archive::EVENT_TICKETS_PRIORITY
637
+		);
638 638
 		remove_filter(
639
-		    'the_excerpt',
640
-            array( 'EED_Events_Archive', 'event_venues' ),
641
-            EED_Events_Archive::EVENT_VENUES_PRIORITY
642
-        );
639
+			'the_excerpt',
640
+			array( 'EED_Events_Archive', 'event_venues' ),
641
+			EED_Events_Archive::EVENT_VENUES_PRIORITY
642
+		);
643 643
 		remove_filter(
644
-		    'the_content',
645
-            array( 'EED_Events_Archive', 'event_datetimes' ),
646
-            EED_Events_Archive::EVENT_DATETIMES_PRIORITY
647
-        );
644
+			'the_content',
645
+			array( 'EED_Events_Archive', 'event_datetimes' ),
646
+			EED_Events_Archive::EVENT_DATETIMES_PRIORITY
647
+		);
648 648
 		remove_filter(
649
-		    'the_content',
650
-            array( 'EED_Events_Archive', 'event_tickets' ),
651
-            EED_Events_Archive::EVENT_TICKETS_PRIORITY
652
-        );
649
+			'the_content',
650
+			array( 'EED_Events_Archive', 'event_tickets' ),
651
+			EED_Events_Archive::EVENT_TICKETS_PRIORITY
652
+		);
653 653
 		remove_filter(
654
-		    'the_content',
655
-            array( 'EED_Events_Archive', 'event_venues' ),
656
-            EED_Events_Archive::EVENT_VENUES_PRIORITY
657
-        );
654
+			'the_content',
655
+			array( 'EED_Events_Archive', 'event_venues' ),
656
+			EED_Events_Archive::EVENT_VENUES_PRIORITY
657
+		);
658 658
 	}
659 659
 
660 660
 
@@ -669,50 +669,50 @@  discard block
 block discarded – undo
669 669
 		//remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 );
670 670
 		remove_filter( 'the_title', array( 'EED_Events_Archive', 'the_title' ), 1 );
671 671
 		remove_filter(
672
-		    'the_excerpt',
673
-            array( 'EED_Events_Archive', 'event_details' ),
674
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
675
-        );
672
+			'the_excerpt',
673
+			array( 'EED_Events_Archive', 'event_details' ),
674
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
675
+		);
676 676
 		remove_filter(
677
-		    'the_excerpt',
678
-            array( 'EED_Events_Archive', 'event_datetimes' ),
679
-            EED_Events_Archive::EVENT_DATETIMES_PRIORITY
680
-        );
677
+			'the_excerpt',
678
+			array( 'EED_Events_Archive', 'event_datetimes' ),
679
+			EED_Events_Archive::EVENT_DATETIMES_PRIORITY
680
+		);
681 681
 		remove_filter(
682
-		    'the_excerpt',
683
-            array( 'EED_Events_Archive', 'event_tickets' ),
684
-            EED_Events_Archive::EVENT_TICKETS_PRIORITY
685
-        );
682
+			'the_excerpt',
683
+			array( 'EED_Events_Archive', 'event_tickets' ),
684
+			EED_Events_Archive::EVENT_TICKETS_PRIORITY
685
+		);
686 686
 		remove_filter(
687
-		    'the_excerpt',
688
-            array( 'EED_Events_Archive', 'event_venues' ),
689
-            EED_Events_Archive::EVENT_VENUES_PRIORITY
690
-        );
687
+			'the_excerpt',
688
+			array( 'EED_Events_Archive', 'event_venues' ),
689
+			EED_Events_Archive::EVENT_VENUES_PRIORITY
690
+		);
691 691
 		remove_filter(
692
-		    'the_content',
693
-            array( 'EED_Events_Archive', 'event_details' ),
694
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
695
-        );
692
+			'the_content',
693
+			array( 'EED_Events_Archive', 'event_details' ),
694
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
695
+		);
696 696
 		remove_filter(
697
-		    'the_content',
698
-            array( 'EED_Events_Archive', 'event_datetimes' ),
699
-            EED_Events_Archive::EVENT_DATETIMES_PRIORITY
700
-        );
697
+			'the_content',
698
+			array( 'EED_Events_Archive', 'event_datetimes' ),
699
+			EED_Events_Archive::EVENT_DATETIMES_PRIORITY
700
+		);
701 701
 		remove_filter(
702
-		    'the_content',
703
-            array( 'EED_Events_Archive', 'event_tickets' ),
704
-            EED_Events_Archive::EVENT_TICKETS_PRIORITY
705
-        );
702
+			'the_content',
703
+			array( 'EED_Events_Archive', 'event_tickets' ),
704
+			EED_Events_Archive::EVENT_TICKETS_PRIORITY
705
+		);
706 706
 		remove_filter(
707
-		    'the_content',
708
-            array( 'EED_Events_Archive', 'event_venues' ),
709
-            EED_Events_Archive::EVENT_VENUES_PRIORITY
710
-        );
707
+			'the_content',
708
+			array( 'EED_Events_Archive', 'event_venues' ),
709
+			EED_Events_Archive::EVENT_VENUES_PRIORITY
710
+		);
711 711
 		// don't display entry meta because the existing theme will take care of that
712 712
 		remove_filter(
713
-		    'FHEE__content_espresso_events_details_template__display_entry_meta',
714
-            '__return_false'
715
-        );
713
+			'FHEE__content_espresso_events_details_template__display_entry_meta',
714
+			'__return_false'
715
+		);
716 716
 	}
717 717
 
718 718
 
@@ -727,7 +727,7 @@  discard block
 block discarded – undo
727 727
 	 *  @return 	void
728 728
 	 */
729 729
 	public function load_event_list_assets() {
730
-        do_action( 'AHEE__EED_Events_Archive__before_load_assets' );
730
+		do_action( 'AHEE__EED_Events_Archive__before_load_assets' );
731 731
 		add_filter( 'FHEE_load_EE_Session', '__return_true' );
732 732
 		add_filter( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true' );
733 733
 		add_action('wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ), 10 );
Please login to merge, or discard this patch.
Spacing   +175 added lines, -175 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 use EventEspresso\core\libraries\iframe_display\EventListIframeEmbedButton;
4 4
 use EventEspresso\modules\events_archive\EventsArchiveIframe;
5 5
 
6
-defined( 'EVENT_ESPRESSO_VERSION') || exit('No direct script access allowed');
6
+defined('EVENT_ESPRESSO_VERSION') || exit('No direct script access allowed');
7 7
 
8 8
 /**
9 9
  * Event List
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	 * @return EED_Events_Archive
52 52
 	 */
53 53
 	public static function instance() {
54
-		return parent::get_instance( __CLASS__ );
54
+		return parent::get_instance(__CLASS__);
55 55
 	}
56 56
 
57 57
 
@@ -63,10 +63,10 @@  discard block
 block discarded – undo
63 63
 	 *  @return 	void
64 64
 	 */
65 65
 	public static function set_hooks() {
66
-		EE_Config::register_route( EE_Registry::instance()->CFG->core->event_cpt_slug, 'Events_Archive', 'run' );
67
-		EE_Config::register_route( 'event_list', 'Events_Archive', 'event_list' );
68
-		EE_Config::register_route( 'iframe', 'Events_Archive', 'event_list_iframe', 'event_list' );
69
-		add_action( 'wp_loaded', array( 'EED_Events_Archive', 'set_definitions' ), 2 );
66
+		EE_Config::register_route(EE_Registry::instance()->CFG->core->event_cpt_slug, 'Events_Archive', 'run');
67
+		EE_Config::register_route('event_list', 'Events_Archive', 'event_list');
68
+		EE_Config::register_route('iframe', 'Events_Archive', 'event_list_iframe', 'event_list');
69
+		add_action('wp_loaded', array('EED_Events_Archive', 'set_definitions'), 2);
70 70
 	}
71 71
 
72 72
 	/**
@@ -76,12 +76,12 @@  discard block
 block discarded – undo
76 76
 	 *  @return 	void
77 77
 	 */
78 78
 	public static function set_hooks_admin() {
79
-		add_action( 'wp_loaded', array( 'EED_Events_Archive', 'set_definitions' ), 2 );
79
+		add_action('wp_loaded', array('EED_Events_Archive', 'set_definitions'), 2);
80 80
 		// hook into the end of the \EE_Admin_Page::_load_page_dependencies()
81 81
 		// to load assets for "espresso_events" page on the "default" route (action)
82 82
 		add_action(
83 83
 			'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_events__default',
84
-			array( 'EED_Events_Archive', 'event_list_iframe_embed_button' ),
84
+			array('EED_Events_Archive', 'event_list_iframe_embed_button'),
85 85
 			10
86 86
 		);
87 87
 	}
@@ -96,8 +96,8 @@  discard block
 block discarded – undo
96 96
 	 *  @return 	void
97 97
 	 */
98 98
 	public static function set_definitions() {
99
-		define( 'EVENTS_ARCHIVE_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS );
100
-		define( 'EVENTS_ARCHIVE_TEMPLATES_PATH', str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS );
99
+		define('EVENTS_ARCHIVE_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS);
100
+		define('EVENTS_ARCHIVE_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS);
101 101
 	}
102 102
 
103 103
 
@@ -105,10 +105,10 @@  discard block
 block discarded – undo
105 105
 	/**
106 106
 	 * set up EE_Events_Archive_Config
107 107
 	 */
108
-	protected function set_config(){
109
-		$this->set_config_section( 'template_settings' );
110
-		$this->set_config_class( 'EE_Events_Archive_Config' );
111
-		$this->set_config_name( 'EED_Events_Archive' );
108
+	protected function set_config() {
109
+		$this->set_config_section('template_settings');
110
+		$this->set_config_class('EE_Events_Archive_Config');
111
+		$this->set_config_name('EED_Events_Archive');
112 112
 	}
113 113
 
114 114
 
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 	 * @return EventListIframeEmbedButton
118 118
 	 */
119 119
 	public static function get_iframe_embed_button() {
120
-		if ( ! self::$_iframe_embed_button instanceof EventListIframeEmbedButton ) {
120
+		if ( ! self::$_iframe_embed_button instanceof EventListIframeEmbedButton) {
121 121
 			self::$_iframe_embed_button = new EventListIframeEmbedButton();
122 122
 		}
123 123
 		return self::$_iframe_embed_button;
@@ -143,35 +143,35 @@  discard block
 block discarded – undo
143 143
 	 * @param \EE_Events_Archive_Config $config
144 144
 	 * @return \EE_Template_Part_Manager
145 145
 	 */
146
-	public function initialize_template_parts( EE_Events_Archive_Config $config = null ) {
146
+	public function initialize_template_parts(EE_Events_Archive_Config $config = null) {
147 147
 		$config = $config instanceof EE_Events_Archive_Config ? $config : $this->config();
148 148
 		EEH_Autoloader::instance()->register_template_part_autoloaders();
149 149
 		$template_parts = new EE_Template_Part_Manager();
150 150
 		$template_parts->add_template_part(
151 151
 			'tickets',
152
-			__( 'Ticket Selector', 'event_espresso' ),
152
+			__('Ticket Selector', 'event_espresso'),
153 153
 			'content-espresso_events-tickets.php',
154 154
 			$config->display_order_tickets
155 155
 		);
156 156
 		$template_parts->add_template_part(
157 157
 			'datetimes',
158
-			__( 'Dates and Times', 'event_espresso' ),
158
+			__('Dates and Times', 'event_espresso'),
159 159
 			'content-espresso_events-datetimes.php',
160 160
 			$config->display_order_datetimes
161 161
 		);
162 162
 		$template_parts->add_template_part(
163 163
 			'event',
164
-			__( 'Event Description', 'event_espresso' ),
164
+			__('Event Description', 'event_espresso'),
165 165
 			'content-espresso_events-details.php',
166 166
 			$config->display_order_event
167 167
 		);
168 168
 		$template_parts->add_template_part(
169 169
 			'venue',
170
-			__( 'Venue Information', 'event_espresso' ),
170
+			__('Venue Information', 'event_espresso'),
171 171
 			'content-espresso_events-venues.php',
172 172
 			$config->display_order_venue
173 173
 		);
174
-		do_action( 'AHEE__EED_Event_Archive__initialize_template_parts', $template_parts );
174
+		do_action('AHEE__EED_Event_Archive__initialize_template_parts', $template_parts);
175 175
 		return $template_parts;
176 176
 	}
177 177
 
@@ -184,8 +184,8 @@  discard block
 block discarded – undo
184 184
 	 * @param WP $WP
185 185
 	 * @return    void
186 186
 	 */
187
-	public function run( $WP ) {
188
-		do_action( 'AHEE__EED_Events_Archive__before_run' );
187
+	public function run($WP) {
188
+		do_action('AHEE__EED_Events_Archive__before_run');
189 189
 		// ensure valid EE_Events_Archive_Config() object exists
190 190
 		$this->set_config();
191 191
 		/** @type EE_Events_Archive_Config $config */
@@ -197,14 +197,14 @@  discard block
 block discarded – undo
197 197
 		EEH_Event_Query::add_query_filters();
198 198
 		// set params that will get used by the filters
199 199
 		EEH_Event_Query::set_query_params(
200
-			'', 	// month
201
-			'', 	// category
202
-			$config->display_expired_events, 	// show_expired
203
-			'start_date', 	// orderby
200
+			'', // month
201
+			'', // category
202
+			$config->display_expired_events, // show_expired
203
+			'start_date', // orderby
204 204
 			'ASC' 	// sort
205 205
 		);
206 206
 		// check what template is loaded
207
-		add_filter( 'template_include',  array( $this, 'template_include' ), 999, 1 );
207
+		add_filter('template_include', array($this, 'template_include'), 999, 1);
208 208
 	}
209 209
 
210 210
 
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
      */
232 232
 	public function event_list_iframe() {
233 233
         \EED_Events_Archive::$iframe = true;
234
-		$event_list_iframe = new EventsArchiveIframe( $this );
234
+		$event_list_iframe = new EventsArchiveIframe($this);
235 235
 		$event_list_iframe->display();
236 236
 	}
237 237
 
@@ -269,42 +269,42 @@  discard block
 block discarded – undo
269 269
 	 * @param string $template
270 270
 	 * @return    string
271 271
 	 */
272
-	public function template_include( $template = '' ) {
272
+	public function template_include($template = '') {
273 273
 		// don't add content filter for dedicated EE child themes or private posts
274
-		if ( ! EEH_Template::is_espresso_theme() ) {
274
+		if ( ! EEH_Template::is_espresso_theme()) {
275 275
 			/** @type EE_Events_Archive_Config $config */
276 276
 			$config = $this->config();
277 277
 			// add status banner ?
278
-			if ( $config->display_status_banner ) {
279
-				add_filter( 'the_title', array( 'EED_Events_Archive', 'the_title' ), 100, 2 );
278
+			if ($config->display_status_banner) {
279
+				add_filter('the_title', array('EED_Events_Archive', 'the_title'), 100, 2);
280 280
 			}
281 281
 			// if NOT a custom template
282 282
 			if (
283 283
                 apply_filters('FHEE__EED_Event_Archive__template_include__allow_custom_selected_template', false)
284 284
 				|| EE_Registry::instance()
285
-                    ->load_core( 'Front_Controller' )
285
+                    ->load_core('Front_Controller')
286 286
                     ->get_selected_template() !== 'archive-espresso_events.php'
287 287
 			) {
288 288
 				// don't display entry meta because the existing theme will take care of that
289
-				add_filter( 'FHEE__EED_Events_Archive__template_include__events_list_active', '__return_true' );
289
+				add_filter('FHEE__EED_Events_Archive__template_include__events_list_active', '__return_true');
290 290
 			// load functions.php file for the theme (loaded by WP if using child theme)
291 291
 				EEH_Template::load_espresso_theme_functions();
292 292
 				// because we don't know if the theme is using the_excerpt()
293 293
 				add_filter(
294 294
 				    'the_excerpt',
295
-                    array( 'EED_Events_Archive', 'event_details' ),
295
+                    array('EED_Events_Archive', 'event_details'),
296 296
                     EED_Events_Archive::EVENT_DETAILS_PRIORITY
297 297
                 );
298 298
 				// or the_content
299 299
 				add_filter(
300 300
 				    'the_content',
301
-                    array( 'EED_Events_Archive', 'event_details' ),
301
+                    array('EED_Events_Archive', 'event_details'),
302 302
                     EED_Events_Archive::EVENT_DETAILS_PRIORITY
303 303
                 );
304 304
 				// and just in case they are running get_the_excerpt() which DESTROYS things
305
-				add_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1, 1 );
305
+				add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1);
306 306
 				// don't display entry meta because the existing theme will take care of that
307
-				add_filter( 'FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false' );
307
+				add_filter('FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false');
308 308
 			}
309 309
 		}
310 310
 		return $template;
@@ -319,25 +319,25 @@  discard block
 block discarded – undo
319 319
 	 * 	@param		string 	$excerpt
320 320
 	 * 	@return 		string
321 321
 	 */
322
-	public static function get_the_excerpt( $excerpt = '' ) {
323
-		if ( post_password_required() ) {
322
+	public static function get_the_excerpt($excerpt = '') {
323
+		if (post_password_required()) {
324 324
 			return $excerpt;
325 325
 		}
326
-		if ( apply_filters( 'FHEE__EED_Events_Archive__get_the_excerpt__theme_uses_get_the_excerpt', false ) ) {
326
+		if (apply_filters('FHEE__EED_Events_Archive__get_the_excerpt__theme_uses_get_the_excerpt', false)) {
327 327
 			remove_filter(
328 328
 			    'the_excerpt',
329
-                array( 'EED_Events_Archive', 'event_details' ),
329
+                array('EED_Events_Archive', 'event_details'),
330 330
                 EED_Events_Archive::EVENT_DETAILS_PRIORITY
331 331
             );
332 332
 			remove_filter(
333 333
 			    'the_content',
334
-                array( 'EED_Events_Archive', 'event_details' ),
334
+                array('EED_Events_Archive', 'event_details'),
335 335
                 EED_Events_Archive::EVENT_DETAILS_PRIORITY
336 336
             );
337
-			$excerpt = EED_Events_Archive::event_details( $excerpt );
337
+			$excerpt = EED_Events_Archive::event_details($excerpt);
338 338
 		} else {
339 339
 			EED_Events_Archive::$using_get_the_excerpt = true;
340
-			add_filter( 'wp_trim_excerpt', array( 'EED_Events_Archive', 'end_get_the_excerpt' ), 999, 1 );
340
+			add_filter('wp_trim_excerpt', array('EED_Events_Archive', 'end_get_the_excerpt'), 999, 1);
341 341
 		}
342 342
 		return $excerpt;
343 343
 	}
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
 	 * @param  string $text
352 352
 	 * @return string
353 353
 	 */
354
-	public static function end_get_the_excerpt( $text = '' ) {
354
+	public static function end_get_the_excerpt($text = '') {
355 355
 		EED_Events_Archive::$using_get_the_excerpt = false;
356 356
 		return $text;
357 357
 	}
@@ -366,10 +366,10 @@  discard block
 block discarded – undo
366 366
 	 * @param 		string 		$id
367 367
 	 * @return 		string
368 368
 	 */
369
-	public static function the_title( $title = '', $id = '' ) {
369
+	public static function the_title($title = '', $id = '') {
370 370
 	global $post;
371
-	if ( $post instanceof WP_Post ) {
372
-		return in_the_loop() && $post->ID == $id ? espresso_event_status_banner( $post->ID  ) . $title :  $title;
371
+	if ($post instanceof WP_Post) {
372
+		return in_the_loop() && $post->ID == $id ? espresso_event_status_banner($post->ID).$title : $title;
373 373
 	}
374 374
 	return $title;
375 375
 }
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
 	 * 	@param		string 	$content
384 384
 	 * 	@return 		string
385 385
 	 */
386
-	public static function event_details( $content ) {
386
+	public static function event_details($content) {
387 387
 		global $post;
388 388
 		static $current_post_ID = 0;
389 389
 		if (
@@ -392,8 +392,8 @@  discard block
 block discarded – undo
392 392
 			&& ! EED_Events_Archive::$using_get_the_excerpt
393 393
 			&& ! post_password_required()
394 394
 			&& (
395
-				apply_filters( 'FHEE__EES_Espresso_Events__process_shortcode__true', false )
396
-				|| ! apply_filters( 'FHEE__content_espresso_events__template_loaded', false )
395
+				apply_filters('FHEE__EES_Espresso_Events__process_shortcode__true', false)
396
+				|| ! apply_filters('FHEE__content_espresso_events__template_loaded', false)
397 397
 			)
398 398
 		) {
399 399
 			// Set current post ID to prevent showing content twice, but only if headers have definitely been sent.
@@ -402,8 +402,8 @@  discard block
 block discarded – undo
402 402
 			// We want to allow those plugins to still do their thing and have access to our content, but depending on
403 403
 			// how your event content is being displayed (shortcode, CPT route, etc), this filter can get applied twice,
404 404
 			// so the following allows this filter to be applied multiple times, but only once for real
405
-			$current_post_ID = did_action( 'loop_start' ) ? $post->ID : 0;
406
-			if ( EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->use_sortable_display_order ) {
405
+			$current_post_ID = did_action('loop_start') ? $post->ID : 0;
406
+			if (EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->use_sortable_display_order) {
407 407
 				$content = \EED_Events_Archive::use_sortable_display_order();
408 408
 			} else {
409 409
 				$content = \EED_Events_Archive::use_filterable_display_order();
@@ -422,36 +422,36 @@  discard block
 block discarded – undo
422 422
 	 */
423 423
 	protected static function use_sortable_display_order() {
424 424
 		// no further password checks required atm
425
-		add_filter( 'FHEE__EED_Events_Archive__event_details__no_post_password_required', '__return_true' );
425
+		add_filter('FHEE__EED_Events_Archive__event_details__no_post_password_required', '__return_true');
426 426
 		// we need to first remove this callback from being applied to the_content() or the_excerpt()
427 427
         // (otherwise it will recurse and blow up the interweb)
428 428
 		remove_filter(
429 429
 		    'the_excerpt',
430
-            array( 'EED_Events_Archive', 'event_details' ),
430
+            array('EED_Events_Archive', 'event_details'),
431 431
             EED_Events_Archive::EVENT_DETAILS_PRIORITY
432 432
         );
433 433
 		remove_filter(
434 434
 		    'the_content',
435
-            array( 'EED_Events_Archive', 'event_details' ),
435
+            array('EED_Events_Archive', 'event_details'),
436 436
             EED_Events_Archive::EVENT_DETAILS_PRIORITY
437 437
         );
438
-		remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 );
438
+		remove_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1);
439 439
 		// now add additional content depending on whether event is using the_excerpt() or the_content()
440 440
 		EED_Events_Archive::instance()->template_parts = EED_Events_Archive::instance()->initialize_template_parts();
441
-		$content = EEH_Template::locate_template( 'content-espresso_events-details.php' );
442
-		$content = EED_Events_Archive::instance()->template_parts->apply_template_part_filters( $content );
441
+		$content = EEH_Template::locate_template('content-espresso_events-details.php');
442
+		$content = EED_Events_Archive::instance()->template_parts->apply_template_part_filters($content);
443 443
 		// re-add our main filters (or else the next event won't have them)
444 444
 		add_filter(
445 445
 		    'the_excerpt',
446
-            array( 'EED_Events_Archive', 'event_details' ),
446
+            array('EED_Events_Archive', 'event_details'),
447 447
             EED_Events_Archive::EVENT_DETAILS_PRIORITY
448 448
         );
449 449
 		add_filter(
450 450
 		    'the_content',
451
-            array( 'EED_Events_Archive', 'event_details' ),
451
+            array('EED_Events_Archive', 'event_details'),
452 452
             EED_Events_Archive::EVENT_DETAILS_PRIORITY
453 453
         );
454
-		add_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1, 1 );
454
+		add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1);
455 455
 		remove_filter(
456 456
 		    'FHEE__EED_Events_Archive__event_details__no_post_password_required',
457 457
             '__return_true'
@@ -472,36 +472,36 @@  discard block
 block discarded – undo
472 472
 		// (otherwise it will recurse and blow up the interweb)
473 473
 		remove_filter(
474 474
 		    'the_excerpt',
475
-            array( 'EED_Events_Archive', 'event_details' ),
475
+            array('EED_Events_Archive', 'event_details'),
476 476
             EED_Events_Archive::EVENT_DETAILS_PRIORITY
477 477
         );
478 478
 		remove_filter(
479 479
 		    'the_content',
480
-            array( 'EED_Events_Archive', 'event_details' ),
480
+            array('EED_Events_Archive', 'event_details'),
481 481
             EED_Events_Archive::EVENT_DETAILS_PRIORITY
482 482
         );
483
-		remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 );
483
+		remove_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1);
484 484
 		//now add additional content depending on whether event is using the_excerpt() or the_content()
485 485
 		EED_Events_Archive::_add_additional_excerpt_filters();
486 486
 		EED_Events_Archive::_add_additional_content_filters();
487
-		do_action( 'AHEE__EED_Events_Archive__use_filterable_display_order__after_add_filters' );
487
+		do_action('AHEE__EED_Events_Archive__use_filterable_display_order__after_add_filters');
488 488
 		// now load our template
489
-		$content = EEH_Template::locate_template( 'content-espresso_events-details.php' );
489
+		$content = EEH_Template::locate_template('content-espresso_events-details.php');
490 490
 		// re-add our main filters (or else the next event won't have them)
491 491
 		add_filter(
492 492
 		    'the_excerpt',
493
-            array( 'EED_Events_Archive', 'event_details' ),
493
+            array('EED_Events_Archive', 'event_details'),
494 494
             EED_Events_Archive::EVENT_DETAILS_PRIORITY
495 495
         );
496 496
 		add_filter(
497 497
 		    'the_content',
498
-            array( 'EED_Events_Archive', 'event_details' ),
498
+            array('EED_Events_Archive', 'event_details'),
499 499
             EED_Events_Archive::EVENT_DETAILS_PRIORITY
500 500
         );
501
-		add_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1, 1 );
501
+		add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1);
502 502
 		// but remove the other filters so that they don't get applied to the next post
503 503
 		EED_Events_Archive::_remove_additional_events_archive_filters();
504
-		do_action( 'AHEE__EED_Events_Archive__use_filterable_display_order__after_remove_filters' );
504
+		do_action('AHEE__EED_Events_Archive__use_filterable_display_order__after_remove_filters');
505 505
 		// we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt)
506 506
 		//return ! empty( $template ) ? $template : $content;
507 507
 		return $content;
@@ -516,11 +516,11 @@  discard block
 block discarded – undo
516 516
 	 * 	@param		string 	$content
517 517
 	 *  	@return 		string
518 518
 	 */
519
-	public static function event_datetimes( $content ) {
520
-		if ( post_password_required() ) {
519
+	public static function event_datetimes($content) {
520
+		if (post_password_required()) {
521 521
 			return $content;
522 522
 		}
523
-		return EEH_Template::locate_template( 'content-espresso_events-datetimes.php' ) . $content;
523
+		return EEH_Template::locate_template('content-espresso_events-datetimes.php').$content;
524 524
 	}
525 525
 
526 526
 	/**
@@ -530,11 +530,11 @@  discard block
 block discarded – undo
530 530
 	 * 	@param		string 	$content
531 531
 	 *  	@return 		string
532 532
 	 */
533
-	public static function event_tickets( $content ) {
534
-		if ( post_password_required() ) {
533
+	public static function event_tickets($content) {
534
+		if (post_password_required()) {
535 535
 			return $content;
536 536
 		}
537
-		return EEH_Template::locate_template( 'content-espresso_events-tickets.php' ) . $content;
537
+		return EEH_Template::locate_template('content-espresso_events-tickets.php').$content;
538 538
 	}
539 539
 
540 540
 
@@ -546,8 +546,8 @@  discard block
 block discarded – undo
546 546
 	 * @param    string $content
547 547
 	 * @return    string
548 548
 	 */
549
-	public static function event_venue( $content ) {
550
-		return EED_Events_Archive::event_venues( $content );
549
+	public static function event_venue($content) {
550
+		return EED_Events_Archive::event_venues($content);
551 551
 	}
552 552
 
553 553
 	/**
@@ -557,11 +557,11 @@  discard block
 block discarded – undo
557 557
 	 * 	@param		string 	$content
558 558
 	 *  	@return 		string
559 559
 	 */
560
-	public static function event_venues( $content ) {
561
-		if ( post_password_required() ) {
560
+	public static function event_venues($content) {
561
+		if (post_password_required()) {
562 562
 			return $content;
563 563
 		}
564
-		return $content . EEH_Template::locate_template( 'content-espresso_events-venues.php' );
564
+		return $content.EEH_Template::locate_template('content-espresso_events-venues.php');
565 565
 	}
566 566
 
567 567
 
@@ -575,17 +575,17 @@  discard block
 block discarded – undo
575 575
 	private static function _add_additional_excerpt_filters() {
576 576
 		add_filter(
577 577
 		    'the_excerpt',
578
-            array( 'EED_Events_Archive', 'event_datetimes' ),
578
+            array('EED_Events_Archive', 'event_datetimes'),
579 579
             EED_Events_Archive::EVENT_DATETIMES_PRIORITY
580 580
         );
581 581
 		add_filter(
582 582
 		    'the_excerpt',
583
-            array( 'EED_Events_Archive', 'event_tickets' ),
583
+            array('EED_Events_Archive', 'event_tickets'),
584 584
             EED_Events_Archive::EVENT_TICKETS_PRIORITY
585 585
         );
586 586
 		add_filter(
587 587
 		    'the_excerpt',
588
-            array( 'EED_Events_Archive', 'event_venues' ),
588
+            array('EED_Events_Archive', 'event_venues'),
589 589
             EED_Events_Archive::EVENT_VENUES_PRIORITY
590 590
         );
591 591
 	}
@@ -601,17 +601,17 @@  discard block
 block discarded – undo
601 601
 	private static function _add_additional_content_filters() {
602 602
 		add_filter(
603 603
 		    'the_content',
604
-            array( 'EED_Events_Archive', 'event_datetimes' ),
604
+            array('EED_Events_Archive', 'event_datetimes'),
605 605
             EED_Events_Archive::EVENT_DATETIMES_PRIORITY
606 606
         );
607 607
 		add_filter(
608 608
 		    'the_content',
609
-            array( 'EED_Events_Archive', 'event_tickets' ),
609
+            array('EED_Events_Archive', 'event_tickets'),
610 610
             EED_Events_Archive::EVENT_TICKETS_PRIORITY
611 611
         );
612 612
 		add_filter(
613 613
 		    'the_content',
614
-            array( 'EED_Events_Archive', 'event_venues' ),
614
+            array('EED_Events_Archive', 'event_venues'),
615 615
             EED_Events_Archive::EVENT_VENUES_PRIORITY
616 616
         );
617 617
 	}
@@ -627,32 +627,32 @@  discard block
 block discarded – undo
627 627
 	private static function _remove_additional_events_archive_filters() {
628 628
 		remove_filter(
629 629
 		    'the_excerpt',
630
-            array( 'EED_Events_Archive', 'event_datetimes' ),
630
+            array('EED_Events_Archive', 'event_datetimes'),
631 631
             EED_Events_Archive::EVENT_DATETIMES_PRIORITY
632 632
         );
633 633
 		remove_filter(
634 634
 		    'the_excerpt',
635
-            array( 'EED_Events_Archive', 'event_tickets' ),
635
+            array('EED_Events_Archive', 'event_tickets'),
636 636
             EED_Events_Archive::EVENT_TICKETS_PRIORITY
637 637
         );
638 638
 		remove_filter(
639 639
 		    'the_excerpt',
640
-            array( 'EED_Events_Archive', 'event_venues' ),
640
+            array('EED_Events_Archive', 'event_venues'),
641 641
             EED_Events_Archive::EVENT_VENUES_PRIORITY
642 642
         );
643 643
 		remove_filter(
644 644
 		    'the_content',
645
-            array( 'EED_Events_Archive', 'event_datetimes' ),
645
+            array('EED_Events_Archive', 'event_datetimes'),
646 646
             EED_Events_Archive::EVENT_DATETIMES_PRIORITY
647 647
         );
648 648
 		remove_filter(
649 649
 		    'the_content',
650
-            array( 'EED_Events_Archive', 'event_tickets' ),
650
+            array('EED_Events_Archive', 'event_tickets'),
651 651
             EED_Events_Archive::EVENT_TICKETS_PRIORITY
652 652
         );
653 653
 		remove_filter(
654 654
 		    'the_content',
655
-            array( 'EED_Events_Archive', 'event_venues' ),
655
+            array('EED_Events_Archive', 'event_venues'),
656 656
             EED_Events_Archive::EVENT_VENUES_PRIORITY
657 657
         );
658 658
 	}
@@ -667,45 +667,45 @@  discard block
 block discarded – undo
667 667
 	 */
668 668
 	public static function remove_all_events_archive_filters() {
669 669
 		//remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 );
670
-		remove_filter( 'the_title', array( 'EED_Events_Archive', 'the_title' ), 1 );
670
+		remove_filter('the_title', array('EED_Events_Archive', 'the_title'), 1);
671 671
 		remove_filter(
672 672
 		    'the_excerpt',
673
-            array( 'EED_Events_Archive', 'event_details' ),
673
+            array('EED_Events_Archive', 'event_details'),
674 674
             EED_Events_Archive::EVENT_DETAILS_PRIORITY
675 675
         );
676 676
 		remove_filter(
677 677
 		    'the_excerpt',
678
-            array( 'EED_Events_Archive', 'event_datetimes' ),
678
+            array('EED_Events_Archive', 'event_datetimes'),
679 679
             EED_Events_Archive::EVENT_DATETIMES_PRIORITY
680 680
         );
681 681
 		remove_filter(
682 682
 		    'the_excerpt',
683
-            array( 'EED_Events_Archive', 'event_tickets' ),
683
+            array('EED_Events_Archive', 'event_tickets'),
684 684
             EED_Events_Archive::EVENT_TICKETS_PRIORITY
685 685
         );
686 686
 		remove_filter(
687 687
 		    'the_excerpt',
688
-            array( 'EED_Events_Archive', 'event_venues' ),
688
+            array('EED_Events_Archive', 'event_venues'),
689 689
             EED_Events_Archive::EVENT_VENUES_PRIORITY
690 690
         );
691 691
 		remove_filter(
692 692
 		    'the_content',
693
-            array( 'EED_Events_Archive', 'event_details' ),
693
+            array('EED_Events_Archive', 'event_details'),
694 694
             EED_Events_Archive::EVENT_DETAILS_PRIORITY
695 695
         );
696 696
 		remove_filter(
697 697
 		    'the_content',
698
-            array( 'EED_Events_Archive', 'event_datetimes' ),
698
+            array('EED_Events_Archive', 'event_datetimes'),
699 699
             EED_Events_Archive::EVENT_DATETIMES_PRIORITY
700 700
         );
701 701
 		remove_filter(
702 702
 		    'the_content',
703
-            array( 'EED_Events_Archive', 'event_tickets' ),
703
+            array('EED_Events_Archive', 'event_tickets'),
704 704
             EED_Events_Archive::EVENT_TICKETS_PRIORITY
705 705
         );
706 706
 		remove_filter(
707 707
 		    'the_content',
708
-            array( 'EED_Events_Archive', 'event_venues' ),
708
+            array('EED_Events_Archive', 'event_venues'),
709 709
             EED_Events_Archive::EVENT_VENUES_PRIORITY
710 710
         );
711 711
 		// don't display entry meta because the existing theme will take care of that
@@ -727,12 +727,12 @@  discard block
 block discarded – undo
727 727
 	 *  @return 	void
728 728
 	 */
729 729
 	public function load_event_list_assets() {
730
-        do_action( 'AHEE__EED_Events_Archive__before_load_assets' );
731
-		add_filter( 'FHEE_load_EE_Session', '__return_true' );
732
-		add_filter( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true' );
733
-		add_action('wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ), 10 );
734
-		if ( EE_Registry::instance()->CFG->map_settings->use_google_maps ) {
735
-			add_action('wp_enqueue_scripts', array( 'EEH_Maps', 'espresso_google_map_js' ), 11 );
730
+        do_action('AHEE__EED_Events_Archive__before_load_assets');
731
+		add_filter('FHEE_load_EE_Session', '__return_true');
732
+		add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
733
+		add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10);
734
+		if (EE_Registry::instance()->CFG->map_settings->use_google_maps) {
735
+			add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11);
736 736
 		}
737 737
 	}
738 738
 
@@ -749,13 +749,13 @@  discard block
 block discarded – undo
749 749
 	 */
750 750
 	public function wp_enqueue_scripts() {
751 751
 		// get some style
752
-		if ( apply_filters( 'FHEE_enable_default_espresso_css', FALSE ) ) {
752
+		if (apply_filters('FHEE_enable_default_espresso_css', FALSE)) {
753 753
 			// first check uploads folder
754
-			if ( EEH_File::is_readable( get_stylesheet_directory() . $this->theme . DS . 'style.css' )) {
755
-				wp_register_style( $this->theme, get_stylesheet_directory_uri() . $this->theme . DS . 'style.css', array( 'dashicons', 'espresso_default' ));
754
+			if (EEH_File::is_readable(get_stylesheet_directory().$this->theme.DS.'style.css')) {
755
+				wp_register_style($this->theme, get_stylesheet_directory_uri().$this->theme.DS.'style.css', array('dashicons', 'espresso_default'));
756 756
 			} else {
757 757
 		}
758
-		wp_enqueue_style( $this->theme );
758
+		wp_enqueue_style($this->theme);
759 759
 
760 760
 	}
761 761
 }
@@ -773,8 +773,8 @@  discard block
 block discarded – undo
773 773
 	 */
774 774
 	public static function template_settings_form() {
775 775
 	$template_settings = EE_Registry::instance()->CFG->template_settings;
776
-	$template_settings->EED_Events_Archive = isset( $template_settings->EED_Events_Archive ) ? $template_settings->EED_Events_Archive : new EE_Events_Archive_Config();
777
-	$template_settings->EED_Events_Archive = apply_filters( 'FHEE__EED_Events_Archive__template_settings_form__event_list_config', $template_settings->EED_Events_Archive );
776
+	$template_settings->EED_Events_Archive = isset($template_settings->EED_Events_Archive) ? $template_settings->EED_Events_Archive : new EE_Events_Archive_Config();
777
+	$template_settings->EED_Events_Archive = apply_filters('FHEE__EED_Events_Archive__template_settings_form__event_list_config', $template_settings->EED_Events_Archive);
778 778
 	$events_archive_settings = array(
779 779
 		'display_status_banner' => 0,
780 780
 		'display_description' => 1,
@@ -783,8 +783,8 @@  discard block
 block discarded – undo
783 783
 		'display_venue' => 0,
784 784
 		'display_expired_events' => 0
785 785
 	);
786
-	$events_archive_settings = array_merge( $events_archive_settings, (array)$template_settings->EED_Events_Archive );
787
-	EEH_Template::display_template( EVENTS_ARCHIVE_TEMPLATES_PATH . 'admin-event-list-settings.template.php', $events_archive_settings );
786
+	$events_archive_settings = array_merge($events_archive_settings, (array) $template_settings->EED_Events_Archive);
787
+	EEH_Template::display_template(EVENTS_ARCHIVE_TEMPLATES_PATH.'admin-event-list-settings.template.php', $events_archive_settings);
788 788
 }
789 789
 
790 790
 
@@ -800,16 +800,16 @@  discard block
 block discarded – undo
800 800
 	 *  @param 	EE_Request_Handler $REQ
801 801
 	 *  @return 	EE_Template_Config
802 802
 	 */
803
-	public static function update_template_settings( $CFG, $REQ ) {
803
+	public static function update_template_settings($CFG, $REQ) {
804 804
 		$CFG->EED_Events_Archive = new EE_Events_Archive_Config();
805 805
 		// unless we are resetting the config...
806
-		if ( ! isset( $REQ['EED_Events_Archive_reset_event_list_settings'] ) || absint( $REQ['EED_Events_Archive_reset_event_list_settings'] ) !== 1 ) {
807
-			$CFG->EED_Events_Archive->display_status_banner = isset( $REQ['EED_Events_Archive_display_status_banner'] ) ? absint( $REQ['EED_Events_Archive_display_status_banner'] ) : 0;
808
-			$CFG->EED_Events_Archive->display_description = isset( $REQ['EED_Events_Archive_display_description'] ) ? absint( $REQ['EED_Events_Archive_display_description'] ) : 1;
809
-			$CFG->EED_Events_Archive->display_ticket_selector = isset( $REQ['EED_Events_Archive_display_ticket_selector'] ) ? absint( $REQ['EED_Events_Archive_display_ticket_selector'] ) : 0;
810
-			$CFG->EED_Events_Archive->display_datetimes = isset( $REQ['EED_Events_Archive_display_datetimes'] ) ? absint( $REQ['EED_Events_Archive_display_datetimes'] ) : 1;
811
-			$CFG->EED_Events_Archive->display_venue = isset( $REQ['EED_Events_Archive_display_venue'] ) ? absint( $REQ['EED_Events_Archive_display_venue'] ) : 0;
812
-			$CFG->EED_Events_Archive->display_expired_events = isset( $REQ['EED_Events_Archive_display_expired_events'] ) ? absint( $REQ['EED_Events_Archive_display_expired_events'] ) : 0;			}
806
+		if ( ! isset($REQ['EED_Events_Archive_reset_event_list_settings']) || absint($REQ['EED_Events_Archive_reset_event_list_settings']) !== 1) {
807
+			$CFG->EED_Events_Archive->display_status_banner = isset($REQ['EED_Events_Archive_display_status_banner']) ? absint($REQ['EED_Events_Archive_display_status_banner']) : 0;
808
+			$CFG->EED_Events_Archive->display_description = isset($REQ['EED_Events_Archive_display_description']) ? absint($REQ['EED_Events_Archive_display_description']) : 1;
809
+			$CFG->EED_Events_Archive->display_ticket_selector = isset($REQ['EED_Events_Archive_display_ticket_selector']) ? absint($REQ['EED_Events_Archive_display_ticket_selector']) : 0;
810
+			$CFG->EED_Events_Archive->display_datetimes = isset($REQ['EED_Events_Archive_display_datetimes']) ? absint($REQ['EED_Events_Archive_display_datetimes']) : 1;
811
+			$CFG->EED_Events_Archive->display_venue = isset($REQ['EED_Events_Archive_display_venue']) ? absint($REQ['EED_Events_Archive_display_venue']) : 0;
812
+			$CFG->EED_Events_Archive->display_expired_events = isset($REQ['EED_Events_Archive_display_expired_events']) ? absint($REQ['EED_Events_Archive_display_expired_events']) : 0; }
813 813
 		return $CFG;
814 814
 	}
815 815
 
@@ -822,10 +822,10 @@  discard block
 block discarded – undo
822 822
 	 * @param string $extra_class
823 823
 	 * @return    string
824 824
 	 */
825
-	public static function event_list_css( $extra_class = '' ) {
826
-		$event_list_css = ! empty( $extra_class ) ? array( $extra_class ) : array();
825
+	public static function event_list_css($extra_class = '') {
826
+		$event_list_css = ! empty($extra_class) ? array($extra_class) : array();
827 827
 		$event_list_css[] = 'espresso-event-list-event';
828
-		return implode( ' ', $event_list_css );
828
+		return implode(' ', $event_list_css);
829 829
 	}
830 830
 
831 831
 
@@ -852,9 +852,9 @@  discard block
 block discarded – undo
852 852
 	 * @param $value
853 853
 	 * @return    bool
854 854
 	 */
855
-	public static function display_description( $value ) {
855
+	public static function display_description($value) {
856 856
 		$config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive;
857
-		$display_description= isset( $config->display_description ) ? $config->display_description : 1;
857
+		$display_description = isset($config->display_description) ? $config->display_description : 1;
858 858
 		return $display_description === $value ? TRUE : FALSE;
859 859
 	}
860 860
 
@@ -867,7 +867,7 @@  discard block
 block discarded – undo
867 867
 	 */
868 868
 	public static function display_ticket_selector() {
869 869
 		$config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive;
870
-		return isset( $config->display_ticket_selector ) && $config->display_ticket_selector ? TRUE : FALSE;
870
+		return isset($config->display_ticket_selector) && $config->display_ticket_selector ? TRUE : FALSE;
871 871
 	}
872 872
 
873 873
 
@@ -880,7 +880,7 @@  discard block
 block discarded – undo
880 880
 	 */
881 881
 	public static function display_venue() {
882 882
 		$config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive;
883
-		return isset( $config->display_venue ) && $config->display_venue && EEH_Venue_View::venue_name() ? TRUE : FALSE;
883
+		return isset($config->display_venue) && $config->display_venue && EEH_Venue_View::venue_name() ? TRUE : FALSE;
884 884
 	}
885 885
 
886 886
 
@@ -892,7 +892,7 @@  discard block
 block discarded – undo
892 892
 	 */
893 893
 	public static function display_datetimes() {
894 894
 		$config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive;
895
-		return isset( $config->display_datetimes ) && $config->display_datetimes ? TRUE : FALSE;
895
+		return isset($config->display_datetimes) && $config->display_datetimes ? TRUE : FALSE;
896 896
 }
897 897
 
898 898
 
@@ -907,7 +907,7 @@  discard block
 block discarded – undo
907 907
 	 *  @return 	string
908 908
 	 */
909 909
 	public static function event_list_title() {
910
-		return apply_filters( 'FHEE__archive_espresso_events_template__upcoming_events_h1', __( 'Upcoming Events', 'event_espresso' ));
910
+		return apply_filters('FHEE__archive_espresso_events_template__upcoming_events_h1', __('Upcoming Events', 'event_espresso'));
911 911
 	}
912 912
 
913 913
 
@@ -916,11 +916,11 @@  discard block
 block discarded – undo
916 916
 	/**
917 917
 	 * 	@since 4.4.0
918 918
 	 */
919
-	public static function _doing_it_wrong_notice( $function = '' ) {
919
+	public static function _doing_it_wrong_notice($function = '') {
920 920
 		EE_Error::doing_it_wrong(
921 921
 			__FUNCTION__,
922 922
 			sprintf(
923
-				__( 'EED_Events_Archive::%1$s was moved to EEH_Event_Query::%1$s:%2$sPlease update your existing code because the method it calls will be removed in version %3$s', 'event_espresso' ),
923
+				__('EED_Events_Archive::%1$s was moved to EEH_Event_Query::%1$s:%2$sPlease update your existing code because the method it calls will be removed in version %3$s', 'event_espresso'),
924 924
 				$function,
925 925
 				'<br />',
926 926
 				'4.6.0'
@@ -942,89 +942,89 @@  discard block
 block discarded – undo
942 942
 	 * 	@deprecated
943 943
 	 * 	@since 4.4.0
944 944
 	 */
945
-	public function posts_fields( $SQL, WP_Query $wp_query ) {
946
-		EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ );
947
-		return EEH_Event_Query::posts_fields( $SQL, $wp_query );
945
+	public function posts_fields($SQL, WP_Query $wp_query) {
946
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
947
+		return EEH_Event_Query::posts_fields($SQL, $wp_query);
948 948
 	}
949 949
 	/**
950 950
 	 * 	@deprecated
951 951
 	 * 	@since 4.4.0
952 952
 	 */
953
-	public static function posts_fields_sql_for_orderby( $orderby_params = array() ) {
954
-		EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ );
955
-		return EEH_Event_Query::posts_fields_sql_for_orderby( $orderby_params );
953
+	public static function posts_fields_sql_for_orderby($orderby_params = array()) {
954
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
955
+		return EEH_Event_Query::posts_fields_sql_for_orderby($orderby_params);
956 956
 	}
957 957
 	/**
958 958
 	 * 	@deprecated
959 959
 	 * 	@since 4.4.0
960 960
 	 */
961
-	public function posts_join( $SQL, WP_Query $wp_query ) {
962
-		EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ );
963
-		return EEH_Event_Query::posts_join( $SQL, $wp_query );
961
+	public function posts_join($SQL, WP_Query $wp_query) {
962
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
963
+		return EEH_Event_Query::posts_join($SQL, $wp_query);
964 964
 	}
965 965
 	/**
966 966
 	 * 	@deprecated
967 967
 	 * 	@since 4.4.0
968 968
 	 */
969
-	public static function posts_join_sql_for_terms( $join_terms = NULL ) {
970
-		EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ );
971
-		return EEH_Event_Query::posts_join_sql_for_terms( $join_terms );
969
+	public static function posts_join_sql_for_terms($join_terms = NULL) {
970
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
971
+		return EEH_Event_Query::posts_join_sql_for_terms($join_terms);
972 972
 	}
973 973
 	/**
974 974
 	 * 	@deprecated
975 975
 	 * 	@since 4.4.0
976 976
 	 */
977
-	public static function posts_join_for_orderby( $orderby_params = array() ) {
978
-		EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ );
979
-		return EEH_Event_Query::posts_join_for_orderby( $orderby_params );
977
+	public static function posts_join_for_orderby($orderby_params = array()) {
978
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
979
+		return EEH_Event_Query::posts_join_for_orderby($orderby_params);
980 980
 	}
981 981
 	/**
982 982
 	 * 	@deprecated
983 983
 	 * 	@since 4.4.0
984 984
 	 */
985
-	public function posts_where( $SQL, WP_Query $wp_query ) {
986
-		EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ );
987
-		return EEH_Event_Query::posts_where( $SQL, $wp_query );
985
+	public function posts_where($SQL, WP_Query $wp_query) {
986
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
987
+		return EEH_Event_Query::posts_where($SQL, $wp_query);
988 988
 	}
989 989
 	/**
990 990
 	 * 	@deprecated
991 991
 	 * 	@since 4.4.0
992 992
 	 */
993
-	public static function posts_where_sql_for_show_expired( $show_expired = FALSE ) {
994
-		EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ );
995
-		return EEH_Event_Query::posts_where_sql_for_show_expired( $show_expired );
993
+	public static function posts_where_sql_for_show_expired($show_expired = FALSE) {
994
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
995
+		return EEH_Event_Query::posts_where_sql_for_show_expired($show_expired);
996 996
 	}
997 997
 	/**
998 998
 	 * 	@deprecated
999 999
 	 * 	@since 4.4.0
1000 1000
 	 */
1001
-	public static function posts_where_sql_for_event_category_slug( $event_category_slug = NULL ) {
1002
-		EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ );
1003
-		return EEH_Event_Query::posts_where_sql_for_event_category_slug( $event_category_slug );
1001
+	public static function posts_where_sql_for_event_category_slug($event_category_slug = NULL) {
1002
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1003
+		return EEH_Event_Query::posts_where_sql_for_event_category_slug($event_category_slug);
1004 1004
 	}
1005 1005
 	/**
1006 1006
 	 * 	@deprecated
1007 1007
 	 * 	@since 4.4.0
1008 1008
 	 */
1009
-	public static function posts_where_sql_for_event_list_month( $month = NULL ) {
1010
-		EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ );
1011
-		return EEH_Event_Query::posts_where_sql_for_event_list_month( $month );
1009
+	public static function posts_where_sql_for_event_list_month($month = NULL) {
1010
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1011
+		return EEH_Event_Query::posts_where_sql_for_event_list_month($month);
1012 1012
 	}
1013 1013
 	/**
1014 1014
 	 * 	@deprecated
1015 1015
 	 * 	@since 4.4.0
1016 1016
 	 */
1017
-	public function posts_orderby( $SQL, WP_Query $wp_query ) {
1018
-		EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ );
1019
-		return EEH_Event_Query::posts_orderby( $SQL, $wp_query );
1017
+	public function posts_orderby($SQL, WP_Query $wp_query) {
1018
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1019
+		return EEH_Event_Query::posts_orderby($SQL, $wp_query);
1020 1020
 	}
1021 1021
 	/**
1022 1022
 	 * 	@deprecated
1023 1023
 	 * 	@since 4.4.0
1024 1024
 	 */
1025
-	public static function posts_orderby_sql( $orderby_params = array(), $sort = 'ASC' ) {
1026
-		EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ );
1027
-		return EEH_Event_Query::posts_orderby_sql( $orderby_params, $sort );
1025
+	public static function posts_orderby_sql($orderby_params = array(), $sort = 'ASC') {
1026
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1027
+		return EEH_Event_Query::posts_orderby_sql($orderby_params, $sort);
1028 1028
 	}
1029 1029
 
1030 1030
 
@@ -1055,8 +1055,8 @@  discard block
 block discarded – undo
1055 1055
  * @param string $extra_class
1056 1056
  * @return string
1057 1057
  */
1058
-function espresso_event_list_css( $extra_class = '' ) {
1059
-	return EED_Events_Archive::event_list_css( $extra_class );
1058
+function espresso_event_list_css($extra_class = '') {
1059
+	return EED_Events_Archive::event_list_css($extra_class);
1060 1060
 }
1061 1061
 
1062 1062
 /**
@@ -1070,14 +1070,14 @@  discard block
 block discarded – undo
1070 1070
  * @return bool
1071 1071
  */
1072 1072
 function espresso_display_full_description_in_event_list() {
1073
-	return EED_Events_Archive::display_description( 2 );
1073
+	return EED_Events_Archive::display_description(2);
1074 1074
 }
1075 1075
 
1076 1076
 /**
1077 1077
  * @return bool
1078 1078
  */
1079 1079
 function espresso_display_excerpt_in_event_list() {
1080
-	return EED_Events_Archive::display_description( 1 );
1080
+	return EED_Events_Archive::display_description(1);
1081 1081
 }
1082 1082
 
1083 1083
 /**
Please login to merge, or discard this patch.
modules/event_single/EED_Event_Single.module.php 2 patches
Indentation   +457 added lines, -457 removed lines patch added patch discarded remove patch
@@ -13,462 +13,462 @@  discard block
 block discarded – undo
13 13
 class EED_Event_Single extends EED_Module
14 14
 {
15 15
 
16
-    const EVENT_DETAILS_PRIORITY = 100;
17
-    const EVENT_DATETIMES_PRIORITY = 110;
18
-    const EVENT_TICKETS_PRIORITY = 120;
19
-    const EVENT_VENUES_PRIORITY = 130;
20
-
21
-    /**
22
-     * @type bool $using_get_the_excerpt
23
-     */
24
-    protected static $using_get_the_excerpt = false;
25
-
26
-
27
-    /**
28
-     * @type EE_Template_Part_Manager $template_parts
29
-     */
30
-    protected $template_parts;
31
-
32
-
33
-    /**
34
-     * @return EED_Module|EED_Event_Single
35
-     */
36
-    public static function instance()
37
-    {
38
-        return parent::get_instance(__CLASS__);
39
-    }
40
-
41
-
42
-    /**
43
-     * set_hooks - for hooking into EE Core, other modules, etc
44
-     *
45
-     * @return    void
46
-     */
47
-    public static function set_hooks()
48
-    {
49
-        add_filter('FHEE_run_EE_wp', '__return_true');
50
-        add_action('wp_loaded', array('EED_Event_Single', 'set_definitions'), 2);
51
-        EE_Config::register_route(__('event', 'event_espresso'), 'Event_Single', 'run');
52
-    }
53
-
54
-    /**
55
-     * set_hooks_admin - for hooking into EE Admin Core, other modules, etc
56
-     *
57
-     * @return    void
58
-     */
59
-    public static function set_hooks_admin()
60
-    {
61
-        add_action('wp_loaded', array('EED_Event_Single', 'set_definitions'), 2);
62
-    }
63
-
64
-
65
-    /**
66
-     * set_definitions
67
-     *
68
-     * @static
69
-     * @return void
70
-     */
71
-    public static function set_definitions()
72
-    {
73
-        define('EVENT_SINGLE_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets' . DS);
74
-        define('EVENT_SINGLE_TEMPLATES_PATH', plugin_dir_path(__FILE__) . 'templates' . DS);
75
-    }
76
-
77
-
78
-    /**
79
-     * set_config
80
-     *
81
-     * @void
82
-     */
83
-    protected function set_config()
84
-    {
85
-        $this->set_config_section('template_settings');
86
-        $this->set_config_class('EE_Event_Single_Config');
87
-        $this->set_config_name('EED_Event_Single');
88
-    }
89
-
90
-
91
-    /**
92
-     * initialize_template_parts
93
-     *
94
-     * @param EE_Config_Base|EE_Event_Single_Config $config
95
-     * @return EE_Template_Part_Manager
96
-     */
97
-    public function initialize_template_parts(EE_Event_Single_Config $config = null)
98
-    {
99
-        /** @type EE_Event_Single_Config $config */
100
-        $config = $config instanceof EE_Event_Single_Config ? $config : $this->config();
101
-        EEH_Autoloader::instance()->register_template_part_autoloaders();
102
-        $template_parts = new EE_Template_Part_Manager();
103
-        $template_parts->add_template_part(
104
-            'tickets',
105
-            __('Ticket Selector', 'event_espresso'),
106
-            'content-espresso_events-tickets.php',
107
-            $config->display_order_tickets
108
-        );
109
-        $template_parts->add_template_part(
110
-            'datetimes',
111
-            __('Dates and Times', 'event_espresso'),
112
-            'content-espresso_events-datetimes.php',
113
-            $config->display_order_datetimes
114
-        );
115
-        $template_parts->add_template_part(
116
-            'event',
117
-            __('Event Description', 'event_espresso'),
118
-            'content-espresso_events-details.php',
119
-            $config->display_order_event
120
-        );
121
-        $template_parts->add_template_part(
122
-            'venue',
123
-            __('Venue Information', 'event_espresso'),
124
-            'content-espresso_events-venues.php',
125
-            $config->display_order_venue
126
-        );
127
-        do_action('AHEE__EED_Event_Single__initialize_template_parts', $template_parts);
128
-        return $template_parts;
129
-    }
130
-
131
-
132
-    /**
133
-     * run - initial module setup
134
-     *
135
-     * @param WP $WP
136
-     * @return    void
137
-     */
138
-    public function run($WP)
139
-    {
140
-        // ensure valid EE_Events_Single_Config() object exists
141
-        $this->set_config();
142
-        // check what template is loaded
143
-        add_filter('template_include', array($this, 'template_include'), 999, 1);
144
-        add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
145
-        // load css
146
-        add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10);
147
-    }
148
-
149
-
150
-    /**
151
-     * template_include
152
-     *
153
-     * @param    string $template
154
-     * @return    string
155
-     */
156
-    public function template_include($template)
157
-    {
158
-        global $post;
159
-        /** @type EE_Event_Single_Config $config */
160
-        $config = $this->config();
161
-        if ($config->display_status_banner_single) {
162
-            add_filter('the_title', array('EED_Event_Single', 'the_title'), 100, 2);
163
-        }
164
-        // not a custom template?
165
-        if (
166
-            !post_password_required($post)
167
-            && (
168
-                apply_filters('FHEE__EED_Event_Single__template_include__allow_custom_selected_template', false)
169
-                || EE_Registry::instance()
170
-                    ->load_core('Front_Controller')
171
-                    ->get_selected_template() !== 'single-espresso_events.php'
172
-            )
173
-
174
-        ) {
175
-            EEH_Template::load_espresso_theme_functions();
176
-            // then add extra event data via hooks
177
-            add_action('loop_start', array('EED_Event_Single', 'loop_start'));
178
-            add_filter('get_the_excerpt', array('EED_Event_Single', 'get_the_excerpt'), 1, 1);
179
-            add_filter(
180
-                'the_content',
181
-                array('EED_Event_Single', 'event_details'),
182
-                EED_Event_Single::EVENT_DETAILS_PRIORITY
183
-            );
184
-            add_action('loop_end', array('EED_Event_Single', 'loop_end'));
185
-            // don't display entry meta because the existing theme will take car of that
186
-            add_filter('FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false');
187
-        }
188
-        return $template;
189
-    }
190
-
191
-
192
-    /**
193
-     * loop_start
194
-     *
195
-     * @param    array $wp_query_array an array containing the WP_Query object
196
-     * @return    void
197
-     */
198
-    public static function loop_start($wp_query_array)
199
-    {
200
-        global $post;
201
-        do_action('AHEE_event_details_before_post', $post, $wp_query_array);
202
-    }
203
-
204
-
205
-    /**
206
-     * the_title
207
-     *
208
-     * @param    string $title
209
-     * @param    int $id
210
-     * @return    string
211
-     */
212
-    public static function the_title($title = '', $id = 0)
213
-    {
214
-        global $post;
215
-        return in_the_loop() && $post->ID === (int)$id
216
-            ? espresso_event_status_banner($post->ID) . $title
217
-            : $title;
218
-    }
219
-
220
-
221
-    /**
222
-     * get_the_excerpt
223
-     * kinda hacky, but if a theme is using get_the_excerpt(),
224
-     * then we need to remove our filters on the_content()
225
-     *
226
-     * @param        string $excerpt
227
-     * @return        string
228
-     */
229
-    public static function get_the_excerpt($excerpt = '')
230
-    {
231
-        EED_Event_Single::$using_get_the_excerpt = true;
232
-        add_filter('wp_trim_excerpt', array('EED_Event_Single', 'end_get_the_excerpt'), 999, 1);
233
-        return $excerpt;
234
-    }
235
-
236
-
237
-    /**
238
-     * end_get_the_excerpt
239
-     *
240
-     * @param  string $text
241
-     * @return string
242
-     */
243
-    public static function end_get_the_excerpt($text = '')
244
-    {
245
-        EED_Event_Single::$using_get_the_excerpt = false;
246
-        return $text;
247
-    }
248
-
249
-
250
-    /**
251
-     * event_details
252
-     *
253
-     * @param    string $content
254
-     * @return    string
255
-     */
256
-    public static function event_details($content)
257
-    {
258
-        global $post;
259
-        static $current_post_ID = 0;
260
-        if (
261
-            $current_post_ID !== $post->ID
262
-            && $post->post_type === 'espresso_events'
263
-            && !EED_Event_Single::$using_get_the_excerpt
264
-            && !post_password_required()
265
-        ) {
266
-            // Set current post ID to prevent showing content twice, but only if headers have definitely been sent.
267
-            // Reason being is that some plugins, like Yoast, need to run through a copy of the loop early
268
-            // BEFORE headers are sent in order to examine the post content and generate content for the HTML header.
269
-            // We want to allow those plugins to still do their thing and have access to our content, but depending on
270
-            // how your event content is being displayed (shortcode, CPT route, etc), this filter can get applied twice,
271
-            // so the following allows this filter to be applied multiple times, but only once for real
272
-            $current_post_ID = did_action('loop_start') ? $post->ID : 0;
273
-            if (EE_Registry::instance()->CFG->template_settings->EED_Event_Single->use_sortable_display_order) {
274
-                // we need to first remove this callback from being applied to the_content()
275
-                // (otherwise it will recurse and blow up the interweb)
276
-                remove_filter(
277
-                    'the_content',
278
-                    array('EED_Event_Single', 'event_details'),
279
-                    EED_Event_Single::EVENT_DETAILS_PRIORITY
280
-                );
281
-                EED_Event_Single::instance()->template_parts = EED_Event_Single::instance()->initialize_template_parts();
282
-                $content = EEH_Template::locate_template('content-espresso_events-details.php');
283
-                $content = EED_Event_Single::instance()->template_parts->apply_template_part_filters($content);
284
-                add_filter(
285
-                    'the_content',
286
-                    array('EED_Event_Single', 'event_details'),
287
-                    EED_Event_Single::EVENT_DETAILS_PRIORITY
288
-                );
289
-            } else {
290
-                $content = EED_Event_Single::use_filterable_display_order();
291
-            }
292
-        }
293
-        return $content;
294
-    }
295
-
296
-
297
-    /**
298
-     * use_filterable_display_order
299
-     *
300
-     * @return string
301
-     */
302
-    protected static function use_filterable_display_order()
303
-    {
304
-        // since the 'content-espresso_events-details.php' template might be used directly from within a theme,
305
-        // it uses the_content() for displaying the $post->post_content
306
-        // so in order to load a template that uses the_content()
307
-        // from within a callback being used to filter the_content(),
308
-        // we need to first remove this callback from being applied to the_content()
309
-        // (otherwise it will recurse and blow up the interweb)
310
-        remove_filter(
311
-            'the_content',
312
-            array('EED_Event_Single', 'event_details'),
313
-            EED_Event_Single::EVENT_DETAILS_PRIORITY
314
-        );
315
-        //now add additional content
316
-        add_filter(
317
-            'the_content',
318
-            array('EED_Event_Single', 'event_datetimes'),
319
-            EED_Event_Single::EVENT_DATETIMES_PRIORITY,
320
-            1
321
-        );
322
-        add_filter(
323
-            'the_content',
324
-            array('EED_Event_Single', 'event_tickets'),
325
-            EED_Event_Single::EVENT_TICKETS_PRIORITY,
326
-            1
327
-        );
328
-        add_filter(
329
-            'the_content',
330
-            array('EED_Event_Single', 'event_venues'),
331
-            EED_Event_Single::EVENT_VENUES_PRIORITY,
332
-            1
333
-        );
334
-        do_action('AHEE__EED_Event_Single__use_filterable_display_order__after_add_filters');
335
-        // now load our template
336
-        $content = EEH_Template::locate_template('content-espresso_events-details.php');
337
-        //now add our filter back in, plus some others
338
-        add_filter(
339
-            'the_content',
340
-            array('EED_Event_Single', 'event_details'),
341
-            EED_Event_Single::EVENT_DETAILS_PRIORITY
342
-        );
343
-        remove_filter(
344
-            'the_content',
345
-            array('EED_Event_Single', 'event_datetimes'),
346
-            EED_Event_Single::EVENT_DATETIMES_PRIORITY
347
-        );
348
-        remove_filter(
349
-            'the_content',
350
-            array('EED_Event_Single', 'event_tickets'),
351
-            EED_Event_Single::EVENT_TICKETS_PRIORITY
352
-        );
353
-        remove_filter(
354
-            'the_content',
355
-            array('EED_Event_Single', 'event_venues'),
356
-            EED_Event_Single::EVENT_VENUES_PRIORITY
357
-        );
358
-        do_action('AHEE__EED_Event_Single__use_filterable_display_order__after_remove_filters');
359
-        // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt)
360
-        return $content;
361
-    }
362
-
363
-
364
-    /**
365
-     * event_datetimes - adds datetimes ABOVE content
366
-     *
367
-     * @param        string $content
368
-     * @return        string
369
-     */
370
-    public static function event_datetimes($content)
371
-    {
372
-        return EEH_Template::locate_template('content-espresso_events-datetimes.php') . $content;
373
-    }
374
-
375
-
376
-    /**
377
-     * event_tickets - adds tickets ABOVE content (which includes datetimes)
378
-     *
379
-     * @param        string $content
380
-     * @return        string
381
-     */
382
-    public static function event_tickets($content)
383
-    {
384
-        return EEH_Template::locate_template('content-espresso_events-tickets.php') . $content;
385
-    }
386
-
387
-
388
-    /**
389
-     * event_venues
390
-     *
391
-     * @param    string $content
392
-     * @return    string
393
-     */
394
-    public static function event_venue($content)
395
-    {
396
-        return EED_Event_Single::event_venues($content);
397
-    }
398
-
399
-
400
-    /**
401
-     * event_venues - adds venues BELOW content
402
-     *
403
-     * @param        string $content
404
-     * @return        string
405
-     */
406
-    public static function event_venues($content)
407
-    {
408
-        return $content . EEH_Template::locate_template('content-espresso_events-venues.php');
409
-    }
410
-
411
-
412
-    /**
413
-     * loop_end
414
-     *
415
-     * @param        array $wp_query_array an array containing the WP_Query object
416
-     * @return        void
417
-     */
418
-    public static function loop_end($wp_query_array)
419
-    {
420
-        global $post;
421
-        do_action('AHEE_event_details_after_post', $post, $wp_query_array);
422
-    }
423
-
424
-
425
-    /**
426
-     * wp_enqueue_scripts
427
-     *
428
-     * @return    void
429
-     */
430
-    public function wp_enqueue_scripts()
431
-    {
432
-        // get some style
433
-        if (
434
-            apply_filters('FHEE_enable_default_espresso_css', TRUE)
435
-            && apply_filters('FHEE__EED_Event_Single__wp_enqueue_scripts__enable_css', TRUE)
436
-        ) {
437
-            // first check uploads folder
438
-            if (is_readable(get_stylesheet_directory() . $this->theme . DS . 'style.css')) {
439
-                wp_register_style(
440
-                    $this->theme,
441
-                    get_stylesheet_directory_uri() . $this->theme . DS . 'style.css',
442
-                    array('dashicons', 'espresso_default')
443
-                );
444
-            } else {
445
-                wp_register_style(
446
-                    $this->theme,
447
-                    EE_TEMPLATES_URL . $this->theme . DS . 'style.css',
448
-                    array('dashicons', 'espresso_default')
449
-                );
450
-            }
451
-            wp_enqueue_script($this->theme);
452
-            if (EE_Registry::instance()->CFG->map_settings->use_google_maps) {
453
-                add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11);
454
-            }
455
-        }
456
-    }
457
-
458
-
459
-    /**
460
-     * display_venue
461
-     *
462
-     * @return    bool
463
-     */
464
-    public static function display_venue()
465
-    {
466
-        /** @type EE_Event_Single_Config $config */
467
-        $config = EED_Event_Single::instance()->config();
468
-        $display_venue = $config->display_venue === null ? true : $config->display_venue;
469
-        $venue_name = EEH_Venue_View::venue_name();
470
-        return $display_venue && !empty($venue_name);
471
-    }
16
+	const EVENT_DETAILS_PRIORITY = 100;
17
+	const EVENT_DATETIMES_PRIORITY = 110;
18
+	const EVENT_TICKETS_PRIORITY = 120;
19
+	const EVENT_VENUES_PRIORITY = 130;
20
+
21
+	/**
22
+	 * @type bool $using_get_the_excerpt
23
+	 */
24
+	protected static $using_get_the_excerpt = false;
25
+
26
+
27
+	/**
28
+	 * @type EE_Template_Part_Manager $template_parts
29
+	 */
30
+	protected $template_parts;
31
+
32
+
33
+	/**
34
+	 * @return EED_Module|EED_Event_Single
35
+	 */
36
+	public static function instance()
37
+	{
38
+		return parent::get_instance(__CLASS__);
39
+	}
40
+
41
+
42
+	/**
43
+	 * set_hooks - for hooking into EE Core, other modules, etc
44
+	 *
45
+	 * @return    void
46
+	 */
47
+	public static function set_hooks()
48
+	{
49
+		add_filter('FHEE_run_EE_wp', '__return_true');
50
+		add_action('wp_loaded', array('EED_Event_Single', 'set_definitions'), 2);
51
+		EE_Config::register_route(__('event', 'event_espresso'), 'Event_Single', 'run');
52
+	}
53
+
54
+	/**
55
+	 * set_hooks_admin - for hooking into EE Admin Core, other modules, etc
56
+	 *
57
+	 * @return    void
58
+	 */
59
+	public static function set_hooks_admin()
60
+	{
61
+		add_action('wp_loaded', array('EED_Event_Single', 'set_definitions'), 2);
62
+	}
63
+
64
+
65
+	/**
66
+	 * set_definitions
67
+	 *
68
+	 * @static
69
+	 * @return void
70
+	 */
71
+	public static function set_definitions()
72
+	{
73
+		define('EVENT_SINGLE_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets' . DS);
74
+		define('EVENT_SINGLE_TEMPLATES_PATH', plugin_dir_path(__FILE__) . 'templates' . DS);
75
+	}
76
+
77
+
78
+	/**
79
+	 * set_config
80
+	 *
81
+	 * @void
82
+	 */
83
+	protected function set_config()
84
+	{
85
+		$this->set_config_section('template_settings');
86
+		$this->set_config_class('EE_Event_Single_Config');
87
+		$this->set_config_name('EED_Event_Single');
88
+	}
89
+
90
+
91
+	/**
92
+	 * initialize_template_parts
93
+	 *
94
+	 * @param EE_Config_Base|EE_Event_Single_Config $config
95
+	 * @return EE_Template_Part_Manager
96
+	 */
97
+	public function initialize_template_parts(EE_Event_Single_Config $config = null)
98
+	{
99
+		/** @type EE_Event_Single_Config $config */
100
+		$config = $config instanceof EE_Event_Single_Config ? $config : $this->config();
101
+		EEH_Autoloader::instance()->register_template_part_autoloaders();
102
+		$template_parts = new EE_Template_Part_Manager();
103
+		$template_parts->add_template_part(
104
+			'tickets',
105
+			__('Ticket Selector', 'event_espresso'),
106
+			'content-espresso_events-tickets.php',
107
+			$config->display_order_tickets
108
+		);
109
+		$template_parts->add_template_part(
110
+			'datetimes',
111
+			__('Dates and Times', 'event_espresso'),
112
+			'content-espresso_events-datetimes.php',
113
+			$config->display_order_datetimes
114
+		);
115
+		$template_parts->add_template_part(
116
+			'event',
117
+			__('Event Description', 'event_espresso'),
118
+			'content-espresso_events-details.php',
119
+			$config->display_order_event
120
+		);
121
+		$template_parts->add_template_part(
122
+			'venue',
123
+			__('Venue Information', 'event_espresso'),
124
+			'content-espresso_events-venues.php',
125
+			$config->display_order_venue
126
+		);
127
+		do_action('AHEE__EED_Event_Single__initialize_template_parts', $template_parts);
128
+		return $template_parts;
129
+	}
130
+
131
+
132
+	/**
133
+	 * run - initial module setup
134
+	 *
135
+	 * @param WP $WP
136
+	 * @return    void
137
+	 */
138
+	public function run($WP)
139
+	{
140
+		// ensure valid EE_Events_Single_Config() object exists
141
+		$this->set_config();
142
+		// check what template is loaded
143
+		add_filter('template_include', array($this, 'template_include'), 999, 1);
144
+		add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
145
+		// load css
146
+		add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10);
147
+	}
148
+
149
+
150
+	/**
151
+	 * template_include
152
+	 *
153
+	 * @param    string $template
154
+	 * @return    string
155
+	 */
156
+	public function template_include($template)
157
+	{
158
+		global $post;
159
+		/** @type EE_Event_Single_Config $config */
160
+		$config = $this->config();
161
+		if ($config->display_status_banner_single) {
162
+			add_filter('the_title', array('EED_Event_Single', 'the_title'), 100, 2);
163
+		}
164
+		// not a custom template?
165
+		if (
166
+			!post_password_required($post)
167
+			&& (
168
+				apply_filters('FHEE__EED_Event_Single__template_include__allow_custom_selected_template', false)
169
+				|| EE_Registry::instance()
170
+					->load_core('Front_Controller')
171
+					->get_selected_template() !== 'single-espresso_events.php'
172
+			)
173
+
174
+		) {
175
+			EEH_Template::load_espresso_theme_functions();
176
+			// then add extra event data via hooks
177
+			add_action('loop_start', array('EED_Event_Single', 'loop_start'));
178
+			add_filter('get_the_excerpt', array('EED_Event_Single', 'get_the_excerpt'), 1, 1);
179
+			add_filter(
180
+				'the_content',
181
+				array('EED_Event_Single', 'event_details'),
182
+				EED_Event_Single::EVENT_DETAILS_PRIORITY
183
+			);
184
+			add_action('loop_end', array('EED_Event_Single', 'loop_end'));
185
+			// don't display entry meta because the existing theme will take car of that
186
+			add_filter('FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false');
187
+		}
188
+		return $template;
189
+	}
190
+
191
+
192
+	/**
193
+	 * loop_start
194
+	 *
195
+	 * @param    array $wp_query_array an array containing the WP_Query object
196
+	 * @return    void
197
+	 */
198
+	public static function loop_start($wp_query_array)
199
+	{
200
+		global $post;
201
+		do_action('AHEE_event_details_before_post', $post, $wp_query_array);
202
+	}
203
+
204
+
205
+	/**
206
+	 * the_title
207
+	 *
208
+	 * @param    string $title
209
+	 * @param    int $id
210
+	 * @return    string
211
+	 */
212
+	public static function the_title($title = '', $id = 0)
213
+	{
214
+		global $post;
215
+		return in_the_loop() && $post->ID === (int)$id
216
+			? espresso_event_status_banner($post->ID) . $title
217
+			: $title;
218
+	}
219
+
220
+
221
+	/**
222
+	 * get_the_excerpt
223
+	 * kinda hacky, but if a theme is using get_the_excerpt(),
224
+	 * then we need to remove our filters on the_content()
225
+	 *
226
+	 * @param        string $excerpt
227
+	 * @return        string
228
+	 */
229
+	public static function get_the_excerpt($excerpt = '')
230
+	{
231
+		EED_Event_Single::$using_get_the_excerpt = true;
232
+		add_filter('wp_trim_excerpt', array('EED_Event_Single', 'end_get_the_excerpt'), 999, 1);
233
+		return $excerpt;
234
+	}
235
+
236
+
237
+	/**
238
+	 * end_get_the_excerpt
239
+	 *
240
+	 * @param  string $text
241
+	 * @return string
242
+	 */
243
+	public static function end_get_the_excerpt($text = '')
244
+	{
245
+		EED_Event_Single::$using_get_the_excerpt = false;
246
+		return $text;
247
+	}
248
+
249
+
250
+	/**
251
+	 * event_details
252
+	 *
253
+	 * @param    string $content
254
+	 * @return    string
255
+	 */
256
+	public static function event_details($content)
257
+	{
258
+		global $post;
259
+		static $current_post_ID = 0;
260
+		if (
261
+			$current_post_ID !== $post->ID
262
+			&& $post->post_type === 'espresso_events'
263
+			&& !EED_Event_Single::$using_get_the_excerpt
264
+			&& !post_password_required()
265
+		) {
266
+			// Set current post ID to prevent showing content twice, but only if headers have definitely been sent.
267
+			// Reason being is that some plugins, like Yoast, need to run through a copy of the loop early
268
+			// BEFORE headers are sent in order to examine the post content and generate content for the HTML header.
269
+			// We want to allow those plugins to still do their thing and have access to our content, but depending on
270
+			// how your event content is being displayed (shortcode, CPT route, etc), this filter can get applied twice,
271
+			// so the following allows this filter to be applied multiple times, but only once for real
272
+			$current_post_ID = did_action('loop_start') ? $post->ID : 0;
273
+			if (EE_Registry::instance()->CFG->template_settings->EED_Event_Single->use_sortable_display_order) {
274
+				// we need to first remove this callback from being applied to the_content()
275
+				// (otherwise it will recurse and blow up the interweb)
276
+				remove_filter(
277
+					'the_content',
278
+					array('EED_Event_Single', 'event_details'),
279
+					EED_Event_Single::EVENT_DETAILS_PRIORITY
280
+				);
281
+				EED_Event_Single::instance()->template_parts = EED_Event_Single::instance()->initialize_template_parts();
282
+				$content = EEH_Template::locate_template('content-espresso_events-details.php');
283
+				$content = EED_Event_Single::instance()->template_parts->apply_template_part_filters($content);
284
+				add_filter(
285
+					'the_content',
286
+					array('EED_Event_Single', 'event_details'),
287
+					EED_Event_Single::EVENT_DETAILS_PRIORITY
288
+				);
289
+			} else {
290
+				$content = EED_Event_Single::use_filterable_display_order();
291
+			}
292
+		}
293
+		return $content;
294
+	}
295
+
296
+
297
+	/**
298
+	 * use_filterable_display_order
299
+	 *
300
+	 * @return string
301
+	 */
302
+	protected static function use_filterable_display_order()
303
+	{
304
+		// since the 'content-espresso_events-details.php' template might be used directly from within a theme,
305
+		// it uses the_content() for displaying the $post->post_content
306
+		// so in order to load a template that uses the_content()
307
+		// from within a callback being used to filter the_content(),
308
+		// we need to first remove this callback from being applied to the_content()
309
+		// (otherwise it will recurse and blow up the interweb)
310
+		remove_filter(
311
+			'the_content',
312
+			array('EED_Event_Single', 'event_details'),
313
+			EED_Event_Single::EVENT_DETAILS_PRIORITY
314
+		);
315
+		//now add additional content
316
+		add_filter(
317
+			'the_content',
318
+			array('EED_Event_Single', 'event_datetimes'),
319
+			EED_Event_Single::EVENT_DATETIMES_PRIORITY,
320
+			1
321
+		);
322
+		add_filter(
323
+			'the_content',
324
+			array('EED_Event_Single', 'event_tickets'),
325
+			EED_Event_Single::EVENT_TICKETS_PRIORITY,
326
+			1
327
+		);
328
+		add_filter(
329
+			'the_content',
330
+			array('EED_Event_Single', 'event_venues'),
331
+			EED_Event_Single::EVENT_VENUES_PRIORITY,
332
+			1
333
+		);
334
+		do_action('AHEE__EED_Event_Single__use_filterable_display_order__after_add_filters');
335
+		// now load our template
336
+		$content = EEH_Template::locate_template('content-espresso_events-details.php');
337
+		//now add our filter back in, plus some others
338
+		add_filter(
339
+			'the_content',
340
+			array('EED_Event_Single', 'event_details'),
341
+			EED_Event_Single::EVENT_DETAILS_PRIORITY
342
+		);
343
+		remove_filter(
344
+			'the_content',
345
+			array('EED_Event_Single', 'event_datetimes'),
346
+			EED_Event_Single::EVENT_DATETIMES_PRIORITY
347
+		);
348
+		remove_filter(
349
+			'the_content',
350
+			array('EED_Event_Single', 'event_tickets'),
351
+			EED_Event_Single::EVENT_TICKETS_PRIORITY
352
+		);
353
+		remove_filter(
354
+			'the_content',
355
+			array('EED_Event_Single', 'event_venues'),
356
+			EED_Event_Single::EVENT_VENUES_PRIORITY
357
+		);
358
+		do_action('AHEE__EED_Event_Single__use_filterable_display_order__after_remove_filters');
359
+		// we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt)
360
+		return $content;
361
+	}
362
+
363
+
364
+	/**
365
+	 * event_datetimes - adds datetimes ABOVE content
366
+	 *
367
+	 * @param        string $content
368
+	 * @return        string
369
+	 */
370
+	public static function event_datetimes($content)
371
+	{
372
+		return EEH_Template::locate_template('content-espresso_events-datetimes.php') . $content;
373
+	}
374
+
375
+
376
+	/**
377
+	 * event_tickets - adds tickets ABOVE content (which includes datetimes)
378
+	 *
379
+	 * @param        string $content
380
+	 * @return        string
381
+	 */
382
+	public static function event_tickets($content)
383
+	{
384
+		return EEH_Template::locate_template('content-espresso_events-tickets.php') . $content;
385
+	}
386
+
387
+
388
+	/**
389
+	 * event_venues
390
+	 *
391
+	 * @param    string $content
392
+	 * @return    string
393
+	 */
394
+	public static function event_venue($content)
395
+	{
396
+		return EED_Event_Single::event_venues($content);
397
+	}
398
+
399
+
400
+	/**
401
+	 * event_venues - adds venues BELOW content
402
+	 *
403
+	 * @param        string $content
404
+	 * @return        string
405
+	 */
406
+	public static function event_venues($content)
407
+	{
408
+		return $content . EEH_Template::locate_template('content-espresso_events-venues.php');
409
+	}
410
+
411
+
412
+	/**
413
+	 * loop_end
414
+	 *
415
+	 * @param        array $wp_query_array an array containing the WP_Query object
416
+	 * @return        void
417
+	 */
418
+	public static function loop_end($wp_query_array)
419
+	{
420
+		global $post;
421
+		do_action('AHEE_event_details_after_post', $post, $wp_query_array);
422
+	}
423
+
424
+
425
+	/**
426
+	 * wp_enqueue_scripts
427
+	 *
428
+	 * @return    void
429
+	 */
430
+	public function wp_enqueue_scripts()
431
+	{
432
+		// get some style
433
+		if (
434
+			apply_filters('FHEE_enable_default_espresso_css', TRUE)
435
+			&& apply_filters('FHEE__EED_Event_Single__wp_enqueue_scripts__enable_css', TRUE)
436
+		) {
437
+			// first check uploads folder
438
+			if (is_readable(get_stylesheet_directory() . $this->theme . DS . 'style.css')) {
439
+				wp_register_style(
440
+					$this->theme,
441
+					get_stylesheet_directory_uri() . $this->theme . DS . 'style.css',
442
+					array('dashicons', 'espresso_default')
443
+				);
444
+			} else {
445
+				wp_register_style(
446
+					$this->theme,
447
+					EE_TEMPLATES_URL . $this->theme . DS . 'style.css',
448
+					array('dashicons', 'espresso_default')
449
+				);
450
+			}
451
+			wp_enqueue_script($this->theme);
452
+			if (EE_Registry::instance()->CFG->map_settings->use_google_maps) {
453
+				add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11);
454
+			}
455
+		}
456
+	}
457
+
458
+
459
+	/**
460
+	 * display_venue
461
+	 *
462
+	 * @return    bool
463
+	 */
464
+	public static function display_venue()
465
+	{
466
+		/** @type EE_Event_Single_Config $config */
467
+		$config = EED_Event_Single::instance()->config();
468
+		$display_venue = $config->display_venue === null ? true : $config->display_venue;
469
+		$venue_name = EEH_Venue_View::venue_name();
470
+		return $display_venue && !empty($venue_name);
471
+	}
472 472
 
473 473
 
474 474
 }
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
  */
483 483
 function espresso_display_venue_in_event_details()
484 484
 {
485
-    return EED_Event_Single::display_venue();
485
+	return EED_Event_Single::display_venue();
486 486
 }
487 487
 
488 488
 
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -70,8 +70,8 @@  discard block
 block discarded – undo
70 70
      */
71 71
     public static function set_definitions()
72 72
     {
73
-        define('EVENT_SINGLE_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets' . DS);
74
-        define('EVENT_SINGLE_TEMPLATES_PATH', plugin_dir_path(__FILE__) . 'templates' . DS);
73
+        define('EVENT_SINGLE_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS);
74
+        define('EVENT_SINGLE_TEMPLATES_PATH', plugin_dir_path(__FILE__).'templates'.DS);
75 75
     }
76 76
 
77 77
 
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
         }
164 164
         // not a custom template?
165 165
         if (
166
-            !post_password_required($post)
166
+            ! post_password_required($post)
167 167
             && (
168 168
                 apply_filters('FHEE__EED_Event_Single__template_include__allow_custom_selected_template', false)
169 169
                 || EE_Registry::instance()
@@ -212,8 +212,8 @@  discard block
 block discarded – undo
212 212
     public static function the_title($title = '', $id = 0)
213 213
     {
214 214
         global $post;
215
-        return in_the_loop() && $post->ID === (int)$id
216
-            ? espresso_event_status_banner($post->ID) . $title
215
+        return in_the_loop() && $post->ID === (int) $id
216
+            ? espresso_event_status_banner($post->ID).$title
217 217
             : $title;
218 218
     }
219 219
 
@@ -260,8 +260,8 @@  discard block
 block discarded – undo
260 260
         if (
261 261
             $current_post_ID !== $post->ID
262 262
             && $post->post_type === 'espresso_events'
263
-            && !EED_Event_Single::$using_get_the_excerpt
264
-            && !post_password_required()
263
+            && ! EED_Event_Single::$using_get_the_excerpt
264
+            && ! post_password_required()
265 265
         ) {
266 266
             // Set current post ID to prevent showing content twice, but only if headers have definitely been sent.
267 267
             // Reason being is that some plugins, like Yoast, need to run through a copy of the loop early
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
      */
370 370
     public static function event_datetimes($content)
371 371
     {
372
-        return EEH_Template::locate_template('content-espresso_events-datetimes.php') . $content;
372
+        return EEH_Template::locate_template('content-espresso_events-datetimes.php').$content;
373 373
     }
374 374
 
375 375
 
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
      */
382 382
     public static function event_tickets($content)
383 383
     {
384
-        return EEH_Template::locate_template('content-espresso_events-tickets.php') . $content;
384
+        return EEH_Template::locate_template('content-espresso_events-tickets.php').$content;
385 385
     }
386 386
 
387 387
 
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
      */
406 406
     public static function event_venues($content)
407 407
     {
408
-        return $content . EEH_Template::locate_template('content-espresso_events-venues.php');
408
+        return $content.EEH_Template::locate_template('content-espresso_events-venues.php');
409 409
     }
410 410
 
411 411
 
@@ -435,16 +435,16 @@  discard block
 block discarded – undo
435 435
             && apply_filters('FHEE__EED_Event_Single__wp_enqueue_scripts__enable_css', TRUE)
436 436
         ) {
437 437
             // first check uploads folder
438
-            if (is_readable(get_stylesheet_directory() . $this->theme . DS . 'style.css')) {
438
+            if (is_readable(get_stylesheet_directory().$this->theme.DS.'style.css')) {
439 439
                 wp_register_style(
440 440
                     $this->theme,
441
-                    get_stylesheet_directory_uri() . $this->theme . DS . 'style.css',
441
+                    get_stylesheet_directory_uri().$this->theme.DS.'style.css',
442 442
                     array('dashicons', 'espresso_default')
443 443
                 );
444 444
             } else {
445 445
                 wp_register_style(
446 446
                     $this->theme,
447
-                    EE_TEMPLATES_URL . $this->theme . DS . 'style.css',
447
+                    EE_TEMPLATES_URL.$this->theme.DS.'style.css',
448 448
                     array('dashicons', 'espresso_default')
449 449
                 );
450 450
             }
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
         $config = EED_Event_Single::instance()->config();
468 468
         $display_venue = $config->display_venue === null ? true : $config->display_venue;
469 469
         $venue_name = EEH_Venue_View::venue_name();
470
-        return $display_venue && !empty($venue_name);
470
+        return $display_venue && ! empty($venue_name);
471 471
     }
472 472
 
473 473
 
Please login to merge, or discard this patch.
modules/messages/EED_Messages.module.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -570,7 +570,7 @@
 block discarded – undo
570 570
      * @deprecated 4.9.0 Use EEH_MSG_Template::payment_status_to_message_type_array
571 571
      *                   or EEH_MSG_Template::convert_payment_status_to_message_type
572 572
      * @param string $payment_status The payment status being matched.
573
-     * @return string|bool The payment message type slug matching the status or false if no match.
573
+     * @return string|false The payment message type slug matching the status or false if no match.
574 574
      */
575 575
     protected static function _get_payment_message_type($payment_status)
576 576
     {
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
             $error_msg = __('Please note that a system message failed to send due to a technical issue.',
151 151
                 'event_espresso');
152 152
             // add specific message for developers if WP_DEBUG in on
153
-            $error_msg .= '||' . $e->getMessage();
153
+            $error_msg .= '||'.$e->getMessage();
154 154
             EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
155 155
         }
156 156
     }
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
             $error_msg = __('Please note that a system message failed to send due to a technical issue.',
227 227
                 'event_espresso');
228 228
             // add specific message for developers if WP_DEBUG in on
229
-            $error_msg .= '||' . $e->getMessage();
229
+            $error_msg .= '||'.$e->getMessage();
230 230
             EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
231 231
         }
232 232
     }
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
         $transient_key = EE_Registry::instance()->REQ->get('key');
258 258
 
259 259
         //now let's verify transient, if not valid exit immediately
260
-        if (! get_transient($transient_key)) {
260
+        if ( ! get_transient($transient_key)) {
261 261
             /**
262 262
              * trigger error so this gets in the error logs.  This is important because it happens on a non-user request.
263 263
              */
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 
270 270
         if (apply_filters('FHEE__EED_Messages__run_cron__use_wp_cron', true)) {
271 271
 
272
-            $method = 'batch_' . $cron_type . '_from_queue';
272
+            $method = 'batch_'.$cron_type.'_from_queue';
273 273
             if (method_exists(self::$_MSG_PROCESSOR, $method)) {
274 274
                 self::$_MSG_PROCESSOR->$method();
275 275
             } else {
@@ -366,9 +366,9 @@  discard block
 block discarded – undo
366 366
             'messages/validators/html',
367 367
             'shortcodes',
368 368
         );
369
-        $paths   = array();
369
+        $paths = array();
370 370
         foreach ($dir_ref as $index => $dir) {
371
-            $paths[$index] = EE_LIBRARIES . $dir;
371
+            $paths[$index] = EE_LIBRARIES.$dir;
372 372
         }
373 373
         self::$_MSG_PATHS = apply_filters('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', $paths);
374 374
     }
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
      */
383 383
     protected static function _load_controller()
384 384
     {
385
-        if (! self::$_MSG_PROCESSOR instanceof EE_Messages_Processor) {
385
+        if ( ! self::$_MSG_PROCESSOR instanceof EE_Messages_Processor) {
386 386
             EE_Registry::instance()->load_core('Request_Handler');
387 387
             self::set_autoloaders();
388 388
             self::$_EEMSG                    = EE_Registry::instance()->load_lib('messages');
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
     public static function maybe_registration(EE_Registration $registration, $extra_details = array())
446 446
     {
447 447
 
448
-        if (! self::_verify_registration_notification_send($registration, $extra_details)) {
448
+        if ( ! self::_verify_registration_notification_send($registration, $extra_details)) {
449 449
             //no messages please
450 450
             return;
451 451
         }
@@ -510,7 +510,7 @@  discard block
 block discarded – undo
510 510
         //	array( '$extra_details' => $extra_details )
511 511
         //);
512 512
         // currently only using this to send messages for the primary registrant
513
-        if (! $registration->is_primary_registrant()) {
513
+        if ( ! $registration->is_primary_registrant()) {
514 514
             return false;
515 515
         }
516 516
         // first we check if we're in admin and not doing front ajax
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
         } else {
524 524
             // frontend request (either regular or via AJAX)
525 525
             // TXN is NOT finalized ?
526
-            if (! isset($extra_details['finalized']) || $extra_details['finalized'] === false) {
526
+            if ( ! isset($extra_details['finalized']) || $extra_details['finalized'] === false) {
527 527
                 return false;
528 528
             }
529 529
             // return visit but nothing changed ???
@@ -598,12 +598,12 @@  discard block
 block discarded – undo
598 598
         }
599 599
 
600 600
         //make sure any incoming request data is set on the REQ so that it gets picked up later.
601
-        $req_data = (array)$req_data;
601
+        $req_data = (array) $req_data;
602 602
         foreach ($req_data as $request_key => $request_value) {
603 603
             EE_Registry::instance()->REQ->set($request_key, $request_value);
604 604
         }
605 605
 
606
-        if (! $messages_to_send = self::$_MSG_PROCESSOR->setup_messages_to_generate_from_registration_ids_in_request()) {
606
+        if ( ! $messages_to_send = self::$_MSG_PROCESSOR->setup_messages_to_generate_from_registration_ids_in_request()) {
607 607
             return false;
608 608
         }
609 609
 
@@ -631,13 +631,13 @@  discard block
 block discarded – undo
631 631
         self::_load_controller();
632 632
 
633 633
         $msgID = EE_Registry::instance()->REQ->get('MSG_ID');
634
-        if (! $msgID) {
634
+        if ( ! $msgID) {
635 635
             EE_Error::add_error(__('Something went wrong because there is no "MSG_ID" value in the request',
636 636
                 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
637 637
             return false;
638 638
         }
639 639
 
640
-        self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send((array)$msgID);
640
+        self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send((array) $msgID);
641 641
 
642 642
         //setup success message.
643 643
         $count_ready_for_resend = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_resend);
@@ -732,7 +732,7 @@  discard block
 block discarded – undo
732 732
     public static function send_newsletter_message($registrations, $grp_id)
733 733
     {
734 734
         //make sure mtp is id and set it in the EE_Request Handler later messages setup.
735
-        EE_Registry::instance()->REQ->set('GRP_ID', (int)$grp_id);
735
+        EE_Registry::instance()->REQ->set('GRP_ID', (int) $grp_id);
736 736
         self::_load_controller();
737 737
         self::$_MSG_PROCESSOR->generate_for_all_active_messengers('newsletter', $registrations);
738 738
     }
@@ -788,14 +788,14 @@  discard block
 block discarded – undo
788 788
             //get the message template group.
789 789
             $msg_template_group = EEM_Message_Template_Group::instance()->get_one(array($template_query_params));
790 790
             //if we don't have an EE_Message_Template_Group then return
791
-            if (! $msg_template_group instanceof EE_Message_Template_Group) {
791
+            if ( ! $msg_template_group instanceof EE_Message_Template_Group) {
792 792
                 // remove EVT_ID from query params so that global templates get picked up
793 793
                 unset($template_query_params['Event.EVT_ID']);
794 794
                 //get global template as the fallback
795 795
                 $msg_template_group = EEM_Message_Template_Group::instance()->get_one(array($template_query_params));
796 796
             }
797 797
             //if we don't have an EE_Message_Template_Group then return
798
-            if (! $msg_template_group instanceof EE_Message_Template_Group) {
798
+            if ( ! $msg_template_group instanceof EE_Message_Template_Group) {
799 799
                 return '';
800 800
             }
801 801
             // generate the URL
@@ -827,7 +827,7 @@  discard block
 block discarded – undo
827 827
     public static function preview_message($type, $context, $messenger, $send = false)
828 828
     {
829 829
         self::_load_controller();
830
-        $mtg                     = new EE_Message_To_Generate(
830
+        $mtg = new EE_Message_To_Generate(
831 831
             $messenger,
832 832
             $type,
833 833
             array(),
@@ -891,7 +891,7 @@  discard block
 block discarded – undo
891 891
     public static function generate_now($message_ids)
892 892
     {
893 893
         self::_load_controller();
894
-        $messages        = EEM_Message::instance()->get_all(
894
+        $messages = EEM_Message::instance()->get_all(
895 895
             array(
896 896
                 0 => array(
897 897
                     'MSG_ID' => array('IN', $message_ids),
@@ -904,7 +904,7 @@  discard block
 block discarded – undo
904 904
             $generated_queue = self::$_MSG_PROCESSOR->batch_generate_from_queue($messages);
905 905
         }
906 906
 
907
-        if (! $generated_queue instanceof EE_Messages_Queue) {
907
+        if ( ! $generated_queue instanceof EE_Messages_Queue) {
908 908
             EE_Error::add_error(
909 909
                 __('The messages were not generated. This could mean there is already a batch being generated on a separate request, or because the selected messages are not ready for generation. Please wait a minute or two and try again.',
910 910
                     'event_espresso'),
@@ -926,7 +926,7 @@  discard block
 block discarded – undo
926 926
     public static function send_now($message_ids)
927 927
     {
928 928
         self::_load_controller();
929
-        $messages   = EEM_Message::instance()->get_all(
929
+        $messages = EEM_Message::instance()->get_all(
930 930
             array(
931 931
                 0 => array(
932 932
                     'MSG_ID' => array('IN', $message_ids),
@@ -942,7 +942,7 @@  discard block
 block discarded – undo
942 942
             $sent_queue = self::$_MSG_PROCESSOR->batch_send_from_queue($messages);
943 943
         }
944 944
 
945
-        if (! $sent_queue instanceof EE_Messages_Queue) {
945
+        if ( ! $sent_queue instanceof EE_Messages_Queue) {
946 946
             EE_Error::add_error(
947 947
                 __('The messages were not sent. This could mean there is already a batch being sent on a separate request, or because the selected messages are not sendable. Please wait a minute or two and try again.',
948 948
                     'event_espresso'),
@@ -1042,7 +1042,7 @@  discard block
 block discarded – undo
1042 1042
                 __FILE__, __FUNCTION__, __LINE__
1043 1043
             );
1044 1044
         }
1045
-        return (bool)$queue_count;
1045
+        return (bool) $queue_count;
1046 1046
     }
1047 1047
 
1048 1048
 
@@ -1071,7 +1071,7 @@  discard block
 block discarded – undo
1071 1071
                 $info['TXN_status']    = $transaction->status_ID();
1072 1072
                 $info['TXN_reg_steps'] = $transaction->reg_steps();
1073 1073
                 if ($transaction->ID()) {
1074
-                    $index = 'EE_Transaction: ' . $transaction->ID();
1074
+                    $index = 'EE_Transaction: '.$transaction->ID();
1075 1075
                     EEH_Debug_Tools::log($class, $func, $line, $info, $display_request, $index);
1076 1076
                 }
1077 1077
             }
Please login to merge, or discard this patch.
Indentation   +1059 added lines, -1059 removed lines patch added patch discarded remove patch
@@ -13,1074 +13,1074 @@
 block discarded – undo
13 13
 class EED_Messages extends EED_Module
14 14
 {
15 15
 
16
-    /**
17
-     * This holds the EE_messages controller
18
-     *
19
-     * @deprecated 4.9.0
20
-     * @var EE_messages $_EEMSG
21
-     */
22
-    protected static $_EEMSG;
23
-
24
-    /**
25
-     * @type EE_Message_Resource_Manager $_message_resource_manager
26
-     */
27
-    protected static $_message_resource_manager;
28
-
29
-    /**
30
-     * This holds the EE_Messages_Processor business class.
31
-     *
32
-     * @type EE_Messages_Processor
33
-     */
34
-    protected static $_MSG_PROCESSOR;
35
-
36
-    /**
37
-     * holds all the paths for various messages components.
38
-     * Utilized by autoloader registry
39
-     *
40
-     * @var array
41
-     */
42
-    protected static $_MSG_PATHS;
43
-
44
-
45
-    /**
46
-     * This will hold an array of messages template packs that are registered in the messages system.
47
-     * Format is:
48
-     * array(
49
-     *    'template_pack_dbref' => EE_Messages_Template_Pack (instance)
50
-     * )
51
-     *
52
-     * @var EE_Messages_Template_Pack[]
53
-     */
54
-    protected static $_TMP_PACKS = array();
55
-
56
-
57
-    /**
58
-     * @return EED_Messages
59
-     */
60
-    public static function instance()
61
-    {
62
-        return parent::get_instance(__CLASS__);
63
-    }
64
-
65
-
66
-    /**
67
-     *  set_hooks - for hooking into EE Core, other modules, etc
68
-     *
69
-     * @since 4.5.0
70
-     * @return    void
71
-     */
72
-    public static function set_hooks()
73
-    {
74
-        //actions
75
-        add_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', array('EED_Messages', 'payment'), 10, 2);
76
-        add_action('AHEE__EE_Registration_Processor__trigger_registration_update_notifications',
77
-            array('EED_Messages', 'maybe_registration'), 10, 2);
78
-        //filters
79
-        add_filter('FHEE__EE_Registration__receipt_url__receipt_url',
80
-            array('EED_Messages', 'registration_message_trigger_url'), 10, 4);
81
-        add_filter('FHEE__EE_Registration__invoice_url__invoice_url',
82
-            array('EED_Messages', 'registration_message_trigger_url'), 10, 4);
83
-        //register routes
84
-        self::_register_routes();
85
-    }
86
-
87
-    /**
88
-     *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
89
-     *
90
-     * @access    public
91
-     * @return    void
92
-     */
93
-    public static function set_hooks_admin()
94
-    {
95
-        //actions
96
-        add_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', array('EED_Messages', 'payment'), 10, 2);
97
-        add_action('AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder',
98
-            array('EED_Messages', 'payment_reminder'), 10);
99
-        add_action('AHEE__EE_Registration_Processor__trigger_registration_update_notifications',
100
-            array('EED_Messages', 'maybe_registration'), 10, 3);
101
-        add_action('AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations',
102
-            array('EED_Messages', 'send_newsletter_message'), 10, 2);
103
-        add_action('AHEE__EES_Espresso_Cancelled__process_shortcode__transaction',
104
-            array('EED_Messages', 'cancelled_registration'), 10);
105
-        add_action('AHEE__EE_Admin_Page___process_admin_payment_notification',
106
-            array('EED_Messages', 'process_admin_payment'), 10, 1);
107
-        //filters
108
-        add_filter('FHEE__EE_Admin_Page___process_resend_registration__success',
109
-            array('EED_Messages', 'process_resend'), 10, 2);
110
-        add_filter('FHEE__EE_Registration__receipt_url__receipt_url',
111
-            array('EED_Messages', 'registration_message_trigger_url'), 10, 4);
112
-        add_filter('FHEE__EE_Registration__invoice_url__invoice_url',
113
-            array('EED_Messages', 'registration_message_trigger_url'), 10, 4);
114
-    }
115
-
116
-
117
-    /**
118
-     * All the message triggers done by route go in here.
119
-     *
120
-     * @since 4.5.0
121
-     * @return void
122
-     */
123
-    protected static function _register_routes()
124
-    {
125
-        EE_Config::register_route('msg_url_trigger', 'Messages', 'run');
126
-        EE_Config::register_route('msg_cron_trigger', 'Messages', 'execute_batch_request');
127
-        EE_Config::register_route('msg_browser_trigger', 'Messages', 'browser_trigger');
128
-        EE_Config::register_route('msg_browser_error_trigger', 'Messages', 'browser_error_trigger');
129
-        do_action('AHEE__EED_Messages___register_routes');
130
-    }
131
-
132
-
133
-    /**
134
-     * This is called when a browser display trigger is executed.
135
-     * The browser display trigger is typically used when a already generated message is displayed directly in the
136
-     * browser.
137
-     *
138
-     * @since 4.9.0
139
-     * @param WP $WP
140
-     */
141
-    public function browser_trigger($WP)
142
-    {
143
-        //ensure controller is loaded
144
-        self::_load_controller();
145
-        $token = EE_Registry::instance()->REQ->get('token');
146
-        try {
147
-            $mtg = new EE_Message_Generated_From_Token($token, 'html', self::$_message_resource_manager);
148
-            self::$_MSG_PROCESSOR->generate_and_send_now($mtg);
149
-        } catch (EE_Error $e) {
150
-            $error_msg = __('Please note that a system message failed to send due to a technical issue.',
151
-                'event_espresso');
152
-            // add specific message for developers if WP_DEBUG in on
153
-            $error_msg .= '||' . $e->getMessage();
154
-            EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
155
-        }
156
-    }
157
-
158
-
159
-    /**
160
-     * This is called when a browser error trigger is executed.
161
-     * When triggered this will grab the EE_Message matching the token in the request and use that to get the error
162
-     * message and display it.
163
-     *
164
-     * @since 4.9.0
165
-     * @param $WP
166
-     */
167
-    public function browser_error_trigger($WP)
168
-    {
169
-        $token = EE_Registry::instance()->REQ->get('token');
170
-        if ($token) {
171
-            $message = EEM_Message::instance()->get_one_by_token($token);
172
-            if ($message instanceof EE_Message) {
173
-                header('HTTP/1.1 200 OK');
174
-                $error_msg = nl2br($message->error_message());
175
-                ?>
16
+	/**
17
+	 * This holds the EE_messages controller
18
+	 *
19
+	 * @deprecated 4.9.0
20
+	 * @var EE_messages $_EEMSG
21
+	 */
22
+	protected static $_EEMSG;
23
+
24
+	/**
25
+	 * @type EE_Message_Resource_Manager $_message_resource_manager
26
+	 */
27
+	protected static $_message_resource_manager;
28
+
29
+	/**
30
+	 * This holds the EE_Messages_Processor business class.
31
+	 *
32
+	 * @type EE_Messages_Processor
33
+	 */
34
+	protected static $_MSG_PROCESSOR;
35
+
36
+	/**
37
+	 * holds all the paths for various messages components.
38
+	 * Utilized by autoloader registry
39
+	 *
40
+	 * @var array
41
+	 */
42
+	protected static $_MSG_PATHS;
43
+
44
+
45
+	/**
46
+	 * This will hold an array of messages template packs that are registered in the messages system.
47
+	 * Format is:
48
+	 * array(
49
+	 *    'template_pack_dbref' => EE_Messages_Template_Pack (instance)
50
+	 * )
51
+	 *
52
+	 * @var EE_Messages_Template_Pack[]
53
+	 */
54
+	protected static $_TMP_PACKS = array();
55
+
56
+
57
+	/**
58
+	 * @return EED_Messages
59
+	 */
60
+	public static function instance()
61
+	{
62
+		return parent::get_instance(__CLASS__);
63
+	}
64
+
65
+
66
+	/**
67
+	 *  set_hooks - for hooking into EE Core, other modules, etc
68
+	 *
69
+	 * @since 4.5.0
70
+	 * @return    void
71
+	 */
72
+	public static function set_hooks()
73
+	{
74
+		//actions
75
+		add_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', array('EED_Messages', 'payment'), 10, 2);
76
+		add_action('AHEE__EE_Registration_Processor__trigger_registration_update_notifications',
77
+			array('EED_Messages', 'maybe_registration'), 10, 2);
78
+		//filters
79
+		add_filter('FHEE__EE_Registration__receipt_url__receipt_url',
80
+			array('EED_Messages', 'registration_message_trigger_url'), 10, 4);
81
+		add_filter('FHEE__EE_Registration__invoice_url__invoice_url',
82
+			array('EED_Messages', 'registration_message_trigger_url'), 10, 4);
83
+		//register routes
84
+		self::_register_routes();
85
+	}
86
+
87
+	/**
88
+	 *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
89
+	 *
90
+	 * @access    public
91
+	 * @return    void
92
+	 */
93
+	public static function set_hooks_admin()
94
+	{
95
+		//actions
96
+		add_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', array('EED_Messages', 'payment'), 10, 2);
97
+		add_action('AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder',
98
+			array('EED_Messages', 'payment_reminder'), 10);
99
+		add_action('AHEE__EE_Registration_Processor__trigger_registration_update_notifications',
100
+			array('EED_Messages', 'maybe_registration'), 10, 3);
101
+		add_action('AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations',
102
+			array('EED_Messages', 'send_newsletter_message'), 10, 2);
103
+		add_action('AHEE__EES_Espresso_Cancelled__process_shortcode__transaction',
104
+			array('EED_Messages', 'cancelled_registration'), 10);
105
+		add_action('AHEE__EE_Admin_Page___process_admin_payment_notification',
106
+			array('EED_Messages', 'process_admin_payment'), 10, 1);
107
+		//filters
108
+		add_filter('FHEE__EE_Admin_Page___process_resend_registration__success',
109
+			array('EED_Messages', 'process_resend'), 10, 2);
110
+		add_filter('FHEE__EE_Registration__receipt_url__receipt_url',
111
+			array('EED_Messages', 'registration_message_trigger_url'), 10, 4);
112
+		add_filter('FHEE__EE_Registration__invoice_url__invoice_url',
113
+			array('EED_Messages', 'registration_message_trigger_url'), 10, 4);
114
+	}
115
+
116
+
117
+	/**
118
+	 * All the message triggers done by route go in here.
119
+	 *
120
+	 * @since 4.5.0
121
+	 * @return void
122
+	 */
123
+	protected static function _register_routes()
124
+	{
125
+		EE_Config::register_route('msg_url_trigger', 'Messages', 'run');
126
+		EE_Config::register_route('msg_cron_trigger', 'Messages', 'execute_batch_request');
127
+		EE_Config::register_route('msg_browser_trigger', 'Messages', 'browser_trigger');
128
+		EE_Config::register_route('msg_browser_error_trigger', 'Messages', 'browser_error_trigger');
129
+		do_action('AHEE__EED_Messages___register_routes');
130
+	}
131
+
132
+
133
+	/**
134
+	 * This is called when a browser display trigger is executed.
135
+	 * The browser display trigger is typically used when a already generated message is displayed directly in the
136
+	 * browser.
137
+	 *
138
+	 * @since 4.9.0
139
+	 * @param WP $WP
140
+	 */
141
+	public function browser_trigger($WP)
142
+	{
143
+		//ensure controller is loaded
144
+		self::_load_controller();
145
+		$token = EE_Registry::instance()->REQ->get('token');
146
+		try {
147
+			$mtg = new EE_Message_Generated_From_Token($token, 'html', self::$_message_resource_manager);
148
+			self::$_MSG_PROCESSOR->generate_and_send_now($mtg);
149
+		} catch (EE_Error $e) {
150
+			$error_msg = __('Please note that a system message failed to send due to a technical issue.',
151
+				'event_espresso');
152
+			// add specific message for developers if WP_DEBUG in on
153
+			$error_msg .= '||' . $e->getMessage();
154
+			EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
155
+		}
156
+	}
157
+
158
+
159
+	/**
160
+	 * This is called when a browser error trigger is executed.
161
+	 * When triggered this will grab the EE_Message matching the token in the request and use that to get the error
162
+	 * message and display it.
163
+	 *
164
+	 * @since 4.9.0
165
+	 * @param $WP
166
+	 */
167
+	public function browser_error_trigger($WP)
168
+	{
169
+		$token = EE_Registry::instance()->REQ->get('token');
170
+		if ($token) {
171
+			$message = EEM_Message::instance()->get_one_by_token($token);
172
+			if ($message instanceof EE_Message) {
173
+				header('HTTP/1.1 200 OK');
174
+				$error_msg = nl2br($message->error_message());
175
+				?>
176 176
                 <!DOCTYPE html>
177 177
                 <html>
178 178
                 <head></head>
179 179
                 <body>
180 180
                 <?php echo empty($error_msg)
181
-                    ? esc_html__('Unfortunately, we were unable to capture the error message for this message.',
182
-                        'event_espresso')
183
-                    : wp_kses(
184
-                        $error_msg,
185
-                        array(
186
-                            'a'      => array(
187
-                                'href'  => array(),
188
-                                'title' => array(),
189
-                            ),
190
-                            'span'   => array(),
191
-                            'div'    => array(),
192
-                            'p'      => array(),
193
-                            'strong' => array(),
194
-                            'em'     => array(),
195
-                            'br'     => array(),
196
-                        )
197
-                    ); ?>
181
+					? esc_html__('Unfortunately, we were unable to capture the error message for this message.',
182
+						'event_espresso')
183
+					: wp_kses(
184
+						$error_msg,
185
+						array(
186
+							'a'      => array(
187
+								'href'  => array(),
188
+								'title' => array(),
189
+							),
190
+							'span'   => array(),
191
+							'div'    => array(),
192
+							'p'      => array(),
193
+							'strong' => array(),
194
+							'em'     => array(),
195
+							'br'     => array(),
196
+						)
197
+					); ?>
198 198
                 </body>
199 199
                 </html>
200 200
                 <?php
201
-                exit;
202
-            }
203
-        }
204
-        return;
205
-    }
206
-
207
-
208
-    /**
209
-     *  This runs when the msg_url_trigger route has initiated.
210
-     *
211
-     * @since 4.5.0
212
-     * @param WP $WP
213
-     * @throws EE_Error
214
-     * @return    void
215
-     */
216
-    public function run($WP)
217
-    {
218
-        //ensure controller is loaded
219
-        self::_load_controller();
220
-        // attempt to process message
221
-        try {
222
-            /** @type EE_Message_To_Generate_From_Request $message_to_generate */
223
-            $message_to_generate = EE_Registry::instance()->load_lib('Message_To_Generate_From_Request');
224
-            self::$_MSG_PROCESSOR->generate_and_send_now($message_to_generate);
225
-        } catch (EE_Error $e) {
226
-            $error_msg = __('Please note that a system message failed to send due to a technical issue.',
227
-                'event_espresso');
228
-            // add specific message for developers if WP_DEBUG in on
229
-            $error_msg .= '||' . $e->getMessage();
230
-            EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
231
-        }
232
-    }
233
-
234
-
235
-    /**
236
-     * This is triggered by the 'msg_cron_trigger' route.
237
-     *
238
-     * @param WP $WP
239
-     */
240
-    public function execute_batch_request($WP)
241
-    {
242
-        $this->run_cron();
243
-        header('HTTP/1.1 200 OK');
244
-        exit();
245
-    }
246
-
247
-
248
-    /**
249
-     * This gets executed on wp_cron jobs or when a batch request is initiated on its own separate non regular wp
250
-     * request.
251
-     */
252
-    public function run_cron()
253
-    {
254
-        self::_load_controller();
255
-        //get required vars
256
-        $cron_type     = EE_Registry::instance()->REQ->get('type');
257
-        $transient_key = EE_Registry::instance()->REQ->get('key');
258
-
259
-        //now let's verify transient, if not valid exit immediately
260
-        if (! get_transient($transient_key)) {
261
-            /**
262
-             * trigger error so this gets in the error logs.  This is important because it happens on a non-user request.
263
-             */
264
-            trigger_error(esc_attr__('Invalid Request (Transient does not exist)', 'event_espresso'));
265
-        }
266
-
267
-        //if made it here, lets' delete the transient to keep the db clean
268
-        delete_transient($transient_key);
269
-
270
-        if (apply_filters('FHEE__EED_Messages__run_cron__use_wp_cron', true)) {
271
-
272
-            $method = 'batch_' . $cron_type . '_from_queue';
273
-            if (method_exists(self::$_MSG_PROCESSOR, $method)) {
274
-                self::$_MSG_PROCESSOR->$method();
275
-            } else {
276
-                //no matching task
277
-                /**
278
-                 * trigger error so this gets in the error logs.  This is important because it happens on a non user request.
279
-                 */
280
-                trigger_error(esc_attr(sprintf(__('There is no task corresponding to this route %s', 'event_espresso'),
281
-                    $cron_type)));
282
-            }
283
-        }
284
-
285
-        do_action('FHEE__EED_Messages__run_cron__end');
286
-    }
287
-
288
-
289
-    /**
290
-     * This is used to retrieve the template pack for the given name.
291
-     * Retrieved packs are cached on the static $_TMP_PACKS array.  If there is no class matching the given name then
292
-     * the default template pack is returned.
293
-     *
294
-     * @deprecated 4.9.0  @see EEH_MSG_Template::get_template_pack()
295
-     * @param string $template_pack_name This should correspond to the dbref of the template pack (which is also used
296
-     *                                   in generating the Pack class name).
297
-     * @return EE_Messages_Template_Pack
298
-     */
299
-    public static function get_template_pack($template_pack_name)
300
-    {
301
-        EE_Registry::instance()->load_helper('MSG_Template');
302
-        return EEH_MSG_Template::get_template_pack($template_pack_name);
303
-    }
304
-
305
-
306
-    /**
307
-     * Retrieves an array of all template packs.
308
-     * Array is in the format array( 'dbref' => EE_Messages_Template_Pack )
309
-     *
310
-     * @deprecated 4.9.0  @see EEH_MSG_Template_Pack::get_template_pack_collection
311
-     * @return EE_Messages_Template_Pack[]
312
-     */
313
-    public static function get_template_packs()
314
-    {
315
-        EE_Registry::instance()->load_helper('MSG_Template');
316
-
317
-        //for backward compat, let's make sure this returns in the same format as originally.
318
-        $template_pack_collection = EEH_MSG_Template::get_template_pack_collection();
319
-        $template_pack_collection->rewind();
320
-        $template_packs = array();
321
-        while ($template_pack_collection->valid()) {
322
-            $template_packs[$template_pack_collection->current()->dbref] = $template_pack_collection->current();
323
-            $template_pack_collection->next();
324
-        }
325
-        return $template_packs;
326
-    }
327
-
328
-
329
-    /**
330
-     * This simply makes sure the autoloaders are registered for the EE_messages system.
331
-     *
332
-     * @since 4.5.0
333
-     * @return void
334
-     */
335
-    public static function set_autoloaders()
336
-    {
337
-        if (empty(self::$_MSG_PATHS)) {
338
-            self::_set_messages_paths();
339
-            foreach (self::$_MSG_PATHS as $path) {
340
-                EEH_Autoloader::register_autoloaders_for_each_file_in_folder($path);
341
-            }
342
-            // add aliases
343
-            EEH_Autoloader::add_alias('EE_messages', 'EE_messages');
344
-            EEH_Autoloader::add_alias('EE_messenger', 'EE_messenger');
345
-        }
346
-    }
347
-
348
-
349
-    /**
350
-     * Take care of adding all the paths for the messages components to the $_MSG_PATHS property
351
-     * for use by the Messages Autoloaders
352
-     *
353
-     * @since 4.5.0
354
-     * @return void.
355
-     */
356
-    protected static function _set_messages_paths()
357
-    {
358
-        $dir_ref = array(
359
-            'messages/message_type',
360
-            'messages/messenger',
361
-            'messages/defaults',
362
-            'messages/defaults/email',
363
-            'messages/data_class',
364
-            'messages/validators',
365
-            'messages/validators/email',
366
-            'messages/validators/html',
367
-            'shortcodes',
368
-        );
369
-        $paths   = array();
370
-        foreach ($dir_ref as $index => $dir) {
371
-            $paths[$index] = EE_LIBRARIES . $dir;
372
-        }
373
-        self::$_MSG_PATHS = apply_filters('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', $paths);
374
-    }
375
-
376
-
377
-    /**
378
-     * Takes care of loading dependencies
379
-     *
380
-     * @since 4.5.0
381
-     * @return void
382
-     */
383
-    protected static function _load_controller()
384
-    {
385
-        if (! self::$_MSG_PROCESSOR instanceof EE_Messages_Processor) {
386
-            EE_Registry::instance()->load_core('Request_Handler');
387
-            self::set_autoloaders();
388
-            self::$_EEMSG                    = EE_Registry::instance()->load_lib('messages');
389
-            self::$_MSG_PROCESSOR            = EE_Registry::instance()->load_lib('Messages_Processor');
390
-            self::$_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
391
-        }
392
-    }
393
-
394
-
395
-    /**
396
-     * @param EE_Transaction $transaction
397
-     */
398
-    public static function payment_reminder(EE_Transaction $transaction)
399
-    {
400
-        self::_load_controller();
401
-        $data = array($transaction, null);
402
-        self::$_MSG_PROCESSOR->generate_for_all_active_messengers('payment_reminder', $data);
403
-    }
404
-
405
-
406
-    /**
407
-     * Any messages triggers for after successful gateway payments should go in here.
408
-     *
409
-     * @param  EE_Transaction object
410
-     * @param  EE_Payment     object
411
-     * @return void
412
-     */
413
-    public static function payment(EE_Transaction $transaction, EE_Payment $payment)
414
-    {
415
-        self::_load_controller();
416
-        $data = array($transaction, $payment);
417
-        EE_Registry::instance()->load_helper('MSG_Template');
418
-        $message_type = EEH_MSG_Template::convert_payment_status_to_message_type($payment->STS_ID());
419
-        //if payment amount is less than 0 then switch to payment_refund message type.
420
-        $message_type = $payment->amount() < 0 ? 'payment_refund' : $message_type;
421
-        self::$_MSG_PROCESSOR->generate_for_all_active_messengers($message_type, $data);
422
-    }
423
-
424
-
425
-    /**
426
-     * @param EE_Transaction $transaction
427
-     */
428
-    public static function cancelled_registration(EE_Transaction $transaction)
429
-    {
430
-        self::_load_controller();
431
-        $data = array($transaction, null);
432
-        self::$_MSG_PROCESSOR->generate_for_all_active_messengers('cancelled_registration', $data);
433
-    }
434
-
435
-
436
-    /**
437
-     * Trigger for Registration messages
438
-     * Note that what registration message type is sent depends on what the reg status is for the registrations on the
439
-     * incoming transaction.
440
-     *
441
-     * @param EE_Registration $registration
442
-     * @param array           $extra_details
443
-     * @return void
444
-     */
445
-    public static function maybe_registration(EE_Registration $registration, $extra_details = array())
446
-    {
447
-
448
-        if (! self::_verify_registration_notification_send($registration, $extra_details)) {
449
-            //no messages please
450
-            return;
451
-        }
452
-
453
-
454
-        //get all registrations so we make sure we send messages for the right status.
455
-        $all_registrations = $registration->transaction()->registrations();
456
-
457
-        //cached array of statuses so we only trigger messages once per status.
458
-        $statuses_sent = array();
459
-        self::_load_controller();
460
-        $mtgs = array();
461
-
462
-        //loop through registrations and trigger messages once per status.
463
-        foreach ($all_registrations as $reg) {
464
-
465
-            //already triggered?
466
-            if (in_array($reg->status_ID(), $statuses_sent)) {
467
-                continue;
468
-            }
469
-
470
-            $message_type    = EEH_MSG_Template::convert_reg_status_to_message_type($reg->status_ID());
471
-            $mtgs            = $mtgs + self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers($message_type,
472
-                    array($registration->transaction(), null, $reg->status_ID()));
473
-            $statuses_sent[] = $reg->status_ID();
474
-        }
475
-
476
-        $mtgs = $mtgs + self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers('registration_summary',
477
-                array($registration->transaction(), null));
478
-
479
-        //batch queue and initiate request
480
-        self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist($mtgs);
481
-        self::$_MSG_PROCESSOR->get_queue()->initiate_request_by_priority();
482
-    }
483
-
484
-
485
-    /**
486
-     * This is a helper method used to very whether a registration notification should be sent or
487
-     * not.  Prevents duplicate notifications going out for registration context notifications.
488
-     *
489
-     * @param EE_Registration $registration  [description]
490
-     * @param array           $extra_details [description]
491
-     * @return bool          true = send away, false = nope halt the presses.
492
-     */
493
-    protected static function _verify_registration_notification_send(
494
-        EE_Registration $registration,
495
-        $extra_details = array()
496
-    ) {
497
-        //self::log(
498
-        //	__CLASS__, __FUNCTION__, __LINE__,
499
-        //	$registration->transaction(),
500
-        //	array( '$extra_details' => $extra_details )
501
-        //);
502
-        // currently only using this to send messages for the primary registrant
503
-        if (! $registration->is_primary_registrant()) {
504
-            return false;
505
-        }
506
-        // first we check if we're in admin and not doing front ajax
507
-        if (is_admin() && ! EE_FRONT_AJAX) {
508
-            //make sure appropriate admin params are set for sending messages
509
-            if (empty($_REQUEST['txn_reg_status_change']['send_notifications']) || ! absint($_REQUEST['txn_reg_status_change']['send_notifications'])) {
510
-                //no messages sent please.
511
-                return false;
512
-            }
513
-        } else {
514
-            // frontend request (either regular or via AJAX)
515
-            // TXN is NOT finalized ?
516
-            if (! isset($extra_details['finalized']) || $extra_details['finalized'] === false) {
517
-                return false;
518
-            }
519
-            // return visit but nothing changed ???
520
-            if (
521
-                isset($extra_details['revisit'], $extra_details['status_updates']) &&
522
-                $extra_details['revisit'] && ! $extra_details['status_updates']
523
-            ) {
524
-                return false;
525
-            }
526
-            // NOT sending messages && reg status is something other than "Not-Approved"
527
-            if (
528
-                ! apply_filters('FHEE__EED_Messages___maybe_registration__deliver_notifications', false) &&
529
-                $registration->status_ID() !== EEM_Registration::status_id_not_approved
530
-            ) {
531
-                return false;
532
-            }
533
-        }
534
-        // release the kraken
535
-        return true;
536
-    }
537
-
538
-
539
-    /**
540
-     * Simply returns an array indexed by Registration Status ID and the related message_type name associated with that
541
-     * status id.
542
-     *
543
-     * @deprecated 4.9.0  Use EEH_MSG_Template::reg_status_to_message_type_array()
544
-     *                    or EEH_MSG_Template::convert_reg_status_to_message_type
545
-     * @param string $reg_status
546
-     * @return array
547
-     */
548
-    protected static function _get_reg_status_array($reg_status = '')
549
-    {
550
-        EE_Registry::instance()->load_helper('MSG_Template');
551
-        return EEH_MSG_Template::convert_reg_status_to_message_type($reg_status)
552
-            ? EEH_MSG_Template::convert_reg_status_to_message_type($reg_status)
553
-            : EEH_MSG_Template::reg_status_to_message_type_array();
554
-    }
555
-
556
-
557
-    /**
558
-     * Simply returns the payment message type for the given payment status.
559
-     *
560
-     * @deprecated 4.9.0 Use EEH_MSG_Template::payment_status_to_message_type_array
561
-     *                   or EEH_MSG_Template::convert_payment_status_to_message_type
562
-     * @param string $payment_status The payment status being matched.
563
-     * @return string|bool The payment message type slug matching the status or false if no match.
564
-     */
565
-    protected static function _get_payment_message_type($payment_status)
566
-    {
567
-        EE_Registry::instance()->load_helper('MSG_Template');
568
-        return EEH_MSG_Template::convert_payment_status_to_message_type($payment_status)
569
-            ? EEH_MSG_Template::convert_payment_status_to_message_type($payment_status)
570
-            : false;
571
-    }
572
-
573
-
574
-    /**
575
-     * Message triggers for a resending already sent message(s) (via EE_Message list table)
576
-     *
577
-     * @access public
578
-     * @param array $req_data This is the $_POST & $_GET data sent from EE_Admin Pages
579
-     * @return bool          success/fail
580
-     */
581
-    public static function process_resend($req_data)
582
-    {
583
-        self::_load_controller();
584
-
585
-        //if $msgID in this request then skip to the new resend_message
586
-        if (EE_Registry::instance()->REQ->get('MSG_ID')) {
587
-            return self::resend_message();
588
-        }
589
-
590
-        //make sure any incoming request data is set on the REQ so that it gets picked up later.
591
-        $req_data = (array)$req_data;
592
-        foreach ($req_data as $request_key => $request_value) {
593
-            EE_Registry::instance()->REQ->set($request_key, $request_value);
594
-        }
595
-
596
-        if (! $messages_to_send = self::$_MSG_PROCESSOR->setup_messages_to_generate_from_registration_ids_in_request()) {
597
-            return false;
598
-        }
599
-
600
-        try {
601
-            self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist($messages_to_send);
602
-            self::$_MSG_PROCESSOR->get_queue()->initiate_request_by_priority();
603
-        } catch (EE_Error $e) {
604
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
605
-            return false;
606
-        }
607
-        EE_Error::add_success(
608
-            __('Messages have been successfully queued for generation and sending.', 'event_espresso')
609
-        );
610
-        return true; //everything got queued.
611
-    }
612
-
613
-
614
-    /**
615
-     * Message triggers for a resending already sent message(s) (via EE_Message list table)
616
-     *
617
-     * @return bool
618
-     */
619
-    public static function resend_message()
620
-    {
621
-        self::_load_controller();
622
-
623
-        $msgID = EE_Registry::instance()->REQ->get('MSG_ID');
624
-        if (! $msgID) {
625
-            EE_Error::add_error(__('Something went wrong because there is no "MSG_ID" value in the request',
626
-                'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
627
-            return false;
628
-        }
629
-
630
-        self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send((array)$msgID);
631
-
632
-        //setup success message.
633
-        $count_ready_for_resend = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_resend);
634
-        EE_Error::add_success(sprintf(
635
-            _n(
636
-                'There was %d message queued for resending.',
637
-                'There were %d messages queued for resending.',
638
-                $count_ready_for_resend,
639
-                'event_espresso'
640
-            ),
641
-            $count_ready_for_resend
642
-        ));
643
-        return true;
644
-    }
645
-
646
-
647
-    /**
648
-     * Message triggers for manual payment applied by admin
649
-     *
650
-     * @param  EE_Payment $payment EE_payment object
651
-     * @return bool              success/fail
652
-     */
653
-    public static function process_admin_payment(EE_Payment $payment)
654
-    {
655
-        EE_Registry::instance()->load_helper('MSG_Template');
656
-        //we need to get the transaction object
657
-        $transaction = $payment->transaction();
658
-        if ($transaction instanceof EE_Transaction) {
659
-            $data         = array($transaction, $payment);
660
-            $message_type = EEH_MSG_Template::convert_payment_status_to_message_type($payment->STS_ID());
661
-
662
-            //if payment amount is less than 0 then switch to payment_refund message type.
663
-            $message_type = $payment->amount() < 0 ? 'payment_refund' : $message_type;
664
-
665
-            //if payment_refund is selected, but the status is NOT accepted.  Then change message type to false so NO message notification goes out.
666
-            $message_type = $message_type == 'payment_refund' && $payment->STS_ID() != EEM_Payment::status_id_approved ? false : $message_type;
667
-
668
-            self::_load_controller();
669
-
670
-            self::$_MSG_PROCESSOR->generate_for_all_active_messengers($message_type, $data);
671
-
672
-            //get count of queued for generation
673
-            $count_to_generate = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(array(
674
-                EEM_Message::status_incomplete,
675
-                EEM_Message::status_idle,
676
-            ));
677
-
678
-            if ($count_to_generate > 0 && self::$_MSG_PROCESSOR->get_queue()->get_message_repository()->count() !== 0) {
679
-                add_filter('FHEE__EE_Admin_Page___process_admin_payment_notification__success', '__return_true');
680
-                return true;
681
-            } else {
682
-                $count_failed = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::instance()->stati_indicating_failed_sending());
683
-                /**
684
-                 * Verify that there are actually errors.  If not then we return a success message because the queue might have been emptied due to successful
685
-                 * IMMEDIATE generation.
686
-                 */
687
-                if ($count_failed > 0) {
688
-                    EE_Error::add_error(sprintf(
689
-                        _n(
690
-                            'The payment notification generation failed.',
691
-                            '%d payment notifications failed being sent.',
692
-                            $count_failed,
693
-                            'event_espresso'
694
-                        ),
695
-                        $count_failed
696
-                    ), __FILE__, __FUNCTION__, __LINE__);
697
-
698
-                    return false;
699
-                } else {
700
-                    add_filter('FHEE__EE_Admin_Page___process_admin_payment_notification__success', '__return_true');
701
-                    return true;
702
-                }
703
-            }
704
-        } else {
705
-            EE_Error::add_error(
706
-                'Unable to generate the payment notification because the given value for the transaction is invalid.',
707
-                'event_espresso'
708
-            );
709
-            return false;
710
-        }
711
-    }
712
-
713
-
714
-    /**
715
-     * Callback for AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send_with_registrations trigger
716
-     *
717
-     * @since   4.3.0
718
-     * @param  EE_Registration[] $registrations an array of EE_Registration objects
719
-     * @param  int               $grp_id        a specific message template group id.
720
-     * @return void
721
-     */
722
-    public static function send_newsletter_message($registrations, $grp_id)
723
-    {
724
-        //make sure mtp is id and set it in the EE_Request Handler later messages setup.
725
-        EE_Registry::instance()->REQ->set('GRP_ID', (int)$grp_id);
726
-        self::_load_controller();
727
-        self::$_MSG_PROCESSOR->generate_for_all_active_messengers('newsletter', $registrations);
728
-    }
729
-
730
-
731
-    /**
732
-     * Callback for FHEE__EE_Registration__invoice_url__invoice_url or FHEE__EE_Registration__receipt_url__receipt_url
733
-     *
734
-     * @since   4.3.0
735
-     * @param    string          $registration_message_trigger_url
736
-     * @param    EE_Registration $registration
737
-     * @param string             $messenger
738
-     * @param string             $message_type
739
-     * @return    string
740
-     */
741
-    public static function registration_message_trigger_url(
742
-        $registration_message_trigger_url,
743
-        EE_Registration $registration,
744
-        $messenger = 'html',
745
-        $message_type = 'invoice'
746
-    ) {
747
-        // whitelist $messenger
748
-        switch ($messenger) {
749
-            case 'pdf' :
750
-                $sending_messenger    = 'pdf';
751
-                $generating_messenger = 'html';
752
-                break;
753
-            case 'html' :
754
-            default :
755
-                $sending_messenger    = 'html';
756
-                $generating_messenger = 'html';
757
-                break;
758
-        }
759
-        // whitelist $message_type
760
-        switch ($message_type) {
761
-            case 'receipt' :
762
-                $message_type = 'receipt';
763
-                break;
764
-            case 'invoice' :
765
-            default :
766
-                $message_type = 'invoice';
767
-                break;
768
-        }
769
-        // verify that both the messenger AND the message type are active
770
-        if (EEH_MSG_Template::is_messenger_active($sending_messenger) && EEH_MSG_Template::is_mt_active($message_type)) {
771
-            //need to get the correct message template group for this (i.e. is there a custom invoice for the event this registration is registered for?)
772
-            $template_query_params = array(
773
-                'MTP_is_active'    => true,
774
-                'MTP_messenger'    => $generating_messenger,
775
-                'MTP_message_type' => $message_type,
776
-                'Event.EVT_ID'     => $registration->event_ID(),
777
-            );
778
-            //get the message template group.
779
-            $msg_template_group = EEM_Message_Template_Group::instance()->get_one(array($template_query_params));
780
-            //if we don't have an EE_Message_Template_Group then return
781
-            if (! $msg_template_group instanceof EE_Message_Template_Group) {
782
-                // remove EVT_ID from query params so that global templates get picked up
783
-                unset($template_query_params['Event.EVT_ID']);
784
-                //get global template as the fallback
785
-                $msg_template_group = EEM_Message_Template_Group::instance()->get_one(array($template_query_params));
786
-            }
787
-            //if we don't have an EE_Message_Template_Group then return
788
-            if (! $msg_template_group instanceof EE_Message_Template_Group) {
789
-                return '';
790
-            }
791
-            // generate the URL
792
-            $registration_message_trigger_url = EEH_MSG_Template::generate_url_trigger(
793
-                $sending_messenger,
794
-                $generating_messenger,
795
-                'purchaser',
796
-                $message_type,
797
-                $registration,
798
-                $msg_template_group->ID(),
799
-                $registration->transaction_ID()
800
-            );
801
-
802
-        }
803
-        return $registration_message_trigger_url;
804
-    }
805
-
806
-
807
-    /**
808
-     * Use to generate and return a message preview!
809
-     *
810
-     * @param  string $type      This should correspond with a valid message type
811
-     * @param  string $context   This should correspond with a valid context for the message type
812
-     * @param  string $messenger This should correspond with a valid messenger.
813
-     * @param bool    $send      true we will do a test send using the messenger delivery, false we just do a regular
814
-     *                           preview
815
-     * @return string|bool          The body of the message or if send is requested, sends.
816
-     */
817
-    public static function preview_message($type, $context, $messenger, $send = false)
818
-    {
819
-        self::_load_controller();
820
-        $mtg                     = new EE_Message_To_Generate(
821
-            $messenger,
822
-            $type,
823
-            array(),
824
-            $context,
825
-            true
826
-        );
827
-        $generated_preview_queue = self::$_MSG_PROCESSOR->generate_for_preview($mtg, $send);
828
-        if ($generated_preview_queue instanceof EE_Messages_Queue) {
829
-            return $generated_preview_queue->get_message_repository()->current()->content();
830
-        } else {
831
-            return $generated_preview_queue;
832
-        }
833
-    }
834
-
835
-
836
-    /**
837
-     * This is a method that allows for sending a message using a messenger matching the string given and the provided
838
-     * EE_Message_Queue object.  The EE_Message_Queue object is used to create a single aggregate EE_Message via the
839
-     * content found in the EE_Message objects in the queue.
840
-     *
841
-     * @since 4.9.0
842
-     * @param string            $messenger            a string matching a valid active messenger in the system
843
-     * @param string            $message_type         Although it seems contrary to the name of the method, a message
844
-     *                                                type name is still required to send along the message type to the
845
-     *                                                messenger because this is used for determining what specific
846
-     *                                                variations might be loaded for the generated message.
847
-     * @param EE_Messages_Queue $queue
848
-     * @param string            $custom_subject       Can be used to set what the custom subject string will be on the
849
-     *                                                aggregate EE_Message object.
850
-     * @return bool          success or fail.
851
-     */
852
-    public static function send_message_with_messenger_only(
853
-        $messenger,
854
-        $message_type,
855
-        EE_Messages_Queue $queue,
856
-        $custom_subject = ''
857
-    ) {
858
-        self::_load_controller();
859
-        /** @type EE_Message_To_Generate_From_Queue $message_to_generate */
860
-        $message_to_generate = EE_Registry::instance()->load_lib(
861
-            'Message_To_Generate_From_Queue',
862
-            array(
863
-                $messenger,
864
-                $message_type,
865
-                $queue,
866
-                $custom_subject,
867
-            )
868
-        );
869
-        return self::$_MSG_PROCESSOR->queue_for_sending($message_to_generate);
870
-    }
871
-
872
-
873
-    /**
874
-     * Generates Messages immediately for EE_Message IDs (but only for the correct status for generation)
875
-     *
876
-     * @since 4.9.0
877
-     * @param array $message_ids An array of message ids
878
-     * @return bool | EE_Messages_Queue     false if nothing was generated, EE_Messages_Queue containing generated
879
-     *              messages.
880
-     */
881
-    public static function generate_now($message_ids)
882
-    {
883
-        self::_load_controller();
884
-        $messages        = EEM_Message::instance()->get_all(
885
-            array(
886
-                0 => array(
887
-                    'MSG_ID' => array('IN', $message_ids),
888
-                    'STS_ID' => EEM_Message::status_incomplete,
889
-                ),
890
-            )
891
-        );
892
-        $generated_queue = false;
893
-        if ($messages) {
894
-            $generated_queue = self::$_MSG_PROCESSOR->batch_generate_from_queue($messages);
895
-        }
896
-
897
-        if (! $generated_queue instanceof EE_Messages_Queue) {
898
-            EE_Error::add_error(
899
-                __('The messages were not generated. This could mean there is already a batch being generated on a separate request, or because the selected messages are not ready for generation. Please wait a minute or two and try again.',
900
-                    'event_espresso'),
901
-                __FILE__, __FUNCTION__, __LINE__
902
-            );
903
-        }
904
-        return $generated_queue;
905
-    }
906
-
907
-
908
-    /**
909
-     * Sends messages immediately for the incoming message_ids that have the status of EEM_Message::status_resend or,
910
-     * EEM_Message::status_idle
911
-     *
912
-     * @since 4.9.0
913
-     * @param $message_ids
914
-     * @return bool | EE_Messages_Queue  false if no messages sent.
915
-     */
916
-    public static function send_now($message_ids)
917
-    {
918
-        self::_load_controller();
919
-        $messages   = EEM_Message::instance()->get_all(
920
-            array(
921
-                0 => array(
922
-                    'MSG_ID' => array('IN', $message_ids),
923
-                    'STS_ID' => array(
924
-                        'IN',
925
-                        array(EEM_Message::status_idle, EEM_Message::status_resend, EEM_Message::status_retry),
926
-                    ),
927
-                ),
928
-            )
929
-        );
930
-        $sent_queue = false;
931
-        if ($messages) {
932
-            $sent_queue = self::$_MSG_PROCESSOR->batch_send_from_queue($messages);
933
-        }
934
-
935
-        if (! $sent_queue instanceof EE_Messages_Queue) {
936
-            EE_Error::add_error(
937
-                __('The messages were not sent. This could mean there is already a batch being sent on a separate request, or because the selected messages are not sendable. Please wait a minute or two and try again.',
938
-                    'event_espresso'),
939
-                __FILE__, __FUNCTION__, __LINE__
940
-            );
941
-        } else {
942
-            //can count how many sent by using the messages in the queue
943
-            $sent_count = $sent_queue->count_STS_in_queue(EEM_Message::instance()->stati_indicating_sent());
944
-            if ($sent_count > 0) {
945
-                EE_Error::add_success(
946
-                    sprintf(
947
-                        _n(
948
-                            'There was %d message successfully sent.',
949
-                            'There were %d messages successfully sent.',
950
-                            $sent_count,
951
-                            'event_espresso'
952
-                        ),
953
-                        $sent_count
954
-                    )
955
-                );
956
-            } else {
957
-                EE_Error::overwrite_errors();
958
-                EE_Error::add_error(
959
-                    __('No message was sent because of problems with sending. Either all the messages you selected were not a sendable message, they were ALREADY sent on a different scheduled task, or there was an error.
201
+				exit;
202
+			}
203
+		}
204
+		return;
205
+	}
206
+
207
+
208
+	/**
209
+	 *  This runs when the msg_url_trigger route has initiated.
210
+	 *
211
+	 * @since 4.5.0
212
+	 * @param WP $WP
213
+	 * @throws EE_Error
214
+	 * @return    void
215
+	 */
216
+	public function run($WP)
217
+	{
218
+		//ensure controller is loaded
219
+		self::_load_controller();
220
+		// attempt to process message
221
+		try {
222
+			/** @type EE_Message_To_Generate_From_Request $message_to_generate */
223
+			$message_to_generate = EE_Registry::instance()->load_lib('Message_To_Generate_From_Request');
224
+			self::$_MSG_PROCESSOR->generate_and_send_now($message_to_generate);
225
+		} catch (EE_Error $e) {
226
+			$error_msg = __('Please note that a system message failed to send due to a technical issue.',
227
+				'event_espresso');
228
+			// add specific message for developers if WP_DEBUG in on
229
+			$error_msg .= '||' . $e->getMessage();
230
+			EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
231
+		}
232
+	}
233
+
234
+
235
+	/**
236
+	 * This is triggered by the 'msg_cron_trigger' route.
237
+	 *
238
+	 * @param WP $WP
239
+	 */
240
+	public function execute_batch_request($WP)
241
+	{
242
+		$this->run_cron();
243
+		header('HTTP/1.1 200 OK');
244
+		exit();
245
+	}
246
+
247
+
248
+	/**
249
+	 * This gets executed on wp_cron jobs or when a batch request is initiated on its own separate non regular wp
250
+	 * request.
251
+	 */
252
+	public function run_cron()
253
+	{
254
+		self::_load_controller();
255
+		//get required vars
256
+		$cron_type     = EE_Registry::instance()->REQ->get('type');
257
+		$transient_key = EE_Registry::instance()->REQ->get('key');
258
+
259
+		//now let's verify transient, if not valid exit immediately
260
+		if (! get_transient($transient_key)) {
261
+			/**
262
+			 * trigger error so this gets in the error logs.  This is important because it happens on a non-user request.
263
+			 */
264
+			trigger_error(esc_attr__('Invalid Request (Transient does not exist)', 'event_espresso'));
265
+		}
266
+
267
+		//if made it here, lets' delete the transient to keep the db clean
268
+		delete_transient($transient_key);
269
+
270
+		if (apply_filters('FHEE__EED_Messages__run_cron__use_wp_cron', true)) {
271
+
272
+			$method = 'batch_' . $cron_type . '_from_queue';
273
+			if (method_exists(self::$_MSG_PROCESSOR, $method)) {
274
+				self::$_MSG_PROCESSOR->$method();
275
+			} else {
276
+				//no matching task
277
+				/**
278
+				 * trigger error so this gets in the error logs.  This is important because it happens on a non user request.
279
+				 */
280
+				trigger_error(esc_attr(sprintf(__('There is no task corresponding to this route %s', 'event_espresso'),
281
+					$cron_type)));
282
+			}
283
+		}
284
+
285
+		do_action('FHEE__EED_Messages__run_cron__end');
286
+	}
287
+
288
+
289
+	/**
290
+	 * This is used to retrieve the template pack for the given name.
291
+	 * Retrieved packs are cached on the static $_TMP_PACKS array.  If there is no class matching the given name then
292
+	 * the default template pack is returned.
293
+	 *
294
+	 * @deprecated 4.9.0  @see EEH_MSG_Template::get_template_pack()
295
+	 * @param string $template_pack_name This should correspond to the dbref of the template pack (which is also used
296
+	 *                                   in generating the Pack class name).
297
+	 * @return EE_Messages_Template_Pack
298
+	 */
299
+	public static function get_template_pack($template_pack_name)
300
+	{
301
+		EE_Registry::instance()->load_helper('MSG_Template');
302
+		return EEH_MSG_Template::get_template_pack($template_pack_name);
303
+	}
304
+
305
+
306
+	/**
307
+	 * Retrieves an array of all template packs.
308
+	 * Array is in the format array( 'dbref' => EE_Messages_Template_Pack )
309
+	 *
310
+	 * @deprecated 4.9.0  @see EEH_MSG_Template_Pack::get_template_pack_collection
311
+	 * @return EE_Messages_Template_Pack[]
312
+	 */
313
+	public static function get_template_packs()
314
+	{
315
+		EE_Registry::instance()->load_helper('MSG_Template');
316
+
317
+		//for backward compat, let's make sure this returns in the same format as originally.
318
+		$template_pack_collection = EEH_MSG_Template::get_template_pack_collection();
319
+		$template_pack_collection->rewind();
320
+		$template_packs = array();
321
+		while ($template_pack_collection->valid()) {
322
+			$template_packs[$template_pack_collection->current()->dbref] = $template_pack_collection->current();
323
+			$template_pack_collection->next();
324
+		}
325
+		return $template_packs;
326
+	}
327
+
328
+
329
+	/**
330
+	 * This simply makes sure the autoloaders are registered for the EE_messages system.
331
+	 *
332
+	 * @since 4.5.0
333
+	 * @return void
334
+	 */
335
+	public static function set_autoloaders()
336
+	{
337
+		if (empty(self::$_MSG_PATHS)) {
338
+			self::_set_messages_paths();
339
+			foreach (self::$_MSG_PATHS as $path) {
340
+				EEH_Autoloader::register_autoloaders_for_each_file_in_folder($path);
341
+			}
342
+			// add aliases
343
+			EEH_Autoloader::add_alias('EE_messages', 'EE_messages');
344
+			EEH_Autoloader::add_alias('EE_messenger', 'EE_messenger');
345
+		}
346
+	}
347
+
348
+
349
+	/**
350
+	 * Take care of adding all the paths for the messages components to the $_MSG_PATHS property
351
+	 * for use by the Messages Autoloaders
352
+	 *
353
+	 * @since 4.5.0
354
+	 * @return void.
355
+	 */
356
+	protected static function _set_messages_paths()
357
+	{
358
+		$dir_ref = array(
359
+			'messages/message_type',
360
+			'messages/messenger',
361
+			'messages/defaults',
362
+			'messages/defaults/email',
363
+			'messages/data_class',
364
+			'messages/validators',
365
+			'messages/validators/email',
366
+			'messages/validators/html',
367
+			'shortcodes',
368
+		);
369
+		$paths   = array();
370
+		foreach ($dir_ref as $index => $dir) {
371
+			$paths[$index] = EE_LIBRARIES . $dir;
372
+		}
373
+		self::$_MSG_PATHS = apply_filters('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', $paths);
374
+	}
375
+
376
+
377
+	/**
378
+	 * Takes care of loading dependencies
379
+	 *
380
+	 * @since 4.5.0
381
+	 * @return void
382
+	 */
383
+	protected static function _load_controller()
384
+	{
385
+		if (! self::$_MSG_PROCESSOR instanceof EE_Messages_Processor) {
386
+			EE_Registry::instance()->load_core('Request_Handler');
387
+			self::set_autoloaders();
388
+			self::$_EEMSG                    = EE_Registry::instance()->load_lib('messages');
389
+			self::$_MSG_PROCESSOR            = EE_Registry::instance()->load_lib('Messages_Processor');
390
+			self::$_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
391
+		}
392
+	}
393
+
394
+
395
+	/**
396
+	 * @param EE_Transaction $transaction
397
+	 */
398
+	public static function payment_reminder(EE_Transaction $transaction)
399
+	{
400
+		self::_load_controller();
401
+		$data = array($transaction, null);
402
+		self::$_MSG_PROCESSOR->generate_for_all_active_messengers('payment_reminder', $data);
403
+	}
404
+
405
+
406
+	/**
407
+	 * Any messages triggers for after successful gateway payments should go in here.
408
+	 *
409
+	 * @param  EE_Transaction object
410
+	 * @param  EE_Payment     object
411
+	 * @return void
412
+	 */
413
+	public static function payment(EE_Transaction $transaction, EE_Payment $payment)
414
+	{
415
+		self::_load_controller();
416
+		$data = array($transaction, $payment);
417
+		EE_Registry::instance()->load_helper('MSG_Template');
418
+		$message_type = EEH_MSG_Template::convert_payment_status_to_message_type($payment->STS_ID());
419
+		//if payment amount is less than 0 then switch to payment_refund message type.
420
+		$message_type = $payment->amount() < 0 ? 'payment_refund' : $message_type;
421
+		self::$_MSG_PROCESSOR->generate_for_all_active_messengers($message_type, $data);
422
+	}
423
+
424
+
425
+	/**
426
+	 * @param EE_Transaction $transaction
427
+	 */
428
+	public static function cancelled_registration(EE_Transaction $transaction)
429
+	{
430
+		self::_load_controller();
431
+		$data = array($transaction, null);
432
+		self::$_MSG_PROCESSOR->generate_for_all_active_messengers('cancelled_registration', $data);
433
+	}
434
+
435
+
436
+	/**
437
+	 * Trigger for Registration messages
438
+	 * Note that what registration message type is sent depends on what the reg status is for the registrations on the
439
+	 * incoming transaction.
440
+	 *
441
+	 * @param EE_Registration $registration
442
+	 * @param array           $extra_details
443
+	 * @return void
444
+	 */
445
+	public static function maybe_registration(EE_Registration $registration, $extra_details = array())
446
+	{
447
+
448
+		if (! self::_verify_registration_notification_send($registration, $extra_details)) {
449
+			//no messages please
450
+			return;
451
+		}
452
+
453
+
454
+		//get all registrations so we make sure we send messages for the right status.
455
+		$all_registrations = $registration->transaction()->registrations();
456
+
457
+		//cached array of statuses so we only trigger messages once per status.
458
+		$statuses_sent = array();
459
+		self::_load_controller();
460
+		$mtgs = array();
461
+
462
+		//loop through registrations and trigger messages once per status.
463
+		foreach ($all_registrations as $reg) {
464
+
465
+			//already triggered?
466
+			if (in_array($reg->status_ID(), $statuses_sent)) {
467
+				continue;
468
+			}
469
+
470
+			$message_type    = EEH_MSG_Template::convert_reg_status_to_message_type($reg->status_ID());
471
+			$mtgs            = $mtgs + self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers($message_type,
472
+					array($registration->transaction(), null, $reg->status_ID()));
473
+			$statuses_sent[] = $reg->status_ID();
474
+		}
475
+
476
+		$mtgs = $mtgs + self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers('registration_summary',
477
+				array($registration->transaction(), null));
478
+
479
+		//batch queue and initiate request
480
+		self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist($mtgs);
481
+		self::$_MSG_PROCESSOR->get_queue()->initiate_request_by_priority();
482
+	}
483
+
484
+
485
+	/**
486
+	 * This is a helper method used to very whether a registration notification should be sent or
487
+	 * not.  Prevents duplicate notifications going out for registration context notifications.
488
+	 *
489
+	 * @param EE_Registration $registration  [description]
490
+	 * @param array           $extra_details [description]
491
+	 * @return bool          true = send away, false = nope halt the presses.
492
+	 */
493
+	protected static function _verify_registration_notification_send(
494
+		EE_Registration $registration,
495
+		$extra_details = array()
496
+	) {
497
+		//self::log(
498
+		//	__CLASS__, __FUNCTION__, __LINE__,
499
+		//	$registration->transaction(),
500
+		//	array( '$extra_details' => $extra_details )
501
+		//);
502
+		// currently only using this to send messages for the primary registrant
503
+		if (! $registration->is_primary_registrant()) {
504
+			return false;
505
+		}
506
+		// first we check if we're in admin and not doing front ajax
507
+		if (is_admin() && ! EE_FRONT_AJAX) {
508
+			//make sure appropriate admin params are set for sending messages
509
+			if (empty($_REQUEST['txn_reg_status_change']['send_notifications']) || ! absint($_REQUEST['txn_reg_status_change']['send_notifications'])) {
510
+				//no messages sent please.
511
+				return false;
512
+			}
513
+		} else {
514
+			// frontend request (either regular or via AJAX)
515
+			// TXN is NOT finalized ?
516
+			if (! isset($extra_details['finalized']) || $extra_details['finalized'] === false) {
517
+				return false;
518
+			}
519
+			// return visit but nothing changed ???
520
+			if (
521
+				isset($extra_details['revisit'], $extra_details['status_updates']) &&
522
+				$extra_details['revisit'] && ! $extra_details['status_updates']
523
+			) {
524
+				return false;
525
+			}
526
+			// NOT sending messages && reg status is something other than "Not-Approved"
527
+			if (
528
+				! apply_filters('FHEE__EED_Messages___maybe_registration__deliver_notifications', false) &&
529
+				$registration->status_ID() !== EEM_Registration::status_id_not_approved
530
+			) {
531
+				return false;
532
+			}
533
+		}
534
+		// release the kraken
535
+		return true;
536
+	}
537
+
538
+
539
+	/**
540
+	 * Simply returns an array indexed by Registration Status ID and the related message_type name associated with that
541
+	 * status id.
542
+	 *
543
+	 * @deprecated 4.9.0  Use EEH_MSG_Template::reg_status_to_message_type_array()
544
+	 *                    or EEH_MSG_Template::convert_reg_status_to_message_type
545
+	 * @param string $reg_status
546
+	 * @return array
547
+	 */
548
+	protected static function _get_reg_status_array($reg_status = '')
549
+	{
550
+		EE_Registry::instance()->load_helper('MSG_Template');
551
+		return EEH_MSG_Template::convert_reg_status_to_message_type($reg_status)
552
+			? EEH_MSG_Template::convert_reg_status_to_message_type($reg_status)
553
+			: EEH_MSG_Template::reg_status_to_message_type_array();
554
+	}
555
+
556
+
557
+	/**
558
+	 * Simply returns the payment message type for the given payment status.
559
+	 *
560
+	 * @deprecated 4.9.0 Use EEH_MSG_Template::payment_status_to_message_type_array
561
+	 *                   or EEH_MSG_Template::convert_payment_status_to_message_type
562
+	 * @param string $payment_status The payment status being matched.
563
+	 * @return string|bool The payment message type slug matching the status or false if no match.
564
+	 */
565
+	protected static function _get_payment_message_type($payment_status)
566
+	{
567
+		EE_Registry::instance()->load_helper('MSG_Template');
568
+		return EEH_MSG_Template::convert_payment_status_to_message_type($payment_status)
569
+			? EEH_MSG_Template::convert_payment_status_to_message_type($payment_status)
570
+			: false;
571
+	}
572
+
573
+
574
+	/**
575
+	 * Message triggers for a resending already sent message(s) (via EE_Message list table)
576
+	 *
577
+	 * @access public
578
+	 * @param array $req_data This is the $_POST & $_GET data sent from EE_Admin Pages
579
+	 * @return bool          success/fail
580
+	 */
581
+	public static function process_resend($req_data)
582
+	{
583
+		self::_load_controller();
584
+
585
+		//if $msgID in this request then skip to the new resend_message
586
+		if (EE_Registry::instance()->REQ->get('MSG_ID')) {
587
+			return self::resend_message();
588
+		}
589
+
590
+		//make sure any incoming request data is set on the REQ so that it gets picked up later.
591
+		$req_data = (array)$req_data;
592
+		foreach ($req_data as $request_key => $request_value) {
593
+			EE_Registry::instance()->REQ->set($request_key, $request_value);
594
+		}
595
+
596
+		if (! $messages_to_send = self::$_MSG_PROCESSOR->setup_messages_to_generate_from_registration_ids_in_request()) {
597
+			return false;
598
+		}
599
+
600
+		try {
601
+			self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist($messages_to_send);
602
+			self::$_MSG_PROCESSOR->get_queue()->initiate_request_by_priority();
603
+		} catch (EE_Error $e) {
604
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
605
+			return false;
606
+		}
607
+		EE_Error::add_success(
608
+			__('Messages have been successfully queued for generation and sending.', 'event_espresso')
609
+		);
610
+		return true; //everything got queued.
611
+	}
612
+
613
+
614
+	/**
615
+	 * Message triggers for a resending already sent message(s) (via EE_Message list table)
616
+	 *
617
+	 * @return bool
618
+	 */
619
+	public static function resend_message()
620
+	{
621
+		self::_load_controller();
622
+
623
+		$msgID = EE_Registry::instance()->REQ->get('MSG_ID');
624
+		if (! $msgID) {
625
+			EE_Error::add_error(__('Something went wrong because there is no "MSG_ID" value in the request',
626
+				'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
627
+			return false;
628
+		}
629
+
630
+		self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send((array)$msgID);
631
+
632
+		//setup success message.
633
+		$count_ready_for_resend = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_resend);
634
+		EE_Error::add_success(sprintf(
635
+			_n(
636
+				'There was %d message queued for resending.',
637
+				'There were %d messages queued for resending.',
638
+				$count_ready_for_resend,
639
+				'event_espresso'
640
+			),
641
+			$count_ready_for_resend
642
+		));
643
+		return true;
644
+	}
645
+
646
+
647
+	/**
648
+	 * Message triggers for manual payment applied by admin
649
+	 *
650
+	 * @param  EE_Payment $payment EE_payment object
651
+	 * @return bool              success/fail
652
+	 */
653
+	public static function process_admin_payment(EE_Payment $payment)
654
+	{
655
+		EE_Registry::instance()->load_helper('MSG_Template');
656
+		//we need to get the transaction object
657
+		$transaction = $payment->transaction();
658
+		if ($transaction instanceof EE_Transaction) {
659
+			$data         = array($transaction, $payment);
660
+			$message_type = EEH_MSG_Template::convert_payment_status_to_message_type($payment->STS_ID());
661
+
662
+			//if payment amount is less than 0 then switch to payment_refund message type.
663
+			$message_type = $payment->amount() < 0 ? 'payment_refund' : $message_type;
664
+
665
+			//if payment_refund is selected, but the status is NOT accepted.  Then change message type to false so NO message notification goes out.
666
+			$message_type = $message_type == 'payment_refund' && $payment->STS_ID() != EEM_Payment::status_id_approved ? false : $message_type;
667
+
668
+			self::_load_controller();
669
+
670
+			self::$_MSG_PROCESSOR->generate_for_all_active_messengers($message_type, $data);
671
+
672
+			//get count of queued for generation
673
+			$count_to_generate = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(array(
674
+				EEM_Message::status_incomplete,
675
+				EEM_Message::status_idle,
676
+			));
677
+
678
+			if ($count_to_generate > 0 && self::$_MSG_PROCESSOR->get_queue()->get_message_repository()->count() !== 0) {
679
+				add_filter('FHEE__EE_Admin_Page___process_admin_payment_notification__success', '__return_true');
680
+				return true;
681
+			} else {
682
+				$count_failed = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::instance()->stati_indicating_failed_sending());
683
+				/**
684
+				 * Verify that there are actually errors.  If not then we return a success message because the queue might have been emptied due to successful
685
+				 * IMMEDIATE generation.
686
+				 */
687
+				if ($count_failed > 0) {
688
+					EE_Error::add_error(sprintf(
689
+						_n(
690
+							'The payment notification generation failed.',
691
+							'%d payment notifications failed being sent.',
692
+							$count_failed,
693
+							'event_espresso'
694
+						),
695
+						$count_failed
696
+					), __FILE__, __FUNCTION__, __LINE__);
697
+
698
+					return false;
699
+				} else {
700
+					add_filter('FHEE__EE_Admin_Page___process_admin_payment_notification__success', '__return_true');
701
+					return true;
702
+				}
703
+			}
704
+		} else {
705
+			EE_Error::add_error(
706
+				'Unable to generate the payment notification because the given value for the transaction is invalid.',
707
+				'event_espresso'
708
+			);
709
+			return false;
710
+		}
711
+	}
712
+
713
+
714
+	/**
715
+	 * Callback for AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send_with_registrations trigger
716
+	 *
717
+	 * @since   4.3.0
718
+	 * @param  EE_Registration[] $registrations an array of EE_Registration objects
719
+	 * @param  int               $grp_id        a specific message template group id.
720
+	 * @return void
721
+	 */
722
+	public static function send_newsletter_message($registrations, $grp_id)
723
+	{
724
+		//make sure mtp is id and set it in the EE_Request Handler later messages setup.
725
+		EE_Registry::instance()->REQ->set('GRP_ID', (int)$grp_id);
726
+		self::_load_controller();
727
+		self::$_MSG_PROCESSOR->generate_for_all_active_messengers('newsletter', $registrations);
728
+	}
729
+
730
+
731
+	/**
732
+	 * Callback for FHEE__EE_Registration__invoice_url__invoice_url or FHEE__EE_Registration__receipt_url__receipt_url
733
+	 *
734
+	 * @since   4.3.0
735
+	 * @param    string          $registration_message_trigger_url
736
+	 * @param    EE_Registration $registration
737
+	 * @param string             $messenger
738
+	 * @param string             $message_type
739
+	 * @return    string
740
+	 */
741
+	public static function registration_message_trigger_url(
742
+		$registration_message_trigger_url,
743
+		EE_Registration $registration,
744
+		$messenger = 'html',
745
+		$message_type = 'invoice'
746
+	) {
747
+		// whitelist $messenger
748
+		switch ($messenger) {
749
+			case 'pdf' :
750
+				$sending_messenger    = 'pdf';
751
+				$generating_messenger = 'html';
752
+				break;
753
+			case 'html' :
754
+			default :
755
+				$sending_messenger    = 'html';
756
+				$generating_messenger = 'html';
757
+				break;
758
+		}
759
+		// whitelist $message_type
760
+		switch ($message_type) {
761
+			case 'receipt' :
762
+				$message_type = 'receipt';
763
+				break;
764
+			case 'invoice' :
765
+			default :
766
+				$message_type = 'invoice';
767
+				break;
768
+		}
769
+		// verify that both the messenger AND the message type are active
770
+		if (EEH_MSG_Template::is_messenger_active($sending_messenger) && EEH_MSG_Template::is_mt_active($message_type)) {
771
+			//need to get the correct message template group for this (i.e. is there a custom invoice for the event this registration is registered for?)
772
+			$template_query_params = array(
773
+				'MTP_is_active'    => true,
774
+				'MTP_messenger'    => $generating_messenger,
775
+				'MTP_message_type' => $message_type,
776
+				'Event.EVT_ID'     => $registration->event_ID(),
777
+			);
778
+			//get the message template group.
779
+			$msg_template_group = EEM_Message_Template_Group::instance()->get_one(array($template_query_params));
780
+			//if we don't have an EE_Message_Template_Group then return
781
+			if (! $msg_template_group instanceof EE_Message_Template_Group) {
782
+				// remove EVT_ID from query params so that global templates get picked up
783
+				unset($template_query_params['Event.EVT_ID']);
784
+				//get global template as the fallback
785
+				$msg_template_group = EEM_Message_Template_Group::instance()->get_one(array($template_query_params));
786
+			}
787
+			//if we don't have an EE_Message_Template_Group then return
788
+			if (! $msg_template_group instanceof EE_Message_Template_Group) {
789
+				return '';
790
+			}
791
+			// generate the URL
792
+			$registration_message_trigger_url = EEH_MSG_Template::generate_url_trigger(
793
+				$sending_messenger,
794
+				$generating_messenger,
795
+				'purchaser',
796
+				$message_type,
797
+				$registration,
798
+				$msg_template_group->ID(),
799
+				$registration->transaction_ID()
800
+			);
801
+
802
+		}
803
+		return $registration_message_trigger_url;
804
+	}
805
+
806
+
807
+	/**
808
+	 * Use to generate and return a message preview!
809
+	 *
810
+	 * @param  string $type      This should correspond with a valid message type
811
+	 * @param  string $context   This should correspond with a valid context for the message type
812
+	 * @param  string $messenger This should correspond with a valid messenger.
813
+	 * @param bool    $send      true we will do a test send using the messenger delivery, false we just do a regular
814
+	 *                           preview
815
+	 * @return string|bool          The body of the message or if send is requested, sends.
816
+	 */
817
+	public static function preview_message($type, $context, $messenger, $send = false)
818
+	{
819
+		self::_load_controller();
820
+		$mtg                     = new EE_Message_To_Generate(
821
+			$messenger,
822
+			$type,
823
+			array(),
824
+			$context,
825
+			true
826
+		);
827
+		$generated_preview_queue = self::$_MSG_PROCESSOR->generate_for_preview($mtg, $send);
828
+		if ($generated_preview_queue instanceof EE_Messages_Queue) {
829
+			return $generated_preview_queue->get_message_repository()->current()->content();
830
+		} else {
831
+			return $generated_preview_queue;
832
+		}
833
+	}
834
+
835
+
836
+	/**
837
+	 * This is a method that allows for sending a message using a messenger matching the string given and the provided
838
+	 * EE_Message_Queue object.  The EE_Message_Queue object is used to create a single aggregate EE_Message via the
839
+	 * content found in the EE_Message objects in the queue.
840
+	 *
841
+	 * @since 4.9.0
842
+	 * @param string            $messenger            a string matching a valid active messenger in the system
843
+	 * @param string            $message_type         Although it seems contrary to the name of the method, a message
844
+	 *                                                type name is still required to send along the message type to the
845
+	 *                                                messenger because this is used for determining what specific
846
+	 *                                                variations might be loaded for the generated message.
847
+	 * @param EE_Messages_Queue $queue
848
+	 * @param string            $custom_subject       Can be used to set what the custom subject string will be on the
849
+	 *                                                aggregate EE_Message object.
850
+	 * @return bool          success or fail.
851
+	 */
852
+	public static function send_message_with_messenger_only(
853
+		$messenger,
854
+		$message_type,
855
+		EE_Messages_Queue $queue,
856
+		$custom_subject = ''
857
+	) {
858
+		self::_load_controller();
859
+		/** @type EE_Message_To_Generate_From_Queue $message_to_generate */
860
+		$message_to_generate = EE_Registry::instance()->load_lib(
861
+			'Message_To_Generate_From_Queue',
862
+			array(
863
+				$messenger,
864
+				$message_type,
865
+				$queue,
866
+				$custom_subject,
867
+			)
868
+		);
869
+		return self::$_MSG_PROCESSOR->queue_for_sending($message_to_generate);
870
+	}
871
+
872
+
873
+	/**
874
+	 * Generates Messages immediately for EE_Message IDs (but only for the correct status for generation)
875
+	 *
876
+	 * @since 4.9.0
877
+	 * @param array $message_ids An array of message ids
878
+	 * @return bool | EE_Messages_Queue     false if nothing was generated, EE_Messages_Queue containing generated
879
+	 *              messages.
880
+	 */
881
+	public static function generate_now($message_ids)
882
+	{
883
+		self::_load_controller();
884
+		$messages        = EEM_Message::instance()->get_all(
885
+			array(
886
+				0 => array(
887
+					'MSG_ID' => array('IN', $message_ids),
888
+					'STS_ID' => EEM_Message::status_incomplete,
889
+				),
890
+			)
891
+		);
892
+		$generated_queue = false;
893
+		if ($messages) {
894
+			$generated_queue = self::$_MSG_PROCESSOR->batch_generate_from_queue($messages);
895
+		}
896
+
897
+		if (! $generated_queue instanceof EE_Messages_Queue) {
898
+			EE_Error::add_error(
899
+				__('The messages were not generated. This could mean there is already a batch being generated on a separate request, or because the selected messages are not ready for generation. Please wait a minute or two and try again.',
900
+					'event_espresso'),
901
+				__FILE__, __FUNCTION__, __LINE__
902
+			);
903
+		}
904
+		return $generated_queue;
905
+	}
906
+
907
+
908
+	/**
909
+	 * Sends messages immediately for the incoming message_ids that have the status of EEM_Message::status_resend or,
910
+	 * EEM_Message::status_idle
911
+	 *
912
+	 * @since 4.9.0
913
+	 * @param $message_ids
914
+	 * @return bool | EE_Messages_Queue  false if no messages sent.
915
+	 */
916
+	public static function send_now($message_ids)
917
+	{
918
+		self::_load_controller();
919
+		$messages   = EEM_Message::instance()->get_all(
920
+			array(
921
+				0 => array(
922
+					'MSG_ID' => array('IN', $message_ids),
923
+					'STS_ID' => array(
924
+						'IN',
925
+						array(EEM_Message::status_idle, EEM_Message::status_resend, EEM_Message::status_retry),
926
+					),
927
+				),
928
+			)
929
+		);
930
+		$sent_queue = false;
931
+		if ($messages) {
932
+			$sent_queue = self::$_MSG_PROCESSOR->batch_send_from_queue($messages);
933
+		}
934
+
935
+		if (! $sent_queue instanceof EE_Messages_Queue) {
936
+			EE_Error::add_error(
937
+				__('The messages were not sent. This could mean there is already a batch being sent on a separate request, or because the selected messages are not sendable. Please wait a minute or two and try again.',
938
+					'event_espresso'),
939
+				__FILE__, __FUNCTION__, __LINE__
940
+			);
941
+		} else {
942
+			//can count how many sent by using the messages in the queue
943
+			$sent_count = $sent_queue->count_STS_in_queue(EEM_Message::instance()->stati_indicating_sent());
944
+			if ($sent_count > 0) {
945
+				EE_Error::add_success(
946
+					sprintf(
947
+						_n(
948
+							'There was %d message successfully sent.',
949
+							'There were %d messages successfully sent.',
950
+							$sent_count,
951
+							'event_espresso'
952
+						),
953
+						$sent_count
954
+					)
955
+				);
956
+			} else {
957
+				EE_Error::overwrite_errors();
958
+				EE_Error::add_error(
959
+					__('No message was sent because of problems with sending. Either all the messages you selected were not a sendable message, they were ALREADY sent on a different scheduled task, or there was an error.
960 960
 					If there was an error, you can look at the messages in the message activity list table for any error messages.',
961
-                        'event_espresso'),
962
-                    __FILE__, __FUNCTION__, __LINE__
963
-                );
964
-            }
965
-        }
966
-        return $sent_queue;
967
-    }
968
-
969
-
970
-    /**
971
-     * This will queue the incoming message ids for resending.
972
-     * Note, only message_ids corresponding to messages with the status of EEM_Message::sent will be queued.
973
-     *
974
-     * @since 4.9.0
975
-     * @param array $message_ids An array of EE_Message IDs
976
-     * @return bool  true means messages were successfully queued for resending, false means none were queued for
977
-     *               resending.
978
-     */
979
-    public static function queue_for_resending($message_ids)
980
-    {
981
-        self::_load_controller();
982
-        self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send($message_ids);
983
-
984
-        //get queue and count
985
-        $queue_count = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_resend);
986
-
987
-        if (
988
-            $queue_count > 0
989
-        ) {
990
-            EE_Error::add_success(
991
-                sprintf(
992
-                    _n(
993
-                        '%d message successfully queued for resending.',
994
-                        '%d messages successfully queued for resending.',
995
-                        $queue_count,
996
-                        'event_espresso'
997
-                    ),
998
-                    $queue_count
999
-                )
1000
-            );
1001
-            /**
1002
-             * @see filter usage in EE_Messages_Queue::initiate_request_by_priority
1003
-             */
1004
-        } elseif (
1005
-            apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', true)
1006
-            || EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request
1007
-        ) {
1008
-            $queue_count = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_sent);
1009
-            if ($queue_count > 0) {
1010
-                EE_Error::add_success(
1011
-                    sprintf(
1012
-                        _n(
1013
-                            '%d message successfully sent.',
1014
-                            '%d messages successfully sent.',
1015
-                            $queue_count,
1016
-                            'event_espresso'
1017
-                        ),
1018
-                        $queue_count
1019
-                    )
1020
-                );
1021
-            } else {
1022
-                EE_Error::add_error(
1023
-                    __('No messages were queued for resending. This usually only happens when all the messages flagged for resending are not a status that can be resent.',
1024
-                        'event_espresso'),
1025
-                    __FILE__, __FUNCTION__, __LINE__
1026
-                );
1027
-            }
1028
-        } else {
1029
-            EE_Error::add_error(
1030
-                __('No messages were queued for resending. This usually only happens when all the messages flagged for resending are not a status that can be resent.',
1031
-                    'event_espresso'),
1032
-                __FILE__, __FUNCTION__, __LINE__
1033
-            );
1034
-        }
1035
-        return (bool)$queue_count;
1036
-    }
1037
-
1038
-
1039
-    /**
1040
-     * debug
1041
-     *
1042
-     * @param string          $class
1043
-     * @param string          $func
1044
-     * @param string          $line
1045
-     * @param \EE_Transaction $transaction
1046
-     * @param array           $info
1047
-     * @param bool            $display_request
1048
-     */
1049
-    protected static function log(
1050
-        $class = '',
1051
-        $func = '',
1052
-        $line = '',
1053
-        EE_Transaction $transaction,
1054
-        $info = array(),
1055
-        $display_request = false
1056
-    ) {
1057
-        if (WP_DEBUG && false) {
1058
-            if ($transaction instanceof EE_Transaction) {
1059
-                // don't serialize objects
1060
-                $info                  = EEH_Debug_Tools::strip_objects($info);
1061
-                $info['TXN_status']    = $transaction->status_ID();
1062
-                $info['TXN_reg_steps'] = $transaction->reg_steps();
1063
-                if ($transaction->ID()) {
1064
-                    $index = 'EE_Transaction: ' . $transaction->ID();
1065
-                    EEH_Debug_Tools::log($class, $func, $line, $info, $display_request, $index);
1066
-                }
1067
-            }
1068
-        }
1069
-
1070
-    }
1071
-
1072
-
1073
-    /**
1074
-     *  Resets all the static properties in this class when called.
1075
-     */
1076
-    public static function reset()
1077
-    {
1078
-        self::$_EEMSG                    = null;
1079
-        self::$_message_resource_manager = null;
1080
-        self::$_MSG_PROCESSOR            = null;
1081
-        self::$_MSG_PATHS                = null;
1082
-        self::$_TMP_PACKS                = array();
1083
-    }
961
+						'event_espresso'),
962
+					__FILE__, __FUNCTION__, __LINE__
963
+				);
964
+			}
965
+		}
966
+		return $sent_queue;
967
+	}
968
+
969
+
970
+	/**
971
+	 * This will queue the incoming message ids for resending.
972
+	 * Note, only message_ids corresponding to messages with the status of EEM_Message::sent will be queued.
973
+	 *
974
+	 * @since 4.9.0
975
+	 * @param array $message_ids An array of EE_Message IDs
976
+	 * @return bool  true means messages were successfully queued for resending, false means none were queued for
977
+	 *               resending.
978
+	 */
979
+	public static function queue_for_resending($message_ids)
980
+	{
981
+		self::_load_controller();
982
+		self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send($message_ids);
983
+
984
+		//get queue and count
985
+		$queue_count = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_resend);
986
+
987
+		if (
988
+			$queue_count > 0
989
+		) {
990
+			EE_Error::add_success(
991
+				sprintf(
992
+					_n(
993
+						'%d message successfully queued for resending.',
994
+						'%d messages successfully queued for resending.',
995
+						$queue_count,
996
+						'event_espresso'
997
+					),
998
+					$queue_count
999
+				)
1000
+			);
1001
+			/**
1002
+			 * @see filter usage in EE_Messages_Queue::initiate_request_by_priority
1003
+			 */
1004
+		} elseif (
1005
+			apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', true)
1006
+			|| EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request
1007
+		) {
1008
+			$queue_count = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_sent);
1009
+			if ($queue_count > 0) {
1010
+				EE_Error::add_success(
1011
+					sprintf(
1012
+						_n(
1013
+							'%d message successfully sent.',
1014
+							'%d messages successfully sent.',
1015
+							$queue_count,
1016
+							'event_espresso'
1017
+						),
1018
+						$queue_count
1019
+					)
1020
+				);
1021
+			} else {
1022
+				EE_Error::add_error(
1023
+					__('No messages were queued for resending. This usually only happens when all the messages flagged for resending are not a status that can be resent.',
1024
+						'event_espresso'),
1025
+					__FILE__, __FUNCTION__, __LINE__
1026
+				);
1027
+			}
1028
+		} else {
1029
+			EE_Error::add_error(
1030
+				__('No messages were queued for resending. This usually only happens when all the messages flagged for resending are not a status that can be resent.',
1031
+					'event_espresso'),
1032
+				__FILE__, __FUNCTION__, __LINE__
1033
+			);
1034
+		}
1035
+		return (bool)$queue_count;
1036
+	}
1037
+
1038
+
1039
+	/**
1040
+	 * debug
1041
+	 *
1042
+	 * @param string          $class
1043
+	 * @param string          $func
1044
+	 * @param string          $line
1045
+	 * @param \EE_Transaction $transaction
1046
+	 * @param array           $info
1047
+	 * @param bool            $display_request
1048
+	 */
1049
+	protected static function log(
1050
+		$class = '',
1051
+		$func = '',
1052
+		$line = '',
1053
+		EE_Transaction $transaction,
1054
+		$info = array(),
1055
+		$display_request = false
1056
+	) {
1057
+		if (WP_DEBUG && false) {
1058
+			if ($transaction instanceof EE_Transaction) {
1059
+				// don't serialize objects
1060
+				$info                  = EEH_Debug_Tools::strip_objects($info);
1061
+				$info['TXN_status']    = $transaction->status_ID();
1062
+				$info['TXN_reg_steps'] = $transaction->reg_steps();
1063
+				if ($transaction->ID()) {
1064
+					$index = 'EE_Transaction: ' . $transaction->ID();
1065
+					EEH_Debug_Tools::log($class, $func, $line, $info, $display_request, $index);
1066
+				}
1067
+			}
1068
+		}
1069
+
1070
+	}
1071
+
1072
+
1073
+	/**
1074
+	 *  Resets all the static properties in this class when called.
1075
+	 */
1076
+	public static function reset()
1077
+	{
1078
+		self::$_EEMSG                    = null;
1079
+		self::$_message_resource_manager = null;
1080
+		self::$_MSG_PROCESSOR            = null;
1081
+		self::$_MSG_PATHS                = null;
1082
+		self::$_TMP_PACKS                = array();
1083
+	}
1084 1084
 
1085 1085
 }
1086 1086
 // End of file EED_Messages.module.php
Please login to merge, or discard this patch.
acceptance_tests/Page/RegistrationsAdmin.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -11,20 +11,20 @@
 block discarded – undo
11 11
  */
12 12
 class RegistrationsAdmin extends CoreAdmin
13 13
 {
14
-    /**
15
-     * @var string
16
-     */
17
-    const REGISTRATION_STATUS_NOT_APPROVED = 'RNA';
14
+	/**
15
+	 * @var string
16
+	 */
17
+	const REGISTRATION_STATUS_NOT_APPROVED = 'RNA';
18 18
 
19 19
 
20
-    /**
21
-     * @var string
22
-     */
23
-    const REGISTRATION_STATUS_APPROVED = 'RAP';
20
+	/**
21
+	 * @var string
22
+	 */
23
+	const REGISTRATION_STATUS_APPROVED = 'RAP';
24 24
 
25 25
 
26
-    /**
27
-     * @var string
28
-     */
29
-    const REGISTRATION_STATUS_PENDING_PAYMENT = 'RPP';
26
+	/**
27
+	 * @var string
28
+	 */
29
+	const REGISTRATION_STATUS_PENDING_PAYMENT = 'RPP';
30 30
 }
31 31
\ No newline at end of file
Please login to merge, or discard this patch.