Completed
Branch BUG/3615-empty-array-arguments (44a08d)
by
unknown
13:14 queued 10:24
created
modules/ticket_selector_caff/EED_Ticket_Selector_Caff.module.php 2 patches
Indentation   +294 added lines, -294 removed lines patch added patch discarded remove patch
@@ -17,319 +17,319 @@
 block discarded – undo
17 17
 {
18 18
 
19 19
 
20
-    /**
21
-     * @return EED_Module|EED_Ticket_Selector_Caff
22
-     */
23
-    public static function instance()
24
-    {
25
-        return parent::get_instance(__CLASS__);
26
-    }
20
+	/**
21
+	 * @return EED_Module|EED_Ticket_Selector_Caff
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
-     * @access    public
33
-     * @return    void
34
-     */
35
-    public static function set_hooks()
36
-    {
37
-        add_action(
38
-            'AHEE__ticket_selector_chart_template__ticket_details__after_description',
39
-            array('EED_Ticket_Selector_Caff', 'ticket_price_details'),
40
-            10,
41
-            3
42
-        );
43
-    }
29
+	/**
30
+	 *    set_hooks - for hooking into EE Core, other modules, etc
31
+	 *
32
+	 * @access    public
33
+	 * @return    void
34
+	 */
35
+	public static function set_hooks()
36
+	{
37
+		add_action(
38
+			'AHEE__ticket_selector_chart_template__ticket_details__after_description',
39
+			array('EED_Ticket_Selector_Caff', 'ticket_price_details'),
40
+			10,
41
+			3
42
+		);
43
+	}
44 44
 
45
-    /**
46
-     *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
47
-     *
48
-     * @access    public
49
-     * @return    void
50
-     */
51
-    public static function set_hooks_admin()
52
-    {
53
-        define(
54
-            'TICKET_SELECTOR_CAFF_TEMPLATES_PATH',
55
-            str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/'
56
-        );
57
-        add_action(
58
-            'AHEE__template_settings__template__before_settings_form',
59
-            array('EED_Ticket_Selector_Caff', 'template_settings_form'),
60
-            10
61
-        );
62
-        add_filter(
63
-            'FHEE__General_Settings_Admin_Page__update_template_settings__data',
64
-            array('EED_Ticket_Selector_Caff', 'update_template_settings'),
65
-            10,
66
-            2
67
-        );
68
-    }
45
+	/**
46
+	 *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
47
+	 *
48
+	 * @access    public
49
+	 * @return    void
50
+	 */
51
+	public static function set_hooks_admin()
52
+	{
53
+		define(
54
+			'TICKET_SELECTOR_CAFF_TEMPLATES_PATH',
55
+			str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/'
56
+		);
57
+		add_action(
58
+			'AHEE__template_settings__template__before_settings_form',
59
+			array('EED_Ticket_Selector_Caff', 'template_settings_form'),
60
+			10
61
+		);
62
+		add_filter(
63
+			'FHEE__General_Settings_Admin_Page__update_template_settings__data',
64
+			array('EED_Ticket_Selector_Caff', 'update_template_settings'),
65
+			10,
66
+			2
67
+		);
68
+	}
69 69
 
70 70
 
71
-    /**
72
-     * @param \WP $WP
73
-     */
74
-    public function run($WP)
75
-    {
76
-        $this->set_config();
77
-    }
71
+	/**
72
+	 * @param \WP $WP
73
+	 */
74
+	public function run($WP)
75
+	{
76
+		$this->set_config();
77
+	}
78 78
 
79 79
 
80
-    /**
81
-     * @static
82
-     * @return void
83
-     * @throws EE_Error
84
-     * @throws InvalidArgumentException
85
-     * @throws InvalidDataTypeException
86
-     * @throws InvalidInterfaceException
87
-     */
88
-    public static function template_settings_form()
89
-    {
90
-        echo EED_Ticket_Selector_Caff::_ticket_selector_settings_form()->get_html();
91
-    }
80
+	/**
81
+	 * @static
82
+	 * @return void
83
+	 * @throws EE_Error
84
+	 * @throws InvalidArgumentException
85
+	 * @throws InvalidDataTypeException
86
+	 * @throws InvalidInterfaceException
87
+	 */
88
+	public static function template_settings_form()
89
+	{
90
+		echo EED_Ticket_Selector_Caff::_ticket_selector_settings_form()->get_html();
91
+	}
92 92
 
93 93
 
94
-    /**
95
-     * @return \EE_Form_Section_Proper
96
-     * @throws \EE_Error
97
-     */
98
-    public static function _ticket_selector_settings_form()
99
-    {
94
+	/**
95
+	 * @return \EE_Form_Section_Proper
96
+	 * @throws \EE_Error
97
+	 */
98
+	public static function _ticket_selector_settings_form()
99
+	{
100 100
 
101
-        return new EE_Form_Section_Proper(
102
-            array(
103
-                'name'            => 'ticket_selector_settings_form',
104
-                'html_id'         => 'ticket_selector_settings_form',
105
-                'layout_strategy' => new EE_Div_Per_Section_Layout(),
106
-                'subsections'     => apply_filters(
107
-                    'FHEE__EED_Ticket_Selector_Caff___ticket_selector_settings_form__form_subsections',
108
-                    array(
109
-                        'appearance_settings_hdr' => new EE_Form_Section_HTML(
110
-                            EEH_HTML::br(2) .
111
-                            EEH_HTML::h2(esc_html__('Ticket Selector Template Settings', 'event_espresso'))
112
-                        ),
113
-                        'appearance_settings'     => EED_Ticket_Selector_Caff::_ticket_selector_appearance_settings(),
114
-                    )
115
-                ),
116
-            )
117
-        );
118
-    }
101
+		return new EE_Form_Section_Proper(
102
+			array(
103
+				'name'            => 'ticket_selector_settings_form',
104
+				'html_id'         => 'ticket_selector_settings_form',
105
+				'layout_strategy' => new EE_Div_Per_Section_Layout(),
106
+				'subsections'     => apply_filters(
107
+					'FHEE__EED_Ticket_Selector_Caff___ticket_selector_settings_form__form_subsections',
108
+					array(
109
+						'appearance_settings_hdr' => new EE_Form_Section_HTML(
110
+							EEH_HTML::br(2) .
111
+							EEH_HTML::h2(esc_html__('Ticket Selector Template Settings', 'event_espresso'))
112
+						),
113
+						'appearance_settings'     => EED_Ticket_Selector_Caff::_ticket_selector_appearance_settings(),
114
+					)
115
+				),
116
+			)
117
+		);
118
+	}
119 119
 
120 120
 
121
-    /**
122
-     * @return \EE_Form_Section_Proper
123
-     * @throws \EE_Error
124
-     */
125
-    public static function _ticket_selector_appearance_settings()
126
-    {
127
-        if (
128
-            ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config
129
-        ) {
130
-            EED_Ticket_Selector::instance()->set_config();
131
-            EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = EED_Ticket_Selector::instance()
132
-                                                                                                      ->config();
133
-        }
134
-        $EE_Ticket_Selector_Config = EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector;
135
-        // get option for whether to show datetime selector in TS
136
-        $show_datetime_selector = $EE_Ticket_Selector_Config->getShowDatetimeSelector();
137
-        // and option for how may datetimes must exist if display is conditional
138
-        $datetime_selector_threshold = $EE_Ticket_Selector_Config->getDatetimeSelectorThreshold();
121
+	/**
122
+	 * @return \EE_Form_Section_Proper
123
+	 * @throws \EE_Error
124
+	 */
125
+	public static function _ticket_selector_appearance_settings()
126
+	{
127
+		if (
128
+			! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config
129
+		) {
130
+			EED_Ticket_Selector::instance()->set_config();
131
+			EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = EED_Ticket_Selector::instance()
132
+																									  ->config();
133
+		}
134
+		$EE_Ticket_Selector_Config = EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector;
135
+		// get option for whether to show datetime selector in TS
136
+		$show_datetime_selector = $EE_Ticket_Selector_Config->getShowDatetimeSelector();
137
+		// and option for how may datetimes must exist if display is conditional
138
+		$datetime_selector_threshold = $EE_Ticket_Selector_Config->getDatetimeSelectorThreshold();
139 139
 
140
-        return new EE_Form_Section_Proper(
141
-            array(
142
-                'name'            => 'ticket_selector_settings_tbl',
143
-                'html_id'         => 'ticket_selector_settings_tbl',
144
-                'html_class'      => 'form-table',
145
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
146
-                'subsections'     => apply_filters(
147
-                    'FHEE__EED_Ticket_Selector_Caff___ticket_selector_appearance_settings__form_subsections',
148
-                    array(
149
-                        'show_ticket_details'         => new EE_Yes_No_Input(
150
-                            array(
151
-                                'html_label_text'         => esc_html__(
152
-                                    'Show Ticket Details?',
153
-                                    'event_espresso'
154
-                                ),
155
-                                'html_help_text'          => esc_html__(
156
-                                    'This lets you choose whether the extra ticket details section is displayed with the ticket selector.',
157
-                                    'event_espresso'
158
-                                ),
159
-                                'default'                 => isset($EE_Ticket_Selector_Config->show_ticket_details)
160
-                                    ? $EE_Ticket_Selector_Config->show_ticket_details
161
-                                    : true,
162
-                                'display_html_label_text' => false,
163
-                            )
164
-                        ),
165
-                        'show_ticket_sale_columns'    => new EE_Yes_No_Input(
166
-                            array(
167
-                                'html_label_text'         => esc_html__(
168
-                                    'Show Ticket Sale Info?',
169
-                                    'event_espresso'
170
-                                ),
171
-                                'html_help_text'          => esc_html__(
172
-                                    'This lets you indicate whether information about ticket sales is shown with ticket details in the ticket selector.',
173
-                                    'event_espresso'
174
-                                ),
175
-                                'default'                 => isset($EE_Ticket_Selector_Config->show_ticket_sale_columns)
176
-                                    ? $EE_Ticket_Selector_Config->show_ticket_sale_columns
177
-                                    : true,
178
-                                'display_html_label_text' => false,
179
-                            )
180
-                        ),
181
-                        'show_expired_tickets'        => new EE_Yes_No_Input(
182
-                            array(
183
-                                'html_label_text'         => esc_html__(
184
-                                    'Show Expired Tickets?',
185
-                                    'event_espresso'
186
-                                ),
187
-                                'html_help_text'          => esc_html__(
188
-                                    'Indicate whether to show expired tickets in the ticket selector',
189
-                                    'event_espresso'
190
-                                ),
191
-                                'default'                 => isset($EE_Ticket_Selector_Config->show_expired_tickets)
192
-                                    ? $EE_Ticket_Selector_Config->show_expired_tickets
193
-                                    : true,
194
-                                'display_html_label_text' => false,
195
-                            )
196
-                        ),
197
-                        'show_datetime_selector'      => new EE_Select_Input(
198
-                            $EE_Ticket_Selector_Config->getShowDatetimeSelectorOptions(false),
199
-                            array(
200
-                                'html_label_text'         => esc_html__(
201
-                                    'Show Date & Time Filter?',
202
-                                    'event_espresso'
203
-                                ),
204
-                                'html_help_text'          => sprintf(
205
-                                    esc_html__(
206
-                                        'Indicates whether or not to display a dropdown select box above each ticket selector that displays dates and times for the available tickets. Ticket options can be unselected, which removes (hides) them from the list of tickets being displayed.%1$sOptions include:%1$s • %2$sdo not show date & time filter%3$s%1$s   this option will NEVER display a date filter, regardless of how many dates exist.%1$s • %2$smaybe show date & time filter%3$s%1$s   this option will conditionally display the date filter when the number of dates for the event matches the value set for "Date Filter Threshold".',
207
-                                        'event_espresso'
208
-                                    ),
209
-                                    '<br>',
210
-                                    '<strong>',
211
-                                    '</strong>'
212
-                                ),
213
-                                'default'                 => ! empty($show_datetime_selector)
214
-                                    ? $show_datetime_selector
215
-                                    : EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR,
216
-                                'display_html_label_text' => false,
217
-                            )
218
-                        ),
219
-                        'datetime_selector_threshold' => new EE_Select_Input(
220
-                            array_combine($r = range(1, 10), $r),
221
-                            array(
222
-                                'html_label_text'         => esc_html__(
223
-                                    'Date & Time Filter Threshold',
224
-                                    'event_espresso'
225
-                                ),
226
-                                'html_help_text'          => esc_html__(
227
-                                    'The number of unique dates an event has to have before conditionally displaying a date & time filter',
228
-                                    'event_espresso'
229
-                                ),
230
-                                'default'                 => ! empty($datetime_selector_threshold)
231
-                                    ? $datetime_selector_threshold
232
-                                    : 3,
233
-                                'display_html_label_text' => false,
234
-                            )
235
-                        ),
236
-                        'datetime_selector_max_checked' => new EE_Integer_Input(
237
-                            array(
238
-                                'html_label_text'         => esc_html__(
239
-                                    'Date & Time Filter Max Checked',
240
-                                    'event_espresso'
241
-                                ),
242
-                                'html_help_text'          => sprintf(
243
-                                    esc_html__(
244
-                                        'Determines the maximum number of dates that will be checked upon initial loading for a Date and Time Filter.%1$sIf set to zero or left blank, then ALL dates will be checked upon initial loading.',
245
-                                        'event_espresso'
246
-                                    ),
247
-                                    '<br>'
248
-                                ),
249
-                                'default'                 => $EE_Ticket_Selector_Config->getDatetimeSelectorMaxChecked(),
250
-                                'display_html_label_text' => false,
251
-                                'min_value'               => 0,
252
-                            )
253
-                        ),
254
-                    )
255
-                ),
256
-            )
257
-        );
258
-    }
140
+		return new EE_Form_Section_Proper(
141
+			array(
142
+				'name'            => 'ticket_selector_settings_tbl',
143
+				'html_id'         => 'ticket_selector_settings_tbl',
144
+				'html_class'      => 'form-table',
145
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
146
+				'subsections'     => apply_filters(
147
+					'FHEE__EED_Ticket_Selector_Caff___ticket_selector_appearance_settings__form_subsections',
148
+					array(
149
+						'show_ticket_details'         => new EE_Yes_No_Input(
150
+							array(
151
+								'html_label_text'         => esc_html__(
152
+									'Show Ticket Details?',
153
+									'event_espresso'
154
+								),
155
+								'html_help_text'          => esc_html__(
156
+									'This lets you choose whether the extra ticket details section is displayed with the ticket selector.',
157
+									'event_espresso'
158
+								),
159
+								'default'                 => isset($EE_Ticket_Selector_Config->show_ticket_details)
160
+									? $EE_Ticket_Selector_Config->show_ticket_details
161
+									: true,
162
+								'display_html_label_text' => false,
163
+							)
164
+						),
165
+						'show_ticket_sale_columns'    => new EE_Yes_No_Input(
166
+							array(
167
+								'html_label_text'         => esc_html__(
168
+									'Show Ticket Sale Info?',
169
+									'event_espresso'
170
+								),
171
+								'html_help_text'          => esc_html__(
172
+									'This lets you indicate whether information about ticket sales is shown with ticket details in the ticket selector.',
173
+									'event_espresso'
174
+								),
175
+								'default'                 => isset($EE_Ticket_Selector_Config->show_ticket_sale_columns)
176
+									? $EE_Ticket_Selector_Config->show_ticket_sale_columns
177
+									: true,
178
+								'display_html_label_text' => false,
179
+							)
180
+						),
181
+						'show_expired_tickets'        => new EE_Yes_No_Input(
182
+							array(
183
+								'html_label_text'         => esc_html__(
184
+									'Show Expired Tickets?',
185
+									'event_espresso'
186
+								),
187
+								'html_help_text'          => esc_html__(
188
+									'Indicate whether to show expired tickets in the ticket selector',
189
+									'event_espresso'
190
+								),
191
+								'default'                 => isset($EE_Ticket_Selector_Config->show_expired_tickets)
192
+									? $EE_Ticket_Selector_Config->show_expired_tickets
193
+									: true,
194
+								'display_html_label_text' => false,
195
+							)
196
+						),
197
+						'show_datetime_selector'      => new EE_Select_Input(
198
+							$EE_Ticket_Selector_Config->getShowDatetimeSelectorOptions(false),
199
+							array(
200
+								'html_label_text'         => esc_html__(
201
+									'Show Date & Time Filter?',
202
+									'event_espresso'
203
+								),
204
+								'html_help_text'          => sprintf(
205
+									esc_html__(
206
+										'Indicates whether or not to display a dropdown select box above each ticket selector that displays dates and times for the available tickets. Ticket options can be unselected, which removes (hides) them from the list of tickets being displayed.%1$sOptions include:%1$s &bull; %2$sdo not show date & time filter%3$s%1$s &nbsp; this option will NEVER display a date filter, regardless of how many dates exist.%1$s &bull; %2$smaybe show date & time filter%3$s%1$s &nbsp; this option will conditionally display the date filter when the number of dates for the event matches the value set for "Date Filter Threshold".',
207
+										'event_espresso'
208
+									),
209
+									'<br>',
210
+									'<strong>',
211
+									'</strong>'
212
+								),
213
+								'default'                 => ! empty($show_datetime_selector)
214
+									? $show_datetime_selector
215
+									: EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR,
216
+								'display_html_label_text' => false,
217
+							)
218
+						),
219
+						'datetime_selector_threshold' => new EE_Select_Input(
220
+							array_combine($r = range(1, 10), $r),
221
+							array(
222
+								'html_label_text'         => esc_html__(
223
+									'Date & Time Filter Threshold',
224
+									'event_espresso'
225
+								),
226
+								'html_help_text'          => esc_html__(
227
+									'The number of unique dates an event has to have before conditionally displaying a date & time filter',
228
+									'event_espresso'
229
+								),
230
+								'default'                 => ! empty($datetime_selector_threshold)
231
+									? $datetime_selector_threshold
232
+									: 3,
233
+								'display_html_label_text' => false,
234
+							)
235
+						),
236
+						'datetime_selector_max_checked' => new EE_Integer_Input(
237
+							array(
238
+								'html_label_text'         => esc_html__(
239
+									'Date & Time Filter Max Checked',
240
+									'event_espresso'
241
+								),
242
+								'html_help_text'          => sprintf(
243
+									esc_html__(
244
+										'Determines the maximum number of dates that will be checked upon initial loading for a Date and Time Filter.%1$sIf set to zero or left blank, then ALL dates will be checked upon initial loading.',
245
+										'event_espresso'
246
+									),
247
+									'<br>'
248
+								),
249
+								'default'                 => $EE_Ticket_Selector_Config->getDatetimeSelectorMaxChecked(),
250
+								'display_html_label_text' => false,
251
+								'min_value'               => 0,
252
+							)
253
+						),
254
+					)
255
+				),
256
+			)
257
+		);
258
+	}
259 259
 
260 260
 
261
-    /**
262
-     * callback for updating template settings
263
-     *
264
-     * @since 4.6.18.rc.006
265
-     * @param EE_Template_Config $CFG
266
-     * @param array              $REQ incoming request
267
-     * @return EE_Template_Config
268
-     * @throws EE_Error
269
-     * @throws InvalidArgumentException
270
-     * @throws ReflectionException
271
-     * @throws InvalidDataTypeException
272
-     * @throws InvalidInterfaceException
273
-     */
274
-    public static function update_template_settings(EE_Template_Config $CFG, $REQ)
275
-    {
276
-        if (! $CFG->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config) {
277
-            EED_Ticket_Selector::instance()->set_config();
278
-            $CFG->EED_Ticket_Selector = EED_Ticket_Selector::instance()->config();
279
-        }
280
-        try {
281
-            $ticket_selector_form = EED_Ticket_Selector_Caff::_ticket_selector_settings_form();
261
+	/**
262
+	 * callback for updating template settings
263
+	 *
264
+	 * @since 4.6.18.rc.006
265
+	 * @param EE_Template_Config $CFG
266
+	 * @param array              $REQ incoming request
267
+	 * @return EE_Template_Config
268
+	 * @throws EE_Error
269
+	 * @throws InvalidArgumentException
270
+	 * @throws ReflectionException
271
+	 * @throws InvalidDataTypeException
272
+	 * @throws InvalidInterfaceException
273
+	 */
274
+	public static function update_template_settings(EE_Template_Config $CFG, $REQ)
275
+	{
276
+		if (! $CFG->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config) {
277
+			EED_Ticket_Selector::instance()->set_config();
278
+			$CFG->EED_Ticket_Selector = EED_Ticket_Selector::instance()->config();
279
+		}
280
+		try {
281
+			$ticket_selector_form = EED_Ticket_Selector_Caff::_ticket_selector_settings_form();
282 282
 
283
-            // check for form submission
284
-            if ($ticket_selector_form->was_submitted()) {
285
-                // capture form data
286
-                $ticket_selector_form->receive_form_submission();
283
+			// check for form submission
284
+			if ($ticket_selector_form->was_submitted()) {
285
+				// capture form data
286
+				$ticket_selector_form->receive_form_submission();
287 287
 
288
-                // validate form data
289
-                if ($ticket_selector_form->is_valid()) {
290
-                    // grab validated data from form
291
-                    $valid_data = $ticket_selector_form->valid_data();
288
+				// validate form data
289
+				if ($ticket_selector_form->is_valid()) {
290
+					// grab validated data from form
291
+					$valid_data = $ticket_selector_form->valid_data();
292 292
 
293
-                    // set data on config
294
-                    $CFG->EED_Ticket_Selector->show_ticket_sale_columns = $valid_data['appearance_settings']['show_ticket_sale_columns'];
295
-                    $CFG->EED_Ticket_Selector->show_ticket_details = $valid_data['appearance_settings']['show_ticket_details'];
296
-                    $CFG->EED_Ticket_Selector->show_expired_tickets = $valid_data['appearance_settings']['show_expired_tickets'];
297
-                    $CFG->EED_Ticket_Selector->setShowDatetimeSelector(
298
-                        $valid_data['appearance_settings']['show_datetime_selector']
299
-                    );
300
-                    $CFG->EED_Ticket_Selector->setDatetimeSelectorThreshold(
301
-                        $valid_data['appearance_settings']['datetime_selector_threshold']
302
-                    );
303
-                    $CFG->EED_Ticket_Selector->setDatetimeSelectorMaxChecked(
304
-                        $valid_data['appearance_settings']['datetime_selector_max_checked']
305
-                    );
306
-                } else {
307
-                    if ($ticket_selector_form->submission_error_message() !== '') {
308
-                        EE_Error::add_error(
309
-                            $ticket_selector_form->submission_error_message(),
310
-                            __FILE__,
311
-                            __FUNCTION__,
312
-                            __LINE__
313
-                        );
314
-                    }
315
-                }
316
-            }
317
-        } catch (EE_Error $e) {
318
-            $e->get_error();
319
-        }
293
+					// set data on config
294
+					$CFG->EED_Ticket_Selector->show_ticket_sale_columns = $valid_data['appearance_settings']['show_ticket_sale_columns'];
295
+					$CFG->EED_Ticket_Selector->show_ticket_details = $valid_data['appearance_settings']['show_ticket_details'];
296
+					$CFG->EED_Ticket_Selector->show_expired_tickets = $valid_data['appearance_settings']['show_expired_tickets'];
297
+					$CFG->EED_Ticket_Selector->setShowDatetimeSelector(
298
+						$valid_data['appearance_settings']['show_datetime_selector']
299
+					);
300
+					$CFG->EED_Ticket_Selector->setDatetimeSelectorThreshold(
301
+						$valid_data['appearance_settings']['datetime_selector_threshold']
302
+					);
303
+					$CFG->EED_Ticket_Selector->setDatetimeSelectorMaxChecked(
304
+						$valid_data['appearance_settings']['datetime_selector_max_checked']
305
+					);
306
+				} else {
307
+					if ($ticket_selector_form->submission_error_message() !== '') {
308
+						EE_Error::add_error(
309
+							$ticket_selector_form->submission_error_message(),
310
+							__FILE__,
311
+							__FUNCTION__,
312
+							__LINE__
313
+						);
314
+					}
315
+				}
316
+			}
317
+		} catch (EE_Error $e) {
318
+			$e->get_error();
319
+		}
320 320
 
321
-        return $CFG;
322
-    }
321
+		return $CFG;
322
+	}
323 323
 
324 324
 
325
-    /**
326
-     * @param \EE_Ticket $ticket
327
-     * @param int        $ticket_price
328
-     * @param bool       $display_ticket_price
329
-     */
330
-    public static function ticket_price_details(EE_Ticket $ticket, $ticket_price = 0, $display_ticket_price = false)
331
-    {
332
-        require str_replace('\\', '/', plugin_dir_path(__FILE__))
333
-                . 'templates/ticket_selector_price_details.template.php';
334
-    }
325
+	/**
326
+	 * @param \EE_Ticket $ticket
327
+	 * @param int        $ticket_price
328
+	 * @param bool       $display_ticket_price
329
+	 */
330
+	public static function ticket_price_details(EE_Ticket $ticket, $ticket_price = 0, $display_ticket_price = false)
331
+	{
332
+		require str_replace('\\', '/', plugin_dir_path(__FILE__))
333
+				. 'templates/ticket_selector_price_details.template.php';
334
+	}
335 335
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
     {
53 53
         define(
54 54
             'TICKET_SELECTOR_CAFF_TEMPLATES_PATH',
55
-            str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/'
55
+            str_replace('\\', '/', plugin_dir_path(__FILE__)).'templates/'
56 56
         );
57 57
         add_action(
58 58
             'AHEE__template_settings__template__before_settings_form',
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
                     'FHEE__EED_Ticket_Selector_Caff___ticket_selector_settings_form__form_subsections',
108 108
                     array(
109 109
                         'appearance_settings_hdr' => new EE_Form_Section_HTML(
110
-                            EEH_HTML::br(2) .
110
+                            EEH_HTML::br(2).
111 111
                             EEH_HTML::h2(esc_html__('Ticket Selector Template Settings', 'event_espresso'))
112 112
                         ),
113 113
                         'appearance_settings'     => EED_Ticket_Selector_Caff::_ticket_selector_appearance_settings(),
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
      */
274 274
     public static function update_template_settings(EE_Template_Config $CFG, $REQ)
275 275
     {
276
-        if (! $CFG->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config) {
276
+        if ( ! $CFG->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config) {
277 277
             EED_Ticket_Selector::instance()->set_config();
278 278
             $CFG->EED_Ticket_Selector = EED_Ticket_Selector::instance()->config();
279 279
         }
Please login to merge, or discard this patch.
caffeinated/modules/recaptcha_invisible/RecaptchaAdminSettings.php 1 patch
Indentation   +346 added lines, -346 removed lines patch added patch discarded remove patch
@@ -31,362 +31,362 @@
 block discarded – undo
31 31
 class RecaptchaAdminSettings
32 32
 {
33 33
 
34
-    /**
35
-     * @var EE_Registration_Config $config
36
-     */
37
-    private $config;
34
+	/**
35
+	 * @var EE_Registration_Config $config
36
+	 */
37
+	private $config;
38 38
 
39 39
 
40
-    /**
41
-     * RecaptchaAdminSettings constructor.
42
-     *
43
-     * @param EE_Registration_Config $registration_config
44
-     */
45
-    public function __construct(EE_Registration_Config $registration_config)
46
-    {
47
-        $this->config = $registration_config;
48
-    }
40
+	/**
41
+	 * RecaptchaAdminSettings constructor.
42
+	 *
43
+	 * @param EE_Registration_Config $registration_config
44
+	 */
45
+	public function __construct(EE_Registration_Config $registration_config)
46
+	{
47
+		$this->config = $registration_config;
48
+	}
49 49
 
50 50
 
51
-    /**
52
-     * @throws InvalidArgumentException
53
-     * @throws InvalidInterfaceException
54
-     * @throws InvalidDataTypeException
55
-     * @throws EE_Error
56
-     */
57
-    public function adminSettings()
58
-    {
59
-        echo $this->settingsForm()->get_html_and_js();
60
-    }
51
+	/**
52
+	 * @throws InvalidArgumentException
53
+	 * @throws InvalidInterfaceException
54
+	 * @throws InvalidDataTypeException
55
+	 * @throws EE_Error
56
+	 */
57
+	public function adminSettings()
58
+	{
59
+		echo $this->settingsForm()->get_html_and_js();
60
+	}
61 61
 
62 62
 
63
-    /**
64
-     * @return EE_Form_Section_Proper
65
-     * @throws EE_Error
66
-     */
67
-    protected function settingsForm()
68
-    {
69
-        return new EE_Form_Section_Proper(
70
-            array(
71
-                'name'            => 'recaptcha_settings_form',
72
-                'html_id'         => 'recaptcha_settings_form',
73
-                'layout_strategy' => new EE_Div_Per_Section_Layout(),
74
-                'subsections'     => apply_filters(
75
-                    'FHEE__EED_Recaptcha___recaptcha_settings_form__form_subsections',
76
-                    array(
77
-                        'main_settings_hdr'       => new EE_Form_Section_HTML(
78
-                            EEH_HTML::h2(
79
-                                esc_html__('reCAPTCHA Anti-spam Settings', 'event_espresso')
80
-                                . EEH_Template::get_help_tab_link('recaptcha_info')
81
-                            )
82
-                        ),
83
-                        'main_settings'           => $this->mainSettings(),
84
-                        'appearance_settings_hdr' => new EE_Form_Section_HTML(
85
-                            EEH_HTML::h2(esc_html__('reCAPTCHA Appearance', 'event_espresso'))
86
-                        ),
87
-                        'appearance_settings'     => $this->appearanceSettings(),
88
-                        'required_fields_note'    => new EE_Form_Section_HTML(
89
-                            EEH_HTML::p(
90
-                                esc_html__('All fields marked with a * are required fields', 'event_espresso'),
91
-                                '',
92
-                                'grey-text'
93
-                            )
94
-                        ),
95
-                    )
96
-                ),
97
-            )
98
-        );
99
-    }
63
+	/**
64
+	 * @return EE_Form_Section_Proper
65
+	 * @throws EE_Error
66
+	 */
67
+	protected function settingsForm()
68
+	{
69
+		return new EE_Form_Section_Proper(
70
+			array(
71
+				'name'            => 'recaptcha_settings_form',
72
+				'html_id'         => 'recaptcha_settings_form',
73
+				'layout_strategy' => new EE_Div_Per_Section_Layout(),
74
+				'subsections'     => apply_filters(
75
+					'FHEE__EED_Recaptcha___recaptcha_settings_form__form_subsections',
76
+					array(
77
+						'main_settings_hdr'       => new EE_Form_Section_HTML(
78
+							EEH_HTML::h2(
79
+								esc_html__('reCAPTCHA Anti-spam Settings', 'event_espresso')
80
+								. EEH_Template::get_help_tab_link('recaptcha_info')
81
+							)
82
+						),
83
+						'main_settings'           => $this->mainSettings(),
84
+						'appearance_settings_hdr' => new EE_Form_Section_HTML(
85
+							EEH_HTML::h2(esc_html__('reCAPTCHA Appearance', 'event_espresso'))
86
+						),
87
+						'appearance_settings'     => $this->appearanceSettings(),
88
+						'required_fields_note'    => new EE_Form_Section_HTML(
89
+							EEH_HTML::p(
90
+								esc_html__('All fields marked with a * are required fields', 'event_espresso'),
91
+								'',
92
+								'grey-text'
93
+							)
94
+						),
95
+					)
96
+				),
97
+			)
98
+		);
99
+	}
100 100
 
101 101
 
102
-    /**
103
-     * @return EE_Form_Section_Proper
104
-     * @throws EE_Error
105
-     */
106
-    protected function mainSettings()
107
-    {
108
-        return new EE_Form_Section_Proper(
109
-            array(
110
-                'name'            => 'recaptcha_settings_tbl',
111
-                'html_id'         => 'recaptcha_settings_tbl',
112
-                'html_class'      => 'form-table',
113
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
114
-                'subsections'     => apply_filters(
115
-                    'FHEE__EED_Recaptcha___recaptcha_main_settings__form_subsections',
116
-                    array(
117
-                        'use_captcha'          => new EE_Yes_No_Input(
118
-                            array(
119
-                                'html_label_text'         => esc_html__('Use reCAPTCHA', 'event_espresso'),
120
-                                'html_help_text'          => sprintf(
121
-                                    esc_html__(
122
-                                        'reCAPTCHA is a free service that  protects your website from spam and abuse. It employs advanced risk analysis technology to separate humans from abusive actors. Sign up %1$shere%2$s to receive your Public and Private keys.',
123
-                                        'event_espresso'
124
-                                    ),
125
-                                    '<a href="https://www.google.com/recaptcha/intro/index.html">',
126
-                                    '</a>'
127
-                                ),
128
-                                'default'                 => $this->config->use_captcha !== null
129
-                                    ? $this->config->use_captcha : false,
130
-                                'display_html_label_text' => false,
131
-                            )
132
-                        ),
133
-                        'recaptcha_publickey'  => new EE_Text_Input(
134
-                            array(
135
-                                'html_label_text' => esc_html__('Site Key', 'event_espresso'),
136
-                                'html_help_text'  => esc_html__(
137
-                                    'The site key is used to display the widget on your site.',
138
-                                    'event_espresso'
139
-                                ),
140
-                                'default'         => $this->config->recaptcha_publickey !== null
141
-                                    ? stripslashes($this->config->recaptcha_publickey) : '',
142
-                            )
143
-                        ),
144
-                        'recaptcha_privatekey' => new EE_Text_Input(
145
-                            array(
146
-                                'html_label_text' => esc_html__('Secret Key', 'event_espresso'),
147
-                                'html_help_text'  => esc_html__(
148
-                                    'The secret key authorizes communication between your application backend and the reCAPTCHA server to verify the user\'s response. The secret key needs to be kept safe for security purposes.',
149
-                                    'event_espresso'
150
-                                ),
151
-                                'default'         => $this->config->recaptcha_privatekey !== null
152
-                                    ? stripslashes($this->config->recaptcha_privatekey)
153
-                                    : '',
154
-                            )
155
-                        ),
156
-                        'recaptcha_protected_forms' => new EE_Checkbox_Multi_Input(
157
-                            array(
158
-                                'ticket_selector'   => esc_html__('Ticket Selector', 'event_espresso'),
159
-                                'registration_form' => esc_html__('Registration Form', 'event_espresso'),
160
-                            ),
161
-                            array(
162
-                                'html_label_text'         => esc_html__(
163
-                                    'Invisible reCAPTCHA Protection',
164
-                                    'event_espresso'
165
-                                ),
166
-                                'html_help_text'          => esc_html__(
167
-                                    'Select which Event Espresso forms you would like to enable Invisible reCAPTCHA on.',
168
-                                    'event_espresso'
169
-                                ),
170
-                                'default'                 => is_array($this->config->recaptcha_protected_forms)
171
-                                    ? $this->config->recaptcha_protected_forms
172
-                                    : array(),
173
-                                'display_html_label_text' => false,
174
-                            )
175
-                        ),
176
-                    )
177
-                ),
178
-            )
179
-        );
180
-    }
102
+	/**
103
+	 * @return EE_Form_Section_Proper
104
+	 * @throws EE_Error
105
+	 */
106
+	protected function mainSettings()
107
+	{
108
+		return new EE_Form_Section_Proper(
109
+			array(
110
+				'name'            => 'recaptcha_settings_tbl',
111
+				'html_id'         => 'recaptcha_settings_tbl',
112
+				'html_class'      => 'form-table',
113
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
114
+				'subsections'     => apply_filters(
115
+					'FHEE__EED_Recaptcha___recaptcha_main_settings__form_subsections',
116
+					array(
117
+						'use_captcha'          => new EE_Yes_No_Input(
118
+							array(
119
+								'html_label_text'         => esc_html__('Use reCAPTCHA', 'event_espresso'),
120
+								'html_help_text'          => sprintf(
121
+									esc_html__(
122
+										'reCAPTCHA is a free service that  protects your website from spam and abuse. It employs advanced risk analysis technology to separate humans from abusive actors. Sign up %1$shere%2$s to receive your Public and Private keys.',
123
+										'event_espresso'
124
+									),
125
+									'<a href="https://www.google.com/recaptcha/intro/index.html">',
126
+									'</a>'
127
+								),
128
+								'default'                 => $this->config->use_captcha !== null
129
+									? $this->config->use_captcha : false,
130
+								'display_html_label_text' => false,
131
+							)
132
+						),
133
+						'recaptcha_publickey'  => new EE_Text_Input(
134
+							array(
135
+								'html_label_text' => esc_html__('Site Key', 'event_espresso'),
136
+								'html_help_text'  => esc_html__(
137
+									'The site key is used to display the widget on your site.',
138
+									'event_espresso'
139
+								),
140
+								'default'         => $this->config->recaptcha_publickey !== null
141
+									? stripslashes($this->config->recaptcha_publickey) : '',
142
+							)
143
+						),
144
+						'recaptcha_privatekey' => new EE_Text_Input(
145
+							array(
146
+								'html_label_text' => esc_html__('Secret Key', 'event_espresso'),
147
+								'html_help_text'  => esc_html__(
148
+									'The secret key authorizes communication between your application backend and the reCAPTCHA server to verify the user\'s response. The secret key needs to be kept safe for security purposes.',
149
+									'event_espresso'
150
+								),
151
+								'default'         => $this->config->recaptcha_privatekey !== null
152
+									? stripslashes($this->config->recaptcha_privatekey)
153
+									: '',
154
+							)
155
+						),
156
+						'recaptcha_protected_forms' => new EE_Checkbox_Multi_Input(
157
+							array(
158
+								'ticket_selector'   => esc_html__('Ticket Selector', 'event_espresso'),
159
+								'registration_form' => esc_html__('Registration Form', 'event_espresso'),
160
+							),
161
+							array(
162
+								'html_label_text'         => esc_html__(
163
+									'Invisible reCAPTCHA Protection',
164
+									'event_espresso'
165
+								),
166
+								'html_help_text'          => esc_html__(
167
+									'Select which Event Espresso forms you would like to enable Invisible reCAPTCHA on.',
168
+									'event_espresso'
169
+								),
170
+								'default'                 => is_array($this->config->recaptcha_protected_forms)
171
+									? $this->config->recaptcha_protected_forms
172
+									: array(),
173
+								'display_html_label_text' => false,
174
+							)
175
+						),
176
+					)
177
+				),
178
+			)
179
+		);
180
+	}
181 181
 
182 182
 
183
-    /**
184
-     * @return EE_Form_Section_Proper
185
-     * @throws EE_Error
186
-     */
187
-    protected function appearanceSettings()
188
-    {
189
-        return new EE_Form_Section_Proper(
190
-            array(
191
-                'name'            => 'recaptcha_appearance_settings_tbl',
192
-                'html_id'         => 'recaptcha_appearance_settings_tbl',
193
-                'html_class'      => 'form-table',
194
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
195
-                'subsections'     => apply_filters(
196
-                    'FHEE__EED_Recaptcha___recaptcha_appearance_settings__form_subsections',
197
-                    array(
198
-                        'recaptcha_theme'    => new EE_Radio_Button_Input(
199
-                            array(
200
-                                'invisible' => esc_html__('Invisible', 'event_espresso'),
201
-                                'light'     => esc_html__('Light', 'event_espresso'),
202
-                                'dark'      => esc_html__('Dark', 'event_espresso'),
203
-                            ),
204
-                            array(
205
-                                'html_label_text'         => esc_html__('Theme', 'event_espresso'),
206
-                                'html_help_text'          => esc_html__(
207
-                                    'The color theme of the widget.',
208
-                                    'event_espresso'
209
-                                ),
210
-                                'default'                 => $this->config->recaptcha_theme !== null
211
-                                    ? $this->config->recaptcha_theme
212
-                                    : 'invisible',
213
-                                'display_html_label_text' => false,
214
-                            )
215
-                        ),
216
-                        'recaptcha_badge'     => new EE_Radio_Button_Input(
217
-                            array(
218
-                                'bottomleft' => esc_html__('Bottom Left', 'event_espresso'),
219
-                                'bottomright' => esc_html__('Bottom Right', 'event_espresso'),
220
-                                'inline' => esc_html__('Inline', 'event_espresso'),
221
-                            ),
222
-                            array(
223
-                                'html_label_text'         => esc_html__(
224
-                                    'Invisible reCAPTCHA Badge Position',
225
-                                    'event_espresso'
226
-                                ),
227
-                                'html_help_text'          => esc_html__(
228
-                                    'If using Invisible reCAPTCHA, then this determines the position of the reCAPTCHA badge. "Bottom Left" and "Bottom Right" both will float at the bottom of the screen. "Inline" appears beside the submit button but allows you to control the CSS.',
229
-                                    'event_espresso'
230
-                                ),
231
-                                'default'                 => $this->config->recaptcha_badge !== null
232
-                                    ? $this->config->recaptcha_badge
233
-                                    : 'bottomleft',
234
-                                'display_html_label_text' => false,
235
-                            )
236
-                        ),
237
-                        'recaptcha_type'     => new EE_Radio_Button_Input(
238
-                            array(
239
-                                'image' => esc_html__('Image', 'event_espresso'),
240
-                                'audio' => esc_html__('Audio', 'event_espresso'),
241
-                            ),
242
-                            array(
243
-                                'html_label_text'         => esc_html__('Type', 'event_espresso'),
244
-                                'html_help_text'          => esc_html__(
245
-                                    'The type of CAPTCHA to serve.',
246
-                                    'event_espresso'
247
-                                ),
248
-                                'default'                 => $this->config->recaptcha_type !== null
249
-                                    ? $this->config->recaptcha_type
250
-                                    : 'image',
251
-                                'display_html_label_text' => false,
252
-                            )
253
-                        ),
254
-                        'recaptcha_language' => new EE_Select_Input(
255
-                            array(
256
-                                'ar'     => esc_html__('Arabic', 'event_espresso'),
257
-                                'bg'     => esc_html__('Bulgarian', 'event_espresso'),
258
-                                'ca'     => esc_html__('Catalan', 'event_espresso'),
259
-                                'zh-CN'  => esc_html__('Chinese (Simplified)', 'event_espresso'),
260
-                                'zh-TW'  => esc_html__('Chinese (Traditional)	', 'event_espresso'),
261
-                                'hr'     => esc_html__('Croatian', 'event_espresso'),
262
-                                'cs'     => esc_html__('Czech', 'event_espresso'),
263
-                                'da'     => esc_html__('Danish', 'event_espresso'),
264
-                                'nl'     => esc_html__('Dutch', 'event_espresso'),
265
-                                'en-GB'  => esc_html__('English (UK)', 'event_espresso'),
266
-                                'en'     => esc_html__('English (US)', 'event_espresso'),
267
-                                'fil'    => esc_html__('Filipino', 'event_espresso'),
268
-                                'fi'     => esc_html__('Finnish', 'event_espresso'),
269
-                                'fr'     => esc_html__('French', 'event_espresso'),
270
-                                'fr-CA'  => esc_html__('French (Canadian)', 'event_espresso'),
271
-                                'de'     => esc_html__('German', 'event_espresso'),
272
-                                'de-AT'  => esc_html__('German (Austria)', 'event_espresso'),
273
-                                'de-CH'  => esc_html__('German (Switzerland)', 'event_espresso'),
274
-                                'el'     => esc_html__('Greek', 'event_espresso'),
275
-                                'iw'     => esc_html__('Hebrew', 'event_espresso'),
276
-                                'hi'     => esc_html__('Hindi', 'event_espresso'),
277
-                                'hu'     => esc_html__('Hungarian', 'event_espresso'),
278
-                                'id'     => esc_html__('Indonesian', 'event_espresso'),
279
-                                'it'     => esc_html__('Italian', 'event_espresso'),
280
-                                'ja'     => esc_html__('Japanese', 'event_espresso'),
281
-                                'ko'     => esc_html__('Korean', 'event_espresso'),
282
-                                'lv'     => esc_html__('Latvian', 'event_espresso'),
283
-                                'lt'     => esc_html__('Lithuanian', 'event_espresso'),
284
-                                'no'     => esc_html__('Norwegian', 'event_espresso'),
285
-                                'fa'     => esc_html__('Persian', 'event_espresso'),
286
-                                'pl'     => esc_html__('Polish', 'event_espresso'),
287
-                                'pt'     => esc_html__('Portuguese', 'event_espresso'),
288
-                                'pt-BR'  => esc_html__('Portuguese (Brazil)', 'event_espresso'),
289
-                                'pt-PT'  => esc_html__('Portuguese (Portugal)', 'event_espresso'),
290
-                                'ro'     => esc_html__('Romanian', 'event_espresso'),
291
-                                'ru'     => esc_html__('Russian', 'event_espresso'),
292
-                                'sr'     => esc_html__('Serbian', 'event_espresso'),
293
-                                'sk'     => esc_html__('Slovak', 'event_espresso'),
294
-                                'sl'     => esc_html__('Slovenian', 'event_espresso'),
295
-                                'es'     => esc_html__('Spanish', 'event_espresso'),
296
-                                'es-419' => esc_html__('Spanish (Latin America)', 'event_espresso'),
297
-                                'sv'     => esc_html__('Swedish', 'event_espresso'),
298
-                                'th'     => esc_html__('Thai', 'event_espresso'),
299
-                                'tr'     => esc_html__('Turkish', 'event_espresso'),
300
-                                'uk'     => esc_html__('Ukrainian', 'event_espresso'),
301
-                                'vi'     => esc_html__('Vietnamese', 'event_espresso'),
302
-                            ),
303
-                            array(
304
-                                'html_label_text' => esc_html__('Language', 'event_espresso'),
305
-                                'html_help_text'  => esc_html__(
306
-                                    'Forces the widget to render in a specific language.',
307
-                                    'event_espresso'
308
-                                ),
309
-                                'default'         => $this->config->recaptcha_language !== null
310
-                                    ? $this->config->recaptcha_language : 'en',
311
-                            )
312
-                        ),
313
-                    )
314
-                ),
315
-            )
316
-        );
317
-    }
183
+	/**
184
+	 * @return EE_Form_Section_Proper
185
+	 * @throws EE_Error
186
+	 */
187
+	protected function appearanceSettings()
188
+	{
189
+		return new EE_Form_Section_Proper(
190
+			array(
191
+				'name'            => 'recaptcha_appearance_settings_tbl',
192
+				'html_id'         => 'recaptcha_appearance_settings_tbl',
193
+				'html_class'      => 'form-table',
194
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
195
+				'subsections'     => apply_filters(
196
+					'FHEE__EED_Recaptcha___recaptcha_appearance_settings__form_subsections',
197
+					array(
198
+						'recaptcha_theme'    => new EE_Radio_Button_Input(
199
+							array(
200
+								'invisible' => esc_html__('Invisible', 'event_espresso'),
201
+								'light'     => esc_html__('Light', 'event_espresso'),
202
+								'dark'      => esc_html__('Dark', 'event_espresso'),
203
+							),
204
+							array(
205
+								'html_label_text'         => esc_html__('Theme', 'event_espresso'),
206
+								'html_help_text'          => esc_html__(
207
+									'The color theme of the widget.',
208
+									'event_espresso'
209
+								),
210
+								'default'                 => $this->config->recaptcha_theme !== null
211
+									? $this->config->recaptcha_theme
212
+									: 'invisible',
213
+								'display_html_label_text' => false,
214
+							)
215
+						),
216
+						'recaptcha_badge'     => new EE_Radio_Button_Input(
217
+							array(
218
+								'bottomleft' => esc_html__('Bottom Left', 'event_espresso'),
219
+								'bottomright' => esc_html__('Bottom Right', 'event_espresso'),
220
+								'inline' => esc_html__('Inline', 'event_espresso'),
221
+							),
222
+							array(
223
+								'html_label_text'         => esc_html__(
224
+									'Invisible reCAPTCHA Badge Position',
225
+									'event_espresso'
226
+								),
227
+								'html_help_text'          => esc_html__(
228
+									'If using Invisible reCAPTCHA, then this determines the position of the reCAPTCHA badge. "Bottom Left" and "Bottom Right" both will float at the bottom of the screen. "Inline" appears beside the submit button but allows you to control the CSS.',
229
+									'event_espresso'
230
+								),
231
+								'default'                 => $this->config->recaptcha_badge !== null
232
+									? $this->config->recaptcha_badge
233
+									: 'bottomleft',
234
+								'display_html_label_text' => false,
235
+							)
236
+						),
237
+						'recaptcha_type'     => new EE_Radio_Button_Input(
238
+							array(
239
+								'image' => esc_html__('Image', 'event_espresso'),
240
+								'audio' => esc_html__('Audio', 'event_espresso'),
241
+							),
242
+							array(
243
+								'html_label_text'         => esc_html__('Type', 'event_espresso'),
244
+								'html_help_text'          => esc_html__(
245
+									'The type of CAPTCHA to serve.',
246
+									'event_espresso'
247
+								),
248
+								'default'                 => $this->config->recaptcha_type !== null
249
+									? $this->config->recaptcha_type
250
+									: 'image',
251
+								'display_html_label_text' => false,
252
+							)
253
+						),
254
+						'recaptcha_language' => new EE_Select_Input(
255
+							array(
256
+								'ar'     => esc_html__('Arabic', 'event_espresso'),
257
+								'bg'     => esc_html__('Bulgarian', 'event_espresso'),
258
+								'ca'     => esc_html__('Catalan', 'event_espresso'),
259
+								'zh-CN'  => esc_html__('Chinese (Simplified)', 'event_espresso'),
260
+								'zh-TW'  => esc_html__('Chinese (Traditional)	', 'event_espresso'),
261
+								'hr'     => esc_html__('Croatian', 'event_espresso'),
262
+								'cs'     => esc_html__('Czech', 'event_espresso'),
263
+								'da'     => esc_html__('Danish', 'event_espresso'),
264
+								'nl'     => esc_html__('Dutch', 'event_espresso'),
265
+								'en-GB'  => esc_html__('English (UK)', 'event_espresso'),
266
+								'en'     => esc_html__('English (US)', 'event_espresso'),
267
+								'fil'    => esc_html__('Filipino', 'event_espresso'),
268
+								'fi'     => esc_html__('Finnish', 'event_espresso'),
269
+								'fr'     => esc_html__('French', 'event_espresso'),
270
+								'fr-CA'  => esc_html__('French (Canadian)', 'event_espresso'),
271
+								'de'     => esc_html__('German', 'event_espresso'),
272
+								'de-AT'  => esc_html__('German (Austria)', 'event_espresso'),
273
+								'de-CH'  => esc_html__('German (Switzerland)', 'event_espresso'),
274
+								'el'     => esc_html__('Greek', 'event_espresso'),
275
+								'iw'     => esc_html__('Hebrew', 'event_espresso'),
276
+								'hi'     => esc_html__('Hindi', 'event_espresso'),
277
+								'hu'     => esc_html__('Hungarian', 'event_espresso'),
278
+								'id'     => esc_html__('Indonesian', 'event_espresso'),
279
+								'it'     => esc_html__('Italian', 'event_espresso'),
280
+								'ja'     => esc_html__('Japanese', 'event_espresso'),
281
+								'ko'     => esc_html__('Korean', 'event_espresso'),
282
+								'lv'     => esc_html__('Latvian', 'event_espresso'),
283
+								'lt'     => esc_html__('Lithuanian', 'event_espresso'),
284
+								'no'     => esc_html__('Norwegian', 'event_espresso'),
285
+								'fa'     => esc_html__('Persian', 'event_espresso'),
286
+								'pl'     => esc_html__('Polish', 'event_espresso'),
287
+								'pt'     => esc_html__('Portuguese', 'event_espresso'),
288
+								'pt-BR'  => esc_html__('Portuguese (Brazil)', 'event_espresso'),
289
+								'pt-PT'  => esc_html__('Portuguese (Portugal)', 'event_espresso'),
290
+								'ro'     => esc_html__('Romanian', 'event_espresso'),
291
+								'ru'     => esc_html__('Russian', 'event_espresso'),
292
+								'sr'     => esc_html__('Serbian', 'event_espresso'),
293
+								'sk'     => esc_html__('Slovak', 'event_espresso'),
294
+								'sl'     => esc_html__('Slovenian', 'event_espresso'),
295
+								'es'     => esc_html__('Spanish', 'event_espresso'),
296
+								'es-419' => esc_html__('Spanish (Latin America)', 'event_espresso'),
297
+								'sv'     => esc_html__('Swedish', 'event_espresso'),
298
+								'th'     => esc_html__('Thai', 'event_espresso'),
299
+								'tr'     => esc_html__('Turkish', 'event_espresso'),
300
+								'uk'     => esc_html__('Ukrainian', 'event_espresso'),
301
+								'vi'     => esc_html__('Vietnamese', 'event_espresso'),
302
+							),
303
+							array(
304
+								'html_label_text' => esc_html__('Language', 'event_espresso'),
305
+								'html_help_text'  => esc_html__(
306
+									'Forces the widget to render in a specific language.',
307
+									'event_espresso'
308
+								),
309
+								'default'         => $this->config->recaptcha_language !== null
310
+									? $this->config->recaptcha_language : 'en',
311
+							)
312
+						),
313
+					)
314
+				),
315
+			)
316
+		);
317
+	}
318 318
 
319 319
 
320
-    /**
321
-     * @param EE_Registration_Config $EE_Registration_Config
322
-     * @return EE_Registration_Config
323
-     * @throws InvalidArgumentException
324
-     * @throws InvalidInterfaceException
325
-     * @throws InvalidDataTypeException
326
-     * @throws EE_Error
327
-     * @throws ReflectionException
328
-     */
329
-    public function updateAdminSettings(EE_Registration_Config $EE_Registration_Config)
330
-    {
331
-        try {
332
-            $recaptcha_settings_form = $this->settingsForm();
333
-            // if not displaying a form, then check for form submission
334
-            if ($recaptcha_settings_form->was_submitted()) {
335
-                // capture form data
336
-                $recaptcha_settings_form->receive_form_submission();
337
-                // validate form data
338
-                if ($recaptcha_settings_form->is_valid()) {
339
-                    // grab validated data from form
340
-                    $valid_data = $recaptcha_settings_form->valid_data();
341
-                    // user proofing recaptcha:  If Use reCAPTCHA is set to yes but we dont' have site or secret keys then set Use reCAPTCHA to FALSE and give error message.
342
-                    if (
343
-                        $valid_data['main_settings']['use_captcha']
344
-                        && (
345
-                            ! $EE_Registration_Config->use_captcha
346
-                            && (
347
-                                empty($valid_data['main_settings']['recaptcha_publickey'])
348
-                                || empty($valid_data['main_settings']['recaptcha_privatekey'])
349
-                            )
350
-                        )
351
-                        && apply_filters(
352
-                            'FHEE__Extend_Registration_Form_Admin_Page__check_for_recaptcha_keys',
353
-                            true,
354
-                            $EE_Registration_Config
355
-                        )
356
-                    ) {
357
-                        $valid_data['main_settings']['use_captcha'] = false;
358
-                        EE_Error::add_error(
359
-                            esc_html__(
360
-                                'The use reCAPTCHA setting has been reset to "no". In order to enable the reCAPTCHA service, you must enter a Site Key and Secret Key.',
361
-                                'event_espresso'
362
-                            ),
363
-                            __FILE__,
364
-                            __FUNCTION__,
365
-                            __LINE__
366
-                        );
367
-                    }
368
-                    $EE_Registration_Config->use_captcha          = $valid_data['main_settings']['use_captcha'];
369
-                    $EE_Registration_Config->recaptcha_publickey  = $valid_data['main_settings']['recaptcha_publickey'];
370
-                    $EE_Registration_Config->recaptcha_protected_forms = $valid_data['main_settings']['recaptcha_protected_forms'];
371
-                    $EE_Registration_Config->recaptcha_privatekey = $valid_data['main_settings']['recaptcha_privatekey'];
372
-                    $EE_Registration_Config->recaptcha_type       = $valid_data['appearance_settings']['recaptcha_type'];
373
-                    $EE_Registration_Config->recaptcha_theme      = $valid_data['appearance_settings']['recaptcha_theme'];
374
-                    $EE_Registration_Config->recaptcha_badge      = $valid_data['appearance_settings']['recaptcha_badge'];
375
-                    $EE_Registration_Config->recaptcha_language   = $valid_data['appearance_settings']['recaptcha_language'];
376
-                } else {
377
-                    if ($recaptcha_settings_form->submission_error_message() !== '') {
378
-                        EE_Error::add_error(
379
-                            $recaptcha_settings_form->submission_error_message(),
380
-                            __FILE__,
381
-                            __FUNCTION__,
382
-                            __LINE__
383
-                        );
384
-                    }
385
-                }
386
-            }
387
-        } catch (EE_Error $e) {
388
-            $e->get_error();
389
-        }
390
-        return $EE_Registration_Config;
391
-    }
320
+	/**
321
+	 * @param EE_Registration_Config $EE_Registration_Config
322
+	 * @return EE_Registration_Config
323
+	 * @throws InvalidArgumentException
324
+	 * @throws InvalidInterfaceException
325
+	 * @throws InvalidDataTypeException
326
+	 * @throws EE_Error
327
+	 * @throws ReflectionException
328
+	 */
329
+	public function updateAdminSettings(EE_Registration_Config $EE_Registration_Config)
330
+	{
331
+		try {
332
+			$recaptcha_settings_form = $this->settingsForm();
333
+			// if not displaying a form, then check for form submission
334
+			if ($recaptcha_settings_form->was_submitted()) {
335
+				// capture form data
336
+				$recaptcha_settings_form->receive_form_submission();
337
+				// validate form data
338
+				if ($recaptcha_settings_form->is_valid()) {
339
+					// grab validated data from form
340
+					$valid_data = $recaptcha_settings_form->valid_data();
341
+					// user proofing recaptcha:  If Use reCAPTCHA is set to yes but we dont' have site or secret keys then set Use reCAPTCHA to FALSE and give error message.
342
+					if (
343
+						$valid_data['main_settings']['use_captcha']
344
+						&& (
345
+							! $EE_Registration_Config->use_captcha
346
+							&& (
347
+								empty($valid_data['main_settings']['recaptcha_publickey'])
348
+								|| empty($valid_data['main_settings']['recaptcha_privatekey'])
349
+							)
350
+						)
351
+						&& apply_filters(
352
+							'FHEE__Extend_Registration_Form_Admin_Page__check_for_recaptcha_keys',
353
+							true,
354
+							$EE_Registration_Config
355
+						)
356
+					) {
357
+						$valid_data['main_settings']['use_captcha'] = false;
358
+						EE_Error::add_error(
359
+							esc_html__(
360
+								'The use reCAPTCHA setting has been reset to "no". In order to enable the reCAPTCHA service, you must enter a Site Key and Secret Key.',
361
+								'event_espresso'
362
+							),
363
+							__FILE__,
364
+							__FUNCTION__,
365
+							__LINE__
366
+						);
367
+					}
368
+					$EE_Registration_Config->use_captcha          = $valid_data['main_settings']['use_captcha'];
369
+					$EE_Registration_Config->recaptcha_publickey  = $valid_data['main_settings']['recaptcha_publickey'];
370
+					$EE_Registration_Config->recaptcha_protected_forms = $valid_data['main_settings']['recaptcha_protected_forms'];
371
+					$EE_Registration_Config->recaptcha_privatekey = $valid_data['main_settings']['recaptcha_privatekey'];
372
+					$EE_Registration_Config->recaptcha_type       = $valid_data['appearance_settings']['recaptcha_type'];
373
+					$EE_Registration_Config->recaptcha_theme      = $valid_data['appearance_settings']['recaptcha_theme'];
374
+					$EE_Registration_Config->recaptcha_badge      = $valid_data['appearance_settings']['recaptcha_badge'];
375
+					$EE_Registration_Config->recaptcha_language   = $valid_data['appearance_settings']['recaptcha_language'];
376
+				} else {
377
+					if ($recaptcha_settings_form->submission_error_message() !== '') {
378
+						EE_Error::add_error(
379
+							$recaptcha_settings_form->submission_error_message(),
380
+							__FILE__,
381
+							__FUNCTION__,
382
+							__LINE__
383
+						);
384
+					}
385
+				}
386
+			}
387
+		} catch (EE_Error $e) {
388
+			$e->get_error();
389
+		}
390
+		return $EE_Registration_Config;
391
+	}
392 392
 }
Please login to merge, or discard this patch.
modules/events_archive/EED_Events_Archive.module.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -123,8 +123,8 @@  discard block
 block discarded – undo
123 123
      */
124 124
     public static function set_definitions()
125 125
     {
126
-        define('EVENTS_ARCHIVE_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/');
127
-        define('EVENTS_ARCHIVE_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/');
126
+        define('EVENTS_ARCHIVE_ASSETS_URL', plugin_dir_url(__FILE__).'assets/');
127
+        define('EVENTS_ARCHIVE_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)).'templates/');
128 128
     }
129 129
 
130 130
 
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
      */
145 145
     public static function get_iframe_embed_button()
146 146
     {
147
-        if (! self::$_iframe_embed_button instanceof EventListIframeEmbedButton) {
147
+        if ( ! self::$_iframe_embed_button instanceof EventListIframeEmbedButton) {
148 148
             self::$_iframe_embed_button = new EventListIframeEmbedButton();
149 149
         }
150 150
         return self::$_iframe_embed_button;
@@ -228,10 +228,10 @@  discard block
 block discarded – undo
228 228
         EEH_Event_Query::add_query_filters();
229 229
         // set params that will get used by the filters
230 230
         EEH_Event_Query::set_query_params(
231
-            '',    // month
232
-            '',    // category
233
-            $config->display_expired_events,    // show_expired
234
-            'start_date',    // orderby
231
+            '', // month
232
+            '', // category
233
+            $config->display_expired_events, // show_expired
234
+            'start_date', // orderby
235 235
             'ASC'    // sort
236 236
         );
237 237
         // check what template is loaded
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
     public function template_include($template = '')
298 298
     {
299 299
         // don't add content filter for dedicated EE child themes or private posts
300
-        if (! EEH_Template::is_espresso_theme()) {
300
+        if ( ! EEH_Template::is_espresso_theme()) {
301 301
             /** @type EE_Events_Archive_Config $config */
302 302
             $config = $this->config();
303 303
             // add status banner ?
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
     {
397 397
         global $post;
398 398
         if ($post instanceof WP_Post) {
399
-            return in_the_loop() && $post->ID == $id ? espresso_event_status_banner($post->ID) . $title : $title;
399
+            return in_the_loop() && $post->ID == $id ? espresso_event_status_banner($post->ID).$title : $title;
400 400
         }
401 401
         return $title;
402 402
     }
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
         if (post_password_required()) {
548 548
             return $content;
549 549
         }
550
-        return EEH_Template::locate_template('content-espresso_events-datetimes.php') . $content;
550
+        return EEH_Template::locate_template('content-espresso_events-datetimes.php').$content;
551 551
     }
552 552
 
553 553
 
@@ -563,7 +563,7 @@  discard block
 block discarded – undo
563 563
         if (post_password_required()) {
564 564
             return $content;
565 565
         }
566
-        return EEH_Template::locate_template('content-espresso_events-tickets.php') . $content;
566
+        return EEH_Template::locate_template('content-espresso_events-tickets.php').$content;
567 567
     }
568 568
 
569 569
 
@@ -592,7 +592,7 @@  discard block
 block discarded – undo
592 592
         if (post_password_required()) {
593 593
             return $content;
594 594
         }
595
-        return $content . EEH_Template::locate_template('content-espresso_events-venues.php');
595
+        return $content.EEH_Template::locate_template('content-espresso_events-venues.php');
596 596
     }
597 597
 
598 598
 
@@ -777,10 +777,10 @@  discard block
 block discarded – undo
777 777
         // get some style
778 778
         if (apply_filters('FHEE_enable_default_espresso_css', false)) {
779 779
             // first check uploads folder
780
-            if (EEH_File::is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) {
780
+            if (EEH_File::is_readable(get_stylesheet_directory().$this->theme.'/style.css')) {
781 781
                 wp_register_style(
782 782
                     $this->theme,
783
-                    get_stylesheet_directory_uri() . $this->theme . '/style.css',
783
+                    get_stylesheet_directory_uri().$this->theme.'/style.css',
784 784
                     array('dashicons', 'espresso_default')
785 785
                 );
786 786
             } else {
@@ -819,7 +819,7 @@  discard block
 block discarded – undo
819 819
             (array) $template_settings->EED_Events_Archive
820 820
         );
821 821
         EEH_Template::display_template(
822
-            EVENTS_ARCHIVE_TEMPLATES_PATH . 'admin-event-list-settings.template.php',
822
+            EVENTS_ARCHIVE_TEMPLATES_PATH.'admin-event-list-settings.template.php',
823 823
             $events_archive_settings
824 824
         );
825 825
     }
Please login to merge, or discard this patch.
Indentation   +1102 added lines, -1102 removed lines patch added patch discarded remove patch
@@ -16,1097 +16,1097 @@  discard block
 block discarded – undo
16 16
 class EED_Events_Archive extends EED_Module
17 17
 {
18 18
 
19
-    const EVENT_DETAILS_PRIORITY = 100;
20
-
21
-    const EVENT_DATETIMES_PRIORITY = 110;
22
-
23
-    const EVENT_TICKETS_PRIORITY = 120;
24
-
25
-    const EVENT_VENUES_PRIORITY = 130;
26
-
27
-
28
-    public static $espresso_event_list_ID = 0;
29
-
30
-    public static $espresso_grid_event_lists = array();
31
-
32
-    /**
33
-     * @type bool $using_get_the_excerpt
34
-     */
35
-    protected static $using_get_the_excerpt = false;
36
-
37
-    /**
38
-     * Used to flag when the event list is being called from an external iframe.
39
-     *
40
-     * @var bool $iframe
41
-     */
42
-    protected static $iframe = false;
43
-
44
-    /**
45
-     * @var EventListIframeEmbedButton $_iframe_embed_button
46
-     */
47
-    private static $_iframe_embed_button;
48
-
49
-    /**
50
-     * @type EE_Template_Part_Manager $template_parts
51
-     */
52
-    protected $template_parts;
53
-
54
-
55
-    /**
56
-     * @return EED_Events_Archive
57
-     */
58
-    public static function instance()
59
-    {
60
-        return parent::get_instance(__CLASS__);
61
-    }
62
-
63
-
64
-    /**
65
-     * set_hooks - for hooking into EE Core, other modules, etc
66
-     *
67
-     * @return void
68
-     * @throws InvalidArgumentException
69
-     * @throws InvalidDataTypeException
70
-     * @throws InvalidInterfaceException
71
-     */
72
-    public static function set_hooks()
73
-    {
74
-        /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_type_definitions */
75
-        $custom_post_type_definitions = LoaderFactory::getLoader()->getShared(
76
-            'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
77
-        );
78
-        $custom_post_types = $custom_post_type_definitions->getDefinitions();
79
-        EE_Config::register_route(
80
-            $custom_post_types['espresso_events']['plural_slug'],
81
-            'Events_Archive',
82
-            'run'
83
-        );
84
-        EE_Config::register_route(
85
-            'event_list',
86
-            'Events_Archive',
87
-            'event_list'
88
-        );
89
-        EE_Config::register_route(
90
-            'iframe',
91
-            'Events_Archive',
92
-            'event_list_iframe',
93
-            'event_list'
94
-        );
95
-        add_action('wp_loaded', array('EED_Events_Archive', 'set_definitions'), 2);
96
-    }
97
-
98
-
99
-    /**
100
-     *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
101
-     *
102
-     * @access    public
103
-     * @return    void
104
-     */
105
-    public static function set_hooks_admin()
106
-    {
107
-        add_action('wp_loaded', array('EED_Events_Archive', 'set_definitions'), 2);
108
-        // hook into the end of the \EE_Admin_Page::_load_page_dependencies()
109
-        // to load assets for "espresso_events" page on the "default" route (action)
110
-        add_action(
111
-            'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_events__default',
112
-            array('EED_Events_Archive', 'event_list_iframe_embed_button'),
113
-            10
114
-        );
115
-    }
116
-
117
-
118
-    /**
119
-     *    set_definitions
120
-     *
121
-     * @access    public
122
-     * @return    void
123
-     */
124
-    public static function set_definitions()
125
-    {
126
-        define('EVENTS_ARCHIVE_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/');
127
-        define('EVENTS_ARCHIVE_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/');
128
-    }
129
-
130
-
131
-    /**
132
-     * set up EE_Events_Archive_Config
133
-     */
134
-    protected function set_config()
135
-    {
136
-        $this->set_config_section('template_settings');
137
-        $this->set_config_class('EE_Events_Archive_Config');
138
-        $this->set_config_name('EED_Events_Archive');
139
-    }
140
-
141
-
142
-    /**
143
-     * @return EventListIframeEmbedButton
144
-     */
145
-    public static function get_iframe_embed_button()
146
-    {
147
-        if (! self::$_iframe_embed_button instanceof EventListIframeEmbedButton) {
148
-            self::$_iframe_embed_button = new EventListIframeEmbedButton();
149
-        }
150
-        return self::$_iframe_embed_button;
151
-    }
152
-
153
-
154
-    /**
155
-     * event_list_iframe_embed_button
156
-     *
157
-     * @return    void
158
-     * @throws EE_Error
159
-     */
160
-    public static function event_list_iframe_embed_button()
161
-    {
162
-        $iframe_embed_button = EED_Events_Archive::get_iframe_embed_button();
163
-        $iframe_embed_button->addEmbedButton();
164
-    }
165
-
166
-
167
-    /**
168
-     *    initialize_template_parts
169
-     *
170
-     * @access    public
171
-     * @param EE_Events_Archive_Config $config
172
-     * @return EE_Template_Part_Manager
173
-     */
174
-    public function initialize_template_parts(EE_Events_Archive_Config $config = null)
175
-    {
176
-        $config = $config instanceof EE_Events_Archive_Config ? $config : $this->config();
177
-        EEH_Autoloader::instance()->register_template_part_autoloaders();
178
-        $template_parts = new EE_Template_Part_Manager();
179
-        $template_parts->add_template_part(
180
-            'tickets',
181
-            esc_html__('Ticket Selector', 'event_espresso'),
182
-            'content-espresso_events-tickets.php',
183
-            $config->display_order_tickets
184
-        );
185
-        $template_parts->add_template_part(
186
-            'datetimes',
187
-            esc_html__('Dates and Times', 'event_espresso'),
188
-            'content-espresso_events-datetimes.php',
189
-            $config->display_order_datetimes
190
-        );
191
-        $template_parts->add_template_part(
192
-            'event',
193
-            esc_html__('Event Description', 'event_espresso'),
194
-            'content-espresso_events-details.php',
195
-            $config->display_order_event
196
-        );
197
-        $template_parts->add_template_part(
198
-            'venue',
199
-            esc_html__('Venue Information', 'event_espresso'),
200
-            'content-espresso_events-venues.php',
201
-            $config->display_order_venue
202
-        );
203
-        do_action('AHEE__EED_Event_Archive__initialize_template_parts', $template_parts);
204
-        return $template_parts;
205
-    }
206
-
207
-
208
-    /**
209
-     *    run - initial module setup - this gets called by the EE_Front_Controller if the module route is found in the
210
-     *    incoming request
211
-     *
212
-     * @access    public
213
-     * @param WP $WP
214
-     * @return    void
215
-     */
216
-    public function run($WP)
217
-    {
218
-        do_action('AHEE__EED_Events_Archive__before_run');
219
-        // ensure valid EE_Events_Archive_Config() object exists
220
-        $this->set_config();
221
-        /** @type EE_Events_Archive_Config $config */
222
-        $config = $this->config();
223
-        // load other required components
224
-        $this->load_event_list_assets();
225
-        // filter the WP posts_join, posts_where, and posts_orderby SQL clauses
226
-        // add query filters
227
-        EEH_Event_Query::add_query_filters();
228
-        // set params that will get used by the filters
229
-        EEH_Event_Query::set_query_params(
230
-            '',    // month
231
-            '',    // category
232
-            $config->display_expired_events,    // show_expired
233
-            'start_date',    // orderby
234
-            'ASC'    // sort
235
-        );
236
-        // check what template is loaded
237
-        add_filter('template_include', array($this, 'template_include'), 999, 1);
238
-    }
239
-
240
-
241
-    /**
242
-     * most likely called by the ESPRESSO_EVENTS shortcode which uses this module to do some of it's lifting
243
-     *
244
-     * @return    void
245
-     */
246
-    public function event_list()
247
-    {
248
-        // ensure valid EE_Events_Archive_Config() object exists
249
-        $this->set_config();
250
-        // load other required components
251
-        $this->load_event_list_assets();
252
-    }
253
-
254
-
255
-    /**
256
-     * @access    public
257
-     * @return    void
258
-     * @throws EE_Error
259
-     * @throws DomainException
260
-     */
261
-    public function event_list_iframe()
262
-    {
263
-        EED_Events_Archive::$iframe = true;
264
-        $event_list_iframe          = new EventsArchiveIframe($this);
265
-        $event_list_iframe->display();
266
-    }
267
-
268
-
269
-    /**
270
-     * @access public
271
-     * @return string
272
-     */
273
-    public static function is_iframe()
274
-    {
275
-        return EED_Events_Archive::$iframe;
276
-    }
277
-
278
-
279
-    /**
280
-     * @access public
281
-     * @return string
282
-     */
283
-    public static function link_target()
284
-    {
285
-        return EED_Events_Archive::$iframe ? ' target="_blank"' : '';
286
-    }
287
-
288
-
289
-    /**
290
-     *    template_include
291
-     *
292
-     * @access    public
293
-     * @param string $template
294
-     * @return    string
295
-     */
296
-    public function template_include($template = '')
297
-    {
298
-        // don't add content filter for dedicated EE child themes or private posts
299
-        if (! EEH_Template::is_espresso_theme()) {
300
-            /** @type EE_Events_Archive_Config $config */
301
-            $config = $this->config();
302
-            // add status banner ?
303
-            if ($config->display_status_banner) {
304
-                add_filter('the_title', array('EED_Events_Archive', 'the_title'), 100, 2);
305
-            }
306
-            // if NOT a custom template
307
-            if (
308
-                apply_filters('FHEE__EED_Event_Archive__template_include__allow_custom_selected_template', false)
309
-                || EE_Registry::instance()
310
-                              ->load_core('Front_Controller')
311
-                              ->get_selected_template() !== 'archive-espresso_events.php'
312
-            ) {
313
-                // don't display entry meta because the existing theme will take care of that
314
-                add_filter('FHEE__EED_Events_Archive__template_include__events_list_active', '__return_true');
315
-                // load functions.php file for the theme (loaded by WP if using child theme)
316
-                EEH_Template::load_espresso_theme_functions();
317
-                // because we don't know if the theme is using the_excerpt()
318
-                add_filter(
319
-                    'the_excerpt',
320
-                    array('EED_Events_Archive', 'event_details'),
321
-                    EED_Events_Archive::EVENT_DETAILS_PRIORITY
322
-                );
323
-                // or the_content
324
-                add_filter(
325
-                    'the_content',
326
-                    array('EED_Events_Archive', 'event_details'),
327
-                    EED_Events_Archive::EVENT_DETAILS_PRIORITY
328
-                );
329
-                // and just in case they are running get_the_excerpt() which DESTROYS things
330
-                add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1);
331
-                // don't display entry meta because the existing theme will take care of that
332
-                add_filter('FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false');
333
-            }
334
-        }
335
-        return $template;
336
-    }
337
-
338
-
339
-    /**
340
-     *    get_the_excerpt - kinda hacky, but if a theme is using get_the_excerpt(), then we need to remove our filters
341
-     *    on the_content()
342
-     *
343
-     * @access    public
344
-     * @param        string $excerpt
345
-     * @return        string
346
-     */
347
-    public static function get_the_excerpt($excerpt = '')
348
-    {
349
-        if (post_password_required()) {
350
-            return $excerpt;
351
-        }
352
-        if (apply_filters('FHEE__EED_Events_Archive__get_the_excerpt__theme_uses_get_the_excerpt', false)) {
353
-            remove_filter(
354
-                'the_excerpt',
355
-                array('EED_Events_Archive', 'event_details'),
356
-                EED_Events_Archive::EVENT_DETAILS_PRIORITY
357
-            );
358
-            remove_filter(
359
-                'the_content',
360
-                array('EED_Events_Archive', 'event_details'),
361
-                EED_Events_Archive::EVENT_DETAILS_PRIORITY
362
-            );
363
-            $excerpt = EED_Events_Archive::event_details($excerpt);
364
-        } else {
365
-            EED_Events_Archive::$using_get_the_excerpt = true;
366
-            add_filter('wp_trim_excerpt', array('EED_Events_Archive', 'end_get_the_excerpt'), 999, 1);
367
-        }
368
-        return $excerpt;
369
-    }
370
-
371
-
372
-    /**
373
-     * end_get_the_excerpt
374
-     *
375
-     * @access public
376
-     * @param  string $text
377
-     * @return string
378
-     */
379
-    public static function end_get_the_excerpt($text = '')
380
-    {
381
-        EED_Events_Archive::$using_get_the_excerpt = false;
382
-        return $text;
383
-    }
384
-
385
-
386
-    /**
387
-     *    the_title
388
-     *
389
-     * @access        public
390
-     * @param        string $title
391
-     * @param        string $id
392
-     * @return        string
393
-     */
394
-    public static function the_title($title = '', $id = '')
395
-    {
396
-        global $post;
397
-        if ($post instanceof WP_Post) {
398
-            return in_the_loop() && $post->ID == $id ? espresso_event_status_banner($post->ID) . $title : $title;
399
-        }
400
-        return $title;
401
-    }
402
-
403
-
404
-    /**
405
-     *    event_details
406
-     *
407
-     * @access    public
408
-     * @param        string $content
409
-     * @return        string
410
-     */
411
-    public static function event_details($content)
412
-    {
413
-        global $post;
414
-        static $current_post_ID = 0;
415
-        if (
416
-            $current_post_ID !== $post->ID
417
-            && $post->post_type === 'espresso_events'
418
-            && ! EED_Events_Archive::$using_get_the_excerpt
419
-            && ! post_password_required()
420
-            && (
421
-                apply_filters('FHEE__EES_Espresso_Events__process_shortcode__true', false)
422
-                || ! apply_filters('FHEE__content_espresso_events__template_loaded', false)
423
-            )
424
-        ) {
425
-            // Set current post ID to prevent showing content twice, but only if headers have definitely been sent.
426
-            // Reason being is that some plugins, like Yoast, need to run through a copy of the loop early
427
-            // BEFORE headers are sent in order to examine the post content and generate content for the HTML header.
428
-            // We want to allow those plugins to still do their thing and have access to our content, but depending on
429
-            // how your event content is being displayed (shortcode, CPT route, etc), this filter can get applied twice,
430
-            // so the following allows this filter to be applied multiple times, but only once for real
431
-            $current_post_ID = did_action('loop_start') ? $post->ID : 0;
432
-            if (EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->use_sortable_display_order) {
433
-                $content = EED_Events_Archive::use_sortable_display_order();
434
-            } else {
435
-                $content = EED_Events_Archive::use_filterable_display_order();
436
-            }
437
-        }
438
-        return $content;
439
-    }
440
-
441
-
442
-    /**
443
-     *    use_sortable_display_order
444
-     *
445
-     * @access    protected
446
-     * @return string
447
-     */
448
-    protected static function use_sortable_display_order()
449
-    {
450
-        // no further password checks required atm
451
-        add_filter('FHEE__EED_Events_Archive__event_details__no_post_password_required', '__return_true');
452
-        // we need to first remove this callback from being applied to the_content() or the_excerpt()
453
-        // (otherwise it will recurse and blow up the interweb)
454
-        remove_filter(
455
-            'the_excerpt',
456
-            array('EED_Events_Archive', 'event_details'),
457
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
458
-        );
459
-        remove_filter(
460
-            'the_content',
461
-            array('EED_Events_Archive', 'event_details'),
462
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
463
-        );
464
-        remove_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1);
465
-        // now add additional content depending on whether event is using the_excerpt() or the_content()
466
-        EED_Events_Archive::instance()->template_parts = EED_Events_Archive::instance()->initialize_template_parts();
467
-        $content = EEH_Template::locate_template('content-espresso_events-details.php');
468
-        $content = EED_Events_Archive::instance()->template_parts->apply_template_part_filters($content);
469
-        // re-add our main filters (or else the next event won't have them)
470
-        add_filter(
471
-            'the_excerpt',
472
-            array('EED_Events_Archive', 'event_details'),
473
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
474
-        );
475
-        add_filter(
476
-            'the_content',
477
-            array('EED_Events_Archive', 'event_details'),
478
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
479
-        );
480
-        add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1);
481
-        remove_filter(
482
-            'FHEE__EED_Events_Archive__event_details__no_post_password_required',
483
-            '__return_true'
484
-        );
485
-        return $content;
486
-    }
487
-
488
-
489
-    /**
490
-     *    use_filterable_display_order
491
-     *
492
-     * @access    protected
493
-     * @return    string
494
-     */
495
-    protected static function use_filterable_display_order()
496
-    {
497
-        // we need to first remove this callback from being applied to the_content()
498
-        // (otherwise it will recurse and blow up the interweb)
499
-        remove_filter(
500
-            'the_excerpt',
501
-            array('EED_Events_Archive', 'event_details'),
502
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
503
-        );
504
-        remove_filter(
505
-            'the_content',
506
-            array('EED_Events_Archive', 'event_details'),
507
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
508
-        );
509
-        remove_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1);
510
-        // now add additional content depending on whether event is using the_excerpt() or the_content()
511
-        EED_Events_Archive::_add_additional_excerpt_filters();
512
-        EED_Events_Archive::_add_additional_content_filters();
513
-        do_action('AHEE__EED_Events_Archive__use_filterable_display_order__after_add_filters');
514
-        // now load our template
515
-        $content = EEH_Template::locate_template('content-espresso_events-details.php');
516
-        // re-add our main filters (or else the next event won't have them)
517
-        add_filter(
518
-            'the_excerpt',
519
-            array('EED_Events_Archive', 'event_details'),
520
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
521
-        );
522
-        add_filter(
523
-            'the_content',
524
-            array('EED_Events_Archive', 'event_details'),
525
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
526
-        );
527
-        add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1);
528
-        // but remove the other filters so that they don't get applied to the next post
529
-        EED_Events_Archive::_remove_additional_events_archive_filters();
530
-        do_action('AHEE__EED_Events_Archive__use_filterable_display_order__after_remove_filters');
531
-        // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt)
532
-        // return ! empty( $template ) ? $template : $content;
533
-        return $content;
534
-    }
535
-
536
-
537
-    /**
538
-     *    event_datetimes - adds datetimes ABOVE content
539
-     *
540
-     * @access    public
541
-     * @param        string $content
542
-     * @return        string
543
-     */
544
-    public static function event_datetimes($content)
545
-    {
546
-        if (post_password_required()) {
547
-            return $content;
548
-        }
549
-        return EEH_Template::locate_template('content-espresso_events-datetimes.php') . $content;
550
-    }
551
-
552
-
553
-    /**
554
-     *    event_tickets - adds tickets ABOVE content (which includes datetimes)
555
-     *
556
-     * @access    public
557
-     * @param        string $content
558
-     * @return        string
559
-     */
560
-    public static function event_tickets($content)
561
-    {
562
-        if (post_password_required()) {
563
-            return $content;
564
-        }
565
-        return EEH_Template::locate_template('content-espresso_events-tickets.php') . $content;
566
-    }
567
-
568
-
569
-    /**
570
-     *    event_venues - adds venues BELOW content
571
-     *
572
-     * @access    public
573
-     * @param    string $content
574
-     * @return    string
575
-     */
576
-    public static function event_venue($content)
577
-    {
578
-        return EED_Events_Archive::event_venues($content);
579
-    }
580
-
581
-
582
-    /**
583
-     *    event_venues - adds venues BELOW content
584
-     *
585
-     * @access    public
586
-     * @param        string $content
587
-     * @return        string
588
-     */
589
-    public static function event_venues($content)
590
-    {
591
-        if (post_password_required()) {
592
-            return $content;
593
-        }
594
-        return $content . EEH_Template::locate_template('content-espresso_events-venues.php');
595
-    }
596
-
597
-
598
-    /**
599
-     *    _add_additional_content_filters
600
-     *
601
-     * @access    private
602
-     * @return        void
603
-     */
604
-    private static function _add_additional_excerpt_filters()
605
-    {
606
-        add_filter(
607
-            'the_excerpt',
608
-            array('EED_Events_Archive', 'event_datetimes'),
609
-            EED_Events_Archive::EVENT_DATETIMES_PRIORITY
610
-        );
611
-        add_filter(
612
-            'the_excerpt',
613
-            array('EED_Events_Archive', 'event_tickets'),
614
-            EED_Events_Archive::EVENT_TICKETS_PRIORITY
615
-        );
616
-        add_filter(
617
-            'the_excerpt',
618
-            array('EED_Events_Archive', 'event_venues'),
619
-            EED_Events_Archive::EVENT_VENUES_PRIORITY
620
-        );
621
-    }
622
-
623
-
624
-    /**
625
-     *    _add_additional_content_filters
626
-     *
627
-     * @access    private
628
-     * @return        void
629
-     */
630
-    private static function _add_additional_content_filters()
631
-    {
632
-        add_filter(
633
-            'the_content',
634
-            array('EED_Events_Archive', 'event_datetimes'),
635
-            EED_Events_Archive::EVENT_DATETIMES_PRIORITY
636
-        );
637
-        add_filter(
638
-            'the_content',
639
-            array('EED_Events_Archive', 'event_tickets'),
640
-            EED_Events_Archive::EVENT_TICKETS_PRIORITY
641
-        );
642
-        add_filter(
643
-            'the_content',
644
-            array('EED_Events_Archive', 'event_venues'),
645
-            EED_Events_Archive::EVENT_VENUES_PRIORITY
646
-        );
647
-    }
648
-
649
-
650
-    /**
651
-     *    _remove_additional_events_archive_filters
652
-     *
653
-     * @access    private
654
-     * @return        void
655
-     */
656
-    private static function _remove_additional_events_archive_filters()
657
-    {
658
-        remove_filter(
659
-            'the_excerpt',
660
-            array('EED_Events_Archive', 'event_datetimes'),
661
-            EED_Events_Archive::EVENT_DATETIMES_PRIORITY
662
-        );
663
-        remove_filter(
664
-            'the_excerpt',
665
-            array('EED_Events_Archive', 'event_tickets'),
666
-            EED_Events_Archive::EVENT_TICKETS_PRIORITY
667
-        );
668
-        remove_filter(
669
-            'the_excerpt',
670
-            array('EED_Events_Archive', 'event_venues'),
671
-            EED_Events_Archive::EVENT_VENUES_PRIORITY
672
-        );
673
-        remove_filter(
674
-            'the_content',
675
-            array('EED_Events_Archive', 'event_datetimes'),
676
-            EED_Events_Archive::EVENT_DATETIMES_PRIORITY
677
-        );
678
-        remove_filter(
679
-            'the_content',
680
-            array('EED_Events_Archive', 'event_tickets'),
681
-            EED_Events_Archive::EVENT_TICKETS_PRIORITY
682
-        );
683
-        remove_filter(
684
-            'the_content',
685
-            array('EED_Events_Archive', 'event_venues'),
686
-            EED_Events_Archive::EVENT_VENUES_PRIORITY
687
-        );
688
-    }
689
-
690
-
691
-    /**
692
-     *    remove_all_events_archive_filters
693
-     *
694
-     * @access    public
695
-     * @return        void
696
-     */
697
-    public static function remove_all_events_archive_filters()
698
-    {
699
-        // remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 );
700
-        remove_filter('the_title', array('EED_Events_Archive', 'the_title'), 1);
701
-        remove_filter(
702
-            'the_excerpt',
703
-            array('EED_Events_Archive', 'event_details'),
704
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
705
-        );
706
-        remove_filter(
707
-            'the_excerpt',
708
-            array('EED_Events_Archive', 'event_datetimes'),
709
-            EED_Events_Archive::EVENT_DATETIMES_PRIORITY
710
-        );
711
-        remove_filter(
712
-            'the_excerpt',
713
-            array('EED_Events_Archive', 'event_tickets'),
714
-            EED_Events_Archive::EVENT_TICKETS_PRIORITY
715
-        );
716
-        remove_filter(
717
-            'the_excerpt',
718
-            array('EED_Events_Archive', 'event_venues'),
719
-            EED_Events_Archive::EVENT_VENUES_PRIORITY
720
-        );
721
-        remove_filter(
722
-            'the_content',
723
-            array('EED_Events_Archive', 'event_details'),
724
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
725
-        );
726
-        remove_filter(
727
-            'the_content',
728
-            array('EED_Events_Archive', 'event_datetimes'),
729
-            EED_Events_Archive::EVENT_DATETIMES_PRIORITY
730
-        );
731
-        remove_filter(
732
-            'the_content',
733
-            array('EED_Events_Archive', 'event_tickets'),
734
-            EED_Events_Archive::EVENT_TICKETS_PRIORITY
735
-        );
736
-        remove_filter(
737
-            'the_content',
738
-            array('EED_Events_Archive', 'event_venues'),
739
-            EED_Events_Archive::EVENT_VENUES_PRIORITY
740
-        );
741
-        // don't display entry meta because the existing theme will take care of that
742
-        remove_filter(
743
-            'FHEE__content_espresso_events_details_template__display_entry_meta',
744
-            '__return_false'
745
-        );
746
-    }
747
-
748
-
749
-    /**
750
-     *    load_event_list_assets
751
-     *
752
-     * @access    public
753
-     * @return    void
754
-     */
755
-    public function load_event_list_assets()
756
-    {
757
-        do_action('AHEE__EED_Events_Archive__before_load_assets');
758
-        add_filter('FHEE_load_EE_Session', '__return_true');
759
-        add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
760
-        add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10);
761
-        if (EE_Registry::instance()->CFG->map_settings->use_google_maps) {
762
-            add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11);
763
-        }
764
-    }
765
-
766
-
767
-    /**
768
-     *    wp_enqueue_scripts
769
-     *
770
-     * @access    public
771
-     * @return    void
772
-     */
773
-    public function wp_enqueue_scripts()
774
-    {
775
-        // get some style
776
-        if (apply_filters('FHEE_enable_default_espresso_css', false)) {
777
-            // first check uploads folder
778
-            if (EEH_File::is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) {
779
-                wp_register_style(
780
-                    $this->theme,
781
-                    get_stylesheet_directory_uri() . $this->theme . '/style.css',
782
-                    array('dashicons', 'espresso_default')
783
-                );
784
-            } else {
785
-            }
786
-            wp_enqueue_style($this->theme);
787
-        }
788
-    }
789
-
790
-
791
-    /**
792
-     *    template_settings_form
793
-     *
794
-     * @access    public
795
-     * @static
796
-     * @return    string
797
-     */
798
-    public static function template_settings_form()
799
-    {
800
-        $template_settings = EE_Registry::instance()->CFG->template_settings;
801
-        $template_settings->EED_Events_Archive = isset($template_settings->EED_Events_Archive)
802
-            ? $template_settings->EED_Events_Archive : new EE_Events_Archive_Config();
803
-        $template_settings->EED_Events_Archive = apply_filters(
804
-            'FHEE__EED_Events_Archive__template_settings_form__event_list_config',
805
-            $template_settings->EED_Events_Archive
806
-        );
807
-        $events_archive_settings = array(
808
-            'display_status_banner' => 0,
809
-            'display_description' => 1,
810
-            'display_ticket_selector' => 0,
811
-            'display_datetimes' => 1,
812
-            'display_venue' => 0,
813
-            'display_expired_events' => 0,
814
-        );
815
-        $events_archive_settings = array_merge(
816
-            $events_archive_settings,
817
-            (array) $template_settings->EED_Events_Archive
818
-        );
819
-        EEH_Template::display_template(
820
-            EVENTS_ARCHIVE_TEMPLATES_PATH . 'admin-event-list-settings.template.php',
821
-            $events_archive_settings
822
-        );
823
-    }
824
-
825
-
826
-    /**
827
-     *    update_template_settings
828
-     *
829
-     * @access    public
830
-     * @param    EE_Template_Config $CFG
831
-     * @param    EE_Request_Handler $REQ
832
-     * @return    EE_Template_Config
833
-     */
834
-    public static function update_template_settings($CFG, $REQ)
835
-    {
836
-        $CFG->EED_Events_Archive = new EE_Events_Archive_Config();
837
-        // unless we are resetting the config...
838
-        if (
839
-            ! isset($REQ['EED_Events_Archive_reset_event_list_settings'])
840
-            || absint($REQ['EED_Events_Archive_reset_event_list_settings']) !== 1
841
-        ) {
842
-            $CFG->EED_Events_Archive->display_status_banner = isset($REQ['EED_Events_Archive_display_status_banner'])
843
-                ? absint($REQ['EED_Events_Archive_display_status_banner']) : 0;
844
-            $CFG->EED_Events_Archive->display_description = isset($REQ['EED_Events_Archive_display_description'])
845
-                ? absint($REQ['EED_Events_Archive_display_description']) : 1;
846
-            $CFG->EED_Events_Archive->display_ticket_selector = isset($REQ['EED_Events_Archive_display_ticket_selector'])
847
-                ? absint($REQ['EED_Events_Archive_display_ticket_selector']) : 0;
848
-            $CFG->EED_Events_Archive->display_datetimes = isset($REQ['EED_Events_Archive_display_datetimes']) ? absint(
849
-                $REQ['EED_Events_Archive_display_datetimes']
850
-            ) : 1;
851
-            $CFG->EED_Events_Archive->display_venue = isset($REQ['EED_Events_Archive_display_venue']) ? absint(
852
-                $REQ['EED_Events_Archive_display_venue']
853
-            ) : 0;
854
-            $CFG->EED_Events_Archive->display_expired_events = isset($REQ['EED_Events_Archive_display_expired_events'])
855
-                ? absint($REQ['EED_Events_Archive_display_expired_events']) : 0;
856
-        }
857
-        return $CFG;
858
-    }
859
-
860
-
861
-    /**
862
-     *    event_list_css
863
-     *
864
-     * @access    public
865
-     * @param string $extra_class
866
-     * @return    string
867
-     */
868
-    public static function event_list_css($extra_class = '')
869
-    {
870
-        $event_list_css = ! empty($extra_class) ? array($extra_class) : array();
871
-        $event_list_css[] = 'espresso-event-list-event';
872
-        return implode(' ', $event_list_css);
873
-    }
874
-
875
-
876
-    /**
877
-     *    event_categories
878
-     *
879
-     * @access    public
880
-     * @return    array
881
-     */
882
-    public static function event_categories()
883
-    {
884
-        return EE_Registry::instance()->load_model('Term')->get_all_ee_categories();
885
-    }
886
-
887
-
888
-    /**
889
-     *    display_description
890
-     *
891
-     * @access    public
892
-     * @param $value
893
-     * @return    bool
894
-     */
895
-    public static function display_description($value)
896
-    {
897
-        $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive;
898
-        $display_description = isset($config->display_description) ? $config->display_description : 1;
899
-        return $display_description === $value ? true : false;
900
-    }
901
-
902
-
903
-    /**
904
-     *    display_ticket_selector
905
-     *
906
-     * @access    public
907
-     * @return    bool
908
-     */
909
-    public static function display_ticket_selector()
910
-    {
911
-        $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive;
912
-        return isset($config->display_ticket_selector) && $config->display_ticket_selector ? true : false;
913
-    }
914
-
915
-
916
-    /**
917
-     *    display_venue
918
-     *
919
-     * @access    public
920
-     * @return    bool
921
-     */
922
-    public static function display_venue()
923
-    {
924
-        $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive;
925
-        return isset($config->display_venue) && $config->display_venue && EEH_Venue_View::venue_name() ? true : false;
926
-    }
927
-
928
-
929
-    /**
930
-     *    display_datetimes
931
-     *
932
-     * @access    public
933
-     * @return    bool
934
-     */
935
-    public static function display_datetimes()
936
-    {
937
-        $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive;
938
-        return isset($config->display_datetimes) && $config->display_datetimes ? true : false;
939
-    }
940
-
941
-
942
-    /**
943
-     *    event_list_title
944
-     *
945
-     * @access    public
946
-     * @return    string
947
-     */
948
-    public static function event_list_title()
949
-    {
950
-        return apply_filters(
951
-            'FHEE__archive_espresso_events_template__upcoming_events_h1',
952
-            esc_html__('Upcoming Events', 'event_espresso')
953
-        );
954
-    }
955
-
956
-
957
-    // GRAVEYARD
958
-
959
-
960
-    /**
961
-     * @since 4.4.0
962
-     */
963
-    public static function _doing_it_wrong_notice($function = '')
964
-    {
965
-        EE_Error::doing_it_wrong(
966
-            __FUNCTION__,
967
-            sprintf(
968
-                esc_html__(
969
-                    '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',
970
-                    'event_espresso'
971
-                ),
972
-                $function,
973
-                '<br />',
974
-                '4.6.0'
975
-            ),
976
-            '4.4.0'
977
-        );
978
-    }
979
-
980
-
981
-    /**
982
-     * @deprecated
983
-     * @since 4.4.0
984
-     */
985
-    public function get_post_data()
986
-    {
987
-        EEH_Event_Query::set_query_params();
988
-    }
989
-
990
-
991
-    /**
992
-     * @deprecated
993
-     * @since 4.4.0
994
-     */
995
-    public function posts_fields($SQL, WP_Query $wp_query)
996
-    {
997
-        EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
998
-        return EEH_Event_Query::posts_fields($SQL, $wp_query);
999
-    }
1000
-
1001
-
1002
-    /**
1003
-     * @deprecated
1004
-     * @since 4.4.0
1005
-     */
1006
-    public static function posts_fields_sql_for_orderby($orderby_params = array())
1007
-    {
1008
-        EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1009
-        return EEH_Event_Query::posts_fields_sql_for_orderby($orderby_params);
1010
-    }
1011
-
1012
-
1013
-    /**
1014
-     * @deprecated
1015
-     * @since 4.4.0
1016
-     */
1017
-    public function posts_join($SQL, WP_Query $wp_query)
1018
-    {
1019
-        EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1020
-        return EEH_Event_Query::posts_join($SQL, $wp_query);
1021
-    }
1022
-
1023
-
1024
-    /**
1025
-     * @deprecated
1026
-     * @since 4.4.0
1027
-     */
1028
-    public static function posts_join_sql_for_terms($join_terms = null)
1029
-    {
1030
-        EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1031
-        return EEH_Event_Query::posts_join_sql_for_terms($join_terms);
1032
-    }
1033
-
1034
-
1035
-    /**
1036
-     * @deprecated
1037
-     * @since 4.4.0
1038
-     */
1039
-    public static function posts_join_for_orderby($orderby_params = array())
1040
-    {
1041
-        EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1042
-        return EEH_Event_Query::posts_join_for_orderby($orderby_params);
1043
-    }
1044
-
1045
-
1046
-    /**
1047
-     * @deprecated
1048
-     * @since 4.4.0
1049
-     */
1050
-    public function posts_where($SQL, WP_Query $wp_query)
1051
-    {
1052
-        EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1053
-        return EEH_Event_Query::posts_where($SQL, $wp_query);
1054
-    }
1055
-
1056
-
1057
-    /**
1058
-     * @deprecated
1059
-     * @since 4.4.0
1060
-     */
1061
-    public static function posts_where_sql_for_show_expired($show_expired = false)
1062
-    {
1063
-        EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1064
-        return EEH_Event_Query::posts_where_sql_for_show_expired($show_expired);
1065
-    }
1066
-
1067
-
1068
-    /**
1069
-     * @deprecated
1070
-     * @since 4.4.0
1071
-     */
1072
-    public static function posts_where_sql_for_event_category_slug($event_category_slug = null)
1073
-    {
1074
-        EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1075
-        return EEH_Event_Query::posts_where_sql_for_event_category_slug($event_category_slug);
1076
-    }
1077
-
1078
-
1079
-    /**
1080
-     * @deprecated
1081
-     * @since 4.4.0
1082
-     */
1083
-    public static function posts_where_sql_for_event_list_month($month = null)
1084
-    {
1085
-        EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1086
-        return EEH_Event_Query::posts_where_sql_for_event_list_month($month);
1087
-    }
1088
-
1089
-
1090
-    /**
1091
-     * @deprecated
1092
-     * @since 4.4.0
1093
-     */
1094
-    public function posts_orderby($SQL, WP_Query $wp_query)
1095
-    {
1096
-        EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1097
-        return EEH_Event_Query::posts_orderby($SQL, $wp_query);
1098
-    }
1099
-
1100
-
1101
-    /**
1102
-     * @deprecated
1103
-     * @since 4.4.0
1104
-     */
1105
-    public static function posts_orderby_sql($orderby_params = array(), $sort = 'ASC')
1106
-    {
1107
-        EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1108
-        return EEH_Event_Query::posts_orderby_sql($orderby_params, $sort);
1109
-    }
19
+	const EVENT_DETAILS_PRIORITY = 100;
20
+
21
+	const EVENT_DATETIMES_PRIORITY = 110;
22
+
23
+	const EVENT_TICKETS_PRIORITY = 120;
24
+
25
+	const EVENT_VENUES_PRIORITY = 130;
26
+
27
+
28
+	public static $espresso_event_list_ID = 0;
29
+
30
+	public static $espresso_grid_event_lists = array();
31
+
32
+	/**
33
+	 * @type bool $using_get_the_excerpt
34
+	 */
35
+	protected static $using_get_the_excerpt = false;
36
+
37
+	/**
38
+	 * Used to flag when the event list is being called from an external iframe.
39
+	 *
40
+	 * @var bool $iframe
41
+	 */
42
+	protected static $iframe = false;
43
+
44
+	/**
45
+	 * @var EventListIframeEmbedButton $_iframe_embed_button
46
+	 */
47
+	private static $_iframe_embed_button;
48
+
49
+	/**
50
+	 * @type EE_Template_Part_Manager $template_parts
51
+	 */
52
+	protected $template_parts;
53
+
54
+
55
+	/**
56
+	 * @return EED_Events_Archive
57
+	 */
58
+	public static function instance()
59
+	{
60
+		return parent::get_instance(__CLASS__);
61
+	}
62
+
63
+
64
+	/**
65
+	 * set_hooks - for hooking into EE Core, other modules, etc
66
+	 *
67
+	 * @return void
68
+	 * @throws InvalidArgumentException
69
+	 * @throws InvalidDataTypeException
70
+	 * @throws InvalidInterfaceException
71
+	 */
72
+	public static function set_hooks()
73
+	{
74
+		/** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_type_definitions */
75
+		$custom_post_type_definitions = LoaderFactory::getLoader()->getShared(
76
+			'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
77
+		);
78
+		$custom_post_types = $custom_post_type_definitions->getDefinitions();
79
+		EE_Config::register_route(
80
+			$custom_post_types['espresso_events']['plural_slug'],
81
+			'Events_Archive',
82
+			'run'
83
+		);
84
+		EE_Config::register_route(
85
+			'event_list',
86
+			'Events_Archive',
87
+			'event_list'
88
+		);
89
+		EE_Config::register_route(
90
+			'iframe',
91
+			'Events_Archive',
92
+			'event_list_iframe',
93
+			'event_list'
94
+		);
95
+		add_action('wp_loaded', array('EED_Events_Archive', 'set_definitions'), 2);
96
+	}
97
+
98
+
99
+	/**
100
+	 *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
101
+	 *
102
+	 * @access    public
103
+	 * @return    void
104
+	 */
105
+	public static function set_hooks_admin()
106
+	{
107
+		add_action('wp_loaded', array('EED_Events_Archive', 'set_definitions'), 2);
108
+		// hook into the end of the \EE_Admin_Page::_load_page_dependencies()
109
+		// to load assets for "espresso_events" page on the "default" route (action)
110
+		add_action(
111
+			'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_events__default',
112
+			array('EED_Events_Archive', 'event_list_iframe_embed_button'),
113
+			10
114
+		);
115
+	}
116
+
117
+
118
+	/**
119
+	 *    set_definitions
120
+	 *
121
+	 * @access    public
122
+	 * @return    void
123
+	 */
124
+	public static function set_definitions()
125
+	{
126
+		define('EVENTS_ARCHIVE_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/');
127
+		define('EVENTS_ARCHIVE_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/');
128
+	}
129
+
130
+
131
+	/**
132
+	 * set up EE_Events_Archive_Config
133
+	 */
134
+	protected function set_config()
135
+	{
136
+		$this->set_config_section('template_settings');
137
+		$this->set_config_class('EE_Events_Archive_Config');
138
+		$this->set_config_name('EED_Events_Archive');
139
+	}
140
+
141
+
142
+	/**
143
+	 * @return EventListIframeEmbedButton
144
+	 */
145
+	public static function get_iframe_embed_button()
146
+	{
147
+		if (! self::$_iframe_embed_button instanceof EventListIframeEmbedButton) {
148
+			self::$_iframe_embed_button = new EventListIframeEmbedButton();
149
+		}
150
+		return self::$_iframe_embed_button;
151
+	}
152
+
153
+
154
+	/**
155
+	 * event_list_iframe_embed_button
156
+	 *
157
+	 * @return    void
158
+	 * @throws EE_Error
159
+	 */
160
+	public static function event_list_iframe_embed_button()
161
+	{
162
+		$iframe_embed_button = EED_Events_Archive::get_iframe_embed_button();
163
+		$iframe_embed_button->addEmbedButton();
164
+	}
165
+
166
+
167
+	/**
168
+	 *    initialize_template_parts
169
+	 *
170
+	 * @access    public
171
+	 * @param EE_Events_Archive_Config $config
172
+	 * @return EE_Template_Part_Manager
173
+	 */
174
+	public function initialize_template_parts(EE_Events_Archive_Config $config = null)
175
+	{
176
+		$config = $config instanceof EE_Events_Archive_Config ? $config : $this->config();
177
+		EEH_Autoloader::instance()->register_template_part_autoloaders();
178
+		$template_parts = new EE_Template_Part_Manager();
179
+		$template_parts->add_template_part(
180
+			'tickets',
181
+			esc_html__('Ticket Selector', 'event_espresso'),
182
+			'content-espresso_events-tickets.php',
183
+			$config->display_order_tickets
184
+		);
185
+		$template_parts->add_template_part(
186
+			'datetimes',
187
+			esc_html__('Dates and Times', 'event_espresso'),
188
+			'content-espresso_events-datetimes.php',
189
+			$config->display_order_datetimes
190
+		);
191
+		$template_parts->add_template_part(
192
+			'event',
193
+			esc_html__('Event Description', 'event_espresso'),
194
+			'content-espresso_events-details.php',
195
+			$config->display_order_event
196
+		);
197
+		$template_parts->add_template_part(
198
+			'venue',
199
+			esc_html__('Venue Information', 'event_espresso'),
200
+			'content-espresso_events-venues.php',
201
+			$config->display_order_venue
202
+		);
203
+		do_action('AHEE__EED_Event_Archive__initialize_template_parts', $template_parts);
204
+		return $template_parts;
205
+	}
206
+
207
+
208
+	/**
209
+	 *    run - initial module setup - this gets called by the EE_Front_Controller if the module route is found in the
210
+	 *    incoming request
211
+	 *
212
+	 * @access    public
213
+	 * @param WP $WP
214
+	 * @return    void
215
+	 */
216
+	public function run($WP)
217
+	{
218
+		do_action('AHEE__EED_Events_Archive__before_run');
219
+		// ensure valid EE_Events_Archive_Config() object exists
220
+		$this->set_config();
221
+		/** @type EE_Events_Archive_Config $config */
222
+		$config = $this->config();
223
+		// load other required components
224
+		$this->load_event_list_assets();
225
+		// filter the WP posts_join, posts_where, and posts_orderby SQL clauses
226
+		// add query filters
227
+		EEH_Event_Query::add_query_filters();
228
+		// set params that will get used by the filters
229
+		EEH_Event_Query::set_query_params(
230
+			'',    // month
231
+			'',    // category
232
+			$config->display_expired_events,    // show_expired
233
+			'start_date',    // orderby
234
+			'ASC'    // sort
235
+		);
236
+		// check what template is loaded
237
+		add_filter('template_include', array($this, 'template_include'), 999, 1);
238
+	}
239
+
240
+
241
+	/**
242
+	 * most likely called by the ESPRESSO_EVENTS shortcode which uses this module to do some of it's lifting
243
+	 *
244
+	 * @return    void
245
+	 */
246
+	public function event_list()
247
+	{
248
+		// ensure valid EE_Events_Archive_Config() object exists
249
+		$this->set_config();
250
+		// load other required components
251
+		$this->load_event_list_assets();
252
+	}
253
+
254
+
255
+	/**
256
+	 * @access    public
257
+	 * @return    void
258
+	 * @throws EE_Error
259
+	 * @throws DomainException
260
+	 */
261
+	public function event_list_iframe()
262
+	{
263
+		EED_Events_Archive::$iframe = true;
264
+		$event_list_iframe          = new EventsArchiveIframe($this);
265
+		$event_list_iframe->display();
266
+	}
267
+
268
+
269
+	/**
270
+	 * @access public
271
+	 * @return string
272
+	 */
273
+	public static function is_iframe()
274
+	{
275
+		return EED_Events_Archive::$iframe;
276
+	}
277
+
278
+
279
+	/**
280
+	 * @access public
281
+	 * @return string
282
+	 */
283
+	public static function link_target()
284
+	{
285
+		return EED_Events_Archive::$iframe ? ' target="_blank"' : '';
286
+	}
287
+
288
+
289
+	/**
290
+	 *    template_include
291
+	 *
292
+	 * @access    public
293
+	 * @param string $template
294
+	 * @return    string
295
+	 */
296
+	public function template_include($template = '')
297
+	{
298
+		// don't add content filter for dedicated EE child themes or private posts
299
+		if (! EEH_Template::is_espresso_theme()) {
300
+			/** @type EE_Events_Archive_Config $config */
301
+			$config = $this->config();
302
+			// add status banner ?
303
+			if ($config->display_status_banner) {
304
+				add_filter('the_title', array('EED_Events_Archive', 'the_title'), 100, 2);
305
+			}
306
+			// if NOT a custom template
307
+			if (
308
+				apply_filters('FHEE__EED_Event_Archive__template_include__allow_custom_selected_template', false)
309
+				|| EE_Registry::instance()
310
+							  ->load_core('Front_Controller')
311
+							  ->get_selected_template() !== 'archive-espresso_events.php'
312
+			) {
313
+				// don't display entry meta because the existing theme will take care of that
314
+				add_filter('FHEE__EED_Events_Archive__template_include__events_list_active', '__return_true');
315
+				// load functions.php file for the theme (loaded by WP if using child theme)
316
+				EEH_Template::load_espresso_theme_functions();
317
+				// because we don't know if the theme is using the_excerpt()
318
+				add_filter(
319
+					'the_excerpt',
320
+					array('EED_Events_Archive', 'event_details'),
321
+					EED_Events_Archive::EVENT_DETAILS_PRIORITY
322
+				);
323
+				// or the_content
324
+				add_filter(
325
+					'the_content',
326
+					array('EED_Events_Archive', 'event_details'),
327
+					EED_Events_Archive::EVENT_DETAILS_PRIORITY
328
+				);
329
+				// and just in case they are running get_the_excerpt() which DESTROYS things
330
+				add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1);
331
+				// don't display entry meta because the existing theme will take care of that
332
+				add_filter('FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false');
333
+			}
334
+		}
335
+		return $template;
336
+	}
337
+
338
+
339
+	/**
340
+	 *    get_the_excerpt - kinda hacky, but if a theme is using get_the_excerpt(), then we need to remove our filters
341
+	 *    on the_content()
342
+	 *
343
+	 * @access    public
344
+	 * @param        string $excerpt
345
+	 * @return        string
346
+	 */
347
+	public static function get_the_excerpt($excerpt = '')
348
+	{
349
+		if (post_password_required()) {
350
+			return $excerpt;
351
+		}
352
+		if (apply_filters('FHEE__EED_Events_Archive__get_the_excerpt__theme_uses_get_the_excerpt', false)) {
353
+			remove_filter(
354
+				'the_excerpt',
355
+				array('EED_Events_Archive', 'event_details'),
356
+				EED_Events_Archive::EVENT_DETAILS_PRIORITY
357
+			);
358
+			remove_filter(
359
+				'the_content',
360
+				array('EED_Events_Archive', 'event_details'),
361
+				EED_Events_Archive::EVENT_DETAILS_PRIORITY
362
+			);
363
+			$excerpt = EED_Events_Archive::event_details($excerpt);
364
+		} else {
365
+			EED_Events_Archive::$using_get_the_excerpt = true;
366
+			add_filter('wp_trim_excerpt', array('EED_Events_Archive', 'end_get_the_excerpt'), 999, 1);
367
+		}
368
+		return $excerpt;
369
+	}
370
+
371
+
372
+	/**
373
+	 * end_get_the_excerpt
374
+	 *
375
+	 * @access public
376
+	 * @param  string $text
377
+	 * @return string
378
+	 */
379
+	public static function end_get_the_excerpt($text = '')
380
+	{
381
+		EED_Events_Archive::$using_get_the_excerpt = false;
382
+		return $text;
383
+	}
384
+
385
+
386
+	/**
387
+	 *    the_title
388
+	 *
389
+	 * @access        public
390
+	 * @param        string $title
391
+	 * @param        string $id
392
+	 * @return        string
393
+	 */
394
+	public static function the_title($title = '', $id = '')
395
+	{
396
+		global $post;
397
+		if ($post instanceof WP_Post) {
398
+			return in_the_loop() && $post->ID == $id ? espresso_event_status_banner($post->ID) . $title : $title;
399
+		}
400
+		return $title;
401
+	}
402
+
403
+
404
+	/**
405
+	 *    event_details
406
+	 *
407
+	 * @access    public
408
+	 * @param        string $content
409
+	 * @return        string
410
+	 */
411
+	public static function event_details($content)
412
+	{
413
+		global $post;
414
+		static $current_post_ID = 0;
415
+		if (
416
+			$current_post_ID !== $post->ID
417
+			&& $post->post_type === 'espresso_events'
418
+			&& ! EED_Events_Archive::$using_get_the_excerpt
419
+			&& ! post_password_required()
420
+			&& (
421
+				apply_filters('FHEE__EES_Espresso_Events__process_shortcode__true', false)
422
+				|| ! apply_filters('FHEE__content_espresso_events__template_loaded', false)
423
+			)
424
+		) {
425
+			// Set current post ID to prevent showing content twice, but only if headers have definitely been sent.
426
+			// Reason being is that some plugins, like Yoast, need to run through a copy of the loop early
427
+			// BEFORE headers are sent in order to examine the post content and generate content for the HTML header.
428
+			// We want to allow those plugins to still do their thing and have access to our content, but depending on
429
+			// how your event content is being displayed (shortcode, CPT route, etc), this filter can get applied twice,
430
+			// so the following allows this filter to be applied multiple times, but only once for real
431
+			$current_post_ID = did_action('loop_start') ? $post->ID : 0;
432
+			if (EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->use_sortable_display_order) {
433
+				$content = EED_Events_Archive::use_sortable_display_order();
434
+			} else {
435
+				$content = EED_Events_Archive::use_filterable_display_order();
436
+			}
437
+		}
438
+		return $content;
439
+	}
440
+
441
+
442
+	/**
443
+	 *    use_sortable_display_order
444
+	 *
445
+	 * @access    protected
446
+	 * @return string
447
+	 */
448
+	protected static function use_sortable_display_order()
449
+	{
450
+		// no further password checks required atm
451
+		add_filter('FHEE__EED_Events_Archive__event_details__no_post_password_required', '__return_true');
452
+		// we need to first remove this callback from being applied to the_content() or the_excerpt()
453
+		// (otherwise it will recurse and blow up the interweb)
454
+		remove_filter(
455
+			'the_excerpt',
456
+			array('EED_Events_Archive', 'event_details'),
457
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
458
+		);
459
+		remove_filter(
460
+			'the_content',
461
+			array('EED_Events_Archive', 'event_details'),
462
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
463
+		);
464
+		remove_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1);
465
+		// now add additional content depending on whether event is using the_excerpt() or the_content()
466
+		EED_Events_Archive::instance()->template_parts = EED_Events_Archive::instance()->initialize_template_parts();
467
+		$content = EEH_Template::locate_template('content-espresso_events-details.php');
468
+		$content = EED_Events_Archive::instance()->template_parts->apply_template_part_filters($content);
469
+		// re-add our main filters (or else the next event won't have them)
470
+		add_filter(
471
+			'the_excerpt',
472
+			array('EED_Events_Archive', 'event_details'),
473
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
474
+		);
475
+		add_filter(
476
+			'the_content',
477
+			array('EED_Events_Archive', 'event_details'),
478
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
479
+		);
480
+		add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1);
481
+		remove_filter(
482
+			'FHEE__EED_Events_Archive__event_details__no_post_password_required',
483
+			'__return_true'
484
+		);
485
+		return $content;
486
+	}
487
+
488
+
489
+	/**
490
+	 *    use_filterable_display_order
491
+	 *
492
+	 * @access    protected
493
+	 * @return    string
494
+	 */
495
+	protected static function use_filterable_display_order()
496
+	{
497
+		// we need to first remove this callback from being applied to the_content()
498
+		// (otherwise it will recurse and blow up the interweb)
499
+		remove_filter(
500
+			'the_excerpt',
501
+			array('EED_Events_Archive', 'event_details'),
502
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
503
+		);
504
+		remove_filter(
505
+			'the_content',
506
+			array('EED_Events_Archive', 'event_details'),
507
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
508
+		);
509
+		remove_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1);
510
+		// now add additional content depending on whether event is using the_excerpt() or the_content()
511
+		EED_Events_Archive::_add_additional_excerpt_filters();
512
+		EED_Events_Archive::_add_additional_content_filters();
513
+		do_action('AHEE__EED_Events_Archive__use_filterable_display_order__after_add_filters');
514
+		// now load our template
515
+		$content = EEH_Template::locate_template('content-espresso_events-details.php');
516
+		// re-add our main filters (or else the next event won't have them)
517
+		add_filter(
518
+			'the_excerpt',
519
+			array('EED_Events_Archive', 'event_details'),
520
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
521
+		);
522
+		add_filter(
523
+			'the_content',
524
+			array('EED_Events_Archive', 'event_details'),
525
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
526
+		);
527
+		add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1);
528
+		// but remove the other filters so that they don't get applied to the next post
529
+		EED_Events_Archive::_remove_additional_events_archive_filters();
530
+		do_action('AHEE__EED_Events_Archive__use_filterable_display_order__after_remove_filters');
531
+		// we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt)
532
+		// return ! empty( $template ) ? $template : $content;
533
+		return $content;
534
+	}
535
+
536
+
537
+	/**
538
+	 *    event_datetimes - adds datetimes ABOVE content
539
+	 *
540
+	 * @access    public
541
+	 * @param        string $content
542
+	 * @return        string
543
+	 */
544
+	public static function event_datetimes($content)
545
+	{
546
+		if (post_password_required()) {
547
+			return $content;
548
+		}
549
+		return EEH_Template::locate_template('content-espresso_events-datetimes.php') . $content;
550
+	}
551
+
552
+
553
+	/**
554
+	 *    event_tickets - adds tickets ABOVE content (which includes datetimes)
555
+	 *
556
+	 * @access    public
557
+	 * @param        string $content
558
+	 * @return        string
559
+	 */
560
+	public static function event_tickets($content)
561
+	{
562
+		if (post_password_required()) {
563
+			return $content;
564
+		}
565
+		return EEH_Template::locate_template('content-espresso_events-tickets.php') . $content;
566
+	}
567
+
568
+
569
+	/**
570
+	 *    event_venues - adds venues BELOW content
571
+	 *
572
+	 * @access    public
573
+	 * @param    string $content
574
+	 * @return    string
575
+	 */
576
+	public static function event_venue($content)
577
+	{
578
+		return EED_Events_Archive::event_venues($content);
579
+	}
580
+
581
+
582
+	/**
583
+	 *    event_venues - adds venues BELOW content
584
+	 *
585
+	 * @access    public
586
+	 * @param        string $content
587
+	 * @return        string
588
+	 */
589
+	public static function event_venues($content)
590
+	{
591
+		if (post_password_required()) {
592
+			return $content;
593
+		}
594
+		return $content . EEH_Template::locate_template('content-espresso_events-venues.php');
595
+	}
596
+
597
+
598
+	/**
599
+	 *    _add_additional_content_filters
600
+	 *
601
+	 * @access    private
602
+	 * @return        void
603
+	 */
604
+	private static function _add_additional_excerpt_filters()
605
+	{
606
+		add_filter(
607
+			'the_excerpt',
608
+			array('EED_Events_Archive', 'event_datetimes'),
609
+			EED_Events_Archive::EVENT_DATETIMES_PRIORITY
610
+		);
611
+		add_filter(
612
+			'the_excerpt',
613
+			array('EED_Events_Archive', 'event_tickets'),
614
+			EED_Events_Archive::EVENT_TICKETS_PRIORITY
615
+		);
616
+		add_filter(
617
+			'the_excerpt',
618
+			array('EED_Events_Archive', 'event_venues'),
619
+			EED_Events_Archive::EVENT_VENUES_PRIORITY
620
+		);
621
+	}
622
+
623
+
624
+	/**
625
+	 *    _add_additional_content_filters
626
+	 *
627
+	 * @access    private
628
+	 * @return        void
629
+	 */
630
+	private static function _add_additional_content_filters()
631
+	{
632
+		add_filter(
633
+			'the_content',
634
+			array('EED_Events_Archive', 'event_datetimes'),
635
+			EED_Events_Archive::EVENT_DATETIMES_PRIORITY
636
+		);
637
+		add_filter(
638
+			'the_content',
639
+			array('EED_Events_Archive', 'event_tickets'),
640
+			EED_Events_Archive::EVENT_TICKETS_PRIORITY
641
+		);
642
+		add_filter(
643
+			'the_content',
644
+			array('EED_Events_Archive', 'event_venues'),
645
+			EED_Events_Archive::EVENT_VENUES_PRIORITY
646
+		);
647
+	}
648
+
649
+
650
+	/**
651
+	 *    _remove_additional_events_archive_filters
652
+	 *
653
+	 * @access    private
654
+	 * @return        void
655
+	 */
656
+	private static function _remove_additional_events_archive_filters()
657
+	{
658
+		remove_filter(
659
+			'the_excerpt',
660
+			array('EED_Events_Archive', 'event_datetimes'),
661
+			EED_Events_Archive::EVENT_DATETIMES_PRIORITY
662
+		);
663
+		remove_filter(
664
+			'the_excerpt',
665
+			array('EED_Events_Archive', 'event_tickets'),
666
+			EED_Events_Archive::EVENT_TICKETS_PRIORITY
667
+		);
668
+		remove_filter(
669
+			'the_excerpt',
670
+			array('EED_Events_Archive', 'event_venues'),
671
+			EED_Events_Archive::EVENT_VENUES_PRIORITY
672
+		);
673
+		remove_filter(
674
+			'the_content',
675
+			array('EED_Events_Archive', 'event_datetimes'),
676
+			EED_Events_Archive::EVENT_DATETIMES_PRIORITY
677
+		);
678
+		remove_filter(
679
+			'the_content',
680
+			array('EED_Events_Archive', 'event_tickets'),
681
+			EED_Events_Archive::EVENT_TICKETS_PRIORITY
682
+		);
683
+		remove_filter(
684
+			'the_content',
685
+			array('EED_Events_Archive', 'event_venues'),
686
+			EED_Events_Archive::EVENT_VENUES_PRIORITY
687
+		);
688
+	}
689
+
690
+
691
+	/**
692
+	 *    remove_all_events_archive_filters
693
+	 *
694
+	 * @access    public
695
+	 * @return        void
696
+	 */
697
+	public static function remove_all_events_archive_filters()
698
+	{
699
+		// remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 );
700
+		remove_filter('the_title', array('EED_Events_Archive', 'the_title'), 1);
701
+		remove_filter(
702
+			'the_excerpt',
703
+			array('EED_Events_Archive', 'event_details'),
704
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
705
+		);
706
+		remove_filter(
707
+			'the_excerpt',
708
+			array('EED_Events_Archive', 'event_datetimes'),
709
+			EED_Events_Archive::EVENT_DATETIMES_PRIORITY
710
+		);
711
+		remove_filter(
712
+			'the_excerpt',
713
+			array('EED_Events_Archive', 'event_tickets'),
714
+			EED_Events_Archive::EVENT_TICKETS_PRIORITY
715
+		);
716
+		remove_filter(
717
+			'the_excerpt',
718
+			array('EED_Events_Archive', 'event_venues'),
719
+			EED_Events_Archive::EVENT_VENUES_PRIORITY
720
+		);
721
+		remove_filter(
722
+			'the_content',
723
+			array('EED_Events_Archive', 'event_details'),
724
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
725
+		);
726
+		remove_filter(
727
+			'the_content',
728
+			array('EED_Events_Archive', 'event_datetimes'),
729
+			EED_Events_Archive::EVENT_DATETIMES_PRIORITY
730
+		);
731
+		remove_filter(
732
+			'the_content',
733
+			array('EED_Events_Archive', 'event_tickets'),
734
+			EED_Events_Archive::EVENT_TICKETS_PRIORITY
735
+		);
736
+		remove_filter(
737
+			'the_content',
738
+			array('EED_Events_Archive', 'event_venues'),
739
+			EED_Events_Archive::EVENT_VENUES_PRIORITY
740
+		);
741
+		// don't display entry meta because the existing theme will take care of that
742
+		remove_filter(
743
+			'FHEE__content_espresso_events_details_template__display_entry_meta',
744
+			'__return_false'
745
+		);
746
+	}
747
+
748
+
749
+	/**
750
+	 *    load_event_list_assets
751
+	 *
752
+	 * @access    public
753
+	 * @return    void
754
+	 */
755
+	public function load_event_list_assets()
756
+	{
757
+		do_action('AHEE__EED_Events_Archive__before_load_assets');
758
+		add_filter('FHEE_load_EE_Session', '__return_true');
759
+		add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
760
+		add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10);
761
+		if (EE_Registry::instance()->CFG->map_settings->use_google_maps) {
762
+			add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11);
763
+		}
764
+	}
765
+
766
+
767
+	/**
768
+	 *    wp_enqueue_scripts
769
+	 *
770
+	 * @access    public
771
+	 * @return    void
772
+	 */
773
+	public function wp_enqueue_scripts()
774
+	{
775
+		// get some style
776
+		if (apply_filters('FHEE_enable_default_espresso_css', false)) {
777
+			// first check uploads folder
778
+			if (EEH_File::is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) {
779
+				wp_register_style(
780
+					$this->theme,
781
+					get_stylesheet_directory_uri() . $this->theme . '/style.css',
782
+					array('dashicons', 'espresso_default')
783
+				);
784
+			} else {
785
+			}
786
+			wp_enqueue_style($this->theme);
787
+		}
788
+	}
789
+
790
+
791
+	/**
792
+	 *    template_settings_form
793
+	 *
794
+	 * @access    public
795
+	 * @static
796
+	 * @return    string
797
+	 */
798
+	public static function template_settings_form()
799
+	{
800
+		$template_settings = EE_Registry::instance()->CFG->template_settings;
801
+		$template_settings->EED_Events_Archive = isset($template_settings->EED_Events_Archive)
802
+			? $template_settings->EED_Events_Archive : new EE_Events_Archive_Config();
803
+		$template_settings->EED_Events_Archive = apply_filters(
804
+			'FHEE__EED_Events_Archive__template_settings_form__event_list_config',
805
+			$template_settings->EED_Events_Archive
806
+		);
807
+		$events_archive_settings = array(
808
+			'display_status_banner' => 0,
809
+			'display_description' => 1,
810
+			'display_ticket_selector' => 0,
811
+			'display_datetimes' => 1,
812
+			'display_venue' => 0,
813
+			'display_expired_events' => 0,
814
+		);
815
+		$events_archive_settings = array_merge(
816
+			$events_archive_settings,
817
+			(array) $template_settings->EED_Events_Archive
818
+		);
819
+		EEH_Template::display_template(
820
+			EVENTS_ARCHIVE_TEMPLATES_PATH . 'admin-event-list-settings.template.php',
821
+			$events_archive_settings
822
+		);
823
+	}
824
+
825
+
826
+	/**
827
+	 *    update_template_settings
828
+	 *
829
+	 * @access    public
830
+	 * @param    EE_Template_Config $CFG
831
+	 * @param    EE_Request_Handler $REQ
832
+	 * @return    EE_Template_Config
833
+	 */
834
+	public static function update_template_settings($CFG, $REQ)
835
+	{
836
+		$CFG->EED_Events_Archive = new EE_Events_Archive_Config();
837
+		// unless we are resetting the config...
838
+		if (
839
+			! isset($REQ['EED_Events_Archive_reset_event_list_settings'])
840
+			|| absint($REQ['EED_Events_Archive_reset_event_list_settings']) !== 1
841
+		) {
842
+			$CFG->EED_Events_Archive->display_status_banner = isset($REQ['EED_Events_Archive_display_status_banner'])
843
+				? absint($REQ['EED_Events_Archive_display_status_banner']) : 0;
844
+			$CFG->EED_Events_Archive->display_description = isset($REQ['EED_Events_Archive_display_description'])
845
+				? absint($REQ['EED_Events_Archive_display_description']) : 1;
846
+			$CFG->EED_Events_Archive->display_ticket_selector = isset($REQ['EED_Events_Archive_display_ticket_selector'])
847
+				? absint($REQ['EED_Events_Archive_display_ticket_selector']) : 0;
848
+			$CFG->EED_Events_Archive->display_datetimes = isset($REQ['EED_Events_Archive_display_datetimes']) ? absint(
849
+				$REQ['EED_Events_Archive_display_datetimes']
850
+			) : 1;
851
+			$CFG->EED_Events_Archive->display_venue = isset($REQ['EED_Events_Archive_display_venue']) ? absint(
852
+				$REQ['EED_Events_Archive_display_venue']
853
+			) : 0;
854
+			$CFG->EED_Events_Archive->display_expired_events = isset($REQ['EED_Events_Archive_display_expired_events'])
855
+				? absint($REQ['EED_Events_Archive_display_expired_events']) : 0;
856
+		}
857
+		return $CFG;
858
+	}
859
+
860
+
861
+	/**
862
+	 *    event_list_css
863
+	 *
864
+	 * @access    public
865
+	 * @param string $extra_class
866
+	 * @return    string
867
+	 */
868
+	public static function event_list_css($extra_class = '')
869
+	{
870
+		$event_list_css = ! empty($extra_class) ? array($extra_class) : array();
871
+		$event_list_css[] = 'espresso-event-list-event';
872
+		return implode(' ', $event_list_css);
873
+	}
874
+
875
+
876
+	/**
877
+	 *    event_categories
878
+	 *
879
+	 * @access    public
880
+	 * @return    array
881
+	 */
882
+	public static function event_categories()
883
+	{
884
+		return EE_Registry::instance()->load_model('Term')->get_all_ee_categories();
885
+	}
886
+
887
+
888
+	/**
889
+	 *    display_description
890
+	 *
891
+	 * @access    public
892
+	 * @param $value
893
+	 * @return    bool
894
+	 */
895
+	public static function display_description($value)
896
+	{
897
+		$config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive;
898
+		$display_description = isset($config->display_description) ? $config->display_description : 1;
899
+		return $display_description === $value ? true : false;
900
+	}
901
+
902
+
903
+	/**
904
+	 *    display_ticket_selector
905
+	 *
906
+	 * @access    public
907
+	 * @return    bool
908
+	 */
909
+	public static function display_ticket_selector()
910
+	{
911
+		$config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive;
912
+		return isset($config->display_ticket_selector) && $config->display_ticket_selector ? true : false;
913
+	}
914
+
915
+
916
+	/**
917
+	 *    display_venue
918
+	 *
919
+	 * @access    public
920
+	 * @return    bool
921
+	 */
922
+	public static function display_venue()
923
+	{
924
+		$config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive;
925
+		return isset($config->display_venue) && $config->display_venue && EEH_Venue_View::venue_name() ? true : false;
926
+	}
927
+
928
+
929
+	/**
930
+	 *    display_datetimes
931
+	 *
932
+	 * @access    public
933
+	 * @return    bool
934
+	 */
935
+	public static function display_datetimes()
936
+	{
937
+		$config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive;
938
+		return isset($config->display_datetimes) && $config->display_datetimes ? true : false;
939
+	}
940
+
941
+
942
+	/**
943
+	 *    event_list_title
944
+	 *
945
+	 * @access    public
946
+	 * @return    string
947
+	 */
948
+	public static function event_list_title()
949
+	{
950
+		return apply_filters(
951
+			'FHEE__archive_espresso_events_template__upcoming_events_h1',
952
+			esc_html__('Upcoming Events', 'event_espresso')
953
+		);
954
+	}
955
+
956
+
957
+	// GRAVEYARD
958
+
959
+
960
+	/**
961
+	 * @since 4.4.0
962
+	 */
963
+	public static function _doing_it_wrong_notice($function = '')
964
+	{
965
+		EE_Error::doing_it_wrong(
966
+			__FUNCTION__,
967
+			sprintf(
968
+				esc_html__(
969
+					'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',
970
+					'event_espresso'
971
+				),
972
+				$function,
973
+				'<br />',
974
+				'4.6.0'
975
+			),
976
+			'4.4.0'
977
+		);
978
+	}
979
+
980
+
981
+	/**
982
+	 * @deprecated
983
+	 * @since 4.4.0
984
+	 */
985
+	public function get_post_data()
986
+	{
987
+		EEH_Event_Query::set_query_params();
988
+	}
989
+
990
+
991
+	/**
992
+	 * @deprecated
993
+	 * @since 4.4.0
994
+	 */
995
+	public function posts_fields($SQL, WP_Query $wp_query)
996
+	{
997
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
998
+		return EEH_Event_Query::posts_fields($SQL, $wp_query);
999
+	}
1000
+
1001
+
1002
+	/**
1003
+	 * @deprecated
1004
+	 * @since 4.4.0
1005
+	 */
1006
+	public static function posts_fields_sql_for_orderby($orderby_params = array())
1007
+	{
1008
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1009
+		return EEH_Event_Query::posts_fields_sql_for_orderby($orderby_params);
1010
+	}
1011
+
1012
+
1013
+	/**
1014
+	 * @deprecated
1015
+	 * @since 4.4.0
1016
+	 */
1017
+	public function posts_join($SQL, WP_Query $wp_query)
1018
+	{
1019
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1020
+		return EEH_Event_Query::posts_join($SQL, $wp_query);
1021
+	}
1022
+
1023
+
1024
+	/**
1025
+	 * @deprecated
1026
+	 * @since 4.4.0
1027
+	 */
1028
+	public static function posts_join_sql_for_terms($join_terms = null)
1029
+	{
1030
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1031
+		return EEH_Event_Query::posts_join_sql_for_terms($join_terms);
1032
+	}
1033
+
1034
+
1035
+	/**
1036
+	 * @deprecated
1037
+	 * @since 4.4.0
1038
+	 */
1039
+	public static function posts_join_for_orderby($orderby_params = array())
1040
+	{
1041
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1042
+		return EEH_Event_Query::posts_join_for_orderby($orderby_params);
1043
+	}
1044
+
1045
+
1046
+	/**
1047
+	 * @deprecated
1048
+	 * @since 4.4.0
1049
+	 */
1050
+	public function posts_where($SQL, WP_Query $wp_query)
1051
+	{
1052
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1053
+		return EEH_Event_Query::posts_where($SQL, $wp_query);
1054
+	}
1055
+
1056
+
1057
+	/**
1058
+	 * @deprecated
1059
+	 * @since 4.4.0
1060
+	 */
1061
+	public static function posts_where_sql_for_show_expired($show_expired = false)
1062
+	{
1063
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1064
+		return EEH_Event_Query::posts_where_sql_for_show_expired($show_expired);
1065
+	}
1066
+
1067
+
1068
+	/**
1069
+	 * @deprecated
1070
+	 * @since 4.4.0
1071
+	 */
1072
+	public static function posts_where_sql_for_event_category_slug($event_category_slug = null)
1073
+	{
1074
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1075
+		return EEH_Event_Query::posts_where_sql_for_event_category_slug($event_category_slug);
1076
+	}
1077
+
1078
+
1079
+	/**
1080
+	 * @deprecated
1081
+	 * @since 4.4.0
1082
+	 */
1083
+	public static function posts_where_sql_for_event_list_month($month = null)
1084
+	{
1085
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1086
+		return EEH_Event_Query::posts_where_sql_for_event_list_month($month);
1087
+	}
1088
+
1089
+
1090
+	/**
1091
+	 * @deprecated
1092
+	 * @since 4.4.0
1093
+	 */
1094
+	public function posts_orderby($SQL, WP_Query $wp_query)
1095
+	{
1096
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1097
+		return EEH_Event_Query::posts_orderby($SQL, $wp_query);
1098
+	}
1099
+
1100
+
1101
+	/**
1102
+	 * @deprecated
1103
+	 * @since 4.4.0
1104
+	 */
1105
+	public static function posts_orderby_sql($orderby_params = array(), $sort = 'ASC')
1106
+	{
1107
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1108
+		return EEH_Event_Query::posts_orderby_sql($orderby_params, $sort);
1109
+	}
1110 1110
 }
1111 1111
 
1112 1112
 
@@ -1115,9 +1115,9 @@  discard block
 block discarded – undo
1115 1115
  */
1116 1116
 function espresso_get_event_list_ID()
1117 1117
 {
1118
-    EED_Events_Archive::$espresso_event_list_ID++;
1119
-    EED_Events_Archive::$espresso_grid_event_lists[] = EED_Events_Archive::$espresso_event_list_ID;
1120
-    return EED_Events_Archive::$espresso_event_list_ID;
1118
+	EED_Events_Archive::$espresso_event_list_ID++;
1119
+	EED_Events_Archive::$espresso_grid_event_lists[] = EED_Events_Archive::$espresso_event_list_ID;
1120
+	return EED_Events_Archive::$espresso_event_list_ID;
1121 1121
 }
1122 1122
 
1123 1123
 /**
@@ -1125,7 +1125,7 @@  discard block
 block discarded – undo
1125 1125
  */
1126 1126
 function espresso_event_list_title()
1127 1127
 {
1128
-    return EED_Events_Archive::event_list_title();
1128
+	return EED_Events_Archive::event_list_title();
1129 1129
 }
1130 1130
 
1131 1131
 /**
@@ -1134,7 +1134,7 @@  discard block
 block discarded – undo
1134 1134
  */
1135 1135
 function espresso_event_list_css($extra_class = '')
1136 1136
 {
1137
-    return EED_Events_Archive::event_list_css($extra_class);
1137
+	return EED_Events_Archive::event_list_css($extra_class);
1138 1138
 }
1139 1139
 
1140 1140
 /**
@@ -1142,7 +1142,7 @@  discard block
 block discarded – undo
1142 1142
  */
1143 1143
 function espresso_get_event_categories()
1144 1144
 {
1145
-    return EED_Events_Archive::event_categories();
1145
+	return EED_Events_Archive::event_categories();
1146 1146
 }
1147 1147
 
1148 1148
 /**
@@ -1150,7 +1150,7 @@  discard block
 block discarded – undo
1150 1150
  */
1151 1151
 function espresso_display_full_description_in_event_list()
1152 1152
 {
1153
-    return EED_Events_Archive::display_description(2);
1153
+	return EED_Events_Archive::display_description(2);
1154 1154
 }
1155 1155
 
1156 1156
 /**
@@ -1158,7 +1158,7 @@  discard block
 block discarded – undo
1158 1158
  */
1159 1159
 function espresso_display_excerpt_in_event_list()
1160 1160
 {
1161
-    return EED_Events_Archive::display_description(1);
1161
+	return EED_Events_Archive::display_description(1);
1162 1162
 }
1163 1163
 
1164 1164
 /**
@@ -1166,7 +1166,7 @@  discard block
 block discarded – undo
1166 1166
  */
1167 1167
 function espresso_display_ticket_selector_in_event_list()
1168 1168
 {
1169
-    return EED_Events_Archive::display_ticket_selector();
1169
+	return EED_Events_Archive::display_ticket_selector();
1170 1170
 }
1171 1171
 
1172 1172
 /**
@@ -1174,7 +1174,7 @@  discard block
 block discarded – undo
1174 1174
  */
1175 1175
 function espresso_display_venue_in_event_list()
1176 1176
 {
1177
-    return EED_Events_Archive::display_venue();
1177
+	return EED_Events_Archive::display_venue();
1178 1178
 }
1179 1179
 
1180 1180
 /**
@@ -1182,5 +1182,5 @@  discard block
 block discarded – undo
1182 1182
  */
1183 1183
 function espresso_display_datetimes_in_event_list()
1184 1184
 {
1185
-    return EED_Events_Archive::display_datetimes();
1185
+	return EED_Events_Archive::display_datetimes();
1186 1186
 }
Please login to merge, or discard this patch.
modules/event_single/EED_Event_Single.module.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -83,8 +83,8 @@  discard block
 block discarded – undo
83 83
      */
84 84
     public static function set_definitions()
85 85
     {
86
-        define('EVENT_SINGLE_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/');
87
-        define('EVENT_SINGLE_TEMPLATES_PATH', plugin_dir_path(__FILE__) . 'templates/');
86
+        define('EVENT_SINGLE_ASSETS_URL', plugin_dir_url(__FILE__).'assets/');
87
+        define('EVENT_SINGLE_TEMPLATES_PATH', plugin_dir_path(__FILE__).'templates/');
88 88
     }
89 89
 
90 90
 
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
     {
227 227
         global $post;
228 228
         return in_the_loop() && $post->ID === (int) $id
229
-            ? espresso_event_status_banner($post->ID) . $title
229
+            ? espresso_event_status_banner($post->ID).$title
230 230
             : $title;
231 231
     }
232 232
 
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
      */
384 384
     public static function event_datetimes($content)
385 385
     {
386
-        return EEH_Template::locate_template('content-espresso_events-datetimes.php') . $content;
386
+        return EEH_Template::locate_template('content-espresso_events-datetimes.php').$content;
387 387
     }
388 388
 
389 389
 
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
      */
396 396
     public static function event_tickets($content)
397 397
     {
398
-        return EEH_Template::locate_template('content-espresso_events-tickets.php') . $content;
398
+        return EEH_Template::locate_template('content-espresso_events-tickets.php').$content;
399 399
     }
400 400
 
401 401
 
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
      */
420 420
     public static function event_venues($content)
421 421
     {
422
-        return $content . EEH_Template::locate_template('content-espresso_events-venues.php');
422
+        return $content.EEH_Template::locate_template('content-espresso_events-venues.php');
423 423
     }
424 424
 
425 425
 
@@ -449,16 +449,16 @@  discard block
 block discarded – undo
449 449
             && apply_filters('FHEE__EED_Event_Single__wp_enqueue_scripts__enable_css', true)
450 450
         ) {
451 451
             // first check uploads folder
452
-            if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) {
452
+            if (is_readable(get_stylesheet_directory().$this->theme.'/style.css')) {
453 453
                 wp_register_style(
454 454
                     $this->theme,
455
-                    get_stylesheet_directory_uri() . $this->theme . '/style.css',
455
+                    get_stylesheet_directory_uri().$this->theme.'/style.css',
456 456
                     array('dashicons', 'espresso_default')
457 457
                 );
458 458
             } else {
459 459
                 wp_register_style(
460 460
                     $this->theme,
461
-                    EE_TEMPLATES_URL . $this->theme . '/style.css',
461
+                    EE_TEMPLATES_URL.$this->theme.'/style.css',
462 462
                     array('dashicons', 'espresso_default')
463 463
                 );
464 464
             }
Please login to merge, or discard this patch.
Indentation   +469 added lines, -469 removed lines patch added patch discarded remove patch
@@ -14,474 +14,474 @@  discard block
 block discarded – undo
14 14
 class EED_Event_Single extends EED_Module
15 15
 {
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;
21
-
22
-    /**
23
-     * @type bool $using_get_the_excerpt
24
-     */
25
-    protected static $using_get_the_excerpt = false;
26
-
27
-
28
-    /**
29
-     * @type EE_Template_Part_Manager $template_parts
30
-     */
31
-    protected $template_parts;
32
-
33
-
34
-    /**
35
-     * @return EED_Module|EED_Event_Single
36
-     */
37
-    public static function instance()
38
-    {
39
-        return parent::get_instance(__CLASS__);
40
-    }
41
-
42
-
43
-    /**
44
-     * set_hooks - for hooking into EE Core, other modules, etc
45
-     *
46
-     * @return void
47
-     * @throws InvalidArgumentException
48
-     * @throws InvalidDataTypeException
49
-     * @throws InvalidInterfaceException
50
-     */
51
-    public static function set_hooks()
52
-    {
53
-        add_filter('FHEE_run_EE_wp', '__return_true');
54
-        add_action('wp_loaded', array('EED_Event_Single', 'set_definitions'), 2);
55
-        /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_type_definitions */
56
-        $custom_post_type_definitions = LoaderFactory::getLoader()->getShared(
57
-            'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
58
-        );
59
-        $custom_post_types = $custom_post_type_definitions->getDefinitions();
60
-        EE_Config::register_route(
61
-            $custom_post_types['espresso_events']['singular_slug'],
62
-            'Event_Single',
63
-            'run'
64
-        );
65
-    }
66
-
67
-    /**
68
-     * set_hooks_admin - for hooking into EE Admin Core, other modules, etc
69
-     *
70
-     * @return    void
71
-     */
72
-    public static function set_hooks_admin()
73
-    {
74
-        add_action('wp_loaded', array('EED_Event_Single', 'set_definitions'), 2);
75
-    }
76
-
77
-
78
-    /**
79
-     * set_definitions
80
-     *
81
-     * @static
82
-     * @return void
83
-     */
84
-    public static function set_definitions()
85
-    {
86
-        define('EVENT_SINGLE_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/');
87
-        define('EVENT_SINGLE_TEMPLATES_PATH', plugin_dir_path(__FILE__) . 'templates/');
88
-    }
89
-
90
-
91
-    /**
92
-     * set_config
93
-     *
94
-     * @void
95
-     */
96
-    protected function set_config()
97
-    {
98
-        $this->set_config_section('template_settings');
99
-        $this->set_config_class('EE_Event_Single_Config');
100
-        $this->set_config_name('EED_Event_Single');
101
-    }
102
-
103
-
104
-    /**
105
-     * initialize_template_parts
106
-     *
107
-     * @param EE_Config_Base|EE_Event_Single_Config $config
108
-     * @return EE_Template_Part_Manager
109
-     */
110
-    public function initialize_template_parts(EE_Event_Single_Config $config = null)
111
-    {
112
-        /** @type EE_Event_Single_Config $config */
113
-        $config = $config instanceof EE_Event_Single_Config ? $config : $this->config();
114
-        EEH_Autoloader::instance()->register_template_part_autoloaders();
115
-        $template_parts = new EE_Template_Part_Manager();
116
-        $template_parts->add_template_part(
117
-            'tickets',
118
-            esc_html__('Ticket Selector', 'event_espresso'),
119
-            'content-espresso_events-tickets.php',
120
-            $config->display_order_tickets
121
-        );
122
-        $template_parts->add_template_part(
123
-            'datetimes',
124
-            esc_html__('Dates and Times', 'event_espresso'),
125
-            'content-espresso_events-datetimes.php',
126
-            $config->display_order_datetimes
127
-        );
128
-        $template_parts->add_template_part(
129
-            'event',
130
-            esc_html__('Event Description', 'event_espresso'),
131
-            'content-espresso_events-details.php',
132
-            $config->display_order_event
133
-        );
134
-        $template_parts->add_template_part(
135
-            'venue',
136
-            esc_html__('Venue Information', 'event_espresso'),
137
-            'content-espresso_events-venues.php',
138
-            $config->display_order_venue
139
-        );
140
-        do_action('AHEE__EED_Event_Single__initialize_template_parts', $template_parts);
141
-        return $template_parts;
142
-    }
143
-
144
-
145
-    /**
146
-     * run - initial module setup
147
-     *
148
-     * @param WP $WP
149
-     * @return    void
150
-     */
151
-    public function run($WP)
152
-    {
153
-        // ensure valid EE_Events_Single_Config() object exists
154
-        $this->set_config();
155
-        // check what template is loaded
156
-        add_filter('template_include', array($this, 'template_include'), 999, 1);
157
-        add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
158
-        // load css
159
-        add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10);
160
-    }
161
-
162
-
163
-    /**
164
-     * template_include
165
-     *
166
-     * @param    string $template
167
-     * @return    string
168
-     */
169
-    public function template_include($template)
170
-    {
171
-        global $post;
172
-        /** @type EE_Event_Single_Config $config */
173
-        $config = $this->config();
174
-        if ($config->display_status_banner_single) {
175
-            add_filter('the_title', array('EED_Event_Single', 'the_title'), 100, 2);
176
-        }
177
-        // not a custom template?
178
-        if (
179
-            ! post_password_required($post)
180
-            && (
181
-                apply_filters('FHEE__EED_Event_Single__template_include__allow_custom_selected_template', false)
182
-                || EE_Registry::instance()
183
-                              ->load_core('Front_Controller')
184
-                              ->get_selected_template() !== 'single-espresso_events.php'
185
-            )
186
-        ) {
187
-            EEH_Template::load_espresso_theme_functions();
188
-            // then add extra event data via hooks
189
-            add_action('loop_start', array('EED_Event_Single', 'loop_start'));
190
-            add_filter('get_the_excerpt', array('EED_Event_Single', 'get_the_excerpt'), 1, 1);
191
-            add_filter(
192
-                'the_content',
193
-                array('EED_Event_Single', 'event_details'),
194
-                EED_Event_Single::EVENT_DETAILS_PRIORITY
195
-            );
196
-            add_action('loop_end', array('EED_Event_Single', 'loop_end'));
197
-            // don't display entry meta because the existing theme will take car of that
198
-            add_filter('FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false');
199
-        }
200
-        return $template;
201
-    }
202
-
203
-
204
-    /**
205
-     * loop_start
206
-     *
207
-     * @param    array $wp_query_array an array containing the WP_Query object
208
-     * @return    void
209
-     */
210
-    public static function loop_start($wp_query_array)
211
-    {
212
-        global $post;
213
-        do_action('AHEE_event_details_before_post', $post, $wp_query_array);
214
-    }
215
-
216
-
217
-    /**
218
-     * the_title
219
-     *
220
-     * @param    string $title
221
-     * @param    int    $id
222
-     * @return    string
223
-     */
224
-    public static function the_title($title = '', $id = 0)
225
-    {
226
-        global $post;
227
-        return in_the_loop() && $post->ID === (int) $id
228
-            ? espresso_event_status_banner($post->ID) . $title
229
-            : $title;
230
-    }
231
-
232
-
233
-    /**
234
-     * get_the_excerpt
235
-     * kinda hacky, but if a theme is using get_the_excerpt(),
236
-     * then we need to remove our filters on the_content()
237
-     *
238
-     * @param        string $excerpt
239
-     * @return        string
240
-     */
241
-    public static function get_the_excerpt($excerpt = '')
242
-    {
243
-        EED_Event_Single::$using_get_the_excerpt = true;
244
-        add_filter('wp_trim_excerpt', array('EED_Event_Single', 'end_get_the_excerpt'), 999, 1);
245
-        return $excerpt;
246
-    }
247
-
248
-
249
-    /**
250
-     * end_get_the_excerpt
251
-     *
252
-     * @param  string $text
253
-     * @return string
254
-     */
255
-    public static function end_get_the_excerpt($text = '')
256
-    {
257
-        EED_Event_Single::$using_get_the_excerpt = false;
258
-        return $text;
259
-    }
260
-
261
-
262
-    /**
263
-     * event_details
264
-     *
265
-     * @param    string $content
266
-     * @return    string
267
-     */
268
-    public static function event_details($content)
269
-    {
270
-        global $post;
271
-        static $current_post_ID = 0;
272
-        if (
273
-            $current_post_ID !== $post->ID
274
-            && $post->post_type === 'espresso_events'
275
-            && ! EED_Event_Single::$using_get_the_excerpt
276
-            && ! post_password_required()
277
-        ) {
278
-            // Set current post ID to prevent showing content twice, but only if headers have definitely been sent.
279
-            // Reason being is that some plugins, like Yoast, need to run through a copy of the loop early
280
-            // BEFORE headers are sent in order to examine the post content and generate content for the HTML header.
281
-            // We want to allow those plugins to still do their thing and have access to our content, but depending on
282
-            // how your event content is being displayed (shortcode, CPT route, etc), this filter can get applied twice,
283
-            // so the following allows this filter to be applied multiple times, but only once for real
284
-            $current_post_ID = did_action('loop_start') ? $post->ID : 0;
285
-            if (EE_Registry::instance()->CFG->template_settings->EED_Event_Single->use_sortable_display_order) {
286
-                // we need to first remove this callback from being applied to the_content()
287
-                // (otherwise it will recurse and blow up the interweb)
288
-                remove_filter(
289
-                    'the_content',
290
-                    array('EED_Event_Single', 'event_details'),
291
-                    EED_Event_Single::EVENT_DETAILS_PRIORITY
292
-                );
293
-                EED_Event_Single::instance()->template_parts = EED_Event_Single::instance()->initialize_template_parts(
294
-                );
295
-                $content = EEH_Template::locate_template('content-espresso_events-details.php');
296
-                $content = EED_Event_Single::instance()->template_parts->apply_template_part_filters($content);
297
-                add_filter(
298
-                    'the_content',
299
-                    array('EED_Event_Single', 'event_details'),
300
-                    EED_Event_Single::EVENT_DETAILS_PRIORITY
301
-                );
302
-            } else {
303
-                $content = EED_Event_Single::use_filterable_display_order();
304
-            }
305
-        }
306
-        return $content;
307
-    }
308
-
309
-
310
-    /**
311
-     * use_filterable_display_order
312
-     *
313
-     * @return string
314
-     */
315
-    protected static function use_filterable_display_order()
316
-    {
317
-        // since the 'content-espresso_events-details.php' template might be used directly from within a theme,
318
-        // it uses the_content() for displaying the $post->post_content
319
-        // so in order to load a template that uses the_content()
320
-        // from within a callback being used to filter the_content(),
321
-        // we need to first remove this callback from being applied to the_content()
322
-        // (otherwise it will recurse and blow up the interweb)
323
-        remove_filter(
324
-            'the_content',
325
-            array('EED_Event_Single', 'event_details'),
326
-            EED_Event_Single::EVENT_DETAILS_PRIORITY
327
-        );
328
-        // now add additional content
329
-        add_filter(
330
-            'the_content',
331
-            array('EED_Event_Single', 'event_datetimes'),
332
-            EED_Event_Single::EVENT_DATETIMES_PRIORITY,
333
-            1
334
-        );
335
-        add_filter(
336
-            'the_content',
337
-            array('EED_Event_Single', 'event_tickets'),
338
-            EED_Event_Single::EVENT_TICKETS_PRIORITY,
339
-            1
340
-        );
341
-        add_filter(
342
-            'the_content',
343
-            array('EED_Event_Single', 'event_venues'),
344
-            EED_Event_Single::EVENT_VENUES_PRIORITY,
345
-            1
346
-        );
347
-        do_action('AHEE__EED_Event_Single__use_filterable_display_order__after_add_filters');
348
-        // now load our template
349
-        $content = EEH_Template::locate_template('content-espresso_events-details.php');
350
-        // now add our filter back in, plus some others
351
-        add_filter(
352
-            'the_content',
353
-            array('EED_Event_Single', 'event_details'),
354
-            EED_Event_Single::EVENT_DETAILS_PRIORITY
355
-        );
356
-        remove_filter(
357
-            'the_content',
358
-            array('EED_Event_Single', 'event_datetimes'),
359
-            EED_Event_Single::EVENT_DATETIMES_PRIORITY
360
-        );
361
-        remove_filter(
362
-            'the_content',
363
-            array('EED_Event_Single', 'event_tickets'),
364
-            EED_Event_Single::EVENT_TICKETS_PRIORITY
365
-        );
366
-        remove_filter(
367
-            'the_content',
368
-            array('EED_Event_Single', 'event_venues'),
369
-            EED_Event_Single::EVENT_VENUES_PRIORITY
370
-        );
371
-        do_action('AHEE__EED_Event_Single__use_filterable_display_order__after_remove_filters');
372
-        // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt)
373
-        return $content;
374
-    }
375
-
376
-
377
-    /**
378
-     * event_datetimes - adds datetimes ABOVE content
379
-     *
380
-     * @param        string $content
381
-     * @return        string
382
-     */
383
-    public static function event_datetimes($content)
384
-    {
385
-        return EEH_Template::locate_template('content-espresso_events-datetimes.php') . $content;
386
-    }
387
-
388
-
389
-    /**
390
-     * event_tickets - adds tickets ABOVE content (which includes datetimes)
391
-     *
392
-     * @param        string $content
393
-     * @return        string
394
-     */
395
-    public static function event_tickets($content)
396
-    {
397
-        return EEH_Template::locate_template('content-espresso_events-tickets.php') . $content;
398
-    }
399
-
400
-
401
-    /**
402
-     * event_venues
403
-     *
404
-     * @param    string $content
405
-     * @return    string
406
-     */
407
-    public static function event_venue($content)
408
-    {
409
-        return EED_Event_Single::event_venues($content);
410
-    }
411
-
412
-
413
-    /**
414
-     * event_venues - adds venues BELOW content
415
-     *
416
-     * @param        string $content
417
-     * @return        string
418
-     */
419
-    public static function event_venues($content)
420
-    {
421
-        return $content . EEH_Template::locate_template('content-espresso_events-venues.php');
422
-    }
423
-
424
-
425
-    /**
426
-     * loop_end
427
-     *
428
-     * @param        array $wp_query_array an array containing the WP_Query object
429
-     * @return        void
430
-     */
431
-    public static function loop_end($wp_query_array)
432
-    {
433
-        global $post;
434
-        do_action('AHEE_event_details_after_post', $post, $wp_query_array);
435
-    }
436
-
437
-
438
-    /**
439
-     * wp_enqueue_scripts
440
-     *
441
-     * @return    void
442
-     */
443
-    public function wp_enqueue_scripts()
444
-    {
445
-        // get some style
446
-        if (
447
-            apply_filters('FHEE_enable_default_espresso_css', true)
448
-            && apply_filters('FHEE__EED_Event_Single__wp_enqueue_scripts__enable_css', true)
449
-        ) {
450
-            // first check uploads folder
451
-            if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) {
452
-                wp_register_style(
453
-                    $this->theme,
454
-                    get_stylesheet_directory_uri() . $this->theme . '/style.css',
455
-                    array('dashicons', 'espresso_default')
456
-                );
457
-            } else {
458
-                wp_register_style(
459
-                    $this->theme,
460
-                    EE_TEMPLATES_URL . $this->theme . '/style.css',
461
-                    array('dashicons', 'espresso_default')
462
-                );
463
-            }
464
-            wp_enqueue_script($this->theme);
465
-            if (EE_Registry::instance()->CFG->map_settings->use_google_maps) {
466
-                add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11);
467
-            }
468
-        }
469
-    }
470
-
471
-
472
-    /**
473
-     * display_venue
474
-     *
475
-     * @return    bool
476
-     */
477
-    public static function display_venue()
478
-    {
479
-        /** @type EE_Event_Single_Config $config */
480
-        $config = EED_Event_Single::instance()->config();
481
-        $display_venue = $config->display_venue === null ? true : $config->display_venue;
482
-        $venue_name = EEH_Venue_View::venue_name();
483
-        return $display_venue && ! empty($venue_name);
484
-    }
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
+
22
+	/**
23
+	 * @type bool $using_get_the_excerpt
24
+	 */
25
+	protected static $using_get_the_excerpt = false;
26
+
27
+
28
+	/**
29
+	 * @type EE_Template_Part_Manager $template_parts
30
+	 */
31
+	protected $template_parts;
32
+
33
+
34
+	/**
35
+	 * @return EED_Module|EED_Event_Single
36
+	 */
37
+	public static function instance()
38
+	{
39
+		return parent::get_instance(__CLASS__);
40
+	}
41
+
42
+
43
+	/**
44
+	 * set_hooks - for hooking into EE Core, other modules, etc
45
+	 *
46
+	 * @return void
47
+	 * @throws InvalidArgumentException
48
+	 * @throws InvalidDataTypeException
49
+	 * @throws InvalidInterfaceException
50
+	 */
51
+	public static function set_hooks()
52
+	{
53
+		add_filter('FHEE_run_EE_wp', '__return_true');
54
+		add_action('wp_loaded', array('EED_Event_Single', 'set_definitions'), 2);
55
+		/** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_type_definitions */
56
+		$custom_post_type_definitions = LoaderFactory::getLoader()->getShared(
57
+			'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
58
+		);
59
+		$custom_post_types = $custom_post_type_definitions->getDefinitions();
60
+		EE_Config::register_route(
61
+			$custom_post_types['espresso_events']['singular_slug'],
62
+			'Event_Single',
63
+			'run'
64
+		);
65
+	}
66
+
67
+	/**
68
+	 * set_hooks_admin - for hooking into EE Admin Core, other modules, etc
69
+	 *
70
+	 * @return    void
71
+	 */
72
+	public static function set_hooks_admin()
73
+	{
74
+		add_action('wp_loaded', array('EED_Event_Single', 'set_definitions'), 2);
75
+	}
76
+
77
+
78
+	/**
79
+	 * set_definitions
80
+	 *
81
+	 * @static
82
+	 * @return void
83
+	 */
84
+	public static function set_definitions()
85
+	{
86
+		define('EVENT_SINGLE_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/');
87
+		define('EVENT_SINGLE_TEMPLATES_PATH', plugin_dir_path(__FILE__) . 'templates/');
88
+	}
89
+
90
+
91
+	/**
92
+	 * set_config
93
+	 *
94
+	 * @void
95
+	 */
96
+	protected function set_config()
97
+	{
98
+		$this->set_config_section('template_settings');
99
+		$this->set_config_class('EE_Event_Single_Config');
100
+		$this->set_config_name('EED_Event_Single');
101
+	}
102
+
103
+
104
+	/**
105
+	 * initialize_template_parts
106
+	 *
107
+	 * @param EE_Config_Base|EE_Event_Single_Config $config
108
+	 * @return EE_Template_Part_Manager
109
+	 */
110
+	public function initialize_template_parts(EE_Event_Single_Config $config = null)
111
+	{
112
+		/** @type EE_Event_Single_Config $config */
113
+		$config = $config instanceof EE_Event_Single_Config ? $config : $this->config();
114
+		EEH_Autoloader::instance()->register_template_part_autoloaders();
115
+		$template_parts = new EE_Template_Part_Manager();
116
+		$template_parts->add_template_part(
117
+			'tickets',
118
+			esc_html__('Ticket Selector', 'event_espresso'),
119
+			'content-espresso_events-tickets.php',
120
+			$config->display_order_tickets
121
+		);
122
+		$template_parts->add_template_part(
123
+			'datetimes',
124
+			esc_html__('Dates and Times', 'event_espresso'),
125
+			'content-espresso_events-datetimes.php',
126
+			$config->display_order_datetimes
127
+		);
128
+		$template_parts->add_template_part(
129
+			'event',
130
+			esc_html__('Event Description', 'event_espresso'),
131
+			'content-espresso_events-details.php',
132
+			$config->display_order_event
133
+		);
134
+		$template_parts->add_template_part(
135
+			'venue',
136
+			esc_html__('Venue Information', 'event_espresso'),
137
+			'content-espresso_events-venues.php',
138
+			$config->display_order_venue
139
+		);
140
+		do_action('AHEE__EED_Event_Single__initialize_template_parts', $template_parts);
141
+		return $template_parts;
142
+	}
143
+
144
+
145
+	/**
146
+	 * run - initial module setup
147
+	 *
148
+	 * @param WP $WP
149
+	 * @return    void
150
+	 */
151
+	public function run($WP)
152
+	{
153
+		// ensure valid EE_Events_Single_Config() object exists
154
+		$this->set_config();
155
+		// check what template is loaded
156
+		add_filter('template_include', array($this, 'template_include'), 999, 1);
157
+		add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
158
+		// load css
159
+		add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10);
160
+	}
161
+
162
+
163
+	/**
164
+	 * template_include
165
+	 *
166
+	 * @param    string $template
167
+	 * @return    string
168
+	 */
169
+	public function template_include($template)
170
+	{
171
+		global $post;
172
+		/** @type EE_Event_Single_Config $config */
173
+		$config = $this->config();
174
+		if ($config->display_status_banner_single) {
175
+			add_filter('the_title', array('EED_Event_Single', 'the_title'), 100, 2);
176
+		}
177
+		// not a custom template?
178
+		if (
179
+			! post_password_required($post)
180
+			&& (
181
+				apply_filters('FHEE__EED_Event_Single__template_include__allow_custom_selected_template', false)
182
+				|| EE_Registry::instance()
183
+							  ->load_core('Front_Controller')
184
+							  ->get_selected_template() !== 'single-espresso_events.php'
185
+			)
186
+		) {
187
+			EEH_Template::load_espresso_theme_functions();
188
+			// then add extra event data via hooks
189
+			add_action('loop_start', array('EED_Event_Single', 'loop_start'));
190
+			add_filter('get_the_excerpt', array('EED_Event_Single', 'get_the_excerpt'), 1, 1);
191
+			add_filter(
192
+				'the_content',
193
+				array('EED_Event_Single', 'event_details'),
194
+				EED_Event_Single::EVENT_DETAILS_PRIORITY
195
+			);
196
+			add_action('loop_end', array('EED_Event_Single', 'loop_end'));
197
+			// don't display entry meta because the existing theme will take car of that
198
+			add_filter('FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false');
199
+		}
200
+		return $template;
201
+	}
202
+
203
+
204
+	/**
205
+	 * loop_start
206
+	 *
207
+	 * @param    array $wp_query_array an array containing the WP_Query object
208
+	 * @return    void
209
+	 */
210
+	public static function loop_start($wp_query_array)
211
+	{
212
+		global $post;
213
+		do_action('AHEE_event_details_before_post', $post, $wp_query_array);
214
+	}
215
+
216
+
217
+	/**
218
+	 * the_title
219
+	 *
220
+	 * @param    string $title
221
+	 * @param    int    $id
222
+	 * @return    string
223
+	 */
224
+	public static function the_title($title = '', $id = 0)
225
+	{
226
+		global $post;
227
+		return in_the_loop() && $post->ID === (int) $id
228
+			? espresso_event_status_banner($post->ID) . $title
229
+			: $title;
230
+	}
231
+
232
+
233
+	/**
234
+	 * get_the_excerpt
235
+	 * kinda hacky, but if a theme is using get_the_excerpt(),
236
+	 * then we need to remove our filters on the_content()
237
+	 *
238
+	 * @param        string $excerpt
239
+	 * @return        string
240
+	 */
241
+	public static function get_the_excerpt($excerpt = '')
242
+	{
243
+		EED_Event_Single::$using_get_the_excerpt = true;
244
+		add_filter('wp_trim_excerpt', array('EED_Event_Single', 'end_get_the_excerpt'), 999, 1);
245
+		return $excerpt;
246
+	}
247
+
248
+
249
+	/**
250
+	 * end_get_the_excerpt
251
+	 *
252
+	 * @param  string $text
253
+	 * @return string
254
+	 */
255
+	public static function end_get_the_excerpt($text = '')
256
+	{
257
+		EED_Event_Single::$using_get_the_excerpt = false;
258
+		return $text;
259
+	}
260
+
261
+
262
+	/**
263
+	 * event_details
264
+	 *
265
+	 * @param    string $content
266
+	 * @return    string
267
+	 */
268
+	public static function event_details($content)
269
+	{
270
+		global $post;
271
+		static $current_post_ID = 0;
272
+		if (
273
+			$current_post_ID !== $post->ID
274
+			&& $post->post_type === 'espresso_events'
275
+			&& ! EED_Event_Single::$using_get_the_excerpt
276
+			&& ! post_password_required()
277
+		) {
278
+			// Set current post ID to prevent showing content twice, but only if headers have definitely been sent.
279
+			// Reason being is that some plugins, like Yoast, need to run through a copy of the loop early
280
+			// BEFORE headers are sent in order to examine the post content and generate content for the HTML header.
281
+			// We want to allow those plugins to still do their thing and have access to our content, but depending on
282
+			// how your event content is being displayed (shortcode, CPT route, etc), this filter can get applied twice,
283
+			// so the following allows this filter to be applied multiple times, but only once for real
284
+			$current_post_ID = did_action('loop_start') ? $post->ID : 0;
285
+			if (EE_Registry::instance()->CFG->template_settings->EED_Event_Single->use_sortable_display_order) {
286
+				// we need to first remove this callback from being applied to the_content()
287
+				// (otherwise it will recurse and blow up the interweb)
288
+				remove_filter(
289
+					'the_content',
290
+					array('EED_Event_Single', 'event_details'),
291
+					EED_Event_Single::EVENT_DETAILS_PRIORITY
292
+				);
293
+				EED_Event_Single::instance()->template_parts = EED_Event_Single::instance()->initialize_template_parts(
294
+				);
295
+				$content = EEH_Template::locate_template('content-espresso_events-details.php');
296
+				$content = EED_Event_Single::instance()->template_parts->apply_template_part_filters($content);
297
+				add_filter(
298
+					'the_content',
299
+					array('EED_Event_Single', 'event_details'),
300
+					EED_Event_Single::EVENT_DETAILS_PRIORITY
301
+				);
302
+			} else {
303
+				$content = EED_Event_Single::use_filterable_display_order();
304
+			}
305
+		}
306
+		return $content;
307
+	}
308
+
309
+
310
+	/**
311
+	 * use_filterable_display_order
312
+	 *
313
+	 * @return string
314
+	 */
315
+	protected static function use_filterable_display_order()
316
+	{
317
+		// since the 'content-espresso_events-details.php' template might be used directly from within a theme,
318
+		// it uses the_content() for displaying the $post->post_content
319
+		// so in order to load a template that uses the_content()
320
+		// from within a callback being used to filter the_content(),
321
+		// we need to first remove this callback from being applied to the_content()
322
+		// (otherwise it will recurse and blow up the interweb)
323
+		remove_filter(
324
+			'the_content',
325
+			array('EED_Event_Single', 'event_details'),
326
+			EED_Event_Single::EVENT_DETAILS_PRIORITY
327
+		);
328
+		// now add additional content
329
+		add_filter(
330
+			'the_content',
331
+			array('EED_Event_Single', 'event_datetimes'),
332
+			EED_Event_Single::EVENT_DATETIMES_PRIORITY,
333
+			1
334
+		);
335
+		add_filter(
336
+			'the_content',
337
+			array('EED_Event_Single', 'event_tickets'),
338
+			EED_Event_Single::EVENT_TICKETS_PRIORITY,
339
+			1
340
+		);
341
+		add_filter(
342
+			'the_content',
343
+			array('EED_Event_Single', 'event_venues'),
344
+			EED_Event_Single::EVENT_VENUES_PRIORITY,
345
+			1
346
+		);
347
+		do_action('AHEE__EED_Event_Single__use_filterable_display_order__after_add_filters');
348
+		// now load our template
349
+		$content = EEH_Template::locate_template('content-espresso_events-details.php');
350
+		// now add our filter back in, plus some others
351
+		add_filter(
352
+			'the_content',
353
+			array('EED_Event_Single', 'event_details'),
354
+			EED_Event_Single::EVENT_DETAILS_PRIORITY
355
+		);
356
+		remove_filter(
357
+			'the_content',
358
+			array('EED_Event_Single', 'event_datetimes'),
359
+			EED_Event_Single::EVENT_DATETIMES_PRIORITY
360
+		);
361
+		remove_filter(
362
+			'the_content',
363
+			array('EED_Event_Single', 'event_tickets'),
364
+			EED_Event_Single::EVENT_TICKETS_PRIORITY
365
+		);
366
+		remove_filter(
367
+			'the_content',
368
+			array('EED_Event_Single', 'event_venues'),
369
+			EED_Event_Single::EVENT_VENUES_PRIORITY
370
+		);
371
+		do_action('AHEE__EED_Event_Single__use_filterable_display_order__after_remove_filters');
372
+		// we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt)
373
+		return $content;
374
+	}
375
+
376
+
377
+	/**
378
+	 * event_datetimes - adds datetimes ABOVE content
379
+	 *
380
+	 * @param        string $content
381
+	 * @return        string
382
+	 */
383
+	public static function event_datetimes($content)
384
+	{
385
+		return EEH_Template::locate_template('content-espresso_events-datetimes.php') . $content;
386
+	}
387
+
388
+
389
+	/**
390
+	 * event_tickets - adds tickets ABOVE content (which includes datetimes)
391
+	 *
392
+	 * @param        string $content
393
+	 * @return        string
394
+	 */
395
+	public static function event_tickets($content)
396
+	{
397
+		return EEH_Template::locate_template('content-espresso_events-tickets.php') . $content;
398
+	}
399
+
400
+
401
+	/**
402
+	 * event_venues
403
+	 *
404
+	 * @param    string $content
405
+	 * @return    string
406
+	 */
407
+	public static function event_venue($content)
408
+	{
409
+		return EED_Event_Single::event_venues($content);
410
+	}
411
+
412
+
413
+	/**
414
+	 * event_venues - adds venues BELOW content
415
+	 *
416
+	 * @param        string $content
417
+	 * @return        string
418
+	 */
419
+	public static function event_venues($content)
420
+	{
421
+		return $content . EEH_Template::locate_template('content-espresso_events-venues.php');
422
+	}
423
+
424
+
425
+	/**
426
+	 * loop_end
427
+	 *
428
+	 * @param        array $wp_query_array an array containing the WP_Query object
429
+	 * @return        void
430
+	 */
431
+	public static function loop_end($wp_query_array)
432
+	{
433
+		global $post;
434
+		do_action('AHEE_event_details_after_post', $post, $wp_query_array);
435
+	}
436
+
437
+
438
+	/**
439
+	 * wp_enqueue_scripts
440
+	 *
441
+	 * @return    void
442
+	 */
443
+	public function wp_enqueue_scripts()
444
+	{
445
+		// get some style
446
+		if (
447
+			apply_filters('FHEE_enable_default_espresso_css', true)
448
+			&& apply_filters('FHEE__EED_Event_Single__wp_enqueue_scripts__enable_css', true)
449
+		) {
450
+			// first check uploads folder
451
+			if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) {
452
+				wp_register_style(
453
+					$this->theme,
454
+					get_stylesheet_directory_uri() . $this->theme . '/style.css',
455
+					array('dashicons', 'espresso_default')
456
+				);
457
+			} else {
458
+				wp_register_style(
459
+					$this->theme,
460
+					EE_TEMPLATES_URL . $this->theme . '/style.css',
461
+					array('dashicons', 'espresso_default')
462
+				);
463
+			}
464
+			wp_enqueue_script($this->theme);
465
+			if (EE_Registry::instance()->CFG->map_settings->use_google_maps) {
466
+				add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11);
467
+			}
468
+		}
469
+	}
470
+
471
+
472
+	/**
473
+	 * display_venue
474
+	 *
475
+	 * @return    bool
476
+	 */
477
+	public static function display_venue()
478
+	{
479
+		/** @type EE_Event_Single_Config $config */
480
+		$config = EED_Event_Single::instance()->config();
481
+		$display_venue = $config->display_venue === null ? true : $config->display_venue;
482
+		$venue_name = EEH_Venue_View::venue_name();
483
+		return $display_venue && ! empty($venue_name);
484
+	}
485 485
 }
486 486
 
487 487
 
@@ -493,5 +493,5 @@  discard block
 block discarded – undo
493 493
  */
494 494
 function espresso_display_venue_in_event_details()
495 495
 {
496
-    return EED_Event_Single::display_venue();
496
+	return EED_Event_Single::display_venue();
497 497
 }
Please login to merge, or discard this patch.
core/libraries/line_item_display/EE_Line_Item_Display.class.php 1 patch
Indentation   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -15,63 +15,63 @@
 block discarded – undo
15 15
 class EE_Line_Item_Display
16 16
 {
17 17
 
18
-    private $strategy = null;
18
+	private $strategy = null;
19 19
 
20 20
 
21
-    /**
22
-     * @param string $context - where/how the line items are being displayed
23
-     * @param string $other_line_item_display_strategy
24
-     */
25
-    public function __construct($context = '', $other_line_item_display_strategy = '')
26
-    {
27
-        $context = strtolower($context);
28
-        switch ($context) {
29
-            case 'invoice':
30
-                $this->strategy = new EE_Invoice_Line_Item_Display_Strategy();
31
-                break;
32
-            case 'receipt':
33
-                $this->strategy = new EE_Receipt_Line_Item_Display_Strategy();
34
-                break;
35
-            case 'spco':
36
-                $this->strategy = new EE_SPCO_Line_Item_Display_Strategy();
37
-                break;
38
-            default:
39
-                if (
40
-                    ! empty($other_line_item_display_strategy) &&
41
-                    class_exists($other_line_item_display_strategy)
42
-                ) {
43
-                    $this->strategy = new  $other_line_item_display_strategy();
44
-                } else {
45
-                    $this->strategy = new EE_Default_Line_Item_Display_Strategy();
46
-                }
47
-        }
48
-    }
21
+	/**
22
+	 * @param string $context - where/how the line items are being displayed
23
+	 * @param string $other_line_item_display_strategy
24
+	 */
25
+	public function __construct($context = '', $other_line_item_display_strategy = '')
26
+	{
27
+		$context = strtolower($context);
28
+		switch ($context) {
29
+			case 'invoice':
30
+				$this->strategy = new EE_Invoice_Line_Item_Display_Strategy();
31
+				break;
32
+			case 'receipt':
33
+				$this->strategy = new EE_Receipt_Line_Item_Display_Strategy();
34
+				break;
35
+			case 'spco':
36
+				$this->strategy = new EE_SPCO_Line_Item_Display_Strategy();
37
+				break;
38
+			default:
39
+				if (
40
+					! empty($other_line_item_display_strategy) &&
41
+					class_exists($other_line_item_display_strategy)
42
+				) {
43
+					$this->strategy = new  $other_line_item_display_strategy();
44
+				} else {
45
+					$this->strategy = new EE_Default_Line_Item_Display_Strategy();
46
+				}
47
+		}
48
+	}
49 49
 
50
-    /**
51
-     * @param EE_Line_Item $line_item
52
-     * @param array        $options
53
-     * @return mixed
54
-     */
55
-    public function display_line_item(EE_Line_Item $line_item, $options = array())
56
-    {
57
-        return $this->strategy->display_line_item($line_item, $options);
58
-    }
50
+	/**
51
+	 * @param EE_Line_Item $line_item
52
+	 * @param array        $options
53
+	 * @return mixed
54
+	 */
55
+	public function display_line_item(EE_Line_Item $line_item, $options = array())
56
+	{
57
+		return $this->strategy->display_line_item($line_item, $options);
58
+	}
59 59
 
60 60
 
61
-    /**
62
-     * @return float
63
-     */
64
-    public function grand_total()
65
-    {
66
-        return $this->strategy->grand_total();
67
-    }
61
+	/**
62
+	 * @return float
63
+	 */
64
+	public function grand_total()
65
+	{
66
+		return $this->strategy->grand_total();
67
+	}
68 68
 
69 69
 
70
-    /**
71
-     * @return float
72
-     */
73
-    public function total_items()
74
-    {
75
-        return $this->strategy->total_items();
76
-    }
70
+	/**
71
+	 * @return float
72
+	 */
73
+	public function total_items()
74
+	{
75
+		return $this->strategy->total_items();
76
+	}
77 77
 }
Please login to merge, or discard this patch.
libraries/line_item_display/EE_SPCO_Line_Item_Display_Strategy.strategy.php 2 patches
Indentation   +659 added lines, -659 removed lines patch added patch discarded remove patch
@@ -12,663 +12,663 @@
 block discarded – undo
12 12
 class EE_SPCO_Line_Item_Display_Strategy implements EEI_Line_Item_Display
13 13
 {
14 14
 
15
-    /**
16
-     * array of events
17
-     *
18
-     * @type EE_Line_Item[] $_events
19
-     */
20
-    private $_events = array();
21
-
22
-    /**
23
-     * whether to display the taxes row or not
24
-     *
25
-     * @type bool $_show_taxes
26
-     */
27
-    private $_show_taxes = false;
28
-
29
-    /**
30
-     * html for any tax rows
31
-     *
32
-     * @type string $_show_taxes
33
-     */
34
-    private $_taxes_html = '';
35
-
36
-    /**
37
-     * total amount including tax we can bill for at this time
38
-     *
39
-     * @type float $_grand_total
40
-     */
41
-    private $_grand_total = 0.00;
42
-
43
-    /**
44
-     * total number of items being billed for
45
-     *
46
-     * @type int $_total_items
47
-     */
48
-    private $_total_items = 0;
49
-
50
-
51
-
52
-    /**
53
-     * @return float
54
-     */
55
-    public function grand_total()
56
-    {
57
-        return $this->_grand_total;
58
-    }
59
-
60
-
61
-
62
-    /**
63
-     * @return int
64
-     */
65
-    public function total_items()
66
-    {
67
-        return $this->_total_items;
68
-    }
69
-
70
-
71
-
72
-    /**
73
-     * @param EE_Line_Item $line_item
74
-     * @param array        $options
75
-     * @param EE_Line_Item $parent_line_item
76
-     * @return mixed
77
-     * @throws EE_Error
78
-     */
79
-    public function display_line_item(
80
-        EE_Line_Item $line_item,
81
-        $options = array(),
82
-        EE_Line_Item $parent_line_item = null
83
-    ) {
84
-        $html = '';
85
-        // set some default options and merge with incoming
86
-        $default_options = array(
87
-            'show_desc' => true,  //    true        false
88
-            'odd'       => false,
89
-        );
90
-        $options = array_merge($default_options, (array) $options);
91
-        switch ($line_item->type()) {
92
-            case EEM_Line_Item::type_line_item:
93
-                $this->_show_taxes = $line_item->is_taxable() ? true : $this->_show_taxes;
94
-                if ($line_item->OBJ_type() === 'Ticket') {
95
-                    // item row
96
-                    $html .= $this->_ticket_row($line_item, $options);
97
-                } else {
98
-                    // item row
99
-                    $html .= $this->_item_row($line_item, $options);
100
-                }
101
-                if (
102
-                    apply_filters(
103
-                        'FHEE__EE_SPCO_Line_Item_Display_Strategy__display_line_item__display_sub_line_items',
104
-                        true
105
-                    )
106
-                ) {
107
-                    // got any kids?
108
-                    foreach ($line_item->children() as $child_line_item) {
109
-                        $html .= $this->display_line_item($child_line_item, $options, $line_item);
110
-                    }
111
-                }
112
-                break;
113
-            case EEM_Line_Item::type_sub_line_item:
114
-                $html .= $this->_sub_item_row($line_item, $options, $parent_line_item);
115
-                break;
116
-            case EEM_Line_Item::type_sub_total:
117
-                static $sub_total = 0;
118
-                $event_sub_total = 0;
119
-                $text = esc_html__('Sub-Total', 'event_espresso');
120
-                if ($line_item->OBJ_type() === 'Event') {
121
-                    $options['event_id'] = $event_id = $line_item->OBJ_ID();
122
-                    if (! isset($this->_events[ $options['event_id'] ])) {
123
-                        $event = EEM_Event::instance()->get_one_by_ID($options['event_id']);
124
-                        // if event has default reg status of Not Approved, then don't display info on it
125
-                        if (
126
-                            $event instanceof EE_Event
127
-                            && $event->default_registration_status() === EEM_Registration::status_id_not_approved
128
-                        ) {
129
-                            $display_event = false;
130
-                            // unless there are registrations for it that are returning to pay
131
-                            if (isset($options['registrations']) && is_array($options['registrations'])) {
132
-                                foreach ($options['registrations'] as $registration) {
133
-                                    if (! $registration instanceof EE_Registration) {
134
-                                        continue;
135
-                                    }
136
-                                    $display_event = $registration->event_ID() === $options['event_id']
137
-                                                     && $registration->status_ID() !== EEM_Registration::status_id_not_approved
138
-                                        ? true
139
-                                        : $display_event;
140
-                                }
141
-                            }
142
-                            if (! $display_event) {
143
-                                return '';
144
-                            }
145
-                        }
146
-                        $this->_events[ $options['event_id'] ] = 0;
147
-                        $html .= $this->_event_row($line_item);
148
-                        $text = esc_html__('Event Sub-Total', 'event_espresso');
149
-                    }
150
-                }
151
-                $child_line_items = $line_item->children();
152
-                // loop thru children
153
-                foreach ($child_line_items as $child_line_item) {
154
-                    // recursively feed children back into this method
155
-                    $html .= $this->display_line_item($child_line_item, $options, $line_item);
156
-                }
157
-                $event_sub_total += isset($options['event_id']) ? $this->_events[ $options['event_id'] ] : 0;
158
-                $sub_total += $event_sub_total;
159
-                if (
160
-                    (
161
-                        // event subtotals
162
-                        $line_item->code() !== 'pre-tax-subtotal' && count($child_line_items) > 1
163
-                    )
164
-                    || (
165
-                        // pre-tax subtotals
166
-                        $line_item->code() === 'pre-tax-subtotal' && count($this->_events) > 1
167
-                    )
168
-                ) {
169
-                    $options['sub_total'] = $line_item->OBJ_type() === 'Event' ? $event_sub_total : $sub_total;
170
-                    $html .= $this->_sub_total_row($line_item, $text, $options);
171
-                }
172
-                break;
173
-            case EEM_Line_Item::type_tax:
174
-                if ($this->_show_taxes) {
175
-                    $this->_taxes_html .= $this->_tax_row($line_item, $options);
176
-                }
177
-                break;
178
-            case EEM_Line_Item::type_tax_sub_total:
179
-                if ($this->_show_taxes) {
180
-                    $child_line_items = $line_item->children();
181
-                    // loop thru children
182
-                    foreach ($child_line_items as $child_line_item) {
183
-                        // recursively feed children back into this method
184
-                        $html .= $this->display_line_item($child_line_item, $options, $line_item);
185
-                    }
186
-                    if (count($child_line_items) > 1) {
187
-                        $this->_taxes_html .= $this->_total_tax_row($line_item, esc_html__('Tax Total', 'event_espresso'));
188
-                    }
189
-                }
190
-                break;
191
-            case EEM_Line_Item::type_total:
192
-                // get all child line items
193
-                $children = $line_item->children();
194
-                // loop thru all non-tax child line items
195
-                foreach ($children as $child_line_item) {
196
-                    if ($child_line_item->type() !== EEM_Line_Item::type_tax_sub_total) {
197
-                        // recursively feed children back into this method
198
-                        $html .= $this->display_line_item($child_line_item, $options, $line_item);
199
-                    }
200
-                }
201
-                // now loop thru  tax child line items
202
-                foreach ($children as $child_line_item) {
203
-                    if ($child_line_item->type() === EEM_Line_Item::type_tax_sub_total) {
204
-                        // recursively feed children back into this method
205
-                        $html .= $this->display_line_item($child_line_item, $options, $line_item);
206
-                    }
207
-                }
208
-                $html .= $this->_taxes_html;
209
-                $html .= $this->_total_row($line_item, esc_html__('Total', 'event_espresso'));
210
-                $html .= $this->_payments_and_amount_owing_rows($line_item, $options);
211
-                break;
212
-        }
213
-        return $html;
214
-    }
215
-
216
-
217
-
218
-    /**
219
-     * _event_row - basically a Heading row displayed once above each event's ticket rows
220
-     *
221
-     * @param EE_Line_Item $line_item
222
-     * @return mixed
223
-     */
224
-    private function _event_row(EE_Line_Item $line_item)
225
-    {
226
-        // start of row
227
-        $html = EEH_HTML::tr('', 'event-cart-total-row', 'total_tr odd');
228
-        // event name td
229
-        $html .= EEH_HTML::td(
230
-            EEH_HTML::strong($line_item->name()),
231
-            '',
232
-            'event-header',
233
-            '',
234
-            ' colspan="4"'
235
-        );
236
-        // end of row
237
-        $html .= EEH_HTML::trx();
238
-        return $html;
239
-    }
240
-
241
-
242
-
243
-    /**
244
-     * _ticket_row
245
-     *
246
-     * @param EE_Line_Item $line_item
247
-     * @param array        $options
248
-     * @return mixed
249
-     * @throws EE_Error
250
-     */
251
-    private function _ticket_row(EE_Line_Item $line_item, $options = array())
252
-    {
253
-        // start of row
254
-        $row_class = $options['odd'] ? 'item odd' : 'item';
255
-        $html = EEH_HTML::tr('', '', $row_class);
256
-        // name && desc
257
-        $name_and_desc = apply_filters(
258
-            'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name',
259
-            $line_item->name(),
260
-            $line_item
261
-        );
262
-        $name_and_desc .= apply_filters(
263
-            'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc',
264
-            (
265
-                $options['show_desc']
266
-                    ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>'
267
-                    : ''
268
-            ),
269
-            $line_item,
270
-            $options
271
-        );
272
-        $name_and_desc .= $line_item->is_taxable() ? ' * ' : '';
273
-        $name_and_desc = apply_filters(
274
-            'FHEE__EE_SPCO_Line_Item_Display_Strategy___ticket_row__name_and_desc',
275
-            $name_and_desc,
276
-            $line_item,
277
-            $options
278
-        );
279
-
280
-        // name td
281
-        $html .= EEH_HTML::td( /*__FUNCTION__ .*/
282
-            $name_and_desc,
283
-            '',
284
-            'item_l'
285
-        );
286
-        // price td
287
-        $price = apply_filters(
288
-            'FHEE__EE_SPCO_Line_Item_Display_Strategy___ticket_row__price',
289
-            $line_item->unit_price_no_code(),
290
-            $line_item
291
-        );
292
-        $html .= EEH_HTML::td($price, '', 'item_c jst-rght');
293
-        // quantity td
294
-        $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght');
295
-        $this->_total_items += $line_item->quantity();
296
-        // determine total for line item
297
-        $total = apply_filters(
298
-            'FHEE__EE_SPCO_Line_Item_Display_Strategy___ticket_row__total',
299
-            $line_item->total(),
300
-            $line_item
301
-        );
302
-        $this->_events[ $options['event_id'] ] += $total;
303
-        // total td
304
-        $html .= EEH_HTML::td(
305
-            EEH_Template::format_currency($total, false, false),
306
-            '',
307
-            'item_r jst-rght'
308
-        );
309
-        // end of row
310
-        $html .= EEH_HTML::trx();
311
-        return $html;
312
-    }
313
-
314
-
315
-
316
-    /**
317
-     * _item_row
318
-     *
319
-     * @param EE_Line_Item $line_item
320
-     * @param array        $options
321
-     * @return mixed
322
-     * @throws EE_Error
323
-     */
324
-    private function _item_row(EE_Line_Item $line_item, $options = array())
325
-    {
326
-        // start of row
327
-        $row_class = $options['odd'] ? 'item odd' : 'item';
328
-        $html = EEH_HTML::tr('', '', $row_class);
329
-        $obj_name = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n() . ': ' : '';
330
-        // name && desc
331
-        $name_and_desc = apply_filters(
332
-            'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name',
333
-            $obj_name . $line_item->name(),
334
-            $line_item
335
-        );
336
-        $name_and_desc .= apply_filters(
337
-            'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc',
338
-            (
339
-                $options['show_desc']
340
-                ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>'
341
-                : ''
342
-            ),
343
-            $line_item,
344
-            $options
345
-        );
346
-        $name_and_desc .= $line_item->is_taxable() ? ' * ' : '';
347
-        $name_and_desc = apply_filters(
348
-            'FHEE__EE_SPCO_Line_Item_Display_Strategy___item_row__name_and_desc',
349
-            $name_and_desc,
350
-            $line_item,
351
-            $options
352
-        );
353
-
354
-        // name td
355
-        $html .= EEH_HTML::td($name_and_desc, '', 'item_l');
356
-        // price td
357
-        if ($line_item->is_percent()) {
358
-            $html .= EEH_HTML::td($line_item->percent() . '%', '', 'item_c jst-rght');
359
-        } else {
360
-            $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght');
361
-        }
362
-        // quantity td
363
-        $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght');
364
-        // $total = $line_item->total() * $line_item->quantity();
365
-        $total = $line_item->total();
366
-        if (isset($options['event_id'], $this->_events[ $options['event_id'] ])) {
367
-            $this->_events[ $options['event_id'] ] += $total;
368
-        }
369
-        // total td
370
-        $html .= EEH_HTML::td(
371
-            EEH_Template::format_currency($total, false, false),
372
-            '',
373
-            'item_r jst-rght'
374
-        );
375
-        // end of row
376
-        $html .= EEH_HTML::trx();
377
-        return $html;
378
-    }
379
-
380
-
381
-
382
-    /**
383
-     * _sub_item_row
384
-     *
385
-     * @param EE_Line_Item $line_item
386
-     * @param array        $options
387
-     * @param EE_Line_Item $parent_line_item
388
-     * @return mixed
389
-     * @throws EE_Error
390
-     */
391
-    private function _sub_item_row(EE_Line_Item $line_item, $options = array(), EE_Line_Item $parent_line_item = null)
392
-    {
393
-        if (
394
-            $parent_line_item instanceof  EE_Line_Item
395
-            && $line_item->children() === array()
396
-            && $line_item->name() === $parent_line_item->name()
397
-            && apply_filters(
398
-                'FHEE__EE_SPCO_Line_Item_Display_Strategy___sub_item_row__hide_main_sub_line_item',
399
-                true
400
-            )
401
-        ) {
402
-            return '';
403
-        }
404
-        // start of row
405
-        $html = EEH_HTML::tr('', '', 'item sub-item-row');
406
-        // name && desc
407
-        $name_and_desc = EEH_HTML::span('', '', 'sub-item-row-bullet dashicons dashicons-arrow-right')
408
-                         . $line_item->name();
409
-        $name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: '
410
-                                                  . $line_item->desc()
411
-                                                  . '</span>' : '';
412
-        // name td
413
-        $html .= EEH_HTML::td($name_and_desc, '', 'item_l sub-item');
414
-        $qty = $parent_line_item instanceof EE_Line_Item ? $parent_line_item->quantity() : 1;
415
-        // discount/surcharge td
416
-        if ($line_item->is_percent()) {
417
-            $html .= EEH_HTML::td(
418
-                EEH_Template::format_currency(
419
-                    $line_item->total() / $qty,
420
-                    false,
421
-                    false
422
-                ),
423
-                '',
424
-                'item_c jst-rght'
425
-            );
426
-        } else {
427
-            $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght');
428
-        }
429
-        // no quantity td
430
-        $html .= EEH_HTML::td();
431
-        // no total td
432
-        $html .= EEH_HTML::td();
433
-        // end of row
434
-        $html .= EEH_HTML::trx();
435
-        $html = apply_filters(
436
-            'FHEE__EE_SPCO_Line_Item_Display_Strategy___sub_item_row__html',
437
-            $html,
438
-            $line_item,
439
-            $options,
440
-            $parent_line_item
441
-        );
442
-        return $html;
443
-    }
444
-
445
-
446
-
447
-    /**
448
-     * _tax_row
449
-     *
450
-     * @param EE_Line_Item $line_item
451
-     * @param array        $options
452
-     * @return mixed
453
-     * @throws EE_Error
454
-     */
455
-    private function _tax_row(EE_Line_Item $line_item, $options = array())
456
-    {
457
-        // start of row
458
-        $html = EEH_HTML::tr('', 'item sub-item tax-total');
459
-        // name && desc
460
-        $name_and_desc = $line_item->name();
461
-        $name_and_desc .= '<span class="smaller-text lt-grey-text" style="margin:0 0 0 2em;">'
462
-                          . esc_html__(' * taxable items', 'event_espresso') . '</span>';
463
-        $name_and_desc .= $options['show_desc'] ? '<br/>' . $line_item->desc() : '';
464
-        // name td
465
-        $html .= EEH_HTML::td( /*__FUNCTION__ .*/
466
-            $name_and_desc,
467
-            '',
468
-            'item_l sub-item'
469
-        );
470
-        // percent td
471
-        $html .= EEH_HTML::td($line_item->percent() . '%', '', ' jst-rght', '');
472
-        // empty td (price)
473
-        $html .= EEH_HTML::td(EEH_HTML::nbsp());
474
-        // total td
475
-        $html .= EEH_HTML::td(
476
-            EEH_Template::format_currency(
477
-                $line_item->total(),
478
-                false,
479
-                false
480
-            ),
481
-            '',
482
-            'item_r jst-rght'
483
-        );
484
-        // end of row
485
-        $html .= EEH_HTML::trx();
486
-        return $html;
487
-    }
488
-
489
-
490
-
491
-    /**
492
-     * _total_row
493
-     *
494
-     * @param EE_Line_Item $line_item
495
-     * @param string       $text
496
-     * @return mixed
497
-     * @throws EE_Error
498
-     */
499
-    private function _total_tax_row(EE_Line_Item $line_item, $text = '')
500
-    {
501
-        $html = '';
502
-        if ($line_item->total()) {
503
-            // start of row
504
-            $html = EEH_HTML::tr('', '', 'total_tr odd');
505
-            // total td
506
-            $html .= EEH_HTML::td(
507
-                $text,
508
-                '',
509
-                'total_currency total jst-rght',
510
-                '',
511
-                ' colspan="2"'
512
-            );
513
-            // empty td (price)
514
-            $html .= EEH_HTML::td(EEH_HTML::nbsp());
515
-            // total td
516
-            $html .= EEH_HTML::td(
517
-                EEH_Template::format_currency($line_item->total(), false, false),
518
-                '',
519
-                'total jst-rght'
520
-            );
521
-            // end of row
522
-            $html .= EEH_HTML::trx();
523
-        }
524
-        return $html;
525
-    }
526
-
527
-
528
-
529
-    /**
530
-     * _total_row
531
-     *
532
-     * @param EE_Line_Item $line_item
533
-     * @param string       $text
534
-     * @param array        $options
535
-     * @return mixed
536
-     * @throws EE_Error
537
-     */
538
-    private function _sub_total_row(EE_Line_Item $line_item, $text = '', $options = array())
539
-    {
540
-        $html = '';
541
-        if ($line_item->total()) {
542
-            // start of row
543
-            $html = EEH_HTML::tr('', '', 'total_tr odd');
544
-            // total td
545
-            $html .= EEH_HTML::td(
546
-                $text,
547
-                '',
548
-                'total_currency total jst-rght',
549
-                '',
550
-                ' colspan="3"'
551
-            );
552
-            // total td
553
-            $html .= EEH_HTML::td(
554
-                EEH_Template::format_currency($options['sub_total'], false, false),
555
-                '',
556
-                'total jst-rght'
557
-            );
558
-            // end of row
559
-            $html .= EEH_HTML::trx();
560
-        }
561
-        return $html;
562
-    }
563
-
564
-
565
-
566
-    /**
567
-     * _total_row
568
-     *
569
-     * @param EE_Line_Item $line_item
570
-     * @param string       $text
571
-     * @return mixed
572
-     * @throws EE_Error
573
-     */
574
-    private function _total_row(EE_Line_Item $line_item, $text = '')
575
-    {
576
-        // start of row
577
-        $html = EEH_HTML::tr('', '', 'spco-grand-total total_tr odd');
578
-        // total td
579
-        $html .= EEH_HTML::td($text, '', 'total_currency total jst-rght', '', ' colspan="3"');
580
-        // total td
581
-        $html .= EEH_HTML::td(
582
-            EEH_Template::format_currency($line_item->total(), false, false),
583
-            '',
584
-            'total jst-rght'
585
-        );
586
-        // end of row
587
-        $html .= EEH_HTML::trx();
588
-        return $html;
589
-    }
590
-
591
-
592
-
593
-    /**
594
-     * _payments_and_amount_owing_rows
595
-     *
596
-     * @param EE_Line_Item $line_item
597
-     * @param array        $options
598
-     * @return mixed
599
-     * @throws EE_Error
600
-     */
601
-    private function _payments_and_amount_owing_rows(EE_Line_Item $line_item, $options = array())
602
-    {
603
-        $html = '';
604
-        $owing = $line_item->total();
605
-        $transaction = EEM_Transaction::instance()->get_one_by_ID($line_item->TXN_ID());
606
-        if ($transaction instanceof EE_Transaction) {
607
-            $registration_payments = array();
608
-            $registrations = ! empty($options['registrations'])
609
-                ? $options['registrations']
610
-                : $transaction->registrations();
611
-            foreach ($registrations as $registration) {
612
-                if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) {
613
-                    $registration_payments += $registration->registration_payments();
614
-                }
615
-            }
616
-            if (! empty($registration_payments)) {
617
-                foreach ($registration_payments as $registration_payment) {
618
-                    if ($registration_payment instanceof EE_Registration_Payment) {
619
-                        $owing -= $registration_payment->amount();
620
-                        $payment = $registration_payment->payment();
621
-                        $payment_desc = '';
622
-                        if ($payment instanceof EE_Payment) {
623
-                            $payment_desc = sprintf(
624
-                                esc_html__('Payment%1$s Received: %2$s', 'event_espresso'),
625
-                                $payment->txn_id_chq_nmbr() !== ''
626
-                                    ? ' <span class="small-text">(#' . $payment->txn_id_chq_nmbr() . ')</span> '
627
-                                    : '',
628
-                                $payment->timestamp()
629
-                            );
630
-                        }
631
-                        // start of row
632
-                        $html .= EEH_HTML::tr('', '', 'total_tr odd');
633
-                        // payment desc
634
-                        $html .= EEH_HTML::td($payment_desc, '', '', '', ' colspan="3"');
635
-                        // total td
636
-                        $html .= EEH_HTML::td(
637
-                            EEH_Template::format_currency(
638
-                                $registration_payment->amount(),
639
-                                false,
640
-                                false
641
-                            ),
642
-                            '',
643
-                            'total jst-rght'
644
-                        );
645
-                        // end of row
646
-                        $html .= EEH_HTML::trx();
647
-                    }
648
-                }
649
-                if ($line_item->total()) {
650
-                    // start of row
651
-                    $html .= EEH_HTML::tr('', '', 'total_tr odd');
652
-                    // total td
653
-                    $html .= EEH_HTML::td(
654
-                        esc_html__('Amount Owing', 'event_espresso'),
655
-                        '',
656
-                        'total_currency total jst-rght',
657
-                        '',
658
-                        ' colspan="3"'
659
-                    );
660
-                    // total td
661
-                    $html .= EEH_HTML::td(
662
-                        EEH_Template::format_currency($owing, false, false),
663
-                        '',
664
-                        'total jst-rght'
665
-                    );
666
-                    // end of row
667
-                    $html .= EEH_HTML::trx();
668
-                }
669
-            }
670
-        }
671
-        $this->_grand_total = $owing;
672
-        return $html;
673
-    }
15
+	/**
16
+	 * array of events
17
+	 *
18
+	 * @type EE_Line_Item[] $_events
19
+	 */
20
+	private $_events = array();
21
+
22
+	/**
23
+	 * whether to display the taxes row or not
24
+	 *
25
+	 * @type bool $_show_taxes
26
+	 */
27
+	private $_show_taxes = false;
28
+
29
+	/**
30
+	 * html for any tax rows
31
+	 *
32
+	 * @type string $_show_taxes
33
+	 */
34
+	private $_taxes_html = '';
35
+
36
+	/**
37
+	 * total amount including tax we can bill for at this time
38
+	 *
39
+	 * @type float $_grand_total
40
+	 */
41
+	private $_grand_total = 0.00;
42
+
43
+	/**
44
+	 * total number of items being billed for
45
+	 *
46
+	 * @type int $_total_items
47
+	 */
48
+	private $_total_items = 0;
49
+
50
+
51
+
52
+	/**
53
+	 * @return float
54
+	 */
55
+	public function grand_total()
56
+	{
57
+		return $this->_grand_total;
58
+	}
59
+
60
+
61
+
62
+	/**
63
+	 * @return int
64
+	 */
65
+	public function total_items()
66
+	{
67
+		return $this->_total_items;
68
+	}
69
+
70
+
71
+
72
+	/**
73
+	 * @param EE_Line_Item $line_item
74
+	 * @param array        $options
75
+	 * @param EE_Line_Item $parent_line_item
76
+	 * @return mixed
77
+	 * @throws EE_Error
78
+	 */
79
+	public function display_line_item(
80
+		EE_Line_Item $line_item,
81
+		$options = array(),
82
+		EE_Line_Item $parent_line_item = null
83
+	) {
84
+		$html = '';
85
+		// set some default options and merge with incoming
86
+		$default_options = array(
87
+			'show_desc' => true,  //    true        false
88
+			'odd'       => false,
89
+		);
90
+		$options = array_merge($default_options, (array) $options);
91
+		switch ($line_item->type()) {
92
+			case EEM_Line_Item::type_line_item:
93
+				$this->_show_taxes = $line_item->is_taxable() ? true : $this->_show_taxes;
94
+				if ($line_item->OBJ_type() === 'Ticket') {
95
+					// item row
96
+					$html .= $this->_ticket_row($line_item, $options);
97
+				} else {
98
+					// item row
99
+					$html .= $this->_item_row($line_item, $options);
100
+				}
101
+				if (
102
+					apply_filters(
103
+						'FHEE__EE_SPCO_Line_Item_Display_Strategy__display_line_item__display_sub_line_items',
104
+						true
105
+					)
106
+				) {
107
+					// got any kids?
108
+					foreach ($line_item->children() as $child_line_item) {
109
+						$html .= $this->display_line_item($child_line_item, $options, $line_item);
110
+					}
111
+				}
112
+				break;
113
+			case EEM_Line_Item::type_sub_line_item:
114
+				$html .= $this->_sub_item_row($line_item, $options, $parent_line_item);
115
+				break;
116
+			case EEM_Line_Item::type_sub_total:
117
+				static $sub_total = 0;
118
+				$event_sub_total = 0;
119
+				$text = esc_html__('Sub-Total', 'event_espresso');
120
+				if ($line_item->OBJ_type() === 'Event') {
121
+					$options['event_id'] = $event_id = $line_item->OBJ_ID();
122
+					if (! isset($this->_events[ $options['event_id'] ])) {
123
+						$event = EEM_Event::instance()->get_one_by_ID($options['event_id']);
124
+						// if event has default reg status of Not Approved, then don't display info on it
125
+						if (
126
+							$event instanceof EE_Event
127
+							&& $event->default_registration_status() === EEM_Registration::status_id_not_approved
128
+						) {
129
+							$display_event = false;
130
+							// unless there are registrations for it that are returning to pay
131
+							if (isset($options['registrations']) && is_array($options['registrations'])) {
132
+								foreach ($options['registrations'] as $registration) {
133
+									if (! $registration instanceof EE_Registration) {
134
+										continue;
135
+									}
136
+									$display_event = $registration->event_ID() === $options['event_id']
137
+													 && $registration->status_ID() !== EEM_Registration::status_id_not_approved
138
+										? true
139
+										: $display_event;
140
+								}
141
+							}
142
+							if (! $display_event) {
143
+								return '';
144
+							}
145
+						}
146
+						$this->_events[ $options['event_id'] ] = 0;
147
+						$html .= $this->_event_row($line_item);
148
+						$text = esc_html__('Event Sub-Total', 'event_espresso');
149
+					}
150
+				}
151
+				$child_line_items = $line_item->children();
152
+				// loop thru children
153
+				foreach ($child_line_items as $child_line_item) {
154
+					// recursively feed children back into this method
155
+					$html .= $this->display_line_item($child_line_item, $options, $line_item);
156
+				}
157
+				$event_sub_total += isset($options['event_id']) ? $this->_events[ $options['event_id'] ] : 0;
158
+				$sub_total += $event_sub_total;
159
+				if (
160
+					(
161
+						// event subtotals
162
+						$line_item->code() !== 'pre-tax-subtotal' && count($child_line_items) > 1
163
+					)
164
+					|| (
165
+						// pre-tax subtotals
166
+						$line_item->code() === 'pre-tax-subtotal' && count($this->_events) > 1
167
+					)
168
+				) {
169
+					$options['sub_total'] = $line_item->OBJ_type() === 'Event' ? $event_sub_total : $sub_total;
170
+					$html .= $this->_sub_total_row($line_item, $text, $options);
171
+				}
172
+				break;
173
+			case EEM_Line_Item::type_tax:
174
+				if ($this->_show_taxes) {
175
+					$this->_taxes_html .= $this->_tax_row($line_item, $options);
176
+				}
177
+				break;
178
+			case EEM_Line_Item::type_tax_sub_total:
179
+				if ($this->_show_taxes) {
180
+					$child_line_items = $line_item->children();
181
+					// loop thru children
182
+					foreach ($child_line_items as $child_line_item) {
183
+						// recursively feed children back into this method
184
+						$html .= $this->display_line_item($child_line_item, $options, $line_item);
185
+					}
186
+					if (count($child_line_items) > 1) {
187
+						$this->_taxes_html .= $this->_total_tax_row($line_item, esc_html__('Tax Total', 'event_espresso'));
188
+					}
189
+				}
190
+				break;
191
+			case EEM_Line_Item::type_total:
192
+				// get all child line items
193
+				$children = $line_item->children();
194
+				// loop thru all non-tax child line items
195
+				foreach ($children as $child_line_item) {
196
+					if ($child_line_item->type() !== EEM_Line_Item::type_tax_sub_total) {
197
+						// recursively feed children back into this method
198
+						$html .= $this->display_line_item($child_line_item, $options, $line_item);
199
+					}
200
+				}
201
+				// now loop thru  tax child line items
202
+				foreach ($children as $child_line_item) {
203
+					if ($child_line_item->type() === EEM_Line_Item::type_tax_sub_total) {
204
+						// recursively feed children back into this method
205
+						$html .= $this->display_line_item($child_line_item, $options, $line_item);
206
+					}
207
+				}
208
+				$html .= $this->_taxes_html;
209
+				$html .= $this->_total_row($line_item, esc_html__('Total', 'event_espresso'));
210
+				$html .= $this->_payments_and_amount_owing_rows($line_item, $options);
211
+				break;
212
+		}
213
+		return $html;
214
+	}
215
+
216
+
217
+
218
+	/**
219
+	 * _event_row - basically a Heading row displayed once above each event's ticket rows
220
+	 *
221
+	 * @param EE_Line_Item $line_item
222
+	 * @return mixed
223
+	 */
224
+	private function _event_row(EE_Line_Item $line_item)
225
+	{
226
+		// start of row
227
+		$html = EEH_HTML::tr('', 'event-cart-total-row', 'total_tr odd');
228
+		// event name td
229
+		$html .= EEH_HTML::td(
230
+			EEH_HTML::strong($line_item->name()),
231
+			'',
232
+			'event-header',
233
+			'',
234
+			' colspan="4"'
235
+		);
236
+		// end of row
237
+		$html .= EEH_HTML::trx();
238
+		return $html;
239
+	}
240
+
241
+
242
+
243
+	/**
244
+	 * _ticket_row
245
+	 *
246
+	 * @param EE_Line_Item $line_item
247
+	 * @param array        $options
248
+	 * @return mixed
249
+	 * @throws EE_Error
250
+	 */
251
+	private function _ticket_row(EE_Line_Item $line_item, $options = array())
252
+	{
253
+		// start of row
254
+		$row_class = $options['odd'] ? 'item odd' : 'item';
255
+		$html = EEH_HTML::tr('', '', $row_class);
256
+		// name && desc
257
+		$name_and_desc = apply_filters(
258
+			'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name',
259
+			$line_item->name(),
260
+			$line_item
261
+		);
262
+		$name_and_desc .= apply_filters(
263
+			'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc',
264
+			(
265
+				$options['show_desc']
266
+					? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>'
267
+					: ''
268
+			),
269
+			$line_item,
270
+			$options
271
+		);
272
+		$name_and_desc .= $line_item->is_taxable() ? ' * ' : '';
273
+		$name_and_desc = apply_filters(
274
+			'FHEE__EE_SPCO_Line_Item_Display_Strategy___ticket_row__name_and_desc',
275
+			$name_and_desc,
276
+			$line_item,
277
+			$options
278
+		);
279
+
280
+		// name td
281
+		$html .= EEH_HTML::td( /*__FUNCTION__ .*/
282
+			$name_and_desc,
283
+			'',
284
+			'item_l'
285
+		);
286
+		// price td
287
+		$price = apply_filters(
288
+			'FHEE__EE_SPCO_Line_Item_Display_Strategy___ticket_row__price',
289
+			$line_item->unit_price_no_code(),
290
+			$line_item
291
+		);
292
+		$html .= EEH_HTML::td($price, '', 'item_c jst-rght');
293
+		// quantity td
294
+		$html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght');
295
+		$this->_total_items += $line_item->quantity();
296
+		// determine total for line item
297
+		$total = apply_filters(
298
+			'FHEE__EE_SPCO_Line_Item_Display_Strategy___ticket_row__total',
299
+			$line_item->total(),
300
+			$line_item
301
+		);
302
+		$this->_events[ $options['event_id'] ] += $total;
303
+		// total td
304
+		$html .= EEH_HTML::td(
305
+			EEH_Template::format_currency($total, false, false),
306
+			'',
307
+			'item_r jst-rght'
308
+		);
309
+		// end of row
310
+		$html .= EEH_HTML::trx();
311
+		return $html;
312
+	}
313
+
314
+
315
+
316
+	/**
317
+	 * _item_row
318
+	 *
319
+	 * @param EE_Line_Item $line_item
320
+	 * @param array        $options
321
+	 * @return mixed
322
+	 * @throws EE_Error
323
+	 */
324
+	private function _item_row(EE_Line_Item $line_item, $options = array())
325
+	{
326
+		// start of row
327
+		$row_class = $options['odd'] ? 'item odd' : 'item';
328
+		$html = EEH_HTML::tr('', '', $row_class);
329
+		$obj_name = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n() . ': ' : '';
330
+		// name && desc
331
+		$name_and_desc = apply_filters(
332
+			'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name',
333
+			$obj_name . $line_item->name(),
334
+			$line_item
335
+		);
336
+		$name_and_desc .= apply_filters(
337
+			'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc',
338
+			(
339
+				$options['show_desc']
340
+				? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>'
341
+				: ''
342
+			),
343
+			$line_item,
344
+			$options
345
+		);
346
+		$name_and_desc .= $line_item->is_taxable() ? ' * ' : '';
347
+		$name_and_desc = apply_filters(
348
+			'FHEE__EE_SPCO_Line_Item_Display_Strategy___item_row__name_and_desc',
349
+			$name_and_desc,
350
+			$line_item,
351
+			$options
352
+		);
353
+
354
+		// name td
355
+		$html .= EEH_HTML::td($name_and_desc, '', 'item_l');
356
+		// price td
357
+		if ($line_item->is_percent()) {
358
+			$html .= EEH_HTML::td($line_item->percent() . '%', '', 'item_c jst-rght');
359
+		} else {
360
+			$html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght');
361
+		}
362
+		// quantity td
363
+		$html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght');
364
+		// $total = $line_item->total() * $line_item->quantity();
365
+		$total = $line_item->total();
366
+		if (isset($options['event_id'], $this->_events[ $options['event_id'] ])) {
367
+			$this->_events[ $options['event_id'] ] += $total;
368
+		}
369
+		// total td
370
+		$html .= EEH_HTML::td(
371
+			EEH_Template::format_currency($total, false, false),
372
+			'',
373
+			'item_r jst-rght'
374
+		);
375
+		// end of row
376
+		$html .= EEH_HTML::trx();
377
+		return $html;
378
+	}
379
+
380
+
381
+
382
+	/**
383
+	 * _sub_item_row
384
+	 *
385
+	 * @param EE_Line_Item $line_item
386
+	 * @param array        $options
387
+	 * @param EE_Line_Item $parent_line_item
388
+	 * @return mixed
389
+	 * @throws EE_Error
390
+	 */
391
+	private function _sub_item_row(EE_Line_Item $line_item, $options = array(), EE_Line_Item $parent_line_item = null)
392
+	{
393
+		if (
394
+			$parent_line_item instanceof  EE_Line_Item
395
+			&& $line_item->children() === array()
396
+			&& $line_item->name() === $parent_line_item->name()
397
+			&& apply_filters(
398
+				'FHEE__EE_SPCO_Line_Item_Display_Strategy___sub_item_row__hide_main_sub_line_item',
399
+				true
400
+			)
401
+		) {
402
+			return '';
403
+		}
404
+		// start of row
405
+		$html = EEH_HTML::tr('', '', 'item sub-item-row');
406
+		// name && desc
407
+		$name_and_desc = EEH_HTML::span('', '', 'sub-item-row-bullet dashicons dashicons-arrow-right')
408
+						 . $line_item->name();
409
+		$name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: '
410
+												  . $line_item->desc()
411
+												  . '</span>' : '';
412
+		// name td
413
+		$html .= EEH_HTML::td($name_and_desc, '', 'item_l sub-item');
414
+		$qty = $parent_line_item instanceof EE_Line_Item ? $parent_line_item->quantity() : 1;
415
+		// discount/surcharge td
416
+		if ($line_item->is_percent()) {
417
+			$html .= EEH_HTML::td(
418
+				EEH_Template::format_currency(
419
+					$line_item->total() / $qty,
420
+					false,
421
+					false
422
+				),
423
+				'',
424
+				'item_c jst-rght'
425
+			);
426
+		} else {
427
+			$html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght');
428
+		}
429
+		// no quantity td
430
+		$html .= EEH_HTML::td();
431
+		// no total td
432
+		$html .= EEH_HTML::td();
433
+		// end of row
434
+		$html .= EEH_HTML::trx();
435
+		$html = apply_filters(
436
+			'FHEE__EE_SPCO_Line_Item_Display_Strategy___sub_item_row__html',
437
+			$html,
438
+			$line_item,
439
+			$options,
440
+			$parent_line_item
441
+		);
442
+		return $html;
443
+	}
444
+
445
+
446
+
447
+	/**
448
+	 * _tax_row
449
+	 *
450
+	 * @param EE_Line_Item $line_item
451
+	 * @param array        $options
452
+	 * @return mixed
453
+	 * @throws EE_Error
454
+	 */
455
+	private function _tax_row(EE_Line_Item $line_item, $options = array())
456
+	{
457
+		// start of row
458
+		$html = EEH_HTML::tr('', 'item sub-item tax-total');
459
+		// name && desc
460
+		$name_and_desc = $line_item->name();
461
+		$name_and_desc .= '<span class="smaller-text lt-grey-text" style="margin:0 0 0 2em;">'
462
+						  . esc_html__(' * taxable items', 'event_espresso') . '</span>';
463
+		$name_and_desc .= $options['show_desc'] ? '<br/>' . $line_item->desc() : '';
464
+		// name td
465
+		$html .= EEH_HTML::td( /*__FUNCTION__ .*/
466
+			$name_and_desc,
467
+			'',
468
+			'item_l sub-item'
469
+		);
470
+		// percent td
471
+		$html .= EEH_HTML::td($line_item->percent() . '%', '', ' jst-rght', '');
472
+		// empty td (price)
473
+		$html .= EEH_HTML::td(EEH_HTML::nbsp());
474
+		// total td
475
+		$html .= EEH_HTML::td(
476
+			EEH_Template::format_currency(
477
+				$line_item->total(),
478
+				false,
479
+				false
480
+			),
481
+			'',
482
+			'item_r jst-rght'
483
+		);
484
+		// end of row
485
+		$html .= EEH_HTML::trx();
486
+		return $html;
487
+	}
488
+
489
+
490
+
491
+	/**
492
+	 * _total_row
493
+	 *
494
+	 * @param EE_Line_Item $line_item
495
+	 * @param string       $text
496
+	 * @return mixed
497
+	 * @throws EE_Error
498
+	 */
499
+	private function _total_tax_row(EE_Line_Item $line_item, $text = '')
500
+	{
501
+		$html = '';
502
+		if ($line_item->total()) {
503
+			// start of row
504
+			$html = EEH_HTML::tr('', '', 'total_tr odd');
505
+			// total td
506
+			$html .= EEH_HTML::td(
507
+				$text,
508
+				'',
509
+				'total_currency total jst-rght',
510
+				'',
511
+				' colspan="2"'
512
+			);
513
+			// empty td (price)
514
+			$html .= EEH_HTML::td(EEH_HTML::nbsp());
515
+			// total td
516
+			$html .= EEH_HTML::td(
517
+				EEH_Template::format_currency($line_item->total(), false, false),
518
+				'',
519
+				'total jst-rght'
520
+			);
521
+			// end of row
522
+			$html .= EEH_HTML::trx();
523
+		}
524
+		return $html;
525
+	}
526
+
527
+
528
+
529
+	/**
530
+	 * _total_row
531
+	 *
532
+	 * @param EE_Line_Item $line_item
533
+	 * @param string       $text
534
+	 * @param array        $options
535
+	 * @return mixed
536
+	 * @throws EE_Error
537
+	 */
538
+	private function _sub_total_row(EE_Line_Item $line_item, $text = '', $options = array())
539
+	{
540
+		$html = '';
541
+		if ($line_item->total()) {
542
+			// start of row
543
+			$html = EEH_HTML::tr('', '', 'total_tr odd');
544
+			// total td
545
+			$html .= EEH_HTML::td(
546
+				$text,
547
+				'',
548
+				'total_currency total jst-rght',
549
+				'',
550
+				' colspan="3"'
551
+			);
552
+			// total td
553
+			$html .= EEH_HTML::td(
554
+				EEH_Template::format_currency($options['sub_total'], false, false),
555
+				'',
556
+				'total jst-rght'
557
+			);
558
+			// end of row
559
+			$html .= EEH_HTML::trx();
560
+		}
561
+		return $html;
562
+	}
563
+
564
+
565
+
566
+	/**
567
+	 * _total_row
568
+	 *
569
+	 * @param EE_Line_Item $line_item
570
+	 * @param string       $text
571
+	 * @return mixed
572
+	 * @throws EE_Error
573
+	 */
574
+	private function _total_row(EE_Line_Item $line_item, $text = '')
575
+	{
576
+		// start of row
577
+		$html = EEH_HTML::tr('', '', 'spco-grand-total total_tr odd');
578
+		// total td
579
+		$html .= EEH_HTML::td($text, '', 'total_currency total jst-rght', '', ' colspan="3"');
580
+		// total td
581
+		$html .= EEH_HTML::td(
582
+			EEH_Template::format_currency($line_item->total(), false, false),
583
+			'',
584
+			'total jst-rght'
585
+		);
586
+		// end of row
587
+		$html .= EEH_HTML::trx();
588
+		return $html;
589
+	}
590
+
591
+
592
+
593
+	/**
594
+	 * _payments_and_amount_owing_rows
595
+	 *
596
+	 * @param EE_Line_Item $line_item
597
+	 * @param array        $options
598
+	 * @return mixed
599
+	 * @throws EE_Error
600
+	 */
601
+	private function _payments_and_amount_owing_rows(EE_Line_Item $line_item, $options = array())
602
+	{
603
+		$html = '';
604
+		$owing = $line_item->total();
605
+		$transaction = EEM_Transaction::instance()->get_one_by_ID($line_item->TXN_ID());
606
+		if ($transaction instanceof EE_Transaction) {
607
+			$registration_payments = array();
608
+			$registrations = ! empty($options['registrations'])
609
+				? $options['registrations']
610
+				: $transaction->registrations();
611
+			foreach ($registrations as $registration) {
612
+				if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) {
613
+					$registration_payments += $registration->registration_payments();
614
+				}
615
+			}
616
+			if (! empty($registration_payments)) {
617
+				foreach ($registration_payments as $registration_payment) {
618
+					if ($registration_payment instanceof EE_Registration_Payment) {
619
+						$owing -= $registration_payment->amount();
620
+						$payment = $registration_payment->payment();
621
+						$payment_desc = '';
622
+						if ($payment instanceof EE_Payment) {
623
+							$payment_desc = sprintf(
624
+								esc_html__('Payment%1$s Received: %2$s', 'event_espresso'),
625
+								$payment->txn_id_chq_nmbr() !== ''
626
+									? ' <span class="small-text">(#' . $payment->txn_id_chq_nmbr() . ')</span> '
627
+									: '',
628
+								$payment->timestamp()
629
+							);
630
+						}
631
+						// start of row
632
+						$html .= EEH_HTML::tr('', '', 'total_tr odd');
633
+						// payment desc
634
+						$html .= EEH_HTML::td($payment_desc, '', '', '', ' colspan="3"');
635
+						// total td
636
+						$html .= EEH_HTML::td(
637
+							EEH_Template::format_currency(
638
+								$registration_payment->amount(),
639
+								false,
640
+								false
641
+							),
642
+							'',
643
+							'total jst-rght'
644
+						);
645
+						// end of row
646
+						$html .= EEH_HTML::trx();
647
+					}
648
+				}
649
+				if ($line_item->total()) {
650
+					// start of row
651
+					$html .= EEH_HTML::tr('', '', 'total_tr odd');
652
+					// total td
653
+					$html .= EEH_HTML::td(
654
+						esc_html__('Amount Owing', 'event_espresso'),
655
+						'',
656
+						'total_currency total jst-rght',
657
+						'',
658
+						' colspan="3"'
659
+					);
660
+					// total td
661
+					$html .= EEH_HTML::td(
662
+						EEH_Template::format_currency($owing, false, false),
663
+						'',
664
+						'total jst-rght'
665
+					);
666
+					// end of row
667
+					$html .= EEH_HTML::trx();
668
+				}
669
+			}
670
+		}
671
+		$this->_grand_total = $owing;
672
+		return $html;
673
+	}
674 674
 }
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
         $html = '';
85 85
         // set some default options and merge with incoming
86 86
         $default_options = array(
87
-            'show_desc' => true,  //    true        false
87
+            'show_desc' => true, //    true        false
88 88
             'odd'       => false,
89 89
         );
90 90
         $options = array_merge($default_options, (array) $options);
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
                 $text = esc_html__('Sub-Total', 'event_espresso');
120 120
                 if ($line_item->OBJ_type() === 'Event') {
121 121
                     $options['event_id'] = $event_id = $line_item->OBJ_ID();
122
-                    if (! isset($this->_events[ $options['event_id'] ])) {
122
+                    if ( ! isset($this->_events[$options['event_id']])) {
123 123
                         $event = EEM_Event::instance()->get_one_by_ID($options['event_id']);
124 124
                         // if event has default reg status of Not Approved, then don't display info on it
125 125
                         if (
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
                             // unless there are registrations for it that are returning to pay
131 131
                             if (isset($options['registrations']) && is_array($options['registrations'])) {
132 132
                                 foreach ($options['registrations'] as $registration) {
133
-                                    if (! $registration instanceof EE_Registration) {
133
+                                    if ( ! $registration instanceof EE_Registration) {
134 134
                                         continue;
135 135
                                     }
136 136
                                     $display_event = $registration->event_ID() === $options['event_id']
@@ -139,11 +139,11 @@  discard block
 block discarded – undo
139 139
                                         : $display_event;
140 140
                                 }
141 141
                             }
142
-                            if (! $display_event) {
142
+                            if ( ! $display_event) {
143 143
                                 return '';
144 144
                             }
145 145
                         }
146
-                        $this->_events[ $options['event_id'] ] = 0;
146
+                        $this->_events[$options['event_id']] = 0;
147 147
                         $html .= $this->_event_row($line_item);
148 148
                         $text = esc_html__('Event Sub-Total', 'event_espresso');
149 149
                     }
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
                     // recursively feed children back into this method
155 155
                     $html .= $this->display_line_item($child_line_item, $options, $line_item);
156 156
                 }
157
-                $event_sub_total += isset($options['event_id']) ? $this->_events[ $options['event_id'] ] : 0;
157
+                $event_sub_total += isset($options['event_id']) ? $this->_events[$options['event_id']] : 0;
158 158
                 $sub_total += $event_sub_total;
159 159
                 if (
160 160
                     (
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
             'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc',
264 264
             (
265 265
                 $options['show_desc']
266
-                    ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>'
266
+                    ? '<span class="line-item-desc-spn smaller-text">: '.$line_item->desc().'</span>'
267 267
                     : ''
268 268
             ),
269 269
             $line_item,
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
             $line_item->total(),
300 300
             $line_item
301 301
         );
302
-        $this->_events[ $options['event_id'] ] += $total;
302
+        $this->_events[$options['event_id']] += $total;
303 303
         // total td
304 304
         $html .= EEH_HTML::td(
305 305
             EEH_Template::format_currency($total, false, false),
@@ -326,18 +326,18 @@  discard block
 block discarded – undo
326 326
         // start of row
327 327
         $row_class = $options['odd'] ? 'item odd' : 'item';
328 328
         $html = EEH_HTML::tr('', '', $row_class);
329
-        $obj_name = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n() . ': ' : '';
329
+        $obj_name = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n().': ' : '';
330 330
         // name && desc
331 331
         $name_and_desc = apply_filters(
332 332
             'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name',
333
-            $obj_name . $line_item->name(),
333
+            $obj_name.$line_item->name(),
334 334
             $line_item
335 335
         );
336 336
         $name_and_desc .= apply_filters(
337 337
             'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc',
338 338
             (
339 339
                 $options['show_desc']
340
-                ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>'
340
+                ? '<span class="line-item-desc-spn smaller-text">: '.$line_item->desc().'</span>'
341 341
                 : ''
342 342
             ),
343 343
             $line_item,
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
         $html .= EEH_HTML::td($name_and_desc, '', 'item_l');
356 356
         // price td
357 357
         if ($line_item->is_percent()) {
358
-            $html .= EEH_HTML::td($line_item->percent() . '%', '', 'item_c jst-rght');
358
+            $html .= EEH_HTML::td($line_item->percent().'%', '', 'item_c jst-rght');
359 359
         } else {
360 360
             $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght');
361 361
         }
@@ -363,8 +363,8 @@  discard block
 block discarded – undo
363 363
         $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght');
364 364
         // $total = $line_item->total() * $line_item->quantity();
365 365
         $total = $line_item->total();
366
-        if (isset($options['event_id'], $this->_events[ $options['event_id'] ])) {
367
-            $this->_events[ $options['event_id'] ] += $total;
366
+        if (isset($options['event_id'], $this->_events[$options['event_id']])) {
367
+            $this->_events[$options['event_id']] += $total;
368 368
         }
369 369
         // total td
370 370
         $html .= EEH_HTML::td(
@@ -459,8 +459,8 @@  discard block
 block discarded – undo
459 459
         // name && desc
460 460
         $name_and_desc = $line_item->name();
461 461
         $name_and_desc .= '<span class="smaller-text lt-grey-text" style="margin:0 0 0 2em;">'
462
-                          . esc_html__(' * taxable items', 'event_espresso') . '</span>';
463
-        $name_and_desc .= $options['show_desc'] ? '<br/>' . $line_item->desc() : '';
462
+                          . esc_html__(' * taxable items', 'event_espresso').'</span>';
463
+        $name_and_desc .= $options['show_desc'] ? '<br/>'.$line_item->desc() : '';
464 464
         // name td
465 465
         $html .= EEH_HTML::td( /*__FUNCTION__ .*/
466 466
             $name_and_desc,
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
             'item_l sub-item'
469 469
         );
470 470
         // percent td
471
-        $html .= EEH_HTML::td($line_item->percent() . '%', '', ' jst-rght', '');
471
+        $html .= EEH_HTML::td($line_item->percent().'%', '', ' jst-rght', '');
472 472
         // empty td (price)
473 473
         $html .= EEH_HTML::td(EEH_HTML::nbsp());
474 474
         // total td
@@ -613,7 +613,7 @@  discard block
 block discarded – undo
613 613
                     $registration_payments += $registration->registration_payments();
614 614
                 }
615 615
             }
616
-            if (! empty($registration_payments)) {
616
+            if ( ! empty($registration_payments)) {
617 617
                 foreach ($registration_payments as $registration_payment) {
618 618
                     if ($registration_payment instanceof EE_Registration_Payment) {
619 619
                         $owing -= $registration_payment->amount();
@@ -623,7 +623,7 @@  discard block
 block discarded – undo
623 623
                             $payment_desc = sprintf(
624 624
                                 esc_html__('Payment%1$s Received: %2$s', 'event_espresso'),
625 625
                                 $payment->txn_id_chq_nmbr() !== ''
626
-                                    ? ' <span class="small-text">(#' . $payment->txn_id_chq_nmbr() . ')</span> '
626
+                                    ? ' <span class="small-text">(#'.$payment->txn_id_chq_nmbr().')</span> '
627 627
                                     : '',
628 628
                                 $payment->timestamp()
629 629
                             );
Please login to merge, or discard this patch.
core/libraries/rest_api/Capabilities.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
     ) {
100 100
         $has_password = $model->hasPassword();
101 101
         if ($has_password) {
102
-            $entity[ $model->getPasswordField()->get_name() ] = ModelDataTranslator::prepareFieldValueForJson(
102
+            $entity[$model->getPasswordField()->get_name()] = ModelDataTranslator::prepareFieldValueForJson(
103 103
                 $model->getPasswordField(),
104 104
                 $model->getPasswordField()->get_default_value(),
105 105
                 $model_version_info->requestedVersion()
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
             if (
110 110
                 $has_password
111 111
                 && $model->getPasswordField()->fieldIsProtected($field_name)
112
-                && $entity[ $field_name ]
112
+                && $entity[$field_name]
113 113
             ) {
114 114
                 $replacement_value = ModelDataTranslator::prepareFieldValueForJson(
115 115
                     $field_obj,
@@ -117,10 +117,10 @@  discard block
 block discarded – undo
117 117
                     $model_version_info->requestedVersion()
118 118
                 );
119 119
                 if ($model_version_info->fieldHasRenderedFormat($field_obj)) {
120
-                    $entity[ $field_name ]['rendered'] = $replacement_value;
120
+                    $entity[$field_name]['rendered'] = $replacement_value;
121 121
                 } elseif ($model_version_info->fieldHasPrettyFormat($field_obj)) {
122
-                    $entity[ $field_name ]['raw'] = $replacement_value;
123
-                    $entity[ $field_name ]['pretty'] = ModelDataTranslator::prepareFieldValueForJson(
122
+                    $entity[$field_name]['raw'] = $replacement_value;
123
+                    $entity[$field_name]['pretty'] = ModelDataTranslator::prepareFieldValueForJson(
124 124
                         $field_obj,
125 125
                         $field_obj->prepare_for_pretty_echoing($field_obj->get_default_value()),
126 126
                         $model_version_info->requestedVersion()
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
                     // so just remove it (or rather, set its default)
132 132
                     // API clients will just need to look to fields with rendered formats to know if these have
133 133
                     // been redacted. Sorry.
134
-                    $entity[ $field_name ] = $replacement_value;
134
+                    $entity[$field_name] = $replacement_value;
135 135
                 }
136 136
             }
137 137
         }
@@ -160,11 +160,11 @@  discard block
 block discarded – undo
160 160
         foreach ($model->field_settings() as $field_name => $field_obj) {
161 161
             if (
162 162
                 $model_version_info->fieldHasRenderedFormat($field_obj)
163
-                && isset($entity[ $field_name ])
164
-                && is_array($entity[ $field_name ])
165
-                && isset($entity[ $field_name ]['raw'])
163
+                && isset($entity[$field_name])
164
+                && is_array($entity[$field_name])
165
+                && isset($entity[$field_name]['raw'])
166 166
             ) {
167
-                unset($entity[ $field_name ]['raw']);
167
+                unset($entity[$field_name]['raw']);
168 168
             }
169 169
         }
170 170
         // theoretically we may want to filter out specific fields for specific models
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
      */
191 191
     public static function verifyAtLeastPartialAccessTo($model, $model_action_context, $action_name = 'list')
192 192
     {
193
-        if (! Capabilities::currentUserHasPartialAccessTo($model, $model_action_context)) {
193
+        if ( ! Capabilities::currentUserHasPartialAccessTo($model, $model_action_context)) {
194 194
             $model_name_plural = EEH_Inflector::pluralize_and_lower($model->get_this_model_name());
195 195
             throw new RestException(
196 196
                 sprintf('rest_cannot_%s_%s', strtolower($action_name), $model_name_plural),
Please login to merge, or discard this patch.
Indentation   +177 added lines, -177 removed lines patch added patch discarded remove patch
@@ -18,190 +18,190 @@
 block discarded – undo
18 18
 class Capabilities
19 19
 {
20 20
 
21
-    /**
22
-     * The current user can see at least SOME of these entities.
23
-     *
24
-     * @param EEM_Base $model
25
-     * @param string   $model_context one of the return values from EEM_Base::valid_cap_contexts()
26
-     * @return boolean
27
-     */
28
-    public static function currentUserHasPartialAccessTo($model, $model_context = EEM_Base::caps_read)
29
-    {
30
-        if (
31
-            apply_filters(
32
-                'FHEE__Capabilities__current_user_has_partial_access_to__override_begin',
33
-                false,
34
-                $model,
35
-                $model
36
-            )
37
-        ) {
38
-            return true;
39
-        }
40
-        foreach ($model->caps_missing($model_context) as $capability_name => $restriction_obj) {
41
-            if ($restriction_obj instanceof \EE_Return_None_Where_Conditions) {
42
-                return false;
43
-            }
44
-        }
45
-        if (
46
-            apply_filters(
47
-                'FHEE__Capabilities__current_user_has_partial_access_to__override_end',
48
-                false,
49
-                $model,
50
-                $model
51
-            )
52
-        ) {
53
-            return false;
54
-        }
55
-        return true;
56
-    }
21
+	/**
22
+	 * The current user can see at least SOME of these entities.
23
+	 *
24
+	 * @param EEM_Base $model
25
+	 * @param string   $model_context one of the return values from EEM_Base::valid_cap_contexts()
26
+	 * @return boolean
27
+	 */
28
+	public static function currentUserHasPartialAccessTo($model, $model_context = EEM_Base::caps_read)
29
+	{
30
+		if (
31
+			apply_filters(
32
+				'FHEE__Capabilities__current_user_has_partial_access_to__override_begin',
33
+				false,
34
+				$model,
35
+				$model
36
+			)
37
+		) {
38
+			return true;
39
+		}
40
+		foreach ($model->caps_missing($model_context) as $capability_name => $restriction_obj) {
41
+			if ($restriction_obj instanceof \EE_Return_None_Where_Conditions) {
42
+				return false;
43
+			}
44
+		}
45
+		if (
46
+			apply_filters(
47
+				'FHEE__Capabilities__current_user_has_partial_access_to__override_end',
48
+				false,
49
+				$model,
50
+				$model
51
+			)
52
+		) {
53
+			return false;
54
+		}
55
+		return true;
56
+	}
57 57
 
58 58
 
59
-    /**
60
-     * Gets an array of all the capabilities the current user is missing that affected
61
-     * the query
62
-     *
63
-     * @param EEM_Base $model
64
-     * @param string   $request_type one of the constants on WP_JSON_Server
65
-     * @return array
66
-     */
67
-    public static function getMissingPermissions($model, $request_type = EEM_Base::caps_read)
68
-    {
69
-        return $model->caps_missing($request_type);
70
-    }
59
+	/**
60
+	 * Gets an array of all the capabilities the current user is missing that affected
61
+	 * the query
62
+	 *
63
+	 * @param EEM_Base $model
64
+	 * @param string   $request_type one of the constants on WP_JSON_Server
65
+	 * @return array
66
+	 */
67
+	public static function getMissingPermissions($model, $request_type = EEM_Base::caps_read)
68
+	{
69
+		return $model->caps_missing($request_type);
70
+	}
71 71
 
72 72
 
73
-    /**
74
-     * Gets a string of all the capabilities the current user is missing that affected
75
-     * the query
76
-     *
77
-     * @param EEM_Base $model
78
-     * @param string   $model_context one of the return values from EEM_Base::valid_cap_contexts()
79
-     * @return string
80
-     */
81
-    public static function getMissingPermissionsString($model, $model_context = EEM_Base::caps_read)
82
-    {
83
-        return implode(',', array_keys(self::getMissingPermissions($model, $model_context)));
84
-    }
73
+	/**
74
+	 * Gets a string of all the capabilities the current user is missing that affected
75
+	 * the query
76
+	 *
77
+	 * @param EEM_Base $model
78
+	 * @param string   $model_context one of the return values from EEM_Base::valid_cap_contexts()
79
+	 * @return string
80
+	 */
81
+	public static function getMissingPermissionsString($model, $model_context = EEM_Base::caps_read)
82
+	{
83
+		return implode(',', array_keys(self::getMissingPermissions($model, $model_context)));
84
+	}
85 85
 
86
-    /**
87
-     * "Removes" password-protected fields. Currently that means setting their values to their default.
88
-     * @since 4.9.74.p
89
-     * @param array $entity
90
-     * @param EEM_Base $model
91
-     * @param ModelVersionInfo $model_version_info
92
-     * @return array
93
-     * @throws EE_Error
94
-     */
95
-    public static function filterOutPasswordProtectedFields(
96
-        $entity,
97
-        EEM_Base $model,
98
-        ModelVersionInfo $model_version_info
99
-    ) {
100
-        $has_password = $model->hasPassword();
101
-        if ($has_password) {
102
-            $entity[ $model->getPasswordField()->get_name() ] = ModelDataTranslator::prepareFieldValueForJson(
103
-                $model->getPasswordField(),
104
-                $model->getPasswordField()->get_default_value(),
105
-                $model_version_info->requestedVersion()
106
-            );
107
-        }
108
-        foreach ($model->field_settings() as $field_name => $field_obj) {
109
-            if (
110
-                $has_password
111
-                && $model->getPasswordField()->fieldIsProtected($field_name)
112
-                && $entity[ $field_name ]
113
-            ) {
114
-                $replacement_value = ModelDataTranslator::prepareFieldValueForJson(
115
-                    $field_obj,
116
-                    $field_obj->get_default_value(),
117
-                    $model_version_info->requestedVersion()
118
-                );
119
-                if ($model_version_info->fieldHasRenderedFormat($field_obj)) {
120
-                    $entity[ $field_name ]['rendered'] = $replacement_value;
121
-                } elseif ($model_version_info->fieldHasPrettyFormat($field_obj)) {
122
-                    $entity[ $field_name ]['raw'] = $replacement_value;
123
-                    $entity[ $field_name ]['pretty'] = ModelDataTranslator::prepareFieldValueForJson(
124
-                        $field_obj,
125
-                        $field_obj->prepare_for_pretty_echoing($field_obj->get_default_value()),
126
-                        $model_version_info->requestedVersion()
127
-                    );
128
-                } else {
129
-                    // this is most likely an excerpt field. (These should have also had "rendered" and "raw"
130
-                    // versions, but we missed that, and can't change it without breaking backward compatibility)
131
-                    // so just remove it (or rather, set its default)
132
-                    // API clients will just need to look to fields with rendered formats to know if these have
133
-                    // been redacted. Sorry.
134
-                    $entity[ $field_name ] = $replacement_value;
135
-                }
136
-            }
137
-        }
138
-        return $entity;
139
-    }
86
+	/**
87
+	 * "Removes" password-protected fields. Currently that means setting their values to their default.
88
+	 * @since 4.9.74.p
89
+	 * @param array $entity
90
+	 * @param EEM_Base $model
91
+	 * @param ModelVersionInfo $model_version_info
92
+	 * @return array
93
+	 * @throws EE_Error
94
+	 */
95
+	public static function filterOutPasswordProtectedFields(
96
+		$entity,
97
+		EEM_Base $model,
98
+		ModelVersionInfo $model_version_info
99
+	) {
100
+		$has_password = $model->hasPassword();
101
+		if ($has_password) {
102
+			$entity[ $model->getPasswordField()->get_name() ] = ModelDataTranslator::prepareFieldValueForJson(
103
+				$model->getPasswordField(),
104
+				$model->getPasswordField()->get_default_value(),
105
+				$model_version_info->requestedVersion()
106
+			);
107
+		}
108
+		foreach ($model->field_settings() as $field_name => $field_obj) {
109
+			if (
110
+				$has_password
111
+				&& $model->getPasswordField()->fieldIsProtected($field_name)
112
+				&& $entity[ $field_name ]
113
+			) {
114
+				$replacement_value = ModelDataTranslator::prepareFieldValueForJson(
115
+					$field_obj,
116
+					$field_obj->get_default_value(),
117
+					$model_version_info->requestedVersion()
118
+				);
119
+				if ($model_version_info->fieldHasRenderedFormat($field_obj)) {
120
+					$entity[ $field_name ]['rendered'] = $replacement_value;
121
+				} elseif ($model_version_info->fieldHasPrettyFormat($field_obj)) {
122
+					$entity[ $field_name ]['raw'] = $replacement_value;
123
+					$entity[ $field_name ]['pretty'] = ModelDataTranslator::prepareFieldValueForJson(
124
+						$field_obj,
125
+						$field_obj->prepare_for_pretty_echoing($field_obj->get_default_value()),
126
+						$model_version_info->requestedVersion()
127
+					);
128
+				} else {
129
+					// this is most likely an excerpt field. (These should have also had "rendered" and "raw"
130
+					// versions, but we missed that, and can't change it without breaking backward compatibility)
131
+					// so just remove it (or rather, set its default)
132
+					// API clients will just need to look to fields with rendered formats to know if these have
133
+					// been redacted. Sorry.
134
+					$entity[ $field_name ] = $replacement_value;
135
+				}
136
+			}
137
+		}
138
+		return $entity;
139
+	}
140 140
 
141 141
 
142
-    /**
143
-     * Takes a entity that's ready to be returned and removes fields which the user shouldn't be able to access.
144
-     *
145
-     * @param array $entity
146
-     * @param EEM_Base $model
147
-     * @param string $request_type one of the return values from EEM_Base::valid_cap_contexts()
148
-     * @param ModelVersionInfo $model_version_info
149
-     * @param string $primary_key_string result of EEM_Base::get_index_primary_key_string(), so that we can
150
-     *                                               use this with models that have no primary key
151
-     * @return array ready for converting into json
152
-     */
153
-    public static function filterOutInaccessibleEntityFields(
154
-        $entity,
155
-        $model,
156
-        $request_type,
157
-        $model_version_info,
158
-        $primary_key_string = null
159
-    ) {
160
-        foreach ($model->field_settings() as $field_name => $field_obj) {
161
-            if (
162
-                $model_version_info->fieldHasRenderedFormat($field_obj)
163
-                && isset($entity[ $field_name ])
164
-                && is_array($entity[ $field_name ])
165
-                && isset($entity[ $field_name ]['raw'])
166
-            ) {
167
-                unset($entity[ $field_name ]['raw']);
168
-            }
169
-        }
170
-        // theoretically we may want to filter out specific fields for specific models
171
-        return apply_filters(
172
-            'FHEE__Capabilities__filter_out_inaccessible_entity_fields',
173
-            $entity,
174
-            $model,
175
-            $request_type
176
-        );
177
-    }
142
+	/**
143
+	 * Takes a entity that's ready to be returned and removes fields which the user shouldn't be able to access.
144
+	 *
145
+	 * @param array $entity
146
+	 * @param EEM_Base $model
147
+	 * @param string $request_type one of the return values from EEM_Base::valid_cap_contexts()
148
+	 * @param ModelVersionInfo $model_version_info
149
+	 * @param string $primary_key_string result of EEM_Base::get_index_primary_key_string(), so that we can
150
+	 *                                               use this with models that have no primary key
151
+	 * @return array ready for converting into json
152
+	 */
153
+	public static function filterOutInaccessibleEntityFields(
154
+		$entity,
155
+		$model,
156
+		$request_type,
157
+		$model_version_info,
158
+		$primary_key_string = null
159
+	) {
160
+		foreach ($model->field_settings() as $field_name => $field_obj) {
161
+			if (
162
+				$model_version_info->fieldHasRenderedFormat($field_obj)
163
+				&& isset($entity[ $field_name ])
164
+				&& is_array($entity[ $field_name ])
165
+				&& isset($entity[ $field_name ]['raw'])
166
+			) {
167
+				unset($entity[ $field_name ]['raw']);
168
+			}
169
+		}
170
+		// theoretically we may want to filter out specific fields for specific models
171
+		return apply_filters(
172
+			'FHEE__Capabilities__filter_out_inaccessible_entity_fields',
173
+			$entity,
174
+			$model,
175
+			$request_type
176
+		);
177
+	}
178 178
 
179 179
 
180
-    /**
181
-     * Verifies the current user has at least partial access to do this action on this model.
182
-     * If not, throws an exception (so we can define the code that sets up this error object
183
-     * once)
184
-     *
185
-     * @param EEM_Base $model
186
-     * @param string   $model_action_context
187
-     * @param string   $action_name
188
-     * @return void
189
-     * @throws RestException
190
-     */
191
-    public static function verifyAtLeastPartialAccessTo($model, $model_action_context, $action_name = 'list')
192
-    {
193
-        if (! Capabilities::currentUserHasPartialAccessTo($model, $model_action_context)) {
194
-            $model_name_plural = EEH_Inflector::pluralize_and_lower($model->get_this_model_name());
195
-            throw new RestException(
196
-                sprintf('rest_cannot_%s_%s', strtolower($action_name), $model_name_plural),
197
-                sprintf(
198
-                    esc_html__('Sorry, you are not allowed to %1$s %2$s. Missing permissions: %3$s', 'event_espresso'),
199
-                    $action_name,
200
-                    $model_name_plural,
201
-                    Capabilities::getMissingPermissionsString($model, $model_action_context)
202
-                ),
203
-                array('status' => 403)
204
-            );
205
-        }
206
-    }
180
+	/**
181
+	 * Verifies the current user has at least partial access to do this action on this model.
182
+	 * If not, throws an exception (so we can define the code that sets up this error object
183
+	 * once)
184
+	 *
185
+	 * @param EEM_Base $model
186
+	 * @param string   $model_action_context
187
+	 * @param string   $action_name
188
+	 * @return void
189
+	 * @throws RestException
190
+	 */
191
+	public static function verifyAtLeastPartialAccessTo($model, $model_action_context, $action_name = 'list')
192
+	{
193
+		if (! Capabilities::currentUserHasPartialAccessTo($model, $model_action_context)) {
194
+			$model_name_plural = EEH_Inflector::pluralize_and_lower($model->get_this_model_name());
195
+			throw new RestException(
196
+				sprintf('rest_cannot_%s_%s', strtolower($action_name), $model_name_plural),
197
+				sprintf(
198
+					esc_html__('Sorry, you are not allowed to %1$s %2$s. Missing permissions: %3$s', 'event_espresso'),
199
+					$action_name,
200
+					$model_name_plural,
201
+					Capabilities::getMissingPermissionsString($model, $model_action_context)
202
+				),
203
+				array('status' => 403)
204
+			);
205
+		}
206
+	}
207 207
 }
Please login to merge, or discard this patch.
core/libraries/rest_api/RestIncomingQueryParamMetadata.php 2 patches
Indentation   +701 added lines, -701 removed lines patch added patch discarded remove patch
@@ -28,707 +28,707 @@
 block discarded – undo
28 28
  */
29 29
 class RestIncomingQueryParamMetadata
30 30
 {
31
-    private $query_param_key;
32
-    private $query_param_value;
33
-    /**
34
-     * @var RestIncomingQueryParamContext
35
-     */
36
-    private $context;
37
-
38
-    /**
39
-     * @var EE_Model_Field_Base|null
40
-     */
41
-    private $field;
42
-
43
-    /**
44
-     * @var string same as $query_param_key but has the * and anything after it removed
45
-     */
46
-    private $query_param_key_sans_stars;
47
-
48
-    /**
49
-     * @var string for timezone or timezone offset
50
-     */
51
-    private $timezone;
52
-
53
-    /**
54
-     * @var boolean if the field in $query_param_key is for a GMT field (eg `EVT_modified_gmt`)
55
-     */
56
-    private $is_gmt_field = false;
57
-
58
-    /**
59
-     * RestIncomingQueryParamMetadata constructor.
60
-     * You probably want to call
61
-     * @param string $query_param_key
62
-     * @param string $query_param_value
63
-     * @param RestIncomingQueryParamContext $context
64
-     */
65
-    public function __construct($query_param_key, $query_param_value, RestIncomingQueryParamContext $context)
66
-    {
67
-        $this->query_param_key = $query_param_key;
68
-        $this->query_param_value = $query_param_value;
69
-        $this->context = $context;
70
-        $this->determineFieldAndTimezone();
71
-    }
72
-
73
-    /**
74
-     * Gets the query parameter key. This may have been modified (see setQueryParamValue())
75
-     * @return string
76
-     */
77
-    public function getQueryParamKey()
78
-    {
79
-        return $this->query_param_key;
80
-    }
81
-
82
-    /**
83
-     * Modifies the query parameter key passed in (Eg this is done when rewriting the simplified specified operator REST
84
-     * query parameters into the legacy structure)
85
-     * @param string|array|int|float $query_param_value
86
-     */
87
-    private function setQueryParamValue($query_param_value)
88
-    {
89
-        $this->query_param_value = $query_param_value;
90
-    }
91
-
92
-    /**
93
-     * Gets the original query parameter value passed in.
94
-     * @return string
95
-     */
96
-    public function getQueryParamValue()
97
-    {
98
-        return $this->query_param_value;
99
-    }
100
-
101
-    /**
102
-     * Gets the context object.
103
-     * @return RestIncomingQueryParamContext
104
-     */
105
-    public function getContext()
106
-    {
107
-        return $this->context;
108
-    }
109
-
110
-    /**
111
-     * Sets the query parameter key. This may be used to rewrite a key into its non-GMT alternative.
112
-     * @param string $query_param_key
113
-     */
114
-    private function setQueryParamKey($query_param_key)
115
-    {
116
-        $this->query_param_key = $query_param_key;
117
-    }
118
-
119
-    /**
120
-     * Gets the field the query parameter key indicated. This may be null (in cases where the query parameter key
121
-     * did not indicate a field, eg if it were `OR`).
122
-     * @return EE_Model_Field_Base|null
123
-     */
124
-    public function getField()
125
-    {
126
-        return $this->field;
127
-    }
128
-
129
-    /**
130
-     * Gets the query parameter key (with the star and everything afterwards removed).
131
-     * @return string
132
-     */
133
-    public function getQueryParamKeySansStars()
134
-    {
135
-        return $this->query_param_key_sans_stars;
136
-    }
137
-
138
-    /**
139
-     * Gets the timezone associated with this model (the site timezone, except for GMT datetime fields).
140
-     * @return string
141
-     */
142
-    public function getTimezone()
143
-    {
144
-        return $this->timezone;
145
-    }
146
-
147
-    /**
148
-     * Returns whether or not this is a GMT field
149
-     * @return boolean
150
-     */
151
-    public function isGmtField()
152
-    {
153
-        return $this->is_gmt_field;
154
-    }
155
-
156
-    /**
157
-     * Sets the field indicated by the query parameter key (might be null).
158
-     * @param EE_Model_Field_Base|null $field
159
-     */
160
-    private function setField(EE_Model_Field_Base $field = null)
161
-    {
162
-        $this->field = $field;
163
-    }
164
-
165
-    /**
166
-     * Sets the query parameter key-with-stars-removed.
167
-     * @param string $query_param_key_sans_stars
168
-     */
169
-    private function setQueryParamKeySansStars($query_param_key_sans_stars)
170
-    {
171
-        $this->query_param_key_sans_stars = $query_param_key_sans_stars;
172
-    }
173
-
174
-    /**
175
-     * Sets the timezone (this could be a timezeon offset string).
176
-     * @param string $timezone
177
-     */
178
-    private function setTimezone($timezone)
179
-    {
180
-        $this->timezone = $timezone;
181
-    }
182
-
183
-    /**
184
-     * @param mixed $is_gmt_field
185
-     */
186
-    private function setIsGmtField($is_gmt_field)
187
-    {
188
-        $this->is_gmt_field = $is_gmt_field;
189
-    }
190
-
191
-    /**
192
-     * Determines what field, query param name, and query param name without stars, and timezone to use.
193
-     * @since 4.9.72.p
194
-     * @type EE_Model_Field_Base $field
195
-     * @return void {
196
-     * @throws EE_Error
197
-     * @throws InvalidDataTypeException
198
-     * @throws InvalidInterfaceException
199
-     * @throws InvalidArgumentException
200
-     */
201
-    private function determineFieldAndTimezone()
202
-    {
203
-        $this->setQueryParamKeySansStars(ModelDataTranslator::removeStarsAndAnythingAfterFromConditionQueryParamKey(
204
-            $this->getQueryParamKey()
205
-        ));
206
-        $this->setField(ModelDataTranslator::deduceFieldFromQueryParam(
207
-            $this->getQueryParamKeySansStars(),
208
-            $this->getContext()->getModel()
209
-        ));
210
-        // double-check is it a *_gmt field?
211
-        if (
212
-            !$this->getField() instanceof EE_Model_Field_Base
213
-            && ModelDataTranslator::isGmtDateFieldName($this->getQueryParamKeySansStars())
214
-        ) {
215
-            // yep, take off '_gmt', and find the field
216
-            $this->setQueryParamKey(ModelDataTranslator::removeGmtFromFieldName($this->getQueryParamKeySansStars()));
217
-            $this->setField(ModelDataTranslator::deduceFieldFromQueryParam(
218
-                $this->getQueryParamKey(),
219
-                $this->context->getModel()
220
-            ));
221
-            $this->setTimezone('UTC');
222
-            $this->setIsGmtField(true);
223
-        } elseif ($this->getField() instanceof EE_Datetime_Field) {
224
-            // so it's not a GMT field. Set the timezone on the model to the default
225
-            $this->setTimezone(EEH_DTT_Helper::get_valid_timezone_string());
226
-        } else {
227
-            // just keep using what's already set for the timezone
228
-            $this->setTimezone($this->context->getModel()->get_timezone());
229
-        }
230
-        $this->assertOnlyAdminCanReadPasswordFields();
231
-    }
232
-
233
-    /**
234
-     * Throws an exception if a non-admin is trying to query by password.
235
-     * @since 4.9.74.p
236
-     * @throws RestException
237
-     */
238
-    private function assertOnlyAdminCanReadPasswordFields()
239
-    {
240
-        if (
241
-            $this->getField() instanceof EE_Password_Field
242
-            && ! current_user_can(EE_Restriction_Generator_Base::get_default_restrictions_cap())
243
-        ) {
244
-            // only full admins can query by password. sorry bub!
245
-            throw new RestException(
246
-                'only_admins_can_query_by_password',
247
-                // @codingStandardsIgnoreStart
248
-                esc_html__('You attempted to filter by a password field without the needed privileges. Only a full admin is allowed to do that.', 'event_espresso'),
249
-                // @codingStandardsIgnoreEnd
250
-                array(
251
-                    'status' => 403
252
-                )
253
-            );
254
-        }
255
-    }
256
-
257
-    /**
258
-     * Given a ton of input, determines the value to use for the models.
259
-     * @since 4.9.72.p
260
-     * @return array|null
261
-     * @throws DomainException
262
-     * @throws EE_Error
263
-     * @throws RestException
264
-     * @throws DomainException
265
-     */
266
-    public function determineConditionsQueryParameterValue()
267
-    {
268
-        if ($this->valueIsArrayDuringRead()) {
269
-            return $this->determineModelValueGivenRestInputArray();
270
-        }
271
-        return ModelDataTranslator::prepareFieldValueFromJson(
272
-            $this->getField(),
273
-            $this->getQueryParamValue(),
274
-            $this->getContext()->getRequestedVersion(),
275
-            $this->getTimezone()
276
-        );
277
-    }
278
-
279
-    /**
280
-     * Given that the array value provided was itself an array, handles finding the correct value to pass to the model.
281
-     * @since 4.9.72.p
282
-     * @return array|null
283
-     * @throws RestException
284
-     */
285
-    private function determineModelValueGivenRestInputArray()
286
-    {
287
-        $this->transformSimplifiedSpecifiedOperatorSyntaxIntoStandardSyntax();
288
-        // did they specify an operator?
289
-        if ($this->valueIsLegacySpecifiedOperator()) {
290
-            $query_param_value = $this->getQueryParamValue();
291
-            $sub_array_key = $query_param_value[0];
292
-            $translated_value = array($sub_array_key);
293
-            if ($this->operatorIsNAry($sub_array_key)) {
294
-                $translated_value[] = $this->prepareValuesFromJson($query_param_value[1]);
295
-            } elseif ($this->operatorIsTernary($sub_array_key)) {
296
-                $translated_value[] = array(
297
-                    $this->prepareValuesFromJson($query_param_value[1][0]),
298
-                    $this->prepareValuesFromJson($query_param_value[1][1])
299
-                );
300
-            } elseif ($this->operatorIsLike($sub_array_key)) {
301
-                // we want to leave this value mostly-as-is (eg don't force it to be a float
302
-                // or a boolean or an enum value. Leave it as-is with wildcards etc)
303
-                // but do verify it at least doesn't have any serialized data
304
-                ModelDataTranslator::throwExceptionIfContainsSerializedData($query_param_value[1]);
305
-                $translated_value[] = $query_param_value[1];
306
-            } elseif ($this->operatorIsUnary($sub_array_key)) {
307
-                // no arguments should have been provided, so don't look for any
308
-            } elseif ($this->operatorisBinary($sub_array_key)) {
309
-                // it's a valid operator, but none of the exceptions. Treat it normally.
310
-                $translated_value[] = $this->prepareValuesFromJson($query_param_value[1]);
311
-            } else {
312
-                // so they provided a valid operator, but wrong number of arguments
313
-                $this->throwWrongNumberOfArgsExceptionIfDebugging($sub_array_key);
314
-                $translated_value = null;
315
-            }
316
-        } else {
317
-            // so they didn't provide a valid operator
318
-            // if we aren't in debug mode, then just try our best to fulfill the user's request
319
-            $this->throwInvalidOperatorExceptionIfDebugging();
320
-            $translated_value = null;
321
-        }
322
-        return $translated_value;
323
-    }
324
-
325
-    /**
326
-     * Returns if this request is a "read" request and the value provided was an array.
327
-     * This will indicate is such things as `array('<', 123)` and `array('IN', array(1,2,3))` are acceptable or not.
328
-     * @since 4.9.72.p
329
-     * @return boolean
330
-     */
331
-    private function valueIsArrayDuringRead()
332
-    {
333
-        return !$this->getContext()->isWriting() && is_array($this->getQueryParamValue());
334
-    }
335
-
336
-    /**
337
-     * Returns if the value provided was an associative array (we should have already verified it's an array of some
338
-     * sort). If the value is an associative array, it had better be in the simplified specified operator structure.
339
-     * @since 4.9.72.p
340
-     * @return boolean
341
-     */
342
-    private function valueIsAssociativeArray()
343
-    {
344
-        return !EEH_Array::is_array_numerically_and_sequentially_indexed($this->getQueryParamValue());
345
-    }
346
-
347
-    /**
348
-     * Checks if the array value is itself an array that fits into the simplified specified operator structure
349
-     * (eg `array('!=' => 123)`).
350
-     * @since 4.9.72.p
351
-     * @return boolean
352
-     */
353
-    private function valueIsSimplifiedSpecifiedOperator()
354
-    {
355
-        return count($this->getQueryParamValue()) === 1
356
-            && array_key_exists(
357
-                key($this->getQueryParamValue()),
358
-                $this->getContext()->getModel()->valid_operators()
359
-            );
360
-    }
361
-
362
-    /**
363
-     * Throws an exception if the sub-value is an array (eg `array('!=' => array())`). It needs to just be a string,
364
-     * of either comma-separated-values, or a JSON array.
365
-     * @since 4.9.72.p
366
-     * @param $sub_array_key
367
-     * @param $sub_array_value
368
-     * @throws RestException
369
-     */
370
-    private function assertSubValueIsntArray($sub_array_key, $sub_array_value)
371
-    {
372
-        if (is_array($sub_array_value) && EED_Core_Rest_Api::debugMode()) {
373
-            throw new RestException(
374
-                'csv_or_json_string_only',
375
-                sprintf(
376
-                    /* translators: 1: variable name*/
377
-                    esc_html__(
378
-                        'The value provided for the operator "%1$s" should be comma-separated value string or a JSON array.',
379
-                        'event_espresso'
380
-                    ),
381
-                    $sub_array_key
382
-                ),
383
-                array(
384
-                    'status' => 400,
385
-                )
386
-            );
387
-        }
388
-    }
389
-
390
-    /**
391
-     * Determines if the sub-array key is an operator taking 3 or more operators.
392
-     * @since 4.9.72.p
393
-     * @param $sub_array_key
394
-     * @return boolean
395
-     */
396
-    private function subArrayKeyIsNonBinaryOperator($sub_array_key)
397
-    {
398
-        return array_key_exists(
399
-            $sub_array_key,
400
-            array_merge(
401
-                $this->getContext()->getModel()->valid_in_style_operators(),
402
-                $this->getContext()->getModel()->valid_between_style_operators()
403
-            )
404
-        );
405
-    }
406
-
407
-    /**
408
-     * Given that the $sub_array_key is a string, checks if it's an operator taking only 1 argument.
409
-     * @since 4.9.72.p
410
-     * @param string $sub_array_key
411
-     * @return boolean
412
-     */
413
-    private function subArrayKeyIsUnaryOperator($sub_array_key)
414
-    {
415
-        return array_key_exists(
416
-            $sub_array_key,
417
-            $this->getContext()->getModel()->valid_null_style_operators()
418
-        );
419
-    }
420
-
421
-    /**
422
-     * Parses the $sub_array_value string into an array (given it could either be a comma-separated-list or a JSON
423
-     * array). eg `"1,2,3"` or `"[1,2,3]"` into `array(1,2,3)`.
424
-     * @since 4.9.72.p
425
-     * @param $sub_array_value
426
-     * @return array|mixed|object
427
-     */
428
-    private function extractQuickStyleSpecifiedOperatorValue($sub_array_value)
429
-    {
430
-        // the value should be JSON or CSV
431
-        $values = json_decode($sub_array_value);
432
-        if (!is_array($values)) {
433
-            $values = array_filter(
434
-                array_map(
435
-                    'trim',
436
-                    explode(
437
-                        ',',
438
-                        $sub_array_value
439
-                    )
440
-                )
441
-            );
442
-        }
443
-        return $values;
444
-    }
445
-
446
-    /**
447
-     * Throws an exception if the value isn't a simplified specified operator (only called when we expect that).
448
-     * @since 4.9.72.p
449
-     * @throws RestException
450
-     */
451
-    private function assertSimplifiedSpecifiedOperator()
452
-    {
453
-        if (!$this->valueIsSimplifiedSpecifiedOperator() && EED_Core_Rest_Api::debugMode()) {
454
-            throw new RestException(
455
-                'numerically_indexed_array_of_values_only',
456
-                sprintf(
457
-                    /* translators: 1: variable name*/
458
-                    esc_html__(
459
-                        'The array provided for the parameter "%1$s" should be numerically indexed.',
460
-                        'event_espresso'
461
-                    ),
462
-                    $this->getQueryParamKey()
463
-                ),
464
-                array(
465
-                    'status' => 400,
466
-                )
467
-            );
468
-        }
469
-    }
470
-
471
-    /**
472
-     * If query_param_value were in the simplified specific operator structure, change it into the legacy structure.
473
-     * @since 4.9.72.p
474
-     * @throws RestException
475
-     */
476
-    private function transformSimplifiedSpecifiedOperatorSyntaxIntoStandardSyntax()
477
-    {
478
-        if ($this->valueIsAssociativeArray()) {
479
-            $this->assertSimplifiedSpecifiedOperator();
480
-            $query_param_value = $this->getQueryParamValue();
481
-            $sub_array_value = reset($query_param_value);
482
-            $sub_array_key = key($query_param_value);
483
-            $this->assertSubValueIsntArray($sub_array_key, $sub_array_value);
484
-            // they're doing something like "&where[EVT_ID][IN]=1,2,3" or "&where[EVT_ID][>]=5"
485
-            if ($this->subArrayKeyIsNonBinaryOperator($sub_array_key)) {
486
-                $this->setQueryParamValue(array(
487
-                    $sub_array_key,
488
-                    $this->extractQuickStyleSpecifiedOperatorValue($sub_array_value)
489
-                ));
490
-            } elseif ($this->subArrayKeyIsUnaryOperator($sub_array_key)) {
491
-                $this->setQueryParamValue(array($sub_array_key));
492
-            } else {
493
-                $this->setQueryParamValue(array($sub_array_key, $sub_array_value));
494
-            }
495
-        }
496
-    }
497
-
498
-    /**
499
-     * Returns true is the value is an array using the legacy structure to specify the operator. Eg `array('!=',123)`.
500
-     * @since 4.9.72.p
501
-     * @return boolean
502
-     */
503
-    private function valueIsLegacySpecifiedOperator()
504
-    {
505
-        $valid_operators = $this->getContext()->getModel()->valid_operators();
506
-        $query_param_value = $this->getQueryParamValue();
507
-        return isset($query_param_value[0])
508
-            && isset($valid_operators[ $query_param_value[0] ]);
509
-    }
510
-
511
-    /**
512
-     * Returns true if the value specified operator accepts arbitrary number of arguments, like "IN".
513
-     * @since 4.9.72.p
514
-     * @param $operator
515
-     * @return boolean
516
-     */
517
-    private function operatorIsNAry($operator)
518
-    {
519
-        $valueArray = $this->getQueryParamValue();
520
-        return array_key_exists(
521
-            $operator,
522
-            $this->getContext()->getModel()->valid_in_style_operators()
523
-        )
524
-            && isset($valueArray[1])
525
-            && is_array($valueArray[1])
526
-            && !isset($valueArray[2]);
527
-    }
528
-
529
-    /**
530
-     * Returns true if the operator accepts 3 arguments (eg "BETWEEN").
531
-     * So we're looking for a value that looks like
532
-     * `array('BETWEEN', array('2015-01-01T00:00:00', '2016-01-01T00:00:00'))`.
533
-     * @since 4.9.72.p
534
-     * @param $operator
535
-     * @return boolean
536
-     */
537
-    private function operatorIsTernary($operator)
538
-    {
539
-        $query_param_value = $this->getQueryParamValue();
540
-        return array_key_exists($operator, $this->getContext()->getModel()->valid_between_style_operators())
541
-            && isset($query_param_value[1])
542
-            && is_array($query_param_value[1])
543
-            && isset($query_param_value[1][0], $query_param_value[1][1])
544
-            && !isset($query_param_value[1][2])
545
-            && !isset($query_param_value[2]);
546
-    }
547
-
548
-    /**
549
-     * Returns true if the operator is a similar to LIKE, indicating the value may have wildcards we should leave alone.
550
-     * @since 4.9.72.p
551
-     * @param $operator
552
-     * @return boolean
553
-     */
554
-    private function operatorIsLike($operator)
555
-    {
556
-        $query_param_value = $this->getQueryParamValue();
557
-        return array_key_exists($operator, $this->getContext()->getModel()->valid_like_style_operators())
558
-            && isset($query_param_value[1])
559
-            && !isset($query_param_value[2]);
560
-    }
561
-
562
-    /**
563
-     * Returns true if the operator only takes one argument (eg it's like `IS NULL`).
564
-     * @since 4.9.72.p
565
-     * @param $operator
566
-     * @return boolean
567
-     */
568
-    private function operatorIsUnary($operator)
569
-    {
570
-        $query_param_value = $this->getQueryParamValue();
571
-        return array_key_exists($operator, $this->getContext()->getModel()->valid_null_style_operators())
572
-            && !isset($query_param_value[1]);
573
-    }
574
-
575
-    /**
576
-     * Returns true if the operator specified is a binary opeator (eg `=`, `!=`)
577
-     * @since 4.9.72.p
578
-     * @param $operator
579
-     * @return boolean
580
-     */
581
-    private function operatorisBinary($operator)
582
-    {
583
-        $query_param_value = $this->getQueryParamValue();
584
-        $model = $this->getContext()->getModel();
585
-        return isset($query_param_value[1])
586
-            && !isset($query_param_value[2])
587
-            && !array_key_exists(
588
-                $operator,
589
-                array_merge(
590
-                    $model->valid_in_style_operators(),
591
-                    $model->valid_null_style_operators(),
592
-                    $model->valid_like_style_operators(),
593
-                    $model->valid_between_style_operators()
594
-                )
595
-            );
596
-    }
597
-
598
-    /**
599
-     * If we're debugging, throws an exception saying that the wrong number of arguments was provided.
600
-     * @since 4.9.72.p
601
-     * @param $operator
602
-     * @throws RestException
603
-     */
604
-    private function throwWrongNumberOfArgsExceptionIfDebugging($operator)
605
-    {
606
-        if (EED_Core_Rest_Api::debugMode()) {
607
-            throw new RestException(
608
-                'wrong_number_of_arguments',
609
-                sprintf(
610
-                    esc_html__(
611
-                        'The operator you provided, "%1$s" had the wrong number of arguments',
612
-                        'event_espresso'
613
-                    ),
614
-                    $operator
615
-                ),
616
-                array(
617
-                    'status' => 400,
618
-                )
619
-            );
620
-        }
621
-    }
622
-
623
-    /**
624
-     * Wrapper for ModelDataTranslator::prepareFieldValuesFromJson(), just a tad more DRY.
625
-     * @since 4.9.72.p
626
-     * @param $value
627
-     * @return mixed
628
-     * @throws RestException
629
-     */
630
-    private function prepareValuesFromJson($value)
631
-    {
632
-        return ModelDataTranslator::prepareFieldValuesFromJson(
633
-            $this->getField(),
634
-            $value,
635
-            $this->getContext()->getRequestedVersion(),
636
-            $this->getTimezone()
637
-        );
638
-    }
639
-
640
-    /**
641
-     * Throws an exception if an invalid operator was specified and we're debugging.
642
-     * @since 4.9.72.p
643
-     * @throws RestException
644
-     */
645
-    private function throwInvalidOperatorExceptionIfDebugging()
646
-    {
647
-        // so they didn't provide a valid operator
648
-        if (EED_Core_Rest_Api::debugMode()) {
649
-            throw new RestException(
650
-                'invalid_operator',
651
-                sprintf(
652
-                    esc_html__(
653
-                        'You provided an invalid parameter, with key "%1$s" and value "%2$s"',
654
-                        'event_espresso'
655
-                    ),
656
-                    $this->getQueryParamKey(),
657
-                    $this->getQueryParamValue()
658
-                ),
659
-                array(
660
-                    'status' => 400,
661
-                )
662
-            );
663
-        }
664
-    }
665
-
666
-    /**
667
-     * Returns true if the query_param_key was a logic query parameter, eg `OR`, `AND`, `NOT`, `OR*`, etc.
668
-     * @since 4.9.72.p
669
-     * @return boolean
670
-     */
671
-    private function isLogicQueryParam()
672
-    {
673
-        return in_array($this->getQueryParamKeySansStars(), $this->getContext()->getModel()->logic_query_param_keys());
674
-    }
675
-
676
-
677
-    /**
678
-     * If the query param isn't for a field, it must be a nested query parameter which requires different logic.
679
-     * @since 4.9.72.p
680
-     * @return array
681
-     * @throws DomainException
682
-     * @throws EE_Error
683
-     * @throws RestException
684
-     * @throws InvalidDataTypeException
685
-     * @throws InvalidInterfaceException
686
-     * @throws InvalidArgumentException
687
-     */
688
-    public function determineNestedConditionQueryParameters()
689
-    {
690
-
691
-        // so this param doesn't correspond to a field eh?
692
-        if ($this->getContext()->isWriting()) {
693
-            // always tell API clients about invalid parameters when they're creating data. Otherwise,
694
-            // they are probably going to create invalid data
695
-            throw new RestException(
696
-                'invalid_field',
697
-                sprintf(
698
-                    /* translators: 1: variable name */
699
-                    esc_html__('You have provided an invalid parameter: "%1$s"', 'event_espresso'),
700
-                    $this->getQueryParamKey()
701
-                )
702
-            );
703
-        }
704
-        // so it's not for a field, is it a logic query param key?
705
-        if ($this->isLogicQueryParam()) {
706
-            return ModelDataTranslator::prepareConditionsQueryParamsForModels(
707
-                $this->getQueryParamValue(),
708
-                $this->getContext()->getModel(),
709
-                $this->getContext()->getRequestedVersion()
710
-            );
711
-        }
712
-        if (EED_Core_Rest_Api::debugMode()) {
713
-            // only tell API clients they got it wrong if we're in debug mode
714
-            // otherwise try our best ot fulfill their request by ignoring this invalid data
715
-            throw new RestException(
716
-                'invalid_parameter',
717
-                sprintf(
718
-                    /* translators: 1: variable name */
719
-                    esc_html__(
720
-                        'You provided an invalid parameter, with key "%1$s"',
721
-                        'event_espresso'
722
-                    ),
723
-                    $this->getQueryParamKey()
724
-                ),
725
-                array(
726
-                    'status' => 400,
727
-                )
728
-            );
729
-        }
730
-        return null;
731
-    }
31
+	private $query_param_key;
32
+	private $query_param_value;
33
+	/**
34
+	 * @var RestIncomingQueryParamContext
35
+	 */
36
+	private $context;
37
+
38
+	/**
39
+	 * @var EE_Model_Field_Base|null
40
+	 */
41
+	private $field;
42
+
43
+	/**
44
+	 * @var string same as $query_param_key but has the * and anything after it removed
45
+	 */
46
+	private $query_param_key_sans_stars;
47
+
48
+	/**
49
+	 * @var string for timezone or timezone offset
50
+	 */
51
+	private $timezone;
52
+
53
+	/**
54
+	 * @var boolean if the field in $query_param_key is for a GMT field (eg `EVT_modified_gmt`)
55
+	 */
56
+	private $is_gmt_field = false;
57
+
58
+	/**
59
+	 * RestIncomingQueryParamMetadata constructor.
60
+	 * You probably want to call
61
+	 * @param string $query_param_key
62
+	 * @param string $query_param_value
63
+	 * @param RestIncomingQueryParamContext $context
64
+	 */
65
+	public function __construct($query_param_key, $query_param_value, RestIncomingQueryParamContext $context)
66
+	{
67
+		$this->query_param_key = $query_param_key;
68
+		$this->query_param_value = $query_param_value;
69
+		$this->context = $context;
70
+		$this->determineFieldAndTimezone();
71
+	}
72
+
73
+	/**
74
+	 * Gets the query parameter key. This may have been modified (see setQueryParamValue())
75
+	 * @return string
76
+	 */
77
+	public function getQueryParamKey()
78
+	{
79
+		return $this->query_param_key;
80
+	}
81
+
82
+	/**
83
+	 * Modifies the query parameter key passed in (Eg this is done when rewriting the simplified specified operator REST
84
+	 * query parameters into the legacy structure)
85
+	 * @param string|array|int|float $query_param_value
86
+	 */
87
+	private function setQueryParamValue($query_param_value)
88
+	{
89
+		$this->query_param_value = $query_param_value;
90
+	}
91
+
92
+	/**
93
+	 * Gets the original query parameter value passed in.
94
+	 * @return string
95
+	 */
96
+	public function getQueryParamValue()
97
+	{
98
+		return $this->query_param_value;
99
+	}
100
+
101
+	/**
102
+	 * Gets the context object.
103
+	 * @return RestIncomingQueryParamContext
104
+	 */
105
+	public function getContext()
106
+	{
107
+		return $this->context;
108
+	}
109
+
110
+	/**
111
+	 * Sets the query parameter key. This may be used to rewrite a key into its non-GMT alternative.
112
+	 * @param string $query_param_key
113
+	 */
114
+	private function setQueryParamKey($query_param_key)
115
+	{
116
+		$this->query_param_key = $query_param_key;
117
+	}
118
+
119
+	/**
120
+	 * Gets the field the query parameter key indicated. This may be null (in cases where the query parameter key
121
+	 * did not indicate a field, eg if it were `OR`).
122
+	 * @return EE_Model_Field_Base|null
123
+	 */
124
+	public function getField()
125
+	{
126
+		return $this->field;
127
+	}
128
+
129
+	/**
130
+	 * Gets the query parameter key (with the star and everything afterwards removed).
131
+	 * @return string
132
+	 */
133
+	public function getQueryParamKeySansStars()
134
+	{
135
+		return $this->query_param_key_sans_stars;
136
+	}
137
+
138
+	/**
139
+	 * Gets the timezone associated with this model (the site timezone, except for GMT datetime fields).
140
+	 * @return string
141
+	 */
142
+	public function getTimezone()
143
+	{
144
+		return $this->timezone;
145
+	}
146
+
147
+	/**
148
+	 * Returns whether or not this is a GMT field
149
+	 * @return boolean
150
+	 */
151
+	public function isGmtField()
152
+	{
153
+		return $this->is_gmt_field;
154
+	}
155
+
156
+	/**
157
+	 * Sets the field indicated by the query parameter key (might be null).
158
+	 * @param EE_Model_Field_Base|null $field
159
+	 */
160
+	private function setField(EE_Model_Field_Base $field = null)
161
+	{
162
+		$this->field = $field;
163
+	}
164
+
165
+	/**
166
+	 * Sets the query parameter key-with-stars-removed.
167
+	 * @param string $query_param_key_sans_stars
168
+	 */
169
+	private function setQueryParamKeySansStars($query_param_key_sans_stars)
170
+	{
171
+		$this->query_param_key_sans_stars = $query_param_key_sans_stars;
172
+	}
173
+
174
+	/**
175
+	 * Sets the timezone (this could be a timezeon offset string).
176
+	 * @param string $timezone
177
+	 */
178
+	private function setTimezone($timezone)
179
+	{
180
+		$this->timezone = $timezone;
181
+	}
182
+
183
+	/**
184
+	 * @param mixed $is_gmt_field
185
+	 */
186
+	private function setIsGmtField($is_gmt_field)
187
+	{
188
+		$this->is_gmt_field = $is_gmt_field;
189
+	}
190
+
191
+	/**
192
+	 * Determines what field, query param name, and query param name without stars, and timezone to use.
193
+	 * @since 4.9.72.p
194
+	 * @type EE_Model_Field_Base $field
195
+	 * @return void {
196
+	 * @throws EE_Error
197
+	 * @throws InvalidDataTypeException
198
+	 * @throws InvalidInterfaceException
199
+	 * @throws InvalidArgumentException
200
+	 */
201
+	private function determineFieldAndTimezone()
202
+	{
203
+		$this->setQueryParamKeySansStars(ModelDataTranslator::removeStarsAndAnythingAfterFromConditionQueryParamKey(
204
+			$this->getQueryParamKey()
205
+		));
206
+		$this->setField(ModelDataTranslator::deduceFieldFromQueryParam(
207
+			$this->getQueryParamKeySansStars(),
208
+			$this->getContext()->getModel()
209
+		));
210
+		// double-check is it a *_gmt field?
211
+		if (
212
+			!$this->getField() instanceof EE_Model_Field_Base
213
+			&& ModelDataTranslator::isGmtDateFieldName($this->getQueryParamKeySansStars())
214
+		) {
215
+			// yep, take off '_gmt', and find the field
216
+			$this->setQueryParamKey(ModelDataTranslator::removeGmtFromFieldName($this->getQueryParamKeySansStars()));
217
+			$this->setField(ModelDataTranslator::deduceFieldFromQueryParam(
218
+				$this->getQueryParamKey(),
219
+				$this->context->getModel()
220
+			));
221
+			$this->setTimezone('UTC');
222
+			$this->setIsGmtField(true);
223
+		} elseif ($this->getField() instanceof EE_Datetime_Field) {
224
+			// so it's not a GMT field. Set the timezone on the model to the default
225
+			$this->setTimezone(EEH_DTT_Helper::get_valid_timezone_string());
226
+		} else {
227
+			// just keep using what's already set for the timezone
228
+			$this->setTimezone($this->context->getModel()->get_timezone());
229
+		}
230
+		$this->assertOnlyAdminCanReadPasswordFields();
231
+	}
232
+
233
+	/**
234
+	 * Throws an exception if a non-admin is trying to query by password.
235
+	 * @since 4.9.74.p
236
+	 * @throws RestException
237
+	 */
238
+	private function assertOnlyAdminCanReadPasswordFields()
239
+	{
240
+		if (
241
+			$this->getField() instanceof EE_Password_Field
242
+			&& ! current_user_can(EE_Restriction_Generator_Base::get_default_restrictions_cap())
243
+		) {
244
+			// only full admins can query by password. sorry bub!
245
+			throw new RestException(
246
+				'only_admins_can_query_by_password',
247
+				// @codingStandardsIgnoreStart
248
+				esc_html__('You attempted to filter by a password field without the needed privileges. Only a full admin is allowed to do that.', 'event_espresso'),
249
+				// @codingStandardsIgnoreEnd
250
+				array(
251
+					'status' => 403
252
+				)
253
+			);
254
+		}
255
+	}
256
+
257
+	/**
258
+	 * Given a ton of input, determines the value to use for the models.
259
+	 * @since 4.9.72.p
260
+	 * @return array|null
261
+	 * @throws DomainException
262
+	 * @throws EE_Error
263
+	 * @throws RestException
264
+	 * @throws DomainException
265
+	 */
266
+	public function determineConditionsQueryParameterValue()
267
+	{
268
+		if ($this->valueIsArrayDuringRead()) {
269
+			return $this->determineModelValueGivenRestInputArray();
270
+		}
271
+		return ModelDataTranslator::prepareFieldValueFromJson(
272
+			$this->getField(),
273
+			$this->getQueryParamValue(),
274
+			$this->getContext()->getRequestedVersion(),
275
+			$this->getTimezone()
276
+		);
277
+	}
278
+
279
+	/**
280
+	 * Given that the array value provided was itself an array, handles finding the correct value to pass to the model.
281
+	 * @since 4.9.72.p
282
+	 * @return array|null
283
+	 * @throws RestException
284
+	 */
285
+	private function determineModelValueGivenRestInputArray()
286
+	{
287
+		$this->transformSimplifiedSpecifiedOperatorSyntaxIntoStandardSyntax();
288
+		// did they specify an operator?
289
+		if ($this->valueIsLegacySpecifiedOperator()) {
290
+			$query_param_value = $this->getQueryParamValue();
291
+			$sub_array_key = $query_param_value[0];
292
+			$translated_value = array($sub_array_key);
293
+			if ($this->operatorIsNAry($sub_array_key)) {
294
+				$translated_value[] = $this->prepareValuesFromJson($query_param_value[1]);
295
+			} elseif ($this->operatorIsTernary($sub_array_key)) {
296
+				$translated_value[] = array(
297
+					$this->prepareValuesFromJson($query_param_value[1][0]),
298
+					$this->prepareValuesFromJson($query_param_value[1][1])
299
+				);
300
+			} elseif ($this->operatorIsLike($sub_array_key)) {
301
+				// we want to leave this value mostly-as-is (eg don't force it to be a float
302
+				// or a boolean or an enum value. Leave it as-is with wildcards etc)
303
+				// but do verify it at least doesn't have any serialized data
304
+				ModelDataTranslator::throwExceptionIfContainsSerializedData($query_param_value[1]);
305
+				$translated_value[] = $query_param_value[1];
306
+			} elseif ($this->operatorIsUnary($sub_array_key)) {
307
+				// no arguments should have been provided, so don't look for any
308
+			} elseif ($this->operatorisBinary($sub_array_key)) {
309
+				// it's a valid operator, but none of the exceptions. Treat it normally.
310
+				$translated_value[] = $this->prepareValuesFromJson($query_param_value[1]);
311
+			} else {
312
+				// so they provided a valid operator, but wrong number of arguments
313
+				$this->throwWrongNumberOfArgsExceptionIfDebugging($sub_array_key);
314
+				$translated_value = null;
315
+			}
316
+		} else {
317
+			// so they didn't provide a valid operator
318
+			// if we aren't in debug mode, then just try our best to fulfill the user's request
319
+			$this->throwInvalidOperatorExceptionIfDebugging();
320
+			$translated_value = null;
321
+		}
322
+		return $translated_value;
323
+	}
324
+
325
+	/**
326
+	 * Returns if this request is a "read" request and the value provided was an array.
327
+	 * This will indicate is such things as `array('<', 123)` and `array('IN', array(1,2,3))` are acceptable or not.
328
+	 * @since 4.9.72.p
329
+	 * @return boolean
330
+	 */
331
+	private function valueIsArrayDuringRead()
332
+	{
333
+		return !$this->getContext()->isWriting() && is_array($this->getQueryParamValue());
334
+	}
335
+
336
+	/**
337
+	 * Returns if the value provided was an associative array (we should have already verified it's an array of some
338
+	 * sort). If the value is an associative array, it had better be in the simplified specified operator structure.
339
+	 * @since 4.9.72.p
340
+	 * @return boolean
341
+	 */
342
+	private function valueIsAssociativeArray()
343
+	{
344
+		return !EEH_Array::is_array_numerically_and_sequentially_indexed($this->getQueryParamValue());
345
+	}
346
+
347
+	/**
348
+	 * Checks if the array value is itself an array that fits into the simplified specified operator structure
349
+	 * (eg `array('!=' => 123)`).
350
+	 * @since 4.9.72.p
351
+	 * @return boolean
352
+	 */
353
+	private function valueIsSimplifiedSpecifiedOperator()
354
+	{
355
+		return count($this->getQueryParamValue()) === 1
356
+			&& array_key_exists(
357
+				key($this->getQueryParamValue()),
358
+				$this->getContext()->getModel()->valid_operators()
359
+			);
360
+	}
361
+
362
+	/**
363
+	 * Throws an exception if the sub-value is an array (eg `array('!=' => array())`). It needs to just be a string,
364
+	 * of either comma-separated-values, or a JSON array.
365
+	 * @since 4.9.72.p
366
+	 * @param $sub_array_key
367
+	 * @param $sub_array_value
368
+	 * @throws RestException
369
+	 */
370
+	private function assertSubValueIsntArray($sub_array_key, $sub_array_value)
371
+	{
372
+		if (is_array($sub_array_value) && EED_Core_Rest_Api::debugMode()) {
373
+			throw new RestException(
374
+				'csv_or_json_string_only',
375
+				sprintf(
376
+					/* translators: 1: variable name*/
377
+					esc_html__(
378
+						'The value provided for the operator "%1$s" should be comma-separated value string or a JSON array.',
379
+						'event_espresso'
380
+					),
381
+					$sub_array_key
382
+				),
383
+				array(
384
+					'status' => 400,
385
+				)
386
+			);
387
+		}
388
+	}
389
+
390
+	/**
391
+	 * Determines if the sub-array key is an operator taking 3 or more operators.
392
+	 * @since 4.9.72.p
393
+	 * @param $sub_array_key
394
+	 * @return boolean
395
+	 */
396
+	private function subArrayKeyIsNonBinaryOperator($sub_array_key)
397
+	{
398
+		return array_key_exists(
399
+			$sub_array_key,
400
+			array_merge(
401
+				$this->getContext()->getModel()->valid_in_style_operators(),
402
+				$this->getContext()->getModel()->valid_between_style_operators()
403
+			)
404
+		);
405
+	}
406
+
407
+	/**
408
+	 * Given that the $sub_array_key is a string, checks if it's an operator taking only 1 argument.
409
+	 * @since 4.9.72.p
410
+	 * @param string $sub_array_key
411
+	 * @return boolean
412
+	 */
413
+	private function subArrayKeyIsUnaryOperator($sub_array_key)
414
+	{
415
+		return array_key_exists(
416
+			$sub_array_key,
417
+			$this->getContext()->getModel()->valid_null_style_operators()
418
+		);
419
+	}
420
+
421
+	/**
422
+	 * Parses the $sub_array_value string into an array (given it could either be a comma-separated-list or a JSON
423
+	 * array). eg `"1,2,3"` or `"[1,2,3]"` into `array(1,2,3)`.
424
+	 * @since 4.9.72.p
425
+	 * @param $sub_array_value
426
+	 * @return array|mixed|object
427
+	 */
428
+	private function extractQuickStyleSpecifiedOperatorValue($sub_array_value)
429
+	{
430
+		// the value should be JSON or CSV
431
+		$values = json_decode($sub_array_value);
432
+		if (!is_array($values)) {
433
+			$values = array_filter(
434
+				array_map(
435
+					'trim',
436
+					explode(
437
+						',',
438
+						$sub_array_value
439
+					)
440
+				)
441
+			);
442
+		}
443
+		return $values;
444
+	}
445
+
446
+	/**
447
+	 * Throws an exception if the value isn't a simplified specified operator (only called when we expect that).
448
+	 * @since 4.9.72.p
449
+	 * @throws RestException
450
+	 */
451
+	private function assertSimplifiedSpecifiedOperator()
452
+	{
453
+		if (!$this->valueIsSimplifiedSpecifiedOperator() && EED_Core_Rest_Api::debugMode()) {
454
+			throw new RestException(
455
+				'numerically_indexed_array_of_values_only',
456
+				sprintf(
457
+					/* translators: 1: variable name*/
458
+					esc_html__(
459
+						'The array provided for the parameter "%1$s" should be numerically indexed.',
460
+						'event_espresso'
461
+					),
462
+					$this->getQueryParamKey()
463
+				),
464
+				array(
465
+					'status' => 400,
466
+				)
467
+			);
468
+		}
469
+	}
470
+
471
+	/**
472
+	 * If query_param_value were in the simplified specific operator structure, change it into the legacy structure.
473
+	 * @since 4.9.72.p
474
+	 * @throws RestException
475
+	 */
476
+	private function transformSimplifiedSpecifiedOperatorSyntaxIntoStandardSyntax()
477
+	{
478
+		if ($this->valueIsAssociativeArray()) {
479
+			$this->assertSimplifiedSpecifiedOperator();
480
+			$query_param_value = $this->getQueryParamValue();
481
+			$sub_array_value = reset($query_param_value);
482
+			$sub_array_key = key($query_param_value);
483
+			$this->assertSubValueIsntArray($sub_array_key, $sub_array_value);
484
+			// they're doing something like "&where[EVT_ID][IN]=1,2,3" or "&where[EVT_ID][>]=5"
485
+			if ($this->subArrayKeyIsNonBinaryOperator($sub_array_key)) {
486
+				$this->setQueryParamValue(array(
487
+					$sub_array_key,
488
+					$this->extractQuickStyleSpecifiedOperatorValue($sub_array_value)
489
+				));
490
+			} elseif ($this->subArrayKeyIsUnaryOperator($sub_array_key)) {
491
+				$this->setQueryParamValue(array($sub_array_key));
492
+			} else {
493
+				$this->setQueryParamValue(array($sub_array_key, $sub_array_value));
494
+			}
495
+		}
496
+	}
497
+
498
+	/**
499
+	 * Returns true is the value is an array using the legacy structure to specify the operator. Eg `array('!=',123)`.
500
+	 * @since 4.9.72.p
501
+	 * @return boolean
502
+	 */
503
+	private function valueIsLegacySpecifiedOperator()
504
+	{
505
+		$valid_operators = $this->getContext()->getModel()->valid_operators();
506
+		$query_param_value = $this->getQueryParamValue();
507
+		return isset($query_param_value[0])
508
+			&& isset($valid_operators[ $query_param_value[0] ]);
509
+	}
510
+
511
+	/**
512
+	 * Returns true if the value specified operator accepts arbitrary number of arguments, like "IN".
513
+	 * @since 4.9.72.p
514
+	 * @param $operator
515
+	 * @return boolean
516
+	 */
517
+	private function operatorIsNAry($operator)
518
+	{
519
+		$valueArray = $this->getQueryParamValue();
520
+		return array_key_exists(
521
+			$operator,
522
+			$this->getContext()->getModel()->valid_in_style_operators()
523
+		)
524
+			&& isset($valueArray[1])
525
+			&& is_array($valueArray[1])
526
+			&& !isset($valueArray[2]);
527
+	}
528
+
529
+	/**
530
+	 * Returns true if the operator accepts 3 arguments (eg "BETWEEN").
531
+	 * So we're looking for a value that looks like
532
+	 * `array('BETWEEN', array('2015-01-01T00:00:00', '2016-01-01T00:00:00'))`.
533
+	 * @since 4.9.72.p
534
+	 * @param $operator
535
+	 * @return boolean
536
+	 */
537
+	private function operatorIsTernary($operator)
538
+	{
539
+		$query_param_value = $this->getQueryParamValue();
540
+		return array_key_exists($operator, $this->getContext()->getModel()->valid_between_style_operators())
541
+			&& isset($query_param_value[1])
542
+			&& is_array($query_param_value[1])
543
+			&& isset($query_param_value[1][0], $query_param_value[1][1])
544
+			&& !isset($query_param_value[1][2])
545
+			&& !isset($query_param_value[2]);
546
+	}
547
+
548
+	/**
549
+	 * Returns true if the operator is a similar to LIKE, indicating the value may have wildcards we should leave alone.
550
+	 * @since 4.9.72.p
551
+	 * @param $operator
552
+	 * @return boolean
553
+	 */
554
+	private function operatorIsLike($operator)
555
+	{
556
+		$query_param_value = $this->getQueryParamValue();
557
+		return array_key_exists($operator, $this->getContext()->getModel()->valid_like_style_operators())
558
+			&& isset($query_param_value[1])
559
+			&& !isset($query_param_value[2]);
560
+	}
561
+
562
+	/**
563
+	 * Returns true if the operator only takes one argument (eg it's like `IS NULL`).
564
+	 * @since 4.9.72.p
565
+	 * @param $operator
566
+	 * @return boolean
567
+	 */
568
+	private function operatorIsUnary($operator)
569
+	{
570
+		$query_param_value = $this->getQueryParamValue();
571
+		return array_key_exists($operator, $this->getContext()->getModel()->valid_null_style_operators())
572
+			&& !isset($query_param_value[1]);
573
+	}
574
+
575
+	/**
576
+	 * Returns true if the operator specified is a binary opeator (eg `=`, `!=`)
577
+	 * @since 4.9.72.p
578
+	 * @param $operator
579
+	 * @return boolean
580
+	 */
581
+	private function operatorisBinary($operator)
582
+	{
583
+		$query_param_value = $this->getQueryParamValue();
584
+		$model = $this->getContext()->getModel();
585
+		return isset($query_param_value[1])
586
+			&& !isset($query_param_value[2])
587
+			&& !array_key_exists(
588
+				$operator,
589
+				array_merge(
590
+					$model->valid_in_style_operators(),
591
+					$model->valid_null_style_operators(),
592
+					$model->valid_like_style_operators(),
593
+					$model->valid_between_style_operators()
594
+				)
595
+			);
596
+	}
597
+
598
+	/**
599
+	 * If we're debugging, throws an exception saying that the wrong number of arguments was provided.
600
+	 * @since 4.9.72.p
601
+	 * @param $operator
602
+	 * @throws RestException
603
+	 */
604
+	private function throwWrongNumberOfArgsExceptionIfDebugging($operator)
605
+	{
606
+		if (EED_Core_Rest_Api::debugMode()) {
607
+			throw new RestException(
608
+				'wrong_number_of_arguments',
609
+				sprintf(
610
+					esc_html__(
611
+						'The operator you provided, "%1$s" had the wrong number of arguments',
612
+						'event_espresso'
613
+					),
614
+					$operator
615
+				),
616
+				array(
617
+					'status' => 400,
618
+				)
619
+			);
620
+		}
621
+	}
622
+
623
+	/**
624
+	 * Wrapper for ModelDataTranslator::prepareFieldValuesFromJson(), just a tad more DRY.
625
+	 * @since 4.9.72.p
626
+	 * @param $value
627
+	 * @return mixed
628
+	 * @throws RestException
629
+	 */
630
+	private function prepareValuesFromJson($value)
631
+	{
632
+		return ModelDataTranslator::prepareFieldValuesFromJson(
633
+			$this->getField(),
634
+			$value,
635
+			$this->getContext()->getRequestedVersion(),
636
+			$this->getTimezone()
637
+		);
638
+	}
639
+
640
+	/**
641
+	 * Throws an exception if an invalid operator was specified and we're debugging.
642
+	 * @since 4.9.72.p
643
+	 * @throws RestException
644
+	 */
645
+	private function throwInvalidOperatorExceptionIfDebugging()
646
+	{
647
+		// so they didn't provide a valid operator
648
+		if (EED_Core_Rest_Api::debugMode()) {
649
+			throw new RestException(
650
+				'invalid_operator',
651
+				sprintf(
652
+					esc_html__(
653
+						'You provided an invalid parameter, with key "%1$s" and value "%2$s"',
654
+						'event_espresso'
655
+					),
656
+					$this->getQueryParamKey(),
657
+					$this->getQueryParamValue()
658
+				),
659
+				array(
660
+					'status' => 400,
661
+				)
662
+			);
663
+		}
664
+	}
665
+
666
+	/**
667
+	 * Returns true if the query_param_key was a logic query parameter, eg `OR`, `AND`, `NOT`, `OR*`, etc.
668
+	 * @since 4.9.72.p
669
+	 * @return boolean
670
+	 */
671
+	private function isLogicQueryParam()
672
+	{
673
+		return in_array($this->getQueryParamKeySansStars(), $this->getContext()->getModel()->logic_query_param_keys());
674
+	}
675
+
676
+
677
+	/**
678
+	 * If the query param isn't for a field, it must be a nested query parameter which requires different logic.
679
+	 * @since 4.9.72.p
680
+	 * @return array
681
+	 * @throws DomainException
682
+	 * @throws EE_Error
683
+	 * @throws RestException
684
+	 * @throws InvalidDataTypeException
685
+	 * @throws InvalidInterfaceException
686
+	 * @throws InvalidArgumentException
687
+	 */
688
+	public function determineNestedConditionQueryParameters()
689
+	{
690
+
691
+		// so this param doesn't correspond to a field eh?
692
+		if ($this->getContext()->isWriting()) {
693
+			// always tell API clients about invalid parameters when they're creating data. Otherwise,
694
+			// they are probably going to create invalid data
695
+			throw new RestException(
696
+				'invalid_field',
697
+				sprintf(
698
+					/* translators: 1: variable name */
699
+					esc_html__('You have provided an invalid parameter: "%1$s"', 'event_espresso'),
700
+					$this->getQueryParamKey()
701
+				)
702
+			);
703
+		}
704
+		// so it's not for a field, is it a logic query param key?
705
+		if ($this->isLogicQueryParam()) {
706
+			return ModelDataTranslator::prepareConditionsQueryParamsForModels(
707
+				$this->getQueryParamValue(),
708
+				$this->getContext()->getModel(),
709
+				$this->getContext()->getRequestedVersion()
710
+			);
711
+		}
712
+		if (EED_Core_Rest_Api::debugMode()) {
713
+			// only tell API clients they got it wrong if we're in debug mode
714
+			// otherwise try our best ot fulfill their request by ignoring this invalid data
715
+			throw new RestException(
716
+				'invalid_parameter',
717
+				sprintf(
718
+					/* translators: 1: variable name */
719
+					esc_html__(
720
+						'You provided an invalid parameter, with key "%1$s"',
721
+						'event_espresso'
722
+					),
723
+					$this->getQueryParamKey()
724
+				),
725
+				array(
726
+					'status' => 400,
727
+				)
728
+			);
729
+		}
730
+		return null;
731
+	}
732 732
 }
733 733
 // End of file RestQueryParamMetadata.php
734 734
 // Location: EventEspresso\core\libraries\rest_api/RestQueryParamMetadata.php
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
         ));
210 210
         // double-check is it a *_gmt field?
211 211
         if (
212
-            !$this->getField() instanceof EE_Model_Field_Base
212
+            ! $this->getField() instanceof EE_Model_Field_Base
213 213
             && ModelDataTranslator::isGmtDateFieldName($this->getQueryParamKeySansStars())
214 214
         ) {
215 215
             // yep, take off '_gmt', and find the field
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
      */
331 331
     private function valueIsArrayDuringRead()
332 332
     {
333
-        return !$this->getContext()->isWriting() && is_array($this->getQueryParamValue());
333
+        return ! $this->getContext()->isWriting() && is_array($this->getQueryParamValue());
334 334
     }
335 335
 
336 336
     /**
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
      */
342 342
     private function valueIsAssociativeArray()
343 343
     {
344
-        return !EEH_Array::is_array_numerically_and_sequentially_indexed($this->getQueryParamValue());
344
+        return ! EEH_Array::is_array_numerically_and_sequentially_indexed($this->getQueryParamValue());
345 345
     }
346 346
 
347 347
     /**
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
     {
430 430
         // the value should be JSON or CSV
431 431
         $values = json_decode($sub_array_value);
432
-        if (!is_array($values)) {
432
+        if ( ! is_array($values)) {
433 433
             $values = array_filter(
434 434
                 array_map(
435 435
                     'trim',
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
      */
451 451
     private function assertSimplifiedSpecifiedOperator()
452 452
     {
453
-        if (!$this->valueIsSimplifiedSpecifiedOperator() && EED_Core_Rest_Api::debugMode()) {
453
+        if ( ! $this->valueIsSimplifiedSpecifiedOperator() && EED_Core_Rest_Api::debugMode()) {
454 454
             throw new RestException(
455 455
                 'numerically_indexed_array_of_values_only',
456 456
                 sprintf(
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
         $valid_operators = $this->getContext()->getModel()->valid_operators();
506 506
         $query_param_value = $this->getQueryParamValue();
507 507
         return isset($query_param_value[0])
508
-            && isset($valid_operators[ $query_param_value[0] ]);
508
+            && isset($valid_operators[$query_param_value[0]]);
509 509
     }
510 510
 
511 511
     /**
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
         )
524 524
             && isset($valueArray[1])
525 525
             && is_array($valueArray[1])
526
-            && !isset($valueArray[2]);
526
+            && ! isset($valueArray[2]);
527 527
     }
528 528
 
529 529
     /**
@@ -541,8 +541,8 @@  discard block
 block discarded – undo
541 541
             && isset($query_param_value[1])
542 542
             && is_array($query_param_value[1])
543 543
             && isset($query_param_value[1][0], $query_param_value[1][1])
544
-            && !isset($query_param_value[1][2])
545
-            && !isset($query_param_value[2]);
544
+            && ! isset($query_param_value[1][2])
545
+            && ! isset($query_param_value[2]);
546 546
     }
547 547
 
548 548
     /**
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
         $query_param_value = $this->getQueryParamValue();
557 557
         return array_key_exists($operator, $this->getContext()->getModel()->valid_like_style_operators())
558 558
             && isset($query_param_value[1])
559
-            && !isset($query_param_value[2]);
559
+            && ! isset($query_param_value[2]);
560 560
     }
561 561
 
562 562
     /**
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
     {
570 570
         $query_param_value = $this->getQueryParamValue();
571 571
         return array_key_exists($operator, $this->getContext()->getModel()->valid_null_style_operators())
572
-            && !isset($query_param_value[1]);
572
+            && ! isset($query_param_value[1]);
573 573
     }
574 574
 
575 575
     /**
@@ -583,8 +583,8 @@  discard block
 block discarded – undo
583 583
         $query_param_value = $this->getQueryParamValue();
584 584
         $model = $this->getContext()->getModel();
585 585
         return isset($query_param_value[1])
586
-            && !isset($query_param_value[2])
587
-            && !array_key_exists(
586
+            && ! isset($query_param_value[2])
587
+            && ! array_key_exists(
588 588
                 $operator,
589 589
                 array_merge(
590 590
                     $model->valid_in_style_operators(),
Please login to merge, or discard this patch.
core/libraries/rest_api/changes/ChangesIn40834.php 1 patch
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -12,39 +12,39 @@
 block discarded – undo
12 12
 class ChangesIn40834 extends ChangesInBase
13 13
 {
14 14
 
15
-    /**
16
-     * Adds hooks so requests to 4.8.29 don't have the checkin endpoints
17
-     */
18
-    public function setHooks()
19
-    {
20
-        // set a hook to remove the checkout/checkout endpoints if the request
21
-        // is for lower than 4.8.33
22
-        add_filter(
23
-            'FHEE__EventEspresso\core\libraries\rest_api\controllers\Base___get_response_headers',
24
-            array($this, 'removeResponseHeaders'),
25
-            10,
26
-            3
27
-        );
28
-    }
15
+	/**
16
+	 * Adds hooks so requests to 4.8.29 don't have the checkin endpoints
17
+	 */
18
+	public function setHooks()
19
+	{
20
+		// set a hook to remove the checkout/checkout endpoints if the request
21
+		// is for lower than 4.8.33
22
+		add_filter(
23
+			'FHEE__EventEspresso\core\libraries\rest_api\controllers\Base___get_response_headers',
24
+			array($this, 'removeResponseHeaders'),
25
+			10,
26
+			3
27
+		);
28
+	}
29 29
 
30 30
 
31
-    /**
32
-     * Removes the checkin and checkout endpoints from the index for requests
33
-     * to api versions lowers than 4.8.33
34
-     *
35
-     * @param array  $response_headers
36
-     * @param Base   $controller
37
-     * @param string $requested_version
38
-     * @return array like $routes_on_this_version
39
-     */
40
-    public function removeResponseHeaders($response_headers, $controller, $requested_version)
41
-    {
42
-        if (
43
-            $controller instanceof Base
44
-            && $this->appliesToVersion($requested_version)
45
-        ) {
46
-            return array();
47
-        }
48
-        return $response_headers;
49
-    }
31
+	/**
32
+	 * Removes the checkin and checkout endpoints from the index for requests
33
+	 * to api versions lowers than 4.8.33
34
+	 *
35
+	 * @param array  $response_headers
36
+	 * @param Base   $controller
37
+	 * @param string $requested_version
38
+	 * @return array like $routes_on_this_version
39
+	 */
40
+	public function removeResponseHeaders($response_headers, $controller, $requested_version)
41
+	{
42
+		if (
43
+			$controller instanceof Base
44
+			&& $this->appliesToVersion($requested_version)
45
+		) {
46
+			return array();
47
+		}
48
+		return $response_headers;
49
+	}
50 50
 }
Please login to merge, or discard this patch.