Completed
Branch FET/reg-form-builder/main (d0d867)
by
unknown
09:57 queued 24s
created
core/libraries/shortcodes/EE_Event_Shortcodes.lib.php 3 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -283,6 +283,7 @@
 block discarded – undo
283 283
      *
284 284
      * @param  boolean $full_link if TRUE (default) we return the html for the name of the event linked to the event.
285 285
      *                            Otherwise we just return the url of the event.
286
+     * @param EE_Event $event
286 287
      * @return string
287 288
      */
288 289
     private function _get_event_link($event, $full_link = true)
Please login to merge, or discard this patch.
Indentation   +293 added lines, -293 removed lines patch added patch discarded remove patch
@@ -19,297 +19,297 @@
 block discarded – undo
19 19
 {
20 20
 
21 21
 
22
-    /**
23
-     * Will hold the EE_Event if available
24
-     *
25
-     * @var EE_Event
26
-     */
27
-    protected $_event;
28
-
29
-
30
-    public function __construct()
31
-    {
32
-        parent::__construct();
33
-    }
34
-
35
-
36
-    protected function _init_props()
37
-    {
38
-        $this->label = __('Event Shortcodes', 'event_espresso');
39
-        $this->description = __('All shortcodes specific to event related data', 'event_espresso');
40
-        $this->_shortcodes = array(
41
-            '[EVENT_ID]'                              => __(
42
-                'Will be replaced by the event ID of an event',
43
-                'event_espresso'
44
-            ),
45
-            '[EVENT]'                                 => __('The name of the event', 'event_espresso'),
46
-            '[EVENT_NAME]'                            => __(
47
-                "This also can be used for the name of the event",
48
-                'event_espresso'
49
-            ),
50
-            '[EVENT_PHONE]'                           => __(
51
-                'The phone number for the event (usually an info number)',
52
-                'event_espresso'
53
-            ),
54
-            '[EVENT_DESCRIPTION]'                     => __('The description of the event', 'event_espresso'),
55
-            '[EVENT_EXCERPT]'                         => __(
56
-                'This gets parsed to the value for the excerpt field in the event or blank if there is no excerpt.',
57
-                'event_espresso'
58
-            ),
59
-            '[EVENT_LINK]'                            => __('A link associated with the event', 'event_espresso'),
60
-            '[EVENT_URL]'                             => __(
61
-                'A link to the event set up on the host site.',
62
-                'event_espresso'
63
-            ),
64
-            '[VIRTUAL_URL]'                           => __(
65
-                'What was used for the "URL of Event" field in the Venue settings',
66
-                'event_espresso'
67
-            ),
68
-            '[VIRTUAL_PHONE]'                         => __(
69
-                'An alternate phone number for the event. Typically used as a "call-in" number',
70
-                'event_espresso'
71
-            ),
72
-            '[EVENT_IMAGE]'                           => __(
73
-                'This will parse to the Feature image for the event.',
74
-                'event_espresso'
75
-            ),
76
-            '[EVENT_IMAGE_*]'                         => sprintf(
77
-                __(
78
-                    'This will parse to the Feature image for the event, %1$ssize%2$s can be set to determine the size of the image loaded by the shortcode. The %1$swidth%2$s and/or %1$sheight%2$s can also be set to determine the width and height of the image when output. By default the shortcode will load the %1$sthumbnail%2$s image size.',
79
-                    'event_espresso'
80
-                ),
81
-                '<code>',
82
-                '</code>'
83
-            ),
84
-            '[EVENT_TOTAL_AVAILABLE_SPACES_*]'        => sprintf(
85
-                __(
86
-                    'This will parse to the total available spaces for an event. Calculating total spaces is approximate because it is dependent on the complexity of limits on your event.  There are two methods of calculation (which can be indicated by the %1$smethod%2$s param on the shortcode).  %1$scurrent%2$s which will do a more accurate calculation of total available spaces based on current sales, and %1$sfull%2$s which will be the maximum total available spaces that is on the event in optimal conditions. The shortcode will default to current.',
87
-                    'event_espresso'
88
-                ),
89
-                '<code>',
90
-                '</code>'
91
-            ),
92
-            '[EVENT_TOTAL_SPOTS_TAKEN]'               => __(
93
-                'This shortcode will parse to the output the total approved registrations for this event',
94
-                'event_espresso'
95
-            ),
96
-            '[EVENT_FACEBOOK_URL]'                    => __(
97
-                'This will return the Facebook URL for the event if you have it set via custom field in your event, otherwise it will use the Facebook URL set in "Your Organization Settings". To set the facebook url in your event, add a custom field with the key as <code>event_facebook</code> and the value as your facebook url.',
98
-                'event_espresso'
99
-            ),
100
-            '[EVENT_TWITTER_URL]'                     => __(
101
-                'This will return the Twitter URL for the event if you have it set via custom field in your event, otherwise it will use the Twitter URL set in "Your Organization Settings". To set the facebook url in your event, add a custom field with the key as <code>event_twitter</code> and the value as your facebook url',
102
-                'event_espresso'
103
-            ),
104
-            '[EVENT_META_*]'                          => sprintf(
105
-                __(
106
-                    'This is a special dynamic shortcode. After the "*", add the exact name for your custom field, if there is a value set for that custom field within the event then it will be output in place of this shortcode. If you use shortcodes within your custom fields set %1$sdo_shortcode=true%2$s at the end of the shortcode to run the value through the do_shortcode function. ',
107
-                    'event_espresso'
108
-                ),
109
-                '<code>',
110
-                '</code>'
111
-            ),
112
-            '[REGISTRATION_LIST_TABLE_FOR_EVENT_URL]' => __(
113
-                'This parses to the url for the registration list table filtered by registrations for this event.',
114
-                'event_espresso'
115
-            ),
116
-        );
117
-    }
118
-
119
-
120
-    protected function _parser($shortcode)
121
-    {
122
-
123
-
124
-        $this->_event = $this->_data instanceof EE_Event ? $this->_data : null;
125
-
126
-        // if no event, then let's see if there is a reg_obj.  If there IS, then we'll try and grab the event from the reg_obj instead.
127
-        if (empty($this->_event)) {
128
-            $aee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null;
129
-            $aee = $this->_extra_data instanceof EE_Messages_Addressee ? $this->_extra_data : $aee;
130
-
131
-            $this->_event = $aee instanceof EE_Messages_Addressee && $aee->reg_obj instanceof EE_Registration
132
-                ? $aee->reg_obj->event() : null;
133
-        }
134
-
135
-
136
-        // If there is no event objecdt by now then get out.
137
-        if (! $this->_event instanceof EE_Event) {
138
-            return '';
139
-        }
140
-
141
-        switch ($shortcode) {
142
-            case '[EVENT_ID]':
143
-                return $this->_event->ID();
144
-                break;
145
-
146
-            case '[EVENT]':
147
-            case '[EVENT_NAME]':
148
-                return $this->_event->get('EVT_name');
149
-                break;
150
-
151
-            case '[EVENT_PHONE]':
152
-                return $this->_event->get('EVT_phone');
153
-                break;
154
-
155
-            case '[EVENT_DESCRIPTION]':
156
-                return $this->_event->get('EVT_desc');
157
-                break;
158
-
159
-            case '[EVENT_EXCERPT]':
160
-                return $this->_event->get('EVT_short_desc');
161
-                break;
162
-
163
-            case '[EVENT_LINK]':
164
-                return $this->_get_event_link($this->_event);
165
-                break;
166
-
167
-            case '[EVENT_URL]':
168
-                return $this->_get_event_link($this->_event, false);
169
-                break;
170
-
171
-            case '[VIRTUAL_URL]':
172
-                $venue = $this->_event->get_first_related('Venue');
173
-                if (empty($venue)) {
174
-                    return '';
175
-                }
176
-                return $venue->get('VNU_virtual_url');
177
-
178
-            case '[VIRTUAL_PHONE]':
179
-                $venue = $this->_event->get_first_related('Venue');
180
-                if (empty($venue)) {
181
-                    return '';
182
-                }
183
-                return $venue->get('VNU_virtual_phone');
184
-                break;
185
-
186
-            case '[EVENT_IMAGE]':
187
-                $image = $this->_event->feature_image_url(array(600, 300));
188
-                // @todo: eventually we should make this an attribute shortcode so that em can send along what size they want returned.
189
-                return ! empty($image)
190
-                    ? '<img src="' . $image . '" alt="'
191
-                      . sprintf(
192
-                          esc_attr__('%s Feature Image', 'event_espresso'),
193
-                          $this->_event->get('EVT_name')
194
-                      ) . '" />'
195
-                    : '';
196
-                break;
197
-
198
-            case '[EVENT_FACEBOOK_URL]':
199
-                $facebook_url = $this->_event->get_post_meta('event_facebook', true);
200
-                return empty($facebook_url) ? EE_Registry::instance()->CFG->organization->get_pretty('facebook')
201
-                    : $facebook_url;
202
-                break;
203
-
204
-            case '[EVENT_TWITTER_URL]':
205
-                $twitter_url = $this->_event->get_post_meta('event_twitter', true);
206
-                return empty($twitter_url) ? EE_Registry::instance()->CFG->organization->get_pretty('twitter')
207
-                    : $twitter_url;
208
-                break;
209
-
210
-            case '[EVENT_AUTHOR_EMAIL]':
211
-                $author_id = $this->_event->get('EVT_wp_user');
212
-                $user_data = get_userdata((int) $author_id);
213
-                return $user_data->user_email;
214
-                break;
215
-
216
-            case '[EVENT_TOTAL_SPOTS_TAKEN]':
217
-                return EEM_Registration::instance()->count(
218
-                    array(array('EVT_ID' => $this->_event->ID(), 'STS_ID' => EEM_Registration::status_id_approved)),
219
-                    'REG_ID',
220
-                    true
221
-                );
222
-                break;
223
-
224
-            case '[REGISTRATION_LIST_TABLE_FOR_EVENT_URL]':
225
-                return EEH_URL::add_query_args_and_nonce(
226
-                    array(
227
-                        'event_id' => $this->_event->ID(),
228
-                        'page'     => 'espresso_registrations',
229
-                        'action'   => 'default',
230
-                    ),
231
-                    admin_url('admin.php'),
232
-                    true
233
-                );
234
-                break;
235
-        }
236
-
237
-        if (strpos($shortcode, '[EVENT_META_*') !== false) {
238
-            // Strip the shortcode itself from $shortcode leaving any attributes set.
239
-            // Removing the * is correct here as _* is used to indiciate a dynamic shortcode.
240
-            $shortcode = str_replace('[EVENT_META_*', '', $shortcode);
241
-            $shortcode = trim(str_replace(']', '', $shortcode));
242
-            // Get any attributes set on this shortcode.
243
-            $attrs = $this->_get_shortcode_attrs($shortcode);
244
-            // The meta_key set on the shortcode should always be the first value in the array.
245
-            $meta_key = $attrs[0];
246
-            // Pull the meta value from the event post.
247
-            $event_meta = $this->_event->get_post_meta($meta_key, true);
248
-            // If we have no event_meta, just return an empty string.
249
-            if (empty($event_meta)) {
250
-                return '';
251
-            }
252
-            // Add a filter to allow all instances of EVENT_META_* to run through do_shortcode, default to false.
253
-            // Check if a do_shortcode attribute was set to true and if so run $event_meta through that function.
254
-            if (
255
-                apply_filters('FHEE__EventEspresso_core_libraries_shortcodes_EE_Event_Shortcodes___parser__event_meta_do_shortcode', false)
256
-                || !empty($attrs['do_shortcode']) && filter_var($attrs['do_shortcode'], FILTER_VALIDATE_BOOLEAN)
257
-            ) {
258
-                return do_shortcode($event_meta);
259
-            }
260
-            // Still here? We just need to return the event_meta value as is.
261
-            return $event_meta;
262
-        }
263
-
264
-        if (strpos($shortcode, '[EVENT_TOTAL_AVAILABLE_SPACES_*') !== false) {
265
-            $attrs = $this->_get_shortcode_attrs($shortcode);
266
-            $method = empty($attrs['method']) ? 'current' : $attrs['method'];
267
-            $method = $method === 'current';
268
-            $available = $this->_event->total_available_spaces($method);
269
-            return $available === EE_INF ? '&infin;' : $available;
270
-        }
271
-
272
-        if (strpos($shortcode, '[EVENT_IMAGE_*') !== false) {
273
-            $attrs = $this->_get_shortcode_attrs($shortcode);
274
-            $width = empty($attrs['width']) ? '' : ' width="' . $attrs['width'] . '"';
275
-            $height = empty($attrs['height']) ? '' : ' height="' . $attrs['height'] . '"';
276
-
277
-            // Size may be set to a string such as 'tumbnail' or "width, height" eg - '200,200'
278
-            if (! empty($attrs['size'])) {
279
-                $size = explode(',', $attrs['size']);
280
-                if (count($size) === 1) {
281
-                    $size = $size[0];
282
-                }
283
-            } else {
284
-                $size = 'thumbnail';
285
-            }
286
-
287
-            $image = $this->_event->feature_image_url($size);
288
-
289
-            return ! empty($image)
290
-                ? '<img src="' . $image . '" alt="'
291
-                  . sprintf(
292
-                      esc_attr__('%s Feature Image', 'event_espresso'),
293
-                      $this->_event->get('EVT_name')
294
-                  ) . '"' . $width . $height . '/>'
295
-                : '';
296
-        }
297
-
298
-        return '';
299
-    }
300
-
301
-
302
-    /**
303
-     * returns the link to the event
304
-     *
305
-     * @param  boolean $full_link if TRUE (default) we return the html for the name of the event linked to the event.
306
-     *                            Otherwise we just return the url of the event.
307
-     * @return string
308
-     */
309
-    private function _get_event_link($event, $full_link = true)
310
-    {
311
-        $url = get_permalink($event->ID());
312
-
313
-        return $full_link ? '<a href="' . $url . '">' . $event->get('EVT_name') . '</a>' : $url;
314
-    }
22
+	/**
23
+	 * Will hold the EE_Event if available
24
+	 *
25
+	 * @var EE_Event
26
+	 */
27
+	protected $_event;
28
+
29
+
30
+	public function __construct()
31
+	{
32
+		parent::__construct();
33
+	}
34
+
35
+
36
+	protected function _init_props()
37
+	{
38
+		$this->label = __('Event Shortcodes', 'event_espresso');
39
+		$this->description = __('All shortcodes specific to event related data', 'event_espresso');
40
+		$this->_shortcodes = array(
41
+			'[EVENT_ID]'                              => __(
42
+				'Will be replaced by the event ID of an event',
43
+				'event_espresso'
44
+			),
45
+			'[EVENT]'                                 => __('The name of the event', 'event_espresso'),
46
+			'[EVENT_NAME]'                            => __(
47
+				"This also can be used for the name of the event",
48
+				'event_espresso'
49
+			),
50
+			'[EVENT_PHONE]'                           => __(
51
+				'The phone number for the event (usually an info number)',
52
+				'event_espresso'
53
+			),
54
+			'[EVENT_DESCRIPTION]'                     => __('The description of the event', 'event_espresso'),
55
+			'[EVENT_EXCERPT]'                         => __(
56
+				'This gets parsed to the value for the excerpt field in the event or blank if there is no excerpt.',
57
+				'event_espresso'
58
+			),
59
+			'[EVENT_LINK]'                            => __('A link associated with the event', 'event_espresso'),
60
+			'[EVENT_URL]'                             => __(
61
+				'A link to the event set up on the host site.',
62
+				'event_espresso'
63
+			),
64
+			'[VIRTUAL_URL]'                           => __(
65
+				'What was used for the "URL of Event" field in the Venue settings',
66
+				'event_espresso'
67
+			),
68
+			'[VIRTUAL_PHONE]'                         => __(
69
+				'An alternate phone number for the event. Typically used as a "call-in" number',
70
+				'event_espresso'
71
+			),
72
+			'[EVENT_IMAGE]'                           => __(
73
+				'This will parse to the Feature image for the event.',
74
+				'event_espresso'
75
+			),
76
+			'[EVENT_IMAGE_*]'                         => sprintf(
77
+				__(
78
+					'This will parse to the Feature image for the event, %1$ssize%2$s can be set to determine the size of the image loaded by the shortcode. The %1$swidth%2$s and/or %1$sheight%2$s can also be set to determine the width and height of the image when output. By default the shortcode will load the %1$sthumbnail%2$s image size.',
79
+					'event_espresso'
80
+				),
81
+				'<code>',
82
+				'</code>'
83
+			),
84
+			'[EVENT_TOTAL_AVAILABLE_SPACES_*]'        => sprintf(
85
+				__(
86
+					'This will parse to the total available spaces for an event. Calculating total spaces is approximate because it is dependent on the complexity of limits on your event.  There are two methods of calculation (which can be indicated by the %1$smethod%2$s param on the shortcode).  %1$scurrent%2$s which will do a more accurate calculation of total available spaces based on current sales, and %1$sfull%2$s which will be the maximum total available spaces that is on the event in optimal conditions. The shortcode will default to current.',
87
+					'event_espresso'
88
+				),
89
+				'<code>',
90
+				'</code>'
91
+			),
92
+			'[EVENT_TOTAL_SPOTS_TAKEN]'               => __(
93
+				'This shortcode will parse to the output the total approved registrations for this event',
94
+				'event_espresso'
95
+			),
96
+			'[EVENT_FACEBOOK_URL]'                    => __(
97
+				'This will return the Facebook URL for the event if you have it set via custom field in your event, otherwise it will use the Facebook URL set in "Your Organization Settings". To set the facebook url in your event, add a custom field with the key as <code>event_facebook</code> and the value as your facebook url.',
98
+				'event_espresso'
99
+			),
100
+			'[EVENT_TWITTER_URL]'                     => __(
101
+				'This will return the Twitter URL for the event if you have it set via custom field in your event, otherwise it will use the Twitter URL set in "Your Organization Settings". To set the facebook url in your event, add a custom field with the key as <code>event_twitter</code> and the value as your facebook url',
102
+				'event_espresso'
103
+			),
104
+			'[EVENT_META_*]'                          => sprintf(
105
+				__(
106
+					'This is a special dynamic shortcode. After the "*", add the exact name for your custom field, if there is a value set for that custom field within the event then it will be output in place of this shortcode. If you use shortcodes within your custom fields set %1$sdo_shortcode=true%2$s at the end of the shortcode to run the value through the do_shortcode function. ',
107
+					'event_espresso'
108
+				),
109
+				'<code>',
110
+				'</code>'
111
+			),
112
+			'[REGISTRATION_LIST_TABLE_FOR_EVENT_URL]' => __(
113
+				'This parses to the url for the registration list table filtered by registrations for this event.',
114
+				'event_espresso'
115
+			),
116
+		);
117
+	}
118
+
119
+
120
+	protected function _parser($shortcode)
121
+	{
122
+
123
+
124
+		$this->_event = $this->_data instanceof EE_Event ? $this->_data : null;
125
+
126
+		// if no event, then let's see if there is a reg_obj.  If there IS, then we'll try and grab the event from the reg_obj instead.
127
+		if (empty($this->_event)) {
128
+			$aee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null;
129
+			$aee = $this->_extra_data instanceof EE_Messages_Addressee ? $this->_extra_data : $aee;
130
+
131
+			$this->_event = $aee instanceof EE_Messages_Addressee && $aee->reg_obj instanceof EE_Registration
132
+				? $aee->reg_obj->event() : null;
133
+		}
134
+
135
+
136
+		// If there is no event objecdt by now then get out.
137
+		if (! $this->_event instanceof EE_Event) {
138
+			return '';
139
+		}
140
+
141
+		switch ($shortcode) {
142
+			case '[EVENT_ID]':
143
+				return $this->_event->ID();
144
+				break;
145
+
146
+			case '[EVENT]':
147
+			case '[EVENT_NAME]':
148
+				return $this->_event->get('EVT_name');
149
+				break;
150
+
151
+			case '[EVENT_PHONE]':
152
+				return $this->_event->get('EVT_phone');
153
+				break;
154
+
155
+			case '[EVENT_DESCRIPTION]':
156
+				return $this->_event->get('EVT_desc');
157
+				break;
158
+
159
+			case '[EVENT_EXCERPT]':
160
+				return $this->_event->get('EVT_short_desc');
161
+				break;
162
+
163
+			case '[EVENT_LINK]':
164
+				return $this->_get_event_link($this->_event);
165
+				break;
166
+
167
+			case '[EVENT_URL]':
168
+				return $this->_get_event_link($this->_event, false);
169
+				break;
170
+
171
+			case '[VIRTUAL_URL]':
172
+				$venue = $this->_event->get_first_related('Venue');
173
+				if (empty($venue)) {
174
+					return '';
175
+				}
176
+				return $venue->get('VNU_virtual_url');
177
+
178
+			case '[VIRTUAL_PHONE]':
179
+				$venue = $this->_event->get_first_related('Venue');
180
+				if (empty($venue)) {
181
+					return '';
182
+				}
183
+				return $venue->get('VNU_virtual_phone');
184
+				break;
185
+
186
+			case '[EVENT_IMAGE]':
187
+				$image = $this->_event->feature_image_url(array(600, 300));
188
+				// @todo: eventually we should make this an attribute shortcode so that em can send along what size they want returned.
189
+				return ! empty($image)
190
+					? '<img src="' . $image . '" alt="'
191
+					  . sprintf(
192
+						  esc_attr__('%s Feature Image', 'event_espresso'),
193
+						  $this->_event->get('EVT_name')
194
+					  ) . '" />'
195
+					: '';
196
+				break;
197
+
198
+			case '[EVENT_FACEBOOK_URL]':
199
+				$facebook_url = $this->_event->get_post_meta('event_facebook', true);
200
+				return empty($facebook_url) ? EE_Registry::instance()->CFG->organization->get_pretty('facebook')
201
+					: $facebook_url;
202
+				break;
203
+
204
+			case '[EVENT_TWITTER_URL]':
205
+				$twitter_url = $this->_event->get_post_meta('event_twitter', true);
206
+				return empty($twitter_url) ? EE_Registry::instance()->CFG->organization->get_pretty('twitter')
207
+					: $twitter_url;
208
+				break;
209
+
210
+			case '[EVENT_AUTHOR_EMAIL]':
211
+				$author_id = $this->_event->get('EVT_wp_user');
212
+				$user_data = get_userdata((int) $author_id);
213
+				return $user_data->user_email;
214
+				break;
215
+
216
+			case '[EVENT_TOTAL_SPOTS_TAKEN]':
217
+				return EEM_Registration::instance()->count(
218
+					array(array('EVT_ID' => $this->_event->ID(), 'STS_ID' => EEM_Registration::status_id_approved)),
219
+					'REG_ID',
220
+					true
221
+				);
222
+				break;
223
+
224
+			case '[REGISTRATION_LIST_TABLE_FOR_EVENT_URL]':
225
+				return EEH_URL::add_query_args_and_nonce(
226
+					array(
227
+						'event_id' => $this->_event->ID(),
228
+						'page'     => 'espresso_registrations',
229
+						'action'   => 'default',
230
+					),
231
+					admin_url('admin.php'),
232
+					true
233
+				);
234
+				break;
235
+		}
236
+
237
+		if (strpos($shortcode, '[EVENT_META_*') !== false) {
238
+			// Strip the shortcode itself from $shortcode leaving any attributes set.
239
+			// Removing the * is correct here as _* is used to indiciate a dynamic shortcode.
240
+			$shortcode = str_replace('[EVENT_META_*', '', $shortcode);
241
+			$shortcode = trim(str_replace(']', '', $shortcode));
242
+			// Get any attributes set on this shortcode.
243
+			$attrs = $this->_get_shortcode_attrs($shortcode);
244
+			// The meta_key set on the shortcode should always be the first value in the array.
245
+			$meta_key = $attrs[0];
246
+			// Pull the meta value from the event post.
247
+			$event_meta = $this->_event->get_post_meta($meta_key, true);
248
+			// If we have no event_meta, just return an empty string.
249
+			if (empty($event_meta)) {
250
+				return '';
251
+			}
252
+			// Add a filter to allow all instances of EVENT_META_* to run through do_shortcode, default to false.
253
+			// Check if a do_shortcode attribute was set to true and if so run $event_meta through that function.
254
+			if (
255
+				apply_filters('FHEE__EventEspresso_core_libraries_shortcodes_EE_Event_Shortcodes___parser__event_meta_do_shortcode', false)
256
+				|| !empty($attrs['do_shortcode']) && filter_var($attrs['do_shortcode'], FILTER_VALIDATE_BOOLEAN)
257
+			) {
258
+				return do_shortcode($event_meta);
259
+			}
260
+			// Still here? We just need to return the event_meta value as is.
261
+			return $event_meta;
262
+		}
263
+
264
+		if (strpos($shortcode, '[EVENT_TOTAL_AVAILABLE_SPACES_*') !== false) {
265
+			$attrs = $this->_get_shortcode_attrs($shortcode);
266
+			$method = empty($attrs['method']) ? 'current' : $attrs['method'];
267
+			$method = $method === 'current';
268
+			$available = $this->_event->total_available_spaces($method);
269
+			return $available === EE_INF ? '&infin;' : $available;
270
+		}
271
+
272
+		if (strpos($shortcode, '[EVENT_IMAGE_*') !== false) {
273
+			$attrs = $this->_get_shortcode_attrs($shortcode);
274
+			$width = empty($attrs['width']) ? '' : ' width="' . $attrs['width'] . '"';
275
+			$height = empty($attrs['height']) ? '' : ' height="' . $attrs['height'] . '"';
276
+
277
+			// Size may be set to a string such as 'tumbnail' or "width, height" eg - '200,200'
278
+			if (! empty($attrs['size'])) {
279
+				$size = explode(',', $attrs['size']);
280
+				if (count($size) === 1) {
281
+					$size = $size[0];
282
+				}
283
+			} else {
284
+				$size = 'thumbnail';
285
+			}
286
+
287
+			$image = $this->_event->feature_image_url($size);
288
+
289
+			return ! empty($image)
290
+				? '<img src="' . $image . '" alt="'
291
+				  . sprintf(
292
+					  esc_attr__('%s Feature Image', 'event_espresso'),
293
+					  $this->_event->get('EVT_name')
294
+				  ) . '"' . $width . $height . '/>'
295
+				: '';
296
+		}
297
+
298
+		return '';
299
+	}
300
+
301
+
302
+	/**
303
+	 * returns the link to the event
304
+	 *
305
+	 * @param  boolean $full_link if TRUE (default) we return the html for the name of the event linked to the event.
306
+	 *                            Otherwise we just return the url of the event.
307
+	 * @return string
308
+	 */
309
+	private function _get_event_link($event, $full_link = true)
310
+	{
311
+		$url = get_permalink($event->ID());
312
+
313
+		return $full_link ? '<a href="' . $url . '">' . $event->get('EVT_name') . '</a>' : $url;
314
+	}
315 315
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 
135 135
 
136 136
         // If there is no event objecdt by now then get out.
137
-        if (! $this->_event instanceof EE_Event) {
137
+        if ( ! $this->_event instanceof EE_Event) {
138 138
             return '';
139 139
         }
140 140
 
@@ -187,11 +187,11 @@  discard block
 block discarded – undo
187 187
                 $image = $this->_event->feature_image_url(array(600, 300));
188 188
                 // @todo: eventually we should make this an attribute shortcode so that em can send along what size they want returned.
189 189
                 return ! empty($image)
190
-                    ? '<img src="' . $image . '" alt="'
190
+                    ? '<img src="'.$image.'" alt="'
191 191
                       . sprintf(
192 192
                           esc_attr__('%s Feature Image', 'event_espresso'),
193 193
                           $this->_event->get('EVT_name')
194
-                      ) . '" />'
194
+                      ).'" />'
195 195
                     : '';
196 196
                 break;
197 197
 
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
             // Check if a do_shortcode attribute was set to true and if so run $event_meta through that function.
254 254
             if (
255 255
                 apply_filters('FHEE__EventEspresso_core_libraries_shortcodes_EE_Event_Shortcodes___parser__event_meta_do_shortcode', false)
256
-                || !empty($attrs['do_shortcode']) && filter_var($attrs['do_shortcode'], FILTER_VALIDATE_BOOLEAN)
256
+                || ! empty($attrs['do_shortcode']) && filter_var($attrs['do_shortcode'], FILTER_VALIDATE_BOOLEAN)
257 257
             ) {
258 258
                 return do_shortcode($event_meta);
259 259
             }
@@ -271,11 +271,11 @@  discard block
 block discarded – undo
271 271
 
272 272
         if (strpos($shortcode, '[EVENT_IMAGE_*') !== false) {
273 273
             $attrs = $this->_get_shortcode_attrs($shortcode);
274
-            $width = empty($attrs['width']) ? '' : ' width="' . $attrs['width'] . '"';
275
-            $height = empty($attrs['height']) ? '' : ' height="' . $attrs['height'] . '"';
274
+            $width = empty($attrs['width']) ? '' : ' width="'.$attrs['width'].'"';
275
+            $height = empty($attrs['height']) ? '' : ' height="'.$attrs['height'].'"';
276 276
 
277 277
             // Size may be set to a string such as 'tumbnail' or "width, height" eg - '200,200'
278
-            if (! empty($attrs['size'])) {
278
+            if ( ! empty($attrs['size'])) {
279 279
                 $size = explode(',', $attrs['size']);
280 280
                 if (count($size) === 1) {
281 281
                     $size = $size[0];
@@ -287,11 +287,11 @@  discard block
 block discarded – undo
287 287
             $image = $this->_event->feature_image_url($size);
288 288
 
289 289
             return ! empty($image)
290
-                ? '<img src="' . $image . '" alt="'
290
+                ? '<img src="'.$image.'" alt="'
291 291
                   . sprintf(
292 292
                       esc_attr__('%s Feature Image', 'event_espresso'),
293 293
                       $this->_event->get('EVT_name')
294
-                  ) . '"' . $width . $height . '/>'
294
+                  ).'"'.$width.$height.'/>'
295 295
                 : '';
296 296
         }
297 297
 
@@ -310,6 +310,6 @@  discard block
 block discarded – undo
310 310
     {
311 311
         $url = get_permalink($event->ID());
312 312
 
313
-        return $full_link ? '<a href="' . $url . '">' . $event->get('EVT_name') . '</a>' : $url;
313
+        return $full_link ? '<a href="'.$url.'">'.$event->get('EVT_name').'</a>' : $url;
314 314
     }
315 315
 }
Please login to merge, or discard this patch.
core/libraries/shortcodes/EE_Primary_Registration_List_Shortcodes.lib.php 3 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -125,6 +125,9 @@  discard block
 block discarded – undo
125 125
     }
126 126
 
127 127
 
128
+    /**
129
+     * @param EE_Registration $reg
130
+     */
128 131
     private function _get_tickets_from_event(EE_Event $event, $reg = null)
129 132
     {
130 133
         $evt_tkts = isset($this->_extra_data['data']->events) ? $this->_extra_data['data']->events[ $event->ID(
@@ -203,6 +206,9 @@  discard block
 block discarded – undo
203 206
     }
204 207
 
205 208
 
209
+    /**
210
+     * @param EE_Registration $reg
211
+     */
206 212
     private function _get_datetimes_from_event(EE_Event $event, $reg = null)
207 213
     {
208 214
         $evt_dtts = isset($this->_extra_data['data']->events) ? $this->_extra_data['data']->events[ $event->ID(
Please login to merge, or discard this patch.
Indentation   +202 added lines, -202 removed lines patch added patch discarded remove patch
@@ -19,206 +19,206 @@
 block discarded – undo
19 19
 class EE_Primary_Registration_List_Shortcodes extends EE_Shortcodes
20 20
 {
21 21
 
22
-    public function __construct()
23
-    {
24
-        parent::__construct();
25
-    }
26
-
27
-
28
-    protected function _init_props()
29
-    {
30
-        $this->label = __('Primary Registrant List Shortcodes', 'event_espresso');
31
-        $this->description = __(
32
-            'All shortcodes specific primary registrant recipients list type data.',
33
-            'event_espresso'
34
-        );
35
-        $this->_shortcodes = array(
36
-            '[PRIMARY_REGISTRANT_TICKET_LIST]' => __(
37
-                'Will output a list of tickets that the primary registration received.',
38
-                'event_espresso'
39
-            ),
40
-            '[PRIMARY_REGISTRANT_DATETIME_LIST]' => __(
41
-                'Will output a list of datetimes that the primary registrant for the transaction has been registered for.',
42
-                'event_espresso'
43
-            ),
44
-        );
45
-    }
46
-
47
-
48
-    protected function _parser($shortcode)
49
-    {
50
-        switch ($shortcode) {
51
-            case '[PRIMARY_REGISTRANT_TICKET_LIST]':
52
-                return $this->_get_recipient_ticket_list(true);
53
-                break;
54
-
55
-            case '[PRIMARY_REGISTRANT_DATETIME_LIST]':
56
-                return $this->_get_recipient_datetime_list(true);
57
-                break;
58
-        }
59
-        return '';
60
-    }
61
-
62
-
63
-    /**
64
-     * figure out what the incoming data is and then return the appropriate parsed value
65
-     *
66
-     * @param  boolean $primary whether we're getting the primary registrant ticket_list.
67
-     * @return string
68
-     */
69
-    private function _get_recipient_ticket_list($primary = false)
70
-    {
71
-        $this->_validate_list_requirements();
72
-
73
-        if ($this->_data['data'] instanceof EE_Messages_Addressee) {
74
-            return $this->_get_recipient_ticket_list_parsed($this->_data['data'], $primary);
75
-        } elseif ($this->_extra_data['data'] instanceof EE_Messages_Addressee) {
76
-            return $this->_get_recipient_ticket_list_parsed($this->_extra_data['data'], $primary);
77
-        } else {
78
-            return '';
79
-        }
80
-    }
81
-
82
-
83
-    private function _get_recipient_ticket_list_parsed(EE_Messages_Addressee $data, $primary = false)
84
-    {
85
-        $registration = $primary ? $data->primary_reg_obj : $data->reg_obj;
86
-        if (! $registration instanceof EE_Registration) {
87
-            return '';
88
-        }
89
-        // setup valid shortcodes depending on what the status of the $this->_data property is
90
-        if ($this->_data['data'] instanceof EE_Messages_Addressee) {
91
-            $valid_shortcodes = array(
92
-                'ticket',
93
-                'event_list',
94
-                'attendee_list',
95
-                'datetime_list',
96
-                'registration_details',
97
-                'attendee',
98
-            );
99
-            $template = $this->_data['template'];
100
-            $tkts = array($data->registrations[ $registration->ID() ]['tkt_obj']);
101
-            $data = $this->_data;
102
-        } elseif ($this->_data['data'] instanceof EE_Event) {
103
-            $valid_shortcodes = array('ticket', 'attendee_list', 'datetime_list', 'attendee');
104
-            $template = is_array($this->_data['template']) && isset($this->_data['template']['ticket_list'])
105
-                ? $this->_data['template']['ticket_list'] : $this->_extra_data['template']['ticket_list'];
106
-            // let's remove any existing [EVENT_LIST] shortcode from the ticket list template so that we don't get recursion.
107
-            $template = str_replace('[EVENT_LIST]', '', $template);
108
-            // data will be tickets for this event for this recipient.
109
-            $tkts = $this->_get_tickets_from_event($this->_data['data'], $registration);
110
-            $data = $this->_extra_data;
111
-        } else {
112
-            return '';
113
-        }
114
-
115
-        $tktparsed = '';
116
-        foreach ($tkts as $ticket) {
117
-            $tktparsed .= $this->_shortcode_helper->parse_ticket_list_template(
118
-                $template,
119
-                $ticket,
120
-                $valid_shortcodes,
121
-                $data
122
-            );
123
-        }
124
-        return $tktparsed;
125
-    }
126
-
127
-
128
-    private function _get_tickets_from_event(EE_Event $event, $reg = null)
129
-    {
130
-        $evt_tkts = isset($this->_extra_data['data']->events) ? $this->_extra_data['data']->events[ $event->ID(
131
-        ) ]['tkt_objs'] : array();
132
-
133
-        if ($reg instanceof EE_Registration && $this->_extra_data['data'] instanceof EE_Messages_Addressee) {
134
-            $adj_tkts = array();
135
-            // return only tickets for the given attendee
136
-            foreach ($evt_tkts as $tkt) {
137
-                if (
138
-                    isset($this->_extra_data['data']->registrations[ $reg->ID() ]['tkt_obj'])
139
-                    && $this->_extra_data['data']->registrations[ $reg->ID() ]['tkt_obj']->ID() == $tkt->ID()
140
-                ) {
141
-                    $adj_tkts[] = $tkt;
142
-                }
143
-            }
144
-            $evt_tkts = $adj_tkts;
145
-        }
146
-        return $evt_tkts;
147
-    }
148
-
149
-
150
-    /**
151
-     * figure out what the incoming data is and then return the appropriate parsed value
152
-     *
153
-     * @param  boolean $primary whether we're getting the primary registrant ticket_list.
154
-     * @return string
155
-     */
156
-    private function _get_recipient_datetime_list($primary = false)
157
-    {
158
-        $this->_validate_list_requirements();
159
-
160
-        if ($this->_data['data'] instanceof EE_Messages_Addressee) {
161
-            return $this->_get_recipient_datetime_list_parsed($this->_data['data'], $primary);
162
-        } elseif ($this->_extra_data['data'] instanceof EE_Messages_Addressee) {
163
-            return $this->_get_recipient_datetime_list_parsed($this->_extra_data['data'], $primary);
164
-        } else {
165
-            return '';
166
-        }
167
-
168
-        return $this->_get_recipient_datetime_list_parsed($this->_data['data'], $primary);
169
-    }
170
-
171
-
172
-    private function _get_recipient_datetime_list_parsed(EE_Messages_Addressee $data, $primary = false)
173
-    {
174
-        $registration = $primary ? $data->primary_reg_obj : $data->reg_obj;
175
-        if (! $registration instanceof EE_Registration) {
176
-            return '';
177
-        }
178
-        // setup valid shortcodes depending on what the status of the $this->_data property is
179
-        if ($this->_data['data'] instanceof EE_Messages_Addressee) {
180
-            $valid_shortcodes = array('datetime', 'attendee');
181
-            $template = $this->_data['template'];
182
-            $dtts = $data->registrations[ $registration->ID() ]['dtt_objs'];
183
-            $data = $this->_data;
184
-        } elseif ($this->_data['data'] instanceof EE_Event) {
185
-            $valid_shortcodes = array('datetime', 'attendee');
186
-            $template = is_array($this->_data['template']) && isset($this->_data['template']['datetime_list'])
187
-                ? $this->_data['template']['datetime_list'] : $this->_extra_data['template']['datetime_list'];
188
-            $dtts = $this->_get_datetimes_from_event($this->_data['data'], $registration);
189
-            $data = $this->_extra_data;
190
-        } else {
191
-            return '';
192
-        }
193
-
194
-        $dtt_parsed = '';
195
-        foreach ($dtts as $datetime) {
196
-            $dtt_parsed .= $this->_shortcode_helper->parse_datetime_list_template(
197
-                $template,
198
-                $datetime,
199
-                $valid_shortcodes,
200
-                $this->_extra_data
201
-            );
202
-        }
203
-        return $dtt_parsed;
204
-    }
205
-
206
-
207
-    private function _get_datetimes_from_event(EE_Event $event, $reg = null)
208
-    {
209
-        $evt_dtts = isset($this->_extra_data['data']->events) ? $this->_extra_data['data']->events[ $event->ID(
210
-        ) ]['dtt_objs'] : array();
211
-
212
-        if ($reg instanceof EE_Registration && $this->_extra_data['data'] instanceof EE_Messages_Addressee) {
213
-            $adj_dtts = array();
214
-            // return only dtts for the given attendee
215
-            foreach ($evt_dtts as $dtt) {
216
-                if (isset($this->_extra_data['data']->registrations[ $reg->ID() ]['dtt_objs'][ $dtt->ID() ])) {
217
-                    $adj_dtts[] = $dtt;
218
-                }
219
-            }
220
-            $evt_dtts = $adj_dtts;
221
-        }
222
-        return $evt_dtts;
223
-    }
22
+	public function __construct()
23
+	{
24
+		parent::__construct();
25
+	}
26
+
27
+
28
+	protected function _init_props()
29
+	{
30
+		$this->label = __('Primary Registrant List Shortcodes', 'event_espresso');
31
+		$this->description = __(
32
+			'All shortcodes specific primary registrant recipients list type data.',
33
+			'event_espresso'
34
+		);
35
+		$this->_shortcodes = array(
36
+			'[PRIMARY_REGISTRANT_TICKET_LIST]' => __(
37
+				'Will output a list of tickets that the primary registration received.',
38
+				'event_espresso'
39
+			),
40
+			'[PRIMARY_REGISTRANT_DATETIME_LIST]' => __(
41
+				'Will output a list of datetimes that the primary registrant for the transaction has been registered for.',
42
+				'event_espresso'
43
+			),
44
+		);
45
+	}
46
+
47
+
48
+	protected function _parser($shortcode)
49
+	{
50
+		switch ($shortcode) {
51
+			case '[PRIMARY_REGISTRANT_TICKET_LIST]':
52
+				return $this->_get_recipient_ticket_list(true);
53
+				break;
54
+
55
+			case '[PRIMARY_REGISTRANT_DATETIME_LIST]':
56
+				return $this->_get_recipient_datetime_list(true);
57
+				break;
58
+		}
59
+		return '';
60
+	}
61
+
62
+
63
+	/**
64
+	 * figure out what the incoming data is and then return the appropriate parsed value
65
+	 *
66
+	 * @param  boolean $primary whether we're getting the primary registrant ticket_list.
67
+	 * @return string
68
+	 */
69
+	private function _get_recipient_ticket_list($primary = false)
70
+	{
71
+		$this->_validate_list_requirements();
72
+
73
+		if ($this->_data['data'] instanceof EE_Messages_Addressee) {
74
+			return $this->_get_recipient_ticket_list_parsed($this->_data['data'], $primary);
75
+		} elseif ($this->_extra_data['data'] instanceof EE_Messages_Addressee) {
76
+			return $this->_get_recipient_ticket_list_parsed($this->_extra_data['data'], $primary);
77
+		} else {
78
+			return '';
79
+		}
80
+	}
81
+
82
+
83
+	private function _get_recipient_ticket_list_parsed(EE_Messages_Addressee $data, $primary = false)
84
+	{
85
+		$registration = $primary ? $data->primary_reg_obj : $data->reg_obj;
86
+		if (! $registration instanceof EE_Registration) {
87
+			return '';
88
+		}
89
+		// setup valid shortcodes depending on what the status of the $this->_data property is
90
+		if ($this->_data['data'] instanceof EE_Messages_Addressee) {
91
+			$valid_shortcodes = array(
92
+				'ticket',
93
+				'event_list',
94
+				'attendee_list',
95
+				'datetime_list',
96
+				'registration_details',
97
+				'attendee',
98
+			);
99
+			$template = $this->_data['template'];
100
+			$tkts = array($data->registrations[ $registration->ID() ]['tkt_obj']);
101
+			$data = $this->_data;
102
+		} elseif ($this->_data['data'] instanceof EE_Event) {
103
+			$valid_shortcodes = array('ticket', 'attendee_list', 'datetime_list', 'attendee');
104
+			$template = is_array($this->_data['template']) && isset($this->_data['template']['ticket_list'])
105
+				? $this->_data['template']['ticket_list'] : $this->_extra_data['template']['ticket_list'];
106
+			// let's remove any existing [EVENT_LIST] shortcode from the ticket list template so that we don't get recursion.
107
+			$template = str_replace('[EVENT_LIST]', '', $template);
108
+			// data will be tickets for this event for this recipient.
109
+			$tkts = $this->_get_tickets_from_event($this->_data['data'], $registration);
110
+			$data = $this->_extra_data;
111
+		} else {
112
+			return '';
113
+		}
114
+
115
+		$tktparsed = '';
116
+		foreach ($tkts as $ticket) {
117
+			$tktparsed .= $this->_shortcode_helper->parse_ticket_list_template(
118
+				$template,
119
+				$ticket,
120
+				$valid_shortcodes,
121
+				$data
122
+			);
123
+		}
124
+		return $tktparsed;
125
+	}
126
+
127
+
128
+	private function _get_tickets_from_event(EE_Event $event, $reg = null)
129
+	{
130
+		$evt_tkts = isset($this->_extra_data['data']->events) ? $this->_extra_data['data']->events[ $event->ID(
131
+		) ]['tkt_objs'] : array();
132
+
133
+		if ($reg instanceof EE_Registration && $this->_extra_data['data'] instanceof EE_Messages_Addressee) {
134
+			$adj_tkts = array();
135
+			// return only tickets for the given attendee
136
+			foreach ($evt_tkts as $tkt) {
137
+				if (
138
+					isset($this->_extra_data['data']->registrations[ $reg->ID() ]['tkt_obj'])
139
+					&& $this->_extra_data['data']->registrations[ $reg->ID() ]['tkt_obj']->ID() == $tkt->ID()
140
+				) {
141
+					$adj_tkts[] = $tkt;
142
+				}
143
+			}
144
+			$evt_tkts = $adj_tkts;
145
+		}
146
+		return $evt_tkts;
147
+	}
148
+
149
+
150
+	/**
151
+	 * figure out what the incoming data is and then return the appropriate parsed value
152
+	 *
153
+	 * @param  boolean $primary whether we're getting the primary registrant ticket_list.
154
+	 * @return string
155
+	 */
156
+	private function _get_recipient_datetime_list($primary = false)
157
+	{
158
+		$this->_validate_list_requirements();
159
+
160
+		if ($this->_data['data'] instanceof EE_Messages_Addressee) {
161
+			return $this->_get_recipient_datetime_list_parsed($this->_data['data'], $primary);
162
+		} elseif ($this->_extra_data['data'] instanceof EE_Messages_Addressee) {
163
+			return $this->_get_recipient_datetime_list_parsed($this->_extra_data['data'], $primary);
164
+		} else {
165
+			return '';
166
+		}
167
+
168
+		return $this->_get_recipient_datetime_list_parsed($this->_data['data'], $primary);
169
+	}
170
+
171
+
172
+	private function _get_recipient_datetime_list_parsed(EE_Messages_Addressee $data, $primary = false)
173
+	{
174
+		$registration = $primary ? $data->primary_reg_obj : $data->reg_obj;
175
+		if (! $registration instanceof EE_Registration) {
176
+			return '';
177
+		}
178
+		// setup valid shortcodes depending on what the status of the $this->_data property is
179
+		if ($this->_data['data'] instanceof EE_Messages_Addressee) {
180
+			$valid_shortcodes = array('datetime', 'attendee');
181
+			$template = $this->_data['template'];
182
+			$dtts = $data->registrations[ $registration->ID() ]['dtt_objs'];
183
+			$data = $this->_data;
184
+		} elseif ($this->_data['data'] instanceof EE_Event) {
185
+			$valid_shortcodes = array('datetime', 'attendee');
186
+			$template = is_array($this->_data['template']) && isset($this->_data['template']['datetime_list'])
187
+				? $this->_data['template']['datetime_list'] : $this->_extra_data['template']['datetime_list'];
188
+			$dtts = $this->_get_datetimes_from_event($this->_data['data'], $registration);
189
+			$data = $this->_extra_data;
190
+		} else {
191
+			return '';
192
+		}
193
+
194
+		$dtt_parsed = '';
195
+		foreach ($dtts as $datetime) {
196
+			$dtt_parsed .= $this->_shortcode_helper->parse_datetime_list_template(
197
+				$template,
198
+				$datetime,
199
+				$valid_shortcodes,
200
+				$this->_extra_data
201
+			);
202
+		}
203
+		return $dtt_parsed;
204
+	}
205
+
206
+
207
+	private function _get_datetimes_from_event(EE_Event $event, $reg = null)
208
+	{
209
+		$evt_dtts = isset($this->_extra_data['data']->events) ? $this->_extra_data['data']->events[ $event->ID(
210
+		) ]['dtt_objs'] : array();
211
+
212
+		if ($reg instanceof EE_Registration && $this->_extra_data['data'] instanceof EE_Messages_Addressee) {
213
+			$adj_dtts = array();
214
+			// return only dtts for the given attendee
215
+			foreach ($evt_dtts as $dtt) {
216
+				if (isset($this->_extra_data['data']->registrations[ $reg->ID() ]['dtt_objs'][ $dtt->ID() ])) {
217
+					$adj_dtts[] = $dtt;
218
+				}
219
+			}
220
+			$evt_dtts = $adj_dtts;
221
+		}
222
+		return $evt_dtts;
223
+	}
224 224
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
     private function _get_recipient_ticket_list_parsed(EE_Messages_Addressee $data, $primary = false)
84 84
     {
85 85
         $registration = $primary ? $data->primary_reg_obj : $data->reg_obj;
86
-        if (! $registration instanceof EE_Registration) {
86
+        if ( ! $registration instanceof EE_Registration) {
87 87
             return '';
88 88
         }
89 89
         // setup valid shortcodes depending on what the status of the $this->_data property is
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
                 'attendee',
98 98
             );
99 99
             $template = $this->_data['template'];
100
-            $tkts = array($data->registrations[ $registration->ID() ]['tkt_obj']);
100
+            $tkts = array($data->registrations[$registration->ID()]['tkt_obj']);
101 101
             $data = $this->_data;
102 102
         } elseif ($this->_data['data'] instanceof EE_Event) {
103 103
             $valid_shortcodes = array('ticket', 'attendee_list', 'datetime_list', 'attendee');
@@ -127,16 +127,16 @@  discard block
 block discarded – undo
127 127
 
128 128
     private function _get_tickets_from_event(EE_Event $event, $reg = null)
129 129
     {
130
-        $evt_tkts = isset($this->_extra_data['data']->events) ? $this->_extra_data['data']->events[ $event->ID(
131
-        ) ]['tkt_objs'] : array();
130
+        $evt_tkts = isset($this->_extra_data['data']->events) ? $this->_extra_data['data']->events[$event->ID(
131
+        )]['tkt_objs'] : array();
132 132
 
133 133
         if ($reg instanceof EE_Registration && $this->_extra_data['data'] instanceof EE_Messages_Addressee) {
134 134
             $adj_tkts = array();
135 135
             // return only tickets for the given attendee
136 136
             foreach ($evt_tkts as $tkt) {
137 137
                 if (
138
-                    isset($this->_extra_data['data']->registrations[ $reg->ID() ]['tkt_obj'])
139
-                    && $this->_extra_data['data']->registrations[ $reg->ID() ]['tkt_obj']->ID() == $tkt->ID()
138
+                    isset($this->_extra_data['data']->registrations[$reg->ID()]['tkt_obj'])
139
+                    && $this->_extra_data['data']->registrations[$reg->ID()]['tkt_obj']->ID() == $tkt->ID()
140 140
                 ) {
141 141
                     $adj_tkts[] = $tkt;
142 142
                 }
@@ -172,14 +172,14 @@  discard block
 block discarded – undo
172 172
     private function _get_recipient_datetime_list_parsed(EE_Messages_Addressee $data, $primary = false)
173 173
     {
174 174
         $registration = $primary ? $data->primary_reg_obj : $data->reg_obj;
175
-        if (! $registration instanceof EE_Registration) {
175
+        if ( ! $registration instanceof EE_Registration) {
176 176
             return '';
177 177
         }
178 178
         // setup valid shortcodes depending on what the status of the $this->_data property is
179 179
         if ($this->_data['data'] instanceof EE_Messages_Addressee) {
180 180
             $valid_shortcodes = array('datetime', 'attendee');
181 181
             $template = $this->_data['template'];
182
-            $dtts = $data->registrations[ $registration->ID() ]['dtt_objs'];
182
+            $dtts = $data->registrations[$registration->ID()]['dtt_objs'];
183 183
             $data = $this->_data;
184 184
         } elseif ($this->_data['data'] instanceof EE_Event) {
185 185
             $valid_shortcodes = array('datetime', 'attendee');
@@ -206,14 +206,14 @@  discard block
 block discarded – undo
206 206
 
207 207
     private function _get_datetimes_from_event(EE_Event $event, $reg = null)
208 208
     {
209
-        $evt_dtts = isset($this->_extra_data['data']->events) ? $this->_extra_data['data']->events[ $event->ID(
210
-        ) ]['dtt_objs'] : array();
209
+        $evt_dtts = isset($this->_extra_data['data']->events) ? $this->_extra_data['data']->events[$event->ID(
210
+        )]['dtt_objs'] : array();
211 211
 
212 212
         if ($reg instanceof EE_Registration && $this->_extra_data['data'] instanceof EE_Messages_Addressee) {
213 213
             $adj_dtts = array();
214 214
             // return only dtts for the given attendee
215 215
             foreach ($evt_dtts as $dtt) {
216
-                if (isset($this->_extra_data['data']->registrations[ $reg->ID() ]['dtt_objs'][ $dtt->ID() ])) {
216
+                if (isset($this->_extra_data['data']->registrations[$reg->ID()]['dtt_objs'][$dtt->ID()])) {
217 217
                     $adj_dtts[] = $dtt;
218 218
                 }
219 219
             }
Please login to merge, or discard this patch.
core/services/notices/NoticeConverterInterface.php 2 patches
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,6 +20,7 @@  discard block
 block discarded – undo
20 20
 
21 21
     /**
22 22
      * @param bool $throw_exceptions
23
+     * @return void
23 24
      */
24 25
     public function setThrowExceptions($throw_exceptions);
25 26
 
@@ -37,7 +38,7 @@  discard block
 block discarded – undo
37 38
     public function process(NoticesContainerInterface $notices);
38 39
 
39 40
     /**
40
-     * @return void;
41
+     * @return void
41 42
      */
42 43
     public function clearNotices();
43 44
 }
Please login to merge, or discard this patch.
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -13,31 +13,31 @@
 block discarded – undo
13 13
 interface NoticeConverterInterface
14 14
 {
15 15
 
16
-    /**
17
-     * @return NoticesContainerInterface
18
-     */
19
-    public function getNotices();
16
+	/**
17
+	 * @return NoticesContainerInterface
18
+	 */
19
+	public function getNotices();
20 20
 
21
-    /**
22
-     * @param bool $throw_exceptions
23
-     */
24
-    public function setThrowExceptions($throw_exceptions);
21
+	/**
22
+	 * @param bool $throw_exceptions
23
+	 */
24
+	public function setThrowExceptions($throw_exceptions);
25 25
 
26
-    /**
27
-     * @return bool
28
-     */
29
-    public function getThrowExceptions();
26
+	/**
27
+	 * @return bool
28
+	 */
29
+	public function getThrowExceptions();
30 30
 
31
-    /**
32
-     * Converts NoticesContainerInterface objects into other format
33
-     *
34
-     * @param NoticesContainerInterface $notices
35
-     * @return
36
-     */
37
-    public function process(NoticesContainerInterface $notices);
31
+	/**
32
+	 * Converts NoticesContainerInterface objects into other format
33
+	 *
34
+	 * @param NoticesContainerInterface $notices
35
+	 * @return
36
+	 */
37
+	public function process(NoticesContainerInterface $notices);
38 38
 
39
-    /**
40
-     * @return void;
41
-     */
42
-    public function clearNotices();
39
+	/**
40
+	 * @return void;
41
+	 */
42
+	public function clearNotices();
43 43
 }
Please login to merge, or discard this patch.
modules/add_new_state/EED_Add_New_State.module.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
      * display_add_new_state_micro_form
232 232
      *
233 233
      * @param EE_Form_Section_Proper $question_group_reg_form
234
-     * @return string
234
+     * @return EE_Form_Section_Proper
235 235
      * @throws EE_Error
236 236
      * @throws InvalidArgumentException
237 237
      * @throws InvalidDataTypeException
@@ -773,7 +773,7 @@  discard block
 block discarded – undo
773 773
 
774 774
     /**
775 775
      * @param EE_State[] $state_options
776
-     * @return array
776
+     * @return EE_State[]
777 777
      * @throws EE_Error
778 778
      * @throws InvalidArgumentException
779 779
      * @throws InvalidDataTypeException
Please login to merge, or discard this patch.
Indentation   +819 added lines, -819 removed lines patch added patch discarded remove patch
@@ -19,823 +19,823 @@
 block discarded – undo
19 19
 {
20 20
 
21 21
 
22
-    /**
23
-     * @return EED_Module|EED_Add_New_State
24
-     */
25
-    public static function instance()
26
-    {
27
-        return parent::get_instance(__CLASS__);
28
-    }
29
-
30
-
31
-    /**
32
-     * set_hooks - for hooking into EE Core, other modules, etc
33
-     *
34
-     * @return void
35
-     */
36
-    public static function set_hooks()
37
-    {
38
-        add_action('wp_loaded', array('EED_Add_New_State', 'set_definitions'), 2);
39
-        add_action('wp_enqueue_scripts', array('EED_Add_New_State', 'translate_js_strings'), 0);
40
-        add_action('wp_enqueue_scripts', array('EED_Add_New_State', 'wp_enqueue_scripts'), 10);
41
-        add_filter(
42
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form',
43
-            array('EED_Add_New_State', 'display_add_new_state_micro_form'),
44
-            1,
45
-            1
46
-        );
47
-        add_filter(
48
-            'FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form',
49
-            array('EED_Add_New_State', 'display_add_new_state_micro_form'),
50
-            1,
51
-            1
52
-        );
53
-        add_filter(
54
-            'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item',
55
-            array('EED_Add_New_State', 'unset_new_state_request_params'),
56
-            10,
57
-            1
58
-        );
59
-        add_filter(
60
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options',
61
-            array('EED_Add_New_State', 'inject_new_reg_state_into_options'),
62
-            10,
63
-            5
64
-        );
65
-        add_filter(
66
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options',
67
-            array('EED_Add_New_State', 'inject_new_reg_country_into_options'),
68
-            10,
69
-            5
70
-        );
71
-        add_filter(
72
-            'FHEE__EE_State_Select_Input____construct__state_options',
73
-            array('EED_Add_New_State', 'state_options'),
74
-            10,
75
-            1
76
-        );
77
-        add_filter(
78
-            'FHEE__EE_Country_Select_Input____construct__country_options',
79
-            array('EED_Add_New_State', 'country_options'),
80
-            10,
81
-            1
82
-        );
83
-    }
84
-
85
-
86
-    /**
87
-     * set_hooks_admin - for hooking into EE Admin Core, other modules, etc
88
-     *
89
-     * @return void
90
-     */
91
-    public static function set_hooks_admin()
92
-    {
93
-        add_action('wp_loaded', array('EED_Add_New_State', 'set_definitions'), 2);
94
-        add_filter(
95
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form',
96
-            array('EED_Add_New_State', 'display_add_new_state_micro_form'),
97
-            1,
98
-            1
99
-        );
100
-        add_filter(
101
-            'FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form',
102
-            array('EED_Add_New_State', 'display_add_new_state_micro_form'),
103
-            1,
104
-            1
105
-        );
106
-        add_action('wp_ajax_espresso_add_new_state', array('EED_Add_New_State', 'add_new_state'));
107
-        add_action('wp_ajax_nopriv_espresso_add_new_state', array('EED_Add_New_State', 'add_new_state'));
108
-        add_filter(
109
-            'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item',
110
-            array('EED_Add_New_State', 'unset_new_state_request_params'),
111
-            10,
112
-            1
113
-        );
114
-        add_action(
115
-            'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved',
116
-            array('EED_Add_New_State', 'update_country_settings'),
117
-            10,
118
-            3
119
-        );
120
-        add_action(
121
-            'AHEE__General_Settings_Admin_Page__delete_state__state_deleted',
122
-            array('EED_Add_New_State', 'update_country_settings'),
123
-            10,
124
-            3
125
-        );
126
-        add_filter(
127
-            'FHEE__EE_State_Select_Input____construct__state_options',
128
-            array('EED_Add_New_State', 'state_options'),
129
-            10,
130
-            1
131
-        );
132
-        add_filter(
133
-            'FHEE__EE_Country_Select_Input____construct__country_options',
134
-            array('EED_Add_New_State', 'country_options'),
135
-            10,
136
-            1
137
-        );
138
-        add_filter(
139
-            'FHEE__EE_Form_Section_Proper__receive_form_submission__request_data',
140
-            array('EED_Add_New_State', 'filter_checkout_request_params'),
141
-            10,
142
-            1
143
-        );
144
-        add_filter(
145
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options',
146
-            array('EED_Add_New_State', 'inject_new_reg_state_into_options'),
147
-            10,
148
-            5
149
-        );
150
-        add_filter(
151
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options',
152
-            array('EED_Add_New_State', 'inject_new_reg_country_into_options'),
153
-            10,
154
-            5
155
-        );
156
-    }
157
-
158
-
159
-    /**
160
-     * @return void
161
-     */
162
-    public static function set_definitions()
163
-    {
164
-        define('ANS_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/');
165
-        define(
166
-            'ANS_TEMPLATES_PATH',
167
-            str_replace(
168
-                '\\',
169
-                '/',
170
-                plugin_dir_path(__FILE__)
171
-            ) . 'templates/'
172
-        );
173
-    }
174
-
175
-
176
-    /**
177
-     * @param WP $WP
178
-     * @return void
179
-     */
180
-    public function run($WP)
181
-    {
182
-    }
183
-
184
-
185
-    /**
186
-     * @return void
187
-     */
188
-    public static function translate_js_strings()
189
-    {
190
-        EE_Registry::$i18n_js_strings['ans_no_country'] = esc_html__(
191
-            'In order to proceed, you need to select the Country that your State/Province belongs to.',
192
-            'event_espresso'
193
-        );
194
-        EE_Registry::$i18n_js_strings['ans_no_name'] = esc_html__(
195
-            'In order to proceed, you need to enter the name of your State/Province.',
196
-            'event_espresso'
197
-        );
198
-        EE_Registry::$i18n_js_strings['ans_no_abbreviation'] = esc_html__(
199
-            'In order to proceed, you need to enter an abbreviation for the name of your State/Province.',
200
-            'event_espresso'
201
-        );
202
-        EE_Registry::$i18n_js_strings['ans_save_success'] = esc_html__(
203
-            'The new state was successfully saved to the database.',
204
-            'event_espresso'
205
-        );
206
-        EE_Registry::$i18n_js_strings['ans_server_save_error'] = esc_html__(
207
-            'An unknown error has occurred on the server while saving the new state to the database.',
208
-            'event_espresso'
209
-        );
210
-    }
211
-
212
-
213
-    /**
214
-     * @return void
215
-     */
216
-    public static function wp_enqueue_scripts()
217
-    {
218
-        if (apply_filters('EED_Single_Page_Checkout__SPCO_active', false)) {
219
-            wp_register_script(
220
-                'add_new_state',
221
-                ANS_ASSETS_URL . 'add_new_state.js',
222
-                array('espresso_core', 'single_page_checkout'),
223
-                EVENT_ESPRESSO_VERSION,
224
-                true
225
-            );
226
-            wp_enqueue_script('add_new_state');
227
-        }
228
-    }
229
-
230
-
231
-
232
-    /**
233
-     * display_add_new_state_micro_form
234
-     *
235
-     * @param EE_Form_Section_Proper $question_group_reg_form
236
-     * @return string
237
-     * @throws EE_Error
238
-     * @throws InvalidArgumentException
239
-     * @throws InvalidDataTypeException
240
-     * @throws InvalidInterfaceException
241
-     */
242
-    public static function display_add_new_state_micro_form(EE_Form_Section_Proper $question_group_reg_form)
243
-    {
244
-        // only add the 'new_state_micro_form' when displaying reg forms,
245
-        // not during processing since we process the 'new_state_micro_form' in it's own AJAX request
246
-        $action = EE_Registry::instance()->REQ->get('action', '');
247
-        // is the "state" question in this form section?
248
-        $input = $question_group_reg_form->get_subsection('state');
249
-        if ($action === 'process_reg_step' || $action === 'update_reg_step') {
250
-            // ok then all we need to do is make sure the input's HTML name is consistent
251
-            // by forcing it to set it now, like it did while getting the form for display
252
-            if ($input instanceof EE_State_Select_Input) {
253
-                $input->html_name();
254
-            }
255
-            return $question_group_reg_form;
256
-        }
257
-        // we're only doing this for state select inputs
258
-        if (
259
-            $input instanceof EE_State_Select_Input
260
-            && ! $input->get_display_strategy() instanceof EE_Hidden_Display_Strategy
261
-        ) {
262
-            // grab any set values from the request
263
-            $country_name = str_replace('state', 'nsmf_new_state_country', $input->html_name());
264
-            $state_name = str_replace('state', 'nsmf_new_state_name', $input->html_name());
265
-            $abbrv_name = str_replace('state', 'nsmf_new_state_abbrv', $input->html_name());
266
-            $new_state_submit_id = str_replace('state', 'new_state', $input->html_id());
267
-            $country_options = array();
268
-            $countries = EEM_Country::instance()->get_all_countries();
269
-            if (! empty($countries)) {
270
-                foreach ($countries as $country) {
271
-                    if ($country instanceof EE_Country) {
272
-                        $country_options[ $country->ID() ] = $country->name();
273
-                    }
274
-                }
275
-            }
276
-            $new_state_micro_form = new EE_Form_Section_Proper(
277
-                array(
278
-                    'name'            => 'new_state_micro_form',
279
-                    'html_id'         => 'new_state_micro_form',
280
-                    'layout_strategy' => new EE_Div_Per_Section_Layout(),
281
-                    'subsections'     => array(
282
-                        // add hidden input to indicate that a new state is being added
283
-                        'add_new_state'               => new EE_Hidden_Input(
284
-                            array(
285
-                                'html_name' => str_replace(
286
-                                    'state',
287
-                                    'nsmf_add_new_state',
288
-                                    $input->html_name()
289
-                                ),
290
-                                'html_id'   => str_replace(
291
-                                    'state',
292
-                                    'nsmf_add_new_state',
293
-                                    $input->html_id()
294
-                                ),
295
-                                'default'   => 0,
296
-                            )
297
-                        ),
298
-                        // add link for displaying hidden container
299
-                        'click_here_link'             => new EE_Form_Section_HTML(
300
-                            apply_filters(
301
-                                'FHEE__EED_Add_New_State__display_add_new_state_micro_form__click_here_link',
302
-                                EEH_HTML::link(
303
-                                    '',
304
-                                    esc_html__('click here to add a new state/province', 'event_espresso'),
305
-                                    '',
306
-                                    'display-' . $input->html_id(),
307
-                                    'ee-form-add-new-state-lnk display-the-hidden smaller-text hide-if-no-js',
308
-                                    '',
309
-                                    'data-target="' . $input->html_id() . '"'
310
-                                )
311
-                            )
312
-                        ),
313
-                        // add initial html for hidden container
314
-                        'add_new_state_micro_form'    => new EE_Form_Section_HTML(
315
-                            apply_filters(
316
-                                'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_micro_form',
317
-                                EEH_HTML::div(
318
-                                    '',
319
-                                    $input->html_id() . '-dv',
320
-                                    'ee-form-add-new-state-dv',
321
-                                    'display: none;'
322
-                                ) .
323
-                                EEH_HTML::h6(
324
-                                    esc_html__(
325
-                                        'Is your state/province missing from the dropdown menu above? You can add it by completing the following steps:',
326
-                                        'event_espresso'
327
-                                    )
328
-                                ) .
329
-                                EEH_HTML::ul() .
330
-                                EEH_HTML::li(
331
-                                    esc_html__(
332
-                                        'first select the Country that your State/Province belongs to',
333
-                                        'event_espresso'
334
-                                    )
335
-                                ) .
336
-                                EEH_HTML::li(
337
-                                    esc_html__('enter the name of your State/Province', 'event_espresso')
338
-                                ) .
339
-                                EEH_HTML::li(
340
-                                    esc_html__(
341
-                                        'enter a two to six letter abbreviation for the name of your State/Province',
342
-                                        'event_espresso'
343
-                                    )
344
-                                ) .
345
-                                EEH_HTML::li(esc_html__('click the ADD button', 'event_espresso')) .
346
-                                EEH_HTML::ulx()
347
-                            )
348
-                        ),
349
-                        // NEW STATE COUNTRY
350
-                        'new_state_country'           => new EE_Country_Select_Input(
351
-                            $country_options,
352
-                            array(
353
-                                'html_name'       => $country_name,
354
-                                'html_id'         => str_replace(
355
-                                    'state',
356
-                                    'nsmf_new_state_country',
357
-                                    $input->html_id()
358
-                                ),
359
-                                'html_class'      => $input->html_class() . ' new-state-country',
360
-                                'html_label_text' => esc_html__('New State/Province Country', 'event_espresso'),
361
-                                'default'         => EE_Registry::instance()->REQ->get($country_name, ''),
362
-                                'required'        => false,
363
-                            )
364
-                        ),
365
-                        // NEW STATE NAME
366
-                        'new_state_name'              => new EE_Text_Input(
367
-                            array(
368
-                                'html_name'       => $state_name,
369
-                                'html_id'         => str_replace(
370
-                                    'state',
371
-                                    'nsmf_new_state_name',
372
-                                    $input->html_id()
373
-                                ),
374
-                                'html_class'      => $input->html_class() . ' new-state-state',
375
-                                'html_label_text' => esc_html__(
376
-                                    'New State/Province Name',
377
-                                    'event_espresso'
378
-                                ),
379
-                                'default'         => EE_Registry::instance()->REQ->get($state_name, ''),
380
-                                'required'        => false,
381
-                            )
382
-                        ),
383
-                        'spacer'                      => new EE_Form_Section_HTML(EEH_HTML::br()),
384
-                        // NEW STATE NAME
385
-                        'new_state_abbrv'             => new EE_Text_Input(
386
-                            array(
387
-                                'html_name'             => $abbrv_name,
388
-                                'html_id'               => str_replace(
389
-                                    'state',
390
-                                    'nsmf_new_state_abbrv',
391
-                                    $input->html_id()
392
-                                ),
393
-                                'html_class'            => $input->html_class() . ' new-state-abbrv',
394
-                                'html_label_text'       => esc_html__(
395
-                                    'New State/Province Abbreviation',
396
-                                    'event_espresso'
397
-                                ) . ' *',
398
-                                'other_html_attributes' => 'size="24"',
399
-                                'default'               => EE_Registry::instance()->REQ->get($abbrv_name, ''),
400
-                                'required'              => false,
401
-                            )
402
-                        ),
403
-                        // "submit" button
404
-                        'add_new_state_submit_button' => new EE_Form_Section_HTML(
405
-                            apply_filters(
406
-                                'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_submit_button',
407
-                                EEH_HTML::nbsp(3) .
408
-                                EEH_HTML::link(
409
-                                    '',
410
-                                    esc_html__('ADD', 'event_espresso'),
411
-                                    '',
412
-                                    'submit-' . $new_state_submit_id,
413
-                                    'ee-form-add-new-state-submit button button-secondary',
414
-                                    '',
415
-                                    'data-target="' . $new_state_submit_id . '" data-value-field-name="' . $input->valueFieldName() . '"'
416
-                                )
417
-                            )
418
-                        ),
419
-                        // extra info
420
-                        'add_new_state_extra'         => new EE_Form_Section_HTML(
421
-                            apply_filters(
422
-                                'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_extra',
423
-                                EEH_HTML::br(2)
424
-                                .
425
-                                EEH_HTML::div('', '', 'small-text')
426
-                                .
427
-                                EEH_HTML::strong(
428
-                                    '* ' .
429
-                                    esc_html__(
430
-                                        'Don\'t know your State/Province Abbreviation?',
431
-                                        'event_espresso'
432
-                                    )
433
-                                )
434
-                                .
435
-                                EEH_HTML::br()
436
-                                .
437
-                                sprintf(
438
-                                    esc_html__(
439
-                                        'You can look here: %s, for a list of Countries and links to their State/Province Abbreviations ("Subdivisions assigned codes" column).',
440
-                                        'event_espresso'
441
-                                    ),
442
-                                    EEH_HTML::link(
443
-                                        'http://en.wikipedia.org/wiki/ISO_3166-2',
444
-                                        'http://en.wikipedia.org/wiki/ISO_3166-2',
445
-                                        '',
446
-                                        '',
447
-                                        'ee-form-add-new-state-wiki-lnk',
448
-                                        '',
449
-                                        'target="_blank"'
450
-                                    )
451
-                                )
452
-                                .
453
-                                EEH_HTML::divx()
454
-                                .
455
-                                EEH_HTML::br()
456
-                                .
457
-                                EEH_HTML::link(
458
-                                    '',
459
-                                    esc_html__('cancel new State/Province', 'event_espresso'),
460
-                                    '',
461
-                                    'hide-' . $input->html_id(),
462
-                                    'ee-form-cancel-new-state-lnk smaller-text',
463
-                                    '',
464
-                                    'data-target="' . $input->html_id() . '"'
465
-                                )
466
-                                .
467
-                                EEH_HTML::divx()
468
-                                .
469
-                                EEH_HTML::br()
470
-                            )
471
-                        ),
472
-                    ),
473
-                )
474
-            );
475
-            $question_group_reg_form->add_subsections(
476
-                array('new_state_micro_form' => $new_state_micro_form),
477
-                'state',
478
-                false
479
-            );
480
-        }
481
-        return $question_group_reg_form;
482
-    }
483
-
484
-
485
-    /**
486
-     * set_new_state_input_width
487
-     *
488
-     * @return int|string
489
-     * @throws EE_Error
490
-     * @throws InvalidArgumentException
491
-     * @throws InvalidDataTypeException
492
-     * @throws InvalidInterfaceException
493
-     * @throws ReflectionException
494
-     */
495
-    public static function add_new_state()
496
-    {
497
-        $REQ = EE_Registry::instance()->load_core('Request_Handler');
498
-        if (absint($REQ->get('nsmf_add_new_state')) === 1) {
499
-            EE_Registry::instance()->load_model('State');
500
-            // grab country ISO code, new state name, and new state abbreviation
501
-            $state_country = $REQ->is_set('nsmf_new_state_country')
502
-                ? sanitize_text_field($REQ->get('nsmf_new_state_country'))
503
-                : false;
504
-            $state_name = $REQ->is_set('nsmf_new_state_name')
505
-                ? sanitize_text_field($REQ->get('nsmf_new_state_name'))
506
-                : false;
507
-            $state_abbr = $REQ->is_set('nsmf_new_state_abbrv')
508
-                ? sanitize_text_field($REQ->get('nsmf_new_state_abbrv'))
509
-                : false;
510
-            if ($state_country && $state_name && $state_abbr) {
511
-                $new_state = EED_Add_New_State::save_new_state_to_db(
512
-                    array(
513
-                        'CNT_ISO'    => strtoupper($state_country),
514
-                        'STA_abbrev' => strtoupper($state_abbr),
515
-                        'STA_name'   => ucwords($state_name),
516
-                        'STA_active' => false,
517
-                    )
518
-                );
519
-                if ($new_state instanceof EE_State) {
520
-                    // clean house
521
-                    EE_Registry::instance()->REQ->un_set('nsmf_add_new_state');
522
-                    EE_Registry::instance()->REQ->un_set('nsmf_new_state_country');
523
-                    EE_Registry::instance()->REQ->un_set('nsmf_new_state_name');
524
-                    EE_Registry::instance()->REQ->un_set('nsmf_new_state_abbrv');
525
-                    // get any existing new states
526
-                    $new_states = EE_Registry::instance()->SSN->get_session_data(
527
-                        'nsmf_new_states'
528
-                    );
529
-                    $new_states[ $new_state->ID() ] = $new_state;
530
-                    EE_Registry::instance()->SSN->set_session_data(
531
-                        array('nsmf_new_states' => $new_states)
532
-                    );
533
-                    if (EE_Registry::instance()->REQ->ajax) {
534
-                        echo wp_json_encode(
535
-                            array(
536
-                                'success'      => true,
537
-                                'id'           => $new_state->ID(),
538
-                                'name'         => $new_state->name(),
539
-                                'abbrev'       => $new_state->abbrev(),
540
-                                'country_iso'  => $new_state->country_iso(),
541
-                                'country_name' => $new_state->country()->name(),
542
-                            )
543
-                        );
544
-                        exit();
545
-                    }
546
-                    return $new_state->ID();
547
-                }
548
-            } else {
549
-                $error = esc_html__(
550
-                    'A new State/Province could not be added because invalid or missing data was received.',
551
-                    'event_espresso'
552
-                );
553
-                if (EE_Registry::instance()->REQ->ajax) {
554
-                    echo wp_json_encode(array('error' => $error));
555
-                    exit();
556
-                }
557
-                EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__);
558
-            }
559
-        }
560
-        return false;
561
-    }
562
-
563
-
564
-    /**
565
-     * recursively drills down through request params to remove any that were added by this module
566
-     *
567
-     * @param array $request_params
568
-     * @return array
569
-     */
570
-    public static function filter_checkout_request_params($request_params)
571
-    {
572
-        foreach ($request_params as $form_section) {
573
-            if (is_array($form_section)) {
574
-                EED_Add_New_State::unset_new_state_request_params($form_section);
575
-                EED_Add_New_State::filter_checkout_request_params($form_section);
576
-            }
577
-        }
578
-        return $request_params;
579
-    }
580
-
581
-
582
-    /**
583
-     * @param array $request_params
584
-     * @return array
585
-     */
586
-    public static function unset_new_state_request_params($request_params)
587
-    {
588
-        unset(
589
-            $request_params['new_state_micro_form'],
590
-            $request_params['new_state_micro_add_new_state'],
591
-            $request_params['new_state_micro_new_state_country'],
592
-            $request_params['new_state_micro_new_state_name'],
593
-            $request_params['new_state_micro_new_state_abbrv']
594
-        );
595
-        return $request_params;
596
-    }
597
-
598
-
599
-    /**
600
-     * @param array $props_n_values
601
-     * @return bool
602
-     * @throws EE_Error
603
-     * @throws InvalidArgumentException
604
-     * @throws InvalidDataTypeException
605
-     * @throws InvalidInterfaceException
606
-     */
607
-    public static function save_new_state_to_db($props_n_values = array())
608
-    {
609
-        $existing_state = EEM_State::instance()->get_all(array($props_n_values, 'limit' => 1));
610
-        if (! empty($existing_state)) {
611
-            return array_pop($existing_state);
612
-        }
613
-        $new_state = EE_State::new_instance($props_n_values);
614
-        if ($new_state instanceof EE_State) {
615
-            $country_settings_url = add_query_arg(
616
-                array(
617
-                    'page'    => 'espresso_general_settings',
618
-                    'action'  => 'country_settings',
619
-                    'country' => $new_state->country_iso(),
620
-                ),
621
-                admin_url('admin.php')
622
-            );
623
-            // if not non-ajax admin
624
-            new PersistentAdminNotice(
625
-                'new-state-added-' . $new_state->country_iso() . '-' . $new_state->abbrev(),
626
-                sprintf(
627
-                    esc_html__(
628
-                        'A new State named "%1$s (%2$s)" was dynamically added from an Event Espresso form for the Country of "%3$s".%5$sTo verify, edit, and/or delete this new State, please go to the %4$s and update the States / Provinces section.%5$sCheck "Yes" to have this new State added to dropdown select lists in forms.',
629
-                        'event_espresso'
630
-                    ),
631
-                    '<b>' . $new_state->name() . '</b>',
632
-                    '<b>' . $new_state->abbrev() . '</b>',
633
-                    '<b>' . $new_state->country()->name() . '</b>',
634
-                    '<a href="'
635
-                    . $country_settings_url
636
-                    . '">'
637
-                    . esc_html__(
638
-                        'Event Espresso - General Settings > Countries Tab',
639
-                        'event_espresso'
640
-                    )
641
-                    . '</a>',
642
-                    '<br />'
643
-                )
644
-            );
645
-            $new_state->save();
646
-            EEM_State::instance()->reset_cached_states();
647
-            return $new_state;
648
-        }
649
-        return false;
650
-    }
651
-
652
-
653
-    /**
654
-     * @param string $CNT_ISO
655
-     * @param string $STA_ID
656
-     * @param array  $cols_n_values
657
-     * @return void
658
-     * @throws DomainException
659
-     * @throws EE_Error
660
-     * @throws InvalidArgumentException
661
-     * @throws InvalidDataTypeException
662
-     * @throws InvalidInterfaceException
663
-     */
664
-    public static function update_country_settings($CNT_ISO = '', $STA_ID = '', $cols_n_values = array())
665
-    {
666
-        if (! $CNT_ISO) {
667
-            EE_Error::add_error(
668
-                esc_html__('An invalid or missing Country ISO Code was received.', 'event_espresso'),
669
-                __FILE__,
670
-                __FUNCTION__,
671
-                __LINE__
672
-            );
673
-        }
674
-        $STA_abbrev = is_array($cols_n_values) && isset($cols_n_values['STA_abbrev']) ? $cols_n_values['STA_abbrev']
675
-            : false;
676
-        if (! $STA_abbrev && ! empty($STA_ID)) {
677
-            $state = EEM_State::instance()->get_one_by_ID($STA_ID);
678
-            if ($state instanceof EE_State) {
679
-                $STA_abbrev = $state->abbrev();
680
-            }
681
-        }
682
-        if (! $STA_abbrev) {
683
-            EE_Error::add_error(
684
-                esc_html__('An invalid or missing State Abbreviation was received.', 'event_espresso'),
685
-                __FILE__,
686
-                __FUNCTION__,
687
-                __LINE__
688
-            );
689
-        }
690
-        /** @var PersistentAdminNoticeManager $persistent_admin_notice_manager */
691
-        $persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared(
692
-            'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
693
-        );
694
-        $persistent_admin_notice_manager->dismissNotice($CNT_ISO . '-' . $STA_abbrev, true, true);
695
-    }
696
-
697
-
698
-    /**
699
-     * @param EE_State[]                            $state_options
700
-     * @param EE_SPCO_Reg_Step_Attendee_Information|StateOptions $deprecated
701
-     * @param EE_Registration                       $registration
702
-     * @param EE_Question                           $question
703
-     * @param                                       $answer
704
-     * @return array
705
-     * @throws EE_Error
706
-     * @throws InvalidArgumentException
707
-     * @throws InvalidDataTypeException
708
-     * @throws InvalidInterfaceException
709
-     */
710
-    public static function inject_new_reg_state_into_options(
711
-        $state_options = array(),
712
-        $deprecated,
713
-        EE_Registration $registration,
714
-        EE_Question $question,
715
-        $answer
716
-    ) {
717
-        if (
718
-            $answer instanceof EE_Answer && $question instanceof EE_Question
719
-            && $question->type() === EEM_Question::QST_type_state
720
-        ) {
721
-            $STA_ID = $answer->value();
722
-            if (! empty($STA_ID)) {
723
-                $state = EEM_State::instance()->get_one_by_ID($STA_ID);
724
-                if ($state instanceof EE_State) {
725
-                    $country = $state->country();
726
-                    if ($country instanceof EE_Country) {
727
-                        if (! isset($state_options[ $country->name() ])) {
728
-                            $state_options[ $country->name() ] = array();
729
-                        }
730
-                        if (! isset($state_options[ $country->name() ][ $STA_ID ])) {
731
-                            $state_options[ $country->name() ][ $STA_ID ] = $state->name();
732
-                        }
733
-                    }
734
-                }
735
-            }
736
-        }
737
-        return $state_options;
738
-    }
739
-
740
-
741
-    /**
742
-     * @param EE_Country[]                          $country_options
743
-     * @param EE_SPCO_Reg_Step_Attendee_Information|CountryOptions $deprecated
744
-     * @param EE_Registration                       $registration
745
-     * @param EE_Question                           $question
746
-     * @param                                       $answer
747
-     * @return array
748
-     * @throws EE_Error
749
-     * @throws InvalidArgumentException
750
-     * @throws InvalidDataTypeException
751
-     * @throws InvalidInterfaceException
752
-     * @throws ReflectionException
753
-     */
754
-    public static function inject_new_reg_country_into_options(
755
-        $country_options = array(),
756
-        $deprecated,
757
-        EE_Registration $registration,
758
-        EE_Question $question,
759
-        $answer
760
-    ) {
761
-        if (
762
-            $answer instanceof EE_Answer && $question instanceof EE_Question
763
-            && $question->type() === EEM_Question::QST_type_country
764
-        ) {
765
-            $CNT_ISO = $answer->value();
766
-            if (! empty($CNT_ISO)) {
767
-                $country = EEM_Country::instance()->get_one_by_ID($CNT_ISO);
768
-                if ($country instanceof EE_Country) {
769
-                    if (! isset($country_options[ $CNT_ISO ])) {
770
-                        $country_options[ $CNT_ISO ] = $country->name();
771
-                    }
772
-                }
773
-            }
774
-        }
775
-        return $country_options;
776
-    }
777
-
778
-
779
-    /**
780
-     * @param EE_State[] $state_options
781
-     * @return array
782
-     * @throws EE_Error
783
-     * @throws InvalidArgumentException
784
-     * @throws InvalidDataTypeException
785
-     * @throws InvalidInterfaceException
786
-     */
787
-    public static function state_options($state_options = array())
788
-    {
789
-        $new_states = EED_Add_New_State::_get_new_states();
790
-        foreach ($new_states as $new_state) {
791
-            if (
792
-                $new_state instanceof EE_State
793
-                && $new_state->country() instanceof EE_Country
794
-            ) {
795
-                $state_options[ $new_state->country()->name() ][ $new_state->ID() ] = $new_state->name();
796
-            }
797
-        }
798
-        return $state_options;
799
-    }
800
-
801
-
802
-    /**
803
-     * @return array
804
-     * @throws InvalidArgumentException
805
-     * @throws InvalidDataTypeException
806
-     * @throws InvalidInterfaceException
807
-     */
808
-    protected static function _get_new_states()
809
-    {
810
-        $new_states = array();
811
-        if (EE_Registry::instance()->SSN instanceof EE_Session) {
812
-            $new_states = EE_Registry::instance()->SSN->get_session_data(
813
-                'nsmf_new_states'
814
-            );
815
-        }
816
-        return is_array($new_states) ? $new_states : array();
817
-    }
818
-
819
-
820
-    /**
821
-     * @param EE_Country[] $country_options
822
-     * @return array
823
-     * @throws EE_Error
824
-     * @throws InvalidArgumentException
825
-     * @throws InvalidDataTypeException
826
-     * @throws InvalidInterfaceException
827
-     */
828
-    public static function country_options($country_options = array())
829
-    {
830
-        $new_states = EED_Add_New_State::_get_new_states();
831
-        foreach ($new_states as $new_state) {
832
-            if (
833
-                $new_state instanceof EE_State
834
-                && $new_state->country() instanceof EE_Country
835
-            ) {
836
-                $country_options[ $new_state->country()->ID() ] = $new_state->country()->name();
837
-            }
838
-        }
839
-        return $country_options;
840
-    }
22
+	/**
23
+	 * @return EED_Module|EED_Add_New_State
24
+	 */
25
+	public static function instance()
26
+	{
27
+		return parent::get_instance(__CLASS__);
28
+	}
29
+
30
+
31
+	/**
32
+	 * set_hooks - for hooking into EE Core, other modules, etc
33
+	 *
34
+	 * @return void
35
+	 */
36
+	public static function set_hooks()
37
+	{
38
+		add_action('wp_loaded', array('EED_Add_New_State', 'set_definitions'), 2);
39
+		add_action('wp_enqueue_scripts', array('EED_Add_New_State', 'translate_js_strings'), 0);
40
+		add_action('wp_enqueue_scripts', array('EED_Add_New_State', 'wp_enqueue_scripts'), 10);
41
+		add_filter(
42
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form',
43
+			array('EED_Add_New_State', 'display_add_new_state_micro_form'),
44
+			1,
45
+			1
46
+		);
47
+		add_filter(
48
+			'FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form',
49
+			array('EED_Add_New_State', 'display_add_new_state_micro_form'),
50
+			1,
51
+			1
52
+		);
53
+		add_filter(
54
+			'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item',
55
+			array('EED_Add_New_State', 'unset_new_state_request_params'),
56
+			10,
57
+			1
58
+		);
59
+		add_filter(
60
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options',
61
+			array('EED_Add_New_State', 'inject_new_reg_state_into_options'),
62
+			10,
63
+			5
64
+		);
65
+		add_filter(
66
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options',
67
+			array('EED_Add_New_State', 'inject_new_reg_country_into_options'),
68
+			10,
69
+			5
70
+		);
71
+		add_filter(
72
+			'FHEE__EE_State_Select_Input____construct__state_options',
73
+			array('EED_Add_New_State', 'state_options'),
74
+			10,
75
+			1
76
+		);
77
+		add_filter(
78
+			'FHEE__EE_Country_Select_Input____construct__country_options',
79
+			array('EED_Add_New_State', 'country_options'),
80
+			10,
81
+			1
82
+		);
83
+	}
84
+
85
+
86
+	/**
87
+	 * set_hooks_admin - for hooking into EE Admin Core, other modules, etc
88
+	 *
89
+	 * @return void
90
+	 */
91
+	public static function set_hooks_admin()
92
+	{
93
+		add_action('wp_loaded', array('EED_Add_New_State', 'set_definitions'), 2);
94
+		add_filter(
95
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form',
96
+			array('EED_Add_New_State', 'display_add_new_state_micro_form'),
97
+			1,
98
+			1
99
+		);
100
+		add_filter(
101
+			'FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form',
102
+			array('EED_Add_New_State', 'display_add_new_state_micro_form'),
103
+			1,
104
+			1
105
+		);
106
+		add_action('wp_ajax_espresso_add_new_state', array('EED_Add_New_State', 'add_new_state'));
107
+		add_action('wp_ajax_nopriv_espresso_add_new_state', array('EED_Add_New_State', 'add_new_state'));
108
+		add_filter(
109
+			'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item',
110
+			array('EED_Add_New_State', 'unset_new_state_request_params'),
111
+			10,
112
+			1
113
+		);
114
+		add_action(
115
+			'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved',
116
+			array('EED_Add_New_State', 'update_country_settings'),
117
+			10,
118
+			3
119
+		);
120
+		add_action(
121
+			'AHEE__General_Settings_Admin_Page__delete_state__state_deleted',
122
+			array('EED_Add_New_State', 'update_country_settings'),
123
+			10,
124
+			3
125
+		);
126
+		add_filter(
127
+			'FHEE__EE_State_Select_Input____construct__state_options',
128
+			array('EED_Add_New_State', 'state_options'),
129
+			10,
130
+			1
131
+		);
132
+		add_filter(
133
+			'FHEE__EE_Country_Select_Input____construct__country_options',
134
+			array('EED_Add_New_State', 'country_options'),
135
+			10,
136
+			1
137
+		);
138
+		add_filter(
139
+			'FHEE__EE_Form_Section_Proper__receive_form_submission__request_data',
140
+			array('EED_Add_New_State', 'filter_checkout_request_params'),
141
+			10,
142
+			1
143
+		);
144
+		add_filter(
145
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options',
146
+			array('EED_Add_New_State', 'inject_new_reg_state_into_options'),
147
+			10,
148
+			5
149
+		);
150
+		add_filter(
151
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options',
152
+			array('EED_Add_New_State', 'inject_new_reg_country_into_options'),
153
+			10,
154
+			5
155
+		);
156
+	}
157
+
158
+
159
+	/**
160
+	 * @return void
161
+	 */
162
+	public static function set_definitions()
163
+	{
164
+		define('ANS_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/');
165
+		define(
166
+			'ANS_TEMPLATES_PATH',
167
+			str_replace(
168
+				'\\',
169
+				'/',
170
+				plugin_dir_path(__FILE__)
171
+			) . 'templates/'
172
+		);
173
+	}
174
+
175
+
176
+	/**
177
+	 * @param WP $WP
178
+	 * @return void
179
+	 */
180
+	public function run($WP)
181
+	{
182
+	}
183
+
184
+
185
+	/**
186
+	 * @return void
187
+	 */
188
+	public static function translate_js_strings()
189
+	{
190
+		EE_Registry::$i18n_js_strings['ans_no_country'] = esc_html__(
191
+			'In order to proceed, you need to select the Country that your State/Province belongs to.',
192
+			'event_espresso'
193
+		);
194
+		EE_Registry::$i18n_js_strings['ans_no_name'] = esc_html__(
195
+			'In order to proceed, you need to enter the name of your State/Province.',
196
+			'event_espresso'
197
+		);
198
+		EE_Registry::$i18n_js_strings['ans_no_abbreviation'] = esc_html__(
199
+			'In order to proceed, you need to enter an abbreviation for the name of your State/Province.',
200
+			'event_espresso'
201
+		);
202
+		EE_Registry::$i18n_js_strings['ans_save_success'] = esc_html__(
203
+			'The new state was successfully saved to the database.',
204
+			'event_espresso'
205
+		);
206
+		EE_Registry::$i18n_js_strings['ans_server_save_error'] = esc_html__(
207
+			'An unknown error has occurred on the server while saving the new state to the database.',
208
+			'event_espresso'
209
+		);
210
+	}
211
+
212
+
213
+	/**
214
+	 * @return void
215
+	 */
216
+	public static function wp_enqueue_scripts()
217
+	{
218
+		if (apply_filters('EED_Single_Page_Checkout__SPCO_active', false)) {
219
+			wp_register_script(
220
+				'add_new_state',
221
+				ANS_ASSETS_URL . 'add_new_state.js',
222
+				array('espresso_core', 'single_page_checkout'),
223
+				EVENT_ESPRESSO_VERSION,
224
+				true
225
+			);
226
+			wp_enqueue_script('add_new_state');
227
+		}
228
+	}
229
+
230
+
231
+
232
+	/**
233
+	 * display_add_new_state_micro_form
234
+	 *
235
+	 * @param EE_Form_Section_Proper $question_group_reg_form
236
+	 * @return string
237
+	 * @throws EE_Error
238
+	 * @throws InvalidArgumentException
239
+	 * @throws InvalidDataTypeException
240
+	 * @throws InvalidInterfaceException
241
+	 */
242
+	public static function display_add_new_state_micro_form(EE_Form_Section_Proper $question_group_reg_form)
243
+	{
244
+		// only add the 'new_state_micro_form' when displaying reg forms,
245
+		// not during processing since we process the 'new_state_micro_form' in it's own AJAX request
246
+		$action = EE_Registry::instance()->REQ->get('action', '');
247
+		// is the "state" question in this form section?
248
+		$input = $question_group_reg_form->get_subsection('state');
249
+		if ($action === 'process_reg_step' || $action === 'update_reg_step') {
250
+			// ok then all we need to do is make sure the input's HTML name is consistent
251
+			// by forcing it to set it now, like it did while getting the form for display
252
+			if ($input instanceof EE_State_Select_Input) {
253
+				$input->html_name();
254
+			}
255
+			return $question_group_reg_form;
256
+		}
257
+		// we're only doing this for state select inputs
258
+		if (
259
+			$input instanceof EE_State_Select_Input
260
+			&& ! $input->get_display_strategy() instanceof EE_Hidden_Display_Strategy
261
+		) {
262
+			// grab any set values from the request
263
+			$country_name = str_replace('state', 'nsmf_new_state_country', $input->html_name());
264
+			$state_name = str_replace('state', 'nsmf_new_state_name', $input->html_name());
265
+			$abbrv_name = str_replace('state', 'nsmf_new_state_abbrv', $input->html_name());
266
+			$new_state_submit_id = str_replace('state', 'new_state', $input->html_id());
267
+			$country_options = array();
268
+			$countries = EEM_Country::instance()->get_all_countries();
269
+			if (! empty($countries)) {
270
+				foreach ($countries as $country) {
271
+					if ($country instanceof EE_Country) {
272
+						$country_options[ $country->ID() ] = $country->name();
273
+					}
274
+				}
275
+			}
276
+			$new_state_micro_form = new EE_Form_Section_Proper(
277
+				array(
278
+					'name'            => 'new_state_micro_form',
279
+					'html_id'         => 'new_state_micro_form',
280
+					'layout_strategy' => new EE_Div_Per_Section_Layout(),
281
+					'subsections'     => array(
282
+						// add hidden input to indicate that a new state is being added
283
+						'add_new_state'               => new EE_Hidden_Input(
284
+							array(
285
+								'html_name' => str_replace(
286
+									'state',
287
+									'nsmf_add_new_state',
288
+									$input->html_name()
289
+								),
290
+								'html_id'   => str_replace(
291
+									'state',
292
+									'nsmf_add_new_state',
293
+									$input->html_id()
294
+								),
295
+								'default'   => 0,
296
+							)
297
+						),
298
+						// add link for displaying hidden container
299
+						'click_here_link'             => new EE_Form_Section_HTML(
300
+							apply_filters(
301
+								'FHEE__EED_Add_New_State__display_add_new_state_micro_form__click_here_link',
302
+								EEH_HTML::link(
303
+									'',
304
+									esc_html__('click here to add a new state/province', 'event_espresso'),
305
+									'',
306
+									'display-' . $input->html_id(),
307
+									'ee-form-add-new-state-lnk display-the-hidden smaller-text hide-if-no-js',
308
+									'',
309
+									'data-target="' . $input->html_id() . '"'
310
+								)
311
+							)
312
+						),
313
+						// add initial html for hidden container
314
+						'add_new_state_micro_form'    => new EE_Form_Section_HTML(
315
+							apply_filters(
316
+								'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_micro_form',
317
+								EEH_HTML::div(
318
+									'',
319
+									$input->html_id() . '-dv',
320
+									'ee-form-add-new-state-dv',
321
+									'display: none;'
322
+								) .
323
+								EEH_HTML::h6(
324
+									esc_html__(
325
+										'Is your state/province missing from the dropdown menu above? You can add it by completing the following steps:',
326
+										'event_espresso'
327
+									)
328
+								) .
329
+								EEH_HTML::ul() .
330
+								EEH_HTML::li(
331
+									esc_html__(
332
+										'first select the Country that your State/Province belongs to',
333
+										'event_espresso'
334
+									)
335
+								) .
336
+								EEH_HTML::li(
337
+									esc_html__('enter the name of your State/Province', 'event_espresso')
338
+								) .
339
+								EEH_HTML::li(
340
+									esc_html__(
341
+										'enter a two to six letter abbreviation for the name of your State/Province',
342
+										'event_espresso'
343
+									)
344
+								) .
345
+								EEH_HTML::li(esc_html__('click the ADD button', 'event_espresso')) .
346
+								EEH_HTML::ulx()
347
+							)
348
+						),
349
+						// NEW STATE COUNTRY
350
+						'new_state_country'           => new EE_Country_Select_Input(
351
+							$country_options,
352
+							array(
353
+								'html_name'       => $country_name,
354
+								'html_id'         => str_replace(
355
+									'state',
356
+									'nsmf_new_state_country',
357
+									$input->html_id()
358
+								),
359
+								'html_class'      => $input->html_class() . ' new-state-country',
360
+								'html_label_text' => esc_html__('New State/Province Country', 'event_espresso'),
361
+								'default'         => EE_Registry::instance()->REQ->get($country_name, ''),
362
+								'required'        => false,
363
+							)
364
+						),
365
+						// NEW STATE NAME
366
+						'new_state_name'              => new EE_Text_Input(
367
+							array(
368
+								'html_name'       => $state_name,
369
+								'html_id'         => str_replace(
370
+									'state',
371
+									'nsmf_new_state_name',
372
+									$input->html_id()
373
+								),
374
+								'html_class'      => $input->html_class() . ' new-state-state',
375
+								'html_label_text' => esc_html__(
376
+									'New State/Province Name',
377
+									'event_espresso'
378
+								),
379
+								'default'         => EE_Registry::instance()->REQ->get($state_name, ''),
380
+								'required'        => false,
381
+							)
382
+						),
383
+						'spacer'                      => new EE_Form_Section_HTML(EEH_HTML::br()),
384
+						// NEW STATE NAME
385
+						'new_state_abbrv'             => new EE_Text_Input(
386
+							array(
387
+								'html_name'             => $abbrv_name,
388
+								'html_id'               => str_replace(
389
+									'state',
390
+									'nsmf_new_state_abbrv',
391
+									$input->html_id()
392
+								),
393
+								'html_class'            => $input->html_class() . ' new-state-abbrv',
394
+								'html_label_text'       => esc_html__(
395
+									'New State/Province Abbreviation',
396
+									'event_espresso'
397
+								) . ' *',
398
+								'other_html_attributes' => 'size="24"',
399
+								'default'               => EE_Registry::instance()->REQ->get($abbrv_name, ''),
400
+								'required'              => false,
401
+							)
402
+						),
403
+						// "submit" button
404
+						'add_new_state_submit_button' => new EE_Form_Section_HTML(
405
+							apply_filters(
406
+								'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_submit_button',
407
+								EEH_HTML::nbsp(3) .
408
+								EEH_HTML::link(
409
+									'',
410
+									esc_html__('ADD', 'event_espresso'),
411
+									'',
412
+									'submit-' . $new_state_submit_id,
413
+									'ee-form-add-new-state-submit button button-secondary',
414
+									'',
415
+									'data-target="' . $new_state_submit_id . '" data-value-field-name="' . $input->valueFieldName() . '"'
416
+								)
417
+							)
418
+						),
419
+						// extra info
420
+						'add_new_state_extra'         => new EE_Form_Section_HTML(
421
+							apply_filters(
422
+								'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_extra',
423
+								EEH_HTML::br(2)
424
+								.
425
+								EEH_HTML::div('', '', 'small-text')
426
+								.
427
+								EEH_HTML::strong(
428
+									'* ' .
429
+									esc_html__(
430
+										'Don\'t know your State/Province Abbreviation?',
431
+										'event_espresso'
432
+									)
433
+								)
434
+								.
435
+								EEH_HTML::br()
436
+								.
437
+								sprintf(
438
+									esc_html__(
439
+										'You can look here: %s, for a list of Countries and links to their State/Province Abbreviations ("Subdivisions assigned codes" column).',
440
+										'event_espresso'
441
+									),
442
+									EEH_HTML::link(
443
+										'http://en.wikipedia.org/wiki/ISO_3166-2',
444
+										'http://en.wikipedia.org/wiki/ISO_3166-2',
445
+										'',
446
+										'',
447
+										'ee-form-add-new-state-wiki-lnk',
448
+										'',
449
+										'target="_blank"'
450
+									)
451
+								)
452
+								.
453
+								EEH_HTML::divx()
454
+								.
455
+								EEH_HTML::br()
456
+								.
457
+								EEH_HTML::link(
458
+									'',
459
+									esc_html__('cancel new State/Province', 'event_espresso'),
460
+									'',
461
+									'hide-' . $input->html_id(),
462
+									'ee-form-cancel-new-state-lnk smaller-text',
463
+									'',
464
+									'data-target="' . $input->html_id() . '"'
465
+								)
466
+								.
467
+								EEH_HTML::divx()
468
+								.
469
+								EEH_HTML::br()
470
+							)
471
+						),
472
+					),
473
+				)
474
+			);
475
+			$question_group_reg_form->add_subsections(
476
+				array('new_state_micro_form' => $new_state_micro_form),
477
+				'state',
478
+				false
479
+			);
480
+		}
481
+		return $question_group_reg_form;
482
+	}
483
+
484
+
485
+	/**
486
+	 * set_new_state_input_width
487
+	 *
488
+	 * @return int|string
489
+	 * @throws EE_Error
490
+	 * @throws InvalidArgumentException
491
+	 * @throws InvalidDataTypeException
492
+	 * @throws InvalidInterfaceException
493
+	 * @throws ReflectionException
494
+	 */
495
+	public static function add_new_state()
496
+	{
497
+		$REQ = EE_Registry::instance()->load_core('Request_Handler');
498
+		if (absint($REQ->get('nsmf_add_new_state')) === 1) {
499
+			EE_Registry::instance()->load_model('State');
500
+			// grab country ISO code, new state name, and new state abbreviation
501
+			$state_country = $REQ->is_set('nsmf_new_state_country')
502
+				? sanitize_text_field($REQ->get('nsmf_new_state_country'))
503
+				: false;
504
+			$state_name = $REQ->is_set('nsmf_new_state_name')
505
+				? sanitize_text_field($REQ->get('nsmf_new_state_name'))
506
+				: false;
507
+			$state_abbr = $REQ->is_set('nsmf_new_state_abbrv')
508
+				? sanitize_text_field($REQ->get('nsmf_new_state_abbrv'))
509
+				: false;
510
+			if ($state_country && $state_name && $state_abbr) {
511
+				$new_state = EED_Add_New_State::save_new_state_to_db(
512
+					array(
513
+						'CNT_ISO'    => strtoupper($state_country),
514
+						'STA_abbrev' => strtoupper($state_abbr),
515
+						'STA_name'   => ucwords($state_name),
516
+						'STA_active' => false,
517
+					)
518
+				);
519
+				if ($new_state instanceof EE_State) {
520
+					// clean house
521
+					EE_Registry::instance()->REQ->un_set('nsmf_add_new_state');
522
+					EE_Registry::instance()->REQ->un_set('nsmf_new_state_country');
523
+					EE_Registry::instance()->REQ->un_set('nsmf_new_state_name');
524
+					EE_Registry::instance()->REQ->un_set('nsmf_new_state_abbrv');
525
+					// get any existing new states
526
+					$new_states = EE_Registry::instance()->SSN->get_session_data(
527
+						'nsmf_new_states'
528
+					);
529
+					$new_states[ $new_state->ID() ] = $new_state;
530
+					EE_Registry::instance()->SSN->set_session_data(
531
+						array('nsmf_new_states' => $new_states)
532
+					);
533
+					if (EE_Registry::instance()->REQ->ajax) {
534
+						echo wp_json_encode(
535
+							array(
536
+								'success'      => true,
537
+								'id'           => $new_state->ID(),
538
+								'name'         => $new_state->name(),
539
+								'abbrev'       => $new_state->abbrev(),
540
+								'country_iso'  => $new_state->country_iso(),
541
+								'country_name' => $new_state->country()->name(),
542
+							)
543
+						);
544
+						exit();
545
+					}
546
+					return $new_state->ID();
547
+				}
548
+			} else {
549
+				$error = esc_html__(
550
+					'A new State/Province could not be added because invalid or missing data was received.',
551
+					'event_espresso'
552
+				);
553
+				if (EE_Registry::instance()->REQ->ajax) {
554
+					echo wp_json_encode(array('error' => $error));
555
+					exit();
556
+				}
557
+				EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__);
558
+			}
559
+		}
560
+		return false;
561
+	}
562
+
563
+
564
+	/**
565
+	 * recursively drills down through request params to remove any that were added by this module
566
+	 *
567
+	 * @param array $request_params
568
+	 * @return array
569
+	 */
570
+	public static function filter_checkout_request_params($request_params)
571
+	{
572
+		foreach ($request_params as $form_section) {
573
+			if (is_array($form_section)) {
574
+				EED_Add_New_State::unset_new_state_request_params($form_section);
575
+				EED_Add_New_State::filter_checkout_request_params($form_section);
576
+			}
577
+		}
578
+		return $request_params;
579
+	}
580
+
581
+
582
+	/**
583
+	 * @param array $request_params
584
+	 * @return array
585
+	 */
586
+	public static function unset_new_state_request_params($request_params)
587
+	{
588
+		unset(
589
+			$request_params['new_state_micro_form'],
590
+			$request_params['new_state_micro_add_new_state'],
591
+			$request_params['new_state_micro_new_state_country'],
592
+			$request_params['new_state_micro_new_state_name'],
593
+			$request_params['new_state_micro_new_state_abbrv']
594
+		);
595
+		return $request_params;
596
+	}
597
+
598
+
599
+	/**
600
+	 * @param array $props_n_values
601
+	 * @return bool
602
+	 * @throws EE_Error
603
+	 * @throws InvalidArgumentException
604
+	 * @throws InvalidDataTypeException
605
+	 * @throws InvalidInterfaceException
606
+	 */
607
+	public static function save_new_state_to_db($props_n_values = array())
608
+	{
609
+		$existing_state = EEM_State::instance()->get_all(array($props_n_values, 'limit' => 1));
610
+		if (! empty($existing_state)) {
611
+			return array_pop($existing_state);
612
+		}
613
+		$new_state = EE_State::new_instance($props_n_values);
614
+		if ($new_state instanceof EE_State) {
615
+			$country_settings_url = add_query_arg(
616
+				array(
617
+					'page'    => 'espresso_general_settings',
618
+					'action'  => 'country_settings',
619
+					'country' => $new_state->country_iso(),
620
+				),
621
+				admin_url('admin.php')
622
+			);
623
+			// if not non-ajax admin
624
+			new PersistentAdminNotice(
625
+				'new-state-added-' . $new_state->country_iso() . '-' . $new_state->abbrev(),
626
+				sprintf(
627
+					esc_html__(
628
+						'A new State named "%1$s (%2$s)" was dynamically added from an Event Espresso form for the Country of "%3$s".%5$sTo verify, edit, and/or delete this new State, please go to the %4$s and update the States / Provinces section.%5$sCheck "Yes" to have this new State added to dropdown select lists in forms.',
629
+						'event_espresso'
630
+					),
631
+					'<b>' . $new_state->name() . '</b>',
632
+					'<b>' . $new_state->abbrev() . '</b>',
633
+					'<b>' . $new_state->country()->name() . '</b>',
634
+					'<a href="'
635
+					. $country_settings_url
636
+					. '">'
637
+					. esc_html__(
638
+						'Event Espresso - General Settings > Countries Tab',
639
+						'event_espresso'
640
+					)
641
+					. '</a>',
642
+					'<br />'
643
+				)
644
+			);
645
+			$new_state->save();
646
+			EEM_State::instance()->reset_cached_states();
647
+			return $new_state;
648
+		}
649
+		return false;
650
+	}
651
+
652
+
653
+	/**
654
+	 * @param string $CNT_ISO
655
+	 * @param string $STA_ID
656
+	 * @param array  $cols_n_values
657
+	 * @return void
658
+	 * @throws DomainException
659
+	 * @throws EE_Error
660
+	 * @throws InvalidArgumentException
661
+	 * @throws InvalidDataTypeException
662
+	 * @throws InvalidInterfaceException
663
+	 */
664
+	public static function update_country_settings($CNT_ISO = '', $STA_ID = '', $cols_n_values = array())
665
+	{
666
+		if (! $CNT_ISO) {
667
+			EE_Error::add_error(
668
+				esc_html__('An invalid or missing Country ISO Code was received.', 'event_espresso'),
669
+				__FILE__,
670
+				__FUNCTION__,
671
+				__LINE__
672
+			);
673
+		}
674
+		$STA_abbrev = is_array($cols_n_values) && isset($cols_n_values['STA_abbrev']) ? $cols_n_values['STA_abbrev']
675
+			: false;
676
+		if (! $STA_abbrev && ! empty($STA_ID)) {
677
+			$state = EEM_State::instance()->get_one_by_ID($STA_ID);
678
+			if ($state instanceof EE_State) {
679
+				$STA_abbrev = $state->abbrev();
680
+			}
681
+		}
682
+		if (! $STA_abbrev) {
683
+			EE_Error::add_error(
684
+				esc_html__('An invalid or missing State Abbreviation was received.', 'event_espresso'),
685
+				__FILE__,
686
+				__FUNCTION__,
687
+				__LINE__
688
+			);
689
+		}
690
+		/** @var PersistentAdminNoticeManager $persistent_admin_notice_manager */
691
+		$persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared(
692
+			'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
693
+		);
694
+		$persistent_admin_notice_manager->dismissNotice($CNT_ISO . '-' . $STA_abbrev, true, true);
695
+	}
696
+
697
+
698
+	/**
699
+	 * @param EE_State[]                            $state_options
700
+	 * @param EE_SPCO_Reg_Step_Attendee_Information|StateOptions $deprecated
701
+	 * @param EE_Registration                       $registration
702
+	 * @param EE_Question                           $question
703
+	 * @param                                       $answer
704
+	 * @return array
705
+	 * @throws EE_Error
706
+	 * @throws InvalidArgumentException
707
+	 * @throws InvalidDataTypeException
708
+	 * @throws InvalidInterfaceException
709
+	 */
710
+	public static function inject_new_reg_state_into_options(
711
+		$state_options = array(),
712
+		$deprecated,
713
+		EE_Registration $registration,
714
+		EE_Question $question,
715
+		$answer
716
+	) {
717
+		if (
718
+			$answer instanceof EE_Answer && $question instanceof EE_Question
719
+			&& $question->type() === EEM_Question::QST_type_state
720
+		) {
721
+			$STA_ID = $answer->value();
722
+			if (! empty($STA_ID)) {
723
+				$state = EEM_State::instance()->get_one_by_ID($STA_ID);
724
+				if ($state instanceof EE_State) {
725
+					$country = $state->country();
726
+					if ($country instanceof EE_Country) {
727
+						if (! isset($state_options[ $country->name() ])) {
728
+							$state_options[ $country->name() ] = array();
729
+						}
730
+						if (! isset($state_options[ $country->name() ][ $STA_ID ])) {
731
+							$state_options[ $country->name() ][ $STA_ID ] = $state->name();
732
+						}
733
+					}
734
+				}
735
+			}
736
+		}
737
+		return $state_options;
738
+	}
739
+
740
+
741
+	/**
742
+	 * @param EE_Country[]                          $country_options
743
+	 * @param EE_SPCO_Reg_Step_Attendee_Information|CountryOptions $deprecated
744
+	 * @param EE_Registration                       $registration
745
+	 * @param EE_Question                           $question
746
+	 * @param                                       $answer
747
+	 * @return array
748
+	 * @throws EE_Error
749
+	 * @throws InvalidArgumentException
750
+	 * @throws InvalidDataTypeException
751
+	 * @throws InvalidInterfaceException
752
+	 * @throws ReflectionException
753
+	 */
754
+	public static function inject_new_reg_country_into_options(
755
+		$country_options = array(),
756
+		$deprecated,
757
+		EE_Registration $registration,
758
+		EE_Question $question,
759
+		$answer
760
+	) {
761
+		if (
762
+			$answer instanceof EE_Answer && $question instanceof EE_Question
763
+			&& $question->type() === EEM_Question::QST_type_country
764
+		) {
765
+			$CNT_ISO = $answer->value();
766
+			if (! empty($CNT_ISO)) {
767
+				$country = EEM_Country::instance()->get_one_by_ID($CNT_ISO);
768
+				if ($country instanceof EE_Country) {
769
+					if (! isset($country_options[ $CNT_ISO ])) {
770
+						$country_options[ $CNT_ISO ] = $country->name();
771
+					}
772
+				}
773
+			}
774
+		}
775
+		return $country_options;
776
+	}
777
+
778
+
779
+	/**
780
+	 * @param EE_State[] $state_options
781
+	 * @return array
782
+	 * @throws EE_Error
783
+	 * @throws InvalidArgumentException
784
+	 * @throws InvalidDataTypeException
785
+	 * @throws InvalidInterfaceException
786
+	 */
787
+	public static function state_options($state_options = array())
788
+	{
789
+		$new_states = EED_Add_New_State::_get_new_states();
790
+		foreach ($new_states as $new_state) {
791
+			if (
792
+				$new_state instanceof EE_State
793
+				&& $new_state->country() instanceof EE_Country
794
+			) {
795
+				$state_options[ $new_state->country()->name() ][ $new_state->ID() ] = $new_state->name();
796
+			}
797
+		}
798
+		return $state_options;
799
+	}
800
+
801
+
802
+	/**
803
+	 * @return array
804
+	 * @throws InvalidArgumentException
805
+	 * @throws InvalidDataTypeException
806
+	 * @throws InvalidInterfaceException
807
+	 */
808
+	protected static function _get_new_states()
809
+	{
810
+		$new_states = array();
811
+		if (EE_Registry::instance()->SSN instanceof EE_Session) {
812
+			$new_states = EE_Registry::instance()->SSN->get_session_data(
813
+				'nsmf_new_states'
814
+			);
815
+		}
816
+		return is_array($new_states) ? $new_states : array();
817
+	}
818
+
819
+
820
+	/**
821
+	 * @param EE_Country[] $country_options
822
+	 * @return array
823
+	 * @throws EE_Error
824
+	 * @throws InvalidArgumentException
825
+	 * @throws InvalidDataTypeException
826
+	 * @throws InvalidInterfaceException
827
+	 */
828
+	public static function country_options($country_options = array())
829
+	{
830
+		$new_states = EED_Add_New_State::_get_new_states();
831
+		foreach ($new_states as $new_state) {
832
+			if (
833
+				$new_state instanceof EE_State
834
+				&& $new_state->country() instanceof EE_Country
835
+			) {
836
+				$country_options[ $new_state->country()->ID() ] = $new_state->country()->name();
837
+			}
838
+		}
839
+		return $country_options;
840
+	}
841 841
 }
Please login to merge, or discard this patch.
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -161,14 +161,14 @@  discard block
 block discarded – undo
161 161
      */
162 162
     public static function set_definitions()
163 163
     {
164
-        define('ANS_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/');
164
+        define('ANS_ASSETS_URL', plugin_dir_url(__FILE__).'assets/');
165 165
         define(
166 166
             'ANS_TEMPLATES_PATH',
167 167
             str_replace(
168 168
                 '\\',
169 169
                 '/',
170 170
                 plugin_dir_path(__FILE__)
171
-            ) . 'templates/'
171
+            ).'templates/'
172 172
         );
173 173
     }
174 174
 
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
         if (apply_filters('EED_Single_Page_Checkout__SPCO_active', false)) {
219 219
             wp_register_script(
220 220
                 'add_new_state',
221
-                ANS_ASSETS_URL . 'add_new_state.js',
221
+                ANS_ASSETS_URL.'add_new_state.js',
222 222
                 array('espresso_core', 'single_page_checkout'),
223 223
                 EVENT_ESPRESSO_VERSION,
224 224
                 true
@@ -266,10 +266,10 @@  discard block
 block discarded – undo
266 266
             $new_state_submit_id = str_replace('state', 'new_state', $input->html_id());
267 267
             $country_options = array();
268 268
             $countries = EEM_Country::instance()->get_all_countries();
269
-            if (! empty($countries)) {
269
+            if ( ! empty($countries)) {
270 270
                 foreach ($countries as $country) {
271 271
                     if ($country instanceof EE_Country) {
272
-                        $country_options[ $country->ID() ] = $country->name();
272
+                        $country_options[$country->ID()] = $country->name();
273 273
                     }
274 274
                 }
275 275
             }
@@ -303,10 +303,10 @@  discard block
 block discarded – undo
303 303
                                     '',
304 304
                                     esc_html__('click here to add a new state/province', 'event_espresso'),
305 305
                                     '',
306
-                                    'display-' . $input->html_id(),
306
+                                    'display-'.$input->html_id(),
307 307
                                     'ee-form-add-new-state-lnk display-the-hidden smaller-text hide-if-no-js',
308 308
                                     '',
309
-                                    'data-target="' . $input->html_id() . '"'
309
+                                    'data-target="'.$input->html_id().'"'
310 310
                                 )
311 311
                             )
312 312
                         ),
@@ -316,33 +316,33 @@  discard block
 block discarded – undo
316 316
                                 'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_micro_form',
317 317
                                 EEH_HTML::div(
318 318
                                     '',
319
-                                    $input->html_id() . '-dv',
319
+                                    $input->html_id().'-dv',
320 320
                                     'ee-form-add-new-state-dv',
321 321
                                     'display: none;'
322
-                                ) .
322
+                                ).
323 323
                                 EEH_HTML::h6(
324 324
                                     esc_html__(
325 325
                                         'Is your state/province missing from the dropdown menu above? You can add it by completing the following steps:',
326 326
                                         'event_espresso'
327 327
                                     )
328
-                                ) .
329
-                                EEH_HTML::ul() .
328
+                                ).
329
+                                EEH_HTML::ul().
330 330
                                 EEH_HTML::li(
331 331
                                     esc_html__(
332 332
                                         'first select the Country that your State/Province belongs to',
333 333
                                         'event_espresso'
334 334
                                     )
335
-                                ) .
335
+                                ).
336 336
                                 EEH_HTML::li(
337 337
                                     esc_html__('enter the name of your State/Province', 'event_espresso')
338
-                                ) .
338
+                                ).
339 339
                                 EEH_HTML::li(
340 340
                                     esc_html__(
341 341
                                         'enter a two to six letter abbreviation for the name of your State/Province',
342 342
                                         'event_espresso'
343 343
                                     )
344
-                                ) .
345
-                                EEH_HTML::li(esc_html__('click the ADD button', 'event_espresso')) .
344
+                                ).
345
+                                EEH_HTML::li(esc_html__('click the ADD button', 'event_espresso')).
346 346
                                 EEH_HTML::ulx()
347 347
                             )
348 348
                         ),
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
                                     'nsmf_new_state_country',
357 357
                                     $input->html_id()
358 358
                                 ),
359
-                                'html_class'      => $input->html_class() . ' new-state-country',
359
+                                'html_class'      => $input->html_class().' new-state-country',
360 360
                                 'html_label_text' => esc_html__('New State/Province Country', 'event_espresso'),
361 361
                                 'default'         => EE_Registry::instance()->REQ->get($country_name, ''),
362 362
                                 'required'        => false,
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
                                     'nsmf_new_state_name',
372 372
                                     $input->html_id()
373 373
                                 ),
374
-                                'html_class'      => $input->html_class() . ' new-state-state',
374
+                                'html_class'      => $input->html_class().' new-state-state',
375 375
                                 'html_label_text' => esc_html__(
376 376
                                     'New State/Province Name',
377 377
                                     'event_espresso'
@@ -390,11 +390,11 @@  discard block
 block discarded – undo
390 390
                                     'nsmf_new_state_abbrv',
391 391
                                     $input->html_id()
392 392
                                 ),
393
-                                'html_class'            => $input->html_class() . ' new-state-abbrv',
393
+                                'html_class'            => $input->html_class().' new-state-abbrv',
394 394
                                 'html_label_text'       => esc_html__(
395 395
                                     'New State/Province Abbreviation',
396 396
                                     'event_espresso'
397
-                                ) . ' *',
397
+                                ).' *',
398 398
                                 'other_html_attributes' => 'size="24"',
399 399
                                 'default'               => EE_Registry::instance()->REQ->get($abbrv_name, ''),
400 400
                                 'required'              => false,
@@ -404,15 +404,15 @@  discard block
 block discarded – undo
404 404
                         'add_new_state_submit_button' => new EE_Form_Section_HTML(
405 405
                             apply_filters(
406 406
                                 'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_submit_button',
407
-                                EEH_HTML::nbsp(3) .
407
+                                EEH_HTML::nbsp(3).
408 408
                                 EEH_HTML::link(
409 409
                                     '',
410 410
                                     esc_html__('ADD', 'event_espresso'),
411 411
                                     '',
412
-                                    'submit-' . $new_state_submit_id,
412
+                                    'submit-'.$new_state_submit_id,
413 413
                                     'ee-form-add-new-state-submit button button-secondary',
414 414
                                     '',
415
-                                    'data-target="' . $new_state_submit_id . '" data-value-field-name="' . $input->valueFieldName() . '"'
415
+                                    'data-target="'.$new_state_submit_id.'" data-value-field-name="'.$input->valueFieldName().'"'
416 416
                                 )
417 417
                             )
418 418
                         ),
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
                                 EEH_HTML::div('', '', 'small-text')
426 426
                                 .
427 427
                                 EEH_HTML::strong(
428
-                                    '* ' .
428
+                                    '* '.
429 429
                                     esc_html__(
430 430
                                         'Don\'t know your State/Province Abbreviation?',
431 431
                                         'event_espresso'
@@ -458,10 +458,10 @@  discard block
 block discarded – undo
458 458
                                     '',
459 459
                                     esc_html__('cancel new State/Province', 'event_espresso'),
460 460
                                     '',
461
-                                    'hide-' . $input->html_id(),
461
+                                    'hide-'.$input->html_id(),
462 462
                                     'ee-form-cancel-new-state-lnk smaller-text',
463 463
                                     '',
464
-                                    'data-target="' . $input->html_id() . '"'
464
+                                    'data-target="'.$input->html_id().'"'
465 465
                                 )
466 466
                                 .
467 467
                                 EEH_HTML::divx()
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
                     $new_states = EE_Registry::instance()->SSN->get_session_data(
527 527
                         'nsmf_new_states'
528 528
                     );
529
-                    $new_states[ $new_state->ID() ] = $new_state;
529
+                    $new_states[$new_state->ID()] = $new_state;
530 530
                     EE_Registry::instance()->SSN->set_session_data(
531 531
                         array('nsmf_new_states' => $new_states)
532 532
                     );
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
     public static function save_new_state_to_db($props_n_values = array())
608 608
     {
609 609
         $existing_state = EEM_State::instance()->get_all(array($props_n_values, 'limit' => 1));
610
-        if (! empty($existing_state)) {
610
+        if ( ! empty($existing_state)) {
611 611
             return array_pop($existing_state);
612 612
         }
613 613
         $new_state = EE_State::new_instance($props_n_values);
@@ -622,15 +622,15 @@  discard block
 block discarded – undo
622 622
             );
623 623
             // if not non-ajax admin
624 624
             new PersistentAdminNotice(
625
-                'new-state-added-' . $new_state->country_iso() . '-' . $new_state->abbrev(),
625
+                'new-state-added-'.$new_state->country_iso().'-'.$new_state->abbrev(),
626 626
                 sprintf(
627 627
                     esc_html__(
628 628
                         'A new State named "%1$s (%2$s)" was dynamically added from an Event Espresso form for the Country of "%3$s".%5$sTo verify, edit, and/or delete this new State, please go to the %4$s and update the States / Provinces section.%5$sCheck "Yes" to have this new State added to dropdown select lists in forms.',
629 629
                         'event_espresso'
630 630
                     ),
631
-                    '<b>' . $new_state->name() . '</b>',
632
-                    '<b>' . $new_state->abbrev() . '</b>',
633
-                    '<b>' . $new_state->country()->name() . '</b>',
631
+                    '<b>'.$new_state->name().'</b>',
632
+                    '<b>'.$new_state->abbrev().'</b>',
633
+                    '<b>'.$new_state->country()->name().'</b>',
634 634
                     '<a href="'
635 635
                     . $country_settings_url
636 636
                     . '">'
@@ -663,7 +663,7 @@  discard block
 block discarded – undo
663 663
      */
664 664
     public static function update_country_settings($CNT_ISO = '', $STA_ID = '', $cols_n_values = array())
665 665
     {
666
-        if (! $CNT_ISO) {
666
+        if ( ! $CNT_ISO) {
667 667
             EE_Error::add_error(
668 668
                 esc_html__('An invalid or missing Country ISO Code was received.', 'event_espresso'),
669 669
                 __FILE__,
@@ -673,13 +673,13 @@  discard block
 block discarded – undo
673 673
         }
674 674
         $STA_abbrev = is_array($cols_n_values) && isset($cols_n_values['STA_abbrev']) ? $cols_n_values['STA_abbrev']
675 675
             : false;
676
-        if (! $STA_abbrev && ! empty($STA_ID)) {
676
+        if ( ! $STA_abbrev && ! empty($STA_ID)) {
677 677
             $state = EEM_State::instance()->get_one_by_ID($STA_ID);
678 678
             if ($state instanceof EE_State) {
679 679
                 $STA_abbrev = $state->abbrev();
680 680
             }
681 681
         }
682
-        if (! $STA_abbrev) {
682
+        if ( ! $STA_abbrev) {
683 683
             EE_Error::add_error(
684 684
                 esc_html__('An invalid or missing State Abbreviation was received.', 'event_espresso'),
685 685
                 __FILE__,
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
         $persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared(
692 692
             'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
693 693
         );
694
-        $persistent_admin_notice_manager->dismissNotice($CNT_ISO . '-' . $STA_abbrev, true, true);
694
+        $persistent_admin_notice_manager->dismissNotice($CNT_ISO.'-'.$STA_abbrev, true, true);
695 695
     }
696 696
 
697 697
 
@@ -719,16 +719,16 @@  discard block
 block discarded – undo
719 719
             && $question->type() === EEM_Question::QST_type_state
720 720
         ) {
721 721
             $STA_ID = $answer->value();
722
-            if (! empty($STA_ID)) {
722
+            if ( ! empty($STA_ID)) {
723 723
                 $state = EEM_State::instance()->get_one_by_ID($STA_ID);
724 724
                 if ($state instanceof EE_State) {
725 725
                     $country = $state->country();
726 726
                     if ($country instanceof EE_Country) {
727
-                        if (! isset($state_options[ $country->name() ])) {
728
-                            $state_options[ $country->name() ] = array();
727
+                        if ( ! isset($state_options[$country->name()])) {
728
+                            $state_options[$country->name()] = array();
729 729
                         }
730
-                        if (! isset($state_options[ $country->name() ][ $STA_ID ])) {
731
-                            $state_options[ $country->name() ][ $STA_ID ] = $state->name();
730
+                        if ( ! isset($state_options[$country->name()][$STA_ID])) {
731
+                            $state_options[$country->name()][$STA_ID] = $state->name();
732 732
                         }
733 733
                     }
734 734
                 }
@@ -763,11 +763,11 @@  discard block
 block discarded – undo
763 763
             && $question->type() === EEM_Question::QST_type_country
764 764
         ) {
765 765
             $CNT_ISO = $answer->value();
766
-            if (! empty($CNT_ISO)) {
766
+            if ( ! empty($CNT_ISO)) {
767 767
                 $country = EEM_Country::instance()->get_one_by_ID($CNT_ISO);
768 768
                 if ($country instanceof EE_Country) {
769
-                    if (! isset($country_options[ $CNT_ISO ])) {
770
-                        $country_options[ $CNT_ISO ] = $country->name();
769
+                    if ( ! isset($country_options[$CNT_ISO])) {
770
+                        $country_options[$CNT_ISO] = $country->name();
771 771
                     }
772 772
                 }
773 773
             }
@@ -792,7 +792,7 @@  discard block
 block discarded – undo
792 792
                 $new_state instanceof EE_State
793 793
                 && $new_state->country() instanceof EE_Country
794 794
             ) {
795
-                $state_options[ $new_state->country()->name() ][ $new_state->ID() ] = $new_state->name();
795
+                $state_options[$new_state->country()->name()][$new_state->ID()] = $new_state->name();
796 796
             }
797 797
         }
798 798
         return $state_options;
@@ -833,7 +833,7 @@  discard block
 block discarded – undo
833 833
                 $new_state instanceof EE_State
834 834
                 && $new_state->country() instanceof EE_Country
835 835
             ) {
836
-                $country_options[ $new_state->country()->ID() ] = $new_state->country()->name();
836
+                $country_options[$new_state->country()->ID()] = $new_state->country()->name();
837 837
             }
838 838
         }
839 839
         return $country_options;
Please login to merge, or discard this patch.
modules/certificate/EED_Certificate.module.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -96,7 +96,7 @@
 block discarded – undo
96 96
      *    the_content
97 97
      *
98 98
      * @access    public
99
-     * @return    void
99
+     * @return    string
100 100
      */
101 101
     public function the_content($content)
102 102
     {
Please login to merge, or discard this patch.
Indentation   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -13,95 +13,95 @@
 block discarded – undo
13 13
 {
14 14
 
15 15
 
16
-    /**
17
-     * @return EED_Module
18
-     */
19
-    public static function instance()
20
-    {
21
-        return parent::get_instance(__CLASS__);
22
-    }
23
-
24
-
25
-    /**
26
-     *    set_hooks - for hooking into EE Core, other modules, etc
27
-     *
28
-     * @access    public
29
-     * @return    void
30
-     */
31
-    public static function set_hooks()
32
-    {
33
-    }
34
-
35
-    /**
36
-     *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
37
-     *
38
-     * @access    public
39
-     * @return    void
40
-     */
41
-    public static function set_hooks_admin()
42
-    {
43
-    }
44
-
45
-
46
-    /**
47
-     *    run - initial module setup
48
-     *
49
-     * @access    public
50
-     * @return    void
51
-     */
52
-    public function run($WP)
53
-    {
54
-    }
55
-
56
-
57
-    /**
58
-     *    certificate_launch
59
-     *
60
-     * @access    public
61
-     * @return    void
62
-     */
63
-    public function certificate_launch()
64
-    {
65
-        if (EE_Registry::instance()->REQ->is_set('id') && EE_Registry::instance()->REQ->is_set('r_id')) {
66
-            echo espresso_certificate_launch(
67
-                EE_Registry::instance()->REQ->get('id'),
68
-                EE_Registry::instance()->REQ->get('r_id')
69
-            );
70
-        }
71
-    }
72
-
73
-
74
-    /**
75
-     *    wp_loaded
76
-     *
77
-     * @access    public
78
-     * @return    void
79
-     */
80
-    public function wp_loaded()
81
-    {
82
-    }
83
-
84
-
85
-    /**
86
-     *    wp
87
-     *
88
-     * @access    public
89
-     * @return    void
90
-     */
91
-    public function wp()
92
-    {
93
-    }
94
-
95
-
96
-    /**
97
-     *    the_content
98
-     *
99
-     * @access    public
100
-     * @return    void
101
-     */
102
-    public function the_content($content)
103
-    {
104
-        $content .= $this->ouput;
105
-        return $content;
106
-    }
16
+	/**
17
+	 * @return EED_Module
18
+	 */
19
+	public static function instance()
20
+	{
21
+		return parent::get_instance(__CLASS__);
22
+	}
23
+
24
+
25
+	/**
26
+	 *    set_hooks - for hooking into EE Core, other modules, etc
27
+	 *
28
+	 * @access    public
29
+	 * @return    void
30
+	 */
31
+	public static function set_hooks()
32
+	{
33
+	}
34
+
35
+	/**
36
+	 *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
37
+	 *
38
+	 * @access    public
39
+	 * @return    void
40
+	 */
41
+	public static function set_hooks_admin()
42
+	{
43
+	}
44
+
45
+
46
+	/**
47
+	 *    run - initial module setup
48
+	 *
49
+	 * @access    public
50
+	 * @return    void
51
+	 */
52
+	public function run($WP)
53
+	{
54
+	}
55
+
56
+
57
+	/**
58
+	 *    certificate_launch
59
+	 *
60
+	 * @access    public
61
+	 * @return    void
62
+	 */
63
+	public function certificate_launch()
64
+	{
65
+		if (EE_Registry::instance()->REQ->is_set('id') && EE_Registry::instance()->REQ->is_set('r_id')) {
66
+			echo espresso_certificate_launch(
67
+				EE_Registry::instance()->REQ->get('id'),
68
+				EE_Registry::instance()->REQ->get('r_id')
69
+			);
70
+		}
71
+	}
72
+
73
+
74
+	/**
75
+	 *    wp_loaded
76
+	 *
77
+	 * @access    public
78
+	 * @return    void
79
+	 */
80
+	public function wp_loaded()
81
+	{
82
+	}
83
+
84
+
85
+	/**
86
+	 *    wp
87
+	 *
88
+	 * @access    public
89
+	 * @return    void
90
+	 */
91
+	public function wp()
92
+	{
93
+	}
94
+
95
+
96
+	/**
97
+	 *    the_content
98
+	 *
99
+	 * @access    public
100
+	 * @return    void
101
+	 */
102
+	public function the_content($content)
103
+	{
104
+		$content .= $this->ouput;
105
+		return $content;
106
+	}
107 107
 }
Please login to merge, or discard this patch.
modules/events_archive_filters/EED_Events_Archive_Filters.module.php 3 patches
Doc Comments   +14 added lines, -13 removed lines patch added patch discarded remove patch
@@ -247,6 +247,7 @@  discard block
 block discarded – undo
247 247
      * @access    public
248 248
      * @param    mixed boolean|string    $join_terms pass TRUE or term string, doesn't really matter since this value
249 249
      *                                   doesn't really get used for anything yet
250
+     * @param string $join_terms
250 251
      * @return    string
251 252
      */
252 253
     public static function posts_join_sql_for_terms($join_terms = null)
@@ -422,7 +423,7 @@  discard block
 block discarded – undo
422 423
      *    or else some of the table references below will result in MySQL errors
423 424
      *
424 425
      * @access    public
425
-     * @param    boolean $orderby_params
426
+     * @param    string[] $orderby_params
426 427
      * @return    string
427 428
      */
428 429
     public static function posts_orderby_sql($orderby_params = array(), $sort = 'ASC')
@@ -535,7 +536,7 @@  discard block
 block discarded – undo
535 536
      *
536 537
      * @access    public
537 538
      * @param        string $content
538
-     * @return        void
539
+     * @return        string
539 540
      */
540 541
     public function event_details($content)
541 542
     {
@@ -552,7 +553,7 @@  discard block
 block discarded – undo
552 553
      *
553 554
      * @access    public
554 555
      * @param        string $content
555
-     * @return        void
556
+     * @return        string
556 557
      */
557 558
     public function event_tickets($content)
558 559
     {
@@ -569,7 +570,7 @@  discard block
 block discarded – undo
569 570
      *
570 571
      * @access    public
571 572
      * @param        string $content
572
-     * @return        void
573
+     * @return        string
573 574
      */
574 575
     public function event_datetimes($content)
575 576
     {
@@ -586,7 +587,7 @@  discard block
 block discarded – undo
586 587
      *
587 588
      * @access    public
588 589
      * @param        string $content
589
-     * @return        void
590
+     * @return        string
590 591
      */
591 592
     public function event_venues($content)
592 593
     {
@@ -635,7 +636,7 @@  discard block
 block discarded – undo
635 636
      *    excerpt_length
636 637
      *
637 638
      * @access    public
638
-     * @return    void
639
+     * @return    integer|null
639 640
      */
640 641
     public function excerpt_length($length)
641 642
     {
@@ -665,7 +666,7 @@  discard block
 block discarded – undo
665 666
      *    excerpt_more
666 667
      *
667 668
      * @access    public
668
-     * @return    void
669
+     * @return    string
669 670
      */
670 671
     public function excerpt_more($more)
671 672
     {
@@ -866,7 +867,7 @@  discard block
 block discarded – undo
866 867
      *    get_template_part
867 868
      *
868 869
      * @access    public
869
-     * @return    void
870
+     * @return    string|null
870 871
      */
871 872
     public static function get_template_part()
872 873
     {
@@ -910,7 +911,7 @@  discard block
 block discarded – undo
910 911
      *    event_list_css
911 912
      *
912 913
      * @access    public
913
-     * @return    void
914
+     * @return    string
914 915
      */
915 916
     public static function event_list_css($extra_class = '')
916 917
     {
@@ -946,7 +947,7 @@  discard block
 block discarded – undo
946 947
      *    display_description
947 948
      *
948 949
      * @access    public
949
-     * @return    void
950
+     * @return    boolean
950 951
      */
951 952
     public static function display_description($value)
952 953
     {
@@ -961,7 +962,7 @@  discard block
 block discarded – undo
961 962
      *    display_venue_details
962 963
      *
963 964
      * @access    public
964
-     * @return    void
965
+     * @return    boolean
965 966
      */
966 967
     public static function display_venue_details()
967 968
     {
@@ -977,7 +978,7 @@  discard block
 block discarded – undo
977 978
      *    display_address
978 979
      *
979 980
      * @access    public
980
-     * @return    void
981
+     * @return    boolean
981 982
      */
982 983
     public static function display_address()
983 984
     {
@@ -993,7 +994,7 @@  discard block
 block discarded – undo
993 994
      *    pagination
994 995
      *
995 996
      * @access    public
996
-     * @return    void
997
+     * @return    string
997 998
      */
998 999
     public static function pagination()
999 1000
     {
Please login to merge, or discard this patch.
Indentation   +1026 added lines, -1026 removed lines patch added patch discarded remove patch
@@ -13,1030 +13,1030 @@
 block discarded – undo
13 13
 {
14 14
 
15 15
 
16
-    /**
17
-     * @return EED_Events_Archive_Filters
18
-     */
19
-    public static function instance()
20
-    {
21
-        return parent::get_instance(__CLASS__);
22
-    }
23
-
24
-
25
-    /**
26
-     *    Start Date
27
-     *
28
-     * @var    $_elf_month
29
-     * @access    protected
30
-     */
31
-    protected $_elf_month = null;
32
-
33
-
34
-    /**
35
-     *    Category
36
-     *
37
-     * @var    $_elf_category
38
-     * @access    protected
39
-     */
40
-    protected $_elf_category = null;
41
-
42
-
43
-    /**
44
-     *    whether to display expired events in the event list
45
-     *
46
-     * @var    $_show_expired
47
-     * @access    protected
48
-     */
49
-    protected $_show_expired = null;
50
-
51
-
52
-    /**
53
-     *    whether to display the event list as a grid or list
54
-     *
55
-     * @var    $_type
56
-     * @access    protected
57
-     */
58
-    protected static $_type = null;
59
-
60
-
61
-    /**
62
-     *    array of existing event list views
63
-     *
64
-     * @var    $_types
65
-     * @access    protected
66
-     */
67
-    protected static $_types = array('grid', 'text', 'dates');
68
-
69
-
70
-
71
-    /**
72
-     *    set_hooks - for hooking into EE Core, other modules, etc
73
-     *
74
-     * @access    public
75
-     * @return    void
76
-     */
77
-    public static function set_hooks()
78
-    {
79
-    }
80
-
81
-    /**
82
-     *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
83
-     *
84
-     * @access    public
85
-     * @return    void
86
-     */
87
-    public static function set_hooks_admin()
88
-    {
89
-    }
90
-
91
-
92
-    /**
93
-     *    set_definitions
94
-     *
95
-     * @access    public
96
-     * @return    void
97
-     */
98
-    public static function set_definitions()
99
-    {
100
-    }
101
-
102
-
103
-    /**
104
-     *    run - initial module setup
105
-     *
106
-     * @access    public
107
-     * @return    void
108
-     */
109
-    public function run($WP)
110
-    {
111
-    }
112
-
113
-
114
-    /**
115
-     *    event_list
116
-     *
117
-     * @access    public
118
-     * @return    void
119
-     */
120
-    public function event_list()
121
-    {
122
-        // load other required components
123
-        $this->_load_assests();
124
-    }
125
-
126
-
127
-    /**
128
-     *    _filter_query_parts
129
-     *
130
-     * @access    public
131
-     * @return    void
132
-     */
133
-    private function _filter_query_parts()
134
-    {
135
-        // build event list query
136
-        add_filter('posts_join', array($this, 'posts_join'), 1, 2);
137
-        add_filter('posts_where', array($this, 'posts_where'), 1, 2);
138
-        add_filter('posts_orderby', array($this, 'posts_orderby'), 1, 2);
139
-    }
140
-
141
-    /**
142
-     *    _type - the type of event list : grid, text, dates
143
-     *
144
-     * @access    public
145
-     * @return    string
146
-     */
147
-    public static function set_type()
148
-    {
149
-        do_action('AHEE__EED_Events_Archive_Filters__before_set_type');
150
-        EED_Events_Archive_Filters::$_types = apply_filters(
151
-            'EED_Events_Archive_Filters__set_type__types',
152
-            EED_Events_Archive_Filters::$_types
153
-        );
154
-        $view = isset(EE_Registry::instance()->CFG->EED_Events_Archive_Filters['default_type']) ? EE_Registry::instance(
155
-        )->CFG->EED_Events_Archive_Filters['default_type'] : 'grid';
156
-        $elf_type = EE_Registry::instance()->REQ->is_set('elf_type') ? sanitize_text_field(
157
-            EE_Registry::instance()->REQ->get('elf_type')
158
-        ) : '';
159
-        $view = ! empty($elf_type) ? $elf_type : $view;
160
-        $view = apply_filters('EED_Events_Archive_Filters__set_type__type', $view);
161
-        if (! empty($view) && in_array($view, EED_Events_Archive_Filters::$_types)) {
162
-            self::$_type = $view;
163
-        }
164
-    }
165
-
166
-    /**
167
-     *    _show_expired
168
-     *
169
-     * @access    private
170
-     * @param    boolean $req_only if TRUE, then ignore defaults and only return $_POST value
171
-     * @return    boolean
172
-     */
173
-    private static function _show_expired($req_only = false)
174
-    {
175
-        // get default value for "display_expired_events" as set in the EE General Settings > Templates > Event Listings
176
-        $show_expired = ! $req_only && isset(
177
-            EE_Registry::instance()->CFG->EED_Events_Archive_Filters['display_expired_events']
178
-        ) ? EE_Registry::instance()->CFG->EED_Events_Archive_Filters['display_expired_events'] : false;
179
-        // override default expired option if set via filter
180
-        $show_expired = EE_Registry::instance()->REQ->is_set('elf_expired_chk') ? absint(
181
-            EE_Registry::instance()->REQ->get('elf_expired_chk')
182
-        ) : $show_expired;
183
-        return $show_expired ? true : false;
184
-    }
185
-
186
-    /**
187
-     *    _event_category_slug
188
-     *
189
-     * @access    private
190
-     * @return    string
191
-     */
192
-    private static function _event_category_slug()
193
-    {
194
-        return EE_Registry::instance()->REQ->is_set('elf_category_dd') ? sanitize_text_field(
195
-            EE_Registry::instance()->REQ->get('elf_category_dd')
196
-        ) : '';
197
-    }
198
-
199
-    /**
200
-     *    _display_month - what month should the event list display events for?
201
-     *
202
-     * @access    private
203
-     * @return    string
204
-     */
205
-    private static function _display_month()
206
-    {
207
-        return EE_Registry::instance()->REQ->is_set('elf_month_dd') ? sanitize_text_field(
208
-            EE_Registry::instance()->REQ->get('elf_month_dd')
209
-        ) : '';
210
-    }
211
-
212
-
213
-    /**
214
-     *    get_post_data
215
-     *
216
-     * @access    public
217
-     * @return    void
218
-     */
219
-    public function get_post_data()
220
-    {
221
-        $this->_elf_month = EED_Events_Archive_Filters::_display_month();
222
-        $this->_elf_category = EED_Events_Archive_Filters::_event_category_slug();
223
-        $this->_show_expired = EED_Events_Archive_Filters::_show_expired(true);
224
-    }
225
-
226
-
227
-    /**
228
-     *    posts_join
229
-     *
230
-     * @access    public
231
-     * @return    void
232
-     */
233
-    public function posts_join($SQL, WP_Query $wp_query)
234
-    {
235
-        if (isset($wp_query->query) && isset($wp_query->query['post_type']) && $wp_query->query['post_type'] == 'espresso_events') {
236
-            // Category
237
-            $SQL .= EED_Events_Archive_Filters::posts_join_sql_for_terms(
238
-                EED_Events_Archive_Filters::_event_category_slug()
239
-            );
240
-        }
241
-        return $SQL;
242
-    }
243
-
244
-
245
-    /**
246
-     *    posts_join_sql_for_terms
247
-     *
248
-     * @access    public
249
-     * @param    mixed boolean|string    $join_terms pass TRUE or term string, doesn't really matter since this value
250
-     *                                   doesn't really get used for anything yet
251
-     * @return    string
252
-     */
253
-    public static function posts_join_sql_for_terms($join_terms = null)
254
-    {
255
-        $SQL = '';
256
-        if (! empty($join_terms)) {
257
-            global $wpdb;
258
-            $SQL .= " LEFT JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id)";
259
-            $SQL .= " LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)";
260
-            $SQL .= " LEFT JOIN $wpdb->terms ON ($wpdb->terms.term_id = $wpdb->term_taxonomy.term_id) ";
261
-        }
262
-        return $SQL;
263
-    }
264
-
265
-
266
-    /**
267
-     *    posts_join_for_orderby
268
-     *    usage:  $SQL .= EED_Events_Archive_Filters::posts_join_for_orderby( $orderby_params );
269
-     *
270
-     * @access    public
271
-     * @param    array $orderby_params
272
-     * @return    string
273
-     */
274
-    public static function posts_join_for_orderby($orderby_params = array())
275
-    {
276
-        global $wpdb;
277
-        $SQL = '';
278
-        $orderby_params = is_array($orderby_params) ? $orderby_params : array($orderby_params);
279
-        foreach ($orderby_params as $orderby) {
280
-            switch ($orderby) {
281
-                case 'ticket_start':
282
-                case 'ticket_end':
283
-                    $SQL .= ' LEFT JOIN ' . EEM_Datetime_Ticket::instance()->table() . ' ON ('
284
-                            . EEM_Datetime::instance()->table() . '.DTT_ID = '
285
-                            . EEM_Datetime_Ticket::instance()->table() . '.DTT_ID )';
286
-                    $SQL .= ' LEFT JOIN ' . EEM_Ticket::instance()->table() . ' ON ('
287
-                            . EEM_Datetime_Ticket::instance()->table() . '.TKT_ID = '
288
-                            . EEM_Ticket::instance()->table() . '.TKT_ID )';
289
-                    break;
290
-
291
-                case 'venue_title':
292
-                case 'city':
293
-                    $SQL .= ' LEFT JOIN ' . EEM_Event_Venue::instance()->table() . ' ON (' . $wpdb->posts . '.ID = '
294
-                            . EEM_Event_Venue::instance()->table() . '.EVT_ID )';
295
-                    $SQL .= ' LEFT JOIN ' . EEM_Venue::instance()->table() . ' ON ('
296
-                            . EEM_Event_Venue::instance()->table() . '.VNU_ID = '
297
-                            . EEM_Venue::instance()->table() . '.VNU_ID )';
298
-                    break;
299
-
300
-                case 'state':
301
-                    $SQL .= ' LEFT JOIN ' . EEM_Event_Venue::instance()->table() . ' ON (' . $wpdb->posts . '.ID = '
302
-                            . EEM_Event_Venue::instance()->table() . '.EVT_ID )';
303
-                    $SQL .= ' LEFT JOIN ' . EEM_Event_Venue::instance()->second_table() . ' ON ('
304
-                            . EEM_Event_Venue::instance()->table() . '.VNU_ID = '
305
-                            . EEM_Event_Venue::instance()->second_table() . '.VNU_ID )';
306
-                    break;
307
-            }
308
-        }
309
-        return $SQL;
310
-    }
311
-
312
-
313
-    /**
314
-     *    posts_where
315
-     *
316
-     * @access    public
317
-     * @return    void
318
-     */
319
-    public function posts_where($SQL, WP_Query $wp_query)
320
-    {
321
-        if (isset($wp_query->query_vars) && isset($wp_query->query_vars['post_type']) && $wp_query->query_vars['post_type'] == 'espresso_events') {
322
-            // Show Expired ?
323
-            $SQL .= EED_Events_Archive_Filters::posts_where_sql_for_show_expired(
324
-                EED_Events_Archive_Filters::_show_expired()
325
-            );
326
-            // Category
327
-            // $elf_category = EED_Events_Archive_Filters::_event_category_slug();
328
-            $SQL .= EED_Events_Archive_Filters::posts_where_sql_for_event_category_slug(
329
-                EED_Events_Archive_Filters::_event_category_slug()
330
-            );
331
-            // Start Date
332
-            // $elf_month = EED_Events_Archive_Filters::_display_month();
333
-            $SQL .= EED_Events_Archive_Filters::posts_where_sql_for_event_list_month(
334
-                EED_Events_Archive_Filters::_display_month()
335
-            );
336
-        }
337
-        return $SQL;
338
-    }
339
-
340
-
341
-    /**
342
-     *    posts_where_sql_for_show_expired
343
-     *
344
-     * @access    public
345
-     * @param    boolean $show_expired if TRUE, then displayed past events
346
-     * @return    string
347
-     */
348
-    public static function posts_where_sql_for_show_expired($show_expired = false)
349
-    {
350
-        return ! $show_expired
351
-            ? ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_end > "' . date('Y-m-d H:s:i') . '" '
352
-            : '';
353
-    }
354
-
355
-
356
-    /**
357
-     *    posts_where_sql_for_event_category_slug
358
-     *
359
-     * @access    public
360
-     * @param    boolean $event_category_slug
361
-     * @return    string
362
-     */
363
-    public static function posts_where_sql_for_event_category_slug($event_category_slug = null)
364
-    {
365
-        global $wpdb;
366
-        return ! empty($event_category_slug) ? ' AND ' . $wpdb->terms . '.slug = "' . $event_category_slug . '" ' : '';
367
-    }
368
-
369
-    /**
370
-     *    posts_where_sql_for_event_list_month
371
-     *
372
-     * @access    public
373
-     * @param    boolean $month
374
-     * @return    string
375
-     */
376
-    public static function posts_where_sql_for_event_list_month($month = null)
377
-    {
378
-        $SQL = '';
379
-        if (! empty($month)) {
380
-            // event start date is LESS than the end of the month ( so nothing that doesn't start until next month )
381
-            $SQL = ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_start';
382
-            $SQL .= ' <= "' . date('Y-m-t 23:59:59', \EEH_DTT_Helper::first_of_month_timestamp($month)) . '"';
383
-            // event end date is GREATER than the start of the month ( so nothing that ended before this month )
384
-            $SQL .= ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_end';
385
-            $SQL .= ' >= "' . date('Y-m-d 0:0:00', \EEH_DTT_Helper::first_of_month_timestamp($month)) . '" ';
386
-        }
387
-        return $SQL;
388
-    }
389
-
390
-
391
-    /**
392
-     *    posts_orderby
393
-     *
394
-     * @access    public
395
-     * @return    void
396
-     */
397
-    public function posts_orderby($SQL, WP_Query $wp_query)
398
-    {
399
-        if (isset($wp_query->query) && isset($wp_query->query['post_type']) && $wp_query->query['post_type'] == 'espresso_events') {
400
-            $SQL = EED_Events_Archive_Filters::posts_orderby_sql(array('start_date'));
401
-        }
402
-        return $SQL;
403
-    }
404
-
405
-
406
-    /**
407
-     *    posts_orderby_sql
408
-     *
409
-     *    possible parameters:
410
-     *    ID
411
-     *    start_date
412
-     *    end_date
413
-     *    event_name
414
-     *    category_slug
415
-     *    ticket_start
416
-     *    ticket_end
417
-     *    venue_title
418
-     *    city
419
-     *    state
420
-     *
421
-     *    **IMPORTANT**
422
-     *    make sure to also send the $orderby_params array to the posts_join_for_orderby() method
423
-     *    or else some of the table references below will result in MySQL errors
424
-     *
425
-     * @access    public
426
-     * @param    boolean $orderby_params
427
-     * @return    string
428
-     */
429
-    public static function posts_orderby_sql($orderby_params = array(), $sort = 'ASC')
430
-    {
431
-        global $wpdb;
432
-        $SQL = '';
433
-        $cntr = 1;
434
-        $orderby_params = is_array($orderby_params) ? $orderby_params : array($orderby_params);
435
-        foreach ($orderby_params as $orderby) {
436
-            $glue = $cntr == 1 || $cntr == count($orderby_params) ? ' ' : ', ';
437
-            switch ($orderby) {
438
-                case 'id':
439
-                case 'ID':
440
-                    $SQL .= $glue . $wpdb->posts . '.ID ' . $sort;
441
-                    break;
442
-
443
-                case 'start_date':
444
-                    $SQL .= $glue . EEM_Datetime::instance()->table() . '.DTT_EVT_start ' . $sort;
445
-                    break;
446
-
447
-                case 'end_date':
448
-                    $SQL .= $glue . EEM_Datetime::instance()->table() . '.DTT_EVT_end ' . $sort;
449
-                    break;
450
-
451
-                case 'event_name':
452
-                    $SQL .= $glue . $wpdb->posts . '.post_title ' . $sort;
453
-                    break;
454
-
455
-                case 'category_slug':
456
-                    $SQL .= $glue . $wpdb->terms . '.slug ' . $sort;
457
-                    break;
458
-
459
-                case 'ticket_start':
460
-                    $SQL .= $glue . EEM_Ticket::instance()->table() . '.TKT_start_date ' . $sort;
461
-                    break;
462
-
463
-                case 'ticket_end':
464
-                    $SQL .= $glue . EEM_Ticket::instance()->table() . '.TKT_end_date ' . $sort;
465
-                    break;
466
-
467
-                case 'venue_title':
468
-                    $SQL .= $glue . 'venue_title ' . $sort;
469
-                    break;
470
-
471
-                case 'city':
472
-                    $SQL .= $glue . EEM_Venue::instance()->second_table() . '.VNU_city ' . $sort;
473
-                    break;
474
-
475
-                case 'state':
476
-                    $SQL .= $glue . EEM_State::instance()->table() . '.STA_name ' . $sort;
477
-                    break;
478
-            }
479
-            $cntr++;
480
-        }
481
-        // echo '<h4>$SQL : ' . $SQL . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
482
-        return $SQL;
483
-    }
484
-
485
-
486
-    /**
487
-     *    template_redirect
488
-     *
489
-     * @access    public
490
-     * @return    void
491
-     */
492
-    public function template_redirect()
493
-    {
494
-        // add event list filters
495
-        add_action('loop_start', array($this, 'event_list_template_filters'));
496
-        // and pagination
497
-        add_action('loop_start', array($this, 'event_list_pagination'));
498
-        add_action('loop_end', array($this, 'event_list_pagination'));
499
-        // if NOT a custom template
500
-        if (
501
-            EE_Registry::instance()
502
-                       ->load_core('Front_Controller', array(), false, true)
503
-                       ->get_selected_template() != 'archive-espresso_events.php'
504
-        ) {
505
-            // don't know if theme uses the_excerpt
506
-            add_filter('the_excerpt', array($this, 'event_details'), 100);
507
-            add_filter('the_excerpt', array($this, 'event_tickets'), 110);
508
-            add_filter('the_excerpt', array($this, 'event_datetimes'), 120);
509
-            add_filter('the_excerpt', array($this, 'event_venues'), 130);
510
-            // or the_content
511
-            add_filter('the_content', array($this, 'event_details'), 100);
512
-            add_filter('the_content', array($this, 'event_tickets'), 110);
513
-            add_filter('the_content', array($this, 'event_datetimes'), 120);
514
-            add_filter('the_content', array($this, 'event_venues'), 130);
515
-        } else {
516
-            remove_all_filters('excerpt_length');
517
-            add_filter('excerpt_length', array($this, 'excerpt_length'), 10);
518
-            add_filter('excerpt_more', array($this, 'excerpt_more'), 10);
519
-        }
520
-    }
521
-
522
-
523
-    /**
524
-     *    event_list_pagination
525
-     *
526
-     * @access    public
527
-     * @return        void
528
-     */
529
-    public function event_list_pagination()
530
-    {
531
-        echo '<div class="ee-pagination-dv ee-clear-float">' . espresso_event_list_pagination() . '</div>';
532
-    }
533
-
534
-
535
-    /**
536
-     *    event_details
537
-     *
538
-     * @access    public
539
-     * @param        string $content
540
-     * @return        void
541
-     */
542
-    public function event_details($content)
543
-    {
544
-        return EEH_Template::display_template(
545
-            EE_TEMPLATES . EE_Config::get_current_theme() . '/content-espresso_events-details.php',
546
-            array('the_content' => $content),
547
-            true
548
-        );
549
-    }
550
-
551
-
552
-    /**
553
-     *    event_tickets
554
-     *
555
-     * @access    public
556
-     * @param        string $content
557
-     * @return        void
558
-     */
559
-    public function event_tickets($content)
560
-    {
561
-        return $content
562
-               . EEH_Template::display_template(
563
-                   EE_TEMPLATES . EE_Config::get_current_theme() . '/content-espresso_events-tickets.php',
564
-                   array(),
565
-                   true
566
-               );
567
-    }
568
-
569
-    /**
570
-     *    event_datetimes
571
-     *
572
-     * @access    public
573
-     * @param        string $content
574
-     * @return        void
575
-     */
576
-    public function event_datetimes($content)
577
-    {
578
-        return $content
579
-               . EEH_Template::display_template(
580
-                   EE_TEMPLATES . EE_Config::get_current_theme() . '/content-espresso_events-datetimes.php',
581
-                   array(),
582
-                   true
583
-               );
584
-    }
585
-
586
-    /**
587
-     *    event_venues
588
-     *
589
-     * @access    public
590
-     * @param        string $content
591
-     * @return        void
592
-     */
593
-    public function event_venues($content)
594
-    {
595
-        return $content
596
-               . EEH_Template::display_template(
597
-                   EE_TEMPLATES . EE_Config::get_current_theme() . '/content-espresso_events-venues.php',
598
-                   array(),
599
-                   true
600
-               );
601
-    }
602
-
603
-
604
-    /**
605
-     *    _initial_setup
606
-     *
607
-     * @access    public
608
-     * @return    void
609
-     */
610
-    private function _load_assests()
611
-    {
612
-        do_action('AHEE__EED_Events_Archive_Filters__before_load_assests');
613
-        wp_enqueue_style('espresso_default');
614
-        wp_enqueue_style('espresso_custom_css');
615
-        add_filter('FHEE_load_EE_Session', '__return_true');
616
-        add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10);
617
-        if (EE_Registry::instance()->CFG->map_settings->use_google_maps) {
618
-            add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11);
619
-        }
620
-        // add_filter( 'the_excerpt', array( $this, 'the_excerpt' ), 999 );
621
-    }
622
-
623
-
624
-    /**
625
-     *    _get_template
626
-     *
627
-     * @access    private
628
-     * @return    string
629
-     */
630
-    private function _get_template($which = 'part')
631
-    {
632
-        return EE_TEMPLATES . EE_Config::get_current_theme() . '/archive-espresso_events.php';
633
-    }
634
-
635
-
636
-    /**
637
-     *    excerpt_length
638
-     *
639
-     * @access    public
640
-     * @return    void
641
-     */
642
-    public function excerpt_length($length)
643
-    {
644
-
645
-        if (self::$_type == 'grid') {
646
-            return 36;
647
-        }
648
-
649
-        switch (EE_Registry::instance()->CFG->template_settings->EED_Events_Archive_Filters->event_list_grid_size) {
650
-            case 'tiny':
651
-                return 12;
652
-                break;
653
-            case 'small':
654
-                return 24;
655
-                break;
656
-            case 'large':
657
-                return 48;
658
-                break;
659
-            case 'medium':
660
-            default:
661
-                return 36;
662
-        }
663
-    }
664
-
665
-
666
-    /**
667
-     *    excerpt_more
668
-     *
669
-     * @access    public
670
-     * @return    void
671
-     */
672
-    public function excerpt_more($more)
673
-    {
674
-        return '&hellip;';
675
-    }
676
-
677
-
678
-
679
-
680
-    /**
681
-     *    wp_enqueue_scripts
682
-     *
683
-     * @access    public
684
-     * @return    void
685
-     */
686
-    public function wp_enqueue_scripts()
687
-    {
688
-        // get some style
689
-        if (apply_filters('FHEE_enable_default_espresso_css', false)) {
690
-            // first check uploads folder
691
-            if (
692
-                is_readable(
693
-                    get_stylesheet_directory() . EE_Config::get_current_theme() . '/archive-espresso_events.css'
694
-                )
695
-            ) {
696
-                wp_register_style(
697
-                    'archive-espresso_events',
698
-                    get_stylesheet_directory_uri() . EE_Config::get_current_theme(
699
-                    ) . '/archive-espresso_events.css',
700
-                    array('dashicons', 'espresso_default')
701
-                );
702
-            } else {
703
-                wp_register_style(
704
-                    'archive-espresso_events',
705
-                    EE_TEMPLATES_URL . EE_Config::get_current_theme() . '/archive-espresso_events.css',
706
-                    array('dashicons', 'espresso_default')
707
-                );
708
-            }
709
-            if (
710
-                is_readable(
711
-                    get_stylesheet_directory() . EE_Config::get_current_theme() . '/archive-espresso_events.js'
712
-                )
713
-            ) {
714
-                wp_register_script(
715
-                    'archive-espresso_events',
716
-                    get_stylesheet_directory_uri() . EE_Config::get_current_theme() . '/archive-espresso_events.js',
717
-                    array('jquery-masonry'),
718
-                    '1.0',
719
-                    true
720
-                );
721
-            } else {
722
-                wp_register_script(
723
-                    'archive-espresso_events',
724
-                    EVENTS_ARCHIVE_ASSETS_URL . 'archive-espresso_events.js',
725
-                    array('jquery-masonry'),
726
-                    '1.0',
727
-                    true
728
-                );
729
-            }
730
-            wp_enqueue_style('archive-espresso_events');
731
-            wp_enqueue_script('jquery-masonry');
732
-            wp_enqueue_script('archive-espresso_events');
733
-            add_action('wp_footer', array('EED_Events_Archive_Filters', 'localize_grid_event_lists'), 1);
734
-        }
735
-    }
736
-
737
-
738
-    /**
739
-     *    template_settings_form
740
-     *
741
-     * @access    public
742
-     * @static
743
-     * @return    void
744
-     */
745
-    public static function localize_grid_event_lists()
746
-    {
747
-        wp_localize_script(
748
-            'archive-espresso_events',
749
-            'espresso_grid_event_lists',
750
-            EED_Events_Archive_Filters::$espresso_grid_event_lists
751
-        );
752
-    }
753
-
754
-
755
-    /**
756
-     *    template_settings_form
757
-     *
758
-     * @access    public
759
-     * @static
760
-     * @return    void
761
-     */
762
-    public static function template_settings_form()
763
-    {
764
-        $EE = EE_Registry::instance();
765
-        $EE->CFG->template_settings->EED_Events_Archive_Filters = isset($EE->CFG->template_settings->EED_Events_Archive_Filters)
766
-            ? $EE->CFG->template_settings->EED_Events_Archive_Filters : new EE_Events_Archive_Config();
767
-        $EE->CFG->template_settings->EED_Events_Archive_Filters = apply_filters(
768
-            'FHEE__Event_List__template_settings_form__event_list_config',
769
-            $EE->CFG->template_settings->EED_Events_Archive_Filters
770
-        );
771
-        EEH_Template::display_template(
772
-            EVENTS_ARCHIVE_TEMPLATES_PATH . 'admin-event-list-settings.template.php',
773
-            $EE->CFG->template_settings->EED_Events_Archive_Filters
774
-        );
775
-    }
776
-
777
-
778
-    /**
779
-     *    set_default_settings
780
-     *
781
-     * @access    public
782
-     * @static
783
-     * @return    void
784
-     */
785
-    public static function set_default_settings($CFG)
786
-    {
787
-        // EEH_Debug_Tools::printr( $CFG, '$CFG  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
788
-        $CFG->display_description = isset($CFG->display_description) && ! empty($CFG->display_description)
789
-            ? $CFG->display_description : 1;
790
-        $CFG->display_address = isset($CFG->display_address) && ! empty($CFG->display_address) ? $CFG->display_address
791
-            : true;
792
-        $CFG->display_venue_details = isset($CFG->display_venue_details) && ! empty($CFG->display_venue_details)
793
-            ? $CFG->display_venue_details : true;
794
-        $CFG->display_expired_events = isset($CFG->display_expired_events) && ! empty($CFG->display_expired_events)
795
-            ? $CFG->display_expired_events : false;
796
-        $CFG->default_type = isset($CFG->default_type) && ! empty($CFG->default_type) ? $CFG->default_type : 'grid';
797
-        $CFG->event_list_grid_size = isset($CFG->event_list_grid_size) && ! empty($CFG->event_list_grid_size)
798
-            ? $CFG->event_list_grid_size : 'medium';
799
-        $CFG->templates['full'] = isset($CFG->templates['full']) && ! empty($CFG->templates['full'])
800
-            ? $CFG->templates['full']
801
-            : EE_TEMPLATES . EE_Config::get_current_theme() . '/archive-espresso_events.php';
802
-        $CFG->templates['part'] = isset($CFG->templates['part']) && ! empty($CFG->templates['part'])
803
-            ? $CFG->templates['part']
804
-            : EE_TEMPLATES . EE_Config::get_current_theme() . '/archive-espresso_events-grid-view.php';
805
-        return $CFG;
806
-    }
807
-
808
-
809
-    /**
810
-     *    filter_config
811
-     *
812
-     * @access    public
813
-     * @return    void
814
-     */
815
-    public function filter_config($CFG)
816
-    {
817
-        return $CFG;
818
-    }
819
-
820
-
821
-    /**
822
-     *    filter_config
823
-     *
824
-     * @access    public
825
-     * @return    void
826
-     */
827
-    public static function update_template_settings($CFG, $REQ)
828
-    {
829
-        // $CFG->template_settings->EED_Events_Archive_Filters = new stdClass();
830
-        $CFG->EED_Events_Archive_Filters->display_description = isset($REQ['display_description_in_event_list'])
831
-            ? absint($REQ['display_description_in_event_list']) : 1;
832
-        $CFG->EED_Events_Archive_Filters->display_address = isset($REQ['display_address_in_event_list']) ? absint(
833
-            $REQ['display_address_in_event_list']
834
-        ) : true;
835
-        $CFG->EED_Events_Archive_Filters->display_venue_details = isset($REQ['display_venue_details_in_event_list'])
836
-            ? absint($REQ['display_venue_details_in_event_list']) : true;
837
-        $CFG->EED_Events_Archive_Filters->display_expired_events = isset($REQ['display_expired_events']) ? absint(
838
-            $REQ['display_expired_events']
839
-        ) : false;
840
-        $CFG->EED_Events_Archive_Filters->default_type = isset($REQ['default_type']) ? sanitize_text_field(
841
-            $REQ['default_type']
842
-        ) : 'grid';
843
-        $CFG->EED_Events_Archive_Filters->event_list_grid_size = isset($REQ['event_list_grid_size'])
844
-            ? sanitize_text_field($REQ['event_list_grid_size']) : 'medium';
845
-        $CFG->EED_Events_Archive_Filters->templates = array(
846
-            'full' => EE_TEMPLATES . EE_Config::get_current_theme() . '/archive-espresso_events.php',
847
-        );
848
-
849
-        switch ($CFG->EED_Events_Archive_Filters->default_type) {
850
-            case 'dates':
851
-                $CFG->EED_Events_Archive_Filters->templates['part'] = EE_TEMPLATES . EE_Config::get_current_theme()
852
-                                                                      . '/archive-espresso_events-dates-view.php';
853
-                break;
854
-            case 'text':
855
-                $CFG->EED_Events_Archive_Filters->templates['part'] = EE_TEMPLATES . EE_Config::get_current_theme()
856
-                                                                      . '/archive-espresso_events-text-view.php';
857
-                break;
858
-            default:
859
-                $CFG->EED_Events_Archive_Filters->templates['part'] = EE_TEMPLATES . EE_Config::get_current_theme()
860
-                                                                      . '/archive-espresso_events-grid-view.php';
861
-        }
862
-
863
-        $CFG->EED_Events_Archive_Filters = isset($REQ['reset_event_list_settings'])
864
-                                           && absint($REQ['reset_event_list_settings']) == 1
865
-            ? new EE_Events_Archive_Config()
866
-            : $CFG->EED_Events_Archive_Filters;
867
-        return $CFG;
868
-    }
869
-
870
-
871
-    /**
872
-     *    get_template_part
873
-     *
874
-     * @access    public
875
-     * @return    void
876
-     */
877
-    public static function get_template_part()
878
-    {
879
-        switch (self::$_type) {
880
-            case 'dates':
881
-                return 'archive-espresso_events-dates-view.php';
882
-                break;
883
-            case 'text':
884
-                return 'archive-espresso_events-text-view.php';
885
-                break;
886
-            default:
887
-                return 'archive-espresso_events-grid-view.php';
888
-        }
889
-    }
890
-
891
-
892
-    /**
893
-     *    event_list_template_filters
894
-     *
895
-     * @access    public
896
-     * @return    void
897
-     */
898
-    public function event_list_template_filters()
899
-    {
900
-        $args = array(
901
-            'form_url'         => get_post_type_archive_link('espresso_events'),
902
-            // add_query_arg( array( 'post_type' => 'espresso_events' ), home_url() ),
903
-            'elf_month'        => EED_Events_Archive_Filters::_display_month(),
904
-            'elf_category'     => EED_Events_Archive_Filters::_event_category_slug(),
905
-            'elf_show_expired' => EED_Events_Archive_Filters::_show_expired(),
906
-            'elf_type'         => self::$_type,
907
-        );
908
-        EEH_Template::display_template(
909
-            EE_TEMPLATES . EE_Config::get_current_theme() . '/archive-espresso_events-filters.php',
910
-            $args
911
-        );
912
-    }
913
-
914
-
915
-    /**
916
-     *    event_list_css
917
-     *
918
-     * @access    public
919
-     * @return    void
920
-     */
921
-    public static function event_list_css($extra_class = '')
922
-    {
923
-        $EE = EE_Registry::instance();
924
-        $event_list_css = ! empty($extra_class) ? array($extra_class) : array();
925
-        $event_list_css[] = 'espresso-event-list-event';
926
-        if (self::$_type == 'grid') {
927
-            $event_list_grid_size = isset($EE->CFG->template_settings->EED_Events_Archive_Filters->event_list_grid_size)
928
-                ? $EE->CFG->template_settings->EED_Events_Archive_Filters->event_list_grid_size : 'medium';
929
-            $event_list_css[] = $event_list_grid_size . '-event-list-grid';
930
-        }
931
-        $event_list_css = apply_filters(
932
-            'EED_Events_Archive_Filters__event_list_css__event_list_css_array',
933
-            $event_list_css
934
-        );
935
-        return implode(' ', $event_list_css);
936
-    }
937
-
938
-
939
-    /**
940
-     *    event_categories
941
-     *
942
-     * @access    public
943
-     * @return    void
944
-     */
945
-    public static function event_categories()
946
-    {
947
-        return EE_Registry::instance()->load_model('Term')->get_all_ee_categories();
948
-    }
949
-
950
-
951
-    /**
952
-     *    display_description
953
-     *
954
-     * @access    public
955
-     * @return    void
956
-     */
957
-    public static function display_description($value)
958
-    {
959
-        $EE = EE_Registry::instance();
960
-        $display_description = isset($EE->CFG->template_settings->EED_Events_Archive_Filters->display_description)
961
-            ? $EE->CFG->template_settings->EED_Events_Archive_Filters->display_description : 1;
962
-        return $display_description === $value ? true : false;
963
-    }
964
-
965
-
966
-    /**
967
-     *    display_venue_details
968
-     *
969
-     * @access    public
970
-     * @return    void
971
-     */
972
-    public static function display_venue_details()
973
-    {
974
-        $EE = EE_Registry::instance();
975
-        $display_venue_details = isset($EE->CFG->template_settings->EED_Events_Archive_Filters->display_venue_details)
976
-            ? $EE->CFG->template_settings->EED_Events_Archive_Filters->display_venue_details : true;
977
-        $venue_name = EEH_Venue_View::venue_name();
978
-        return $display_venue_details && ! empty($venue_name) ? true : false;
979
-    }
980
-
981
-
982
-    /**
983
-     *    display_address
984
-     *
985
-     * @access    public
986
-     * @return    void
987
-     */
988
-    public static function display_address()
989
-    {
990
-        $EE = EE_Registry::instance();
991
-        $display_address = isset($EE->CFG->template_settings->EED_Events_Archive_Filters->display_address)
992
-            ? $EE->CFG->template_settings->EED_Events_Archive_Filters->display_address : false;
993
-        $venue_name = EEH_Venue_View::venue_name();
994
-        return $display_address && ! empty($venue_name) ? true : false;
995
-    }
996
-
997
-
998
-    /**
999
-     *    pagination
1000
-     *
1001
-     * @access    public
1002
-     * @return    void
1003
-     */
1004
-    public static function pagination()
1005
-    {
1006
-        global $wp_query;
1007
-        $big = 999999999; // need an unlikely integer
1008
-        $pagination = paginate_links(
1009
-            array(
1010
-                'base'         => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
1011
-                'format'       => '?paged=%#%',
1012
-                'current'      => max(1, get_query_var('paged')),
1013
-                'total'        => $wp_query->max_num_pages,
1014
-                'show_all'     => true,
1015
-                'end_size'     => 10,
1016
-                'mid_size'     => 6,
1017
-                'prev_next'    => true,
1018
-                'prev_text'    => __('&lsaquo; PREV', 'event_espresso'),
1019
-                'next_text'    => __('NEXT &rsaquo;', 'event_espresso'),
1020
-                'type'         => 'plain',
1021
-                'add_args'     => false,
1022
-                'add_fragment' => '',
1023
-            )
1024
-        );
1025
-        return ! empty($pagination) ? '<div class="ee-pagination-dv clear">' . $pagination . '</div>' : '';
1026
-    }
1027
-
1028
-
1029
-    /**
1030
-     *    event_list_title
1031
-     *
1032
-     * @access    public
1033
-     * @return    void
1034
-     */
1035
-    public static function event_list_title()
1036
-    {
1037
-        return apply_filters(
1038
-            'EED_Events_Archive_Filters__event_list_title__event_list_title',
1039
-            __('Upcoming Events', 'event_espresso')
1040
-        );
1041
-    }
16
+	/**
17
+	 * @return EED_Events_Archive_Filters
18
+	 */
19
+	public static function instance()
20
+	{
21
+		return parent::get_instance(__CLASS__);
22
+	}
23
+
24
+
25
+	/**
26
+	 *    Start Date
27
+	 *
28
+	 * @var    $_elf_month
29
+	 * @access    protected
30
+	 */
31
+	protected $_elf_month = null;
32
+
33
+
34
+	/**
35
+	 *    Category
36
+	 *
37
+	 * @var    $_elf_category
38
+	 * @access    protected
39
+	 */
40
+	protected $_elf_category = null;
41
+
42
+
43
+	/**
44
+	 *    whether to display expired events in the event list
45
+	 *
46
+	 * @var    $_show_expired
47
+	 * @access    protected
48
+	 */
49
+	protected $_show_expired = null;
50
+
51
+
52
+	/**
53
+	 *    whether to display the event list as a grid or list
54
+	 *
55
+	 * @var    $_type
56
+	 * @access    protected
57
+	 */
58
+	protected static $_type = null;
59
+
60
+
61
+	/**
62
+	 *    array of existing event list views
63
+	 *
64
+	 * @var    $_types
65
+	 * @access    protected
66
+	 */
67
+	protected static $_types = array('grid', 'text', 'dates');
68
+
69
+
70
+
71
+	/**
72
+	 *    set_hooks - for hooking into EE Core, other modules, etc
73
+	 *
74
+	 * @access    public
75
+	 * @return    void
76
+	 */
77
+	public static function set_hooks()
78
+	{
79
+	}
80
+
81
+	/**
82
+	 *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
83
+	 *
84
+	 * @access    public
85
+	 * @return    void
86
+	 */
87
+	public static function set_hooks_admin()
88
+	{
89
+	}
90
+
91
+
92
+	/**
93
+	 *    set_definitions
94
+	 *
95
+	 * @access    public
96
+	 * @return    void
97
+	 */
98
+	public static function set_definitions()
99
+	{
100
+	}
101
+
102
+
103
+	/**
104
+	 *    run - initial module setup
105
+	 *
106
+	 * @access    public
107
+	 * @return    void
108
+	 */
109
+	public function run($WP)
110
+	{
111
+	}
112
+
113
+
114
+	/**
115
+	 *    event_list
116
+	 *
117
+	 * @access    public
118
+	 * @return    void
119
+	 */
120
+	public function event_list()
121
+	{
122
+		// load other required components
123
+		$this->_load_assests();
124
+	}
125
+
126
+
127
+	/**
128
+	 *    _filter_query_parts
129
+	 *
130
+	 * @access    public
131
+	 * @return    void
132
+	 */
133
+	private function _filter_query_parts()
134
+	{
135
+		// build event list query
136
+		add_filter('posts_join', array($this, 'posts_join'), 1, 2);
137
+		add_filter('posts_where', array($this, 'posts_where'), 1, 2);
138
+		add_filter('posts_orderby', array($this, 'posts_orderby'), 1, 2);
139
+	}
140
+
141
+	/**
142
+	 *    _type - the type of event list : grid, text, dates
143
+	 *
144
+	 * @access    public
145
+	 * @return    string
146
+	 */
147
+	public static function set_type()
148
+	{
149
+		do_action('AHEE__EED_Events_Archive_Filters__before_set_type');
150
+		EED_Events_Archive_Filters::$_types = apply_filters(
151
+			'EED_Events_Archive_Filters__set_type__types',
152
+			EED_Events_Archive_Filters::$_types
153
+		);
154
+		$view = isset(EE_Registry::instance()->CFG->EED_Events_Archive_Filters['default_type']) ? EE_Registry::instance(
155
+		)->CFG->EED_Events_Archive_Filters['default_type'] : 'grid';
156
+		$elf_type = EE_Registry::instance()->REQ->is_set('elf_type') ? sanitize_text_field(
157
+			EE_Registry::instance()->REQ->get('elf_type')
158
+		) : '';
159
+		$view = ! empty($elf_type) ? $elf_type : $view;
160
+		$view = apply_filters('EED_Events_Archive_Filters__set_type__type', $view);
161
+		if (! empty($view) && in_array($view, EED_Events_Archive_Filters::$_types)) {
162
+			self::$_type = $view;
163
+		}
164
+	}
165
+
166
+	/**
167
+	 *    _show_expired
168
+	 *
169
+	 * @access    private
170
+	 * @param    boolean $req_only if TRUE, then ignore defaults and only return $_POST value
171
+	 * @return    boolean
172
+	 */
173
+	private static function _show_expired($req_only = false)
174
+	{
175
+		// get default value for "display_expired_events" as set in the EE General Settings > Templates > Event Listings
176
+		$show_expired = ! $req_only && isset(
177
+			EE_Registry::instance()->CFG->EED_Events_Archive_Filters['display_expired_events']
178
+		) ? EE_Registry::instance()->CFG->EED_Events_Archive_Filters['display_expired_events'] : false;
179
+		// override default expired option if set via filter
180
+		$show_expired = EE_Registry::instance()->REQ->is_set('elf_expired_chk') ? absint(
181
+			EE_Registry::instance()->REQ->get('elf_expired_chk')
182
+		) : $show_expired;
183
+		return $show_expired ? true : false;
184
+	}
185
+
186
+	/**
187
+	 *    _event_category_slug
188
+	 *
189
+	 * @access    private
190
+	 * @return    string
191
+	 */
192
+	private static function _event_category_slug()
193
+	{
194
+		return EE_Registry::instance()->REQ->is_set('elf_category_dd') ? sanitize_text_field(
195
+			EE_Registry::instance()->REQ->get('elf_category_dd')
196
+		) : '';
197
+	}
198
+
199
+	/**
200
+	 *    _display_month - what month should the event list display events for?
201
+	 *
202
+	 * @access    private
203
+	 * @return    string
204
+	 */
205
+	private static function _display_month()
206
+	{
207
+		return EE_Registry::instance()->REQ->is_set('elf_month_dd') ? sanitize_text_field(
208
+			EE_Registry::instance()->REQ->get('elf_month_dd')
209
+		) : '';
210
+	}
211
+
212
+
213
+	/**
214
+	 *    get_post_data
215
+	 *
216
+	 * @access    public
217
+	 * @return    void
218
+	 */
219
+	public function get_post_data()
220
+	{
221
+		$this->_elf_month = EED_Events_Archive_Filters::_display_month();
222
+		$this->_elf_category = EED_Events_Archive_Filters::_event_category_slug();
223
+		$this->_show_expired = EED_Events_Archive_Filters::_show_expired(true);
224
+	}
225
+
226
+
227
+	/**
228
+	 *    posts_join
229
+	 *
230
+	 * @access    public
231
+	 * @return    void
232
+	 */
233
+	public function posts_join($SQL, WP_Query $wp_query)
234
+	{
235
+		if (isset($wp_query->query) && isset($wp_query->query['post_type']) && $wp_query->query['post_type'] == 'espresso_events') {
236
+			// Category
237
+			$SQL .= EED_Events_Archive_Filters::posts_join_sql_for_terms(
238
+				EED_Events_Archive_Filters::_event_category_slug()
239
+			);
240
+		}
241
+		return $SQL;
242
+	}
243
+
244
+
245
+	/**
246
+	 *    posts_join_sql_for_terms
247
+	 *
248
+	 * @access    public
249
+	 * @param    mixed boolean|string    $join_terms pass TRUE or term string, doesn't really matter since this value
250
+	 *                                   doesn't really get used for anything yet
251
+	 * @return    string
252
+	 */
253
+	public static function posts_join_sql_for_terms($join_terms = null)
254
+	{
255
+		$SQL = '';
256
+		if (! empty($join_terms)) {
257
+			global $wpdb;
258
+			$SQL .= " LEFT JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id)";
259
+			$SQL .= " LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)";
260
+			$SQL .= " LEFT JOIN $wpdb->terms ON ($wpdb->terms.term_id = $wpdb->term_taxonomy.term_id) ";
261
+		}
262
+		return $SQL;
263
+	}
264
+
265
+
266
+	/**
267
+	 *    posts_join_for_orderby
268
+	 *    usage:  $SQL .= EED_Events_Archive_Filters::posts_join_for_orderby( $orderby_params );
269
+	 *
270
+	 * @access    public
271
+	 * @param    array $orderby_params
272
+	 * @return    string
273
+	 */
274
+	public static function posts_join_for_orderby($orderby_params = array())
275
+	{
276
+		global $wpdb;
277
+		$SQL = '';
278
+		$orderby_params = is_array($orderby_params) ? $orderby_params : array($orderby_params);
279
+		foreach ($orderby_params as $orderby) {
280
+			switch ($orderby) {
281
+				case 'ticket_start':
282
+				case 'ticket_end':
283
+					$SQL .= ' LEFT JOIN ' . EEM_Datetime_Ticket::instance()->table() . ' ON ('
284
+							. EEM_Datetime::instance()->table() . '.DTT_ID = '
285
+							. EEM_Datetime_Ticket::instance()->table() . '.DTT_ID )';
286
+					$SQL .= ' LEFT JOIN ' . EEM_Ticket::instance()->table() . ' ON ('
287
+							. EEM_Datetime_Ticket::instance()->table() . '.TKT_ID = '
288
+							. EEM_Ticket::instance()->table() . '.TKT_ID )';
289
+					break;
290
+
291
+				case 'venue_title':
292
+				case 'city':
293
+					$SQL .= ' LEFT JOIN ' . EEM_Event_Venue::instance()->table() . ' ON (' . $wpdb->posts . '.ID = '
294
+							. EEM_Event_Venue::instance()->table() . '.EVT_ID )';
295
+					$SQL .= ' LEFT JOIN ' . EEM_Venue::instance()->table() . ' ON ('
296
+							. EEM_Event_Venue::instance()->table() . '.VNU_ID = '
297
+							. EEM_Venue::instance()->table() . '.VNU_ID )';
298
+					break;
299
+
300
+				case 'state':
301
+					$SQL .= ' LEFT JOIN ' . EEM_Event_Venue::instance()->table() . ' ON (' . $wpdb->posts . '.ID = '
302
+							. EEM_Event_Venue::instance()->table() . '.EVT_ID )';
303
+					$SQL .= ' LEFT JOIN ' . EEM_Event_Venue::instance()->second_table() . ' ON ('
304
+							. EEM_Event_Venue::instance()->table() . '.VNU_ID = '
305
+							. EEM_Event_Venue::instance()->second_table() . '.VNU_ID )';
306
+					break;
307
+			}
308
+		}
309
+		return $SQL;
310
+	}
311
+
312
+
313
+	/**
314
+	 *    posts_where
315
+	 *
316
+	 * @access    public
317
+	 * @return    void
318
+	 */
319
+	public function posts_where($SQL, WP_Query $wp_query)
320
+	{
321
+		if (isset($wp_query->query_vars) && isset($wp_query->query_vars['post_type']) && $wp_query->query_vars['post_type'] == 'espresso_events') {
322
+			// Show Expired ?
323
+			$SQL .= EED_Events_Archive_Filters::posts_where_sql_for_show_expired(
324
+				EED_Events_Archive_Filters::_show_expired()
325
+			);
326
+			// Category
327
+			// $elf_category = EED_Events_Archive_Filters::_event_category_slug();
328
+			$SQL .= EED_Events_Archive_Filters::posts_where_sql_for_event_category_slug(
329
+				EED_Events_Archive_Filters::_event_category_slug()
330
+			);
331
+			// Start Date
332
+			// $elf_month = EED_Events_Archive_Filters::_display_month();
333
+			$SQL .= EED_Events_Archive_Filters::posts_where_sql_for_event_list_month(
334
+				EED_Events_Archive_Filters::_display_month()
335
+			);
336
+		}
337
+		return $SQL;
338
+	}
339
+
340
+
341
+	/**
342
+	 *    posts_where_sql_for_show_expired
343
+	 *
344
+	 * @access    public
345
+	 * @param    boolean $show_expired if TRUE, then displayed past events
346
+	 * @return    string
347
+	 */
348
+	public static function posts_where_sql_for_show_expired($show_expired = false)
349
+	{
350
+		return ! $show_expired
351
+			? ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_end > "' . date('Y-m-d H:s:i') . '" '
352
+			: '';
353
+	}
354
+
355
+
356
+	/**
357
+	 *    posts_where_sql_for_event_category_slug
358
+	 *
359
+	 * @access    public
360
+	 * @param    boolean $event_category_slug
361
+	 * @return    string
362
+	 */
363
+	public static function posts_where_sql_for_event_category_slug($event_category_slug = null)
364
+	{
365
+		global $wpdb;
366
+		return ! empty($event_category_slug) ? ' AND ' . $wpdb->terms . '.slug = "' . $event_category_slug . '" ' : '';
367
+	}
368
+
369
+	/**
370
+	 *    posts_where_sql_for_event_list_month
371
+	 *
372
+	 * @access    public
373
+	 * @param    boolean $month
374
+	 * @return    string
375
+	 */
376
+	public static function posts_where_sql_for_event_list_month($month = null)
377
+	{
378
+		$SQL = '';
379
+		if (! empty($month)) {
380
+			// event start date is LESS than the end of the month ( so nothing that doesn't start until next month )
381
+			$SQL = ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_start';
382
+			$SQL .= ' <= "' . date('Y-m-t 23:59:59', \EEH_DTT_Helper::first_of_month_timestamp($month)) . '"';
383
+			// event end date is GREATER than the start of the month ( so nothing that ended before this month )
384
+			$SQL .= ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_end';
385
+			$SQL .= ' >= "' . date('Y-m-d 0:0:00', \EEH_DTT_Helper::first_of_month_timestamp($month)) . '" ';
386
+		}
387
+		return $SQL;
388
+	}
389
+
390
+
391
+	/**
392
+	 *    posts_orderby
393
+	 *
394
+	 * @access    public
395
+	 * @return    void
396
+	 */
397
+	public function posts_orderby($SQL, WP_Query $wp_query)
398
+	{
399
+		if (isset($wp_query->query) && isset($wp_query->query['post_type']) && $wp_query->query['post_type'] == 'espresso_events') {
400
+			$SQL = EED_Events_Archive_Filters::posts_orderby_sql(array('start_date'));
401
+		}
402
+		return $SQL;
403
+	}
404
+
405
+
406
+	/**
407
+	 *    posts_orderby_sql
408
+	 *
409
+	 *    possible parameters:
410
+	 *    ID
411
+	 *    start_date
412
+	 *    end_date
413
+	 *    event_name
414
+	 *    category_slug
415
+	 *    ticket_start
416
+	 *    ticket_end
417
+	 *    venue_title
418
+	 *    city
419
+	 *    state
420
+	 *
421
+	 *    **IMPORTANT**
422
+	 *    make sure to also send the $orderby_params array to the posts_join_for_orderby() method
423
+	 *    or else some of the table references below will result in MySQL errors
424
+	 *
425
+	 * @access    public
426
+	 * @param    boolean $orderby_params
427
+	 * @return    string
428
+	 */
429
+	public static function posts_orderby_sql($orderby_params = array(), $sort = 'ASC')
430
+	{
431
+		global $wpdb;
432
+		$SQL = '';
433
+		$cntr = 1;
434
+		$orderby_params = is_array($orderby_params) ? $orderby_params : array($orderby_params);
435
+		foreach ($orderby_params as $orderby) {
436
+			$glue = $cntr == 1 || $cntr == count($orderby_params) ? ' ' : ', ';
437
+			switch ($orderby) {
438
+				case 'id':
439
+				case 'ID':
440
+					$SQL .= $glue . $wpdb->posts . '.ID ' . $sort;
441
+					break;
442
+
443
+				case 'start_date':
444
+					$SQL .= $glue . EEM_Datetime::instance()->table() . '.DTT_EVT_start ' . $sort;
445
+					break;
446
+
447
+				case 'end_date':
448
+					$SQL .= $glue . EEM_Datetime::instance()->table() . '.DTT_EVT_end ' . $sort;
449
+					break;
450
+
451
+				case 'event_name':
452
+					$SQL .= $glue . $wpdb->posts . '.post_title ' . $sort;
453
+					break;
454
+
455
+				case 'category_slug':
456
+					$SQL .= $glue . $wpdb->terms . '.slug ' . $sort;
457
+					break;
458
+
459
+				case 'ticket_start':
460
+					$SQL .= $glue . EEM_Ticket::instance()->table() . '.TKT_start_date ' . $sort;
461
+					break;
462
+
463
+				case 'ticket_end':
464
+					$SQL .= $glue . EEM_Ticket::instance()->table() . '.TKT_end_date ' . $sort;
465
+					break;
466
+
467
+				case 'venue_title':
468
+					$SQL .= $glue . 'venue_title ' . $sort;
469
+					break;
470
+
471
+				case 'city':
472
+					$SQL .= $glue . EEM_Venue::instance()->second_table() . '.VNU_city ' . $sort;
473
+					break;
474
+
475
+				case 'state':
476
+					$SQL .= $glue . EEM_State::instance()->table() . '.STA_name ' . $sort;
477
+					break;
478
+			}
479
+			$cntr++;
480
+		}
481
+		// echo '<h4>$SQL : ' . $SQL . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
482
+		return $SQL;
483
+	}
484
+
485
+
486
+	/**
487
+	 *    template_redirect
488
+	 *
489
+	 * @access    public
490
+	 * @return    void
491
+	 */
492
+	public function template_redirect()
493
+	{
494
+		// add event list filters
495
+		add_action('loop_start', array($this, 'event_list_template_filters'));
496
+		// and pagination
497
+		add_action('loop_start', array($this, 'event_list_pagination'));
498
+		add_action('loop_end', array($this, 'event_list_pagination'));
499
+		// if NOT a custom template
500
+		if (
501
+			EE_Registry::instance()
502
+					   ->load_core('Front_Controller', array(), false, true)
503
+					   ->get_selected_template() != 'archive-espresso_events.php'
504
+		) {
505
+			// don't know if theme uses the_excerpt
506
+			add_filter('the_excerpt', array($this, 'event_details'), 100);
507
+			add_filter('the_excerpt', array($this, 'event_tickets'), 110);
508
+			add_filter('the_excerpt', array($this, 'event_datetimes'), 120);
509
+			add_filter('the_excerpt', array($this, 'event_venues'), 130);
510
+			// or the_content
511
+			add_filter('the_content', array($this, 'event_details'), 100);
512
+			add_filter('the_content', array($this, 'event_tickets'), 110);
513
+			add_filter('the_content', array($this, 'event_datetimes'), 120);
514
+			add_filter('the_content', array($this, 'event_venues'), 130);
515
+		} else {
516
+			remove_all_filters('excerpt_length');
517
+			add_filter('excerpt_length', array($this, 'excerpt_length'), 10);
518
+			add_filter('excerpt_more', array($this, 'excerpt_more'), 10);
519
+		}
520
+	}
521
+
522
+
523
+	/**
524
+	 *    event_list_pagination
525
+	 *
526
+	 * @access    public
527
+	 * @return        void
528
+	 */
529
+	public function event_list_pagination()
530
+	{
531
+		echo '<div class="ee-pagination-dv ee-clear-float">' . espresso_event_list_pagination() . '</div>';
532
+	}
533
+
534
+
535
+	/**
536
+	 *    event_details
537
+	 *
538
+	 * @access    public
539
+	 * @param        string $content
540
+	 * @return        void
541
+	 */
542
+	public function event_details($content)
543
+	{
544
+		return EEH_Template::display_template(
545
+			EE_TEMPLATES . EE_Config::get_current_theme() . '/content-espresso_events-details.php',
546
+			array('the_content' => $content),
547
+			true
548
+		);
549
+	}
550
+
551
+
552
+	/**
553
+	 *    event_tickets
554
+	 *
555
+	 * @access    public
556
+	 * @param        string $content
557
+	 * @return        void
558
+	 */
559
+	public function event_tickets($content)
560
+	{
561
+		return $content
562
+			   . EEH_Template::display_template(
563
+				   EE_TEMPLATES . EE_Config::get_current_theme() . '/content-espresso_events-tickets.php',
564
+				   array(),
565
+				   true
566
+			   );
567
+	}
568
+
569
+	/**
570
+	 *    event_datetimes
571
+	 *
572
+	 * @access    public
573
+	 * @param        string $content
574
+	 * @return        void
575
+	 */
576
+	public function event_datetimes($content)
577
+	{
578
+		return $content
579
+			   . EEH_Template::display_template(
580
+				   EE_TEMPLATES . EE_Config::get_current_theme() . '/content-espresso_events-datetimes.php',
581
+				   array(),
582
+				   true
583
+			   );
584
+	}
585
+
586
+	/**
587
+	 *    event_venues
588
+	 *
589
+	 * @access    public
590
+	 * @param        string $content
591
+	 * @return        void
592
+	 */
593
+	public function event_venues($content)
594
+	{
595
+		return $content
596
+			   . EEH_Template::display_template(
597
+				   EE_TEMPLATES . EE_Config::get_current_theme() . '/content-espresso_events-venues.php',
598
+				   array(),
599
+				   true
600
+			   );
601
+	}
602
+
603
+
604
+	/**
605
+	 *    _initial_setup
606
+	 *
607
+	 * @access    public
608
+	 * @return    void
609
+	 */
610
+	private function _load_assests()
611
+	{
612
+		do_action('AHEE__EED_Events_Archive_Filters__before_load_assests');
613
+		wp_enqueue_style('espresso_default');
614
+		wp_enqueue_style('espresso_custom_css');
615
+		add_filter('FHEE_load_EE_Session', '__return_true');
616
+		add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10);
617
+		if (EE_Registry::instance()->CFG->map_settings->use_google_maps) {
618
+			add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11);
619
+		}
620
+		// add_filter( 'the_excerpt', array( $this, 'the_excerpt' ), 999 );
621
+	}
622
+
623
+
624
+	/**
625
+	 *    _get_template
626
+	 *
627
+	 * @access    private
628
+	 * @return    string
629
+	 */
630
+	private function _get_template($which = 'part')
631
+	{
632
+		return EE_TEMPLATES . EE_Config::get_current_theme() . '/archive-espresso_events.php';
633
+	}
634
+
635
+
636
+	/**
637
+	 *    excerpt_length
638
+	 *
639
+	 * @access    public
640
+	 * @return    void
641
+	 */
642
+	public function excerpt_length($length)
643
+	{
644
+
645
+		if (self::$_type == 'grid') {
646
+			return 36;
647
+		}
648
+
649
+		switch (EE_Registry::instance()->CFG->template_settings->EED_Events_Archive_Filters->event_list_grid_size) {
650
+			case 'tiny':
651
+				return 12;
652
+				break;
653
+			case 'small':
654
+				return 24;
655
+				break;
656
+			case 'large':
657
+				return 48;
658
+				break;
659
+			case 'medium':
660
+			default:
661
+				return 36;
662
+		}
663
+	}
664
+
665
+
666
+	/**
667
+	 *    excerpt_more
668
+	 *
669
+	 * @access    public
670
+	 * @return    void
671
+	 */
672
+	public function excerpt_more($more)
673
+	{
674
+		return '&hellip;';
675
+	}
676
+
677
+
678
+
679
+
680
+	/**
681
+	 *    wp_enqueue_scripts
682
+	 *
683
+	 * @access    public
684
+	 * @return    void
685
+	 */
686
+	public function wp_enqueue_scripts()
687
+	{
688
+		// get some style
689
+		if (apply_filters('FHEE_enable_default_espresso_css', false)) {
690
+			// first check uploads folder
691
+			if (
692
+				is_readable(
693
+					get_stylesheet_directory() . EE_Config::get_current_theme() . '/archive-espresso_events.css'
694
+				)
695
+			) {
696
+				wp_register_style(
697
+					'archive-espresso_events',
698
+					get_stylesheet_directory_uri() . EE_Config::get_current_theme(
699
+					) . '/archive-espresso_events.css',
700
+					array('dashicons', 'espresso_default')
701
+				);
702
+			} else {
703
+				wp_register_style(
704
+					'archive-espresso_events',
705
+					EE_TEMPLATES_URL . EE_Config::get_current_theme() . '/archive-espresso_events.css',
706
+					array('dashicons', 'espresso_default')
707
+				);
708
+			}
709
+			if (
710
+				is_readable(
711
+					get_stylesheet_directory() . EE_Config::get_current_theme() . '/archive-espresso_events.js'
712
+				)
713
+			) {
714
+				wp_register_script(
715
+					'archive-espresso_events',
716
+					get_stylesheet_directory_uri() . EE_Config::get_current_theme() . '/archive-espresso_events.js',
717
+					array('jquery-masonry'),
718
+					'1.0',
719
+					true
720
+				);
721
+			} else {
722
+				wp_register_script(
723
+					'archive-espresso_events',
724
+					EVENTS_ARCHIVE_ASSETS_URL . 'archive-espresso_events.js',
725
+					array('jquery-masonry'),
726
+					'1.0',
727
+					true
728
+				);
729
+			}
730
+			wp_enqueue_style('archive-espresso_events');
731
+			wp_enqueue_script('jquery-masonry');
732
+			wp_enqueue_script('archive-espresso_events');
733
+			add_action('wp_footer', array('EED_Events_Archive_Filters', 'localize_grid_event_lists'), 1);
734
+		}
735
+	}
736
+
737
+
738
+	/**
739
+	 *    template_settings_form
740
+	 *
741
+	 * @access    public
742
+	 * @static
743
+	 * @return    void
744
+	 */
745
+	public static function localize_grid_event_lists()
746
+	{
747
+		wp_localize_script(
748
+			'archive-espresso_events',
749
+			'espresso_grid_event_lists',
750
+			EED_Events_Archive_Filters::$espresso_grid_event_lists
751
+		);
752
+	}
753
+
754
+
755
+	/**
756
+	 *    template_settings_form
757
+	 *
758
+	 * @access    public
759
+	 * @static
760
+	 * @return    void
761
+	 */
762
+	public static function template_settings_form()
763
+	{
764
+		$EE = EE_Registry::instance();
765
+		$EE->CFG->template_settings->EED_Events_Archive_Filters = isset($EE->CFG->template_settings->EED_Events_Archive_Filters)
766
+			? $EE->CFG->template_settings->EED_Events_Archive_Filters : new EE_Events_Archive_Config();
767
+		$EE->CFG->template_settings->EED_Events_Archive_Filters = apply_filters(
768
+			'FHEE__Event_List__template_settings_form__event_list_config',
769
+			$EE->CFG->template_settings->EED_Events_Archive_Filters
770
+		);
771
+		EEH_Template::display_template(
772
+			EVENTS_ARCHIVE_TEMPLATES_PATH . 'admin-event-list-settings.template.php',
773
+			$EE->CFG->template_settings->EED_Events_Archive_Filters
774
+		);
775
+	}
776
+
777
+
778
+	/**
779
+	 *    set_default_settings
780
+	 *
781
+	 * @access    public
782
+	 * @static
783
+	 * @return    void
784
+	 */
785
+	public static function set_default_settings($CFG)
786
+	{
787
+		// EEH_Debug_Tools::printr( $CFG, '$CFG  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
788
+		$CFG->display_description = isset($CFG->display_description) && ! empty($CFG->display_description)
789
+			? $CFG->display_description : 1;
790
+		$CFG->display_address = isset($CFG->display_address) && ! empty($CFG->display_address) ? $CFG->display_address
791
+			: true;
792
+		$CFG->display_venue_details = isset($CFG->display_venue_details) && ! empty($CFG->display_venue_details)
793
+			? $CFG->display_venue_details : true;
794
+		$CFG->display_expired_events = isset($CFG->display_expired_events) && ! empty($CFG->display_expired_events)
795
+			? $CFG->display_expired_events : false;
796
+		$CFG->default_type = isset($CFG->default_type) && ! empty($CFG->default_type) ? $CFG->default_type : 'grid';
797
+		$CFG->event_list_grid_size = isset($CFG->event_list_grid_size) && ! empty($CFG->event_list_grid_size)
798
+			? $CFG->event_list_grid_size : 'medium';
799
+		$CFG->templates['full'] = isset($CFG->templates['full']) && ! empty($CFG->templates['full'])
800
+			? $CFG->templates['full']
801
+			: EE_TEMPLATES . EE_Config::get_current_theme() . '/archive-espresso_events.php';
802
+		$CFG->templates['part'] = isset($CFG->templates['part']) && ! empty($CFG->templates['part'])
803
+			? $CFG->templates['part']
804
+			: EE_TEMPLATES . EE_Config::get_current_theme() . '/archive-espresso_events-grid-view.php';
805
+		return $CFG;
806
+	}
807
+
808
+
809
+	/**
810
+	 *    filter_config
811
+	 *
812
+	 * @access    public
813
+	 * @return    void
814
+	 */
815
+	public function filter_config($CFG)
816
+	{
817
+		return $CFG;
818
+	}
819
+
820
+
821
+	/**
822
+	 *    filter_config
823
+	 *
824
+	 * @access    public
825
+	 * @return    void
826
+	 */
827
+	public static function update_template_settings($CFG, $REQ)
828
+	{
829
+		// $CFG->template_settings->EED_Events_Archive_Filters = new stdClass();
830
+		$CFG->EED_Events_Archive_Filters->display_description = isset($REQ['display_description_in_event_list'])
831
+			? absint($REQ['display_description_in_event_list']) : 1;
832
+		$CFG->EED_Events_Archive_Filters->display_address = isset($REQ['display_address_in_event_list']) ? absint(
833
+			$REQ['display_address_in_event_list']
834
+		) : true;
835
+		$CFG->EED_Events_Archive_Filters->display_venue_details = isset($REQ['display_venue_details_in_event_list'])
836
+			? absint($REQ['display_venue_details_in_event_list']) : true;
837
+		$CFG->EED_Events_Archive_Filters->display_expired_events = isset($REQ['display_expired_events']) ? absint(
838
+			$REQ['display_expired_events']
839
+		) : false;
840
+		$CFG->EED_Events_Archive_Filters->default_type = isset($REQ['default_type']) ? sanitize_text_field(
841
+			$REQ['default_type']
842
+		) : 'grid';
843
+		$CFG->EED_Events_Archive_Filters->event_list_grid_size = isset($REQ['event_list_grid_size'])
844
+			? sanitize_text_field($REQ['event_list_grid_size']) : 'medium';
845
+		$CFG->EED_Events_Archive_Filters->templates = array(
846
+			'full' => EE_TEMPLATES . EE_Config::get_current_theme() . '/archive-espresso_events.php',
847
+		);
848
+
849
+		switch ($CFG->EED_Events_Archive_Filters->default_type) {
850
+			case 'dates':
851
+				$CFG->EED_Events_Archive_Filters->templates['part'] = EE_TEMPLATES . EE_Config::get_current_theme()
852
+																	  . '/archive-espresso_events-dates-view.php';
853
+				break;
854
+			case 'text':
855
+				$CFG->EED_Events_Archive_Filters->templates['part'] = EE_TEMPLATES . EE_Config::get_current_theme()
856
+																	  . '/archive-espresso_events-text-view.php';
857
+				break;
858
+			default:
859
+				$CFG->EED_Events_Archive_Filters->templates['part'] = EE_TEMPLATES . EE_Config::get_current_theme()
860
+																	  . '/archive-espresso_events-grid-view.php';
861
+		}
862
+
863
+		$CFG->EED_Events_Archive_Filters = isset($REQ['reset_event_list_settings'])
864
+										   && absint($REQ['reset_event_list_settings']) == 1
865
+			? new EE_Events_Archive_Config()
866
+			: $CFG->EED_Events_Archive_Filters;
867
+		return $CFG;
868
+	}
869
+
870
+
871
+	/**
872
+	 *    get_template_part
873
+	 *
874
+	 * @access    public
875
+	 * @return    void
876
+	 */
877
+	public static function get_template_part()
878
+	{
879
+		switch (self::$_type) {
880
+			case 'dates':
881
+				return 'archive-espresso_events-dates-view.php';
882
+				break;
883
+			case 'text':
884
+				return 'archive-espresso_events-text-view.php';
885
+				break;
886
+			default:
887
+				return 'archive-espresso_events-grid-view.php';
888
+		}
889
+	}
890
+
891
+
892
+	/**
893
+	 *    event_list_template_filters
894
+	 *
895
+	 * @access    public
896
+	 * @return    void
897
+	 */
898
+	public function event_list_template_filters()
899
+	{
900
+		$args = array(
901
+			'form_url'         => get_post_type_archive_link('espresso_events'),
902
+			// add_query_arg( array( 'post_type' => 'espresso_events' ), home_url() ),
903
+			'elf_month'        => EED_Events_Archive_Filters::_display_month(),
904
+			'elf_category'     => EED_Events_Archive_Filters::_event_category_slug(),
905
+			'elf_show_expired' => EED_Events_Archive_Filters::_show_expired(),
906
+			'elf_type'         => self::$_type,
907
+		);
908
+		EEH_Template::display_template(
909
+			EE_TEMPLATES . EE_Config::get_current_theme() . '/archive-espresso_events-filters.php',
910
+			$args
911
+		);
912
+	}
913
+
914
+
915
+	/**
916
+	 *    event_list_css
917
+	 *
918
+	 * @access    public
919
+	 * @return    void
920
+	 */
921
+	public static function event_list_css($extra_class = '')
922
+	{
923
+		$EE = EE_Registry::instance();
924
+		$event_list_css = ! empty($extra_class) ? array($extra_class) : array();
925
+		$event_list_css[] = 'espresso-event-list-event';
926
+		if (self::$_type == 'grid') {
927
+			$event_list_grid_size = isset($EE->CFG->template_settings->EED_Events_Archive_Filters->event_list_grid_size)
928
+				? $EE->CFG->template_settings->EED_Events_Archive_Filters->event_list_grid_size : 'medium';
929
+			$event_list_css[] = $event_list_grid_size . '-event-list-grid';
930
+		}
931
+		$event_list_css = apply_filters(
932
+			'EED_Events_Archive_Filters__event_list_css__event_list_css_array',
933
+			$event_list_css
934
+		);
935
+		return implode(' ', $event_list_css);
936
+	}
937
+
938
+
939
+	/**
940
+	 *    event_categories
941
+	 *
942
+	 * @access    public
943
+	 * @return    void
944
+	 */
945
+	public static function event_categories()
946
+	{
947
+		return EE_Registry::instance()->load_model('Term')->get_all_ee_categories();
948
+	}
949
+
950
+
951
+	/**
952
+	 *    display_description
953
+	 *
954
+	 * @access    public
955
+	 * @return    void
956
+	 */
957
+	public static function display_description($value)
958
+	{
959
+		$EE = EE_Registry::instance();
960
+		$display_description = isset($EE->CFG->template_settings->EED_Events_Archive_Filters->display_description)
961
+			? $EE->CFG->template_settings->EED_Events_Archive_Filters->display_description : 1;
962
+		return $display_description === $value ? true : false;
963
+	}
964
+
965
+
966
+	/**
967
+	 *    display_venue_details
968
+	 *
969
+	 * @access    public
970
+	 * @return    void
971
+	 */
972
+	public static function display_venue_details()
973
+	{
974
+		$EE = EE_Registry::instance();
975
+		$display_venue_details = isset($EE->CFG->template_settings->EED_Events_Archive_Filters->display_venue_details)
976
+			? $EE->CFG->template_settings->EED_Events_Archive_Filters->display_venue_details : true;
977
+		$venue_name = EEH_Venue_View::venue_name();
978
+		return $display_venue_details && ! empty($venue_name) ? true : false;
979
+	}
980
+
981
+
982
+	/**
983
+	 *    display_address
984
+	 *
985
+	 * @access    public
986
+	 * @return    void
987
+	 */
988
+	public static function display_address()
989
+	{
990
+		$EE = EE_Registry::instance();
991
+		$display_address = isset($EE->CFG->template_settings->EED_Events_Archive_Filters->display_address)
992
+			? $EE->CFG->template_settings->EED_Events_Archive_Filters->display_address : false;
993
+		$venue_name = EEH_Venue_View::venue_name();
994
+		return $display_address && ! empty($venue_name) ? true : false;
995
+	}
996
+
997
+
998
+	/**
999
+	 *    pagination
1000
+	 *
1001
+	 * @access    public
1002
+	 * @return    void
1003
+	 */
1004
+	public static function pagination()
1005
+	{
1006
+		global $wp_query;
1007
+		$big = 999999999; // need an unlikely integer
1008
+		$pagination = paginate_links(
1009
+			array(
1010
+				'base'         => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
1011
+				'format'       => '?paged=%#%',
1012
+				'current'      => max(1, get_query_var('paged')),
1013
+				'total'        => $wp_query->max_num_pages,
1014
+				'show_all'     => true,
1015
+				'end_size'     => 10,
1016
+				'mid_size'     => 6,
1017
+				'prev_next'    => true,
1018
+				'prev_text'    => __('&lsaquo; PREV', 'event_espresso'),
1019
+				'next_text'    => __('NEXT &rsaquo;', 'event_espresso'),
1020
+				'type'         => 'plain',
1021
+				'add_args'     => false,
1022
+				'add_fragment' => '',
1023
+			)
1024
+		);
1025
+		return ! empty($pagination) ? '<div class="ee-pagination-dv clear">' . $pagination . '</div>' : '';
1026
+	}
1027
+
1028
+
1029
+	/**
1030
+	 *    event_list_title
1031
+	 *
1032
+	 * @access    public
1033
+	 * @return    void
1034
+	 */
1035
+	public static function event_list_title()
1036
+	{
1037
+		return apply_filters(
1038
+			'EED_Events_Archive_Filters__event_list_title__event_list_title',
1039
+			__('Upcoming Events', 'event_espresso')
1040
+		);
1041
+	}
1042 1042
 }
Please login to merge, or discard this patch.
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
         ) : '';
159 159
         $view = ! empty($elf_type) ? $elf_type : $view;
160 160
         $view = apply_filters('EED_Events_Archive_Filters__set_type__type', $view);
161
-        if (! empty($view) && in_array($view, EED_Events_Archive_Filters::$_types)) {
161
+        if ( ! empty($view) && in_array($view, EED_Events_Archive_Filters::$_types)) {
162 162
             self::$_type = $view;
163 163
         }
164 164
     }
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
     public static function posts_join_sql_for_terms($join_terms = null)
254 254
     {
255 255
         $SQL = '';
256
-        if (! empty($join_terms)) {
256
+        if ( ! empty($join_terms)) {
257 257
             global $wpdb;
258 258
             $SQL .= " LEFT JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id)";
259 259
             $SQL .= " LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)";
@@ -280,29 +280,29 @@  discard block
 block discarded – undo
280 280
             switch ($orderby) {
281 281
                 case 'ticket_start':
282 282
                 case 'ticket_end':
283
-                    $SQL .= ' LEFT JOIN ' . EEM_Datetime_Ticket::instance()->table() . ' ON ('
284
-                            . EEM_Datetime::instance()->table() . '.DTT_ID = '
285
-                            . EEM_Datetime_Ticket::instance()->table() . '.DTT_ID )';
286
-                    $SQL .= ' LEFT JOIN ' . EEM_Ticket::instance()->table() . ' ON ('
287
-                            . EEM_Datetime_Ticket::instance()->table() . '.TKT_ID = '
288
-                            . EEM_Ticket::instance()->table() . '.TKT_ID )';
283
+                    $SQL .= ' LEFT JOIN '.EEM_Datetime_Ticket::instance()->table().' ON ('
284
+                            . EEM_Datetime::instance()->table().'.DTT_ID = '
285
+                            . EEM_Datetime_Ticket::instance()->table().'.DTT_ID )';
286
+                    $SQL .= ' LEFT JOIN '.EEM_Ticket::instance()->table().' ON ('
287
+                            . EEM_Datetime_Ticket::instance()->table().'.TKT_ID = '
288
+                            . EEM_Ticket::instance()->table().'.TKT_ID )';
289 289
                     break;
290 290
 
291 291
                 case 'venue_title':
292 292
                 case 'city':
293
-                    $SQL .= ' LEFT JOIN ' . EEM_Event_Venue::instance()->table() . ' ON (' . $wpdb->posts . '.ID = '
294
-                            . EEM_Event_Venue::instance()->table() . '.EVT_ID )';
295
-                    $SQL .= ' LEFT JOIN ' . EEM_Venue::instance()->table() . ' ON ('
296
-                            . EEM_Event_Venue::instance()->table() . '.VNU_ID = '
297
-                            . EEM_Venue::instance()->table() . '.VNU_ID )';
293
+                    $SQL .= ' LEFT JOIN '.EEM_Event_Venue::instance()->table().' ON ('.$wpdb->posts.'.ID = '
294
+                            . EEM_Event_Venue::instance()->table().'.EVT_ID )';
295
+                    $SQL .= ' LEFT JOIN '.EEM_Venue::instance()->table().' ON ('
296
+                            . EEM_Event_Venue::instance()->table().'.VNU_ID = '
297
+                            . EEM_Venue::instance()->table().'.VNU_ID )';
298 298
                     break;
299 299
 
300 300
                 case 'state':
301
-                    $SQL .= ' LEFT JOIN ' . EEM_Event_Venue::instance()->table() . ' ON (' . $wpdb->posts . '.ID = '
302
-                            . EEM_Event_Venue::instance()->table() . '.EVT_ID )';
303
-                    $SQL .= ' LEFT JOIN ' . EEM_Event_Venue::instance()->second_table() . ' ON ('
304
-                            . EEM_Event_Venue::instance()->table() . '.VNU_ID = '
305
-                            . EEM_Event_Venue::instance()->second_table() . '.VNU_ID )';
301
+                    $SQL .= ' LEFT JOIN '.EEM_Event_Venue::instance()->table().' ON ('.$wpdb->posts.'.ID = '
302
+                            . EEM_Event_Venue::instance()->table().'.EVT_ID )';
303
+                    $SQL .= ' LEFT JOIN '.EEM_Event_Venue::instance()->second_table().' ON ('
304
+                            . EEM_Event_Venue::instance()->table().'.VNU_ID = '
305
+                            . EEM_Event_Venue::instance()->second_table().'.VNU_ID )';
306 306
                     break;
307 307
             }
308 308
         }
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
     public static function posts_where_sql_for_show_expired($show_expired = false)
349 349
     {
350 350
         return ! $show_expired
351
-            ? ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_end > "' . date('Y-m-d H:s:i') . '" '
351
+            ? ' AND '.EEM_Datetime::instance()->table().'.DTT_EVT_end > "'.date('Y-m-d H:s:i').'" '
352 352
             : '';
353 353
     }
354 354
 
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
     public static function posts_where_sql_for_event_category_slug($event_category_slug = null)
364 364
     {
365 365
         global $wpdb;
366
-        return ! empty($event_category_slug) ? ' AND ' . $wpdb->terms . '.slug = "' . $event_category_slug . '" ' : '';
366
+        return ! empty($event_category_slug) ? ' AND '.$wpdb->terms.'.slug = "'.$event_category_slug.'" ' : '';
367 367
     }
368 368
 
369 369
     /**
@@ -376,13 +376,13 @@  discard block
 block discarded – undo
376 376
     public static function posts_where_sql_for_event_list_month($month = null)
377 377
     {
378 378
         $SQL = '';
379
-        if (! empty($month)) {
379
+        if ( ! empty($month)) {
380 380
             // event start date is LESS than the end of the month ( so nothing that doesn't start until next month )
381
-            $SQL = ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_start';
382
-            $SQL .= ' <= "' . date('Y-m-t 23:59:59', \EEH_DTT_Helper::first_of_month_timestamp($month)) . '"';
381
+            $SQL = ' AND '.EEM_Datetime::instance()->table().'.DTT_EVT_start';
382
+            $SQL .= ' <= "'.date('Y-m-t 23:59:59', \EEH_DTT_Helper::first_of_month_timestamp($month)).'"';
383 383
             // event end date is GREATER than the start of the month ( so nothing that ended before this month )
384
-            $SQL .= ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_end';
385
-            $SQL .= ' >= "' . date('Y-m-d 0:0:00', \EEH_DTT_Helper::first_of_month_timestamp($month)) . '" ';
384
+            $SQL .= ' AND '.EEM_Datetime::instance()->table().'.DTT_EVT_end';
385
+            $SQL .= ' >= "'.date('Y-m-d 0:0:00', \EEH_DTT_Helper::first_of_month_timestamp($month)).'" ';
386 386
         }
387 387
         return $SQL;
388 388
     }
@@ -437,43 +437,43 @@  discard block
 block discarded – undo
437 437
             switch ($orderby) {
438 438
                 case 'id':
439 439
                 case 'ID':
440
-                    $SQL .= $glue . $wpdb->posts . '.ID ' . $sort;
440
+                    $SQL .= $glue.$wpdb->posts.'.ID '.$sort;
441 441
                     break;
442 442
 
443 443
                 case 'start_date':
444
-                    $SQL .= $glue . EEM_Datetime::instance()->table() . '.DTT_EVT_start ' . $sort;
444
+                    $SQL .= $glue.EEM_Datetime::instance()->table().'.DTT_EVT_start '.$sort;
445 445
                     break;
446 446
 
447 447
                 case 'end_date':
448
-                    $SQL .= $glue . EEM_Datetime::instance()->table() . '.DTT_EVT_end ' . $sort;
448
+                    $SQL .= $glue.EEM_Datetime::instance()->table().'.DTT_EVT_end '.$sort;
449 449
                     break;
450 450
 
451 451
                 case 'event_name':
452
-                    $SQL .= $glue . $wpdb->posts . '.post_title ' . $sort;
452
+                    $SQL .= $glue.$wpdb->posts.'.post_title '.$sort;
453 453
                     break;
454 454
 
455 455
                 case 'category_slug':
456
-                    $SQL .= $glue . $wpdb->terms . '.slug ' . $sort;
456
+                    $SQL .= $glue.$wpdb->terms.'.slug '.$sort;
457 457
                     break;
458 458
 
459 459
                 case 'ticket_start':
460
-                    $SQL .= $glue . EEM_Ticket::instance()->table() . '.TKT_start_date ' . $sort;
460
+                    $SQL .= $glue.EEM_Ticket::instance()->table().'.TKT_start_date '.$sort;
461 461
                     break;
462 462
 
463 463
                 case 'ticket_end':
464
-                    $SQL .= $glue . EEM_Ticket::instance()->table() . '.TKT_end_date ' . $sort;
464
+                    $SQL .= $glue.EEM_Ticket::instance()->table().'.TKT_end_date '.$sort;
465 465
                     break;
466 466
 
467 467
                 case 'venue_title':
468
-                    $SQL .= $glue . 'venue_title ' . $sort;
468
+                    $SQL .= $glue.'venue_title '.$sort;
469 469
                     break;
470 470
 
471 471
                 case 'city':
472
-                    $SQL .= $glue . EEM_Venue::instance()->second_table() . '.VNU_city ' . $sort;
472
+                    $SQL .= $glue.EEM_Venue::instance()->second_table().'.VNU_city '.$sort;
473 473
                     break;
474 474
 
475 475
                 case 'state':
476
-                    $SQL .= $glue . EEM_State::instance()->table() . '.STA_name ' . $sort;
476
+                    $SQL .= $glue.EEM_State::instance()->table().'.STA_name '.$sort;
477 477
                     break;
478 478
             }
479 479
             $cntr++;
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
      */
529 529
     public function event_list_pagination()
530 530
     {
531
-        echo '<div class="ee-pagination-dv ee-clear-float">' . espresso_event_list_pagination() . '</div>';
531
+        echo '<div class="ee-pagination-dv ee-clear-float">'.espresso_event_list_pagination().'</div>';
532 532
     }
533 533
 
534 534
 
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
     public function event_details($content)
543 543
     {
544 544
         return EEH_Template::display_template(
545
-            EE_TEMPLATES . EE_Config::get_current_theme() . '/content-espresso_events-details.php',
545
+            EE_TEMPLATES.EE_Config::get_current_theme().'/content-espresso_events-details.php',
546 546
             array('the_content' => $content),
547 547
             true
548 548
         );
@@ -560,7 +560,7 @@  discard block
 block discarded – undo
560 560
     {
561 561
         return $content
562 562
                . EEH_Template::display_template(
563
-                   EE_TEMPLATES . EE_Config::get_current_theme() . '/content-espresso_events-tickets.php',
563
+                   EE_TEMPLATES.EE_Config::get_current_theme().'/content-espresso_events-tickets.php',
564 564
                    array(),
565 565
                    true
566 566
                );
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
     {
578 578
         return $content
579 579
                . EEH_Template::display_template(
580
-                   EE_TEMPLATES . EE_Config::get_current_theme() . '/content-espresso_events-datetimes.php',
580
+                   EE_TEMPLATES.EE_Config::get_current_theme().'/content-espresso_events-datetimes.php',
581 581
                    array(),
582 582
                    true
583 583
                );
@@ -594,7 +594,7 @@  discard block
 block discarded – undo
594 594
     {
595 595
         return $content
596 596
                . EEH_Template::display_template(
597
-                   EE_TEMPLATES . EE_Config::get_current_theme() . '/content-espresso_events-venues.php',
597
+                   EE_TEMPLATES.EE_Config::get_current_theme().'/content-espresso_events-venues.php',
598 598
                    array(),
599 599
                    true
600 600
                );
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
      */
630 630
     private function _get_template($which = 'part')
631 631
     {
632
-        return EE_TEMPLATES . EE_Config::get_current_theme() . '/archive-espresso_events.php';
632
+        return EE_TEMPLATES.EE_Config::get_current_theme().'/archive-espresso_events.php';
633 633
     }
634 634
 
635 635
 
@@ -690,30 +690,30 @@  discard block
 block discarded – undo
690 690
             // first check uploads folder
691 691
             if (
692 692
                 is_readable(
693
-                    get_stylesheet_directory() . EE_Config::get_current_theme() . '/archive-espresso_events.css'
693
+                    get_stylesheet_directory().EE_Config::get_current_theme().'/archive-espresso_events.css'
694 694
                 )
695 695
             ) {
696 696
                 wp_register_style(
697 697
                     'archive-espresso_events',
698
-                    get_stylesheet_directory_uri() . EE_Config::get_current_theme(
699
-                    ) . '/archive-espresso_events.css',
698
+                    get_stylesheet_directory_uri().EE_Config::get_current_theme(
699
+                    ).'/archive-espresso_events.css',
700 700
                     array('dashicons', 'espresso_default')
701 701
                 );
702 702
             } else {
703 703
                 wp_register_style(
704 704
                     'archive-espresso_events',
705
-                    EE_TEMPLATES_URL . EE_Config::get_current_theme() . '/archive-espresso_events.css',
705
+                    EE_TEMPLATES_URL.EE_Config::get_current_theme().'/archive-espresso_events.css',
706 706
                     array('dashicons', 'espresso_default')
707 707
                 );
708 708
             }
709 709
             if (
710 710
                 is_readable(
711
-                    get_stylesheet_directory() . EE_Config::get_current_theme() . '/archive-espresso_events.js'
711
+                    get_stylesheet_directory().EE_Config::get_current_theme().'/archive-espresso_events.js'
712 712
                 )
713 713
             ) {
714 714
                 wp_register_script(
715 715
                     'archive-espresso_events',
716
-                    get_stylesheet_directory_uri() . EE_Config::get_current_theme() . '/archive-espresso_events.js',
716
+                    get_stylesheet_directory_uri().EE_Config::get_current_theme().'/archive-espresso_events.js',
717 717
                     array('jquery-masonry'),
718 718
                     '1.0',
719 719
                     true
@@ -721,7 +721,7 @@  discard block
 block discarded – undo
721 721
             } else {
722 722
                 wp_register_script(
723 723
                     'archive-espresso_events',
724
-                    EVENTS_ARCHIVE_ASSETS_URL . 'archive-espresso_events.js',
724
+                    EVENTS_ARCHIVE_ASSETS_URL.'archive-espresso_events.js',
725 725
                     array('jquery-masonry'),
726 726
                     '1.0',
727 727
                     true
@@ -769,7 +769,7 @@  discard block
 block discarded – undo
769 769
             $EE->CFG->template_settings->EED_Events_Archive_Filters
770 770
         );
771 771
         EEH_Template::display_template(
772
-            EVENTS_ARCHIVE_TEMPLATES_PATH . 'admin-event-list-settings.template.php',
772
+            EVENTS_ARCHIVE_TEMPLATES_PATH.'admin-event-list-settings.template.php',
773 773
             $EE->CFG->template_settings->EED_Events_Archive_Filters
774 774
         );
775 775
     }
@@ -798,10 +798,10 @@  discard block
 block discarded – undo
798 798
             ? $CFG->event_list_grid_size : 'medium';
799 799
         $CFG->templates['full'] = isset($CFG->templates['full']) && ! empty($CFG->templates['full'])
800 800
             ? $CFG->templates['full']
801
-            : EE_TEMPLATES . EE_Config::get_current_theme() . '/archive-espresso_events.php';
801
+            : EE_TEMPLATES.EE_Config::get_current_theme().'/archive-espresso_events.php';
802 802
         $CFG->templates['part'] = isset($CFG->templates['part']) && ! empty($CFG->templates['part'])
803 803
             ? $CFG->templates['part']
804
-            : EE_TEMPLATES . EE_Config::get_current_theme() . '/archive-espresso_events-grid-view.php';
804
+            : EE_TEMPLATES.EE_Config::get_current_theme().'/archive-espresso_events-grid-view.php';
805 805
         return $CFG;
806 806
     }
807 807
 
@@ -843,20 +843,20 @@  discard block
 block discarded – undo
843 843
         $CFG->EED_Events_Archive_Filters->event_list_grid_size = isset($REQ['event_list_grid_size'])
844 844
             ? sanitize_text_field($REQ['event_list_grid_size']) : 'medium';
845 845
         $CFG->EED_Events_Archive_Filters->templates = array(
846
-            'full' => EE_TEMPLATES . EE_Config::get_current_theme() . '/archive-espresso_events.php',
846
+            'full' => EE_TEMPLATES.EE_Config::get_current_theme().'/archive-espresso_events.php',
847 847
         );
848 848
 
849 849
         switch ($CFG->EED_Events_Archive_Filters->default_type) {
850 850
             case 'dates':
851
-                $CFG->EED_Events_Archive_Filters->templates['part'] = EE_TEMPLATES . EE_Config::get_current_theme()
851
+                $CFG->EED_Events_Archive_Filters->templates['part'] = EE_TEMPLATES.EE_Config::get_current_theme()
852 852
                                                                       . '/archive-espresso_events-dates-view.php';
853 853
                 break;
854 854
             case 'text':
855
-                $CFG->EED_Events_Archive_Filters->templates['part'] = EE_TEMPLATES . EE_Config::get_current_theme()
855
+                $CFG->EED_Events_Archive_Filters->templates['part'] = EE_TEMPLATES.EE_Config::get_current_theme()
856 856
                                                                       . '/archive-espresso_events-text-view.php';
857 857
                 break;
858 858
             default:
859
-                $CFG->EED_Events_Archive_Filters->templates['part'] = EE_TEMPLATES . EE_Config::get_current_theme()
859
+                $CFG->EED_Events_Archive_Filters->templates['part'] = EE_TEMPLATES.EE_Config::get_current_theme()
860 860
                                                                       . '/archive-espresso_events-grid-view.php';
861 861
         }
862 862
 
@@ -906,7 +906,7 @@  discard block
 block discarded – undo
906 906
             'elf_type'         => self::$_type,
907 907
         );
908 908
         EEH_Template::display_template(
909
-            EE_TEMPLATES . EE_Config::get_current_theme() . '/archive-espresso_events-filters.php',
909
+            EE_TEMPLATES.EE_Config::get_current_theme().'/archive-espresso_events-filters.php',
910 910
             $args
911 911
         );
912 912
     }
@@ -926,7 +926,7 @@  discard block
 block discarded – undo
926 926
         if (self::$_type == 'grid') {
927 927
             $event_list_grid_size = isset($EE->CFG->template_settings->EED_Events_Archive_Filters->event_list_grid_size)
928 928
                 ? $EE->CFG->template_settings->EED_Events_Archive_Filters->event_list_grid_size : 'medium';
929
-            $event_list_css[] = $event_list_grid_size . '-event-list-grid';
929
+            $event_list_css[] = $event_list_grid_size.'-event-list-grid';
930 930
         }
931 931
         $event_list_css = apply_filters(
932 932
             'EED_Events_Archive_Filters__event_list_css__event_list_css_array',
@@ -1022,7 +1022,7 @@  discard block
 block discarded – undo
1022 1022
                 'add_fragment' => '',
1023 1023
             )
1024 1024
         );
1025
-        return ! empty($pagination) ? '<div class="ee-pagination-dv clear">' . $pagination . '</div>' : '';
1025
+        return ! empty($pagination) ? '<div class="ee-pagination-dv clear">'.$pagination.'</div>' : '';
1026 1026
     }
1027 1027
 
1028 1028
 
Please login to merge, or discard this patch.
modules/feeds/EED_Feeds.module.php 3 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
      *
113 113
      * @access    public
114 114
      * @param    string $SQL the JOIN clause for the comment feed query
115
-     * @return    void
115
+     * @return    string
116 116
      */
117 117
     public static function comment_feed_join($SQL)
118 118
     {
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
      *
134 134
      * @access    public
135 135
      * @param    string $SQL the WHERE clause for the comment feed query
136
-     * @return    void
136
+     * @return    string
137 137
      */
138 138
     public static function comment_feed_where($SQL)
139 139
     {
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
      *
151 151
      * @access    public
152 152
      * @param    string $content
153
-     * @return    void
153
+     * @return    string
154 154
      */
155 155
     public static function the_event_feed($content)
156 156
     {
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
      *
192 192
      * @access    public
193 193
      * @param    string $content
194
-     * @return    void
194
+     * @return    string
195 195
      */
196 196
     public static function the_venue_feed($content)
197 197
     {
Please login to merge, or discard this patch.
Indentation   +213 added lines, -213 removed lines patch added patch discarded remove patch
@@ -12,217 +12,217 @@
 block discarded – undo
12 12
 {
13 13
 
14 14
 
15
-    /**
16
-     * @return EED_Feeds
17
-     */
18
-    public static function instance()
19
-    {
20
-        return parent::get_instance(__CLASS__);
21
-    }
22
-
23
-
24
-    /**
25
-     *    set_hooks - for hooking into EE Core, other modules, etc
26
-     *
27
-     * @access    public
28
-     * @return    void
29
-     */
30
-    public static function set_hooks()
31
-    {
32
-        add_action('parse_request', array('EED_Feeds', 'parse_request'), 10);
33
-        add_filter('default_feed', array('EED_Feeds', 'default_feed'), 10, 1);
34
-        add_filter('comment_feed_join', array('EED_Feeds', 'comment_feed_join'), 10, 2);
35
-        add_filter('comment_feed_where', array('EED_Feeds', 'comment_feed_where'), 10, 2);
36
-    }
37
-
38
-    /**
39
-     *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
40
-     *
41
-     * @access    public
42
-     * @return    void
43
-     */
44
-    public static function set_hooks_admin()
45
-    {
46
-    }
47
-
48
-
49
-    /**
50
-     *    run - initial module setup
51
-     *
52
-     * @access    public
53
-     * @return    void
54
-     */
55
-    public function run($WP)
56
-    {
57
-    }
58
-
59
-
60
-    /**
61
-     *    default_feed
62
-     *
63
-     * @access    public
64
-     * @param    type    rss2, atom, rss, rdf, rssjs
65
-     * @return    string
66
-     */
67
-    public static function default_feed($type = 'rss2')
68
-    {
69
-        // rss2, atom, rss, rdf, rssjs
70
-        $type = 'rss2';
71
-        return $type;
72
-    }
73
-
74
-
75
-    /**
76
-     *    parse_request
77
-     *
78
-     * @access    public
79
-     * @return    void
80
-     */
81
-    public static function parse_request()
82
-    {
83
-        if (EE_Registry::instance()->REQ->is_set('post_type')) {
84
-            // define path to templates
85
-            define('RSS_FEEDS_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/');
86
-            // what kinda post_type are we dealing with ?
87
-            switch (EE_Registry::instance()->REQ->get('post_type')) {
88
-                case 'espresso_events':
89
-                    // for rss2, atom, rss, rdf
90
-                    add_filter('the_excerpt_rss', array('EED_Feeds', 'the_event_feed'), 10, 1);
91
-                    add_filter('the_content_feed', array('EED_Feeds', 'the_event_feed'), 10, 1);
92
-                    // for json ( also uses the above filter )
93
-                    add_filter('rssjs_feed_item', array('EED_Feeds', 'the_event_rssjs_feed'), 10, 1);
94
-                    break;
95
-                case 'espresso_venues':
96
-                    // for rss2, atom, rss, rdf
97
-                    add_filter('the_excerpt_rss', array('EED_Feeds', 'the_venue_feed'), 10, 1);
98
-                    add_filter('the_content_feed', array('EED_Feeds', 'the_venue_feed'), 10, 1);
99
-                    // for json ( also uses the above filter )
100
-                    add_filter('rssjs_feed_item', array('EED_Feeds', 'the_venue_rssjs_feed'), 10, 1);
101
-                    break;
102
-            }
103
-        }
104
-    }
105
-
106
-
107
-    /**
108
-     *    comment_feed_join - EVEN THOUGH... our espresso_attendees custom post type is set to NOT PUBLIC
109
-     *    WordPress thought it would be a good idea to display the comments for them in the RSS feeds... we think NOT
110
-     *    so this little snippet of SQL taps into the comment feed query and removes comments for the
111
-     *    espresso_attendees post_type
112
-     *
113
-     * @access    public
114
-     * @param    string $SQL the JOIN clause for the comment feed query
115
-     * @return    void
116
-     */
117
-    public static function comment_feed_join($SQL)
118
-    {
119
-        global $wpdb;
120
-        // check for wp_posts table in JOIN clause
121
-        if (strpos($SQL, $wpdb->posts) !== false) {
122
-            add_filter('EED_Feeds__comment_feed_where__espresso_attendees', '__return_true');
123
-        }
124
-        return $SQL;
125
-    }
126
-
127
-
128
-    /**
129
-     *    comment_feed_where - EVEN THOUGH... our espresso_attendees custom post type is set to NOT PUBLIC
130
-     *    WordPress thought it would be a good idea to display the comments for them in the RSS feeds... we think NOT
131
-     *    so this little snippet of SQL taps into the comment feed query and removes comments for the
132
-     *    espresso_attendees post_type
133
-     *
134
-     * @access    public
135
-     * @param    string $SQL the WHERE clause for the comment feed query
136
-     * @return    void
137
-     */
138
-    public static function comment_feed_where($SQL)
139
-    {
140
-        global $wp_query, $wpdb;
141
-        if ($wp_query->is_comment_feed && apply_filters('EED_Feeds__comment_feed_where__espresso_attendees', false)) {
142
-            $SQL .= " AND $wpdb->posts.post_type != 'espresso_attendees'";
143
-        }
144
-        return $SQL;
145
-    }
146
-
147
-
148
-    /**
149
-     *    the_event_feed
150
-     *
151
-     * @access    public
152
-     * @param    string $content
153
-     * @return    void
154
-     */
155
-    public static function the_event_feed($content)
156
-    {
157
-        if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php')) {
158
-            global $post;
159
-            $template_args = array(
160
-                'EVT_ID'            => $post->ID,
161
-                'event_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content,
162
-            );
163
-            $content = EEH_Template::display_template(
164
-                RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php',
165
-                $template_args,
166
-                true
167
-            );
168
-        }
169
-        return $content;
170
-    }
171
-
172
-
173
-    /**
174
-     *    the_event_rssjs_feed
175
-     *
176
-     * @access    public
177
-     * @param    object $item
178
-     * @return    void
179
-     */
180
-    public static function the_event_rssjs_feed($item)
181
-    {
182
-        if (is_feed() && isset($item->description)) {
183
-            $item->description = EED_Feeds::the_event_feed($item->description);
184
-        }
185
-        return $item;
186
-    }
187
-
188
-
189
-    /**
190
-     *    the_venue_feed
191
-     *
192
-     * @access    public
193
-     * @param    string $content
194
-     * @return    void
195
-     */
196
-    public static function the_venue_feed($content)
197
-    {
198
-        if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php')) {
199
-            global $post;
200
-            $template_args = array(
201
-                'VNU_ID'            => $post->ID,
202
-                'venue_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content,
203
-            );
204
-            $content = EEH_Template::display_template(
205
-                RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php',
206
-                $template_args,
207
-                true
208
-            );
209
-        }
210
-        return $content;
211
-    }
212
-
213
-
214
-    /**
215
-     *    the_venue_rssjs_feed
216
-     *
217
-     * @access    public
218
-     * @param    object $item
219
-     * @return    void
220
-     */
221
-    public static function the_venue_rssjs_feed($item)
222
-    {
223
-        if (is_feed() && isset($item->description)) {
224
-            $item->description = EED_Feeds::the_venue_feed($item->description);
225
-        }
226
-        return $item;
227
-    }
15
+	/**
16
+	 * @return EED_Feeds
17
+	 */
18
+	public static function instance()
19
+	{
20
+		return parent::get_instance(__CLASS__);
21
+	}
22
+
23
+
24
+	/**
25
+	 *    set_hooks - for hooking into EE Core, other modules, etc
26
+	 *
27
+	 * @access    public
28
+	 * @return    void
29
+	 */
30
+	public static function set_hooks()
31
+	{
32
+		add_action('parse_request', array('EED_Feeds', 'parse_request'), 10);
33
+		add_filter('default_feed', array('EED_Feeds', 'default_feed'), 10, 1);
34
+		add_filter('comment_feed_join', array('EED_Feeds', 'comment_feed_join'), 10, 2);
35
+		add_filter('comment_feed_where', array('EED_Feeds', 'comment_feed_where'), 10, 2);
36
+	}
37
+
38
+	/**
39
+	 *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
40
+	 *
41
+	 * @access    public
42
+	 * @return    void
43
+	 */
44
+	public static function set_hooks_admin()
45
+	{
46
+	}
47
+
48
+
49
+	/**
50
+	 *    run - initial module setup
51
+	 *
52
+	 * @access    public
53
+	 * @return    void
54
+	 */
55
+	public function run($WP)
56
+	{
57
+	}
58
+
59
+
60
+	/**
61
+	 *    default_feed
62
+	 *
63
+	 * @access    public
64
+	 * @param    type    rss2, atom, rss, rdf, rssjs
65
+	 * @return    string
66
+	 */
67
+	public static function default_feed($type = 'rss2')
68
+	{
69
+		// rss2, atom, rss, rdf, rssjs
70
+		$type = 'rss2';
71
+		return $type;
72
+	}
73
+
74
+
75
+	/**
76
+	 *    parse_request
77
+	 *
78
+	 * @access    public
79
+	 * @return    void
80
+	 */
81
+	public static function parse_request()
82
+	{
83
+		if (EE_Registry::instance()->REQ->is_set('post_type')) {
84
+			// define path to templates
85
+			define('RSS_FEEDS_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/');
86
+			// what kinda post_type are we dealing with ?
87
+			switch (EE_Registry::instance()->REQ->get('post_type')) {
88
+				case 'espresso_events':
89
+					// for rss2, atom, rss, rdf
90
+					add_filter('the_excerpt_rss', array('EED_Feeds', 'the_event_feed'), 10, 1);
91
+					add_filter('the_content_feed', array('EED_Feeds', 'the_event_feed'), 10, 1);
92
+					// for json ( also uses the above filter )
93
+					add_filter('rssjs_feed_item', array('EED_Feeds', 'the_event_rssjs_feed'), 10, 1);
94
+					break;
95
+				case 'espresso_venues':
96
+					// for rss2, atom, rss, rdf
97
+					add_filter('the_excerpt_rss', array('EED_Feeds', 'the_venue_feed'), 10, 1);
98
+					add_filter('the_content_feed', array('EED_Feeds', 'the_venue_feed'), 10, 1);
99
+					// for json ( also uses the above filter )
100
+					add_filter('rssjs_feed_item', array('EED_Feeds', 'the_venue_rssjs_feed'), 10, 1);
101
+					break;
102
+			}
103
+		}
104
+	}
105
+
106
+
107
+	/**
108
+	 *    comment_feed_join - EVEN THOUGH... our espresso_attendees custom post type is set to NOT PUBLIC
109
+	 *    WordPress thought it would be a good idea to display the comments for them in the RSS feeds... we think NOT
110
+	 *    so this little snippet of SQL taps into the comment feed query and removes comments for the
111
+	 *    espresso_attendees post_type
112
+	 *
113
+	 * @access    public
114
+	 * @param    string $SQL the JOIN clause for the comment feed query
115
+	 * @return    void
116
+	 */
117
+	public static function comment_feed_join($SQL)
118
+	{
119
+		global $wpdb;
120
+		// check for wp_posts table in JOIN clause
121
+		if (strpos($SQL, $wpdb->posts) !== false) {
122
+			add_filter('EED_Feeds__comment_feed_where__espresso_attendees', '__return_true');
123
+		}
124
+		return $SQL;
125
+	}
126
+
127
+
128
+	/**
129
+	 *    comment_feed_where - EVEN THOUGH... our espresso_attendees custom post type is set to NOT PUBLIC
130
+	 *    WordPress thought it would be a good idea to display the comments for them in the RSS feeds... we think NOT
131
+	 *    so this little snippet of SQL taps into the comment feed query and removes comments for the
132
+	 *    espresso_attendees post_type
133
+	 *
134
+	 * @access    public
135
+	 * @param    string $SQL the WHERE clause for the comment feed query
136
+	 * @return    void
137
+	 */
138
+	public static function comment_feed_where($SQL)
139
+	{
140
+		global $wp_query, $wpdb;
141
+		if ($wp_query->is_comment_feed && apply_filters('EED_Feeds__comment_feed_where__espresso_attendees', false)) {
142
+			$SQL .= " AND $wpdb->posts.post_type != 'espresso_attendees'";
143
+		}
144
+		return $SQL;
145
+	}
146
+
147
+
148
+	/**
149
+	 *    the_event_feed
150
+	 *
151
+	 * @access    public
152
+	 * @param    string $content
153
+	 * @return    void
154
+	 */
155
+	public static function the_event_feed($content)
156
+	{
157
+		if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php')) {
158
+			global $post;
159
+			$template_args = array(
160
+				'EVT_ID'            => $post->ID,
161
+				'event_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content,
162
+			);
163
+			$content = EEH_Template::display_template(
164
+				RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php',
165
+				$template_args,
166
+				true
167
+			);
168
+		}
169
+		return $content;
170
+	}
171
+
172
+
173
+	/**
174
+	 *    the_event_rssjs_feed
175
+	 *
176
+	 * @access    public
177
+	 * @param    object $item
178
+	 * @return    void
179
+	 */
180
+	public static function the_event_rssjs_feed($item)
181
+	{
182
+		if (is_feed() && isset($item->description)) {
183
+			$item->description = EED_Feeds::the_event_feed($item->description);
184
+		}
185
+		return $item;
186
+	}
187
+
188
+
189
+	/**
190
+	 *    the_venue_feed
191
+	 *
192
+	 * @access    public
193
+	 * @param    string $content
194
+	 * @return    void
195
+	 */
196
+	public static function the_venue_feed($content)
197
+	{
198
+		if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php')) {
199
+			global $post;
200
+			$template_args = array(
201
+				'VNU_ID'            => $post->ID,
202
+				'venue_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content,
203
+			);
204
+			$content = EEH_Template::display_template(
205
+				RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php',
206
+				$template_args,
207
+				true
208
+			);
209
+		}
210
+		return $content;
211
+	}
212
+
213
+
214
+	/**
215
+	 *    the_venue_rssjs_feed
216
+	 *
217
+	 * @access    public
218
+	 * @param    object $item
219
+	 * @return    void
220
+	 */
221
+	public static function the_venue_rssjs_feed($item)
222
+	{
223
+		if (is_feed() && isset($item->description)) {
224
+			$item->description = EED_Feeds::the_venue_feed($item->description);
225
+		}
226
+		return $item;
227
+	}
228 228
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
     {
83 83
         if (EE_Registry::instance()->REQ->is_set('post_type')) {
84 84
             // define path to templates
85
-            define('RSS_FEEDS_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/');
85
+            define('RSS_FEEDS_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)).'templates/');
86 86
             // what kinda post_type are we dealing with ?
87 87
             switch (EE_Registry::instance()->REQ->get('post_type')) {
88 88
                 case 'espresso_events':
@@ -154,14 +154,14 @@  discard block
 block discarded – undo
154 154
      */
155 155
     public static function the_event_feed($content)
156 156
     {
157
-        if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php')) {
157
+        if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH.'espresso_events_feed.template.php')) {
158 158
             global $post;
159 159
             $template_args = array(
160 160
                 'EVT_ID'            => $post->ID,
161 161
                 'event_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content,
162 162
             );
163 163
             $content = EEH_Template::display_template(
164
-                RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php',
164
+                RSS_FEEDS_TEMPLATES_PATH.'espresso_events_feed.template.php',
165 165
                 $template_args,
166 166
                 true
167 167
             );
@@ -195,14 +195,14 @@  discard block
 block discarded – undo
195 195
      */
196 196
     public static function the_venue_feed($content)
197 197
     {
198
-        if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php')) {
198
+        if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH.'espresso_venues_feed.template.php')) {
199 199
             global $post;
200 200
             $template_args = array(
201 201
                 'VNU_ID'            => $post->ID,
202 202
                 'venue_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content,
203 203
             );
204 204
             $content = EEH_Template::display_template(
205
-                RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php',
205
+                RSS_FEEDS_TEMPLATES_PATH.'espresso_venues_feed.template.php',
206 206
                 $template_args,
207 207
                 true
208 208
             );
Please login to merge, or discard this patch.
admin_pages/support/Support_Admin_Page_Init.core.php 2 patches
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -16,36 +16,36 @@
 block discarded – undo
16 16
 {
17 17
 
18 18
 
19
-    public function __construct()
20
-    {
21
-        // define some help/support page related constants
22
-        define('EE_SUPPORT_PG_SLUG', 'espresso_support');
23
-        define('EE_SUPPORT_ADMIN_URL', admin_url('admin.php?page=' . EE_SUPPORT_PG_SLUG));
24
-        define('EE_SUPPORT_ADMIN_TEMPLATE_PATH', EE_ADMIN_PAGES . 'support/templates/');
25
-        define('EE_SUPPORT_ADMIN', EE_ADMIN_PAGES . 'support/');
26
-        define('EE_SUPPORT_ASSETS_URL', EE_ADMIN_PAGES_URL . 'support/assets/');
27
-        parent::__construct();
28
-    }
19
+	public function __construct()
20
+	{
21
+		// define some help/support page related constants
22
+		define('EE_SUPPORT_PG_SLUG', 'espresso_support');
23
+		define('EE_SUPPORT_ADMIN_URL', admin_url('admin.php?page=' . EE_SUPPORT_PG_SLUG));
24
+		define('EE_SUPPORT_ADMIN_TEMPLATE_PATH', EE_ADMIN_PAGES . 'support/templates/');
25
+		define('EE_SUPPORT_ADMIN', EE_ADMIN_PAGES . 'support/');
26
+		define('EE_SUPPORT_ASSETS_URL', EE_ADMIN_PAGES_URL . 'support/assets/');
27
+		parent::__construct();
28
+	}
29 29
 
30
-    protected function _set_init_properties()
31
-    {
32
-        $this->label = __('Help & Support', 'event_espresso');
33
-    }
30
+	protected function _set_init_properties()
31
+	{
32
+		$this->label = __('Help & Support', 'event_espresso');
33
+	}
34 34
 
35
-    protected function _set_menu_map()
36
-    {
37
-        $this->_menu_map = new EE_Admin_Page_Sub_Menu(
38
-            array(
39
-                'menu_group'              => 'extras',
40
-                'menu_order'              => 30,
41
-                'show_on_menu'            => EE_Admin_Page_Menu_Map::BLOG_AND_NETWORK_ADMIN,
42
-                'parent_slug'             => 'espresso_events',
43
-                'menu_slug'               => EE_SUPPORT_PG_SLUG,
44
-                'menu_label'              => __('Help & Support', 'event_espresso'),
45
-                'capability'              => 'ee_read_ee',
46
-                'maintenance_mode_parent' => 'espresso_maintenance_settings',
47
-                'admin_init_page'         => $this,
48
-            )
49
-        );
50
-    }
35
+	protected function _set_menu_map()
36
+	{
37
+		$this->_menu_map = new EE_Admin_Page_Sub_Menu(
38
+			array(
39
+				'menu_group'              => 'extras',
40
+				'menu_order'              => 30,
41
+				'show_on_menu'            => EE_Admin_Page_Menu_Map::BLOG_AND_NETWORK_ADMIN,
42
+				'parent_slug'             => 'espresso_events',
43
+				'menu_slug'               => EE_SUPPORT_PG_SLUG,
44
+				'menu_label'              => __('Help & Support', 'event_espresso'),
45
+				'capability'              => 'ee_read_ee',
46
+				'maintenance_mode_parent' => 'espresso_maintenance_settings',
47
+				'admin_init_page'         => $this,
48
+			)
49
+		);
50
+	}
51 51
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -20,10 +20,10 @@
 block discarded – undo
20 20
     {
21 21
         // define some help/support page related constants
22 22
         define('EE_SUPPORT_PG_SLUG', 'espresso_support');
23
-        define('EE_SUPPORT_ADMIN_URL', admin_url('admin.php?page=' . EE_SUPPORT_PG_SLUG));
24
-        define('EE_SUPPORT_ADMIN_TEMPLATE_PATH', EE_ADMIN_PAGES . 'support/templates/');
25
-        define('EE_SUPPORT_ADMIN', EE_ADMIN_PAGES . 'support/');
26
-        define('EE_SUPPORT_ASSETS_URL', EE_ADMIN_PAGES_URL . 'support/assets/');
23
+        define('EE_SUPPORT_ADMIN_URL', admin_url('admin.php?page='.EE_SUPPORT_PG_SLUG));
24
+        define('EE_SUPPORT_ADMIN_TEMPLATE_PATH', EE_ADMIN_PAGES.'support/templates/');
25
+        define('EE_SUPPORT_ADMIN', EE_ADMIN_PAGES.'support/');
26
+        define('EE_SUPPORT_ASSETS_URL', EE_ADMIN_PAGES_URL.'support/assets/');
27 27
         parent::__construct();
28 28
     }
29 29
 
Please login to merge, or discard this patch.
admin_pages/support/Support_Admin_Page.core.php 2 patches
Indentation   +238 added lines, -238 removed lines patch added patch discarded remove patch
@@ -13,242 +13,242 @@
 block discarded – undo
13 13
 {
14 14
 
15 15
 
16
-    protected function _init_page_props()
17
-    {
18
-        $this->page_slug = EE_SUPPORT_PG_SLUG;
19
-        $this->page_label = esc_html__('Help & Support', 'event_espresso');
20
-        $this->_admin_base_url = EE_SUPPORT_ADMIN_URL;
21
-        $this->_admin_base_path = EE_SUPPORT_ADMIN;
22
-    }
23
-
24
-
25
-    protected function _ajax_hooks()
26
-    {
27
-    }
28
-
29
-
30
-    protected function _define_page_props()
31
-    {
32
-        $this->_labels = array();
33
-        $this->_admin_page_title = $this->page_label;
34
-    }
35
-
36
-
37
-    protected function _set_page_routes()
38
-    {
39
-        $this->_page_routes = array(
40
-            'default'    => array(
41
-                'func'       => '_contact_support',
42
-                'capability' => 'ee_read_ee',
43
-            ),
44
-            'developers' => array(
45
-                'func'       => '_developers',
46
-                'capability' => 'ee_read_ee',
47
-            ),
48
-            'shortcodes' => array(
49
-                'func'       => '_shortcodes',
50
-                'capability' => 'ee_read_ee',
51
-            ),
52
-        );
53
-    }
54
-
55
-
56
-    protected function _set_page_config()
57
-    {
58
-        $this->_page_config = array(
59
-            'default'    => array(
60
-                'nav'           => array(
61
-                    'label' => esc_html__('Support', 'event_espresso'),
62
-                    'order' => 30,
63
-                ),
64
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_support_boxes')),
65
-                'require_nonce' => false,
66
-            ),
67
-            'developers' => array(
68
-                'nav'           => array(
69
-                    'label' => esc_html__('Developers', 'event_espresso'),
70
-                    'order' => 50,
71
-                ),
72
-                'metaboxes'     => $this->_default_espresso_metaboxes,
73
-                'require_nonce' => false,
74
-            ),
75
-            'shortcodes' => array(
76
-                'nav'           => array(
77
-                    'label' => esc_html__('Shortcodes', 'event_espresso'),
78
-                    'order' => 60,
79
-                ),
80
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_shortcodes_boxes')),
81
-                'require_nonce' => false,
82
-            ),
83
-        );
84
-    }
85
-
86
-
87
-    // none of the below group are currently used for Support pages
88
-    protected function _add_screen_options()
89
-    {
90
-    }
91
-
92
-
93
-    protected function _add_feature_pointers()
94
-    {
95
-    }
96
-
97
-
98
-    public function admin_init()
99
-    {
100
-    }
101
-
102
-
103
-    public function admin_notices()
104
-    {
105
-    }
106
-
107
-
108
-    public function admin_footer_scripts()
109
-    {
110
-    }
111
-
112
-
113
-    public function load_scripts_styles()
114
-    {
115
-    }
116
-
117
-
118
-    protected function _installation()
119
-    {
120
-        $template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'support_admin_details_installation.template.php';
121
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
122
-            $template_path,
123
-            '',
124
-            true
125
-        );
126
-        $this->display_admin_page_with_sidebar();
127
-    }
128
-
129
-
130
-    protected function _resources()
131
-    {
132
-        $this->display_admin_page_with_sidebar();
133
-    }
134
-
135
-
136
-    protected function _add_settings_metabox($box, $label, array $args)
137
-    {
138
-        add_meta_box(
139
-            "espresso_{$box}_settings",
140
-            $label,
141
-            function ($post, $metabox) {
142
-                echo EEH_Template::display_template(
143
-                    $metabox['args']['template_path'],
144
-                    $metabox['args']['template_args'],
145
-                    true
146
-                );
147
-            },
148
-            $this->_current_screen->id,
149
-            'normal',
150
-            'high',
151
-            apply_filters(
152
-                "FHEE__Support_Admin_Page___add_settings_metabox__{$box}_args_array",
153
-                $args
154
-            )
155
-        );
156
-    }
157
-
158
-
159
-    protected function _resources_boxes()
160
-    {
161
-        $boxes = apply_filters(
162
-            'FHEE__Support_Admin_Page___resources_boxes__boxes_array',
163
-            array(
164
-                'favorite_theme_developers' => esc_html__('Favorite Theme Developers', 'event_espresso'),
165
-                'highly_recommended_themes' => esc_html__('Highly Recommended Themes', 'event_espresso'),
166
-                'hire_developer'            => esc_html__('Hire a Developer', 'event_espresso'),
167
-                'partners'                  => esc_html__('Partners', 'event_espresso'),
168
-                'recommended_plugins'       => esc_html__('Recommended Plugins', 'event_espresso'),
169
-                'other_resources'           => esc_html__('Other Resources', 'event_espresso'),
170
-            )
171
-        );
172
-        foreach ($boxes as $box => $label) {
173
-            $this->_add_settings_metabox(
174
-                $box,
175
-                $label,
176
-                array(
177
-                    'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH . "support_admin_details_{$box}.template.php",
178
-                    'template_args' => $this->_template_args,
179
-                )
180
-            );
181
-        }
182
-    }
183
-
184
-
185
-    protected function _shortcodes()
186
-    {
187
-        $this->display_admin_page_with_sidebar();
188
-    }
189
-
190
-
191
-    protected function _shortcodes_boxes()
192
-    {
193
-        $boxes = apply_filters(
194
-            'FHEE__Support_Admin_Page___shortcodes_boxes__boxes_array',
195
-            array(
196
-                'shortcodes_event_listings'  => esc_html__('Event Listings', 'event_espresso'),
197
-                'shortcodes_ticket_selector' => esc_html__('Event Ticket Selector', 'event_espresso'),
198
-                'shortcodes_category'        => esc_html__('Event Categories', 'event_espresso'),
199
-                'shortcodes_attendee'        => esc_html__('Event Attendees', 'event_espresso')
200
-                /*'shortcodes_single_events' => esc_html__('Single Events', 'event_espresso'),*/
201
-                /*'shortcodes_attendee_listings' => esc_html__('Attendee Listings', 'event_espresso'),*/
202
-            )
203
-        );
204
-        foreach ($boxes as $box => $label) {
205
-            $this->_add_settings_metabox(
206
-                $box,
207
-                $label,
208
-                array(
209
-                    'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH . "support_admin_details_{$box}.template.php",
210
-                    'template_args' => $this->_template_args,
211
-                )
212
-            );
213
-        }
214
-    }
215
-
216
-
217
-    protected function _contact_support()
218
-    {
219
-        $this->display_admin_page_with_sidebar();
220
-    }
221
-
222
-
223
-    protected function _support_boxes()
224
-    {
225
-        $boxes = apply_filters(
226
-            'FHEE__Support_Admin_Page___support_boxes__boxes_array',
227
-            array(
228
-                'contact_support'       => esc_html__('Contact Support', 'event_espresso'),
229
-                'important_information' => esc_html__('Important Information', 'event_espresso'),
230
-            )
231
-        );
232
-        foreach ($boxes as $box => $label) {
233
-            $this->_add_settings_metabox(
234
-                $box,
235
-                $label,
236
-                array(
237
-                    'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH . "support_admin_details_{$box}.template.php",
238
-                    'template_args' => $this->_template_args,
239
-                )
240
-            );
241
-        }
242
-    }
243
-
244
-
245
-    protected function _developers()
246
-    {
247
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
248
-            EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'developers_admin_details.template.php',
249
-            array(),
250
-            true
251
-        );
252
-        $this->display_admin_page_with_sidebar();
253
-    }
16
+	protected function _init_page_props()
17
+	{
18
+		$this->page_slug = EE_SUPPORT_PG_SLUG;
19
+		$this->page_label = esc_html__('Help & Support', 'event_espresso');
20
+		$this->_admin_base_url = EE_SUPPORT_ADMIN_URL;
21
+		$this->_admin_base_path = EE_SUPPORT_ADMIN;
22
+	}
23
+
24
+
25
+	protected function _ajax_hooks()
26
+	{
27
+	}
28
+
29
+
30
+	protected function _define_page_props()
31
+	{
32
+		$this->_labels = array();
33
+		$this->_admin_page_title = $this->page_label;
34
+	}
35
+
36
+
37
+	protected function _set_page_routes()
38
+	{
39
+		$this->_page_routes = array(
40
+			'default'    => array(
41
+				'func'       => '_contact_support',
42
+				'capability' => 'ee_read_ee',
43
+			),
44
+			'developers' => array(
45
+				'func'       => '_developers',
46
+				'capability' => 'ee_read_ee',
47
+			),
48
+			'shortcodes' => array(
49
+				'func'       => '_shortcodes',
50
+				'capability' => 'ee_read_ee',
51
+			),
52
+		);
53
+	}
54
+
55
+
56
+	protected function _set_page_config()
57
+	{
58
+		$this->_page_config = array(
59
+			'default'    => array(
60
+				'nav'           => array(
61
+					'label' => esc_html__('Support', 'event_espresso'),
62
+					'order' => 30,
63
+				),
64
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_support_boxes')),
65
+				'require_nonce' => false,
66
+			),
67
+			'developers' => array(
68
+				'nav'           => array(
69
+					'label' => esc_html__('Developers', 'event_espresso'),
70
+					'order' => 50,
71
+				),
72
+				'metaboxes'     => $this->_default_espresso_metaboxes,
73
+				'require_nonce' => false,
74
+			),
75
+			'shortcodes' => array(
76
+				'nav'           => array(
77
+					'label' => esc_html__('Shortcodes', 'event_espresso'),
78
+					'order' => 60,
79
+				),
80
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_shortcodes_boxes')),
81
+				'require_nonce' => false,
82
+			),
83
+		);
84
+	}
85
+
86
+
87
+	// none of the below group are currently used for Support pages
88
+	protected function _add_screen_options()
89
+	{
90
+	}
91
+
92
+
93
+	protected function _add_feature_pointers()
94
+	{
95
+	}
96
+
97
+
98
+	public function admin_init()
99
+	{
100
+	}
101
+
102
+
103
+	public function admin_notices()
104
+	{
105
+	}
106
+
107
+
108
+	public function admin_footer_scripts()
109
+	{
110
+	}
111
+
112
+
113
+	public function load_scripts_styles()
114
+	{
115
+	}
116
+
117
+
118
+	protected function _installation()
119
+	{
120
+		$template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'support_admin_details_installation.template.php';
121
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
122
+			$template_path,
123
+			'',
124
+			true
125
+		);
126
+		$this->display_admin_page_with_sidebar();
127
+	}
128
+
129
+
130
+	protected function _resources()
131
+	{
132
+		$this->display_admin_page_with_sidebar();
133
+	}
134
+
135
+
136
+	protected function _add_settings_metabox($box, $label, array $args)
137
+	{
138
+		add_meta_box(
139
+			"espresso_{$box}_settings",
140
+			$label,
141
+			function ($post, $metabox) {
142
+				echo EEH_Template::display_template(
143
+					$metabox['args']['template_path'],
144
+					$metabox['args']['template_args'],
145
+					true
146
+				);
147
+			},
148
+			$this->_current_screen->id,
149
+			'normal',
150
+			'high',
151
+			apply_filters(
152
+				"FHEE__Support_Admin_Page___add_settings_metabox__{$box}_args_array",
153
+				$args
154
+			)
155
+		);
156
+	}
157
+
158
+
159
+	protected function _resources_boxes()
160
+	{
161
+		$boxes = apply_filters(
162
+			'FHEE__Support_Admin_Page___resources_boxes__boxes_array',
163
+			array(
164
+				'favorite_theme_developers' => esc_html__('Favorite Theme Developers', 'event_espresso'),
165
+				'highly_recommended_themes' => esc_html__('Highly Recommended Themes', 'event_espresso'),
166
+				'hire_developer'            => esc_html__('Hire a Developer', 'event_espresso'),
167
+				'partners'                  => esc_html__('Partners', 'event_espresso'),
168
+				'recommended_plugins'       => esc_html__('Recommended Plugins', 'event_espresso'),
169
+				'other_resources'           => esc_html__('Other Resources', 'event_espresso'),
170
+			)
171
+		);
172
+		foreach ($boxes as $box => $label) {
173
+			$this->_add_settings_metabox(
174
+				$box,
175
+				$label,
176
+				array(
177
+					'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH . "support_admin_details_{$box}.template.php",
178
+					'template_args' => $this->_template_args,
179
+				)
180
+			);
181
+		}
182
+	}
183
+
184
+
185
+	protected function _shortcodes()
186
+	{
187
+		$this->display_admin_page_with_sidebar();
188
+	}
189
+
190
+
191
+	protected function _shortcodes_boxes()
192
+	{
193
+		$boxes = apply_filters(
194
+			'FHEE__Support_Admin_Page___shortcodes_boxes__boxes_array',
195
+			array(
196
+				'shortcodes_event_listings'  => esc_html__('Event Listings', 'event_espresso'),
197
+				'shortcodes_ticket_selector' => esc_html__('Event Ticket Selector', 'event_espresso'),
198
+				'shortcodes_category'        => esc_html__('Event Categories', 'event_espresso'),
199
+				'shortcodes_attendee'        => esc_html__('Event Attendees', 'event_espresso')
200
+				/*'shortcodes_single_events' => esc_html__('Single Events', 'event_espresso'),*/
201
+				/*'shortcodes_attendee_listings' => esc_html__('Attendee Listings', 'event_espresso'),*/
202
+			)
203
+		);
204
+		foreach ($boxes as $box => $label) {
205
+			$this->_add_settings_metabox(
206
+				$box,
207
+				$label,
208
+				array(
209
+					'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH . "support_admin_details_{$box}.template.php",
210
+					'template_args' => $this->_template_args,
211
+				)
212
+			);
213
+		}
214
+	}
215
+
216
+
217
+	protected function _contact_support()
218
+	{
219
+		$this->display_admin_page_with_sidebar();
220
+	}
221
+
222
+
223
+	protected function _support_boxes()
224
+	{
225
+		$boxes = apply_filters(
226
+			'FHEE__Support_Admin_Page___support_boxes__boxes_array',
227
+			array(
228
+				'contact_support'       => esc_html__('Contact Support', 'event_espresso'),
229
+				'important_information' => esc_html__('Important Information', 'event_espresso'),
230
+			)
231
+		);
232
+		foreach ($boxes as $box => $label) {
233
+			$this->_add_settings_metabox(
234
+				$box,
235
+				$label,
236
+				array(
237
+					'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH . "support_admin_details_{$box}.template.php",
238
+					'template_args' => $this->_template_args,
239
+				)
240
+			);
241
+		}
242
+	}
243
+
244
+
245
+	protected function _developers()
246
+	{
247
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
248
+			EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'developers_admin_details.template.php',
249
+			array(),
250
+			true
251
+		);
252
+		$this->display_admin_page_with_sidebar();
253
+	}
254 254
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 
118 118
     protected function _installation()
119 119
     {
120
-        $template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'support_admin_details_installation.template.php';
120
+        $template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH.'support_admin_details_installation.template.php';
121 121
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
122 122
             $template_path,
123 123
             '',
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
         add_meta_box(
139 139
             "espresso_{$box}_settings",
140 140
             $label,
141
-            function ($post, $metabox) {
141
+            function($post, $metabox) {
142 142
                 echo EEH_Template::display_template(
143 143
                     $metabox['args']['template_path'],
144 144
                     $metabox['args']['template_args'],
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
                 $box,
175 175
                 $label,
176 176
                 array(
177
-                    'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH . "support_admin_details_{$box}.template.php",
177
+                    'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH."support_admin_details_{$box}.template.php",
178 178
                     'template_args' => $this->_template_args,
179 179
                 )
180 180
             );
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
                 $box,
207 207
                 $label,
208 208
                 array(
209
-                    'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH . "support_admin_details_{$box}.template.php",
209
+                    'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH."support_admin_details_{$box}.template.php",
210 210
                     'template_args' => $this->_template_args,
211 211
                 )
212 212
             );
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
                 $box,
235 235
                 $label,
236 236
                 array(
237
-                    'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH . "support_admin_details_{$box}.template.php",
237
+                    'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH."support_admin_details_{$box}.template.php",
238 238
                     'template_args' => $this->_template_args,
239 239
                 )
240 240
             );
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
     protected function _developers()
246 246
     {
247 247
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
248
-            EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'developers_admin_details.template.php',
248
+            EE_SUPPORT_ADMIN_TEMPLATE_PATH.'developers_admin_details.template.php',
249 249
             array(),
250 250
             true
251 251
         );
Please login to merge, or discard this patch.