Completed
Branch dependabot/npm_and_yarn/@wordp... (e9f48b)
by
unknown
60:52 queued 52:34
created
core/libraries/qtips/EE_Qtip_Config.lib.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -238,7 +238,7 @@
 block discarded – undo
238 238
      * return the _qtips property contents
239 239
      *
240 240
      * @access public
241
-     * @return EE_Qtip[]
241
+     * @return EE_Qtip
242 242
      */
243 243
     public function get_tips()
244 244
     {
Please login to merge, or discard this patch.
Indentation   +225 added lines, -225 removed lines patch added patch discarded remove patch
@@ -15,235 +15,235 @@  discard block
 block discarded – undo
15 15
 abstract class EE_Qtip_Config extends EE_Base
16 16
 {
17 17
 
18
-    /**
19
-     * This will hold the qtips setup array (setup by children)
20
-     *
21
-     * @access protected
22
-     * @var array
23
-     */
24
-    protected $_qtipsa;
18
+	/**
19
+	 * This will hold the qtips setup array (setup by children)
20
+	 *
21
+	 * @access protected
22
+	 * @var array
23
+	 */
24
+	protected $_qtipsa;
25 25
 
26 26
 
27
-    /**
28
-     * This holds the constructed EE_Qtip objects
29
-     *
30
-     * @access protected
31
-     * @var EE_Qtip
32
-     */
33
-    protected $_qtips;
27
+	/**
28
+	 * This holds the constructed EE_Qtip objects
29
+	 *
30
+	 * @access protected
31
+	 * @var EE_Qtip
32
+	 */
33
+	protected $_qtips;
34 34
 
35 35
 
36
-    /**
37
-     * an array of default options for instantiated qtip js objects
38
-     *
39
-     * @access protected
40
-     * @var array
41
-     */
42
-    protected $_default_options;
36
+	/**
37
+	 * an array of default options for instantiated qtip js objects
38
+	 *
39
+	 * @access protected
40
+	 * @var array
41
+	 */
42
+	protected $_default_options;
43 43
 
44 44
 
45
-    /**
46
-     * constructor
47
-     *
48
-     * @access public
49
-     */
50
-    public function __construct()
51
-    {
52
-        $this->_qtipsa = $this->_qtips = array();
53
-        $this->_set_default_options();
54
-        $this->_set_tips_array();
55
-        $this->_construct_tips();
56
-    }
45
+	/**
46
+	 * constructor
47
+	 *
48
+	 * @access public
49
+	 */
50
+	public function __construct()
51
+	{
52
+		$this->_qtipsa = $this->_qtips = array();
53
+		$this->_set_default_options();
54
+		$this->_set_tips_array();
55
+		$this->_construct_tips();
56
+	}
57 57
 
58 58
 
59
-    /**
60
-     * Children define this method and its purpose is to setup the $_qtipsa property.  The format of this property is:
61
-     *
62
-     * $qtipsa = array(
63
-     *        0 => array(
64
-     *            'content_id' => 'some_unique_id_for_referencing_content', //just the string
65
-     *            'content' => 'html/text content for the qtip',
66
-     *            'target' => '#target-element', //use the same schema as jQuery selectors.  This will match what the
67
-     *            target is for the qTip in the dom (i.e. if class then '.some-class').
68
-     *            'options' => array() //use this to override any of the default options for this specific qtip.
69
-     *        )
70
-     * );
71
-     *
72
-     * @abstract
73
-     * @access protected
74
-     * @return void
75
-     */
76
-    abstract protected function _set_tips_array();
59
+	/**
60
+	 * Children define this method and its purpose is to setup the $_qtipsa property.  The format of this property is:
61
+	 *
62
+	 * $qtipsa = array(
63
+	 *        0 => array(
64
+	 *            'content_id' => 'some_unique_id_for_referencing_content', //just the string
65
+	 *            'content' => 'html/text content for the qtip',
66
+	 *            'target' => '#target-element', //use the same schema as jQuery selectors.  This will match what the
67
+	 *            target is for the qTip in the dom (i.e. if class then '.some-class').
68
+	 *            'options' => array() //use this to override any of the default options for this specific qtip.
69
+	 *        )
70
+	 * );
71
+	 *
72
+	 * @abstract
73
+	 * @access protected
74
+	 * @return void
75
+	 */
76
+	abstract protected function _set_tips_array();
77 77
 
78 78
 
79
-    /**
80
-     * all the default options for the qtip js are defined here.  Children class can override the defaults for all the
81
-     * qtips defined in their config OR just leave it and have the parent default options apply.
82
-     *
83
-     * commented out options are there for reference so you know which can be defined by the child.
84
-     *
85
-     * Note: children do NOT have to define all these options.  Just define the ones to override.
86
-     *
87
-     * @link   http://qtip2.com/options
88
-     *
89
-     * @access protected
90
-     * @return void
91
-     */
92
-    protected function _set_default_options()
93
-    {
94
-        $this->_default_options = array(
95
-            // 'id' => 'unique_id_referncing_qtip_instance',
96
-            'prerender'      => false,
97
-            // increases page load if true,
98
-            'suppress'       => true,
99
-            // whether default browser tooltips are suppressed.
100
-            'content'        => array(
101
-                'button' => false,
102
-                // what you want for the close button text/link.
103
-                'title'  => true,
104
-                // Options: "string", true.  If TRUE then the title attribute of the target will be used (if available). If "string" then we'll use that as the title.
105
-                'clone'  => true,
106
-                // Options: true|false.  if true then the text will be cloned from the content instead of removed from the dom.
107
-            ),
108
-            'show_only_once' => false,
109
-            // this is NOT a qtip2 library option, but is something added for EE specific use.  If set to true, this means that this particular tooltip will only show ONCE for the user and then a cookie will be saved so that it doesn't show again (after exit).
110
-            'position'       => array(
111
-                'my'        => 'top left',
112
-                // top left || top center || top right || right top || right center || right bottom || bottom right || bottom center || bottom left || left bottom || left center || left top
113
-                'at'        => 'bottom right',
114
-                // same options as above.
115
-                'target'    => 'event',
116
-                // if u use jQuery::#selector, js will parse to a jQuery selector || 'mouse' (at mouse cursor position) || 'event' (position at target that triggered the tooltip), or an array containing an absolute x/y position on page.
117
-                'container' => false,
118
-                // what HTML element the tooltip is appended to (it's containing element). jquery object.  Use 'jQuery::#selector' and js will parse'
119
-                'viewport'  => true,
120
-                // @link http://qtip2.com/plugins#viewport
121
-                'adjust'    => array(
122
-                    'x'      => 0,
123
-                    // adjust position on x axis by 0 pixels.
124
-                    'y'      => 0,
125
-                    // adjust position on y axis by 0 pixels.
126
-                    'mouse'  => true,
127
-                    // when position['target'] is set to 'mouse', tooltip will follow mouse when hovering over the target.  False, stops following.
128
-                    'resize' => true,
129
-                    // adjust tooltip position when window is resized.
130
-                    'scroll' => true,
131
-                    // position of tooltip adjusted when window (or position.container) is scrolled.
132
-                    'method' => 'flipinvert',
133
-                    // @link http://qtip2.com/plugins#viewport
134
-                ),
135
-            ),
136
-            'show'           => array(
137
-                'event'  => 'mouseenter',
138
-                // what event triggers tooltip to be shown.  Any jQuery standard event or custom events can be used. space separated events provide multiple triggers.
139
-                'target' => false,
140
-                // options jQuery::#selector|false.  Used to indicate which html element will trigger show event.  When false, the element the qtip() method was called upon is used.
141
-                'delay'  => 90,
142
-                // time in millisecons by which to delay showing of tooltip.
143
-                'solo'   => false,
144
-                // determines whether tooltip will hid all others when triggered. Options: true (hide all) || false (ignore) || string (parent selector for which qtips get hidden)
145
-                'modal'  => array(
146
-                    'on'         => false, // does tooltip trigger modal?
147
-                    'blur'       => true, // does clicking on the dimmed background hide the tooltip and remove the dim?
148
-                    'escape'     => true, // hitting escape key hide the tooltip and cancel modal
149
-                    'stealfocus' => true, // can users focus on inputs and elelments outside of tooltip when modal on?
150
-                ),
151
-            ),
152
-            'hide'           => array(
153
-                'event'    => 'mouseleave',
154
-                // similar as what you do for show.event.
155
-                'target'   => false,
156
-                // Options jQuery::#selector. which html element will trigger hide event. When false, the element the .qtip() method was called upon is used.
157
-                'delay'    => 0,
158
-                // set time in milliseconds for delaying the hide of the tooltip
159
-                'inactive' => false,
160
-                // if integer, time in millisecons in which the tooltip should be hidden if remains inactive (not interacted with)
161
-                'fixed'    => false,
162
-                // when set to true, the tooltip will not hide if moused over.
163
-                'leave'    => 'window',
164
-                // specify whether the tooltip will hide when leaving the window it's conained within.
165
-                'distance' => false,
166
-                // if integer, distance in pixels that the tooltip hides when the mouse is moved from the point it triggered the tooltip.
167
-            ),
168
-            'style'          => array(
169
-                'classes' => 'qtip-tipsy',
170
-                // Options "string", false.  A space separated string containing all class names which should be added ot the main qTip element. See options for styles in comment block at end of this class.
171
-                'def'     => true,
172
-                // set to false and the default qtip class does not get applied
173
-                'widget'  => false,
174
-                // whether ui-widget classes of the themeroller UI styles are applied to tooltip.
175
-                'width'   => false,
176
-                // Options: "string", integer, false.  with this you can override all applied CSS width styles for tooltip.  Can be any valid width CSS value. (does not override min/max width styles)
177
-                'height'  => false,
178
-                // same as above except applies to height.
179
-                'tip'     => array(
180
-                    'corner' => true,
181
-                    // where in relation to the tooltip the speech bubble tip is applied. Options: true, "corner string" (see position), false.  true inherits
182
-                    'mimic'  => false,
183
-                    // see documentation @link http://qtip2.com/plugins#tips
184
-                    'border' => true,
185
-                    // Options: true, integer. determines the width of the border that surrounds the tip element.  True inherits from tooltip.
186
-                    'width'  => 6,
187
-                    // width of rendered tip in pixels in relation to the side of the tooltip the tip is on.
188
-                    'height' => 6,
189
-                    // works the same as tip.width
190
-                    'offset' => 0,
191
-                    // use to set the offset of the tip in relation to its corner position.
192
-                ),
193
-            ),
79
+	/**
80
+	 * all the default options for the qtip js are defined here.  Children class can override the defaults for all the
81
+	 * qtips defined in their config OR just leave it and have the parent default options apply.
82
+	 *
83
+	 * commented out options are there for reference so you know which can be defined by the child.
84
+	 *
85
+	 * Note: children do NOT have to define all these options.  Just define the ones to override.
86
+	 *
87
+	 * @link   http://qtip2.com/options
88
+	 *
89
+	 * @access protected
90
+	 * @return void
91
+	 */
92
+	protected function _set_default_options()
93
+	{
94
+		$this->_default_options = array(
95
+			// 'id' => 'unique_id_referncing_qtip_instance',
96
+			'prerender'      => false,
97
+			// increases page load if true,
98
+			'suppress'       => true,
99
+			// whether default browser tooltips are suppressed.
100
+			'content'        => array(
101
+				'button' => false,
102
+				// what you want for the close button text/link.
103
+				'title'  => true,
104
+				// Options: "string", true.  If TRUE then the title attribute of the target will be used (if available). If "string" then we'll use that as the title.
105
+				'clone'  => true,
106
+				// Options: true|false.  if true then the text will be cloned from the content instead of removed from the dom.
107
+			),
108
+			'show_only_once' => false,
109
+			// this is NOT a qtip2 library option, but is something added for EE specific use.  If set to true, this means that this particular tooltip will only show ONCE for the user and then a cookie will be saved so that it doesn't show again (after exit).
110
+			'position'       => array(
111
+				'my'        => 'top left',
112
+				// top left || top center || top right || right top || right center || right bottom || bottom right || bottom center || bottom left || left bottom || left center || left top
113
+				'at'        => 'bottom right',
114
+				// same options as above.
115
+				'target'    => 'event',
116
+				// if u use jQuery::#selector, js will parse to a jQuery selector || 'mouse' (at mouse cursor position) || 'event' (position at target that triggered the tooltip), or an array containing an absolute x/y position on page.
117
+				'container' => false,
118
+				// what HTML element the tooltip is appended to (it's containing element). jquery object.  Use 'jQuery::#selector' and js will parse'
119
+				'viewport'  => true,
120
+				// @link http://qtip2.com/plugins#viewport
121
+				'adjust'    => array(
122
+					'x'      => 0,
123
+					// adjust position on x axis by 0 pixels.
124
+					'y'      => 0,
125
+					// adjust position on y axis by 0 pixels.
126
+					'mouse'  => true,
127
+					// when position['target'] is set to 'mouse', tooltip will follow mouse when hovering over the target.  False, stops following.
128
+					'resize' => true,
129
+					// adjust tooltip position when window is resized.
130
+					'scroll' => true,
131
+					// position of tooltip adjusted when window (or position.container) is scrolled.
132
+					'method' => 'flipinvert',
133
+					// @link http://qtip2.com/plugins#viewport
134
+				),
135
+			),
136
+			'show'           => array(
137
+				'event'  => 'mouseenter',
138
+				// what event triggers tooltip to be shown.  Any jQuery standard event or custom events can be used. space separated events provide multiple triggers.
139
+				'target' => false,
140
+				// options jQuery::#selector|false.  Used to indicate which html element will trigger show event.  When false, the element the qtip() method was called upon is used.
141
+				'delay'  => 90,
142
+				// time in millisecons by which to delay showing of tooltip.
143
+				'solo'   => false,
144
+				// determines whether tooltip will hid all others when triggered. Options: true (hide all) || false (ignore) || string (parent selector for which qtips get hidden)
145
+				'modal'  => array(
146
+					'on'         => false, // does tooltip trigger modal?
147
+					'blur'       => true, // does clicking on the dimmed background hide the tooltip and remove the dim?
148
+					'escape'     => true, // hitting escape key hide the tooltip and cancel modal
149
+					'stealfocus' => true, // can users focus on inputs and elelments outside of tooltip when modal on?
150
+				),
151
+			),
152
+			'hide'           => array(
153
+				'event'    => 'mouseleave',
154
+				// similar as what you do for show.event.
155
+				'target'   => false,
156
+				// Options jQuery::#selector. which html element will trigger hide event. When false, the element the .qtip() method was called upon is used.
157
+				'delay'    => 0,
158
+				// set time in milliseconds for delaying the hide of the tooltip
159
+				'inactive' => false,
160
+				// if integer, time in millisecons in which the tooltip should be hidden if remains inactive (not interacted with)
161
+				'fixed'    => false,
162
+				// when set to true, the tooltip will not hide if moused over.
163
+				'leave'    => 'window',
164
+				// specify whether the tooltip will hide when leaving the window it's conained within.
165
+				'distance' => false,
166
+				// if integer, distance in pixels that the tooltip hides when the mouse is moved from the point it triggered the tooltip.
167
+			),
168
+			'style'          => array(
169
+				'classes' => 'qtip-tipsy',
170
+				// Options "string", false.  A space separated string containing all class names which should be added ot the main qTip element. See options for styles in comment block at end of this class.
171
+				'def'     => true,
172
+				// set to false and the default qtip class does not get applied
173
+				'widget'  => false,
174
+				// whether ui-widget classes of the themeroller UI styles are applied to tooltip.
175
+				'width'   => false,
176
+				// Options: "string", integer, false.  with this you can override all applied CSS width styles for tooltip.  Can be any valid width CSS value. (does not override min/max width styles)
177
+				'height'  => false,
178
+				// same as above except applies to height.
179
+				'tip'     => array(
180
+					'corner' => true,
181
+					// where in relation to the tooltip the speech bubble tip is applied. Options: true, "corner string" (see position), false.  true inherits
182
+					'mimic'  => false,
183
+					// see documentation @link http://qtip2.com/plugins#tips
184
+					'border' => true,
185
+					// Options: true, integer. determines the width of the border that surrounds the tip element.  True inherits from tooltip.
186
+					'width'  => 6,
187
+					// width of rendered tip in pixels in relation to the side of the tooltip the tip is on.
188
+					'height' => 6,
189
+					// works the same as tip.width
190
+					'offset' => 0,
191
+					// use to set the offset of the tip in relation to its corner position.
192
+				),
193
+			),
194 194
 
195
-        );
196
-    }
195
+		);
196
+	}
197 197
 
198 198
 
199
-    /**
200
-     * This takes the set $_qtipsa array property and loops through it to set the EE_Qtip objects and assign them to
201
-     * the $_qtips property
202
-     *
203
-     * @access protected
204
-     * @return void
205
-     */
206
-    protected function _construct_tips()
207
-    {
208
-        foreach ($this->_qtipsa as $qt) {
209
-            // make sure we have what we need.
210
-            if (! isset($qt['content_id']) || ! isset($qt['target']) || ! isset($qt['content'])) {
211
-                throw new EE_Error(
212
-                    sprintf(
213
-                        __(
214
-                            'There is something wrong with the _qtipsa property setup for the %s qtip config class.  The dump of the current array index is: %s.<br /><br />Please check that it is setup correctly.',
215
-                            'event_espresso'
216
-                        ),
217
-                        get_class($this),
218
-                        var_export($qt, true)
219
-                    )
220
-                );
221
-            }
199
+	/**
200
+	 * This takes the set $_qtipsa array property and loops through it to set the EE_Qtip objects and assign them to
201
+	 * the $_qtips property
202
+	 *
203
+	 * @access protected
204
+	 * @return void
205
+	 */
206
+	protected function _construct_tips()
207
+	{
208
+		foreach ($this->_qtipsa as $qt) {
209
+			// make sure we have what we need.
210
+			if (! isset($qt['content_id']) || ! isset($qt['target']) || ! isset($qt['content'])) {
211
+				throw new EE_Error(
212
+					sprintf(
213
+						__(
214
+							'There is something wrong with the _qtipsa property setup for the %s qtip config class.  The dump of the current array index is: %s.<br /><br />Please check that it is setup correctly.',
215
+							'event_espresso'
216
+						),
217
+						get_class($this),
218
+						var_export($qt, true)
219
+					)
220
+				);
221
+			}
222 222
 
223
-            // make sure the options include defaults and just override via set config.
224
-            $options_override = isset($qt['options']) ? (array) $qt['options'] : array();
225
-            $options = array_merge($this->_default_options, $options_override);
226
-            $setup = array(
227
-                'content_id' => $qt['content_id'],
228
-                'options'    => $options,
229
-                'target'     => $qt['target'],
230
-                'content'    => $qt['content'],
231
-            );
232
-            $this->_qtips[] = new EE_Qtip($setup);
233
-        }
234
-    }
223
+			// make sure the options include defaults and just override via set config.
224
+			$options_override = isset($qt['options']) ? (array) $qt['options'] : array();
225
+			$options = array_merge($this->_default_options, $options_override);
226
+			$setup = array(
227
+				'content_id' => $qt['content_id'],
228
+				'options'    => $options,
229
+				'target'     => $qt['target'],
230
+				'content'    => $qt['content'],
231
+			);
232
+			$this->_qtips[] = new EE_Qtip($setup);
233
+		}
234
+	}
235 235
 
236 236
 
237
-    /**
238
-     * return the _qtips property contents
239
-     *
240
-     * @access public
241
-     * @return EE_Qtip[]
242
-     */
243
-    public function get_tips()
244
-    {
245
-        return $this->_qtips;
246
-    }
237
+	/**
238
+	 * return the _qtips property contents
239
+	 *
240
+	 * @access public
241
+	 * @return EE_Qtip[]
242
+	 */
243
+	public function get_tips()
244
+	{
245
+		return $this->_qtips;
246
+	}
247 247
 }
248 248
 
249 249
 // class names you can use for tooltip styles
@@ -295,17 +295,17 @@  discard block
 block discarded – undo
295 295
  */
296 296
 class EE_Qtip extends EE_Base
297 297
 {
298
-    public $content_id;
299
-    public $options;
300
-    public $target;
301
-    public $content;
298
+	public $content_id;
299
+	public $options;
300
+	public $target;
301
+	public $content;
302 302
 
303
-    public function __construct($setup_array)
304
-    {
305
-        foreach ($setup_array as $prop => $value) {
306
-            if (EEH_Class_Tools::has_property($this, $prop)) {
307
-                $this->{$prop} = $value;
308
-            }
309
-        }
310
-    }
303
+	public function __construct($setup_array)
304
+	{
305
+		foreach ($setup_array as $prop => $value) {
306
+			if (EEH_Class_Tools::has_property($this, $prop)) {
307
+				$this->{$prop} = $value;
308
+			}
309
+		}
310
+	}
311 311
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -207,7 +207,7 @@
 block discarded – undo
207 207
     {
208 208
         foreach ($this->_qtipsa as $qt) {
209 209
             // make sure we have what we need.
210
-            if (! isset($qt['content_id']) || ! isset($qt['target']) || ! isset($qt['content'])) {
210
+            if ( ! isset($qt['content_id']) || ! isset($qt['target']) || ! isset($qt['content'])) {
211 211
                 throw new EE_Error(
212 212
                     sprintf(
213 213
                         __(
Please login to merge, or discard this patch.
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   +272 added lines, -272 removed lines patch added patch discarded remove patch
@@ -19,276 +19,276 @@
 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_*]'                          => __(
105
-                '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.',
106
-                'event_espresso'
107
-            ),
108
-            '[REGISTRATION_LIST_TABLE_FOR_EVENT_URL]' => __(
109
-                'This parses to the url for the registration list table filtered by registrations for this event.',
110
-                'event_espresso'
111
-            ),
112
-        );
113
-    }
114
-
115
-
116
-    protected function _parser($shortcode)
117
-    {
118
-
119
-
120
-        $this->_event = $this->_data instanceof EE_Event ? $this->_data : null;
121
-
122
-        // 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.
123
-        if (empty($this->_event)) {
124
-            $aee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null;
125
-            $aee = $this->_extra_data instanceof EE_Messages_Addressee ? $this->_extra_data : $aee;
126
-
127
-            $this->_event = $aee instanceof EE_Messages_Addressee && $aee->reg_obj instanceof EE_Registration
128
-                ? $aee->reg_obj->event() : null;
129
-        }
130
-
131
-
132
-        // If there is no event objecdt by now then get out.
133
-        if (! $this->_event instanceof EE_Event) {
134
-            return '';
135
-        }
136
-
137
-        switch ($shortcode) {
138
-            case '[EVENT_ID]':
139
-                return $this->_event->ID();
140
-                break;
141
-
142
-            case '[EVENT]':
143
-            case '[EVENT_NAME]':
144
-                return $this->_event->get('EVT_name');
145
-                break;
146
-
147
-            case '[EVENT_PHONE]':
148
-                return $this->_event->get('EVT_phone');
149
-                break;
150
-
151
-            case '[EVENT_DESCRIPTION]':
152
-                return $this->_event->get('EVT_desc');
153
-                break;
154
-
155
-            case '[EVENT_EXCERPT]':
156
-                return $this->_event->get('EVT_short_desc');
157
-                break;
158
-
159
-            case '[EVENT_LINK]':
160
-                return $this->_get_event_link($this->_event);
161
-                break;
162
-
163
-            case '[EVENT_URL]':
164
-                return $this->_get_event_link($this->_event, false);
165
-                break;
166
-
167
-            case '[VIRTUAL_URL]':
168
-                $venue = $this->_event->get_first_related('Venue');
169
-                if (empty($venue)) {
170
-                    return '';
171
-                }
172
-                return $venue->get('VNU_virtual_url');
173
-
174
-            case '[VIRTUAL_PHONE]':
175
-                $venue = $this->_event->get_first_related('Venue');
176
-                if (empty($venue)) {
177
-                    return '';
178
-                }
179
-                return $venue->get('VNU_virtual_phone');
180
-                break;
181
-
182
-            case '[EVENT_IMAGE]':
183
-                $image = $this->_event->feature_image_url(array(600, 300));
184
-                // @todo: eventually we should make this an attribute shortcode so that em can send along what size they want returned.
185
-                return ! empty($image)
186
-                    ? '<img src="' . $image . '" alt="'
187
-                      . sprintf(
188
-                          esc_attr__('%s Feature Image', 'event_espresso'),
189
-                          $this->_event->get('EVT_name')
190
-                      ) . '" />'
191
-                    : '';
192
-                break;
193
-
194
-            case '[EVENT_FACEBOOK_URL]':
195
-                $facebook_url = $this->_event->get_post_meta('event_facebook', true);
196
-                return empty($facebook_url) ? EE_Registry::instance()->CFG->organization->get_pretty('facebook')
197
-                    : $facebook_url;
198
-                break;
199
-
200
-            case '[EVENT_TWITTER_URL]':
201
-                $twitter_url = $this->_event->get_post_meta('event_twitter', true);
202
-                return empty($twitter_url) ? EE_Registry::instance()->CFG->organization->get_pretty('twitter')
203
-                    : $twitter_url;
204
-                break;
205
-
206
-            case '[EVENT_AUTHOR_EMAIL]':
207
-                $author_id = $this->_event->get('EVT_wp_user');
208
-                $user_data = get_userdata((int) $author_id);
209
-                return $user_data->user_email;
210
-                break;
211
-
212
-            case '[EVENT_TOTAL_SPOTS_TAKEN]':
213
-                return EEM_Registration::instance()->count(
214
-                    array(array('EVT_ID' => $this->_event->ID(), 'STS_ID' => EEM_Registration::status_id_approved)),
215
-                    'REG_ID',
216
-                    true
217
-                );
218
-                break;
219
-
220
-            case '[REGISTRATION_LIST_TABLE_FOR_EVENT_URL]':
221
-                return EEH_URL::add_query_args_and_nonce(
222
-                    array(
223
-                        'event_id' => $this->_event->ID(),
224
-                        'page'     => 'espresso_registrations',
225
-                        'action'   => 'default',
226
-                    ),
227
-                    admin_url('admin.php'),
228
-                    true
229
-                );
230
-                break;
231
-        }
232
-
233
-        if (strpos($shortcode, '[EVENT_META_*') !== false) {
234
-            $shortcode = str_replace('[EVENT_META_*', '', $shortcode);
235
-            $shortcode = trim(str_replace(']', '', $shortcode));
236
-
237
-            // pull the meta value from the event post
238
-            $event_meta = $this->_event->get_post_meta($shortcode, true);
239
-
240
-            return ! empty($event_meta) ? $this->_event->get_post_meta($shortcode, true) : '';
241
-        }
242
-
243
-        if (strpos($shortcode, '[EVENT_TOTAL_AVAILABLE_SPACES_*') !== false) {
244
-            $attrs = $this->_get_shortcode_attrs($shortcode);
245
-            $method = empty($attrs['method']) ? 'current' : $attrs['method'];
246
-            $method = $method === 'current';
247
-            $available = $this->_event->total_available_spaces($method);
248
-            return $available === EE_INF ? '&infin;' : $available;
249
-        }
250
-
251
-        if (strpos($shortcode, '[EVENT_IMAGE_*') !== false) {
252
-            $attrs = $this->_get_shortcode_attrs($shortcode);
253
-            $width = empty($attrs['width']) ? '' : ' width="' . $attrs['width'] . '"';
254
-            $height = empty($attrs['height']) ? '' : ' height="' . $attrs['height'] . '"';
255
-
256
-            // Size may be set to a string such as 'tumbnail' or "width, height" eg - '200,200'
257
-            if (! empty($attrs['size'])) {
258
-                $size = explode(',', $attrs['size']);
259
-                if (count($size) === 1) {
260
-                    $size = $size[0];
261
-                }
262
-            } else {
263
-                $size = 'thumbnail';
264
-            }
265
-
266
-            $image = $this->_event->feature_image_url($size);
267
-
268
-            return ! empty($image)
269
-                ? '<img src="' . $image . '" alt="'
270
-                  . sprintf(
271
-                      esc_attr__('%s Feature Image', 'event_espresso'),
272
-                      $this->_event->get('EVT_name')
273
-                  ) . '"' . $width . $height . '/>'
274
-                : '';
275
-        }
276
-
277
-        return '';
278
-    }
279
-
280
-
281
-    /**
282
-     * returns the link to the event
283
-     *
284
-     * @param  boolean $full_link if TRUE (default) we return the html for the name of the event linked to the event.
285
-     *                            Otherwise we just return the url of the event.
286
-     * @return string
287
-     */
288
-    private function _get_event_link($event, $full_link = true)
289
-    {
290
-        $url = get_permalink($event->ID());
291
-
292
-        return $full_link ? '<a href="' . $url . '">' . $event->get('EVT_name') . '</a>' : $url;
293
-    }
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_*]'                          => __(
105
+				'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.',
106
+				'event_espresso'
107
+			),
108
+			'[REGISTRATION_LIST_TABLE_FOR_EVENT_URL]' => __(
109
+				'This parses to the url for the registration list table filtered by registrations for this event.',
110
+				'event_espresso'
111
+			),
112
+		);
113
+	}
114
+
115
+
116
+	protected function _parser($shortcode)
117
+	{
118
+
119
+
120
+		$this->_event = $this->_data instanceof EE_Event ? $this->_data : null;
121
+
122
+		// 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.
123
+		if (empty($this->_event)) {
124
+			$aee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null;
125
+			$aee = $this->_extra_data instanceof EE_Messages_Addressee ? $this->_extra_data : $aee;
126
+
127
+			$this->_event = $aee instanceof EE_Messages_Addressee && $aee->reg_obj instanceof EE_Registration
128
+				? $aee->reg_obj->event() : null;
129
+		}
130
+
131
+
132
+		// If there is no event objecdt by now then get out.
133
+		if (! $this->_event instanceof EE_Event) {
134
+			return '';
135
+		}
136
+
137
+		switch ($shortcode) {
138
+			case '[EVENT_ID]':
139
+				return $this->_event->ID();
140
+				break;
141
+
142
+			case '[EVENT]':
143
+			case '[EVENT_NAME]':
144
+				return $this->_event->get('EVT_name');
145
+				break;
146
+
147
+			case '[EVENT_PHONE]':
148
+				return $this->_event->get('EVT_phone');
149
+				break;
150
+
151
+			case '[EVENT_DESCRIPTION]':
152
+				return $this->_event->get('EVT_desc');
153
+				break;
154
+
155
+			case '[EVENT_EXCERPT]':
156
+				return $this->_event->get('EVT_short_desc');
157
+				break;
158
+
159
+			case '[EVENT_LINK]':
160
+				return $this->_get_event_link($this->_event);
161
+				break;
162
+
163
+			case '[EVENT_URL]':
164
+				return $this->_get_event_link($this->_event, false);
165
+				break;
166
+
167
+			case '[VIRTUAL_URL]':
168
+				$venue = $this->_event->get_first_related('Venue');
169
+				if (empty($venue)) {
170
+					return '';
171
+				}
172
+				return $venue->get('VNU_virtual_url');
173
+
174
+			case '[VIRTUAL_PHONE]':
175
+				$venue = $this->_event->get_first_related('Venue');
176
+				if (empty($venue)) {
177
+					return '';
178
+				}
179
+				return $venue->get('VNU_virtual_phone');
180
+				break;
181
+
182
+			case '[EVENT_IMAGE]':
183
+				$image = $this->_event->feature_image_url(array(600, 300));
184
+				// @todo: eventually we should make this an attribute shortcode so that em can send along what size they want returned.
185
+				return ! empty($image)
186
+					? '<img src="' . $image . '" alt="'
187
+					  . sprintf(
188
+						  esc_attr__('%s Feature Image', 'event_espresso'),
189
+						  $this->_event->get('EVT_name')
190
+					  ) . '" />'
191
+					: '';
192
+				break;
193
+
194
+			case '[EVENT_FACEBOOK_URL]':
195
+				$facebook_url = $this->_event->get_post_meta('event_facebook', true);
196
+				return empty($facebook_url) ? EE_Registry::instance()->CFG->organization->get_pretty('facebook')
197
+					: $facebook_url;
198
+				break;
199
+
200
+			case '[EVENT_TWITTER_URL]':
201
+				$twitter_url = $this->_event->get_post_meta('event_twitter', true);
202
+				return empty($twitter_url) ? EE_Registry::instance()->CFG->organization->get_pretty('twitter')
203
+					: $twitter_url;
204
+				break;
205
+
206
+			case '[EVENT_AUTHOR_EMAIL]':
207
+				$author_id = $this->_event->get('EVT_wp_user');
208
+				$user_data = get_userdata((int) $author_id);
209
+				return $user_data->user_email;
210
+				break;
211
+
212
+			case '[EVENT_TOTAL_SPOTS_TAKEN]':
213
+				return EEM_Registration::instance()->count(
214
+					array(array('EVT_ID' => $this->_event->ID(), 'STS_ID' => EEM_Registration::status_id_approved)),
215
+					'REG_ID',
216
+					true
217
+				);
218
+				break;
219
+
220
+			case '[REGISTRATION_LIST_TABLE_FOR_EVENT_URL]':
221
+				return EEH_URL::add_query_args_and_nonce(
222
+					array(
223
+						'event_id' => $this->_event->ID(),
224
+						'page'     => 'espresso_registrations',
225
+						'action'   => 'default',
226
+					),
227
+					admin_url('admin.php'),
228
+					true
229
+				);
230
+				break;
231
+		}
232
+
233
+		if (strpos($shortcode, '[EVENT_META_*') !== false) {
234
+			$shortcode = str_replace('[EVENT_META_*', '', $shortcode);
235
+			$shortcode = trim(str_replace(']', '', $shortcode));
236
+
237
+			// pull the meta value from the event post
238
+			$event_meta = $this->_event->get_post_meta($shortcode, true);
239
+
240
+			return ! empty($event_meta) ? $this->_event->get_post_meta($shortcode, true) : '';
241
+		}
242
+
243
+		if (strpos($shortcode, '[EVENT_TOTAL_AVAILABLE_SPACES_*') !== false) {
244
+			$attrs = $this->_get_shortcode_attrs($shortcode);
245
+			$method = empty($attrs['method']) ? 'current' : $attrs['method'];
246
+			$method = $method === 'current';
247
+			$available = $this->_event->total_available_spaces($method);
248
+			return $available === EE_INF ? '&infin;' : $available;
249
+		}
250
+
251
+		if (strpos($shortcode, '[EVENT_IMAGE_*') !== false) {
252
+			$attrs = $this->_get_shortcode_attrs($shortcode);
253
+			$width = empty($attrs['width']) ? '' : ' width="' . $attrs['width'] . '"';
254
+			$height = empty($attrs['height']) ? '' : ' height="' . $attrs['height'] . '"';
255
+
256
+			// Size may be set to a string such as 'tumbnail' or "width, height" eg - '200,200'
257
+			if (! empty($attrs['size'])) {
258
+				$size = explode(',', $attrs['size']);
259
+				if (count($size) === 1) {
260
+					$size = $size[0];
261
+				}
262
+			} else {
263
+				$size = 'thumbnail';
264
+			}
265
+
266
+			$image = $this->_event->feature_image_url($size);
267
+
268
+			return ! empty($image)
269
+				? '<img src="' . $image . '" alt="'
270
+				  . sprintf(
271
+					  esc_attr__('%s Feature Image', 'event_espresso'),
272
+					  $this->_event->get('EVT_name')
273
+				  ) . '"' . $width . $height . '/>'
274
+				: '';
275
+		}
276
+
277
+		return '';
278
+	}
279
+
280
+
281
+	/**
282
+	 * returns the link to the event
283
+	 *
284
+	 * @param  boolean $full_link if TRUE (default) we return the html for the name of the event linked to the event.
285
+	 *                            Otherwise we just return the url of the event.
286
+	 * @return string
287
+	 */
288
+	private function _get_event_link($event, $full_link = true)
289
+	{
290
+		$url = get_permalink($event->ID());
291
+
292
+		return $full_link ? '<a href="' . $url . '">' . $event->get('EVT_name') . '</a>' : $url;
293
+	}
294 294
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 
131 131
 
132 132
         // If there is no event objecdt by now then get out.
133
-        if (! $this->_event instanceof EE_Event) {
133
+        if ( ! $this->_event instanceof EE_Event) {
134 134
             return '';
135 135
         }
136 136
 
@@ -183,11 +183,11 @@  discard block
 block discarded – undo
183 183
                 $image = $this->_event->feature_image_url(array(600, 300));
184 184
                 // @todo: eventually we should make this an attribute shortcode so that em can send along what size they want returned.
185 185
                 return ! empty($image)
186
-                    ? '<img src="' . $image . '" alt="'
186
+                    ? '<img src="'.$image.'" alt="'
187 187
                       . sprintf(
188 188
                           esc_attr__('%s Feature Image', 'event_espresso'),
189 189
                           $this->_event->get('EVT_name')
190
-                      ) . '" />'
190
+                      ).'" />'
191 191
                     : '';
192 192
                 break;
193 193
 
@@ -250,11 +250,11 @@  discard block
 block discarded – undo
250 250
 
251 251
         if (strpos($shortcode, '[EVENT_IMAGE_*') !== false) {
252 252
             $attrs = $this->_get_shortcode_attrs($shortcode);
253
-            $width = empty($attrs['width']) ? '' : ' width="' . $attrs['width'] . '"';
254
-            $height = empty($attrs['height']) ? '' : ' height="' . $attrs['height'] . '"';
253
+            $width = empty($attrs['width']) ? '' : ' width="'.$attrs['width'].'"';
254
+            $height = empty($attrs['height']) ? '' : ' height="'.$attrs['height'].'"';
255 255
 
256 256
             // Size may be set to a string such as 'tumbnail' or "width, height" eg - '200,200'
257
-            if (! empty($attrs['size'])) {
257
+            if ( ! empty($attrs['size'])) {
258 258
                 $size = explode(',', $attrs['size']);
259 259
                 if (count($size) === 1) {
260 260
                     $size = $size[0];
@@ -266,11 +266,11 @@  discard block
 block discarded – undo
266 266
             $image = $this->_event->feature_image_url($size);
267 267
 
268 268
             return ! empty($image)
269
-                ? '<img src="' . $image . '" alt="'
269
+                ? '<img src="'.$image.'" alt="'
270 270
                   . sprintf(
271 271
                       esc_attr__('%s Feature Image', 'event_espresso'),
272 272
                       $this->_event->get('EVT_name')
273
-                  ) . '"' . $width . $height . '/>'
273
+                  ).'"'.$width.$height.'/>'
274 274
                 : '';
275 275
         }
276 276
 
@@ -289,6 +289,6 @@  discard block
 block discarded – undo
289 289
     {
290 290
         $url = get_permalink($event->ID());
291 291
 
292
-        return $full_link ? '<a href="' . $url . '">' . $event->get('EVT_name') . '</a>' : $url;
292
+        return $full_link ? '<a href="'.$url.'">'.$event->get('EVT_name').'</a>' : $url;
293 293
     }
294 294
 }
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   +201 added lines, -201 removed lines patch added patch discarded remove patch
@@ -19,205 +19,205 @@
 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 (isset($this->_extra_data['data']->registrations[ $reg->ID() ]['tkt_obj'])
138
-                    && $this->_extra_data['data']->registrations[ $reg->ID() ]['tkt_obj']->ID() == $tkt->ID()
139
-                ) {
140
-                    $adj_tkts[] = $tkt;
141
-                }
142
-            }
143
-            $evt_tkts = $adj_tkts;
144
-        }
145
-        return $evt_tkts;
146
-    }
147
-
148
-
149
-    /**
150
-     * figure out what the incoming data is and then return the appropriate parsed value
151
-     *
152
-     * @param  boolean $primary whether we're getting the primary registrant ticket_list.
153
-     * @return string
154
-     */
155
-    private function _get_recipient_datetime_list($primary = false)
156
-    {
157
-        $this->_validate_list_requirements();
158
-
159
-        if ($this->_data['data'] instanceof EE_Messages_Addressee) {
160
-            return $this->_get_recipient_datetime_list_parsed($this->_data['data'], $primary);
161
-        } elseif ($this->_extra_data['data'] instanceof EE_Messages_Addressee) {
162
-            return $this->_get_recipient_datetime_list_parsed($this->_extra_data['data'], $primary);
163
-        } else {
164
-            return '';
165
-        }
166
-
167
-        return $this->_get_recipient_datetime_list_parsed($this->_data['data'], $primary);
168
-    }
169
-
170
-
171
-    private function _get_recipient_datetime_list_parsed(EE_Messages_Addressee $data, $primary = false)
172
-    {
173
-        $registration = $primary ? $data->primary_reg_obj : $data->reg_obj;
174
-        if (! $registration instanceof EE_Registration) {
175
-            return '';
176
-        }
177
-        // setup valid shortcodes depending on what the status of the $this->_data property is
178
-        if ($this->_data['data'] instanceof EE_Messages_Addressee) {
179
-            $valid_shortcodes = array('datetime', 'attendee');
180
-            $template = $this->_data['template'];
181
-            $dtts = $data->registrations[ $registration->ID() ]['dtt_objs'];
182
-            $data = $this->_data;
183
-        } elseif ($this->_data['data'] instanceof EE_Event) {
184
-            $valid_shortcodes = array('datetime', 'attendee');
185
-            $template = is_array($this->_data['template']) && isset($this->_data['template']['datetime_list'])
186
-                ? $this->_data['template']['datetime_list'] : $this->_extra_data['template']['datetime_list'];
187
-            $dtts = $this->_get_datetimes_from_event($this->_data['data'], $registration);
188
-            $data = $this->_extra_data;
189
-        } else {
190
-            return '';
191
-        }
192
-
193
-        $dtt_parsed = '';
194
-        foreach ($dtts as $datetime) {
195
-            $dtt_parsed .= $this->_shortcode_helper->parse_datetime_list_template(
196
-                $template,
197
-                $datetime,
198
-                $valid_shortcodes,
199
-                $this->_extra_data
200
-            );
201
-        }
202
-        return $dtt_parsed;
203
-    }
204
-
205
-
206
-    private function _get_datetimes_from_event(EE_Event $event, $reg = null)
207
-    {
208
-        $evt_dtts = isset($this->_extra_data['data']->events) ? $this->_extra_data['data']->events[ $event->ID(
209
-        ) ]['dtt_objs'] : array();
210
-
211
-        if ($reg instanceof EE_Registration && $this->_extra_data['data'] instanceof EE_Messages_Addressee) {
212
-            $adj_dtts = array();
213
-            // return only dtts for the given attendee
214
-            foreach ($evt_dtts as $dtt) {
215
-                if (isset($this->_extra_data['data']->registrations[ $reg->ID() ]['dtt_objs'][ $dtt->ID() ])) {
216
-                    $adj_dtts[] = $dtt;
217
-                }
218
-            }
219
-            $evt_dtts = $adj_dtts;
220
-        }
221
-        return $evt_dtts;
222
-    }
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 (isset($this->_extra_data['data']->registrations[ $reg->ID() ]['tkt_obj'])
138
+					&& $this->_extra_data['data']->registrations[ $reg->ID() ]['tkt_obj']->ID() == $tkt->ID()
139
+				) {
140
+					$adj_tkts[] = $tkt;
141
+				}
142
+			}
143
+			$evt_tkts = $adj_tkts;
144
+		}
145
+		return $evt_tkts;
146
+	}
147
+
148
+
149
+	/**
150
+	 * figure out what the incoming data is and then return the appropriate parsed value
151
+	 *
152
+	 * @param  boolean $primary whether we're getting the primary registrant ticket_list.
153
+	 * @return string
154
+	 */
155
+	private function _get_recipient_datetime_list($primary = false)
156
+	{
157
+		$this->_validate_list_requirements();
158
+
159
+		if ($this->_data['data'] instanceof EE_Messages_Addressee) {
160
+			return $this->_get_recipient_datetime_list_parsed($this->_data['data'], $primary);
161
+		} elseif ($this->_extra_data['data'] instanceof EE_Messages_Addressee) {
162
+			return $this->_get_recipient_datetime_list_parsed($this->_extra_data['data'], $primary);
163
+		} else {
164
+			return '';
165
+		}
166
+
167
+		return $this->_get_recipient_datetime_list_parsed($this->_data['data'], $primary);
168
+	}
169
+
170
+
171
+	private function _get_recipient_datetime_list_parsed(EE_Messages_Addressee $data, $primary = false)
172
+	{
173
+		$registration = $primary ? $data->primary_reg_obj : $data->reg_obj;
174
+		if (! $registration instanceof EE_Registration) {
175
+			return '';
176
+		}
177
+		// setup valid shortcodes depending on what the status of the $this->_data property is
178
+		if ($this->_data['data'] instanceof EE_Messages_Addressee) {
179
+			$valid_shortcodes = array('datetime', 'attendee');
180
+			$template = $this->_data['template'];
181
+			$dtts = $data->registrations[ $registration->ID() ]['dtt_objs'];
182
+			$data = $this->_data;
183
+		} elseif ($this->_data['data'] instanceof EE_Event) {
184
+			$valid_shortcodes = array('datetime', 'attendee');
185
+			$template = is_array($this->_data['template']) && isset($this->_data['template']['datetime_list'])
186
+				? $this->_data['template']['datetime_list'] : $this->_extra_data['template']['datetime_list'];
187
+			$dtts = $this->_get_datetimes_from_event($this->_data['data'], $registration);
188
+			$data = $this->_extra_data;
189
+		} else {
190
+			return '';
191
+		}
192
+
193
+		$dtt_parsed = '';
194
+		foreach ($dtts as $datetime) {
195
+			$dtt_parsed .= $this->_shortcode_helper->parse_datetime_list_template(
196
+				$template,
197
+				$datetime,
198
+				$valid_shortcodes,
199
+				$this->_extra_data
200
+			);
201
+		}
202
+		return $dtt_parsed;
203
+	}
204
+
205
+
206
+	private function _get_datetimes_from_event(EE_Event $event, $reg = null)
207
+	{
208
+		$evt_dtts = isset($this->_extra_data['data']->events) ? $this->_extra_data['data']->events[ $event->ID(
209
+		) ]['dtt_objs'] : array();
210
+
211
+		if ($reg instanceof EE_Registration && $this->_extra_data['data'] instanceof EE_Messages_Addressee) {
212
+			$adj_dtts = array();
213
+			// return only dtts for the given attendee
214
+			foreach ($evt_dtts as $dtt) {
215
+				if (isset($this->_extra_data['data']->registrations[ $reg->ID() ]['dtt_objs'][ $dtt->ID() ])) {
216
+					$adj_dtts[] = $dtt;
217
+				}
218
+			}
219
+			$evt_dtts = $adj_dtts;
220
+		}
221
+		return $evt_dtts;
222
+	}
223 223
 }
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,15 +127,15 @@  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
-                if (isset($this->_extra_data['data']->registrations[ $reg->ID() ]['tkt_obj'])
138
-                    && $this->_extra_data['data']->registrations[ $reg->ID() ]['tkt_obj']->ID() == $tkt->ID()
137
+                if (isset($this->_extra_data['data']->registrations[$reg->ID()]['tkt_obj'])
138
+                    && $this->_extra_data['data']->registrations[$reg->ID()]['tkt_obj']->ID() == $tkt->ID()
139 139
                 ) {
140 140
                     $adj_tkts[] = $tkt;
141 141
                 }
@@ -171,14 +171,14 @@  discard block
 block discarded – undo
171 171
     private function _get_recipient_datetime_list_parsed(EE_Messages_Addressee $data, $primary = false)
172 172
     {
173 173
         $registration = $primary ? $data->primary_reg_obj : $data->reg_obj;
174
-        if (! $registration instanceof EE_Registration) {
174
+        if ( ! $registration instanceof EE_Registration) {
175 175
             return '';
176 176
         }
177 177
         // setup valid shortcodes depending on what the status of the $this->_data property is
178 178
         if ($this->_data['data'] instanceof EE_Messages_Addressee) {
179 179
             $valid_shortcodes = array('datetime', 'attendee');
180 180
             $template = $this->_data['template'];
181
-            $dtts = $data->registrations[ $registration->ID() ]['dtt_objs'];
181
+            $dtts = $data->registrations[$registration->ID()]['dtt_objs'];
182 182
             $data = $this->_data;
183 183
         } elseif ($this->_data['data'] instanceof EE_Event) {
184 184
             $valid_shortcodes = array('datetime', 'attendee');
@@ -205,14 +205,14 @@  discard block
 block discarded – undo
205 205
 
206 206
     private function _get_datetimes_from_event(EE_Event $event, $reg = null)
207 207
     {
208
-        $evt_dtts = isset($this->_extra_data['data']->events) ? $this->_extra_data['data']->events[ $event->ID(
209
-        ) ]['dtt_objs'] : array();
208
+        $evt_dtts = isset($this->_extra_data['data']->events) ? $this->_extra_data['data']->events[$event->ID(
209
+        )]['dtt_objs'] : array();
210 210
 
211 211
         if ($reg instanceof EE_Registration && $this->_extra_data['data'] instanceof EE_Messages_Addressee) {
212 212
             $adj_dtts = array();
213 213
             // return only dtts for the given attendee
214 214
             foreach ($evt_dtts as $dtt) {
215
-                if (isset($this->_extra_data['data']->registrations[ $reg->ID() ]['dtt_objs'][ $dtt->ID() ])) {
215
+                if (isset($this->_extra_data['data']->registrations[$reg->ID()]['dtt_objs'][$dtt->ID()])) {
216 216
                     $adj_dtts[] = $dtt;
217 217
                 }
218 218
             }
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   +814 added lines, -814 removed lines patch added patch discarded remove patch
@@ -17,818 +17,818 @@
 block discarded – undo
17 17
 {
18 18
 
19 19
 
20
-    /**
21
-     * @return EED_Module|EED_Add_New_State
22
-     */
23
-    public static function instance()
24
-    {
25
-        return parent::get_instance(__CLASS__);
26
-    }
27
-
28
-
29
-    /**
30
-     * set_hooks - for hooking into EE Core, other modules, etc
31
-     *
32
-     * @return void
33
-     */
34
-    public static function set_hooks()
35
-    {
36
-        add_action('wp_loaded', array('EED_Add_New_State', 'set_definitions'), 2);
37
-        add_action('wp_enqueue_scripts', array('EED_Add_New_State', 'translate_js_strings'), 0);
38
-        add_action('wp_enqueue_scripts', array('EED_Add_New_State', 'wp_enqueue_scripts'), 10);
39
-        add_filter(
40
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form',
41
-            array('EED_Add_New_State', 'display_add_new_state_micro_form'),
42
-            1,
43
-            1
44
-        );
45
-        add_filter(
46
-            'FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form',
47
-            array('EED_Add_New_State', 'display_add_new_state_micro_form'),
48
-            1,
49
-            1
50
-        );
51
-        add_filter(
52
-            'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item',
53
-            array('EED_Add_New_State', 'unset_new_state_request_params'),
54
-            10,
55
-            1
56
-        );
57
-        add_filter(
58
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options',
59
-            array('EED_Add_New_State', 'inject_new_reg_state_into_options'),
60
-            10,
61
-            5
62
-        );
63
-        add_filter(
64
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options',
65
-            array('EED_Add_New_State', 'inject_new_reg_country_into_options'),
66
-            10,
67
-            5
68
-        );
69
-        add_filter(
70
-            'FHEE__EE_State_Select_Input____construct__state_options',
71
-            array('EED_Add_New_State', 'state_options'),
72
-            10,
73
-            1
74
-        );
75
-        add_filter(
76
-            'FHEE__EE_Country_Select_Input____construct__country_options',
77
-            array('EED_Add_New_State', 'country_options'),
78
-            10,
79
-            1
80
-        );
81
-    }
82
-
83
-
84
-    /**
85
-     * set_hooks_admin - for hooking into EE Admin Core, other modules, etc
86
-     *
87
-     * @return void
88
-     */
89
-    public static function set_hooks_admin()
90
-    {
91
-        add_action('wp_loaded', array('EED_Add_New_State', 'set_definitions'), 2);
92
-        add_filter(
93
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form',
94
-            array('EED_Add_New_State', 'display_add_new_state_micro_form'),
95
-            1,
96
-            1
97
-        );
98
-        add_filter(
99
-            'FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form',
100
-            array('EED_Add_New_State', 'display_add_new_state_micro_form'),
101
-            1,
102
-            1
103
-        );
104
-        add_action('wp_ajax_espresso_add_new_state', array('EED_Add_New_State', 'add_new_state'));
105
-        add_action('wp_ajax_nopriv_espresso_add_new_state', array('EED_Add_New_State', 'add_new_state'));
106
-        add_filter(
107
-            'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item',
108
-            array('EED_Add_New_State', 'unset_new_state_request_params'),
109
-            10,
110
-            1
111
-        );
112
-        add_action(
113
-            'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved',
114
-            array('EED_Add_New_State', 'update_country_settings'),
115
-            10,
116
-            3
117
-        );
118
-        add_action(
119
-            'AHEE__General_Settings_Admin_Page__delete_state__state_deleted',
120
-            array('EED_Add_New_State', 'update_country_settings'),
121
-            10,
122
-            3
123
-        );
124
-        add_filter(
125
-            'FHEE__EE_State_Select_Input____construct__state_options',
126
-            array('EED_Add_New_State', 'state_options'),
127
-            10,
128
-            1
129
-        );
130
-        add_filter(
131
-            'FHEE__EE_Country_Select_Input____construct__country_options',
132
-            array('EED_Add_New_State', 'country_options'),
133
-            10,
134
-            1
135
-        );
136
-        add_filter(
137
-            'FHEE__EE_Form_Section_Proper__receive_form_submission__request_data',
138
-            array('EED_Add_New_State', 'filter_checkout_request_params'),
139
-            10,
140
-            1
141
-        );
142
-        add_filter(
143
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options',
144
-            array('EED_Add_New_State', 'inject_new_reg_state_into_options'),
145
-            10,
146
-            5
147
-        );
148
-        add_filter(
149
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options',
150
-            array('EED_Add_New_State', 'inject_new_reg_country_into_options'),
151
-            10,
152
-            5
153
-        );
154
-    }
155
-
156
-
157
-    /**
158
-     * @return void
159
-     */
160
-    public static function set_definitions()
161
-    {
162
-        define('ANS_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets' . DS);
163
-        define(
164
-            'ANS_TEMPLATES_PATH',
165
-            str_replace(
166
-                '\\',
167
-                DS,
168
-                plugin_dir_path(__FILE__)
169
-            ) . 'templates' . DS
170
-        );
171
-    }
172
-
173
-
174
-    /**
175
-     * @param WP $WP
176
-     * @return void
177
-     */
178
-    public function run($WP)
179
-    {
180
-    }
181
-
182
-
183
-    /**
184
-     * @return void
185
-     */
186
-    public static function translate_js_strings()
187
-    {
188
-        EE_Registry::$i18n_js_strings['ans_no_country'] = esc_html__(
189
-            'In order to proceed, you need to select the Country that your State/Province belongs to.',
190
-            'event_espresso'
191
-        );
192
-        EE_Registry::$i18n_js_strings['ans_no_name'] = esc_html__(
193
-            'In order to proceed, you need to enter the name of your State/Province.',
194
-            'event_espresso'
195
-        );
196
-        EE_Registry::$i18n_js_strings['ans_no_abbreviation'] = esc_html__(
197
-            'In order to proceed, you need to enter an abbreviation for the name of your State/Province.',
198
-            'event_espresso'
199
-        );
200
-        EE_Registry::$i18n_js_strings['ans_save_success'] = esc_html__(
201
-            'The new state was successfully saved to the database.',
202
-            'event_espresso'
203
-        );
204
-        EE_Registry::$i18n_js_strings['ans_server_save_error'] = esc_html__(
205
-            'An unknown error has occurred on the server while saving the new state to the database.',
206
-            'event_espresso'
207
-        );
208
-    }
209
-
210
-
211
-    /**
212
-     * @return void
213
-     */
214
-    public static function wp_enqueue_scripts()
215
-    {
216
-        if (apply_filters('EED_Single_Page_Checkout__SPCO_active', false)) {
217
-            wp_register_script(
218
-                'add_new_state',
219
-                ANS_ASSETS_URL . 'add_new_state.js',
220
-                array('espresso_core', 'single_page_checkout'),
221
-                EVENT_ESPRESSO_VERSION,
222
-                true
223
-            );
224
-            wp_enqueue_script('add_new_state');
225
-        }
226
-    }
227
-
228
-
229
-
230
-    /**
231
-     * display_add_new_state_micro_form
232
-     *
233
-     * @param EE_Form_Section_Proper $question_group_reg_form
234
-     * @return string
235
-     * @throws EE_Error
236
-     * @throws InvalidArgumentException
237
-     * @throws InvalidDataTypeException
238
-     * @throws InvalidInterfaceException
239
-     */
240
-    public static function display_add_new_state_micro_form(EE_Form_Section_Proper $question_group_reg_form)
241
-    {
242
-        // only add the 'new_state_micro_form' when displaying reg forms,
243
-        // not during processing since we process the 'new_state_micro_form' in it's own AJAX request
244
-        $action = EE_Registry::instance()->REQ->get('action', '');
245
-        // is the "state" question in this form section?
246
-        $input = $question_group_reg_form->get_subsection('state');
247
-        if ($action === 'process_reg_step' || $action === 'update_reg_step') {
248
-            // ok then all we need to do is make sure the input's HTML name is consistent
249
-            // by forcing it to set it now, like it did while getting the form for display
250
-            if ($input instanceof EE_State_Select_Input) {
251
-                $input->html_name();
252
-            }
253
-            return $question_group_reg_form;
254
-        }
255
-        // we're only doing this for state select inputs
256
-        if ($input instanceof EE_State_Select_Input
257
-            && ! $input->get_display_strategy() instanceof EE_Hidden_Display_Strategy
258
-        ) {
259
-            // grab any set values from the request
260
-            $country_name = str_replace('state', 'nsmf_new_state_country', $input->html_name());
261
-            $state_name = str_replace('state', 'nsmf_new_state_name', $input->html_name());
262
-            $abbrv_name = str_replace('state', 'nsmf_new_state_abbrv', $input->html_name());
263
-            $new_state_submit_id = str_replace('state', 'new_state', $input->html_id());
264
-            $country_options = array();
265
-            $countries = EEM_Country::instance()->get_all_countries();
266
-            if (! empty($countries)) {
267
-                foreach ($countries as $country) {
268
-                    if ($country instanceof EE_Country) {
269
-                        $country_options[ $country->ID() ] = $country->name();
270
-                    }
271
-                }
272
-            }
273
-            $new_state_micro_form = new EE_Form_Section_Proper(
274
-                array(
275
-                    'name'            => 'new_state_micro_form',
276
-                    'html_id'         => 'new_state_micro_form',
277
-                    'layout_strategy' => new EE_Div_Per_Section_Layout(),
278
-                    'subsections'     => array(
279
-                        // add hidden input to indicate that a new state is being added
280
-                        'add_new_state'               => new EE_Hidden_Input(
281
-                            array(
282
-                                'html_name' => str_replace(
283
-                                    'state',
284
-                                    'nsmf_add_new_state',
285
-                                    $input->html_name()
286
-                                ),
287
-                                'html_id'   => str_replace(
288
-                                    'state',
289
-                                    'nsmf_add_new_state',
290
-                                    $input->html_id()
291
-                                ),
292
-                                'default'   => 0,
293
-                            )
294
-                        ),
295
-                        // add link for displaying hidden container
296
-                        'click_here_link'             => new EE_Form_Section_HTML(
297
-                            apply_filters(
298
-                                'FHEE__EED_Add_New_State__display_add_new_state_micro_form__click_here_link',
299
-                                EEH_HTML::link(
300
-                                    '',
301
-                                    esc_html__('click here to add a new state/province', 'event_espresso'),
302
-                                    '',
303
-                                    'display-' . $input->html_id(),
304
-                                    'ee-form-add-new-state-lnk display-the-hidden smaller-text hide-if-no-js',
305
-                                    '',
306
-                                    'data-target="' . $input->html_id() . '"'
307
-                                )
308
-                            )
309
-                        ),
310
-                        // add initial html for hidden container
311
-                        'add_new_state_micro_form'    => new EE_Form_Section_HTML(
312
-                            apply_filters(
313
-                                'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_micro_form',
314
-                                EEH_HTML::div(
315
-                                    '',
316
-                                    $input->html_id() . '-dv',
317
-                                    'ee-form-add-new-state-dv',
318
-                                    'display: none;'
319
-                                ) .
320
-                                EEH_HTML::h6(
321
-                                    esc_html__(
322
-                                        'Is your state/province missing from the dropdown menu above? You can add it by completing the following steps:',
323
-                                        'event_espresso'
324
-                                    )
325
-                                ) .
326
-                                EEH_HTML::ul() .
327
-                                EEH_HTML::li(
328
-                                    esc_html__(
329
-                                        'first select the Country that your State/Province belongs to',
330
-                                        'event_espresso'
331
-                                    )
332
-                                ) .
333
-                                EEH_HTML::li(
334
-                                    esc_html__('enter the name of your State/Province', 'event_espresso')
335
-                                ) .
336
-                                EEH_HTML::li(
337
-                                    esc_html__(
338
-                                        'enter a two to six letter abbreviation for the name of your State/Province',
339
-                                        'event_espresso'
340
-                                    )
341
-                                ) .
342
-                                EEH_HTML::li(esc_html__('click the ADD button', 'event_espresso')) .
343
-                                EEH_HTML::ulx()
344
-                            )
345
-                        ),
346
-                        // NEW STATE COUNTRY
347
-                        'new_state_country'           => new EE_Country_Select_Input(
348
-                            $country_options,
349
-                            array(
350
-                                'html_name'       => $country_name,
351
-                                'html_id'         => str_replace(
352
-                                    'state',
353
-                                    'nsmf_new_state_country',
354
-                                    $input->html_id()
355
-                                ),
356
-                                'html_class'      => $input->html_class() . ' new-state-country',
357
-                                'html_label_text' => esc_html__('New State/Province Country', 'event_espresso'),
358
-                                'default'         => EE_Registry::instance()->REQ->get($country_name, ''),
359
-                                'required'        => false,
360
-                            )
361
-                        ),
362
-                        // NEW STATE NAME
363
-                        'new_state_name'              => new EE_Text_Input(
364
-                            array(
365
-                                'html_name'       => $state_name,
366
-                                'html_id'         => str_replace(
367
-                                    'state',
368
-                                    'nsmf_new_state_name',
369
-                                    $input->html_id()
370
-                                ),
371
-                                'html_class'      => $input->html_class() . ' new-state-state',
372
-                                'html_label_text' => esc_html__(
373
-                                    'New State/Province Name',
374
-                                    'event_espresso'
375
-                                ),
376
-                                'default'         => EE_Registry::instance()->REQ->get($state_name, ''),
377
-                                'required'        => false,
378
-                            )
379
-                        ),
380
-                        'spacer'                      => new EE_Form_Section_HTML(EEH_HTML::br()),
381
-                        // NEW STATE NAME
382
-                        'new_state_abbrv'             => new EE_Text_Input(
383
-                            array(
384
-                                'html_name'             => $abbrv_name,
385
-                                'html_id'               => str_replace(
386
-                                    'state',
387
-                                    'nsmf_new_state_abbrv',
388
-                                    $input->html_id()
389
-                                ),
390
-                                'html_class'            => $input->html_class() . ' new-state-abbrv',
391
-                                'html_label_text'       => esc_html__(
392
-                                    'New State/Province Abbreviation',
393
-                                    'event_espresso'
394
-                                ) . ' *',
395
-                                'html_other_attributes' => 'size="24"',
396
-                                'default'               => EE_Registry::instance()->REQ->get($abbrv_name, ''),
397
-                                'required'              => false,
398
-                            )
399
-                        ),
400
-                        // "submit" button
401
-                        'add_new_state_submit_button' => new EE_Form_Section_HTML(
402
-                            apply_filters(
403
-                                'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_submit_button',
404
-                                EEH_HTML::nbsp(3) .
405
-                                EEH_HTML::link(
406
-                                    '',
407
-                                    esc_html__('ADD', 'event_espresso'),
408
-                                    '',
409
-                                    'submit-' . $new_state_submit_id,
410
-                                    'ee-form-add-new-state-submit button button-secondary',
411
-                                    '',
412
-                                    'data-target="' . $new_state_submit_id . '"'
413
-                                )
414
-                            )
415
-                        ),
416
-                        // extra info
417
-                        'add_new_state_extra'         => new EE_Form_Section_HTML(
418
-                            apply_filters(
419
-                                'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_extra',
420
-                                EEH_HTML::br(2)
421
-                                .
422
-                                EEH_HTML::div('', '', 'small-text')
423
-                                .
424
-                                EEH_HTML::strong(
425
-                                    '* ' .
426
-                                    esc_html__(
427
-                                        'Don\'t know your State/Province Abbreviation?',
428
-                                        'event_espresso'
429
-                                    )
430
-                                )
431
-                                .
432
-                                EEH_HTML::br()
433
-                                .
434
-                                sprintf(
435
-                                    esc_html__(
436
-                                        'You can look here: %s, for a list of Countries and links to their State/Province Abbreviations ("Subdivisions assigned codes" column).',
437
-                                        'event_espresso'
438
-                                    ),
439
-                                    EEH_HTML::link(
440
-                                        'http://en.wikipedia.org/wiki/ISO_3166-2',
441
-                                        'http://en.wikipedia.org/wiki/ISO_3166-2',
442
-                                        '',
443
-                                        '',
444
-                                        'ee-form-add-new-state-wiki-lnk',
445
-                                        '',
446
-                                        'target="_blank"'
447
-                                    )
448
-                                )
449
-                                .
450
-                                EEH_HTML::divx()
451
-                                .
452
-                                EEH_HTML::br()
453
-                                .
454
-                                EEH_HTML::link(
455
-                                    '',
456
-                                    esc_html__('cancel new State/Province', 'event_espresso'),
457
-                                    '',
458
-                                    'hide-' . $input->html_id(),
459
-                                    'ee-form-cancel-new-state-lnk smaller-text',
460
-                                    '',
461
-                                    'data-target="' . $input->html_id() . '"'
462
-                                )
463
-                                .
464
-                                EEH_HTML::divx()
465
-                                .
466
-                                EEH_HTML::br()
467
-                            )
468
-                        ),
469
-                    ),
470
-                )
471
-            );
472
-            $question_group_reg_form->add_subsections(
473
-                array('new_state_micro_form' => $new_state_micro_form),
474
-                'state',
475
-                false
476
-            );
477
-        }
478
-        return $question_group_reg_form;
479
-    }
480
-
481
-
482
-    /**
483
-     * set_new_state_input_width
484
-     *
485
-     * @return int|string
486
-     * @throws EE_Error
487
-     * @throws InvalidArgumentException
488
-     * @throws InvalidDataTypeException
489
-     * @throws InvalidInterfaceException
490
-     * @throws ReflectionException
491
-     */
492
-    public static function add_new_state()
493
-    {
494
-        $REQ = EE_Registry::instance()->load_core('Request_Handler');
495
-        if (absint($REQ->get('nsmf_add_new_state')) === 1) {
496
-            EE_Registry::instance()->load_model('State');
497
-            // grab country ISO code, new state name, and new state abbreviation
498
-            $state_country = $REQ->is_set('nsmf_new_state_country')
499
-                ? sanitize_text_field($REQ->get('nsmf_new_state_country'))
500
-                : false;
501
-            $state_name = $REQ->is_set('nsmf_new_state_name')
502
-                ? sanitize_text_field($REQ->get('nsmf_new_state_name'))
503
-                : false;
504
-            $state_abbr = $REQ->is_set('nsmf_new_state_abbrv')
505
-                ? sanitize_text_field($REQ->get('nsmf_new_state_abbrv'))
506
-                : false;
507
-            if ($state_country && $state_name && $state_abbr) {
508
-                $new_state = EED_Add_New_State::save_new_state_to_db(
509
-                    array(
510
-                        'CNT_ISO'    => strtoupper($state_country),
511
-                        'STA_abbrev' => strtoupper($state_abbr),
512
-                        'STA_name'   => ucwords($state_name),
513
-                        'STA_active' => false,
514
-                    )
515
-                );
516
-                if ($new_state instanceof EE_State) {
517
-                    // clean house
518
-                    EE_Registry::instance()->REQ->un_set('nsmf_add_new_state');
519
-                    EE_Registry::instance()->REQ->un_set('nsmf_new_state_country');
520
-                    EE_Registry::instance()->REQ->un_set('nsmf_new_state_name');
521
-                    EE_Registry::instance()->REQ->un_set('nsmf_new_state_abbrv');
522
-                    // get any existing new states
523
-                    $new_states = EE_Registry::instance()->SSN->get_session_data(
524
-                        'nsmf_new_states'
525
-                    );
526
-                    $new_states[ $new_state->ID() ] = $new_state;
527
-                    EE_Registry::instance()->SSN->set_session_data(
528
-                        array('nsmf_new_states' => $new_states)
529
-                    );
530
-                    if (EE_Registry::instance()->REQ->ajax) {
531
-                        echo wp_json_encode(
532
-                            array(
533
-                                'success'      => true,
534
-                                'id'           => $new_state->ID(),
535
-                                'name'         => $new_state->name(),
536
-                                'abbrev'       => $new_state->abbrev(),
537
-                                'country_iso'  => $new_state->country_iso(),
538
-                                'country_name' => $new_state->country()->name(),
539
-                            )
540
-                        );
541
-                        exit();
542
-                    }
543
-                    return $new_state->ID();
544
-                }
545
-            } else {
546
-                $error = esc_html__(
547
-                    'A new State/Province could not be added because invalid or missing data was received.',
548
-                    'event_espresso'
549
-                );
550
-                if (EE_Registry::instance()->REQ->ajax) {
551
-                    echo wp_json_encode(array('error' => $error));
552
-                    exit();
553
-                }
554
-                EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__);
555
-            }
556
-        }
557
-        return false;
558
-    }
559
-
560
-
561
-    /**
562
-     * recursively drills down through request params to remove any that were added by this module
563
-     *
564
-     * @param array $request_params
565
-     * @return array
566
-     */
567
-    public static function filter_checkout_request_params($request_params)
568
-    {
569
-        foreach ($request_params as $form_section) {
570
-            if (is_array($form_section)) {
571
-                EED_Add_New_State::unset_new_state_request_params($form_section);
572
-                EED_Add_New_State::filter_checkout_request_params($form_section);
573
-            }
574
-        }
575
-        return $request_params;
576
-    }
577
-
578
-
579
-    /**
580
-     * @param array $request_params
581
-     * @return array
582
-     */
583
-    public static function unset_new_state_request_params($request_params)
584
-    {
585
-        unset(
586
-            $request_params['new_state_micro_form'],
587
-            $request_params['new_state_micro_add_new_state'],
588
-            $request_params['new_state_micro_new_state_country'],
589
-            $request_params['new_state_micro_new_state_name'],
590
-            $request_params['new_state_micro_new_state_abbrv']
591
-        );
592
-        return $request_params;
593
-    }
594
-
595
-
596
-    /**
597
-     * @param array $props_n_values
598
-     * @return bool
599
-     * @throws EE_Error
600
-     * @throws InvalidArgumentException
601
-     * @throws InvalidDataTypeException
602
-     * @throws InvalidInterfaceException
603
-     */
604
-    public static function save_new_state_to_db($props_n_values = array())
605
-    {
606
-        $existing_state = EEM_State::instance()->get_all(array($props_n_values, 'limit' => 1));
607
-        if (! empty($existing_state)) {
608
-            return array_pop($existing_state);
609
-        }
610
-        $new_state = EE_State::new_instance($props_n_values);
611
-        if ($new_state instanceof EE_State) {
612
-            $country_settings_url = add_query_arg(
613
-                array(
614
-                    'page'    => 'espresso_general_settings',
615
-                    'action'  => 'country_settings',
616
-                    'country' => $new_state->country_iso(),
617
-                ),
618
-                admin_url('admin.php')
619
-            );
620
-            // if not non-ajax admin
621
-            new PersistentAdminNotice(
622
-                'new-state-added-' . $new_state->country_iso() . '-' . $new_state->abbrev(),
623
-                sprintf(
624
-                    esc_html__(
625
-                        '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.',
626
-                        'event_espresso'
627
-                    ),
628
-                    '<b>' . $new_state->name() . '</b>',
629
-                    '<b>' . $new_state->abbrev() . '</b>',
630
-                    '<b>' . $new_state->country()->name() . '</b>',
631
-                    '<a href="'
632
-                    . $country_settings_url
633
-                    . '">'
634
-                    . esc_html__(
635
-                        'Event Espresso - General Settings > Countries Tab',
636
-                        'event_espresso'
637
-                    )
638
-                    . '</a>',
639
-                    '<br />'
640
-                )
641
-            );
642
-            $new_state->save();
643
-            EEM_State::instance()->reset_cached_states();
644
-            return $new_state;
645
-        }
646
-        return false;
647
-    }
648
-
649
-
650
-    /**
651
-     * @param string $CNT_ISO
652
-     * @param string $STA_ID
653
-     * @param array  $cols_n_values
654
-     * @return void
655
-     * @throws DomainException
656
-     * @throws EE_Error
657
-     * @throws InvalidArgumentException
658
-     * @throws InvalidDataTypeException
659
-     * @throws InvalidInterfaceException
660
-     */
661
-    public static function update_country_settings($CNT_ISO = '', $STA_ID = '', $cols_n_values = array())
662
-    {
663
-        if (! $CNT_ISO) {
664
-            EE_Error::add_error(
665
-                esc_html__('An invalid or missing Country ISO Code was received.', 'event_espresso'),
666
-                __FILE__,
667
-                __FUNCTION__,
668
-                __LINE__
669
-            );
670
-        }
671
-        $STA_abbrev = is_array($cols_n_values) && isset($cols_n_values['STA_abbrev']) ? $cols_n_values['STA_abbrev']
672
-            : false;
673
-        if (! $STA_abbrev && ! empty($STA_ID)) {
674
-            $state = EEM_State::instance()->get_one_by_ID($STA_ID);
675
-            if ($state instanceof EE_State) {
676
-                $STA_abbrev = $state->abbrev();
677
-            }
678
-        }
679
-        if (! $STA_abbrev) {
680
-            EE_Error::add_error(
681
-                esc_html__('An invalid or missing State Abbreviation was received.', 'event_espresso'),
682
-                __FILE__,
683
-                __FUNCTION__,
684
-                __LINE__
685
-            );
686
-        }
687
-        /** @var PersistentAdminNoticeManager $persistent_admin_notice_manager */
688
-        $persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared(
689
-            'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
690
-        );
691
-        $persistent_admin_notice_manager->dismissNotice($CNT_ISO . '-' . $STA_abbrev, true, true);
692
-    }
693
-
694
-
695
-    /**
696
-     * @param EE_State[]                            $state_options
697
-     * @param EE_SPCO_Reg_Step_Attendee_Information $reg_step
698
-     * @param EE_Registration                       $registration
699
-     * @param EE_Question                           $question
700
-     * @param                                       $answer
701
-     * @return array
702
-     * @throws EE_Error
703
-     * @throws InvalidArgumentException
704
-     * @throws InvalidDataTypeException
705
-     * @throws InvalidInterfaceException
706
-     */
707
-    public static function inject_new_reg_state_into_options(
708
-        $state_options = array(),
709
-        EE_SPCO_Reg_Step_Attendee_Information $reg_step,
710
-        EE_Registration $registration,
711
-        EE_Question $question,
712
-        $answer
713
-    ) {
714
-        if ($answer instanceof EE_Answer && $question instanceof EE_Question
715
-            && $question->type() === EEM_Question::QST_type_state
716
-        ) {
717
-            $STA_ID = $answer->value();
718
-            if (! empty($STA_ID)) {
719
-                $state = EEM_State::instance()->get_one_by_ID($STA_ID);
720
-                if ($state instanceof EE_State) {
721
-                    $country = $state->country();
722
-                    if ($country instanceof EE_Country) {
723
-                        if (! isset($state_options[ $country->name() ])) {
724
-                            $state_options[ $country->name() ] = array();
725
-                        }
726
-                        if (! isset($state_options[ $country->name() ][ $STA_ID ])) {
727
-                            $state_options[ $country->name() ][ $STA_ID ] = $state->name();
728
-                        }
729
-                    }
730
-                }
731
-            }
732
-        }
733
-        return $state_options;
734
-    }
735
-
736
-
737
-    /**
738
-     * @param EE_Country[]                          $country_options
739
-     * @param EE_SPCO_Reg_Step_Attendee_Information $reg_step
740
-     * @param EE_Registration                       $registration
741
-     * @param EE_Question                           $question
742
-     * @param                                       $answer
743
-     * @return array
744
-     * @throws EE_Error
745
-     * @throws InvalidArgumentException
746
-     * @throws InvalidDataTypeException
747
-     * @throws InvalidInterfaceException
748
-     */
749
-    public static function inject_new_reg_country_into_options(
750
-        $country_options = array(),
751
-        EE_SPCO_Reg_Step_Attendee_Information $reg_step,
752
-        EE_Registration $registration,
753
-        EE_Question $question,
754
-        $answer
755
-    ) {
756
-        if ($answer instanceof EE_Answer && $question instanceof EE_Question
757
-            && $question->type()
758
-               === EEM_Question::QST_type_country
759
-        ) {
760
-            $CNT_ISO = $answer->value();
761
-            if (! empty($CNT_ISO)) {
762
-                $country = EEM_Country::instance()->get_one_by_ID($CNT_ISO);
763
-                if ($country instanceof EE_Country) {
764
-                    if (! isset($country_options[ $CNT_ISO ])) {
765
-                        $country_options[ $CNT_ISO ] = $country->name();
766
-                    }
767
-                }
768
-            }
769
-        }
770
-        return $country_options;
771
-    }
772
-
773
-
774
-    /**
775
-     * @param EE_State[] $state_options
776
-     * @return array
777
-     * @throws EE_Error
778
-     * @throws InvalidArgumentException
779
-     * @throws InvalidDataTypeException
780
-     * @throws InvalidInterfaceException
781
-     */
782
-    public static function state_options($state_options = array())
783
-    {
784
-        $new_states = EED_Add_New_State::_get_new_states();
785
-        foreach ($new_states as $new_state) {
786
-            if ($new_state instanceof EE_State
787
-                && $new_state->country() instanceof EE_Country
788
-            ) {
789
-                $state_options[ $new_state->country()->name() ][ $new_state->ID() ] = $new_state->name();
790
-            }
791
-        }
792
-        return $state_options;
793
-    }
794
-
795
-
796
-    /**
797
-     * @return array
798
-     * @throws InvalidArgumentException
799
-     * @throws InvalidDataTypeException
800
-     * @throws InvalidInterfaceException
801
-     */
802
-    protected static function _get_new_states()
803
-    {
804
-        $new_states = array();
805
-        if (EE_Registry::instance()->SSN instanceof EE_Session) {
806
-            $new_states = EE_Registry::instance()->SSN->get_session_data(
807
-                'nsmf_new_states'
808
-            );
809
-        }
810
-        return is_array($new_states) ? $new_states : array();
811
-    }
812
-
813
-
814
-    /**
815
-     * @param EE_Country[] $country_options
816
-     * @return array
817
-     * @throws EE_Error
818
-     * @throws InvalidArgumentException
819
-     * @throws InvalidDataTypeException
820
-     * @throws InvalidInterfaceException
821
-     */
822
-    public static function country_options($country_options = array())
823
-    {
824
-        $new_states = EED_Add_New_State::_get_new_states();
825
-        foreach ($new_states as $new_state) {
826
-            if ($new_state instanceof EE_State
827
-                && $new_state->country() instanceof EE_Country
828
-            ) {
829
-                $country_options[ $new_state->country()->ID() ] = $new_state->country()->name();
830
-            }
831
-        }
832
-        return $country_options;
833
-    }
20
+	/**
21
+	 * @return EED_Module|EED_Add_New_State
22
+	 */
23
+	public static function instance()
24
+	{
25
+		return parent::get_instance(__CLASS__);
26
+	}
27
+
28
+
29
+	/**
30
+	 * set_hooks - for hooking into EE Core, other modules, etc
31
+	 *
32
+	 * @return void
33
+	 */
34
+	public static function set_hooks()
35
+	{
36
+		add_action('wp_loaded', array('EED_Add_New_State', 'set_definitions'), 2);
37
+		add_action('wp_enqueue_scripts', array('EED_Add_New_State', 'translate_js_strings'), 0);
38
+		add_action('wp_enqueue_scripts', array('EED_Add_New_State', 'wp_enqueue_scripts'), 10);
39
+		add_filter(
40
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form',
41
+			array('EED_Add_New_State', 'display_add_new_state_micro_form'),
42
+			1,
43
+			1
44
+		);
45
+		add_filter(
46
+			'FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form',
47
+			array('EED_Add_New_State', 'display_add_new_state_micro_form'),
48
+			1,
49
+			1
50
+		);
51
+		add_filter(
52
+			'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item',
53
+			array('EED_Add_New_State', 'unset_new_state_request_params'),
54
+			10,
55
+			1
56
+		);
57
+		add_filter(
58
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options',
59
+			array('EED_Add_New_State', 'inject_new_reg_state_into_options'),
60
+			10,
61
+			5
62
+		);
63
+		add_filter(
64
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options',
65
+			array('EED_Add_New_State', 'inject_new_reg_country_into_options'),
66
+			10,
67
+			5
68
+		);
69
+		add_filter(
70
+			'FHEE__EE_State_Select_Input____construct__state_options',
71
+			array('EED_Add_New_State', 'state_options'),
72
+			10,
73
+			1
74
+		);
75
+		add_filter(
76
+			'FHEE__EE_Country_Select_Input____construct__country_options',
77
+			array('EED_Add_New_State', 'country_options'),
78
+			10,
79
+			1
80
+		);
81
+	}
82
+
83
+
84
+	/**
85
+	 * set_hooks_admin - for hooking into EE Admin Core, other modules, etc
86
+	 *
87
+	 * @return void
88
+	 */
89
+	public static function set_hooks_admin()
90
+	{
91
+		add_action('wp_loaded', array('EED_Add_New_State', 'set_definitions'), 2);
92
+		add_filter(
93
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form',
94
+			array('EED_Add_New_State', 'display_add_new_state_micro_form'),
95
+			1,
96
+			1
97
+		);
98
+		add_filter(
99
+			'FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form',
100
+			array('EED_Add_New_State', 'display_add_new_state_micro_form'),
101
+			1,
102
+			1
103
+		);
104
+		add_action('wp_ajax_espresso_add_new_state', array('EED_Add_New_State', 'add_new_state'));
105
+		add_action('wp_ajax_nopriv_espresso_add_new_state', array('EED_Add_New_State', 'add_new_state'));
106
+		add_filter(
107
+			'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item',
108
+			array('EED_Add_New_State', 'unset_new_state_request_params'),
109
+			10,
110
+			1
111
+		);
112
+		add_action(
113
+			'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved',
114
+			array('EED_Add_New_State', 'update_country_settings'),
115
+			10,
116
+			3
117
+		);
118
+		add_action(
119
+			'AHEE__General_Settings_Admin_Page__delete_state__state_deleted',
120
+			array('EED_Add_New_State', 'update_country_settings'),
121
+			10,
122
+			3
123
+		);
124
+		add_filter(
125
+			'FHEE__EE_State_Select_Input____construct__state_options',
126
+			array('EED_Add_New_State', 'state_options'),
127
+			10,
128
+			1
129
+		);
130
+		add_filter(
131
+			'FHEE__EE_Country_Select_Input____construct__country_options',
132
+			array('EED_Add_New_State', 'country_options'),
133
+			10,
134
+			1
135
+		);
136
+		add_filter(
137
+			'FHEE__EE_Form_Section_Proper__receive_form_submission__request_data',
138
+			array('EED_Add_New_State', 'filter_checkout_request_params'),
139
+			10,
140
+			1
141
+		);
142
+		add_filter(
143
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options',
144
+			array('EED_Add_New_State', 'inject_new_reg_state_into_options'),
145
+			10,
146
+			5
147
+		);
148
+		add_filter(
149
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options',
150
+			array('EED_Add_New_State', 'inject_new_reg_country_into_options'),
151
+			10,
152
+			5
153
+		);
154
+	}
155
+
156
+
157
+	/**
158
+	 * @return void
159
+	 */
160
+	public static function set_definitions()
161
+	{
162
+		define('ANS_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets' . DS);
163
+		define(
164
+			'ANS_TEMPLATES_PATH',
165
+			str_replace(
166
+				'\\',
167
+				DS,
168
+				plugin_dir_path(__FILE__)
169
+			) . 'templates' . DS
170
+		);
171
+	}
172
+
173
+
174
+	/**
175
+	 * @param WP $WP
176
+	 * @return void
177
+	 */
178
+	public function run($WP)
179
+	{
180
+	}
181
+
182
+
183
+	/**
184
+	 * @return void
185
+	 */
186
+	public static function translate_js_strings()
187
+	{
188
+		EE_Registry::$i18n_js_strings['ans_no_country'] = esc_html__(
189
+			'In order to proceed, you need to select the Country that your State/Province belongs to.',
190
+			'event_espresso'
191
+		);
192
+		EE_Registry::$i18n_js_strings['ans_no_name'] = esc_html__(
193
+			'In order to proceed, you need to enter the name of your State/Province.',
194
+			'event_espresso'
195
+		);
196
+		EE_Registry::$i18n_js_strings['ans_no_abbreviation'] = esc_html__(
197
+			'In order to proceed, you need to enter an abbreviation for the name of your State/Province.',
198
+			'event_espresso'
199
+		);
200
+		EE_Registry::$i18n_js_strings['ans_save_success'] = esc_html__(
201
+			'The new state was successfully saved to the database.',
202
+			'event_espresso'
203
+		);
204
+		EE_Registry::$i18n_js_strings['ans_server_save_error'] = esc_html__(
205
+			'An unknown error has occurred on the server while saving the new state to the database.',
206
+			'event_espresso'
207
+		);
208
+	}
209
+
210
+
211
+	/**
212
+	 * @return void
213
+	 */
214
+	public static function wp_enqueue_scripts()
215
+	{
216
+		if (apply_filters('EED_Single_Page_Checkout__SPCO_active', false)) {
217
+			wp_register_script(
218
+				'add_new_state',
219
+				ANS_ASSETS_URL . 'add_new_state.js',
220
+				array('espresso_core', 'single_page_checkout'),
221
+				EVENT_ESPRESSO_VERSION,
222
+				true
223
+			);
224
+			wp_enqueue_script('add_new_state');
225
+		}
226
+	}
227
+
228
+
229
+
230
+	/**
231
+	 * display_add_new_state_micro_form
232
+	 *
233
+	 * @param EE_Form_Section_Proper $question_group_reg_form
234
+	 * @return string
235
+	 * @throws EE_Error
236
+	 * @throws InvalidArgumentException
237
+	 * @throws InvalidDataTypeException
238
+	 * @throws InvalidInterfaceException
239
+	 */
240
+	public static function display_add_new_state_micro_form(EE_Form_Section_Proper $question_group_reg_form)
241
+	{
242
+		// only add the 'new_state_micro_form' when displaying reg forms,
243
+		// not during processing since we process the 'new_state_micro_form' in it's own AJAX request
244
+		$action = EE_Registry::instance()->REQ->get('action', '');
245
+		// is the "state" question in this form section?
246
+		$input = $question_group_reg_form->get_subsection('state');
247
+		if ($action === 'process_reg_step' || $action === 'update_reg_step') {
248
+			// ok then all we need to do is make sure the input's HTML name is consistent
249
+			// by forcing it to set it now, like it did while getting the form for display
250
+			if ($input instanceof EE_State_Select_Input) {
251
+				$input->html_name();
252
+			}
253
+			return $question_group_reg_form;
254
+		}
255
+		// we're only doing this for state select inputs
256
+		if ($input instanceof EE_State_Select_Input
257
+			&& ! $input->get_display_strategy() instanceof EE_Hidden_Display_Strategy
258
+		) {
259
+			// grab any set values from the request
260
+			$country_name = str_replace('state', 'nsmf_new_state_country', $input->html_name());
261
+			$state_name = str_replace('state', 'nsmf_new_state_name', $input->html_name());
262
+			$abbrv_name = str_replace('state', 'nsmf_new_state_abbrv', $input->html_name());
263
+			$new_state_submit_id = str_replace('state', 'new_state', $input->html_id());
264
+			$country_options = array();
265
+			$countries = EEM_Country::instance()->get_all_countries();
266
+			if (! empty($countries)) {
267
+				foreach ($countries as $country) {
268
+					if ($country instanceof EE_Country) {
269
+						$country_options[ $country->ID() ] = $country->name();
270
+					}
271
+				}
272
+			}
273
+			$new_state_micro_form = new EE_Form_Section_Proper(
274
+				array(
275
+					'name'            => 'new_state_micro_form',
276
+					'html_id'         => 'new_state_micro_form',
277
+					'layout_strategy' => new EE_Div_Per_Section_Layout(),
278
+					'subsections'     => array(
279
+						// add hidden input to indicate that a new state is being added
280
+						'add_new_state'               => new EE_Hidden_Input(
281
+							array(
282
+								'html_name' => str_replace(
283
+									'state',
284
+									'nsmf_add_new_state',
285
+									$input->html_name()
286
+								),
287
+								'html_id'   => str_replace(
288
+									'state',
289
+									'nsmf_add_new_state',
290
+									$input->html_id()
291
+								),
292
+								'default'   => 0,
293
+							)
294
+						),
295
+						// add link for displaying hidden container
296
+						'click_here_link'             => new EE_Form_Section_HTML(
297
+							apply_filters(
298
+								'FHEE__EED_Add_New_State__display_add_new_state_micro_form__click_here_link',
299
+								EEH_HTML::link(
300
+									'',
301
+									esc_html__('click here to add a new state/province', 'event_espresso'),
302
+									'',
303
+									'display-' . $input->html_id(),
304
+									'ee-form-add-new-state-lnk display-the-hidden smaller-text hide-if-no-js',
305
+									'',
306
+									'data-target="' . $input->html_id() . '"'
307
+								)
308
+							)
309
+						),
310
+						// add initial html for hidden container
311
+						'add_new_state_micro_form'    => new EE_Form_Section_HTML(
312
+							apply_filters(
313
+								'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_micro_form',
314
+								EEH_HTML::div(
315
+									'',
316
+									$input->html_id() . '-dv',
317
+									'ee-form-add-new-state-dv',
318
+									'display: none;'
319
+								) .
320
+								EEH_HTML::h6(
321
+									esc_html__(
322
+										'Is your state/province missing from the dropdown menu above? You can add it by completing the following steps:',
323
+										'event_espresso'
324
+									)
325
+								) .
326
+								EEH_HTML::ul() .
327
+								EEH_HTML::li(
328
+									esc_html__(
329
+										'first select the Country that your State/Province belongs to',
330
+										'event_espresso'
331
+									)
332
+								) .
333
+								EEH_HTML::li(
334
+									esc_html__('enter the name of your State/Province', 'event_espresso')
335
+								) .
336
+								EEH_HTML::li(
337
+									esc_html__(
338
+										'enter a two to six letter abbreviation for the name of your State/Province',
339
+										'event_espresso'
340
+									)
341
+								) .
342
+								EEH_HTML::li(esc_html__('click the ADD button', 'event_espresso')) .
343
+								EEH_HTML::ulx()
344
+							)
345
+						),
346
+						// NEW STATE COUNTRY
347
+						'new_state_country'           => new EE_Country_Select_Input(
348
+							$country_options,
349
+							array(
350
+								'html_name'       => $country_name,
351
+								'html_id'         => str_replace(
352
+									'state',
353
+									'nsmf_new_state_country',
354
+									$input->html_id()
355
+								),
356
+								'html_class'      => $input->html_class() . ' new-state-country',
357
+								'html_label_text' => esc_html__('New State/Province Country', 'event_espresso'),
358
+								'default'         => EE_Registry::instance()->REQ->get($country_name, ''),
359
+								'required'        => false,
360
+							)
361
+						),
362
+						// NEW STATE NAME
363
+						'new_state_name'              => new EE_Text_Input(
364
+							array(
365
+								'html_name'       => $state_name,
366
+								'html_id'         => str_replace(
367
+									'state',
368
+									'nsmf_new_state_name',
369
+									$input->html_id()
370
+								),
371
+								'html_class'      => $input->html_class() . ' new-state-state',
372
+								'html_label_text' => esc_html__(
373
+									'New State/Province Name',
374
+									'event_espresso'
375
+								),
376
+								'default'         => EE_Registry::instance()->REQ->get($state_name, ''),
377
+								'required'        => false,
378
+							)
379
+						),
380
+						'spacer'                      => new EE_Form_Section_HTML(EEH_HTML::br()),
381
+						// NEW STATE NAME
382
+						'new_state_abbrv'             => new EE_Text_Input(
383
+							array(
384
+								'html_name'             => $abbrv_name,
385
+								'html_id'               => str_replace(
386
+									'state',
387
+									'nsmf_new_state_abbrv',
388
+									$input->html_id()
389
+								),
390
+								'html_class'            => $input->html_class() . ' new-state-abbrv',
391
+								'html_label_text'       => esc_html__(
392
+									'New State/Province Abbreviation',
393
+									'event_espresso'
394
+								) . ' *',
395
+								'html_other_attributes' => 'size="24"',
396
+								'default'               => EE_Registry::instance()->REQ->get($abbrv_name, ''),
397
+								'required'              => false,
398
+							)
399
+						),
400
+						// "submit" button
401
+						'add_new_state_submit_button' => new EE_Form_Section_HTML(
402
+							apply_filters(
403
+								'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_submit_button',
404
+								EEH_HTML::nbsp(3) .
405
+								EEH_HTML::link(
406
+									'',
407
+									esc_html__('ADD', 'event_espresso'),
408
+									'',
409
+									'submit-' . $new_state_submit_id,
410
+									'ee-form-add-new-state-submit button button-secondary',
411
+									'',
412
+									'data-target="' . $new_state_submit_id . '"'
413
+								)
414
+							)
415
+						),
416
+						// extra info
417
+						'add_new_state_extra'         => new EE_Form_Section_HTML(
418
+							apply_filters(
419
+								'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_extra',
420
+								EEH_HTML::br(2)
421
+								.
422
+								EEH_HTML::div('', '', 'small-text')
423
+								.
424
+								EEH_HTML::strong(
425
+									'* ' .
426
+									esc_html__(
427
+										'Don\'t know your State/Province Abbreviation?',
428
+										'event_espresso'
429
+									)
430
+								)
431
+								.
432
+								EEH_HTML::br()
433
+								.
434
+								sprintf(
435
+									esc_html__(
436
+										'You can look here: %s, for a list of Countries and links to their State/Province Abbreviations ("Subdivisions assigned codes" column).',
437
+										'event_espresso'
438
+									),
439
+									EEH_HTML::link(
440
+										'http://en.wikipedia.org/wiki/ISO_3166-2',
441
+										'http://en.wikipedia.org/wiki/ISO_3166-2',
442
+										'',
443
+										'',
444
+										'ee-form-add-new-state-wiki-lnk',
445
+										'',
446
+										'target="_blank"'
447
+									)
448
+								)
449
+								.
450
+								EEH_HTML::divx()
451
+								.
452
+								EEH_HTML::br()
453
+								.
454
+								EEH_HTML::link(
455
+									'',
456
+									esc_html__('cancel new State/Province', 'event_espresso'),
457
+									'',
458
+									'hide-' . $input->html_id(),
459
+									'ee-form-cancel-new-state-lnk smaller-text',
460
+									'',
461
+									'data-target="' . $input->html_id() . '"'
462
+								)
463
+								.
464
+								EEH_HTML::divx()
465
+								.
466
+								EEH_HTML::br()
467
+							)
468
+						),
469
+					),
470
+				)
471
+			);
472
+			$question_group_reg_form->add_subsections(
473
+				array('new_state_micro_form' => $new_state_micro_form),
474
+				'state',
475
+				false
476
+			);
477
+		}
478
+		return $question_group_reg_form;
479
+	}
480
+
481
+
482
+	/**
483
+	 * set_new_state_input_width
484
+	 *
485
+	 * @return int|string
486
+	 * @throws EE_Error
487
+	 * @throws InvalidArgumentException
488
+	 * @throws InvalidDataTypeException
489
+	 * @throws InvalidInterfaceException
490
+	 * @throws ReflectionException
491
+	 */
492
+	public static function add_new_state()
493
+	{
494
+		$REQ = EE_Registry::instance()->load_core('Request_Handler');
495
+		if (absint($REQ->get('nsmf_add_new_state')) === 1) {
496
+			EE_Registry::instance()->load_model('State');
497
+			// grab country ISO code, new state name, and new state abbreviation
498
+			$state_country = $REQ->is_set('nsmf_new_state_country')
499
+				? sanitize_text_field($REQ->get('nsmf_new_state_country'))
500
+				: false;
501
+			$state_name = $REQ->is_set('nsmf_new_state_name')
502
+				? sanitize_text_field($REQ->get('nsmf_new_state_name'))
503
+				: false;
504
+			$state_abbr = $REQ->is_set('nsmf_new_state_abbrv')
505
+				? sanitize_text_field($REQ->get('nsmf_new_state_abbrv'))
506
+				: false;
507
+			if ($state_country && $state_name && $state_abbr) {
508
+				$new_state = EED_Add_New_State::save_new_state_to_db(
509
+					array(
510
+						'CNT_ISO'    => strtoupper($state_country),
511
+						'STA_abbrev' => strtoupper($state_abbr),
512
+						'STA_name'   => ucwords($state_name),
513
+						'STA_active' => false,
514
+					)
515
+				);
516
+				if ($new_state instanceof EE_State) {
517
+					// clean house
518
+					EE_Registry::instance()->REQ->un_set('nsmf_add_new_state');
519
+					EE_Registry::instance()->REQ->un_set('nsmf_new_state_country');
520
+					EE_Registry::instance()->REQ->un_set('nsmf_new_state_name');
521
+					EE_Registry::instance()->REQ->un_set('nsmf_new_state_abbrv');
522
+					// get any existing new states
523
+					$new_states = EE_Registry::instance()->SSN->get_session_data(
524
+						'nsmf_new_states'
525
+					);
526
+					$new_states[ $new_state->ID() ] = $new_state;
527
+					EE_Registry::instance()->SSN->set_session_data(
528
+						array('nsmf_new_states' => $new_states)
529
+					);
530
+					if (EE_Registry::instance()->REQ->ajax) {
531
+						echo wp_json_encode(
532
+							array(
533
+								'success'      => true,
534
+								'id'           => $new_state->ID(),
535
+								'name'         => $new_state->name(),
536
+								'abbrev'       => $new_state->abbrev(),
537
+								'country_iso'  => $new_state->country_iso(),
538
+								'country_name' => $new_state->country()->name(),
539
+							)
540
+						);
541
+						exit();
542
+					}
543
+					return $new_state->ID();
544
+				}
545
+			} else {
546
+				$error = esc_html__(
547
+					'A new State/Province could not be added because invalid or missing data was received.',
548
+					'event_espresso'
549
+				);
550
+				if (EE_Registry::instance()->REQ->ajax) {
551
+					echo wp_json_encode(array('error' => $error));
552
+					exit();
553
+				}
554
+				EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__);
555
+			}
556
+		}
557
+		return false;
558
+	}
559
+
560
+
561
+	/**
562
+	 * recursively drills down through request params to remove any that were added by this module
563
+	 *
564
+	 * @param array $request_params
565
+	 * @return array
566
+	 */
567
+	public static function filter_checkout_request_params($request_params)
568
+	{
569
+		foreach ($request_params as $form_section) {
570
+			if (is_array($form_section)) {
571
+				EED_Add_New_State::unset_new_state_request_params($form_section);
572
+				EED_Add_New_State::filter_checkout_request_params($form_section);
573
+			}
574
+		}
575
+		return $request_params;
576
+	}
577
+
578
+
579
+	/**
580
+	 * @param array $request_params
581
+	 * @return array
582
+	 */
583
+	public static function unset_new_state_request_params($request_params)
584
+	{
585
+		unset(
586
+			$request_params['new_state_micro_form'],
587
+			$request_params['new_state_micro_add_new_state'],
588
+			$request_params['new_state_micro_new_state_country'],
589
+			$request_params['new_state_micro_new_state_name'],
590
+			$request_params['new_state_micro_new_state_abbrv']
591
+		);
592
+		return $request_params;
593
+	}
594
+
595
+
596
+	/**
597
+	 * @param array $props_n_values
598
+	 * @return bool
599
+	 * @throws EE_Error
600
+	 * @throws InvalidArgumentException
601
+	 * @throws InvalidDataTypeException
602
+	 * @throws InvalidInterfaceException
603
+	 */
604
+	public static function save_new_state_to_db($props_n_values = array())
605
+	{
606
+		$existing_state = EEM_State::instance()->get_all(array($props_n_values, 'limit' => 1));
607
+		if (! empty($existing_state)) {
608
+			return array_pop($existing_state);
609
+		}
610
+		$new_state = EE_State::new_instance($props_n_values);
611
+		if ($new_state instanceof EE_State) {
612
+			$country_settings_url = add_query_arg(
613
+				array(
614
+					'page'    => 'espresso_general_settings',
615
+					'action'  => 'country_settings',
616
+					'country' => $new_state->country_iso(),
617
+				),
618
+				admin_url('admin.php')
619
+			);
620
+			// if not non-ajax admin
621
+			new PersistentAdminNotice(
622
+				'new-state-added-' . $new_state->country_iso() . '-' . $new_state->abbrev(),
623
+				sprintf(
624
+					esc_html__(
625
+						'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.',
626
+						'event_espresso'
627
+					),
628
+					'<b>' . $new_state->name() . '</b>',
629
+					'<b>' . $new_state->abbrev() . '</b>',
630
+					'<b>' . $new_state->country()->name() . '</b>',
631
+					'<a href="'
632
+					. $country_settings_url
633
+					. '">'
634
+					. esc_html__(
635
+						'Event Espresso - General Settings > Countries Tab',
636
+						'event_espresso'
637
+					)
638
+					. '</a>',
639
+					'<br />'
640
+				)
641
+			);
642
+			$new_state->save();
643
+			EEM_State::instance()->reset_cached_states();
644
+			return $new_state;
645
+		}
646
+		return false;
647
+	}
648
+
649
+
650
+	/**
651
+	 * @param string $CNT_ISO
652
+	 * @param string $STA_ID
653
+	 * @param array  $cols_n_values
654
+	 * @return void
655
+	 * @throws DomainException
656
+	 * @throws EE_Error
657
+	 * @throws InvalidArgumentException
658
+	 * @throws InvalidDataTypeException
659
+	 * @throws InvalidInterfaceException
660
+	 */
661
+	public static function update_country_settings($CNT_ISO = '', $STA_ID = '', $cols_n_values = array())
662
+	{
663
+		if (! $CNT_ISO) {
664
+			EE_Error::add_error(
665
+				esc_html__('An invalid or missing Country ISO Code was received.', 'event_espresso'),
666
+				__FILE__,
667
+				__FUNCTION__,
668
+				__LINE__
669
+			);
670
+		}
671
+		$STA_abbrev = is_array($cols_n_values) && isset($cols_n_values['STA_abbrev']) ? $cols_n_values['STA_abbrev']
672
+			: false;
673
+		if (! $STA_abbrev && ! empty($STA_ID)) {
674
+			$state = EEM_State::instance()->get_one_by_ID($STA_ID);
675
+			if ($state instanceof EE_State) {
676
+				$STA_abbrev = $state->abbrev();
677
+			}
678
+		}
679
+		if (! $STA_abbrev) {
680
+			EE_Error::add_error(
681
+				esc_html__('An invalid or missing State Abbreviation was received.', 'event_espresso'),
682
+				__FILE__,
683
+				__FUNCTION__,
684
+				__LINE__
685
+			);
686
+		}
687
+		/** @var PersistentAdminNoticeManager $persistent_admin_notice_manager */
688
+		$persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared(
689
+			'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
690
+		);
691
+		$persistent_admin_notice_manager->dismissNotice($CNT_ISO . '-' . $STA_abbrev, true, true);
692
+	}
693
+
694
+
695
+	/**
696
+	 * @param EE_State[]                            $state_options
697
+	 * @param EE_SPCO_Reg_Step_Attendee_Information $reg_step
698
+	 * @param EE_Registration                       $registration
699
+	 * @param EE_Question                           $question
700
+	 * @param                                       $answer
701
+	 * @return array
702
+	 * @throws EE_Error
703
+	 * @throws InvalidArgumentException
704
+	 * @throws InvalidDataTypeException
705
+	 * @throws InvalidInterfaceException
706
+	 */
707
+	public static function inject_new_reg_state_into_options(
708
+		$state_options = array(),
709
+		EE_SPCO_Reg_Step_Attendee_Information $reg_step,
710
+		EE_Registration $registration,
711
+		EE_Question $question,
712
+		$answer
713
+	) {
714
+		if ($answer instanceof EE_Answer && $question instanceof EE_Question
715
+			&& $question->type() === EEM_Question::QST_type_state
716
+		) {
717
+			$STA_ID = $answer->value();
718
+			if (! empty($STA_ID)) {
719
+				$state = EEM_State::instance()->get_one_by_ID($STA_ID);
720
+				if ($state instanceof EE_State) {
721
+					$country = $state->country();
722
+					if ($country instanceof EE_Country) {
723
+						if (! isset($state_options[ $country->name() ])) {
724
+							$state_options[ $country->name() ] = array();
725
+						}
726
+						if (! isset($state_options[ $country->name() ][ $STA_ID ])) {
727
+							$state_options[ $country->name() ][ $STA_ID ] = $state->name();
728
+						}
729
+					}
730
+				}
731
+			}
732
+		}
733
+		return $state_options;
734
+	}
735
+
736
+
737
+	/**
738
+	 * @param EE_Country[]                          $country_options
739
+	 * @param EE_SPCO_Reg_Step_Attendee_Information $reg_step
740
+	 * @param EE_Registration                       $registration
741
+	 * @param EE_Question                           $question
742
+	 * @param                                       $answer
743
+	 * @return array
744
+	 * @throws EE_Error
745
+	 * @throws InvalidArgumentException
746
+	 * @throws InvalidDataTypeException
747
+	 * @throws InvalidInterfaceException
748
+	 */
749
+	public static function inject_new_reg_country_into_options(
750
+		$country_options = array(),
751
+		EE_SPCO_Reg_Step_Attendee_Information $reg_step,
752
+		EE_Registration $registration,
753
+		EE_Question $question,
754
+		$answer
755
+	) {
756
+		if ($answer instanceof EE_Answer && $question instanceof EE_Question
757
+			&& $question->type()
758
+			   === EEM_Question::QST_type_country
759
+		) {
760
+			$CNT_ISO = $answer->value();
761
+			if (! empty($CNT_ISO)) {
762
+				$country = EEM_Country::instance()->get_one_by_ID($CNT_ISO);
763
+				if ($country instanceof EE_Country) {
764
+					if (! isset($country_options[ $CNT_ISO ])) {
765
+						$country_options[ $CNT_ISO ] = $country->name();
766
+					}
767
+				}
768
+			}
769
+		}
770
+		return $country_options;
771
+	}
772
+
773
+
774
+	/**
775
+	 * @param EE_State[] $state_options
776
+	 * @return array
777
+	 * @throws EE_Error
778
+	 * @throws InvalidArgumentException
779
+	 * @throws InvalidDataTypeException
780
+	 * @throws InvalidInterfaceException
781
+	 */
782
+	public static function state_options($state_options = array())
783
+	{
784
+		$new_states = EED_Add_New_State::_get_new_states();
785
+		foreach ($new_states as $new_state) {
786
+			if ($new_state instanceof EE_State
787
+				&& $new_state->country() instanceof EE_Country
788
+			) {
789
+				$state_options[ $new_state->country()->name() ][ $new_state->ID() ] = $new_state->name();
790
+			}
791
+		}
792
+		return $state_options;
793
+	}
794
+
795
+
796
+	/**
797
+	 * @return array
798
+	 * @throws InvalidArgumentException
799
+	 * @throws InvalidDataTypeException
800
+	 * @throws InvalidInterfaceException
801
+	 */
802
+	protected static function _get_new_states()
803
+	{
804
+		$new_states = array();
805
+		if (EE_Registry::instance()->SSN instanceof EE_Session) {
806
+			$new_states = EE_Registry::instance()->SSN->get_session_data(
807
+				'nsmf_new_states'
808
+			);
809
+		}
810
+		return is_array($new_states) ? $new_states : array();
811
+	}
812
+
813
+
814
+	/**
815
+	 * @param EE_Country[] $country_options
816
+	 * @return array
817
+	 * @throws EE_Error
818
+	 * @throws InvalidArgumentException
819
+	 * @throws InvalidDataTypeException
820
+	 * @throws InvalidInterfaceException
821
+	 */
822
+	public static function country_options($country_options = array())
823
+	{
824
+		$new_states = EED_Add_New_State::_get_new_states();
825
+		foreach ($new_states as $new_state) {
826
+			if ($new_state instanceof EE_State
827
+				&& $new_state->country() instanceof EE_Country
828
+			) {
829
+				$country_options[ $new_state->country()->ID() ] = $new_state->country()->name();
830
+			}
831
+		}
832
+		return $country_options;
833
+	}
834 834
 }
Please login to merge, or discard this patch.
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -159,14 +159,14 @@  discard block
 block discarded – undo
159 159
      */
160 160
     public static function set_definitions()
161 161
     {
162
-        define('ANS_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets' . DS);
162
+        define('ANS_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS);
163 163
         define(
164 164
             'ANS_TEMPLATES_PATH',
165 165
             str_replace(
166 166
                 '\\',
167 167
                 DS,
168 168
                 plugin_dir_path(__FILE__)
169
-            ) . 'templates' . DS
169
+            ).'templates'.DS
170 170
         );
171 171
     }
172 172
 
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
         if (apply_filters('EED_Single_Page_Checkout__SPCO_active', false)) {
217 217
             wp_register_script(
218 218
                 'add_new_state',
219
-                ANS_ASSETS_URL . 'add_new_state.js',
219
+                ANS_ASSETS_URL.'add_new_state.js',
220 220
                 array('espresso_core', 'single_page_checkout'),
221 221
                 EVENT_ESPRESSO_VERSION,
222 222
                 true
@@ -263,10 +263,10 @@  discard block
 block discarded – undo
263 263
             $new_state_submit_id = str_replace('state', 'new_state', $input->html_id());
264 264
             $country_options = array();
265 265
             $countries = EEM_Country::instance()->get_all_countries();
266
-            if (! empty($countries)) {
266
+            if ( ! empty($countries)) {
267 267
                 foreach ($countries as $country) {
268 268
                     if ($country instanceof EE_Country) {
269
-                        $country_options[ $country->ID() ] = $country->name();
269
+                        $country_options[$country->ID()] = $country->name();
270 270
                     }
271 271
                 }
272 272
             }
@@ -300,10 +300,10 @@  discard block
 block discarded – undo
300 300
                                     '',
301 301
                                     esc_html__('click here to add a new state/province', 'event_espresso'),
302 302
                                     '',
303
-                                    'display-' . $input->html_id(),
303
+                                    'display-'.$input->html_id(),
304 304
                                     'ee-form-add-new-state-lnk display-the-hidden smaller-text hide-if-no-js',
305 305
                                     '',
306
-                                    'data-target="' . $input->html_id() . '"'
306
+                                    'data-target="'.$input->html_id().'"'
307 307
                                 )
308 308
                             )
309 309
                         ),
@@ -313,33 +313,33 @@  discard block
 block discarded – undo
313 313
                                 'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_micro_form',
314 314
                                 EEH_HTML::div(
315 315
                                     '',
316
-                                    $input->html_id() . '-dv',
316
+                                    $input->html_id().'-dv',
317 317
                                     'ee-form-add-new-state-dv',
318 318
                                     'display: none;'
319
-                                ) .
319
+                                ).
320 320
                                 EEH_HTML::h6(
321 321
                                     esc_html__(
322 322
                                         'Is your state/province missing from the dropdown menu above? You can add it by completing the following steps:',
323 323
                                         'event_espresso'
324 324
                                     )
325
-                                ) .
326
-                                EEH_HTML::ul() .
325
+                                ).
326
+                                EEH_HTML::ul().
327 327
                                 EEH_HTML::li(
328 328
                                     esc_html__(
329 329
                                         'first select the Country that your State/Province belongs to',
330 330
                                         'event_espresso'
331 331
                                     )
332
-                                ) .
332
+                                ).
333 333
                                 EEH_HTML::li(
334 334
                                     esc_html__('enter the name of your State/Province', 'event_espresso')
335
-                                ) .
335
+                                ).
336 336
                                 EEH_HTML::li(
337 337
                                     esc_html__(
338 338
                                         'enter a two to six letter abbreviation for the name of your State/Province',
339 339
                                         'event_espresso'
340 340
                                     )
341
-                                ) .
342
-                                EEH_HTML::li(esc_html__('click the ADD button', 'event_espresso')) .
341
+                                ).
342
+                                EEH_HTML::li(esc_html__('click the ADD button', 'event_espresso')).
343 343
                                 EEH_HTML::ulx()
344 344
                             )
345 345
                         ),
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
                                     'nsmf_new_state_country',
354 354
                                     $input->html_id()
355 355
                                 ),
356
-                                'html_class'      => $input->html_class() . ' new-state-country',
356
+                                'html_class'      => $input->html_class().' new-state-country',
357 357
                                 'html_label_text' => esc_html__('New State/Province Country', 'event_espresso'),
358 358
                                 'default'         => EE_Registry::instance()->REQ->get($country_name, ''),
359 359
                                 'required'        => false,
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
                                     'nsmf_new_state_name',
369 369
                                     $input->html_id()
370 370
                                 ),
371
-                                'html_class'      => $input->html_class() . ' new-state-state',
371
+                                'html_class'      => $input->html_class().' new-state-state',
372 372
                                 'html_label_text' => esc_html__(
373 373
                                     'New State/Province Name',
374 374
                                     'event_espresso'
@@ -387,11 +387,11 @@  discard block
 block discarded – undo
387 387
                                     'nsmf_new_state_abbrv',
388 388
                                     $input->html_id()
389 389
                                 ),
390
-                                'html_class'            => $input->html_class() . ' new-state-abbrv',
390
+                                'html_class'            => $input->html_class().' new-state-abbrv',
391 391
                                 'html_label_text'       => esc_html__(
392 392
                                     'New State/Province Abbreviation',
393 393
                                     'event_espresso'
394
-                                ) . ' *',
394
+                                ).' *',
395 395
                                 'html_other_attributes' => 'size="24"',
396 396
                                 'default'               => EE_Registry::instance()->REQ->get($abbrv_name, ''),
397 397
                                 'required'              => false,
@@ -401,15 +401,15 @@  discard block
 block discarded – undo
401 401
                         'add_new_state_submit_button' => new EE_Form_Section_HTML(
402 402
                             apply_filters(
403 403
                                 'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_submit_button',
404
-                                EEH_HTML::nbsp(3) .
404
+                                EEH_HTML::nbsp(3).
405 405
                                 EEH_HTML::link(
406 406
                                     '',
407 407
                                     esc_html__('ADD', 'event_espresso'),
408 408
                                     '',
409
-                                    'submit-' . $new_state_submit_id,
409
+                                    'submit-'.$new_state_submit_id,
410 410
                                     'ee-form-add-new-state-submit button button-secondary',
411 411
                                     '',
412
-                                    'data-target="' . $new_state_submit_id . '"'
412
+                                    'data-target="'.$new_state_submit_id.'"'
413 413
                                 )
414 414
                             )
415 415
                         ),
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
                                 EEH_HTML::div('', '', 'small-text')
423 423
                                 .
424 424
                                 EEH_HTML::strong(
425
-                                    '* ' .
425
+                                    '* '.
426 426
                                     esc_html__(
427 427
                                         'Don\'t know your State/Province Abbreviation?',
428 428
                                         'event_espresso'
@@ -455,10 +455,10 @@  discard block
 block discarded – undo
455 455
                                     '',
456 456
                                     esc_html__('cancel new State/Province', 'event_espresso'),
457 457
                                     '',
458
-                                    'hide-' . $input->html_id(),
458
+                                    'hide-'.$input->html_id(),
459 459
                                     'ee-form-cancel-new-state-lnk smaller-text',
460 460
                                     '',
461
-                                    'data-target="' . $input->html_id() . '"'
461
+                                    'data-target="'.$input->html_id().'"'
462 462
                                 )
463 463
                                 .
464 464
                                 EEH_HTML::divx()
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
                     $new_states = EE_Registry::instance()->SSN->get_session_data(
524 524
                         'nsmf_new_states'
525 525
                     );
526
-                    $new_states[ $new_state->ID() ] = $new_state;
526
+                    $new_states[$new_state->ID()] = $new_state;
527 527
                     EE_Registry::instance()->SSN->set_session_data(
528 528
                         array('nsmf_new_states' => $new_states)
529 529
                     );
@@ -604,7 +604,7 @@  discard block
 block discarded – undo
604 604
     public static function save_new_state_to_db($props_n_values = array())
605 605
     {
606 606
         $existing_state = EEM_State::instance()->get_all(array($props_n_values, 'limit' => 1));
607
-        if (! empty($existing_state)) {
607
+        if ( ! empty($existing_state)) {
608 608
             return array_pop($existing_state);
609 609
         }
610 610
         $new_state = EE_State::new_instance($props_n_values);
@@ -619,15 +619,15 @@  discard block
 block discarded – undo
619 619
             );
620 620
             // if not non-ajax admin
621 621
             new PersistentAdminNotice(
622
-                'new-state-added-' . $new_state->country_iso() . '-' . $new_state->abbrev(),
622
+                'new-state-added-'.$new_state->country_iso().'-'.$new_state->abbrev(),
623 623
                 sprintf(
624 624
                     esc_html__(
625 625
                         '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.',
626 626
                         'event_espresso'
627 627
                     ),
628
-                    '<b>' . $new_state->name() . '</b>',
629
-                    '<b>' . $new_state->abbrev() . '</b>',
630
-                    '<b>' . $new_state->country()->name() . '</b>',
628
+                    '<b>'.$new_state->name().'</b>',
629
+                    '<b>'.$new_state->abbrev().'</b>',
630
+                    '<b>'.$new_state->country()->name().'</b>',
631 631
                     '<a href="'
632 632
                     . $country_settings_url
633 633
                     . '">'
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
      */
661 661
     public static function update_country_settings($CNT_ISO = '', $STA_ID = '', $cols_n_values = array())
662 662
     {
663
-        if (! $CNT_ISO) {
663
+        if ( ! $CNT_ISO) {
664 664
             EE_Error::add_error(
665 665
                 esc_html__('An invalid or missing Country ISO Code was received.', 'event_espresso'),
666 666
                 __FILE__,
@@ -670,13 +670,13 @@  discard block
 block discarded – undo
670 670
         }
671 671
         $STA_abbrev = is_array($cols_n_values) && isset($cols_n_values['STA_abbrev']) ? $cols_n_values['STA_abbrev']
672 672
             : false;
673
-        if (! $STA_abbrev && ! empty($STA_ID)) {
673
+        if ( ! $STA_abbrev && ! empty($STA_ID)) {
674 674
             $state = EEM_State::instance()->get_one_by_ID($STA_ID);
675 675
             if ($state instanceof EE_State) {
676 676
                 $STA_abbrev = $state->abbrev();
677 677
             }
678 678
         }
679
-        if (! $STA_abbrev) {
679
+        if ( ! $STA_abbrev) {
680 680
             EE_Error::add_error(
681 681
                 esc_html__('An invalid or missing State Abbreviation was received.', 'event_espresso'),
682 682
                 __FILE__,
@@ -688,7 +688,7 @@  discard block
 block discarded – undo
688 688
         $persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared(
689 689
             'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
690 690
         );
691
-        $persistent_admin_notice_manager->dismissNotice($CNT_ISO . '-' . $STA_abbrev, true, true);
691
+        $persistent_admin_notice_manager->dismissNotice($CNT_ISO.'-'.$STA_abbrev, true, true);
692 692
     }
693 693
 
694 694
 
@@ -715,16 +715,16 @@  discard block
 block discarded – undo
715 715
             && $question->type() === EEM_Question::QST_type_state
716 716
         ) {
717 717
             $STA_ID = $answer->value();
718
-            if (! empty($STA_ID)) {
718
+            if ( ! empty($STA_ID)) {
719 719
                 $state = EEM_State::instance()->get_one_by_ID($STA_ID);
720 720
                 if ($state instanceof EE_State) {
721 721
                     $country = $state->country();
722 722
                     if ($country instanceof EE_Country) {
723
-                        if (! isset($state_options[ $country->name() ])) {
724
-                            $state_options[ $country->name() ] = array();
723
+                        if ( ! isset($state_options[$country->name()])) {
724
+                            $state_options[$country->name()] = array();
725 725
                         }
726
-                        if (! isset($state_options[ $country->name() ][ $STA_ID ])) {
727
-                            $state_options[ $country->name() ][ $STA_ID ] = $state->name();
726
+                        if ( ! isset($state_options[$country->name()][$STA_ID])) {
727
+                            $state_options[$country->name()][$STA_ID] = $state->name();
728 728
                         }
729 729
                     }
730 730
                 }
@@ -758,11 +758,11 @@  discard block
 block discarded – undo
758 758
                === EEM_Question::QST_type_country
759 759
         ) {
760 760
             $CNT_ISO = $answer->value();
761
-            if (! empty($CNT_ISO)) {
761
+            if ( ! empty($CNT_ISO)) {
762 762
                 $country = EEM_Country::instance()->get_one_by_ID($CNT_ISO);
763 763
                 if ($country instanceof EE_Country) {
764
-                    if (! isset($country_options[ $CNT_ISO ])) {
765
-                        $country_options[ $CNT_ISO ] = $country->name();
764
+                    if ( ! isset($country_options[$CNT_ISO])) {
765
+                        $country_options[$CNT_ISO] = $country->name();
766 766
                     }
767 767
                 }
768 768
             }
@@ -786,7 +786,7 @@  discard block
 block discarded – undo
786 786
             if ($new_state instanceof EE_State
787 787
                 && $new_state->country() instanceof EE_Country
788 788
             ) {
789
-                $state_options[ $new_state->country()->name() ][ $new_state->ID() ] = $new_state->name();
789
+                $state_options[$new_state->country()->name()][$new_state->ID()] = $new_state->name();
790 790
             }
791 791
         }
792 792
         return $state_options;
@@ -826,7 +826,7 @@  discard block
 block discarded – undo
826 826
             if ($new_state instanceof EE_State
827 827
                 && $new_state->country() instanceof EE_Country
828 828
             ) {
829
-                $country_options[ $new_state->country()->ID() ] = $new_state->country()->name();
829
+                $country_options[$new_state->country()->ID()] = $new_state->country()->name();
830 830
             }
831 831
         }
832 832
         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   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -12,95 +12,95 @@
 block discarded – undo
12 12
 {
13 13
 
14 14
 
15
-    /**
16
-     * @return EED_Module
17
-     */
18
-    public static function instance()
19
-    {
20
-        return parent::get_instance(__CLASS__);
21
-    }
15
+	/**
16
+	 * @return EED_Module
17
+	 */
18
+	public static function instance()
19
+	{
20
+		return parent::get_instance(__CLASS__);
21
+	}
22 22
 
23 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
-    }
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
+	}
33 33
 
34
-    /**
35
-     *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
36
-     *
37
-     * @access    public
38
-     * @return    void
39
-     */
40
-    public static function set_hooks_admin()
41
-    {
42
-    }
34
+	/**
35
+	 *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
36
+	 *
37
+	 * @access    public
38
+	 * @return    void
39
+	 */
40
+	public static function set_hooks_admin()
41
+	{
42
+	}
43 43
 
44 44
 
45
-    /**
46
-     *    run - initial module setup
47
-     *
48
-     * @access    public
49
-     * @return    void
50
-     */
51
-    public function run($WP)
52
-    {
53
-    }
45
+	/**
46
+	 *    run - initial module setup
47
+	 *
48
+	 * @access    public
49
+	 * @return    void
50
+	 */
51
+	public function run($WP)
52
+	{
53
+	}
54 54
 
55 55
 
56
-    /**
57
-     *    certificate_launch
58
-     *
59
-     * @access    public
60
-     * @return    void
61
-     */
62
-    public function certificate_launch()
63
-    {
64
-        if (EE_Registry::instance()->REQ->is_set('id') && EE_Registry::instance()->REQ->is_set('r_id')) {
65
-            echo espresso_certificate_launch(
66
-                EE_Registry::instance()->REQ->get('id'),
67
-                EE_Registry::instance()->REQ->get('r_id')
68
-            );
69
-        }
70
-    }
56
+	/**
57
+	 *    certificate_launch
58
+	 *
59
+	 * @access    public
60
+	 * @return    void
61
+	 */
62
+	public function certificate_launch()
63
+	{
64
+		if (EE_Registry::instance()->REQ->is_set('id') && EE_Registry::instance()->REQ->is_set('r_id')) {
65
+			echo espresso_certificate_launch(
66
+				EE_Registry::instance()->REQ->get('id'),
67
+				EE_Registry::instance()->REQ->get('r_id')
68
+			);
69
+		}
70
+	}
71 71
 
72 72
 
73
-    /**
74
-     *    wp_loaded
75
-     *
76
-     * @access    public
77
-     * @return    void
78
-     */
79
-    public function wp_loaded()
80
-    {
81
-    }
73
+	/**
74
+	 *    wp_loaded
75
+	 *
76
+	 * @access    public
77
+	 * @return    void
78
+	 */
79
+	public function wp_loaded()
80
+	{
81
+	}
82 82
 
83 83
 
84
-    /**
85
-     *    wp
86
-     *
87
-     * @access    public
88
-     * @return    void
89
-     */
90
-    public function wp()
91
-    {
92
-    }
84
+	/**
85
+	 *    wp
86
+	 *
87
+	 * @access    public
88
+	 * @return    void
89
+	 */
90
+	public function wp()
91
+	{
92
+	}
93 93
 
94 94
 
95
-    /**
96
-     *    the_content
97
-     *
98
-     * @access    public
99
-     * @return    void
100
-     */
101
-    public function the_content($content)
102
-    {
103
-        $content .= $this->ouput;
104
-        return $content;
105
-    }
95
+	/**
96
+	 *    the_content
97
+	 *
98
+	 * @access    public
99
+	 * @return    void
100
+	 */
101
+	public function the_content($content)
102
+	{
103
+		$content .= $this->ouput;
104
+		return $content;
105
+	}
106 106
 }
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   +1021 added lines, -1021 removed lines patch added patch discarded remove patch
@@ -12,1025 +12,1025 @@
 block discarded – undo
12 12
 {
13 13
 
14 14
 
15
-    /**
16
-     * @return EED_Events_Archive_Filters
17
-     */
18
-    public static function instance()
19
-    {
20
-        return parent::get_instance(__CLASS__);
21
-    }
22
-
23
-
24
-    /**
25
-     *    Start Date
26
-     *
27
-     * @var    $_elf_month
28
-     * @access    protected
29
-     */
30
-    protected $_elf_month = null;
31
-
32
-
33
-    /**
34
-     *    Category
35
-     *
36
-     * @var    $_elf_category
37
-     * @access    protected
38
-     */
39
-    protected $_elf_category = null;
40
-
41
-
42
-    /**
43
-     *    whether to display expired events in the event list
44
-     *
45
-     * @var    $_show_expired
46
-     * @access    protected
47
-     */
48
-    protected $_show_expired = null;
49
-
50
-
51
-    /**
52
-     *    whether to display the event list as a grid or list
53
-     *
54
-     * @var    $_type
55
-     * @access    protected
56
-     */
57
-    protected static $_type = null;
58
-
59
-
60
-    /**
61
-     *    array of existing event list views
62
-     *
63
-     * @var    $_types
64
-     * @access    protected
65
-     */
66
-    protected static $_types = array('grid', 'text', 'dates');
67
-
68
-
69
-
70
-    /**
71
-     *    set_hooks - for hooking into EE Core, other modules, etc
72
-     *
73
-     * @access    public
74
-     * @return    void
75
-     */
76
-    public static function set_hooks()
77
-    {
78
-    }
79
-
80
-    /**
81
-     *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
82
-     *
83
-     * @access    public
84
-     * @return    void
85
-     */
86
-    public static function set_hooks_admin()
87
-    {
88
-    }
89
-
90
-
91
-    /**
92
-     *    set_definitions
93
-     *
94
-     * @access    public
95
-     * @return    void
96
-     */
97
-    public static function set_definitions()
98
-    {
99
-    }
100
-
101
-
102
-    /**
103
-     *    run - initial module setup
104
-     *
105
-     * @access    public
106
-     * @return    void
107
-     */
108
-    public function run($WP)
109
-    {
110
-    }
111
-
112
-
113
-    /**
114
-     *    event_list
115
-     *
116
-     * @access    public
117
-     * @return    void
118
-     */
119
-    public function event_list()
120
-    {
121
-        // load other required components
122
-        $this->_load_assests();
123
-    }
124
-
125
-
126
-    /**
127
-     *    _filter_query_parts
128
-     *
129
-     * @access    public
130
-     * @return    void
131
-     */
132
-    private function _filter_query_parts()
133
-    {
134
-        // build event list query
135
-        add_filter('posts_join', array($this, 'posts_join'), 1, 2);
136
-        add_filter('posts_where', array($this, 'posts_where'), 1, 2);
137
-        add_filter('posts_orderby', array($this, 'posts_orderby'), 1, 2);
138
-    }
139
-
140
-    /**
141
-     *    _type - the type of event list : grid, text, dates
142
-     *
143
-     * @access    public
144
-     * @return    string
145
-     */
146
-    public static function set_type()
147
-    {
148
-        do_action('AHEE__EED_Events_Archive_Filters__before_set_type');
149
-        EED_Events_Archive_Filters::$_types = apply_filters(
150
-            'EED_Events_Archive_Filters__set_type__types',
151
-            EED_Events_Archive_Filters::$_types
152
-        );
153
-        $view = isset(EE_Registry::instance()->CFG->EED_Events_Archive_Filters['default_type']) ? EE_Registry::instance(
154
-        )->CFG->EED_Events_Archive_Filters['default_type'] : 'grid';
155
-        $elf_type = EE_Registry::instance()->REQ->is_set('elf_type') ? sanitize_text_field(
156
-            EE_Registry::instance()->REQ->get('elf_type')
157
-        ) : '';
158
-        $view = ! empty($elf_type) ? $elf_type : $view;
159
-        $view = apply_filters('EED_Events_Archive_Filters__set_type__type', $view);
160
-        if (! empty($view) && in_array($view, EED_Events_Archive_Filters::$_types)) {
161
-            self::$_type = $view;
162
-        }
163
-    }
164
-
165
-    /**
166
-     *    _show_expired
167
-     *
168
-     * @access    private
169
-     * @param    boolean $req_only if TRUE, then ignore defaults and only return $_POST value
170
-     * @return    boolean
171
-     */
172
-    private static function _show_expired($req_only = false)
173
-    {
174
-        // get default value for "display_expired_events" as set in the EE General Settings > Templates > Event Listings
175
-        $show_expired = ! $req_only && isset(
176
-            EE_Registry::instance()->CFG->EED_Events_Archive_Filters['display_expired_events']
177
-        ) ? EE_Registry::instance()->CFG->EED_Events_Archive_Filters['display_expired_events'] : false;
178
-        // override default expired option if set via filter
179
-        $show_expired = EE_Registry::instance()->REQ->is_set('elf_expired_chk') ? absint(
180
-            EE_Registry::instance()->REQ->get('elf_expired_chk')
181
-        ) : $show_expired;
182
-        return $show_expired ? true : false;
183
-    }
184
-
185
-    /**
186
-     *    _event_category_slug
187
-     *
188
-     * @access    private
189
-     * @return    string
190
-     */
191
-    private static function _event_category_slug()
192
-    {
193
-        return EE_Registry::instance()->REQ->is_set('elf_category_dd') ? sanitize_text_field(
194
-            EE_Registry::instance()->REQ->get('elf_category_dd')
195
-        ) : '';
196
-    }
197
-
198
-    /**
199
-     *    _display_month - what month should the event list display events for?
200
-     *
201
-     * @access    private
202
-     * @return    string
203
-     */
204
-    private static function _display_month()
205
-    {
206
-        return EE_Registry::instance()->REQ->is_set('elf_month_dd') ? sanitize_text_field(
207
-            EE_Registry::instance()->REQ->get('elf_month_dd')
208
-        ) : '';
209
-    }
210
-
211
-
212
-    /**
213
-     *    get_post_data
214
-     *
215
-     * @access    public
216
-     * @return    void
217
-     */
218
-    public function get_post_data()
219
-    {
220
-        $this->_elf_month = EED_Events_Archive_Filters::_display_month();
221
-        $this->_elf_category = EED_Events_Archive_Filters::_event_category_slug();
222
-        $this->_show_expired = EED_Events_Archive_Filters::_show_expired(true);
223
-    }
224
-
225
-
226
-    /**
227
-     *    posts_join
228
-     *
229
-     * @access    public
230
-     * @return    void
231
-     */
232
-    public function posts_join($SQL, WP_Query $wp_query)
233
-    {
234
-        if (isset($wp_query->query) && isset($wp_query->query['post_type']) && $wp_query->query['post_type'] == 'espresso_events') {
235
-            // Category
236
-            $SQL .= EED_Events_Archive_Filters::posts_join_sql_for_terms(
237
-                EED_Events_Archive_Filters::_event_category_slug()
238
-            );
239
-        }
240
-        return $SQL;
241
-    }
242
-
243
-
244
-    /**
245
-     *    posts_join_sql_for_terms
246
-     *
247
-     * @access    public
248
-     * @param    mixed boolean|string    $join_terms pass TRUE or term string, doesn't really matter since this value
249
-     *                                   doesn't really get used for anything yet
250
-     * @return    string
251
-     */
252
-    public static function posts_join_sql_for_terms($join_terms = null)
253
-    {
254
-        $SQL = '';
255
-        if (! empty($join_terms)) {
256
-            global $wpdb;
257
-            $SQL .= " LEFT JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id)";
258
-            $SQL .= " LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)";
259
-            $SQL .= " LEFT JOIN $wpdb->terms ON ($wpdb->terms.term_id = $wpdb->term_taxonomy.term_id) ";
260
-        }
261
-        return $SQL;
262
-    }
263
-
264
-
265
-    /**
266
-     *    posts_join_for_orderby
267
-     *    usage:  $SQL .= EED_Events_Archive_Filters::posts_join_for_orderby( $orderby_params );
268
-     *
269
-     * @access    public
270
-     * @param    array $orderby_params
271
-     * @return    string
272
-     */
273
-    public static function posts_join_for_orderby($orderby_params = array())
274
-    {
275
-        global $wpdb;
276
-        $SQL = '';
277
-        $orderby_params = is_array($orderby_params) ? $orderby_params : array($orderby_params);
278
-        foreach ($orderby_params as $orderby) {
279
-            switch ($orderby) {
280
-                case 'ticket_start':
281
-                case 'ticket_end':
282
-                    $SQL .= ' LEFT JOIN ' . EEM_Datetime_Ticket::instance()->table() . ' ON ('
283
-                            . EEM_Datetime::instance()->table() . '.DTT_ID = '
284
-                            . EEM_Datetime_Ticket::instance()->table() . '.DTT_ID )';
285
-                    $SQL .= ' LEFT JOIN ' . EEM_Ticket::instance()->table() . ' ON ('
286
-                            . EEM_Datetime_Ticket::instance()->table() . '.TKT_ID = '
287
-                            . EEM_Ticket::instance()->table() . '.TKT_ID )';
288
-                    break;
289
-
290
-                case 'venue_title':
291
-                case 'city':
292
-                    $SQL .= ' LEFT JOIN ' . EEM_Event_Venue::instance()->table() . ' ON (' . $wpdb->posts . '.ID = '
293
-                            . EEM_Event_Venue::instance()->table() . '.EVT_ID )';
294
-                    $SQL .= ' LEFT JOIN ' . EEM_Venue::instance()->table() . ' ON ('
295
-                            . EEM_Event_Venue::instance()->table() . '.VNU_ID = '
296
-                            . EEM_Venue::instance()->table() . '.VNU_ID )';
297
-                    break;
298
-
299
-                case 'state':
300
-                    $SQL .= ' LEFT JOIN ' . EEM_Event_Venue::instance()->table() . ' ON (' . $wpdb->posts . '.ID = '
301
-                            . EEM_Event_Venue::instance()->table() . '.EVT_ID )';
302
-                    $SQL .= ' LEFT JOIN ' . EEM_Event_Venue::instance()->second_table() . ' ON ('
303
-                            . EEM_Event_Venue::instance()->table() . '.VNU_ID = '
304
-                            . EEM_Event_Venue::instance()->second_table() . '.VNU_ID )';
305
-                    break;
306
-            }
307
-        }
308
-        return $SQL;
309
-    }
310
-
311
-
312
-    /**
313
-     *    posts_where
314
-     *
315
-     * @access    public
316
-     * @return    void
317
-     */
318
-    public function posts_where($SQL, WP_Query $wp_query)
319
-    {
320
-        if (isset($wp_query->query_vars) && isset($wp_query->query_vars['post_type']) && $wp_query->query_vars['post_type'] == 'espresso_events') {
321
-            // Show Expired ?
322
-            $SQL .= EED_Events_Archive_Filters::posts_where_sql_for_show_expired(
323
-                EED_Events_Archive_Filters::_show_expired()
324
-            );
325
-            // Category
326
-            // $elf_category = EED_Events_Archive_Filters::_event_category_slug();
327
-            $SQL .= EED_Events_Archive_Filters::posts_where_sql_for_event_category_slug(
328
-                EED_Events_Archive_Filters::_event_category_slug()
329
-            );
330
-            // Start Date
331
-            // $elf_month = EED_Events_Archive_Filters::_display_month();
332
-            $SQL .= EED_Events_Archive_Filters::posts_where_sql_for_event_list_month(
333
-                EED_Events_Archive_Filters::_display_month()
334
-            );
335
-        }
336
-        return $SQL;
337
-    }
338
-
339
-
340
-    /**
341
-     *    posts_where_sql_for_show_expired
342
-     *
343
-     * @access    public
344
-     * @param    boolean $show_expired if TRUE, then displayed past events
345
-     * @return    string
346
-     */
347
-    public static function posts_where_sql_for_show_expired($show_expired = false)
348
-    {
349
-        return ! $show_expired
350
-            ? ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_end > "' . date('Y-m-d H:s:i') . '" '
351
-            : '';
352
-    }
353
-
354
-
355
-    /**
356
-     *    posts_where_sql_for_event_category_slug
357
-     *
358
-     * @access    public
359
-     * @param    boolean $event_category_slug
360
-     * @return    string
361
-     */
362
-    public static function posts_where_sql_for_event_category_slug($event_category_slug = null)
363
-    {
364
-        global $wpdb;
365
-        return ! empty($event_category_slug) ? ' AND ' . $wpdb->terms . '.slug = "' . $event_category_slug . '" ' : '';
366
-    }
367
-
368
-    /**
369
-     *    posts_where_sql_for_event_list_month
370
-     *
371
-     * @access    public
372
-     * @param    boolean $month
373
-     * @return    string
374
-     */
375
-    public static function posts_where_sql_for_event_list_month($month = null)
376
-    {
377
-        $SQL = '';
378
-        if (! empty($month)) {
379
-            // event start date is LESS than the end of the month ( so nothing that doesn't start until next month )
380
-            $SQL = ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_start';
381
-            $SQL .= ' <= "' . date('Y-m-t 23:59:59', \EEH_DTT_Helper::first_of_month_timestamp($month)) . '"';
382
-            // event end date is GREATER than the start of the month ( so nothing that ended before this month )
383
-            $SQL .= ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_end';
384
-            $SQL .= ' >= "' . date('Y-m-d 0:0:00', \EEH_DTT_Helper::first_of_month_timestamp($month)) . '" ';
385
-        }
386
-        return $SQL;
387
-    }
388
-
389
-
390
-    /**
391
-     *    posts_orderby
392
-     *
393
-     * @access    public
394
-     * @return    void
395
-     */
396
-    public function posts_orderby($SQL, WP_Query $wp_query)
397
-    {
398
-        if (isset($wp_query->query) && isset($wp_query->query['post_type']) && $wp_query->query['post_type'] == 'espresso_events') {
399
-            $SQL = EED_Events_Archive_Filters::posts_orderby_sql(array('start_date'));
400
-        }
401
-        return $SQL;
402
-    }
403
-
404
-
405
-    /**
406
-     *    posts_orderby_sql
407
-     *
408
-     *    possible parameters:
409
-     *    ID
410
-     *    start_date
411
-     *    end_date
412
-     *    event_name
413
-     *    category_slug
414
-     *    ticket_start
415
-     *    ticket_end
416
-     *    venue_title
417
-     *    city
418
-     *    state
419
-     *
420
-     *    **IMPORTANT**
421
-     *    make sure to also send the $orderby_params array to the posts_join_for_orderby() method
422
-     *    or else some of the table references below will result in MySQL errors
423
-     *
424
-     * @access    public
425
-     * @param    boolean $orderby_params
426
-     * @return    string
427
-     */
428
-    public static function posts_orderby_sql($orderby_params = array(), $sort = 'ASC')
429
-    {
430
-        global $wpdb;
431
-        $SQL = '';
432
-        $cntr = 1;
433
-        $orderby_params = is_array($orderby_params) ? $orderby_params : array($orderby_params);
434
-        foreach ($orderby_params as $orderby) {
435
-            $glue = $cntr == 1 || $cntr == count($orderby_params) ? ' ' : ', ';
436
-            switch ($orderby) {
437
-                case 'id':
438
-                case 'ID':
439
-                    $SQL .= $glue . $wpdb->posts . '.ID ' . $sort;
440
-                    break;
441
-
442
-                case 'start_date':
443
-                    $SQL .= $glue . EEM_Datetime::instance()->table() . '.DTT_EVT_start ' . $sort;
444
-                    break;
445
-
446
-                case 'end_date':
447
-                    $SQL .= $glue . EEM_Datetime::instance()->table() . '.DTT_EVT_end ' . $sort;
448
-                    break;
449
-
450
-                case 'event_name':
451
-                    $SQL .= $glue . $wpdb->posts . '.post_title ' . $sort;
452
-                    break;
453
-
454
-                case 'category_slug':
455
-                    $SQL .= $glue . $wpdb->terms . '.slug ' . $sort;
456
-                    break;
457
-
458
-                case 'ticket_start':
459
-                    $SQL .= $glue . EEM_Ticket::instance()->table() . '.TKT_start_date ' . $sort;
460
-                    break;
461
-
462
-                case 'ticket_end':
463
-                    $SQL .= $glue . EEM_Ticket::instance()->table() . '.TKT_end_date ' . $sort;
464
-                    break;
465
-
466
-                case 'venue_title':
467
-                    $SQL .= $glue . 'venue_title ' . $sort;
468
-                    break;
469
-
470
-                case 'city':
471
-                    $SQL .= $glue . EEM_Venue::instance()->second_table() . '.VNU_city ' . $sort;
472
-                    break;
473
-
474
-                case 'state':
475
-                    $SQL .= $glue . EEM_State::instance()->table() . '.STA_name ' . $sort;
476
-                    break;
477
-            }
478
-            $cntr++;
479
-        }
480
-        // echo '<h4>$SQL : ' . $SQL . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
481
-        return $SQL;
482
-    }
483
-
484
-
485
-    /**
486
-     *    template_redirect
487
-     *
488
-     * @access    public
489
-     * @return    void
490
-     */
491
-    public function template_redirect()
492
-    {
493
-        // add event list filters
494
-        add_action('loop_start', array($this, 'event_list_template_filters'));
495
-        // and pagination
496
-        add_action('loop_start', array($this, 'event_list_pagination'));
497
-        add_action('loop_end', array($this, 'event_list_pagination'));
498
-        // if NOT a custom template
499
-        if (EE_Registry::instance()
500
-                       ->load_core('Front_Controller', array(), false, true)
501
-                       ->get_selected_template() != 'archive-espresso_events.php'
502
-        ) {
503
-            // don't know if theme uses the_excerpt
504
-            add_filter('the_excerpt', array($this, 'event_details'), 100);
505
-            add_filter('the_excerpt', array($this, 'event_tickets'), 110);
506
-            add_filter('the_excerpt', array($this, 'event_datetimes'), 120);
507
-            add_filter('the_excerpt', array($this, 'event_venues'), 130);
508
-            // or the_content
509
-            add_filter('the_content', array($this, 'event_details'), 100);
510
-            add_filter('the_content', array($this, 'event_tickets'), 110);
511
-            add_filter('the_content', array($this, 'event_datetimes'), 120);
512
-            add_filter('the_content', array($this, 'event_venues'), 130);
513
-        } else {
514
-            remove_all_filters('excerpt_length');
515
-            add_filter('excerpt_length', array($this, 'excerpt_length'), 10);
516
-            add_filter('excerpt_more', array($this, 'excerpt_more'), 10);
517
-        }
518
-    }
519
-
520
-
521
-    /**
522
-     *    event_list_pagination
523
-     *
524
-     * @access    public
525
-     * @return        void
526
-     */
527
-    public function event_list_pagination()
528
-    {
529
-        echo '<div class="ee-pagination-dv ee-clear-float">' . espresso_event_list_pagination() . '</div>';
530
-    }
531
-
532
-
533
-    /**
534
-     *    event_details
535
-     *
536
-     * @access    public
537
-     * @param        string $content
538
-     * @return        void
539
-     */
540
-    public function event_details($content)
541
-    {
542
-        return EEH_Template::display_template(
543
-            EE_TEMPLATES . EE_Config::get_current_theme() . DS . 'content-espresso_events-details.php',
544
-            array('the_content' => $content),
545
-            true
546
-        );
547
-    }
548
-
549
-
550
-    /**
551
-     *    event_tickets
552
-     *
553
-     * @access    public
554
-     * @param        string $content
555
-     * @return        void
556
-     */
557
-    public function event_tickets($content)
558
-    {
559
-        return $content
560
-               . EEH_Template::display_template(
561
-                   EE_TEMPLATES . EE_Config::get_current_theme() . DS . 'content-espresso_events-tickets.php',
562
-                   array(),
563
-                   true
564
-               );
565
-    }
566
-
567
-    /**
568
-     *    event_datetimes
569
-     *
570
-     * @access    public
571
-     * @param        string $content
572
-     * @return        void
573
-     */
574
-    public function event_datetimes($content)
575
-    {
576
-        return $content
577
-               . EEH_Template::display_template(
578
-                   EE_TEMPLATES . EE_Config::get_current_theme() . DS . 'content-espresso_events-datetimes.php',
579
-                   array(),
580
-                   true
581
-               );
582
-    }
583
-
584
-    /**
585
-     *    event_venues
586
-     *
587
-     * @access    public
588
-     * @param        string $content
589
-     * @return        void
590
-     */
591
-    public function event_venues($content)
592
-    {
593
-        return $content
594
-               . EEH_Template::display_template(
595
-                   EE_TEMPLATES . EE_Config::get_current_theme() . DS . 'content-espresso_events-venues.php',
596
-                   array(),
597
-                   true
598
-               );
599
-    }
600
-
601
-
602
-    /**
603
-     *    _initial_setup
604
-     *
605
-     * @access    public
606
-     * @return    void
607
-     */
608
-    private function _load_assests()
609
-    {
610
-        do_action('AHEE__EED_Events_Archive_Filters__before_load_assests');
611
-        wp_enqueue_style('espresso_default');
612
-        wp_enqueue_style('espresso_custom_css');
613
-        add_filter('FHEE_load_EE_Session', '__return_true');
614
-        add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10);
615
-        if (EE_Registry::instance()->CFG->map_settings->use_google_maps) {
616
-            add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11);
617
-        }
618
-        // add_filter( 'the_excerpt', array( $this, 'the_excerpt' ), 999 );
619
-    }
620
-
621
-
622
-    /**
623
-     *    _get_template
624
-     *
625
-     * @access    private
626
-     * @return    string
627
-     */
628
-    private function _get_template($which = 'part')
629
-    {
630
-        return EE_TEMPLATES . EE_Config::get_current_theme() . DS . 'archive-espresso_events.php';
631
-    }
632
-
633
-
634
-    /**
635
-     *    excerpt_length
636
-     *
637
-     * @access    public
638
-     * @return    void
639
-     */
640
-    public function excerpt_length($length)
641
-    {
642
-
643
-        if (self::$_type == 'grid') {
644
-            return 36;
645
-        }
646
-
647
-        switch (EE_Registry::instance()->CFG->template_settings->EED_Events_Archive_Filters->event_list_grid_size) {
648
-            case 'tiny':
649
-                return 12;
650
-                break;
651
-            case 'small':
652
-                return 24;
653
-                break;
654
-            case 'large':
655
-                return 48;
656
-                break;
657
-            case 'medium':
658
-            default:
659
-                return 36;
660
-        }
661
-    }
662
-
663
-
664
-    /**
665
-     *    excerpt_more
666
-     *
667
-     * @access    public
668
-     * @return    void
669
-     */
670
-    public function excerpt_more($more)
671
-    {
672
-        return '&hellip;';
673
-    }
674
-
675
-
676
-
677
-
678
-    /**
679
-     *    wp_enqueue_scripts
680
-     *
681
-     * @access    public
682
-     * @return    void
683
-     */
684
-    public function wp_enqueue_scripts()
685
-    {
686
-        // get some style
687
-        if (apply_filters('FHEE_enable_default_espresso_css', false)) {
688
-            // first check uploads folder
689
-            if (is_readable(
690
-                get_stylesheet_directory() . EE_Config::get_current_theme() . DS . 'archive-espresso_events.css'
691
-            )) {
692
-                wp_register_style(
693
-                    'archive-espresso_events',
694
-                    get_stylesheet_directory_uri() . EE_Config::get_current_theme(
695
-                    ) . DS . 'archive-espresso_events.css',
696
-                    array('dashicons', 'espresso_default')
697
-                );
698
-            } else {
699
-                wp_register_style(
700
-                    'archive-espresso_events',
701
-                    EE_TEMPLATES_URL . EE_Config::get_current_theme() . DS . 'archive-espresso_events.css',
702
-                    array('dashicons', 'espresso_default')
703
-                );
704
-            }
705
-            if (is_readable(
706
-                get_stylesheet_directory() . EE_Config::get_current_theme() . DS . 'archive-espresso_events.js'
707
-            )) {
708
-                wp_register_script(
709
-                    'archive-espresso_events',
710
-                    get_stylesheet_directory_uri() . EE_Config::get_current_theme() . DS . 'archive-espresso_events.js',
711
-                    array('jquery-masonry'),
712
-                    '1.0',
713
-                    true
714
-                );
715
-            } else {
716
-                wp_register_script(
717
-                    'archive-espresso_events',
718
-                    EVENTS_ARCHIVE_ASSETS_URL . 'archive-espresso_events.js',
719
-                    array('jquery-masonry'),
720
-                    '1.0',
721
-                    true
722
-                );
723
-            }
724
-            wp_enqueue_style('archive-espresso_events');
725
-            wp_enqueue_script('jquery-masonry');
726
-            wp_enqueue_script('archive-espresso_events');
727
-            add_action('wp_footer', array('EED_Events_Archive_Filters', 'localize_grid_event_lists'), 1);
728
-        }
729
-    }
730
-
731
-
732
-    /**
733
-     *    template_settings_form
734
-     *
735
-     * @access    public
736
-     * @static
737
-     * @return    void
738
-     */
739
-    public static function localize_grid_event_lists()
740
-    {
741
-        wp_localize_script(
742
-            'archive-espresso_events',
743
-            'espresso_grid_event_lists',
744
-            EED_Events_Archive_Filters::$espresso_grid_event_lists
745
-        );
746
-    }
747
-
748
-
749
-    /**
750
-     *    template_settings_form
751
-     *
752
-     * @access    public
753
-     * @static
754
-     * @return    void
755
-     */
756
-    public static function template_settings_form()
757
-    {
758
-        $EE = EE_Registry::instance();
759
-        $EE->CFG->template_settings->EED_Events_Archive_Filters = isset($EE->CFG->template_settings->EED_Events_Archive_Filters)
760
-            ? $EE->CFG->template_settings->EED_Events_Archive_Filters : new EE_Events_Archive_Config();
761
-        $EE->CFG->template_settings->EED_Events_Archive_Filters = apply_filters(
762
-            'FHEE__Event_List__template_settings_form__event_list_config',
763
-            $EE->CFG->template_settings->EED_Events_Archive_Filters
764
-        );
765
-        EEH_Template::display_template(
766
-            EVENTS_ARCHIVE_TEMPLATES_PATH . 'admin-event-list-settings.template.php',
767
-            $EE->CFG->template_settings->EED_Events_Archive_Filters
768
-        );
769
-    }
770
-
771
-
772
-    /**
773
-     *    set_default_settings
774
-     *
775
-     * @access    public
776
-     * @static
777
-     * @return    void
778
-     */
779
-    public static function set_default_settings($CFG)
780
-    {
781
-        // EEH_Debug_Tools::printr( $CFG, '$CFG  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
782
-        $CFG->display_description = isset($CFG->display_description) && ! empty($CFG->display_description)
783
-            ? $CFG->display_description : 1;
784
-        $CFG->display_address = isset($CFG->display_address) && ! empty($CFG->display_address) ? $CFG->display_address
785
-            : true;
786
-        $CFG->display_venue_details = isset($CFG->display_venue_details) && ! empty($CFG->display_venue_details)
787
-            ? $CFG->display_venue_details : true;
788
-        $CFG->display_expired_events = isset($CFG->display_expired_events) && ! empty($CFG->display_expired_events)
789
-            ? $CFG->display_expired_events : false;
790
-        $CFG->default_type = isset($CFG->default_type) && ! empty($CFG->default_type) ? $CFG->default_type : 'grid';
791
-        $CFG->event_list_grid_size = isset($CFG->event_list_grid_size) && ! empty($CFG->event_list_grid_size)
792
-            ? $CFG->event_list_grid_size : 'medium';
793
-        $CFG->templates['full'] = isset($CFG->templates['full']) && ! empty($CFG->templates['full'])
794
-            ? $CFG->templates['full']
795
-            : EE_TEMPLATES . EE_Config::get_current_theme() . DS . 'archive-espresso_events.php';
796
-        $CFG->templates['part'] = isset($CFG->templates['part']) && ! empty($CFG->templates['part'])
797
-            ? $CFG->templates['part']
798
-            : EE_TEMPLATES . EE_Config::get_current_theme() . DS . 'archive-espresso_events-grid-view.php';
799
-        return $CFG;
800
-    }
801
-
802
-
803
-    /**
804
-     *    filter_config
805
-     *
806
-     * @access    public
807
-     * @return    void
808
-     */
809
-    public function filter_config($CFG)
810
-    {
811
-        return $CFG;
812
-    }
813
-
814
-
815
-    /**
816
-     *    filter_config
817
-     *
818
-     * @access    public
819
-     * @return    void
820
-     */
821
-    public static function update_template_settings($CFG, $REQ)
822
-    {
823
-        // $CFG->template_settings->EED_Events_Archive_Filters = new stdClass();
824
-        $CFG->EED_Events_Archive_Filters->display_description = isset($REQ['display_description_in_event_list'])
825
-            ? absint($REQ['display_description_in_event_list']) : 1;
826
-        $CFG->EED_Events_Archive_Filters->display_address = isset($REQ['display_address_in_event_list']) ? absint(
827
-            $REQ['display_address_in_event_list']
828
-        ) : true;
829
-        $CFG->EED_Events_Archive_Filters->display_venue_details = isset($REQ['display_venue_details_in_event_list'])
830
-            ? absint($REQ['display_venue_details_in_event_list']) : true;
831
-        $CFG->EED_Events_Archive_Filters->display_expired_events = isset($REQ['display_expired_events']) ? absint(
832
-            $REQ['display_expired_events']
833
-        ) : false;
834
-        $CFG->EED_Events_Archive_Filters->default_type = isset($REQ['default_type']) ? sanitize_text_field(
835
-            $REQ['default_type']
836
-        ) : 'grid';
837
-        $CFG->EED_Events_Archive_Filters->event_list_grid_size = isset($REQ['event_list_grid_size'])
838
-            ? sanitize_text_field($REQ['event_list_grid_size']) : 'medium';
839
-        $CFG->EED_Events_Archive_Filters->templates = array(
840
-            'full' => EE_TEMPLATES . EE_Config::get_current_theme() . DS . 'archive-espresso_events.php',
841
-        );
842
-
843
-        switch ($CFG->EED_Events_Archive_Filters->default_type) {
844
-            case 'dates':
845
-                $CFG->EED_Events_Archive_Filters->templates['part'] = EE_TEMPLATES . EE_Config::get_current_theme()
846
-                                                                      . DS . 'archive-espresso_events-dates-view.php';
847
-                break;
848
-            case 'text':
849
-                $CFG->EED_Events_Archive_Filters->templates['part'] = EE_TEMPLATES . EE_Config::get_current_theme()
850
-                                                                      . DS . 'archive-espresso_events-text-view.php';
851
-                break;
852
-            default:
853
-                $CFG->EED_Events_Archive_Filters->templates['part'] = EE_TEMPLATES . EE_Config::get_current_theme()
854
-                                                                      . DS . 'archive-espresso_events-grid-view.php';
855
-        }
856
-
857
-        $CFG->EED_Events_Archive_Filters = isset($REQ['reset_event_list_settings'])
858
-                                           && absint($REQ['reset_event_list_settings']) == 1
859
-            ? new EE_Events_Archive_Config()
860
-            : $CFG->EED_Events_Archive_Filters;
861
-        return $CFG;
862
-    }
863
-
864
-
865
-    /**
866
-     *    get_template_part
867
-     *
868
-     * @access    public
869
-     * @return    void
870
-     */
871
-    public static function get_template_part()
872
-    {
873
-        switch (self::$_type) {
874
-            case 'dates':
875
-                return 'archive-espresso_events-dates-view.php';
876
-                break;
877
-            case 'text':
878
-                return 'archive-espresso_events-text-view.php';
879
-                break;
880
-            default:
881
-                return 'archive-espresso_events-grid-view.php';
882
-        }
883
-    }
884
-
885
-
886
-    /**
887
-     *    event_list_template_filters
888
-     *
889
-     * @access    public
890
-     * @return    void
891
-     */
892
-    public function event_list_template_filters()
893
-    {
894
-        $args = array(
895
-            'form_url'         => get_post_type_archive_link('espresso_events'),
896
-            // add_query_arg( array( 'post_type' => 'espresso_events' ), home_url() ),
897
-            'elf_month'        => EED_Events_Archive_Filters::_display_month(),
898
-            'elf_category'     => EED_Events_Archive_Filters::_event_category_slug(),
899
-            'elf_show_expired' => EED_Events_Archive_Filters::_show_expired(),
900
-            'elf_type'         => self::$_type,
901
-        );
902
-        EEH_Template::display_template(
903
-            EE_TEMPLATES . EE_Config::get_current_theme() . DS . 'archive-espresso_events-filters.php',
904
-            $args
905
-        );
906
-    }
907
-
908
-
909
-    /**
910
-     *    event_list_css
911
-     *
912
-     * @access    public
913
-     * @return    void
914
-     */
915
-    public static function event_list_css($extra_class = '')
916
-    {
917
-        $EE = EE_Registry::instance();
918
-        $event_list_css = ! empty($extra_class) ? array($extra_class) : array();
919
-        $event_list_css[] = 'espresso-event-list-event';
920
-        if (self::$_type == 'grid') {
921
-            $event_list_grid_size = isset($EE->CFG->template_settings->EED_Events_Archive_Filters->event_list_grid_size)
922
-                ? $EE->CFG->template_settings->EED_Events_Archive_Filters->event_list_grid_size : 'medium';
923
-            $event_list_css[] = $event_list_grid_size . '-event-list-grid';
924
-        }
925
-        $event_list_css = apply_filters(
926
-            'EED_Events_Archive_Filters__event_list_css__event_list_css_array',
927
-            $event_list_css
928
-        );
929
-        return implode(' ', $event_list_css);
930
-    }
931
-
932
-
933
-    /**
934
-     *    event_categories
935
-     *
936
-     * @access    public
937
-     * @return    void
938
-     */
939
-    public static function event_categories()
940
-    {
941
-        return EE_Registry::instance()->load_model('Term')->get_all_ee_categories();
942
-    }
943
-
944
-
945
-    /**
946
-     *    display_description
947
-     *
948
-     * @access    public
949
-     * @return    void
950
-     */
951
-    public static function display_description($value)
952
-    {
953
-        $EE = EE_Registry::instance();
954
-        $display_description = isset($EE->CFG->template_settings->EED_Events_Archive_Filters->display_description)
955
-            ? $EE->CFG->template_settings->EED_Events_Archive_Filters->display_description : 1;
956
-        return $display_description === $value ? true : false;
957
-    }
958
-
959
-
960
-    /**
961
-     *    display_venue_details
962
-     *
963
-     * @access    public
964
-     * @return    void
965
-     */
966
-    public static function display_venue_details()
967
-    {
968
-        $EE = EE_Registry::instance();
969
-        $display_venue_details = isset($EE->CFG->template_settings->EED_Events_Archive_Filters->display_venue_details)
970
-            ? $EE->CFG->template_settings->EED_Events_Archive_Filters->display_venue_details : true;
971
-        $venue_name = EEH_Venue_View::venue_name();
972
-        return $display_venue_details && ! empty($venue_name) ? true : false;
973
-    }
974
-
975
-
976
-    /**
977
-     *    display_address
978
-     *
979
-     * @access    public
980
-     * @return    void
981
-     */
982
-    public static function display_address()
983
-    {
984
-        $EE = EE_Registry::instance();
985
-        $display_address = isset($EE->CFG->template_settings->EED_Events_Archive_Filters->display_address)
986
-            ? $EE->CFG->template_settings->EED_Events_Archive_Filters->display_address : false;
987
-        $venue_name = EEH_Venue_View::venue_name();
988
-        return $display_address && ! empty($venue_name) ? true : false;
989
-    }
990
-
991
-
992
-    /**
993
-     *    pagination
994
-     *
995
-     * @access    public
996
-     * @return    void
997
-     */
998
-    public static function pagination()
999
-    {
1000
-        global $wp_query;
1001
-        $big = 999999999; // need an unlikely integer
1002
-        $pagination = paginate_links(
1003
-            array(
1004
-                'base'         => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
1005
-                'format'       => '?paged=%#%',
1006
-                'current'      => max(1, get_query_var('paged')),
1007
-                'total'        => $wp_query->max_num_pages,
1008
-                'show_all'     => true,
1009
-                'end_size'     => 10,
1010
-                'mid_size'     => 6,
1011
-                'prev_next'    => true,
1012
-                'prev_text'    => __('&lsaquo; PREV', 'event_espresso'),
1013
-                'next_text'    => __('NEXT &rsaquo;', 'event_espresso'),
1014
-                'type'         => 'plain',
1015
-                'add_args'     => false,
1016
-                'add_fragment' => '',
1017
-            )
1018
-        );
1019
-        return ! empty($pagination) ? '<div class="ee-pagination-dv clear">' . $pagination . '</div>' : '';
1020
-    }
1021
-
1022
-
1023
-    /**
1024
-     *    event_list_title
1025
-     *
1026
-     * @access    public
1027
-     * @return    void
1028
-     */
1029
-    public static function event_list_title()
1030
-    {
1031
-        return apply_filters(
1032
-            'EED_Events_Archive_Filters__event_list_title__event_list_title',
1033
-            __('Upcoming Events', 'event_espresso')
1034
-        );
1035
-    }
15
+	/**
16
+	 * @return EED_Events_Archive_Filters
17
+	 */
18
+	public static function instance()
19
+	{
20
+		return parent::get_instance(__CLASS__);
21
+	}
22
+
23
+
24
+	/**
25
+	 *    Start Date
26
+	 *
27
+	 * @var    $_elf_month
28
+	 * @access    protected
29
+	 */
30
+	protected $_elf_month = null;
31
+
32
+
33
+	/**
34
+	 *    Category
35
+	 *
36
+	 * @var    $_elf_category
37
+	 * @access    protected
38
+	 */
39
+	protected $_elf_category = null;
40
+
41
+
42
+	/**
43
+	 *    whether to display expired events in the event list
44
+	 *
45
+	 * @var    $_show_expired
46
+	 * @access    protected
47
+	 */
48
+	protected $_show_expired = null;
49
+
50
+
51
+	/**
52
+	 *    whether to display the event list as a grid or list
53
+	 *
54
+	 * @var    $_type
55
+	 * @access    protected
56
+	 */
57
+	protected static $_type = null;
58
+
59
+
60
+	/**
61
+	 *    array of existing event list views
62
+	 *
63
+	 * @var    $_types
64
+	 * @access    protected
65
+	 */
66
+	protected static $_types = array('grid', 'text', 'dates');
67
+
68
+
69
+
70
+	/**
71
+	 *    set_hooks - for hooking into EE Core, other modules, etc
72
+	 *
73
+	 * @access    public
74
+	 * @return    void
75
+	 */
76
+	public static function set_hooks()
77
+	{
78
+	}
79
+
80
+	/**
81
+	 *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
82
+	 *
83
+	 * @access    public
84
+	 * @return    void
85
+	 */
86
+	public static function set_hooks_admin()
87
+	{
88
+	}
89
+
90
+
91
+	/**
92
+	 *    set_definitions
93
+	 *
94
+	 * @access    public
95
+	 * @return    void
96
+	 */
97
+	public static function set_definitions()
98
+	{
99
+	}
100
+
101
+
102
+	/**
103
+	 *    run - initial module setup
104
+	 *
105
+	 * @access    public
106
+	 * @return    void
107
+	 */
108
+	public function run($WP)
109
+	{
110
+	}
111
+
112
+
113
+	/**
114
+	 *    event_list
115
+	 *
116
+	 * @access    public
117
+	 * @return    void
118
+	 */
119
+	public function event_list()
120
+	{
121
+		// load other required components
122
+		$this->_load_assests();
123
+	}
124
+
125
+
126
+	/**
127
+	 *    _filter_query_parts
128
+	 *
129
+	 * @access    public
130
+	 * @return    void
131
+	 */
132
+	private function _filter_query_parts()
133
+	{
134
+		// build event list query
135
+		add_filter('posts_join', array($this, 'posts_join'), 1, 2);
136
+		add_filter('posts_where', array($this, 'posts_where'), 1, 2);
137
+		add_filter('posts_orderby', array($this, 'posts_orderby'), 1, 2);
138
+	}
139
+
140
+	/**
141
+	 *    _type - the type of event list : grid, text, dates
142
+	 *
143
+	 * @access    public
144
+	 * @return    string
145
+	 */
146
+	public static function set_type()
147
+	{
148
+		do_action('AHEE__EED_Events_Archive_Filters__before_set_type');
149
+		EED_Events_Archive_Filters::$_types = apply_filters(
150
+			'EED_Events_Archive_Filters__set_type__types',
151
+			EED_Events_Archive_Filters::$_types
152
+		);
153
+		$view = isset(EE_Registry::instance()->CFG->EED_Events_Archive_Filters['default_type']) ? EE_Registry::instance(
154
+		)->CFG->EED_Events_Archive_Filters['default_type'] : 'grid';
155
+		$elf_type = EE_Registry::instance()->REQ->is_set('elf_type') ? sanitize_text_field(
156
+			EE_Registry::instance()->REQ->get('elf_type')
157
+		) : '';
158
+		$view = ! empty($elf_type) ? $elf_type : $view;
159
+		$view = apply_filters('EED_Events_Archive_Filters__set_type__type', $view);
160
+		if (! empty($view) && in_array($view, EED_Events_Archive_Filters::$_types)) {
161
+			self::$_type = $view;
162
+		}
163
+	}
164
+
165
+	/**
166
+	 *    _show_expired
167
+	 *
168
+	 * @access    private
169
+	 * @param    boolean $req_only if TRUE, then ignore defaults and only return $_POST value
170
+	 * @return    boolean
171
+	 */
172
+	private static function _show_expired($req_only = false)
173
+	{
174
+		// get default value for "display_expired_events" as set in the EE General Settings > Templates > Event Listings
175
+		$show_expired = ! $req_only && isset(
176
+			EE_Registry::instance()->CFG->EED_Events_Archive_Filters['display_expired_events']
177
+		) ? EE_Registry::instance()->CFG->EED_Events_Archive_Filters['display_expired_events'] : false;
178
+		// override default expired option if set via filter
179
+		$show_expired = EE_Registry::instance()->REQ->is_set('elf_expired_chk') ? absint(
180
+			EE_Registry::instance()->REQ->get('elf_expired_chk')
181
+		) : $show_expired;
182
+		return $show_expired ? true : false;
183
+	}
184
+
185
+	/**
186
+	 *    _event_category_slug
187
+	 *
188
+	 * @access    private
189
+	 * @return    string
190
+	 */
191
+	private static function _event_category_slug()
192
+	{
193
+		return EE_Registry::instance()->REQ->is_set('elf_category_dd') ? sanitize_text_field(
194
+			EE_Registry::instance()->REQ->get('elf_category_dd')
195
+		) : '';
196
+	}
197
+
198
+	/**
199
+	 *    _display_month - what month should the event list display events for?
200
+	 *
201
+	 * @access    private
202
+	 * @return    string
203
+	 */
204
+	private static function _display_month()
205
+	{
206
+		return EE_Registry::instance()->REQ->is_set('elf_month_dd') ? sanitize_text_field(
207
+			EE_Registry::instance()->REQ->get('elf_month_dd')
208
+		) : '';
209
+	}
210
+
211
+
212
+	/**
213
+	 *    get_post_data
214
+	 *
215
+	 * @access    public
216
+	 * @return    void
217
+	 */
218
+	public function get_post_data()
219
+	{
220
+		$this->_elf_month = EED_Events_Archive_Filters::_display_month();
221
+		$this->_elf_category = EED_Events_Archive_Filters::_event_category_slug();
222
+		$this->_show_expired = EED_Events_Archive_Filters::_show_expired(true);
223
+	}
224
+
225
+
226
+	/**
227
+	 *    posts_join
228
+	 *
229
+	 * @access    public
230
+	 * @return    void
231
+	 */
232
+	public function posts_join($SQL, WP_Query $wp_query)
233
+	{
234
+		if (isset($wp_query->query) && isset($wp_query->query['post_type']) && $wp_query->query['post_type'] == 'espresso_events') {
235
+			// Category
236
+			$SQL .= EED_Events_Archive_Filters::posts_join_sql_for_terms(
237
+				EED_Events_Archive_Filters::_event_category_slug()
238
+			);
239
+		}
240
+		return $SQL;
241
+	}
242
+
243
+
244
+	/**
245
+	 *    posts_join_sql_for_terms
246
+	 *
247
+	 * @access    public
248
+	 * @param    mixed boolean|string    $join_terms pass TRUE or term string, doesn't really matter since this value
249
+	 *                                   doesn't really get used for anything yet
250
+	 * @return    string
251
+	 */
252
+	public static function posts_join_sql_for_terms($join_terms = null)
253
+	{
254
+		$SQL = '';
255
+		if (! empty($join_terms)) {
256
+			global $wpdb;
257
+			$SQL .= " LEFT JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id)";
258
+			$SQL .= " LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)";
259
+			$SQL .= " LEFT JOIN $wpdb->terms ON ($wpdb->terms.term_id = $wpdb->term_taxonomy.term_id) ";
260
+		}
261
+		return $SQL;
262
+	}
263
+
264
+
265
+	/**
266
+	 *    posts_join_for_orderby
267
+	 *    usage:  $SQL .= EED_Events_Archive_Filters::posts_join_for_orderby( $orderby_params );
268
+	 *
269
+	 * @access    public
270
+	 * @param    array $orderby_params
271
+	 * @return    string
272
+	 */
273
+	public static function posts_join_for_orderby($orderby_params = array())
274
+	{
275
+		global $wpdb;
276
+		$SQL = '';
277
+		$orderby_params = is_array($orderby_params) ? $orderby_params : array($orderby_params);
278
+		foreach ($orderby_params as $orderby) {
279
+			switch ($orderby) {
280
+				case 'ticket_start':
281
+				case 'ticket_end':
282
+					$SQL .= ' LEFT JOIN ' . EEM_Datetime_Ticket::instance()->table() . ' ON ('
283
+							. EEM_Datetime::instance()->table() . '.DTT_ID = '
284
+							. EEM_Datetime_Ticket::instance()->table() . '.DTT_ID )';
285
+					$SQL .= ' LEFT JOIN ' . EEM_Ticket::instance()->table() . ' ON ('
286
+							. EEM_Datetime_Ticket::instance()->table() . '.TKT_ID = '
287
+							. EEM_Ticket::instance()->table() . '.TKT_ID )';
288
+					break;
289
+
290
+				case 'venue_title':
291
+				case 'city':
292
+					$SQL .= ' LEFT JOIN ' . EEM_Event_Venue::instance()->table() . ' ON (' . $wpdb->posts . '.ID = '
293
+							. EEM_Event_Venue::instance()->table() . '.EVT_ID )';
294
+					$SQL .= ' LEFT JOIN ' . EEM_Venue::instance()->table() . ' ON ('
295
+							. EEM_Event_Venue::instance()->table() . '.VNU_ID = '
296
+							. EEM_Venue::instance()->table() . '.VNU_ID )';
297
+					break;
298
+
299
+				case 'state':
300
+					$SQL .= ' LEFT JOIN ' . EEM_Event_Venue::instance()->table() . ' ON (' . $wpdb->posts . '.ID = '
301
+							. EEM_Event_Venue::instance()->table() . '.EVT_ID )';
302
+					$SQL .= ' LEFT JOIN ' . EEM_Event_Venue::instance()->second_table() . ' ON ('
303
+							. EEM_Event_Venue::instance()->table() . '.VNU_ID = '
304
+							. EEM_Event_Venue::instance()->second_table() . '.VNU_ID )';
305
+					break;
306
+			}
307
+		}
308
+		return $SQL;
309
+	}
310
+
311
+
312
+	/**
313
+	 *    posts_where
314
+	 *
315
+	 * @access    public
316
+	 * @return    void
317
+	 */
318
+	public function posts_where($SQL, WP_Query $wp_query)
319
+	{
320
+		if (isset($wp_query->query_vars) && isset($wp_query->query_vars['post_type']) && $wp_query->query_vars['post_type'] == 'espresso_events') {
321
+			// Show Expired ?
322
+			$SQL .= EED_Events_Archive_Filters::posts_where_sql_for_show_expired(
323
+				EED_Events_Archive_Filters::_show_expired()
324
+			);
325
+			// Category
326
+			// $elf_category = EED_Events_Archive_Filters::_event_category_slug();
327
+			$SQL .= EED_Events_Archive_Filters::posts_where_sql_for_event_category_slug(
328
+				EED_Events_Archive_Filters::_event_category_slug()
329
+			);
330
+			// Start Date
331
+			// $elf_month = EED_Events_Archive_Filters::_display_month();
332
+			$SQL .= EED_Events_Archive_Filters::posts_where_sql_for_event_list_month(
333
+				EED_Events_Archive_Filters::_display_month()
334
+			);
335
+		}
336
+		return $SQL;
337
+	}
338
+
339
+
340
+	/**
341
+	 *    posts_where_sql_for_show_expired
342
+	 *
343
+	 * @access    public
344
+	 * @param    boolean $show_expired if TRUE, then displayed past events
345
+	 * @return    string
346
+	 */
347
+	public static function posts_where_sql_for_show_expired($show_expired = false)
348
+	{
349
+		return ! $show_expired
350
+			? ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_end > "' . date('Y-m-d H:s:i') . '" '
351
+			: '';
352
+	}
353
+
354
+
355
+	/**
356
+	 *    posts_where_sql_for_event_category_slug
357
+	 *
358
+	 * @access    public
359
+	 * @param    boolean $event_category_slug
360
+	 * @return    string
361
+	 */
362
+	public static function posts_where_sql_for_event_category_slug($event_category_slug = null)
363
+	{
364
+		global $wpdb;
365
+		return ! empty($event_category_slug) ? ' AND ' . $wpdb->terms . '.slug = "' . $event_category_slug . '" ' : '';
366
+	}
367
+
368
+	/**
369
+	 *    posts_where_sql_for_event_list_month
370
+	 *
371
+	 * @access    public
372
+	 * @param    boolean $month
373
+	 * @return    string
374
+	 */
375
+	public static function posts_where_sql_for_event_list_month($month = null)
376
+	{
377
+		$SQL = '';
378
+		if (! empty($month)) {
379
+			// event start date is LESS than the end of the month ( so nothing that doesn't start until next month )
380
+			$SQL = ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_start';
381
+			$SQL .= ' <= "' . date('Y-m-t 23:59:59', \EEH_DTT_Helper::first_of_month_timestamp($month)) . '"';
382
+			// event end date is GREATER than the start of the month ( so nothing that ended before this month )
383
+			$SQL .= ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_end';
384
+			$SQL .= ' >= "' . date('Y-m-d 0:0:00', \EEH_DTT_Helper::first_of_month_timestamp($month)) . '" ';
385
+		}
386
+		return $SQL;
387
+	}
388
+
389
+
390
+	/**
391
+	 *    posts_orderby
392
+	 *
393
+	 * @access    public
394
+	 * @return    void
395
+	 */
396
+	public function posts_orderby($SQL, WP_Query $wp_query)
397
+	{
398
+		if (isset($wp_query->query) && isset($wp_query->query['post_type']) && $wp_query->query['post_type'] == 'espresso_events') {
399
+			$SQL = EED_Events_Archive_Filters::posts_orderby_sql(array('start_date'));
400
+		}
401
+		return $SQL;
402
+	}
403
+
404
+
405
+	/**
406
+	 *    posts_orderby_sql
407
+	 *
408
+	 *    possible parameters:
409
+	 *    ID
410
+	 *    start_date
411
+	 *    end_date
412
+	 *    event_name
413
+	 *    category_slug
414
+	 *    ticket_start
415
+	 *    ticket_end
416
+	 *    venue_title
417
+	 *    city
418
+	 *    state
419
+	 *
420
+	 *    **IMPORTANT**
421
+	 *    make sure to also send the $orderby_params array to the posts_join_for_orderby() method
422
+	 *    or else some of the table references below will result in MySQL errors
423
+	 *
424
+	 * @access    public
425
+	 * @param    boolean $orderby_params
426
+	 * @return    string
427
+	 */
428
+	public static function posts_orderby_sql($orderby_params = array(), $sort = 'ASC')
429
+	{
430
+		global $wpdb;
431
+		$SQL = '';
432
+		$cntr = 1;
433
+		$orderby_params = is_array($orderby_params) ? $orderby_params : array($orderby_params);
434
+		foreach ($orderby_params as $orderby) {
435
+			$glue = $cntr == 1 || $cntr == count($orderby_params) ? ' ' : ', ';
436
+			switch ($orderby) {
437
+				case 'id':
438
+				case 'ID':
439
+					$SQL .= $glue . $wpdb->posts . '.ID ' . $sort;
440
+					break;
441
+
442
+				case 'start_date':
443
+					$SQL .= $glue . EEM_Datetime::instance()->table() . '.DTT_EVT_start ' . $sort;
444
+					break;
445
+
446
+				case 'end_date':
447
+					$SQL .= $glue . EEM_Datetime::instance()->table() . '.DTT_EVT_end ' . $sort;
448
+					break;
449
+
450
+				case 'event_name':
451
+					$SQL .= $glue . $wpdb->posts . '.post_title ' . $sort;
452
+					break;
453
+
454
+				case 'category_slug':
455
+					$SQL .= $glue . $wpdb->terms . '.slug ' . $sort;
456
+					break;
457
+
458
+				case 'ticket_start':
459
+					$SQL .= $glue . EEM_Ticket::instance()->table() . '.TKT_start_date ' . $sort;
460
+					break;
461
+
462
+				case 'ticket_end':
463
+					$SQL .= $glue . EEM_Ticket::instance()->table() . '.TKT_end_date ' . $sort;
464
+					break;
465
+
466
+				case 'venue_title':
467
+					$SQL .= $glue . 'venue_title ' . $sort;
468
+					break;
469
+
470
+				case 'city':
471
+					$SQL .= $glue . EEM_Venue::instance()->second_table() . '.VNU_city ' . $sort;
472
+					break;
473
+
474
+				case 'state':
475
+					$SQL .= $glue . EEM_State::instance()->table() . '.STA_name ' . $sort;
476
+					break;
477
+			}
478
+			$cntr++;
479
+		}
480
+		// echo '<h4>$SQL : ' . $SQL . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
481
+		return $SQL;
482
+	}
483
+
484
+
485
+	/**
486
+	 *    template_redirect
487
+	 *
488
+	 * @access    public
489
+	 * @return    void
490
+	 */
491
+	public function template_redirect()
492
+	{
493
+		// add event list filters
494
+		add_action('loop_start', array($this, 'event_list_template_filters'));
495
+		// and pagination
496
+		add_action('loop_start', array($this, 'event_list_pagination'));
497
+		add_action('loop_end', array($this, 'event_list_pagination'));
498
+		// if NOT a custom template
499
+		if (EE_Registry::instance()
500
+					   ->load_core('Front_Controller', array(), false, true)
501
+					   ->get_selected_template() != 'archive-espresso_events.php'
502
+		) {
503
+			// don't know if theme uses the_excerpt
504
+			add_filter('the_excerpt', array($this, 'event_details'), 100);
505
+			add_filter('the_excerpt', array($this, 'event_tickets'), 110);
506
+			add_filter('the_excerpt', array($this, 'event_datetimes'), 120);
507
+			add_filter('the_excerpt', array($this, 'event_venues'), 130);
508
+			// or the_content
509
+			add_filter('the_content', array($this, 'event_details'), 100);
510
+			add_filter('the_content', array($this, 'event_tickets'), 110);
511
+			add_filter('the_content', array($this, 'event_datetimes'), 120);
512
+			add_filter('the_content', array($this, 'event_venues'), 130);
513
+		} else {
514
+			remove_all_filters('excerpt_length');
515
+			add_filter('excerpt_length', array($this, 'excerpt_length'), 10);
516
+			add_filter('excerpt_more', array($this, 'excerpt_more'), 10);
517
+		}
518
+	}
519
+
520
+
521
+	/**
522
+	 *    event_list_pagination
523
+	 *
524
+	 * @access    public
525
+	 * @return        void
526
+	 */
527
+	public function event_list_pagination()
528
+	{
529
+		echo '<div class="ee-pagination-dv ee-clear-float">' . espresso_event_list_pagination() . '</div>';
530
+	}
531
+
532
+
533
+	/**
534
+	 *    event_details
535
+	 *
536
+	 * @access    public
537
+	 * @param        string $content
538
+	 * @return        void
539
+	 */
540
+	public function event_details($content)
541
+	{
542
+		return EEH_Template::display_template(
543
+			EE_TEMPLATES . EE_Config::get_current_theme() . DS . 'content-espresso_events-details.php',
544
+			array('the_content' => $content),
545
+			true
546
+		);
547
+	}
548
+
549
+
550
+	/**
551
+	 *    event_tickets
552
+	 *
553
+	 * @access    public
554
+	 * @param        string $content
555
+	 * @return        void
556
+	 */
557
+	public function event_tickets($content)
558
+	{
559
+		return $content
560
+			   . EEH_Template::display_template(
561
+				   EE_TEMPLATES . EE_Config::get_current_theme() . DS . 'content-espresso_events-tickets.php',
562
+				   array(),
563
+				   true
564
+			   );
565
+	}
566
+
567
+	/**
568
+	 *    event_datetimes
569
+	 *
570
+	 * @access    public
571
+	 * @param        string $content
572
+	 * @return        void
573
+	 */
574
+	public function event_datetimes($content)
575
+	{
576
+		return $content
577
+			   . EEH_Template::display_template(
578
+				   EE_TEMPLATES . EE_Config::get_current_theme() . DS . 'content-espresso_events-datetimes.php',
579
+				   array(),
580
+				   true
581
+			   );
582
+	}
583
+
584
+	/**
585
+	 *    event_venues
586
+	 *
587
+	 * @access    public
588
+	 * @param        string $content
589
+	 * @return        void
590
+	 */
591
+	public function event_venues($content)
592
+	{
593
+		return $content
594
+			   . EEH_Template::display_template(
595
+				   EE_TEMPLATES . EE_Config::get_current_theme() . DS . 'content-espresso_events-venues.php',
596
+				   array(),
597
+				   true
598
+			   );
599
+	}
600
+
601
+
602
+	/**
603
+	 *    _initial_setup
604
+	 *
605
+	 * @access    public
606
+	 * @return    void
607
+	 */
608
+	private function _load_assests()
609
+	{
610
+		do_action('AHEE__EED_Events_Archive_Filters__before_load_assests');
611
+		wp_enqueue_style('espresso_default');
612
+		wp_enqueue_style('espresso_custom_css');
613
+		add_filter('FHEE_load_EE_Session', '__return_true');
614
+		add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10);
615
+		if (EE_Registry::instance()->CFG->map_settings->use_google_maps) {
616
+			add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11);
617
+		}
618
+		// add_filter( 'the_excerpt', array( $this, 'the_excerpt' ), 999 );
619
+	}
620
+
621
+
622
+	/**
623
+	 *    _get_template
624
+	 *
625
+	 * @access    private
626
+	 * @return    string
627
+	 */
628
+	private function _get_template($which = 'part')
629
+	{
630
+		return EE_TEMPLATES . EE_Config::get_current_theme() . DS . 'archive-espresso_events.php';
631
+	}
632
+
633
+
634
+	/**
635
+	 *    excerpt_length
636
+	 *
637
+	 * @access    public
638
+	 * @return    void
639
+	 */
640
+	public function excerpt_length($length)
641
+	{
642
+
643
+		if (self::$_type == 'grid') {
644
+			return 36;
645
+		}
646
+
647
+		switch (EE_Registry::instance()->CFG->template_settings->EED_Events_Archive_Filters->event_list_grid_size) {
648
+			case 'tiny':
649
+				return 12;
650
+				break;
651
+			case 'small':
652
+				return 24;
653
+				break;
654
+			case 'large':
655
+				return 48;
656
+				break;
657
+			case 'medium':
658
+			default:
659
+				return 36;
660
+		}
661
+	}
662
+
663
+
664
+	/**
665
+	 *    excerpt_more
666
+	 *
667
+	 * @access    public
668
+	 * @return    void
669
+	 */
670
+	public function excerpt_more($more)
671
+	{
672
+		return '&hellip;';
673
+	}
674
+
675
+
676
+
677
+
678
+	/**
679
+	 *    wp_enqueue_scripts
680
+	 *
681
+	 * @access    public
682
+	 * @return    void
683
+	 */
684
+	public function wp_enqueue_scripts()
685
+	{
686
+		// get some style
687
+		if (apply_filters('FHEE_enable_default_espresso_css', false)) {
688
+			// first check uploads folder
689
+			if (is_readable(
690
+				get_stylesheet_directory() . EE_Config::get_current_theme() . DS . 'archive-espresso_events.css'
691
+			)) {
692
+				wp_register_style(
693
+					'archive-espresso_events',
694
+					get_stylesheet_directory_uri() . EE_Config::get_current_theme(
695
+					) . DS . 'archive-espresso_events.css',
696
+					array('dashicons', 'espresso_default')
697
+				);
698
+			} else {
699
+				wp_register_style(
700
+					'archive-espresso_events',
701
+					EE_TEMPLATES_URL . EE_Config::get_current_theme() . DS . 'archive-espresso_events.css',
702
+					array('dashicons', 'espresso_default')
703
+				);
704
+			}
705
+			if (is_readable(
706
+				get_stylesheet_directory() . EE_Config::get_current_theme() . DS . 'archive-espresso_events.js'
707
+			)) {
708
+				wp_register_script(
709
+					'archive-espresso_events',
710
+					get_stylesheet_directory_uri() . EE_Config::get_current_theme() . DS . 'archive-espresso_events.js',
711
+					array('jquery-masonry'),
712
+					'1.0',
713
+					true
714
+				);
715
+			} else {
716
+				wp_register_script(
717
+					'archive-espresso_events',
718
+					EVENTS_ARCHIVE_ASSETS_URL . 'archive-espresso_events.js',
719
+					array('jquery-masonry'),
720
+					'1.0',
721
+					true
722
+				);
723
+			}
724
+			wp_enqueue_style('archive-espresso_events');
725
+			wp_enqueue_script('jquery-masonry');
726
+			wp_enqueue_script('archive-espresso_events');
727
+			add_action('wp_footer', array('EED_Events_Archive_Filters', 'localize_grid_event_lists'), 1);
728
+		}
729
+	}
730
+
731
+
732
+	/**
733
+	 *    template_settings_form
734
+	 *
735
+	 * @access    public
736
+	 * @static
737
+	 * @return    void
738
+	 */
739
+	public static function localize_grid_event_lists()
740
+	{
741
+		wp_localize_script(
742
+			'archive-espresso_events',
743
+			'espresso_grid_event_lists',
744
+			EED_Events_Archive_Filters::$espresso_grid_event_lists
745
+		);
746
+	}
747
+
748
+
749
+	/**
750
+	 *    template_settings_form
751
+	 *
752
+	 * @access    public
753
+	 * @static
754
+	 * @return    void
755
+	 */
756
+	public static function template_settings_form()
757
+	{
758
+		$EE = EE_Registry::instance();
759
+		$EE->CFG->template_settings->EED_Events_Archive_Filters = isset($EE->CFG->template_settings->EED_Events_Archive_Filters)
760
+			? $EE->CFG->template_settings->EED_Events_Archive_Filters : new EE_Events_Archive_Config();
761
+		$EE->CFG->template_settings->EED_Events_Archive_Filters = apply_filters(
762
+			'FHEE__Event_List__template_settings_form__event_list_config',
763
+			$EE->CFG->template_settings->EED_Events_Archive_Filters
764
+		);
765
+		EEH_Template::display_template(
766
+			EVENTS_ARCHIVE_TEMPLATES_PATH . 'admin-event-list-settings.template.php',
767
+			$EE->CFG->template_settings->EED_Events_Archive_Filters
768
+		);
769
+	}
770
+
771
+
772
+	/**
773
+	 *    set_default_settings
774
+	 *
775
+	 * @access    public
776
+	 * @static
777
+	 * @return    void
778
+	 */
779
+	public static function set_default_settings($CFG)
780
+	{
781
+		// EEH_Debug_Tools::printr( $CFG, '$CFG  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
782
+		$CFG->display_description = isset($CFG->display_description) && ! empty($CFG->display_description)
783
+			? $CFG->display_description : 1;
784
+		$CFG->display_address = isset($CFG->display_address) && ! empty($CFG->display_address) ? $CFG->display_address
785
+			: true;
786
+		$CFG->display_venue_details = isset($CFG->display_venue_details) && ! empty($CFG->display_venue_details)
787
+			? $CFG->display_venue_details : true;
788
+		$CFG->display_expired_events = isset($CFG->display_expired_events) && ! empty($CFG->display_expired_events)
789
+			? $CFG->display_expired_events : false;
790
+		$CFG->default_type = isset($CFG->default_type) && ! empty($CFG->default_type) ? $CFG->default_type : 'grid';
791
+		$CFG->event_list_grid_size = isset($CFG->event_list_grid_size) && ! empty($CFG->event_list_grid_size)
792
+			? $CFG->event_list_grid_size : 'medium';
793
+		$CFG->templates['full'] = isset($CFG->templates['full']) && ! empty($CFG->templates['full'])
794
+			? $CFG->templates['full']
795
+			: EE_TEMPLATES . EE_Config::get_current_theme() . DS . 'archive-espresso_events.php';
796
+		$CFG->templates['part'] = isset($CFG->templates['part']) && ! empty($CFG->templates['part'])
797
+			? $CFG->templates['part']
798
+			: EE_TEMPLATES . EE_Config::get_current_theme() . DS . 'archive-espresso_events-grid-view.php';
799
+		return $CFG;
800
+	}
801
+
802
+
803
+	/**
804
+	 *    filter_config
805
+	 *
806
+	 * @access    public
807
+	 * @return    void
808
+	 */
809
+	public function filter_config($CFG)
810
+	{
811
+		return $CFG;
812
+	}
813
+
814
+
815
+	/**
816
+	 *    filter_config
817
+	 *
818
+	 * @access    public
819
+	 * @return    void
820
+	 */
821
+	public static function update_template_settings($CFG, $REQ)
822
+	{
823
+		// $CFG->template_settings->EED_Events_Archive_Filters = new stdClass();
824
+		$CFG->EED_Events_Archive_Filters->display_description = isset($REQ['display_description_in_event_list'])
825
+			? absint($REQ['display_description_in_event_list']) : 1;
826
+		$CFG->EED_Events_Archive_Filters->display_address = isset($REQ['display_address_in_event_list']) ? absint(
827
+			$REQ['display_address_in_event_list']
828
+		) : true;
829
+		$CFG->EED_Events_Archive_Filters->display_venue_details = isset($REQ['display_venue_details_in_event_list'])
830
+			? absint($REQ['display_venue_details_in_event_list']) : true;
831
+		$CFG->EED_Events_Archive_Filters->display_expired_events = isset($REQ['display_expired_events']) ? absint(
832
+			$REQ['display_expired_events']
833
+		) : false;
834
+		$CFG->EED_Events_Archive_Filters->default_type = isset($REQ['default_type']) ? sanitize_text_field(
835
+			$REQ['default_type']
836
+		) : 'grid';
837
+		$CFG->EED_Events_Archive_Filters->event_list_grid_size = isset($REQ['event_list_grid_size'])
838
+			? sanitize_text_field($REQ['event_list_grid_size']) : 'medium';
839
+		$CFG->EED_Events_Archive_Filters->templates = array(
840
+			'full' => EE_TEMPLATES . EE_Config::get_current_theme() . DS . 'archive-espresso_events.php',
841
+		);
842
+
843
+		switch ($CFG->EED_Events_Archive_Filters->default_type) {
844
+			case 'dates':
845
+				$CFG->EED_Events_Archive_Filters->templates['part'] = EE_TEMPLATES . EE_Config::get_current_theme()
846
+																	  . DS . 'archive-espresso_events-dates-view.php';
847
+				break;
848
+			case 'text':
849
+				$CFG->EED_Events_Archive_Filters->templates['part'] = EE_TEMPLATES . EE_Config::get_current_theme()
850
+																	  . DS . 'archive-espresso_events-text-view.php';
851
+				break;
852
+			default:
853
+				$CFG->EED_Events_Archive_Filters->templates['part'] = EE_TEMPLATES . EE_Config::get_current_theme()
854
+																	  . DS . 'archive-espresso_events-grid-view.php';
855
+		}
856
+
857
+		$CFG->EED_Events_Archive_Filters = isset($REQ['reset_event_list_settings'])
858
+										   && absint($REQ['reset_event_list_settings']) == 1
859
+			? new EE_Events_Archive_Config()
860
+			: $CFG->EED_Events_Archive_Filters;
861
+		return $CFG;
862
+	}
863
+
864
+
865
+	/**
866
+	 *    get_template_part
867
+	 *
868
+	 * @access    public
869
+	 * @return    void
870
+	 */
871
+	public static function get_template_part()
872
+	{
873
+		switch (self::$_type) {
874
+			case 'dates':
875
+				return 'archive-espresso_events-dates-view.php';
876
+				break;
877
+			case 'text':
878
+				return 'archive-espresso_events-text-view.php';
879
+				break;
880
+			default:
881
+				return 'archive-espresso_events-grid-view.php';
882
+		}
883
+	}
884
+
885
+
886
+	/**
887
+	 *    event_list_template_filters
888
+	 *
889
+	 * @access    public
890
+	 * @return    void
891
+	 */
892
+	public function event_list_template_filters()
893
+	{
894
+		$args = array(
895
+			'form_url'         => get_post_type_archive_link('espresso_events'),
896
+			// add_query_arg( array( 'post_type' => 'espresso_events' ), home_url() ),
897
+			'elf_month'        => EED_Events_Archive_Filters::_display_month(),
898
+			'elf_category'     => EED_Events_Archive_Filters::_event_category_slug(),
899
+			'elf_show_expired' => EED_Events_Archive_Filters::_show_expired(),
900
+			'elf_type'         => self::$_type,
901
+		);
902
+		EEH_Template::display_template(
903
+			EE_TEMPLATES . EE_Config::get_current_theme() . DS . 'archive-espresso_events-filters.php',
904
+			$args
905
+		);
906
+	}
907
+
908
+
909
+	/**
910
+	 *    event_list_css
911
+	 *
912
+	 * @access    public
913
+	 * @return    void
914
+	 */
915
+	public static function event_list_css($extra_class = '')
916
+	{
917
+		$EE = EE_Registry::instance();
918
+		$event_list_css = ! empty($extra_class) ? array($extra_class) : array();
919
+		$event_list_css[] = 'espresso-event-list-event';
920
+		if (self::$_type == 'grid') {
921
+			$event_list_grid_size = isset($EE->CFG->template_settings->EED_Events_Archive_Filters->event_list_grid_size)
922
+				? $EE->CFG->template_settings->EED_Events_Archive_Filters->event_list_grid_size : 'medium';
923
+			$event_list_css[] = $event_list_grid_size . '-event-list-grid';
924
+		}
925
+		$event_list_css = apply_filters(
926
+			'EED_Events_Archive_Filters__event_list_css__event_list_css_array',
927
+			$event_list_css
928
+		);
929
+		return implode(' ', $event_list_css);
930
+	}
931
+
932
+
933
+	/**
934
+	 *    event_categories
935
+	 *
936
+	 * @access    public
937
+	 * @return    void
938
+	 */
939
+	public static function event_categories()
940
+	{
941
+		return EE_Registry::instance()->load_model('Term')->get_all_ee_categories();
942
+	}
943
+
944
+
945
+	/**
946
+	 *    display_description
947
+	 *
948
+	 * @access    public
949
+	 * @return    void
950
+	 */
951
+	public static function display_description($value)
952
+	{
953
+		$EE = EE_Registry::instance();
954
+		$display_description = isset($EE->CFG->template_settings->EED_Events_Archive_Filters->display_description)
955
+			? $EE->CFG->template_settings->EED_Events_Archive_Filters->display_description : 1;
956
+		return $display_description === $value ? true : false;
957
+	}
958
+
959
+
960
+	/**
961
+	 *    display_venue_details
962
+	 *
963
+	 * @access    public
964
+	 * @return    void
965
+	 */
966
+	public static function display_venue_details()
967
+	{
968
+		$EE = EE_Registry::instance();
969
+		$display_venue_details = isset($EE->CFG->template_settings->EED_Events_Archive_Filters->display_venue_details)
970
+			? $EE->CFG->template_settings->EED_Events_Archive_Filters->display_venue_details : true;
971
+		$venue_name = EEH_Venue_View::venue_name();
972
+		return $display_venue_details && ! empty($venue_name) ? true : false;
973
+	}
974
+
975
+
976
+	/**
977
+	 *    display_address
978
+	 *
979
+	 * @access    public
980
+	 * @return    void
981
+	 */
982
+	public static function display_address()
983
+	{
984
+		$EE = EE_Registry::instance();
985
+		$display_address = isset($EE->CFG->template_settings->EED_Events_Archive_Filters->display_address)
986
+			? $EE->CFG->template_settings->EED_Events_Archive_Filters->display_address : false;
987
+		$venue_name = EEH_Venue_View::venue_name();
988
+		return $display_address && ! empty($venue_name) ? true : false;
989
+	}
990
+
991
+
992
+	/**
993
+	 *    pagination
994
+	 *
995
+	 * @access    public
996
+	 * @return    void
997
+	 */
998
+	public static function pagination()
999
+	{
1000
+		global $wp_query;
1001
+		$big = 999999999; // need an unlikely integer
1002
+		$pagination = paginate_links(
1003
+			array(
1004
+				'base'         => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
1005
+				'format'       => '?paged=%#%',
1006
+				'current'      => max(1, get_query_var('paged')),
1007
+				'total'        => $wp_query->max_num_pages,
1008
+				'show_all'     => true,
1009
+				'end_size'     => 10,
1010
+				'mid_size'     => 6,
1011
+				'prev_next'    => true,
1012
+				'prev_text'    => __('&lsaquo; PREV', 'event_espresso'),
1013
+				'next_text'    => __('NEXT &rsaquo;', 'event_espresso'),
1014
+				'type'         => 'plain',
1015
+				'add_args'     => false,
1016
+				'add_fragment' => '',
1017
+			)
1018
+		);
1019
+		return ! empty($pagination) ? '<div class="ee-pagination-dv clear">' . $pagination . '</div>' : '';
1020
+	}
1021
+
1022
+
1023
+	/**
1024
+	 *    event_list_title
1025
+	 *
1026
+	 * @access    public
1027
+	 * @return    void
1028
+	 */
1029
+	public static function event_list_title()
1030
+	{
1031
+		return apply_filters(
1032
+			'EED_Events_Archive_Filters__event_list_title__event_list_title',
1033
+			__('Upcoming Events', 'event_espresso')
1034
+		);
1035
+	}
1036 1036
 }
Please login to merge, or discard this patch.
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
         ) : '';
158 158
         $view = ! empty($elf_type) ? $elf_type : $view;
159 159
         $view = apply_filters('EED_Events_Archive_Filters__set_type__type', $view);
160
-        if (! empty($view) && in_array($view, EED_Events_Archive_Filters::$_types)) {
160
+        if ( ! empty($view) && in_array($view, EED_Events_Archive_Filters::$_types)) {
161 161
             self::$_type = $view;
162 162
         }
163 163
     }
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
     public static function posts_join_sql_for_terms($join_terms = null)
253 253
     {
254 254
         $SQL = '';
255
-        if (! empty($join_terms)) {
255
+        if ( ! empty($join_terms)) {
256 256
             global $wpdb;
257 257
             $SQL .= " LEFT JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id)";
258 258
             $SQL .= " LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)";
@@ -279,29 +279,29 @@  discard block
 block discarded – undo
279 279
             switch ($orderby) {
280 280
                 case 'ticket_start':
281 281
                 case 'ticket_end':
282
-                    $SQL .= ' LEFT JOIN ' . EEM_Datetime_Ticket::instance()->table() . ' ON ('
283
-                            . EEM_Datetime::instance()->table() . '.DTT_ID = '
284
-                            . EEM_Datetime_Ticket::instance()->table() . '.DTT_ID )';
285
-                    $SQL .= ' LEFT JOIN ' . EEM_Ticket::instance()->table() . ' ON ('
286
-                            . EEM_Datetime_Ticket::instance()->table() . '.TKT_ID = '
287
-                            . EEM_Ticket::instance()->table() . '.TKT_ID )';
282
+                    $SQL .= ' LEFT JOIN '.EEM_Datetime_Ticket::instance()->table().' ON ('
283
+                            . EEM_Datetime::instance()->table().'.DTT_ID = '
284
+                            . EEM_Datetime_Ticket::instance()->table().'.DTT_ID )';
285
+                    $SQL .= ' LEFT JOIN '.EEM_Ticket::instance()->table().' ON ('
286
+                            . EEM_Datetime_Ticket::instance()->table().'.TKT_ID = '
287
+                            . EEM_Ticket::instance()->table().'.TKT_ID )';
288 288
                     break;
289 289
 
290 290
                 case 'venue_title':
291 291
                 case 'city':
292
-                    $SQL .= ' LEFT JOIN ' . EEM_Event_Venue::instance()->table() . ' ON (' . $wpdb->posts . '.ID = '
293
-                            . EEM_Event_Venue::instance()->table() . '.EVT_ID )';
294
-                    $SQL .= ' LEFT JOIN ' . EEM_Venue::instance()->table() . ' ON ('
295
-                            . EEM_Event_Venue::instance()->table() . '.VNU_ID = '
296
-                            . EEM_Venue::instance()->table() . '.VNU_ID )';
292
+                    $SQL .= ' LEFT JOIN '.EEM_Event_Venue::instance()->table().' ON ('.$wpdb->posts.'.ID = '
293
+                            . EEM_Event_Venue::instance()->table().'.EVT_ID )';
294
+                    $SQL .= ' LEFT JOIN '.EEM_Venue::instance()->table().' ON ('
295
+                            . EEM_Event_Venue::instance()->table().'.VNU_ID = '
296
+                            . EEM_Venue::instance()->table().'.VNU_ID )';
297 297
                     break;
298 298
 
299 299
                 case 'state':
300
-                    $SQL .= ' LEFT JOIN ' . EEM_Event_Venue::instance()->table() . ' ON (' . $wpdb->posts . '.ID = '
301
-                            . EEM_Event_Venue::instance()->table() . '.EVT_ID )';
302
-                    $SQL .= ' LEFT JOIN ' . EEM_Event_Venue::instance()->second_table() . ' ON ('
303
-                            . EEM_Event_Venue::instance()->table() . '.VNU_ID = '
304
-                            . EEM_Event_Venue::instance()->second_table() . '.VNU_ID )';
300
+                    $SQL .= ' LEFT JOIN '.EEM_Event_Venue::instance()->table().' ON ('.$wpdb->posts.'.ID = '
301
+                            . EEM_Event_Venue::instance()->table().'.EVT_ID )';
302
+                    $SQL .= ' LEFT JOIN '.EEM_Event_Venue::instance()->second_table().' ON ('
303
+                            . EEM_Event_Venue::instance()->table().'.VNU_ID = '
304
+                            . EEM_Event_Venue::instance()->second_table().'.VNU_ID )';
305 305
                     break;
306 306
             }
307 307
         }
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
     public static function posts_where_sql_for_show_expired($show_expired = false)
348 348
     {
349 349
         return ! $show_expired
350
-            ? ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_end > "' . date('Y-m-d H:s:i') . '" '
350
+            ? ' AND '.EEM_Datetime::instance()->table().'.DTT_EVT_end > "'.date('Y-m-d H:s:i').'" '
351 351
             : '';
352 352
     }
353 353
 
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
     public static function posts_where_sql_for_event_category_slug($event_category_slug = null)
363 363
     {
364 364
         global $wpdb;
365
-        return ! empty($event_category_slug) ? ' AND ' . $wpdb->terms . '.slug = "' . $event_category_slug . '" ' : '';
365
+        return ! empty($event_category_slug) ? ' AND '.$wpdb->terms.'.slug = "'.$event_category_slug.'" ' : '';
366 366
     }
367 367
 
368 368
     /**
@@ -375,13 +375,13 @@  discard block
 block discarded – undo
375 375
     public static function posts_where_sql_for_event_list_month($month = null)
376 376
     {
377 377
         $SQL = '';
378
-        if (! empty($month)) {
378
+        if ( ! empty($month)) {
379 379
             // event start date is LESS than the end of the month ( so nothing that doesn't start until next month )
380
-            $SQL = ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_start';
381
-            $SQL .= ' <= "' . date('Y-m-t 23:59:59', \EEH_DTT_Helper::first_of_month_timestamp($month)) . '"';
380
+            $SQL = ' AND '.EEM_Datetime::instance()->table().'.DTT_EVT_start';
381
+            $SQL .= ' <= "'.date('Y-m-t 23:59:59', \EEH_DTT_Helper::first_of_month_timestamp($month)).'"';
382 382
             // event end date is GREATER than the start of the month ( so nothing that ended before this month )
383
-            $SQL .= ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_end';
384
-            $SQL .= ' >= "' . date('Y-m-d 0:0:00', \EEH_DTT_Helper::first_of_month_timestamp($month)) . '" ';
383
+            $SQL .= ' AND '.EEM_Datetime::instance()->table().'.DTT_EVT_end';
384
+            $SQL .= ' >= "'.date('Y-m-d 0:0:00', \EEH_DTT_Helper::first_of_month_timestamp($month)).'" ';
385 385
         }
386 386
         return $SQL;
387 387
     }
@@ -436,43 +436,43 @@  discard block
 block discarded – undo
436 436
             switch ($orderby) {
437 437
                 case 'id':
438 438
                 case 'ID':
439
-                    $SQL .= $glue . $wpdb->posts . '.ID ' . $sort;
439
+                    $SQL .= $glue.$wpdb->posts.'.ID '.$sort;
440 440
                     break;
441 441
 
442 442
                 case 'start_date':
443
-                    $SQL .= $glue . EEM_Datetime::instance()->table() . '.DTT_EVT_start ' . $sort;
443
+                    $SQL .= $glue.EEM_Datetime::instance()->table().'.DTT_EVT_start '.$sort;
444 444
                     break;
445 445
 
446 446
                 case 'end_date':
447
-                    $SQL .= $glue . EEM_Datetime::instance()->table() . '.DTT_EVT_end ' . $sort;
447
+                    $SQL .= $glue.EEM_Datetime::instance()->table().'.DTT_EVT_end '.$sort;
448 448
                     break;
449 449
 
450 450
                 case 'event_name':
451
-                    $SQL .= $glue . $wpdb->posts . '.post_title ' . $sort;
451
+                    $SQL .= $glue.$wpdb->posts.'.post_title '.$sort;
452 452
                     break;
453 453
 
454 454
                 case 'category_slug':
455
-                    $SQL .= $glue . $wpdb->terms . '.slug ' . $sort;
455
+                    $SQL .= $glue.$wpdb->terms.'.slug '.$sort;
456 456
                     break;
457 457
 
458 458
                 case 'ticket_start':
459
-                    $SQL .= $glue . EEM_Ticket::instance()->table() . '.TKT_start_date ' . $sort;
459
+                    $SQL .= $glue.EEM_Ticket::instance()->table().'.TKT_start_date '.$sort;
460 460
                     break;
461 461
 
462 462
                 case 'ticket_end':
463
-                    $SQL .= $glue . EEM_Ticket::instance()->table() . '.TKT_end_date ' . $sort;
463
+                    $SQL .= $glue.EEM_Ticket::instance()->table().'.TKT_end_date '.$sort;
464 464
                     break;
465 465
 
466 466
                 case 'venue_title':
467
-                    $SQL .= $glue . 'venue_title ' . $sort;
467
+                    $SQL .= $glue.'venue_title '.$sort;
468 468
                     break;
469 469
 
470 470
                 case 'city':
471
-                    $SQL .= $glue . EEM_Venue::instance()->second_table() . '.VNU_city ' . $sort;
471
+                    $SQL .= $glue.EEM_Venue::instance()->second_table().'.VNU_city '.$sort;
472 472
                     break;
473 473
 
474 474
                 case 'state':
475
-                    $SQL .= $glue . EEM_State::instance()->table() . '.STA_name ' . $sort;
475
+                    $SQL .= $glue.EEM_State::instance()->table().'.STA_name '.$sort;
476 476
                     break;
477 477
             }
478 478
             $cntr++;
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
      */
527 527
     public function event_list_pagination()
528 528
     {
529
-        echo '<div class="ee-pagination-dv ee-clear-float">' . espresso_event_list_pagination() . '</div>';
529
+        echo '<div class="ee-pagination-dv ee-clear-float">'.espresso_event_list_pagination().'</div>';
530 530
     }
531 531
 
532 532
 
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
     public function event_details($content)
541 541
     {
542 542
         return EEH_Template::display_template(
543
-            EE_TEMPLATES . EE_Config::get_current_theme() . DS . 'content-espresso_events-details.php',
543
+            EE_TEMPLATES.EE_Config::get_current_theme().DS.'content-espresso_events-details.php',
544 544
             array('the_content' => $content),
545 545
             true
546 546
         );
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
     {
559 559
         return $content
560 560
                . EEH_Template::display_template(
561
-                   EE_TEMPLATES . EE_Config::get_current_theme() . DS . 'content-espresso_events-tickets.php',
561
+                   EE_TEMPLATES.EE_Config::get_current_theme().DS.'content-espresso_events-tickets.php',
562 562
                    array(),
563 563
                    true
564 564
                );
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
     {
576 576
         return $content
577 577
                . EEH_Template::display_template(
578
-                   EE_TEMPLATES . EE_Config::get_current_theme() . DS . 'content-espresso_events-datetimes.php',
578
+                   EE_TEMPLATES.EE_Config::get_current_theme().DS.'content-espresso_events-datetimes.php',
579 579
                    array(),
580 580
                    true
581 581
                );
@@ -592,7 +592,7 @@  discard block
 block discarded – undo
592 592
     {
593 593
         return $content
594 594
                . EEH_Template::display_template(
595
-                   EE_TEMPLATES . EE_Config::get_current_theme() . DS . 'content-espresso_events-venues.php',
595
+                   EE_TEMPLATES.EE_Config::get_current_theme().DS.'content-espresso_events-venues.php',
596 596
                    array(),
597 597
                    true
598 598
                );
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
      */
628 628
     private function _get_template($which = 'part')
629 629
     {
630
-        return EE_TEMPLATES . EE_Config::get_current_theme() . DS . 'archive-espresso_events.php';
630
+        return EE_TEMPLATES.EE_Config::get_current_theme().DS.'archive-espresso_events.php';
631 631
     }
632 632
 
633 633
 
@@ -687,27 +687,27 @@  discard block
 block discarded – undo
687 687
         if (apply_filters('FHEE_enable_default_espresso_css', false)) {
688 688
             // first check uploads folder
689 689
             if (is_readable(
690
-                get_stylesheet_directory() . EE_Config::get_current_theme() . DS . 'archive-espresso_events.css'
690
+                get_stylesheet_directory().EE_Config::get_current_theme().DS.'archive-espresso_events.css'
691 691
             )) {
692 692
                 wp_register_style(
693 693
                     'archive-espresso_events',
694
-                    get_stylesheet_directory_uri() . EE_Config::get_current_theme(
695
-                    ) . DS . 'archive-espresso_events.css',
694
+                    get_stylesheet_directory_uri().EE_Config::get_current_theme(
695
+                    ).DS.'archive-espresso_events.css',
696 696
                     array('dashicons', 'espresso_default')
697 697
                 );
698 698
             } else {
699 699
                 wp_register_style(
700 700
                     'archive-espresso_events',
701
-                    EE_TEMPLATES_URL . EE_Config::get_current_theme() . DS . 'archive-espresso_events.css',
701
+                    EE_TEMPLATES_URL.EE_Config::get_current_theme().DS.'archive-espresso_events.css',
702 702
                     array('dashicons', 'espresso_default')
703 703
                 );
704 704
             }
705 705
             if (is_readable(
706
-                get_stylesheet_directory() . EE_Config::get_current_theme() . DS . 'archive-espresso_events.js'
706
+                get_stylesheet_directory().EE_Config::get_current_theme().DS.'archive-espresso_events.js'
707 707
             )) {
708 708
                 wp_register_script(
709 709
                     'archive-espresso_events',
710
-                    get_stylesheet_directory_uri() . EE_Config::get_current_theme() . DS . 'archive-espresso_events.js',
710
+                    get_stylesheet_directory_uri().EE_Config::get_current_theme().DS.'archive-espresso_events.js',
711 711
                     array('jquery-masonry'),
712 712
                     '1.0',
713 713
                     true
@@ -715,7 +715,7 @@  discard block
 block discarded – undo
715 715
             } else {
716 716
                 wp_register_script(
717 717
                     'archive-espresso_events',
718
-                    EVENTS_ARCHIVE_ASSETS_URL . 'archive-espresso_events.js',
718
+                    EVENTS_ARCHIVE_ASSETS_URL.'archive-espresso_events.js',
719 719
                     array('jquery-masonry'),
720 720
                     '1.0',
721 721
                     true
@@ -763,7 +763,7 @@  discard block
 block discarded – undo
763 763
             $EE->CFG->template_settings->EED_Events_Archive_Filters
764 764
         );
765 765
         EEH_Template::display_template(
766
-            EVENTS_ARCHIVE_TEMPLATES_PATH . 'admin-event-list-settings.template.php',
766
+            EVENTS_ARCHIVE_TEMPLATES_PATH.'admin-event-list-settings.template.php',
767 767
             $EE->CFG->template_settings->EED_Events_Archive_Filters
768 768
         );
769 769
     }
@@ -792,10 +792,10 @@  discard block
 block discarded – undo
792 792
             ? $CFG->event_list_grid_size : 'medium';
793 793
         $CFG->templates['full'] = isset($CFG->templates['full']) && ! empty($CFG->templates['full'])
794 794
             ? $CFG->templates['full']
795
-            : EE_TEMPLATES . EE_Config::get_current_theme() . DS . 'archive-espresso_events.php';
795
+            : EE_TEMPLATES.EE_Config::get_current_theme().DS.'archive-espresso_events.php';
796 796
         $CFG->templates['part'] = isset($CFG->templates['part']) && ! empty($CFG->templates['part'])
797 797
             ? $CFG->templates['part']
798
-            : EE_TEMPLATES . EE_Config::get_current_theme() . DS . 'archive-espresso_events-grid-view.php';
798
+            : EE_TEMPLATES.EE_Config::get_current_theme().DS.'archive-espresso_events-grid-view.php';
799 799
         return $CFG;
800 800
     }
801 801
 
@@ -837,21 +837,21 @@  discard block
 block discarded – undo
837 837
         $CFG->EED_Events_Archive_Filters->event_list_grid_size = isset($REQ['event_list_grid_size'])
838 838
             ? sanitize_text_field($REQ['event_list_grid_size']) : 'medium';
839 839
         $CFG->EED_Events_Archive_Filters->templates = array(
840
-            'full' => EE_TEMPLATES . EE_Config::get_current_theme() . DS . 'archive-espresso_events.php',
840
+            'full' => EE_TEMPLATES.EE_Config::get_current_theme().DS.'archive-espresso_events.php',
841 841
         );
842 842
 
843 843
         switch ($CFG->EED_Events_Archive_Filters->default_type) {
844 844
             case 'dates':
845
-                $CFG->EED_Events_Archive_Filters->templates['part'] = EE_TEMPLATES . EE_Config::get_current_theme()
846
-                                                                      . DS . 'archive-espresso_events-dates-view.php';
845
+                $CFG->EED_Events_Archive_Filters->templates['part'] = EE_TEMPLATES.EE_Config::get_current_theme()
846
+                                                                      . DS.'archive-espresso_events-dates-view.php';
847 847
                 break;
848 848
             case 'text':
849
-                $CFG->EED_Events_Archive_Filters->templates['part'] = EE_TEMPLATES . EE_Config::get_current_theme()
850
-                                                                      . DS . 'archive-espresso_events-text-view.php';
849
+                $CFG->EED_Events_Archive_Filters->templates['part'] = EE_TEMPLATES.EE_Config::get_current_theme()
850
+                                                                      . DS.'archive-espresso_events-text-view.php';
851 851
                 break;
852 852
             default:
853
-                $CFG->EED_Events_Archive_Filters->templates['part'] = EE_TEMPLATES . EE_Config::get_current_theme()
854
-                                                                      . DS . 'archive-espresso_events-grid-view.php';
853
+                $CFG->EED_Events_Archive_Filters->templates['part'] = EE_TEMPLATES.EE_Config::get_current_theme()
854
+                                                                      . DS.'archive-espresso_events-grid-view.php';
855 855
         }
856 856
 
857 857
         $CFG->EED_Events_Archive_Filters = isset($REQ['reset_event_list_settings'])
@@ -900,7 +900,7 @@  discard block
 block discarded – undo
900 900
             'elf_type'         => self::$_type,
901 901
         );
902 902
         EEH_Template::display_template(
903
-            EE_TEMPLATES . EE_Config::get_current_theme() . DS . 'archive-espresso_events-filters.php',
903
+            EE_TEMPLATES.EE_Config::get_current_theme().DS.'archive-espresso_events-filters.php',
904 904
             $args
905 905
         );
906 906
     }
@@ -920,7 +920,7 @@  discard block
 block discarded – undo
920 920
         if (self::$_type == 'grid') {
921 921
             $event_list_grid_size = isset($EE->CFG->template_settings->EED_Events_Archive_Filters->event_list_grid_size)
922 922
                 ? $EE->CFG->template_settings->EED_Events_Archive_Filters->event_list_grid_size : 'medium';
923
-            $event_list_css[] = $event_list_grid_size . '-event-list-grid';
923
+            $event_list_css[] = $event_list_grid_size.'-event-list-grid';
924 924
         }
925 925
         $event_list_css = apply_filters(
926 926
             'EED_Events_Archive_Filters__event_list_css__event_list_css_array',
@@ -1016,7 +1016,7 @@  discard block
 block discarded – undo
1016 1016
                 'add_fragment' => '',
1017 1017
             )
1018 1018
         );
1019
-        return ! empty($pagination) ? '<div class="ee-pagination-dv clear">' . $pagination . '</div>' : '';
1019
+        return ! empty($pagination) ? '<div class="ee-pagination-dv clear">'.$pagination.'</div>' : '';
1020 1020
     }
1021 1021
 
1022 1022
 
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('\\', DS, plugin_dir_path(__FILE__)) . 'templates' . DS);
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('\\', DS, plugin_dir_path(__FILE__)) . 'templates' . DS);
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('\\', DS, plugin_dir_path(__FILE__)) . 'templates' . DS);
85
+            define('RSS_FEEDS_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS);
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.