Completed
Branch BUG/11288/fix-datepicker (d15367)
by
unknown
108:07 queued 94:31
created
core/db_classes/EE_Price.class.php 2 patches
Indentation   +141 added lines, -141 removed lines patch added patch discarded remove patch
@@ -21,105 +21,105 @@  discard block
 block discarded – undo
21 21
 class EE_Price extends EE_Soft_Delete_Base_Class implements UsesMoneyInterface
22 22
 {
23 23
 
24
-    /**
25
-     * @param array        $props_n_values      incoming values
26
-     * @param string       $timezone            incoming timezone (if not set the timezone set for the website will be
27
-     *                                          used.)
28
-     * @param array        $date_formats        incoming date_formats in an array where the first value is the
29
-     *                                          date_format and the second value is the time format
30
-     * @param MoneyFactory $money_factory
31
-     * @return EE_Price
32
-     * @throws InvalidArgumentException
33
-     * @throws InvalidInterfaceException
34
-     * @throws InvalidDataTypeException
35
-     * @throws EE_Error
36
-     */
37
-    public static function new_instance(
38
-        $props_n_values = array(),
39
-        $timezone = null,
40
-        $date_formats = array(),
41
-        MoneyFactory $money_factory = null
42
-    ) {
43
-        $has_object = parent::_check_for_object(
44
-            $props_n_values,
45
-            __CLASS__,
46
-            $timezone,
47
-            $date_formats
48
-        );
49
-        return $has_object
50
-            ? $has_object
51
-            : new self(
52
-                $props_n_values,
53
-                false,
54
-                $timezone,
55
-                $date_formats,
56
-                $money_factory
57
-            );
58
-    }
59
-
60
-
61
-    /**
62
-     * @param array        $props_n_values      incoming values from the database
63
-     * @param string       $timezone            incoming timezone as set by the model.  If not set the timezone for
64
-     *                                          the website will be used.
65
-     * @param MoneyFactory $money_factory
66
-     * @return EE_Price
67
-     * @throws InvalidArgumentException
68
-     * @throws InvalidInterfaceException
69
-     * @throws InvalidDataTypeException
70
-     * @throws EE_Error
71
-     */
72
-    public static function new_instance_from_db(
73
-        $props_n_values = array(),
74
-        $timezone = null,
75
-        MoneyFactory $money_factory = null
76
-    ) {
77
-        return new self(
78
-            $props_n_values,
79
-            true,
80
-            $timezone,
81
-            array(),
82
-            $money_factory
83
-        );
84
-    }
85
-
86
-
87
-    /**
88
-     * basic constructor for Event Espresso classes, performs any necessary initialization, and verifies it's children
89
-     * play nice
90
-     *
91
-     * @param array        $fieldValues  where each key is a field (ie, array key in the 2nd layer of the model's
92
-     *                                   _fields array, (eg, EVT_ID, TXN_amount, QST_name, etc) and values are their
93
-     *                                   values
94
-     * @param boolean      $bydb         a flag for setting if the class is instantiated by the corresponding db model
95
-     *                                   or not.
96
-     * @param string       $timezone     indicate what timezone you want any datetime fields to be in when
97
-     *                                   instantiating
98
-     *                                   a EE_Base_Class object.
99
-     * @param array        $date_formats An array of date formats to set on construct where first value is the
100
-     *                                   date_format and second value is the time format.
101
-     * @param MoneyFactory $money_factory
102
-     * @throws InvalidArgumentException
103
-     * @throws InvalidInterfaceException
104
-     * @throws InvalidDataTypeException
105
-     * @throws EE_Error
106
-     */
107
-    protected function __construct(
108
-        array $fieldValues = array(),
109
-        $bydb = false,
110
-        $timezone = '',
111
-        array $date_formats = array(),
112
-        MoneyFactory $money_factory = null
113
-    ) {
114
-        if (! $money_factory instanceof MoneyFactory) {
115
-            $money_factory = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\currency\MoneyFactory');
116
-        }
117
-        $this->money_factory = $money_factory;
118
-        parent::__construct($fieldValues, $bydb, $timezone, $date_formats);
119
-    }
120
-
121
-
122
-    /**
24
+	/**
25
+	 * @param array        $props_n_values      incoming values
26
+	 * @param string       $timezone            incoming timezone (if not set the timezone set for the website will be
27
+	 *                                          used.)
28
+	 * @param array        $date_formats        incoming date_formats in an array where the first value is the
29
+	 *                                          date_format and the second value is the time format
30
+	 * @param MoneyFactory $money_factory
31
+	 * @return EE_Price
32
+	 * @throws InvalidArgumentException
33
+	 * @throws InvalidInterfaceException
34
+	 * @throws InvalidDataTypeException
35
+	 * @throws EE_Error
36
+	 */
37
+	public static function new_instance(
38
+		$props_n_values = array(),
39
+		$timezone = null,
40
+		$date_formats = array(),
41
+		MoneyFactory $money_factory = null
42
+	) {
43
+		$has_object = parent::_check_for_object(
44
+			$props_n_values,
45
+			__CLASS__,
46
+			$timezone,
47
+			$date_formats
48
+		);
49
+		return $has_object
50
+			? $has_object
51
+			: new self(
52
+				$props_n_values,
53
+				false,
54
+				$timezone,
55
+				$date_formats,
56
+				$money_factory
57
+			);
58
+	}
59
+
60
+
61
+	/**
62
+	 * @param array        $props_n_values      incoming values from the database
63
+	 * @param string       $timezone            incoming timezone as set by the model.  If not set the timezone for
64
+	 *                                          the website will be used.
65
+	 * @param MoneyFactory $money_factory
66
+	 * @return EE_Price
67
+	 * @throws InvalidArgumentException
68
+	 * @throws InvalidInterfaceException
69
+	 * @throws InvalidDataTypeException
70
+	 * @throws EE_Error
71
+	 */
72
+	public static function new_instance_from_db(
73
+		$props_n_values = array(),
74
+		$timezone = null,
75
+		MoneyFactory $money_factory = null
76
+	) {
77
+		return new self(
78
+			$props_n_values,
79
+			true,
80
+			$timezone,
81
+			array(),
82
+			$money_factory
83
+		);
84
+	}
85
+
86
+
87
+	/**
88
+	 * basic constructor for Event Espresso classes, performs any necessary initialization, and verifies it's children
89
+	 * play nice
90
+	 *
91
+	 * @param array        $fieldValues  where each key is a field (ie, array key in the 2nd layer of the model's
92
+	 *                                   _fields array, (eg, EVT_ID, TXN_amount, QST_name, etc) and values are their
93
+	 *                                   values
94
+	 * @param boolean      $bydb         a flag for setting if the class is instantiated by the corresponding db model
95
+	 *                                   or not.
96
+	 * @param string       $timezone     indicate what timezone you want any datetime fields to be in when
97
+	 *                                   instantiating
98
+	 *                                   a EE_Base_Class object.
99
+	 * @param array        $date_formats An array of date formats to set on construct where first value is the
100
+	 *                                   date_format and second value is the time format.
101
+	 * @param MoneyFactory $money_factory
102
+	 * @throws InvalidArgumentException
103
+	 * @throws InvalidInterfaceException
104
+	 * @throws InvalidDataTypeException
105
+	 * @throws EE_Error
106
+	 */
107
+	protected function __construct(
108
+		array $fieldValues = array(),
109
+		$bydb = false,
110
+		$timezone = '',
111
+		array $date_formats = array(),
112
+		MoneyFactory $money_factory = null
113
+	) {
114
+		if (! $money_factory instanceof MoneyFactory) {
115
+			$money_factory = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\currency\MoneyFactory');
116
+		}
117
+		$this->money_factory = $money_factory;
118
+		parent::__construct($fieldValues, $bydb, $timezone, $date_formats);
119
+	}
120
+
121
+
122
+	/**
123 123
 	 *        Set Price type ID
124 124
 	 *
125 125
 	 * @access        public
@@ -168,11 +168,11 @@  discard block
 block discarded – undo
168 168
 
169 169
 
170 170
 	/**
171
-	*		set is_default
172
-	*
173
-	* 		@access		public
174
-	*		@param		bool		$PRC_is_default
175
-	*/
171
+	 *		set is_default
172
+	 *
173
+	 * 		@access		public
174
+	 *		@param		bool		$PRC_is_default
175
+	 */
176 176
 	public function set_is_default( $PRC_is_default = FALSE ) {
177 177
 		$this->set( 'PRC_is_default', $PRC_is_default );
178 178
 	}
@@ -180,11 +180,11 @@  discard block
 block discarded – undo
180 180
 
181 181
 
182 182
 	/**
183
-	*		set deleted
184
-	*
185
-	* 		@access		public
186
-	*		@param		bool		$PRC_deleted
187
-	*/
183
+	 *		set deleted
184
+	 *
185
+	 * 		@access		public
186
+	 *		@param		bool		$PRC_deleted
187
+	 */
188 188
 	public function set_deleted( $PRC_deleted = NULL ) {
189 189
 		$this->set( 'PRC_deleted', $PRC_deleted );
190 190
 	}
@@ -365,38 +365,38 @@  discard block
 block discarded – undo
365 365
 	}
366 366
 
367 367
 
368
-    /**
369
-     * Returns the payment's amount in subunits (if the currency has subunits; otherwise this will actually be
370
-     * in the currency's main units)
371
-     *
372
-     * @return int
373
-     * @throws EE_Error
374
-     * @throws InvalidEntityException
375
-     * @throws DomainException
376
-     */
377
-    public function amountInSubunits()
378
-    {
379
-        return $this->moneyInSubunits('PRC_amount');
380
-    }
381
-
382
-
383
-    /**
384
-     * Sets the payment's amount based on the incoming monetary subunits (eg pennies). If the currency has no subunits,
385
-     * the amount is actually assumed to be in the currency's main units
386
-     *
387
-     * @param int $amount_in_subunits
388
-     * @return void
389
-     * @throws EE_Error
390
-     * @throws InvalidArgumentException
391
-     * @throws InvalidInterfaceException
392
-     * @throws InvalidIdentifierException
393
-     * @throws InvalidDataTypeException
394
-     * @throws DomainException
395
-     */
396
-    public function setAmountInSubunits($amount_in_subunits)
397
-    {
398
-        $this->setMoneySubunits('PRC_amount', $amount_in_subunits);
399
-    }
368
+	/**
369
+	 * Returns the payment's amount in subunits (if the currency has subunits; otherwise this will actually be
370
+	 * in the currency's main units)
371
+	 *
372
+	 * @return int
373
+	 * @throws EE_Error
374
+	 * @throws InvalidEntityException
375
+	 * @throws DomainException
376
+	 */
377
+	public function amountInSubunits()
378
+	{
379
+		return $this->moneyInSubunits('PRC_amount');
380
+	}
381
+
382
+
383
+	/**
384
+	 * Sets the payment's amount based on the incoming monetary subunits (eg pennies). If the currency has no subunits,
385
+	 * the amount is actually assumed to be in the currency's main units
386
+	 *
387
+	 * @param int $amount_in_subunits
388
+	 * @return void
389
+	 * @throws EE_Error
390
+	 * @throws InvalidArgumentException
391
+	 * @throws InvalidInterfaceException
392
+	 * @throws InvalidIdentifierException
393
+	 * @throws InvalidDataTypeException
394
+	 * @throws DomainException
395
+	 */
396
+	public function setAmountInSubunits($amount_in_subunits)
397
+	{
398
+		$this->setMoneySubunits('PRC_amount', $amount_in_subunits);
399
+	}
400 400
 }
401 401
 /* End of file EE_Price.class.php */
402 402
 /* Location: /includes/classes/EE_Price.class.php */
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
         array $date_formats = array(),
112 112
         MoneyFactory $money_factory = null
113 113
     ) {
114
-        if (! $money_factory instanceof MoneyFactory) {
114
+        if ( ! $money_factory instanceof MoneyFactory) {
115 115
             $money_factory = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\currency\MoneyFactory');
116 116
         }
117 117
         $this->money_factory = $money_factory;
@@ -125,8 +125,8 @@  discard block
 block discarded – undo
125 125
 	 * @access        public
126 126
 	 * @param        int $PRT_ID
127 127
 	 */
128
-	public function set_type( $PRT_ID = 0 ) {
129
-		$this->set( 'PRT_ID', $PRT_ID );
128
+	public function set_type($PRT_ID = 0) {
129
+		$this->set('PRT_ID', $PRT_ID);
130 130
 	}
131 131
 
132 132
 
@@ -137,8 +137,8 @@  discard block
 block discarded – undo
137 137
 	 * @access        public
138 138
 	 * @param        float $PRC_amount
139 139
 	 */
140
-	public function set_amount( $PRC_amount = 0.00 ) {
141
-		$this->set( 'PRC_amount', $PRC_amount );
140
+	public function set_amount($PRC_amount = 0.00) {
141
+		$this->set('PRC_amount', $PRC_amount);
142 142
 	}
143 143
 
144 144
 
@@ -149,8 +149,8 @@  discard block
 block discarded – undo
149 149
 	 * @access        public
150 150
 	 * @param        string $PRC_name
151 151
 	 */
152
-	public function set_name( $PRC_name = '' ) {
153
-		$this->set( 'PRC_name', $PRC_name );
152
+	public function set_name($PRC_name = '') {
153
+		$this->set('PRC_name', $PRC_name);
154 154
 	}
155 155
 
156 156
 
@@ -161,8 +161,8 @@  discard block
 block discarded – undo
161 161
 	 * @access        public
162 162
 	 * @param        string $PRC_desc
163 163
 	 */
164
-	public function set_description( $PRC_desc = '' ) {
165
-		$this->Set( 'PRC_desc', $PRC_desc );
164
+	public function set_description($PRC_desc = '') {
165
+		$this->Set('PRC_desc', $PRC_desc);
166 166
 	}
167 167
 
168 168
 
@@ -173,8 +173,8 @@  discard block
 block discarded – undo
173 173
 	* 		@access		public
174 174
 	*		@param		bool		$PRC_is_default
175 175
 	*/
176
-	public function set_is_default( $PRC_is_default = FALSE ) {
177
-		$this->set( 'PRC_is_default', $PRC_is_default );
176
+	public function set_is_default($PRC_is_default = FALSE) {
177
+		$this->set('PRC_is_default', $PRC_is_default);
178 178
 	}
179 179
 
180 180
 
@@ -185,8 +185,8 @@  discard block
 block discarded – undo
185 185
 	* 		@access		public
186 186
 	*		@param		bool		$PRC_deleted
187 187
 	*/
188
-	public function set_deleted( $PRC_deleted = NULL ) {
189
-		$this->set( 'PRC_deleted', $PRC_deleted );
188
+	public function set_deleted($PRC_deleted = NULL) {
189
+		$this->set('PRC_deleted', $PRC_deleted);
190 190
 	}
191 191
 
192 192
 
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 	 * @return        int
198 198
 	 */
199 199
 	public function type() {
200
-		return $this->get( 'PRT_ID' );
200
+		return $this->get('PRT_ID');
201 201
 	}
202 202
 
203 203
 
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 	 * @return        float
209 209
 	 */
210 210
 	public function amount() {
211
-		return $this->get( 'PRC_amount' );
211
+		return $this->get('PRC_amount');
212 212
 	}
213 213
 
214 214
 
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 	 * @return        string
220 220
 	 */
221 221
 	public function name() {
222
-		return $this->get( 'PRC_name' );
222
+		return $this->get('PRC_name');
223 223
 	}
224 224
 
225 225
 
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 	 * @return        string
231 231
 	 */
232 232
 	public function desc() {
233
-		return $this->get( 'PRC_desc' );
233
+		return $this->get('PRC_desc');
234 234
 	}
235 235
 
236 236
 
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 	 * @return        int
242 242
 	 */
243 243
 	public function overrides() {
244
-		return $this->get( 'PRC_overrides' );
244
+		return $this->get('PRC_overrides');
245 245
 	}
246 246
 
247 247
 
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 	 * @return        int
253 253
 	 */
254 254
 	public function order() {
255
-		return $this->get( 'PRC_order' );
255
+		return $this->get('PRC_order');
256 256
 	}
257 257
 
258 258
 
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 	 * @return        bool
277 277
 	 */
278 278
 	public function is_default() {
279
-		return $this->get( 'PRC_is_default' );
279
+		return $this->get('PRC_is_default');
280 280
 	}
281 281
 
282 282
 
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 	 * @return        bool
288 288
 	 */
289 289
 	public function deleted() {
290
-		return $this->get( 'PRC_deleted' );
290
+		return $this->get('PRC_deleted');
291 291
 	}
292 292
 
293 293
 
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
 	 * @return bool
297 297
 	 */
298 298
 	public function parent() {
299
-		return $this->get( 'PRC_parent' );
299
+		return $this->get('PRC_parent');
300 300
 	}
301 301
 
302 302
 
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
 	 * @return EE_Price_Type
319 319
 	 */
320 320
 	public function type_obj() {
321
-		return $this->get_first_related( 'Price_Type' );
321
+		return $this->get_first_related('Price_Type');
322 322
 	}
323 323
 
324 324
 
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 	 */
341 341
 	public function is_percent() {
342 342
 		$price_type = $this->type_obj();
343
-		return $price_type->get( 'PRT_is_percent' );
343
+		return $price_type->get('PRT_is_percent');
344 344
 	}
345 345
 
346 346
 
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 	 * @return string
353 353
 	 */
354 354
 	public function pretty_price() {
355
-		return ! $this->is_percent() ? $this->get_pretty('PRC_amount') : $this->get('PRC_amount') . '%';
355
+		return ! $this->is_percent() ? $this->get_pretty('PRC_amount') : $this->get('PRC_amount').'%';
356 356
 	}
357 357
 
358 358
 
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
 	 * @return mixed
362 362
 	 */
363 363
 	public function get_price_without_currency_symbol() {
364
-		return str_replace( EE_Registry::instance()->CFG->currency->sign, '', $this->get_pretty( 'PRC_amount' ) );
364
+		return str_replace(EE_Registry::instance()->CFG->currency->sign, '', $this->get_pretty('PRC_amount'));
365 365
 	}
366 366
 
367 367
 
Please login to merge, or discard this patch.
core/db_classes/EE_Ticket.class.php 2 patches
Indentation   +744 added lines, -744 removed lines patch added patch discarded remove patch
@@ -34,8 +34,8 @@  discard block
 block discarded – undo
34 34
  * @author             Darren Ethier
35 35
  */
36 36
 class EE_Ticket
37
-    extends EE_Soft_Delete_Base_Class
38
-    implements EEI_Line_Item_Object, EEI_Event_Relation, EEI_Has_Icon, UsesMoneyInterface
37
+	extends EE_Soft_Delete_Base_Class
38
+	implements EEI_Line_Item_Object, EEI_Event_Relation, EEI_Has_Icon, UsesMoneyInterface
39 39
 {
40 40
 
41 41
 	/**
@@ -70,121 +70,121 @@  discard block
 block discarded – undo
70 70
 	private $_ticket_total_with_taxes;
71 71
 
72 72
 
73
-    /**
74
-     * @param array        $props_n_values      incoming values
75
-     * @param string       $timezone            incoming timezone (if not set the timezone set for the website will be
76
-     *                                          used.)
77
-     * @param array        $date_formats        incoming date_formats in an array where the first value is the
78
-     *                                          date_format and the second value is the time format
79
-     * @param MoneyFactory $money_factory
80
-     * @return EE_Ticket
81
-     * @throws InvalidArgumentException
82
-     * @throws InvalidInterfaceException
83
-     * @throws InvalidDataTypeException
84
-     * @throws EE_Error
85
-     */
86
-    public static function new_instance(
87
-        $props_n_values = array(),
88
-        $timezone = null,
89
-        $date_formats = array(),
90
-        MoneyFactory $money_factory = null
91
-    ) {
92
-        $has_object = parent::_check_for_object(
93
-            $props_n_values,
94
-            __CLASS__,
95
-            $timezone,
96
-            $date_formats
97
-        );
98
-        return $has_object
99
-            ? $has_object
100
-            : new self(
101
-                $props_n_values,
102
-                false,
103
-                $timezone,
104
-                $date_formats,
105
-                $money_factory
106
-            );
107
-    }
108
-
109
-
110
-    /**
111
-     * @param array        $props_n_values      incoming values from the database
112
-     * @param string       $timezone            incoming timezone as set by the model.  If not set the timezone for
113
-     *                                          the website will be used.
114
-     * @param MoneyFactory $money_factory
115
-     * @return EE_Ticket
116
-     * @throws InvalidArgumentException
117
-     * @throws InvalidInterfaceException
118
-     * @throws InvalidDataTypeException
119
-     * @throws EE_Error
120
-     */
121
-    public static function new_instance_from_db(
122
-        $props_n_values = array(),
123
-        $timezone = null,
124
-        MoneyFactory $money_factory = null
125
-    ) {
126
-        return new self(
127
-            $props_n_values,
128
-            true,
129
-            $timezone,
130
-            array(),
131
-            $money_factory
132
-        );
133
-    }
134
-
135
-
136
-    /**
137
-     * basic constructor for Event Espresso classes, performs any necessary initialization, and verifies it's children
138
-     * play nice
139
-     *
140
-     * @param array        $fieldValues  where each key is a field (ie, array key in the 2nd layer of the model's
141
-     *                                   _fields array, (eg, EVT_ID, TXN_amount, QST_name, etc) and values are their
142
-     *                                   values
143
-     * @param boolean      $bydb         a flag for setting if the class is instantiated by the corresponding db model
144
-     *                                   or not.
145
-     * @param string       $timezone     indicate what timezone you want any datetime fields to be in when
146
-     *                                   instantiating
147
-     *                                   a EE_Base_Class object.
148
-     * @param array        $date_formats An array of date formats to set on construct where first value is the
149
-     *                                   date_format and second value is the time format.
150
-     * @param MoneyFactory $money_factory
151
-     * @throws InvalidArgumentException
152
-     * @throws InvalidInterfaceException
153
-     * @throws InvalidDataTypeException
154
-     * @throws EE_Error
155
-     */
156
-    protected function __construct(
157
-        array $fieldValues = array(),
158
-        $bydb = false,
159
-        $timezone = '',
160
-        array $date_formats = array(),
161
-        MoneyFactory $money_factory = null
162
-    ) {
163
-        if (! $money_factory instanceof MoneyFactory) {
164
-            $money_factory = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\currency\MoneyFactory');
165
-        }
166
-        $this->money_factory = $money_factory;
167
-        parent::__construct($fieldValues, $bydb, $timezone, $date_formats);
168
-    }
169
-
170
-
171
-    /**
172
-     * @return bool
173
-     * @throws \EE_Error
174
-     */
73
+	/**
74
+	 * @param array        $props_n_values      incoming values
75
+	 * @param string       $timezone            incoming timezone (if not set the timezone set for the website will be
76
+	 *                                          used.)
77
+	 * @param array        $date_formats        incoming date_formats in an array where the first value is the
78
+	 *                                          date_format and the second value is the time format
79
+	 * @param MoneyFactory $money_factory
80
+	 * @return EE_Ticket
81
+	 * @throws InvalidArgumentException
82
+	 * @throws InvalidInterfaceException
83
+	 * @throws InvalidDataTypeException
84
+	 * @throws EE_Error
85
+	 */
86
+	public static function new_instance(
87
+		$props_n_values = array(),
88
+		$timezone = null,
89
+		$date_formats = array(),
90
+		MoneyFactory $money_factory = null
91
+	) {
92
+		$has_object = parent::_check_for_object(
93
+			$props_n_values,
94
+			__CLASS__,
95
+			$timezone,
96
+			$date_formats
97
+		);
98
+		return $has_object
99
+			? $has_object
100
+			: new self(
101
+				$props_n_values,
102
+				false,
103
+				$timezone,
104
+				$date_formats,
105
+				$money_factory
106
+			);
107
+	}
108
+
109
+
110
+	/**
111
+	 * @param array        $props_n_values      incoming values from the database
112
+	 * @param string       $timezone            incoming timezone as set by the model.  If not set the timezone for
113
+	 *                                          the website will be used.
114
+	 * @param MoneyFactory $money_factory
115
+	 * @return EE_Ticket
116
+	 * @throws InvalidArgumentException
117
+	 * @throws InvalidInterfaceException
118
+	 * @throws InvalidDataTypeException
119
+	 * @throws EE_Error
120
+	 */
121
+	public static function new_instance_from_db(
122
+		$props_n_values = array(),
123
+		$timezone = null,
124
+		MoneyFactory $money_factory = null
125
+	) {
126
+		return new self(
127
+			$props_n_values,
128
+			true,
129
+			$timezone,
130
+			array(),
131
+			$money_factory
132
+		);
133
+	}
134
+
135
+
136
+	/**
137
+	 * basic constructor for Event Espresso classes, performs any necessary initialization, and verifies it's children
138
+	 * play nice
139
+	 *
140
+	 * @param array        $fieldValues  where each key is a field (ie, array key in the 2nd layer of the model's
141
+	 *                                   _fields array, (eg, EVT_ID, TXN_amount, QST_name, etc) and values are their
142
+	 *                                   values
143
+	 * @param boolean      $bydb         a flag for setting if the class is instantiated by the corresponding db model
144
+	 *                                   or not.
145
+	 * @param string       $timezone     indicate what timezone you want any datetime fields to be in when
146
+	 *                                   instantiating
147
+	 *                                   a EE_Base_Class object.
148
+	 * @param array        $date_formats An array of date formats to set on construct where first value is the
149
+	 *                                   date_format and second value is the time format.
150
+	 * @param MoneyFactory $money_factory
151
+	 * @throws InvalidArgumentException
152
+	 * @throws InvalidInterfaceException
153
+	 * @throws InvalidDataTypeException
154
+	 * @throws EE_Error
155
+	 */
156
+	protected function __construct(
157
+		array $fieldValues = array(),
158
+		$bydb = false,
159
+		$timezone = '',
160
+		array $date_formats = array(),
161
+		MoneyFactory $money_factory = null
162
+	) {
163
+		if (! $money_factory instanceof MoneyFactory) {
164
+			$money_factory = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\currency\MoneyFactory');
165
+		}
166
+		$this->money_factory = $money_factory;
167
+		parent::__construct($fieldValues, $bydb, $timezone, $date_formats);
168
+	}
169
+
170
+
171
+	/**
172
+	 * @return bool
173
+	 * @throws \EE_Error
174
+	 */
175 175
 	public function parent() {
176 176
 		return $this->get( 'TKT_parent' );
177 177
 	}
178 178
 
179 179
 
180 180
 
181
-    /**
182
-     * return if a ticket has quantities available for purchase
183
-     *
184
-     * @param  int $DTT_ID the primary key for a particular datetime
185
-     * @return boolean
186
-     * @throws \EE_Error
187
-     */
181
+	/**
182
+	 * return if a ticket has quantities available for purchase
183
+	 *
184
+	 * @param  int $DTT_ID the primary key for a particular datetime
185
+	 * @return boolean
186
+	 * @throws \EE_Error
187
+	 */
188 188
 	public function available( $DTT_ID = 0 ) {
189 189
 		// are we checking availability for a particular datetime ?
190 190
 		if ( $DTT_ID ) {
@@ -201,14 +201,14 @@  discard block
 block discarded – undo
201 201
 
202 202
 
203 203
 
204
-    /**
205
-     * Using the start date and end date this method calculates whether the ticket is On Sale, Pending, or Expired
206
-     *
207
-     * @param bool        $display   true = we'll return a localized string, otherwise we just return the value of the relevant status const
208
-     * @param bool | null $remaining if it is already known that tickets are available, then simply pass a bool to save further processing
209
-     * @return mixed status int if the display string isn't requested
210
-     * @throws \EE_Error
211
-     */
204
+	/**
205
+	 * Using the start date and end date this method calculates whether the ticket is On Sale, Pending, or Expired
206
+	 *
207
+	 * @param bool        $display   true = we'll return a localized string, otherwise we just return the value of the relevant status const
208
+	 * @param bool | null $remaining if it is already known that tickets are available, then simply pass a bool to save further processing
209
+	 * @return mixed status int if the display string isn't requested
210
+	 * @throws \EE_Error
211
+	 */
212 212
 	public function ticket_status( $display = FALSE, $remaining = null ) {
213 213
 		$remaining = is_bool( $remaining ) ? $remaining : $this->is_remaining();
214 214
 		if ( ! $remaining ) {
@@ -231,14 +231,14 @@  discard block
 block discarded – undo
231 231
 
232 232
 
233 233
 
234
-    /**
235
-     * The purpose of this method is to simply return a boolean for whether there are any tickets remaining for sale considering ALL the factors used for figuring that out.
236
-     *
237
-     * @access public
238
-     * @param  int $DTT_ID if an int above 0 is included here then we get a specific dtt.
239
-     * @return boolean         true = tickets remaining, false not.
240
-     * @throws \EE_Error
241
-     */
234
+	/**
235
+	 * The purpose of this method is to simply return a boolean for whether there are any tickets remaining for sale considering ALL the factors used for figuring that out.
236
+	 *
237
+	 * @access public
238
+	 * @param  int $DTT_ID if an int above 0 is included here then we get a specific dtt.
239
+	 * @return boolean         true = tickets remaining, false not.
240
+	 * @throws \EE_Error
241
+	 */
242 242
 	public function is_remaining( $DTT_ID = 0 ) {
243 243
 		$num_remaining = $this->remaining( $DTT_ID );
244 244
 		if ( $num_remaining === 0 ) {
@@ -252,76 +252,76 @@  discard block
 block discarded – undo
252 252
 
253 253
 
254 254
 
255
-    /**
256
-     * return the total number of tickets available for purchase
257
-     *
258
-     * @param  int $DTT_ID the primary key for a particular datetime.
259
-     *                     set to 0 for all related datetimes
260
-     * @return int
261
-     * @throws \EE_Error
262
-     */
255
+	/**
256
+	 * return the total number of tickets available for purchase
257
+	 *
258
+	 * @param  int $DTT_ID the primary key for a particular datetime.
259
+	 *                     set to 0 for all related datetimes
260
+	 * @return int
261
+	 * @throws \EE_Error
262
+	 */
263 263
 	public function remaining( $DTT_ID = 0 ) {
264 264
 		return $this->real_quantity_on_ticket('saleable', $DTT_ID );
265 265
 	}
266 266
 
267 267
 
268 268
 
269
-    /**
270
-     * Gets min
271
-     *
272
-     * @return int
273
-     * @throws \EE_Error
274
-     */
269
+	/**
270
+	 * Gets min
271
+	 *
272
+	 * @return int
273
+	 * @throws \EE_Error
274
+	 */
275 275
 	public function min() {
276 276
 		return $this->get( 'TKT_min' );
277 277
 	}
278 278
 
279 279
 
280 280
 
281
-    /**
282
-     * return if a ticket is no longer available cause its available dates have expired.
283
-     *
284
-     * @return boolean
285
-     * @throws \EE_Error
286
-     */
281
+	/**
282
+	 * return if a ticket is no longer available cause its available dates have expired.
283
+	 *
284
+	 * @return boolean
285
+	 * @throws \EE_Error
286
+	 */
287 287
 	public function is_expired() {
288 288
 		return ( $this->get_raw( 'TKT_end_date' ) < time() );
289 289
 	}
290 290
 
291 291
 
292 292
 
293
-    /**
294
-     * Return if a ticket is yet to go on sale or not
295
-     *
296
-     * @return boolean
297
-     * @throws \EE_Error
298
-     */
293
+	/**
294
+	 * Return if a ticket is yet to go on sale or not
295
+	 *
296
+	 * @return boolean
297
+	 * @throws \EE_Error
298
+	 */
299 299
 	public function is_pending() {
300 300
 		return ( $this->get_raw( 'TKT_start_date' ) > time() );
301 301
 	}
302 302
 
303 303
 
304 304
 
305
-    /**
306
-     * Return if a ticket is on sale or not
307
-     *
308
-     * @return boolean
309
-     * @throws \EE_Error
310
-     */
305
+	/**
306
+	 * Return if a ticket is on sale or not
307
+	 *
308
+	 * @return boolean
309
+	 * @throws \EE_Error
310
+	 */
311 311
 	public function is_on_sale() {
312 312
 		return ( $this->get_raw( 'TKT_start_date' ) < time() && $this->get_raw( 'TKT_end_date' ) > time() );
313 313
 	}
314 314
 
315 315
 
316 316
 
317
-    /**
318
-     * This returns the chronologically last datetime that this ticket is associated with
319
-     *
320
-     * @param string $dt_frmt
321
-     * @param string $conjunction - conjunction junction what's your function ? this string joins the start date with the end date ie: Jan 01 "to" Dec 31
322
-     * @return string
323
-     * @throws \EE_Error
324
-     */
317
+	/**
318
+	 * This returns the chronologically last datetime that this ticket is associated with
319
+	 *
320
+	 * @param string $dt_frmt
321
+	 * @param string $conjunction - conjunction junction what's your function ? this string joins the start date with the end date ie: Jan 01 "to" Dec 31
322
+	 * @return string
323
+	 * @throws \EE_Error
324
+	 */
325 325
 	public function date_range( $dt_frmt = '', $conjunction = ' - ' ) {
326 326
 		$first_date = $this->first_datetime() instanceof EE_Datetime ? $this->first_datetime()->start_date( $dt_frmt ) : '';
327 327
 		$last_date = $this->last_datetime() instanceof EE_Datetime ? $this->last_datetime()->end_date( $dt_frmt ) : '';
@@ -331,12 +331,12 @@  discard block
 block discarded – undo
331 331
 
332 332
 
333 333
 
334
-    /**
335
-     * This returns the chronologically first datetime that this ticket is associated with
336
-     *
337
-     * @return EE_Datetime
338
-     * @throws \EE_Error
339
-     */
334
+	/**
335
+	 * This returns the chronologically first datetime that this ticket is associated with
336
+	 *
337
+	 * @return EE_Datetime
338
+	 * @throws \EE_Error
339
+	 */
340 340
 	public function first_datetime() {
341 341
 		$datetimes = $this->datetimes( array( 'limit' => 1 ) );
342 342
 		return reset( $datetimes );
@@ -344,14 +344,14 @@  discard block
 block discarded – undo
344 344
 
345 345
 
346 346
 
347
-    /**
348
-     * Gets all the datetimes this ticket can be used for attending.
349
-     * Unless otherwise specified, orders datetimes by start date.
350
-     *
351
-     * @param array $query_params see EEM_Base::get_all()
352
-     * @return EE_Datetime[]|EE_Base_Class[]
353
-     * @throws \EE_Error
354
-     */
347
+	/**
348
+	 * Gets all the datetimes this ticket can be used for attending.
349
+	 * Unless otherwise specified, orders datetimes by start date.
350
+	 *
351
+	 * @param array $query_params see EEM_Base::get_all()
352
+	 * @return EE_Datetime[]|EE_Base_Class[]
353
+	 * @throws \EE_Error
354
+	 */
355 355
 	public function datetimes( $query_params = array() ) {
356 356
 		if ( ! isset( $query_params[ 'order_by' ] ) ) {
357 357
 			$query_params[ 'order_by' ][ 'DTT_order' ] = 'ASC';
@@ -361,12 +361,12 @@  discard block
 block discarded – undo
361 361
 
362 362
 
363 363
 
364
-    /**
365
-     * This returns the chronologically last datetime that this ticket is associated with
366
-     *
367
-     * @return EE_Datetime
368
-     * @throws \EE_Error
369
-     */
364
+	/**
365
+	 * This returns the chronologically last datetime that this ticket is associated with
366
+	 *
367
+	 * @return EE_Datetime
368
+	 * @throws \EE_Error
369
+	 */
370 370
 	public function last_datetime() {
371 371
 		$datetimes = $this->datetimes( array( 'limit' => 1, 'order_by' => array( 'DTT_EVT_start' => 'DESC' ) ) );
372 372
 		return end( $datetimes );
@@ -374,19 +374,19 @@  discard block
 block discarded – undo
374 374
 
375 375
 
376 376
 
377
-    /**
378
-     * This returns the total tickets sold depending on the given parameters.
379
-     *
380
-     * @param  string $what   Can be one of two options: 'ticket', 'datetime'.
381
-     *                        'ticket' = total ticket sales for all datetimes this ticket is related to
382
-     *                        'datetime' = total ticket sales for a specified datetime (required $dtt_id)
383
-     *                        'datetime' = total ticket sales in the datetime_ticket table.
384
-     *                        If $dtt_id is not given then we return an array of sales indexed by datetime.
385
-     *                        If $dtt_id IS given then we return the tickets sold for that given datetime.
386
-     * @param  int    $dtt_id [optional] include the dtt_id with $what = 'datetime'.
387
-     * @return mixed (array|int)          how many tickets have sold
388
-     * @throws \EE_Error
389
-     */
377
+	/**
378
+	 * This returns the total tickets sold depending on the given parameters.
379
+	 *
380
+	 * @param  string $what   Can be one of two options: 'ticket', 'datetime'.
381
+	 *                        'ticket' = total ticket sales for all datetimes this ticket is related to
382
+	 *                        'datetime' = total ticket sales for a specified datetime (required $dtt_id)
383
+	 *                        'datetime' = total ticket sales in the datetime_ticket table.
384
+	 *                        If $dtt_id is not given then we return an array of sales indexed by datetime.
385
+	 *                        If $dtt_id IS given then we return the tickets sold for that given datetime.
386
+	 * @param  int    $dtt_id [optional] include the dtt_id with $what = 'datetime'.
387
+	 * @return mixed (array|int)          how many tickets have sold
388
+	 * @throws \EE_Error
389
+	 */
390 390
 	public function tickets_sold( $what = 'ticket', $dtt_id = NULL ) {
391 391
 		$total = 0;
392 392
 		$tickets_sold = $this->_all_tickets_sold();
@@ -411,12 +411,12 @@  discard block
 block discarded – undo
411 411
 
412 412
 
413 413
 
414
-    /**
415
-     * This returns an array indexed by datetime_id for tickets sold with this ticket.
416
-     *
417
-     * @return EE_Ticket[]
418
-     * @throws \EE_Error
419
-     */
414
+	/**
415
+	 * This returns an array indexed by datetime_id for tickets sold with this ticket.
416
+	 *
417
+	 * @return EE_Ticket[]
418
+	 * @throws \EE_Error
419
+	 */
420 420
 	protected function _all_tickets_sold() {
421 421
 		$datetimes = $this->get_many_related( 'Datetime' );
422 422
 		$tickets_sold = array();
@@ -432,29 +432,29 @@  discard block
 block discarded – undo
432 432
 
433 433
 
434 434
 
435
-    /**
436
-     * This returns the base price object for the ticket.
437
-     *
438
-     * @param  bool $return_array whether to return as an array indexed by price id or just the object.
439
-     * @return EE_Price|EE_Base_Class|EE_Price[]|EE_Base_Class[]
440
-     * @throws \EE_Error
441
-     */
435
+	/**
436
+	 * This returns the base price object for the ticket.
437
+	 *
438
+	 * @param  bool $return_array whether to return as an array indexed by price id or just the object.
439
+	 * @return EE_Price|EE_Base_Class|EE_Price[]|EE_Base_Class[]
440
+	 * @throws \EE_Error
441
+	 */
442 442
 	public function base_price( $return_array = FALSE ) {
443 443
 		$_where = array( 'Price_Type.PBT_ID' => EEM_Price_Type::base_type_base_price );
444 444
 		return $return_array
445
-            ? $this->get_many_related( 'Price', array( $_where ) )
446
-            : $this->get_first_related( 'Price', array( $_where ) );
445
+			? $this->get_many_related( 'Price', array( $_where ) )
446
+			: $this->get_first_related( 'Price', array( $_where ) );
447 447
 	}
448 448
 
449 449
 
450 450
 
451
-    /**
452
-     * This returns ONLY the price modifiers for the ticket (i.e. no taxes or base price)
453
-     *
454
-     * @access public
455
-     * @return EE_Price[]
456
-     * @throws \EE_Error
457
-     */
451
+	/**
452
+	 * This returns ONLY the price modifiers for the ticket (i.e. no taxes or base price)
453
+	 *
454
+	 * @access public
455
+	 * @return EE_Price[]
456
+	 * @throws \EE_Error
457
+	 */
458 458
 	public function price_modifiers() {
459 459
 		$query_params = array( 0 => array( 'Price_Type.PBT_ID' => array( 'NOT IN', array( EEM_Price_Type::base_type_base_price, EEM_Price_Type::base_type_tax ) ) ) );
460 460
 		return $this->prices( $query_params );
@@ -462,132 +462,132 @@  discard block
 block discarded – undo
462 462
 
463 463
 
464 464
 
465
-    /**
466
-     * Gets all the prices that combine to form the final price of this ticket
467
-     *
468
-     * @param array $query_params like EEM_Base::get_all
469
-     * @return EE_Price[]|EE_Base_Class[]
470
-     * @throws \EE_Error
471
-     */
465
+	/**
466
+	 * Gets all the prices that combine to form the final price of this ticket
467
+	 *
468
+	 * @param array $query_params like EEM_Base::get_all
469
+	 * @return EE_Price[]|EE_Base_Class[]
470
+	 * @throws \EE_Error
471
+	 */
472 472
 	public function prices( $query_params = array() ) {
473 473
 		return $this->get_many_related( 'Price', $query_params );
474 474
 	}
475 475
 
476 476
 
477 477
 
478
-    /**
479
-     * Gets all the ticket applicabilities (ie, relations between datetimes and tickets)
480
-     *
481
-     * @param array $query_params see EEM_Base::get_all()
482
-     * @return EE_Datetime_Ticket|EE_Base_Class[]
483
-     * @throws \EE_Error
484
-     */
478
+	/**
479
+	 * Gets all the ticket applicabilities (ie, relations between datetimes and tickets)
480
+	 *
481
+	 * @param array $query_params see EEM_Base::get_all()
482
+	 * @return EE_Datetime_Ticket|EE_Base_Class[]
483
+	 * @throws \EE_Error
484
+	 */
485 485
 	public function datetime_tickets( $query_params = array() ) {
486 486
 		return $this->get_many_related( 'Datetime_Ticket', $query_params );
487 487
 	}
488 488
 
489 489
 
490 490
 
491
-    /**
492
-     * Gets all the datetimes from the db ordered by DTT_order
493
-     *
494
-     * @param boolean $show_expired
495
-     * @param boolean $show_deleted
496
-     * @return EE_Datetime[]
497
-     * @throws \EE_Error
498
-     */
491
+	/**
492
+	 * Gets all the datetimes from the db ordered by DTT_order
493
+	 *
494
+	 * @param boolean $show_expired
495
+	 * @param boolean $show_deleted
496
+	 * @return EE_Datetime[]
497
+	 * @throws \EE_Error
498
+	 */
499 499
 	public function datetimes_ordered( $show_expired = TRUE, $show_deleted = FALSE ) {
500 500
 		return EEM_Datetime::instance( $this->_timezone )->get_datetimes_for_ticket_ordered_by_DTT_order( $this->ID(), $show_expired, $show_deleted );
501 501
 	}
502 502
 
503 503
 
504 504
 
505
-    /**
506
-     * Gets ID
507
-     *
508
-     * @return string
509
-     * @throws \EE_Error
510
-     */
505
+	/**
506
+	 * Gets ID
507
+	 *
508
+	 * @return string
509
+	 * @throws \EE_Error
510
+	 */
511 511
 	public function ID() {
512 512
 		return $this->get( 'TKT_ID' );
513 513
 	}
514 514
 
515 515
 
516 516
 
517
-    /**
518
-     * get the author of the ticket.
519
-     *
520
-     * @since 4.5.0
521
-     * @return int
522
-     * @throws \EE_Error
523
-     */
517
+	/**
518
+	 * get the author of the ticket.
519
+	 *
520
+	 * @since 4.5.0
521
+	 * @return int
522
+	 * @throws \EE_Error
523
+	 */
524 524
 	public function wp_user() {
525 525
 		return $this->get('TKT_wp_user');
526 526
 	}
527 527
 
528 528
 
529 529
 
530
-    /**
531
-     * Gets the template for the ticket
532
-     *
533
-     * @return EE_Ticket_Template|EE_Base_Class
534
-     * @throws \EE_Error
535
-     */
530
+	/**
531
+	 * Gets the template for the ticket
532
+	 *
533
+	 * @return EE_Ticket_Template|EE_Base_Class
534
+	 * @throws \EE_Error
535
+	 */
536 536
 	public function template() {
537 537
 		return $this->get_first_related( 'Ticket_Template' );
538 538
 	}
539 539
 
540 540
 
541 541
 
542
-    /**
543
-     * Simply returns an array of EE_Price objects that are taxes.
544
-     *
545
-     * @return EE_Price[]
546
-     * @throws \EE_Error
547
-     */
542
+	/**
543
+	 * Simply returns an array of EE_Price objects that are taxes.
544
+	 *
545
+	 * @return EE_Price[]
546
+	 * @throws \EE_Error
547
+	 */
548 548
 	public function get_ticket_taxes_for_admin() {
549 549
 		return EE_Taxes::get_taxes_for_admin();
550 550
 	}
551 551
 
552 552
 
553 553
 
554
-    /**
555
-     * @return float
556
-     * @throws \EE_Error
557
-     */
554
+	/**
555
+	 * @return float
556
+	 * @throws \EE_Error
557
+	 */
558 558
 	public function ticket_price() {
559 559
 		return $this->get( 'TKT_price' );
560 560
 	}
561 561
 
562 562
 
563 563
 
564
-    /**
565
-     * @return mixed
566
-     * @throws \EE_Error
567
-     */
564
+	/**
565
+	 * @return mixed
566
+	 * @throws \EE_Error
567
+	 */
568 568
 	public function pretty_price() {
569 569
 		return $this->get_pretty( 'TKT_price' );
570 570
 	}
571 571
 
572 572
 
573 573
 
574
-    /**
575
-     * @return bool
576
-     * @throws \EE_Error
577
-     */
574
+	/**
575
+	 * @return bool
576
+	 * @throws \EE_Error
577
+	 */
578 578
 	public function is_free() {
579 579
 		return $this->get_ticket_total_with_taxes() === (float) 0;
580 580
 	}
581 581
 
582 582
 
583 583
 
584
-    /**
585
-     * get_ticket_total_with_taxes
586
-     *
587
-     * @param bool $no_cache
588
-     * @return float
589
-     * @throws \EE_Error
590
-     */
584
+	/**
585
+	 * get_ticket_total_with_taxes
586
+	 *
587
+	 * @param bool $no_cache
588
+	 * @return float
589
+	 * @throws \EE_Error
590
+	 */
591 591
 	public function get_ticket_total_with_taxes( $no_cache = FALSE ) {
592 592
 		if ($this->_ticket_total_with_taxes === null || $no_cache ) {
593 593
 			$this->_ticket_total_with_taxes = $this->get_ticket_subtotal() + $this->get_ticket_taxes_total_for_admin();
@@ -604,201 +604,201 @@  discard block
 block discarded – undo
604 604
 
605 605
 
606 606
 
607
-    /**
608
-     * @return float
609
-     * @throws \EE_Error
610
-     */
607
+	/**
608
+	 * @return float
609
+	 * @throws \EE_Error
610
+	 */
611 611
 	public function get_ticket_subtotal() {
612 612
 		return EE_Taxes::get_subtotal_for_admin( $this );
613 613
 	}
614 614
 
615 615
 
616 616
 
617
-    /**
618
-     * Returns the total taxes applied to this ticket
619
-     *
620
-     * @return float
621
-     * @throws \EE_Error
622
-     */
617
+	/**
618
+	 * Returns the total taxes applied to this ticket
619
+	 *
620
+	 * @return float
621
+	 * @throws \EE_Error
622
+	 */
623 623
 	public function get_ticket_taxes_total_for_admin() {
624 624
 		return EE_Taxes::get_total_taxes_for_admin( $this );
625 625
 	}
626 626
 
627 627
 
628 628
 
629
-    /**
630
-     * Sets name
631
-     *
632
-     * @param string $name
633
-     * @throws \EE_Error
634
-     */
629
+	/**
630
+	 * Sets name
631
+	 *
632
+	 * @param string $name
633
+	 * @throws \EE_Error
634
+	 */
635 635
 	public function set_name( $name ) {
636 636
 		$this->set( 'TKT_name', $name );
637 637
 	}
638 638
 
639 639
 
640 640
 
641
-    /**
642
-     * Gets description
643
-     *
644
-     * @return string
645
-     * @throws \EE_Error
646
-     */
641
+	/**
642
+	 * Gets description
643
+	 *
644
+	 * @return string
645
+	 * @throws \EE_Error
646
+	 */
647 647
 	public function description() {
648 648
 		return $this->get( 'TKT_description' );
649 649
 	}
650 650
 
651 651
 
652 652
 
653
-    /**
654
-     * Sets description
655
-     *
656
-     * @param string $description
657
-     * @throws \EE_Error
658
-     */
653
+	/**
654
+	 * Sets description
655
+	 *
656
+	 * @param string $description
657
+	 * @throws \EE_Error
658
+	 */
659 659
 	public function set_description( $description ) {
660 660
 		$this->set( 'TKT_description', $description );
661 661
 	}
662 662
 
663 663
 
664 664
 
665
-    /**
666
-     * Gets start_date
667
-     *
668
-     * @param string $dt_frmt
669
-     * @param string $tm_frmt
670
-     * @return string
671
-     * @throws \EE_Error
672
-     */
665
+	/**
666
+	 * Gets start_date
667
+	 *
668
+	 * @param string $dt_frmt
669
+	 * @param string $tm_frmt
670
+	 * @return string
671
+	 * @throws \EE_Error
672
+	 */
673 673
 	public function start_date( $dt_frmt = '', $tm_frmt = '' ) {
674 674
 		return $this->_get_datetime( 'TKT_start_date', $dt_frmt, $tm_frmt );
675 675
 	}
676 676
 
677 677
 
678 678
 
679
-    /**
680
-     * Sets start_date
681
-     *
682
-     * @param string $start_date
683
-     * @return void
684
-     * @throws \EE_Error
685
-     */
679
+	/**
680
+	 * Sets start_date
681
+	 *
682
+	 * @param string $start_date
683
+	 * @return void
684
+	 * @throws \EE_Error
685
+	 */
686 686
 	public function set_start_date( $start_date ) {
687 687
 		$this->_set_date_time( 'B', $start_date, 'TKT_start_date' );
688 688
 	}
689 689
 
690 690
 
691 691
 
692
-    /**
693
-     * Gets end_date
694
-     *
695
-     * @param string $dt_frmt
696
-     * @param string $tm_frmt
697
-     * @return string
698
-     * @throws \EE_Error
699
-     */
692
+	/**
693
+	 * Gets end_date
694
+	 *
695
+	 * @param string $dt_frmt
696
+	 * @param string $tm_frmt
697
+	 * @return string
698
+	 * @throws \EE_Error
699
+	 */
700 700
 	public function end_date( $dt_frmt = '', $tm_frmt = '' ) {
701 701
 		return $this->_get_datetime( 'TKT_end_date', $dt_frmt, $tm_frmt );
702 702
 	}
703 703
 
704 704
 
705 705
 
706
-    /**
707
-     * Sets end_date
708
-     *
709
-     * @param string $end_date
710
-     * @return void
711
-     * @throws \EE_Error
712
-     */
706
+	/**
707
+	 * Sets end_date
708
+	 *
709
+	 * @param string $end_date
710
+	 * @return void
711
+	 * @throws \EE_Error
712
+	 */
713 713
 	public function set_end_date( $end_date ) {
714 714
 		$this->_set_date_time( 'B', $end_date, 'TKT_end_date' );
715 715
 	}
716 716
 
717 717
 
718 718
 
719
-    /**
720
-     * Sets sell until time
721
-     *
722
-     * @since 4.5.0
723
-     * @param string $time a string representation of the sell until time (ex 9am or 7:30pm)
724
-     * @throws \EE_Error
725
-     */
719
+	/**
720
+	 * Sets sell until time
721
+	 *
722
+	 * @since 4.5.0
723
+	 * @param string $time a string representation of the sell until time (ex 9am or 7:30pm)
724
+	 * @throws \EE_Error
725
+	 */
726 726
 	public function set_end_time( $time ) {
727 727
 		$this->_set_time_for( $time, 'TKT_end_date' );
728 728
 	}
729 729
 
730 730
 
731 731
 
732
-    /**
733
-     * Sets min
734
-     *
735
-     * @param int $min
736
-     * @return void
737
-     * @throws \EE_Error
738
-     */
732
+	/**
733
+	 * Sets min
734
+	 *
735
+	 * @param int $min
736
+	 * @return void
737
+	 * @throws \EE_Error
738
+	 */
739 739
 	public function set_min( $min ) {
740 740
 		$this->set( 'TKT_min', $min );
741 741
 	}
742 742
 
743 743
 
744 744
 
745
-    /**
746
-     * Gets max
747
-     *
748
-     * @return int
749
-     * @throws \EE_Error
750
-     */
745
+	/**
746
+	 * Gets max
747
+	 *
748
+	 * @return int
749
+	 * @throws \EE_Error
750
+	 */
751 751
 	public function max() {
752 752
 		return $this->get( 'TKT_max' );
753 753
 	}
754 754
 
755 755
 
756 756
 
757
-    /**
758
-     * Sets max
759
-     *
760
-     * @param int $max
761
-     * @return void
762
-     * @throws \EE_Error
763
-     */
757
+	/**
758
+	 * Sets max
759
+	 *
760
+	 * @param int $max
761
+	 * @return void
762
+	 * @throws \EE_Error
763
+	 */
764 764
 	public function set_max( $max ) {
765 765
 		$this->set( 'TKT_max', $max );
766 766
 	}
767 767
 
768 768
 
769 769
 
770
-    /**
771
-     * Sets price
772
-     *
773
-     * @param float $price
774
-     * @return void
775
-     * @throws \EE_Error
776
-     */
770
+	/**
771
+	 * Sets price
772
+	 *
773
+	 * @param float $price
774
+	 * @return void
775
+	 * @throws \EE_Error
776
+	 */
777 777
 	public function set_price( $price ) {
778 778
 		$this->set( 'TKT_price', $price );
779 779
 	}
780 780
 
781 781
 
782 782
 
783
-    /**
784
-     * Gets sold
785
-     *
786
-     * @return int
787
-     * @throws \EE_Error
788
-     */
783
+	/**
784
+	 * Gets sold
785
+	 *
786
+	 * @return int
787
+	 * @throws \EE_Error
788
+	 */
789 789
 	public function sold() {
790 790
 		return $this->get_raw( 'TKT_sold' );
791 791
 	}
792 792
 
793 793
 
794 794
 
795
-    /**
796
-     * Sets sold
797
-     *
798
-     * @param int $sold
799
-     * @return void
800
-     * @throws \EE_Error
801
-     */
795
+	/**
796
+	 * Sets sold
797
+	 *
798
+	 * @param int $sold
799
+	 * @return void
800
+	 * @throws \EE_Error
801
+	 */
802 802
 	public function set_sold( $sold ) {
803 803
 		// sold can not go below zero
804 804
 		$sold = max( 0, $sold );
@@ -807,13 +807,13 @@  discard block
 block discarded – undo
807 807
 
808 808
 
809 809
 
810
-    /**
811
-     * increments sold by amount passed by $qty
812
-     *
813
-     * @param int $qty
814
-     * @return void
815
-     * @throws \EE_Error
816
-     */
810
+	/**
811
+	 * increments sold by amount passed by $qty
812
+	 *
813
+	 * @param int $qty
814
+	 * @return void
815
+	 * @throws \EE_Error
816
+	 */
817 817
 	public function increase_sold( $qty = 1 ) {
818 818
 		$sold = $this->sold() + $qty;
819 819
 		// remove ticket reservation, but don't adjust datetime reservations,  because that will happen
@@ -822,22 +822,22 @@  discard block
 block discarded – undo
822 822
 		$this->_increase_sold_for_datetimes( $qty );
823 823
 		$this->set_sold( $sold );
824 824
 		do_action(
825
-		    'AHEE__EE_Ticket__increase_sold',
826
-            $this,
827
-            $qty,
828
-            $sold
829
-        );
825
+			'AHEE__EE_Ticket__increase_sold',
826
+			$this,
827
+			$qty,
828
+			$sold
829
+		);
830 830
 	}
831 831
 
832 832
 
833 833
 
834
-    /**
835
-     * Increases sold on related datetimes
836
-     *
837
-     * @param int $qty
838
-     * @return void
839
-     * @throws \EE_Error
840
-     */
834
+	/**
835
+	 * Increases sold on related datetimes
836
+	 *
837
+	 * @param int $qty
838
+	 * @return void
839
+	 * @throws \EE_Error
840
+	 */
841 841
 	protected function _increase_sold_for_datetimes( $qty = 1 ) {
842 842
 		$datetimes = $this->datetimes();
843 843
 		if ( is_array( $datetimes ) ) {
@@ -852,34 +852,34 @@  discard block
 block discarded – undo
852 852
 
853 853
 
854 854
 
855
-    /**
856
-     * decrements (subtracts) sold by amount passed by $qty
857
-     *
858
-     * @param int $qty
859
-     * @return void
860
-     * @throws \EE_Error
861
-     */
855
+	/**
856
+	 * decrements (subtracts) sold by amount passed by $qty
857
+	 *
858
+	 * @param int $qty
859
+	 * @return void
860
+	 * @throws \EE_Error
861
+	 */
862 862
 	public function decrease_sold( $qty = 1 ) {
863 863
 		$sold = $this->sold() - $qty;
864 864
 		$this->_decrease_sold_for_datetimes( $qty );
865 865
 		$this->set_sold( $sold );
866
-        do_action(
867
-            'AHEE__EE_Ticket__decrease_sold',
868
-            $this,
869
-            $qty,
870
-            $sold
871
-        );
872
-    }
873
-
874
-
875
-
876
-    /**
877
-     * Decreases sold on related datetimes
878
-     *
879
-     * @param int $qty
880
-     * @return void
881
-     * @throws \EE_Error
882
-     */
866
+		do_action(
867
+			'AHEE__EE_Ticket__decrease_sold',
868
+			$this,
869
+			$qty,
870
+			$sold
871
+		);
872
+	}
873
+
874
+
875
+
876
+	/**
877
+	 * Decreases sold on related datetimes
878
+	 *
879
+	 * @param int $qty
880
+	 * @return void
881
+	 * @throws \EE_Error
882
+	 */
883 883
 	protected function _decrease_sold_for_datetimes( $qty = 1 ) {
884 884
 		$datetimes = $this->datetimes();
885 885
 		if ( is_array( $datetimes ) ) {
@@ -894,25 +894,25 @@  discard block
 block discarded – undo
894 894
 
895 895
 
896 896
 
897
-    /**
898
-     * Gets qty of reserved tickets
899
-     *
900
-     * @return int
901
-     * @throws \EE_Error
902
-     */
897
+	/**
898
+	 * Gets qty of reserved tickets
899
+	 *
900
+	 * @return int
901
+	 * @throws \EE_Error
902
+	 */
903 903
 	public function reserved() {
904 904
 		return $this->get_raw( 'TKT_reserved' );
905 905
 	}
906 906
 
907 907
 
908 908
 
909
-    /**
910
-     * Sets reserved
911
-     *
912
-     * @param int $reserved
913
-     * @return void
914
-     * @throws \EE_Error
915
-     */
909
+	/**
910
+	 * Sets reserved
911
+	 *
912
+	 * @param int $reserved
913
+	 * @return void
914
+	 * @throws \EE_Error
915
+	 */
916 916
 	public function set_reserved( $reserved ) {
917 917
 		// reserved can not go below zero
918 918
 		$reserved = max( 0, (int) $reserved );
@@ -921,35 +921,35 @@  discard block
 block discarded – undo
921 921
 
922 922
 
923 923
 
924
-    /**
925
-     * increments reserved by amount passed by $qty
926
-     *
927
-     * @param int $qty
928
-     * @return void
929
-     * @throws \EE_Error
930
-     */
924
+	/**
925
+	 * increments reserved by amount passed by $qty
926
+	 *
927
+	 * @param int $qty
928
+	 * @return void
929
+	 * @throws \EE_Error
930
+	 */
931 931
 	public function increase_reserved( $qty = 1 ) {
932 932
 		$qty = absint( $qty );
933 933
 		$reserved = $this->reserved() + $qty;
934 934
 		$this->_increase_reserved_for_datetimes( $qty );
935 935
 		$this->set_reserved( $reserved );
936
-        do_action(
937
-            'AHEE__EE_Ticket__increase_reserved',
938
-            $this,
939
-            $qty,
940
-            $reserved
941
-        );
942
-    }
943
-
944
-
945
-
946
-    /**
947
-     * Increases sold on related datetimes
948
-     *
949
-     * @param int $qty
950
-     * @return void
951
-     * @throws \EE_Error
952
-     */
936
+		do_action(
937
+			'AHEE__EE_Ticket__increase_reserved',
938
+			$this,
939
+			$qty,
940
+			$reserved
941
+		);
942
+	}
943
+
944
+
945
+
946
+	/**
947
+	 * Increases sold on related datetimes
948
+	 *
949
+	 * @param int $qty
950
+	 * @return void
951
+	 * @throws \EE_Error
952
+	 */
953 953
 	protected function _increase_reserved_for_datetimes( $qty = 1 ) {
954 954
 		$datetimes = $this->datetimes();
955 955
 		if ( is_array( $datetimes ) ) {
@@ -964,37 +964,37 @@  discard block
 block discarded – undo
964 964
 
965 965
 
966 966
 
967
-    /**
968
-     * decrements (subtracts) reserved by amount passed by $qty
969
-     *
970
-     * @param int  $qty
971
-     * @param bool $adjust_datetimes
972
-     * @return void
973
-     * @throws \EE_Error
974
-     */
967
+	/**
968
+	 * decrements (subtracts) reserved by amount passed by $qty
969
+	 *
970
+	 * @param int  $qty
971
+	 * @param bool $adjust_datetimes
972
+	 * @return void
973
+	 * @throws \EE_Error
974
+	 */
975 975
 	public function decrease_reserved( $qty = 1, $adjust_datetimes = true ) {
976 976
 		$reserved = $this->reserved() - absint( $qty );
977 977
 		if ( $adjust_datetimes ) {
978 978
 			$this->_decrease_reserved_for_datetimes( $qty );
979 979
 		}
980 980
 		$this->set_reserved( $reserved );
981
-        do_action(
982
-            'AHEE__EE_Ticket__decrease_reserved',
983
-            $this,
984
-            $qty,
985
-            $reserved
986
-        );
987
-    }
988
-
989
-
990
-
991
-    /**
992
-     * Increases sold on related datetimes
993
-     *
994
-     * @param int $qty
995
-     * @return void
996
-     * @throws \EE_Error
997
-     */
981
+		do_action(
982
+			'AHEE__EE_Ticket__decrease_reserved',
983
+			$this,
984
+			$qty,
985
+			$reserved
986
+		);
987
+	}
988
+
989
+
990
+
991
+	/**
992
+	 * Increases sold on related datetimes
993
+	 *
994
+	 * @param int $qty
995
+	 * @return void
996
+	 * @throws \EE_Error
997
+	 */
998 998
 	protected function _decrease_reserved_for_datetimes( $qty = 1 ) {
999 999
 		$datetimes = $this->datetimes();
1000 1000
 		if ( is_array( $datetimes ) ) {
@@ -1009,18 +1009,18 @@  discard block
 block discarded – undo
1009 1009
 
1010 1010
 
1011 1011
 
1012
-    /**
1013
-     * Gets ticket quantity
1014
-     *
1015
-     * @param string $context     ticket quantity is somewhat subjective depending on the exact information sought
1016
-     *                            therefore $context can be one of three values: '', 'reg_limit', or 'saleable'
1017
-     *                            '' (default) quantity is the actual db value for TKT_qty, unaffected by other objects
1018
-     *                            REG LIMIT: caps qty based on DTT_reg_limit for ALL related datetimes
1019
-     *                            SALEABLE: also considers datetime sold and returns zero if ANY DTT is sold out, and
1020
-     *                            is therefore the truest measure of tickets that can be purchased at the moment
1021
-     * @return int
1022
-     * @throws \EE_Error
1023
-     */
1012
+	/**
1013
+	 * Gets ticket quantity
1014
+	 *
1015
+	 * @param string $context     ticket quantity is somewhat subjective depending on the exact information sought
1016
+	 *                            therefore $context can be one of three values: '', 'reg_limit', or 'saleable'
1017
+	 *                            '' (default) quantity is the actual db value for TKT_qty, unaffected by other objects
1018
+	 *                            REG LIMIT: caps qty based on DTT_reg_limit for ALL related datetimes
1019
+	 *                            SALEABLE: also considers datetime sold and returns zero if ANY DTT is sold out, and
1020
+	 *                            is therefore the truest measure of tickets that can be purchased at the moment
1021
+	 * @return int
1022
+	 * @throws \EE_Error
1023
+	 */
1024 1024
 	public function qty( $context = '' ) {
1025 1025
 		switch ( $context ) {
1026 1026
 			case 'reg_limit' :
@@ -1034,19 +1034,19 @@  discard block
 block discarded – undo
1034 1034
 
1035 1035
 
1036 1036
 
1037
-    /**
1038
-     * Gets ticket quantity
1039
-     *
1040
-     * @param string $context     ticket quantity is somewhat subjective depending on the exact information sought
1041
-     *                            therefore $context can be one of two values: 'reg_limit', or 'saleable'
1042
-     *                            REG LIMIT: caps qty based on DTT_reg_limit for ALL related datetimes
1043
-     *                            SALEABLE: also considers datetime sold and returns zero if ANY DTT is sold out, and
1044
-     *                            is therefore the truest measure of tickets that can be purchased at the moment
1045
-     * @param  int   $DTT_ID      the primary key for a particular datetime.
1046
-     *                            set to 0 for all related datetimes
1047
-     * @return int
1048
-     * @throws \EE_Error
1049
-     */
1037
+	/**
1038
+	 * Gets ticket quantity
1039
+	 *
1040
+	 * @param string $context     ticket quantity is somewhat subjective depending on the exact information sought
1041
+	 *                            therefore $context can be one of two values: 'reg_limit', or 'saleable'
1042
+	 *                            REG LIMIT: caps qty based on DTT_reg_limit for ALL related datetimes
1043
+	 *                            SALEABLE: also considers datetime sold and returns zero if ANY DTT is sold out, and
1044
+	 *                            is therefore the truest measure of tickets that can be purchased at the moment
1045
+	 * @param  int   $DTT_ID      the primary key for a particular datetime.
1046
+	 *                            set to 0 for all related datetimes
1047
+	 * @return int
1048
+	 * @throws \EE_Error
1049
+	 */
1050 1050
 	public function real_quantity_on_ticket( $context = 'reg_limit', $DTT_ID = 0 ) {
1051 1051
 		$raw = $this->get_raw( 'TKT_qty' );
1052 1052
 		// return immediately if it's zero
@@ -1129,212 +1129,212 @@  discard block
 block discarded – undo
1129 1129
 
1130 1130
 
1131 1131
 
1132
-    /**
1133
-     * Gets uses
1134
-     *
1135
-     * @return int
1136
-     * @throws \EE_Error
1137
-     */
1132
+	/**
1133
+	 * Gets uses
1134
+	 *
1135
+	 * @return int
1136
+	 * @throws \EE_Error
1137
+	 */
1138 1138
 	public function uses() {
1139 1139
 		return $this->get( 'TKT_uses' );
1140 1140
 	}
1141 1141
 
1142 1142
 
1143 1143
 
1144
-    /**
1145
-     * Sets uses
1146
-     *
1147
-     * @param int $uses
1148
-     * @return void
1149
-     * @throws \EE_Error
1150
-     */
1144
+	/**
1145
+	 * Sets uses
1146
+	 *
1147
+	 * @param int $uses
1148
+	 * @return void
1149
+	 * @throws \EE_Error
1150
+	 */
1151 1151
 	public function set_uses( $uses ) {
1152 1152
 		$this->set( 'TKT_uses', $uses );
1153 1153
 	}
1154 1154
 
1155 1155
 
1156 1156
 
1157
-    /**
1158
-     * returns whether ticket is required or not.
1159
-     *
1160
-     * @return boolean
1161
-     * @throws \EE_Error
1162
-     */
1157
+	/**
1158
+	 * returns whether ticket is required or not.
1159
+	 *
1160
+	 * @return boolean
1161
+	 * @throws \EE_Error
1162
+	 */
1163 1163
 	public function required() {
1164 1164
 		return $this->get( 'TKT_required' );
1165 1165
 	}
1166 1166
 
1167 1167
 
1168 1168
 
1169
-    /**
1170
-     * sets the TKT_required property
1171
-     *
1172
-     * @param boolean $required
1173
-     * @return void
1174
-     * @throws \EE_Error
1175
-     */
1169
+	/**
1170
+	 * sets the TKT_required property
1171
+	 *
1172
+	 * @param boolean $required
1173
+	 * @return void
1174
+	 * @throws \EE_Error
1175
+	 */
1176 1176
 	public function set_required( $required ) {
1177 1177
 		$this->set( 'TKT_required', $required );
1178 1178
 	}
1179 1179
 
1180 1180
 
1181 1181
 
1182
-    /**
1183
-     * Gets taxable
1184
-     *
1185
-     * @return boolean
1186
-     * @throws \EE_Error
1187
-     */
1182
+	/**
1183
+	 * Gets taxable
1184
+	 *
1185
+	 * @return boolean
1186
+	 * @throws \EE_Error
1187
+	 */
1188 1188
 	public function taxable() {
1189 1189
 		return $this->get( 'TKT_taxable' );
1190 1190
 	}
1191 1191
 
1192 1192
 
1193 1193
 
1194
-    /**
1195
-     * Sets taxable
1196
-     *
1197
-     * @param boolean $taxable
1198
-     * @return void
1199
-     * @throws \EE_Error
1200
-     */
1194
+	/**
1195
+	 * Sets taxable
1196
+	 *
1197
+	 * @param boolean $taxable
1198
+	 * @return void
1199
+	 * @throws \EE_Error
1200
+	 */
1201 1201
 	public function set_taxable( $taxable ) {
1202 1202
 		$this->set( 'TKT_taxable', $taxable );
1203 1203
 	}
1204 1204
 
1205 1205
 
1206 1206
 
1207
-    /**
1208
-     * Gets is_default
1209
-     *
1210
-     * @return boolean
1211
-     * @throws \EE_Error
1212
-     */
1207
+	/**
1208
+	 * Gets is_default
1209
+	 *
1210
+	 * @return boolean
1211
+	 * @throws \EE_Error
1212
+	 */
1213 1213
 	public function is_default() {
1214 1214
 		return $this->get( 'TKT_is_default' );
1215 1215
 	}
1216 1216
 
1217 1217
 
1218 1218
 
1219
-    /**
1220
-     * Sets is_default
1221
-     *
1222
-     * @param boolean $is_default
1223
-     * @return void
1224
-     * @throws \EE_Error
1225
-     */
1219
+	/**
1220
+	 * Sets is_default
1221
+	 *
1222
+	 * @param boolean $is_default
1223
+	 * @return void
1224
+	 * @throws \EE_Error
1225
+	 */
1226 1226
 	public function set_is_default( $is_default ) {
1227 1227
 		$this->set( 'TKT_is_default', $is_default );
1228 1228
 	}
1229 1229
 
1230 1230
 
1231 1231
 
1232
-    /**
1233
-     * Gets order
1234
-     *
1235
-     * @return int
1236
-     * @throws \EE_Error
1237
-     */
1232
+	/**
1233
+	 * Gets order
1234
+	 *
1235
+	 * @return int
1236
+	 * @throws \EE_Error
1237
+	 */
1238 1238
 	public function order() {
1239 1239
 		return $this->get( 'TKT_order' );
1240 1240
 	}
1241 1241
 
1242 1242
 
1243 1243
 
1244
-    /**
1245
-     * Sets order
1246
-     *
1247
-     * @param int $order
1248
-     * @return void
1249
-     * @throws \EE_Error
1250
-     */
1244
+	/**
1245
+	 * Sets order
1246
+	 *
1247
+	 * @param int $order
1248
+	 * @return void
1249
+	 * @throws \EE_Error
1250
+	 */
1251 1251
 	public function set_order( $order ) {
1252 1252
 		$this->set( 'TKT_order', $order );
1253 1253
 	}
1254 1254
 
1255 1255
 
1256 1256
 
1257
-    /**
1258
-     * Gets row
1259
-     *
1260
-     * @return int
1261
-     * @throws \EE_Error
1262
-     */
1257
+	/**
1258
+	 * Gets row
1259
+	 *
1260
+	 * @return int
1261
+	 * @throws \EE_Error
1262
+	 */
1263 1263
 	public function row() {
1264 1264
 		return $this->get( 'TKT_row' );
1265 1265
 	}
1266 1266
 
1267 1267
 
1268 1268
 
1269
-    /**
1270
-     * Sets row
1271
-     *
1272
-     * @param int $row
1273
-     * @return void
1274
-     * @throws \EE_Error
1275
-     */
1269
+	/**
1270
+	 * Sets row
1271
+	 *
1272
+	 * @param int $row
1273
+	 * @return void
1274
+	 * @throws \EE_Error
1275
+	 */
1276 1276
 	public function set_row( $row ) {
1277 1277
 		$this->set( 'TKT_row', $row );
1278 1278
 	}
1279 1279
 
1280 1280
 
1281 1281
 
1282
-    /**
1283
-     * Gets deleted
1284
-     *
1285
-     * @return boolean
1286
-     * @throws \EE_Error
1287
-     */
1282
+	/**
1283
+	 * Gets deleted
1284
+	 *
1285
+	 * @return boolean
1286
+	 * @throws \EE_Error
1287
+	 */
1288 1288
 	public function deleted() {
1289 1289
 		return $this->get( 'TKT_deleted' );
1290 1290
 	}
1291 1291
 
1292 1292
 
1293 1293
 
1294
-    /**
1295
-     * Sets deleted
1296
-     *
1297
-     * @param boolean $deleted
1298
-     * @return void
1299
-     * @throws \EE_Error
1300
-     */
1294
+	/**
1295
+	 * Sets deleted
1296
+	 *
1297
+	 * @param boolean $deleted
1298
+	 * @return void
1299
+	 * @throws \EE_Error
1300
+	 */
1301 1301
 	public function set_deleted( $deleted ) {
1302 1302
 		$this->set( 'TKT_deleted', $deleted );
1303 1303
 	}
1304 1304
 
1305 1305
 
1306 1306
 
1307
-    /**
1308
-     * Gets parent
1309
-     *
1310
-     * @return int
1311
-     * @throws \EE_Error
1312
-     */
1307
+	/**
1308
+	 * Gets parent
1309
+	 *
1310
+	 * @return int
1311
+	 * @throws \EE_Error
1312
+	 */
1313 1313
 	public function parent_ID() {
1314 1314
 		return $this->get( 'TKT_parent' );
1315 1315
 	}
1316 1316
 
1317 1317
 
1318 1318
 
1319
-    /**
1320
-     * Sets parent
1321
-     *
1322
-     * @param int $parent
1323
-     * @return void
1324
-     * @throws \EE_Error
1325
-     */
1319
+	/**
1320
+	 * Sets parent
1321
+	 *
1322
+	 * @param int $parent
1323
+	 * @return void
1324
+	 * @throws \EE_Error
1325
+	 */
1326 1326
 	public function set_parent_ID( $parent ) {
1327 1327
 		$this->set( 'TKT_parent', $parent );
1328 1328
 	}
1329 1329
 
1330 1330
 
1331 1331
 
1332
-    /**
1333
-     * Gets a string which is handy for showing in gateways etc that describes the ticket.
1334
-     *
1335
-     * @return string
1336
-     * @throws \EE_Error
1337
-     */
1332
+	/**
1333
+	 * Gets a string which is handy for showing in gateways etc that describes the ticket.
1334
+	 *
1335
+	 * @return string
1336
+	 * @throws \EE_Error
1337
+	 */
1338 1338
 	public function name_and_info() {
1339 1339
 		$times = array();
1340 1340
 		foreach ( $this->datetimes() as $datetime ) {
@@ -1345,67 +1345,67 @@  discard block
 block discarded – undo
1345 1345
 
1346 1346
 
1347 1347
 
1348
-    /**
1349
-     * Gets name
1350
-     *
1351
-     * @return string
1352
-     * @throws \EE_Error
1353
-     */
1348
+	/**
1349
+	 * Gets name
1350
+	 *
1351
+	 * @return string
1352
+	 * @throws \EE_Error
1353
+	 */
1354 1354
 	public function name() {
1355 1355
 		return $this->get( 'TKT_name' );
1356 1356
 	}
1357 1357
 
1358 1358
 
1359 1359
 
1360
-    /**
1361
-     * Gets price
1362
-     *
1363
-     * @return float
1364
-     * @throws \EE_Error
1365
-     */
1360
+	/**
1361
+	 * Gets price
1362
+	 *
1363
+	 * @return float
1364
+	 * @throws \EE_Error
1365
+	 */
1366 1366
 	public function price() {
1367 1367
 		return $this->get( 'TKT_price' );
1368 1368
 	}
1369 1369
 
1370 1370
 
1371 1371
 
1372
-    /**
1373
-     * Gets all the registrations for this ticket
1374
-     *
1375
-     * @param array $query_params like EEM_Base::get_all's
1376
-     * @return EE_Registration[]|EE_Base_Class[]
1377
-     * @throws \EE_Error
1378
-     */
1372
+	/**
1373
+	 * Gets all the registrations for this ticket
1374
+	 *
1375
+	 * @param array $query_params like EEM_Base::get_all's
1376
+	 * @return EE_Registration[]|EE_Base_Class[]
1377
+	 * @throws \EE_Error
1378
+	 */
1379 1379
 	public function registrations( $query_params = array() ) {
1380 1380
 		return $this->get_many_related( 'Registration', $query_params );
1381 1381
 	}
1382 1382
 
1383 1383
 
1384 1384
 
1385
-    /**
1386
-     * Updates the TKT_sold attribute (and saves) based on the number of APPROVED registrations for this ticket.
1387
-     * into account
1388
-     *
1389
-     * @return int
1390
-     * @throws \EE_Error
1391
-     */
1385
+	/**
1386
+	 * Updates the TKT_sold attribute (and saves) based on the number of APPROVED registrations for this ticket.
1387
+	 * into account
1388
+	 *
1389
+	 * @return int
1390
+	 * @throws \EE_Error
1391
+	 */
1392 1392
 	public function update_tickets_sold() {
1393
-        $count_regs_for_this_ticket = $this->count_registrations(
1394
-            array(
1395
-                array(
1396
-                    'STS_ID'      => EEM_Registration::status_id_approved,
1397
-                    'REG_deleted' => 0,
1398
-                ),
1399
-            )
1400
-        );
1401
-        $sold = $this->sold();
1402
-        if ($count_regs_for_this_ticket > $sold) {
1403
-            $this->increase_sold($count_regs_for_this_ticket - $sold);
1404
-            $this->save();
1405
-        } else if ($count_regs_for_this_ticket < $sold) {
1406
-            $this->decrease_sold($count_regs_for_this_ticket - $sold);
1407
-            $this->save();
1408
-        }
1393
+		$count_regs_for_this_ticket = $this->count_registrations(
1394
+			array(
1395
+				array(
1396
+					'STS_ID'      => EEM_Registration::status_id_approved,
1397
+					'REG_deleted' => 0,
1398
+				),
1399
+			)
1400
+		);
1401
+		$sold = $this->sold();
1402
+		if ($count_regs_for_this_ticket > $sold) {
1403
+			$this->increase_sold($count_regs_for_this_ticket - $sold);
1404
+			$this->save();
1405
+		} else if ($count_regs_for_this_ticket < $sold) {
1406
+			$this->decrease_sold($count_regs_for_this_ticket - $sold);
1407
+			$this->save();
1408
+		}
1409 1409
 		return $count_regs_for_this_ticket;
1410 1410
 	}
1411 1411
 
@@ -1433,21 +1433,21 @@  discard block
 block discarded – undo
1433 1433
 
1434 1434
 
1435 1435
 
1436
-    /**
1437
-     * Implementation of the EEI_Event_Relation interface method
1438
-     *
1439
-     * @see EEI_Event_Relation for comments
1440
-     * @return EE_Event
1441
-     * @throws \EE_Error
1442
-     * @throws UnexpectedEntityException
1443
-     */
1436
+	/**
1437
+	 * Implementation of the EEI_Event_Relation interface method
1438
+	 *
1439
+	 * @see EEI_Event_Relation for comments
1440
+	 * @return EE_Event
1441
+	 * @throws \EE_Error
1442
+	 * @throws UnexpectedEntityException
1443
+	 */
1444 1444
 	public function get_related_event() {
1445 1445
 		//get one datetime to use for getting the event
1446 1446
 		$datetime = $this->first_datetime();
1447 1447
 		if ( ! $datetime instanceof \EE_Datetime ) {
1448 1448
 			throw new UnexpectedEntityException(
1449 1449
 				$datetime,
1450
-                'EE_Datetime',
1450
+				'EE_Datetime',
1451 1451
 				sprintf(
1452 1452
 					__( 'The ticket (%s) is not associated with any valid datetimes.', 'event_espresso'),
1453 1453
 					$this->name()
@@ -1458,7 +1458,7 @@  discard block
 block discarded – undo
1458 1458
 		if ( ! $event instanceof \EE_Event ) {
1459 1459
 			throw new UnexpectedEntityException(
1460 1460
 				$event,
1461
-                'EE_Event',
1461
+				'EE_Event',
1462 1462
 				sprintf(
1463 1463
 					__( 'The ticket (%s) is not associated with a valid event.', 'event_espresso'),
1464 1464
 					$this->name()
@@ -1470,14 +1470,14 @@  discard block
 block discarded – undo
1470 1470
 
1471 1471
 
1472 1472
 
1473
-    /**
1474
-     * Implementation of the EEI_Event_Relation interface method
1475
-     *
1476
-     * @see EEI_Event_Relation for comments
1477
-     * @return string
1478
-     * @throws UnexpectedEntityException
1479
-     * @throws \EE_Error
1480
-     */
1473
+	/**
1474
+	 * Implementation of the EEI_Event_Relation interface method
1475
+	 *
1476
+	 * @see EEI_Event_Relation for comments
1477
+	 * @return string
1478
+	 * @throws UnexpectedEntityException
1479
+	 * @throws \EE_Error
1480
+	 */
1481 1481
 	public function get_event_name() {
1482 1482
 		$event = $this->get_related_event();
1483 1483
 		return $event instanceof EE_Event ? $event->name() : '';
@@ -1485,62 +1485,62 @@  discard block
 block discarded – undo
1485 1485
 
1486 1486
 
1487 1487
 
1488
-    /**
1489
-     * Implementation of the EEI_Event_Relation interface method
1490
-     *
1491
-     * @see EEI_Event_Relation for comments
1492
-     * @return int
1493
-     * @throws UnexpectedEntityException
1494
-     * @throws \EE_Error
1495
-     */
1488
+	/**
1489
+	 * Implementation of the EEI_Event_Relation interface method
1490
+	 *
1491
+	 * @see EEI_Event_Relation for comments
1492
+	 * @return int
1493
+	 * @throws UnexpectedEntityException
1494
+	 * @throws \EE_Error
1495
+	 */
1496 1496
 	public function get_event_ID() {
1497 1497
 		$event = $this->get_related_event();
1498 1498
 		return $event instanceof EE_Event ? $event->ID() : 0;
1499 1499
 	}
1500 1500
 
1501 1501
 
1502
-    /**
1503
-     * This simply returns whether a ticket can be permanently deleted or not.
1504
-     * The criteria for determining this is whether the ticket has any related registrations.
1505
-     * If there are none then it can be permanently deleted.
1506
-     *
1507
-     * @return bool
1508
-     */
1502
+	/**
1503
+	 * This simply returns whether a ticket can be permanently deleted or not.
1504
+	 * The criteria for determining this is whether the ticket has any related registrations.
1505
+	 * If there are none then it can be permanently deleted.
1506
+	 *
1507
+	 * @return bool
1508
+	 */
1509 1509
 	public function is_permanently_deleteable() {
1510
-	    return $this->count_registrations() === 0;
1511
-    }
1512
-
1513
-
1514
-    /**
1515
-     * Returns the payment's amount in subunits (if the currency has subunits; otherwise this will actually be
1516
-     * in the currency's main units)
1517
-     *
1518
-     * @return int
1519
-     * @throws EE_Error
1520
-     * @throws InvalidEntityException
1521
-     * @throws DomainException
1522
-     */
1523
-    public function amountInSubunits()
1524
-    {
1525
-        return $this->moneyInSubunits('TKT_price');
1526
-    }
1527
-
1528
-
1529
-    /**
1530
-     * Sets the payment's amount based on the incoming monetary subunits (eg pennies). If the currency has no subunits,
1531
-     * the amount is actually assumed to be in the currency's main units
1532
-     *
1533
-     * @param int $amount_in_subunits
1534
-     * @return void
1535
-     * @throws EE_Error
1536
-     * @throws InvalidArgumentException
1537
-     * @throws InvalidInterfaceException
1538
-     * @throws InvalidIdentifierException
1539
-     * @throws InvalidDataTypeException
1540
-     * @throws DomainException
1541
-     */
1542
-    public function setAmountInSubunits($amount_in_subunits)
1543
-    {
1544
-        $this->setMoneySubunits('TKT_price', $amount_in_subunits);
1545
-    }
1510
+		return $this->count_registrations() === 0;
1511
+	}
1512
+
1513
+
1514
+	/**
1515
+	 * Returns the payment's amount in subunits (if the currency has subunits; otherwise this will actually be
1516
+	 * in the currency's main units)
1517
+	 *
1518
+	 * @return int
1519
+	 * @throws EE_Error
1520
+	 * @throws InvalidEntityException
1521
+	 * @throws DomainException
1522
+	 */
1523
+	public function amountInSubunits()
1524
+	{
1525
+		return $this->moneyInSubunits('TKT_price');
1526
+	}
1527
+
1528
+
1529
+	/**
1530
+	 * Sets the payment's amount based on the incoming monetary subunits (eg pennies). If the currency has no subunits,
1531
+	 * the amount is actually assumed to be in the currency's main units
1532
+	 *
1533
+	 * @param int $amount_in_subunits
1534
+	 * @return void
1535
+	 * @throws EE_Error
1536
+	 * @throws InvalidArgumentException
1537
+	 * @throws InvalidInterfaceException
1538
+	 * @throws InvalidIdentifierException
1539
+	 * @throws InvalidDataTypeException
1540
+	 * @throws DomainException
1541
+	 */
1542
+	public function setAmountInSubunits($amount_in_subunits)
1543
+	{
1544
+		$this->setMoneySubunits('TKT_price', $amount_in_subunits);
1545
+	}
1546 1546
 } //end EE_Ticket class
Please login to merge, or discard this patch.
Spacing   +199 added lines, -199 removed lines patch added patch discarded remove patch
@@ -7,8 +7,8 @@  discard block
 block discarded – undo
7 7
 use EventEspresso\core\services\currency\MoneyFactory;
8 8
 use EventEspresso\core\services\loaders\LoaderFactory;
9 9
 
10
-if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
11
-	exit( 'No direct script access allowed' );
10
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
11
+	exit('No direct script access allowed');
12 12
 }
13 13
 /**
14 14
  * Event Espresso
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
         array $date_formats = array(),
161 161
         MoneyFactory $money_factory = null
162 162
     ) {
163
-        if (! $money_factory instanceof MoneyFactory) {
163
+        if ( ! $money_factory instanceof MoneyFactory) {
164 164
             $money_factory = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\currency\MoneyFactory');
165 165
         }
166 166
         $this->money_factory = $money_factory;
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
      * @throws \EE_Error
174 174
      */
175 175
 	public function parent() {
176
-		return $this->get( 'TKT_parent' );
176
+		return $this->get('TKT_parent');
177 177
 	}
178 178
 
179 179
 
@@ -185,13 +185,13 @@  discard block
 block discarded – undo
185 185
      * @return boolean
186 186
      * @throws \EE_Error
187 187
      */
188
-	public function available( $DTT_ID = 0 ) {
188
+	public function available($DTT_ID = 0) {
189 189
 		// are we checking availability for a particular datetime ?
190
-		if ( $DTT_ID ) {
190
+		if ($DTT_ID) {
191 191
 			// get that datetime object
192
-			$datetime = $this->get_first_related( 'Datetime', array( array( 'DTT_ID' => $DTT_ID ) ) );
192
+			$datetime = $this->get_first_related('Datetime', array(array('DTT_ID' => $DTT_ID)));
193 193
 			// if  ticket sales for this datetime have exceeded the reg limit...
194
-			if ( $datetime instanceof EE_Datetime && $datetime->sold_out() ) {
194
+			if ($datetime instanceof EE_Datetime && $datetime->sold_out()) {
195 195
 				return FALSE;
196 196
 			}
197 197
 		}
@@ -209,22 +209,22 @@  discard block
 block discarded – undo
209 209
      * @return mixed status int if the display string isn't requested
210 210
      * @throws \EE_Error
211 211
      */
212
-	public function ticket_status( $display = FALSE, $remaining = null ) {
213
-		$remaining = is_bool( $remaining ) ? $remaining : $this->is_remaining();
214
-		if ( ! $remaining ) {
215
-			return $display ? EEH_Template::pretty_status( EE_Ticket::sold_out, FALSE, 'sentence' ) : EE_Ticket::sold_out;
212
+	public function ticket_status($display = FALSE, $remaining = null) {
213
+		$remaining = is_bool($remaining) ? $remaining : $this->is_remaining();
214
+		if ( ! $remaining) {
215
+			return $display ? EEH_Template::pretty_status(EE_Ticket::sold_out, FALSE, 'sentence') : EE_Ticket::sold_out;
216 216
 		}
217
-		if ( $this->get( 'TKT_deleted' ) ) {
218
-			return $display ? EEH_Template::pretty_status( EE_Ticket::archived, FALSE, 'sentence' ) : EE_Ticket::archived;
217
+		if ($this->get('TKT_deleted')) {
218
+			return $display ? EEH_Template::pretty_status(EE_Ticket::archived, FALSE, 'sentence') : EE_Ticket::archived;
219 219
 		}
220
-		if ( $this->is_expired() ) {
221
-			return $display ? EEH_Template::pretty_status( EE_Ticket::expired, FALSE, 'sentence' ) : EE_Ticket::expired;
220
+		if ($this->is_expired()) {
221
+			return $display ? EEH_Template::pretty_status(EE_Ticket::expired, FALSE, 'sentence') : EE_Ticket::expired;
222 222
 		}
223
-		if ( $this->is_pending() ) {
224
-			return $display ? EEH_Template::pretty_status( EE_Ticket::pending, FALSE, 'sentence' ) : EE_Ticket::pending;
223
+		if ($this->is_pending()) {
224
+			return $display ? EEH_Template::pretty_status(EE_Ticket::pending, FALSE, 'sentence') : EE_Ticket::pending;
225 225
 		}
226
-		if ( $this->is_on_sale() ) {
227
-			return $display ? EEH_Template::pretty_status( EE_Ticket::onsale, FALSE, 'sentence' ) : EE_Ticket::onsale;
226
+		if ($this->is_on_sale()) {
227
+			return $display ? EEH_Template::pretty_status(EE_Ticket::onsale, FALSE, 'sentence') : EE_Ticket::onsale;
228 228
 		}
229 229
 		return '';
230 230
 	}
@@ -239,12 +239,12 @@  discard block
 block discarded – undo
239 239
      * @return boolean         true = tickets remaining, false not.
240 240
      * @throws \EE_Error
241 241
      */
242
-	public function is_remaining( $DTT_ID = 0 ) {
243
-		$num_remaining = $this->remaining( $DTT_ID );
244
-		if ( $num_remaining === 0 ) {
242
+	public function is_remaining($DTT_ID = 0) {
243
+		$num_remaining = $this->remaining($DTT_ID);
244
+		if ($num_remaining === 0) {
245 245
 			return FALSE;
246 246
 		}
247
-		if ( $num_remaining > 0 && $num_remaining < $this->min() ) {
247
+		if ($num_remaining > 0 && $num_remaining < $this->min()) {
248 248
 			return FALSE;
249 249
 		}
250 250
 		return TRUE;
@@ -260,8 +260,8 @@  discard block
 block discarded – undo
260 260
      * @return int
261 261
      * @throws \EE_Error
262 262
      */
263
-	public function remaining( $DTT_ID = 0 ) {
264
-		return $this->real_quantity_on_ticket('saleable', $DTT_ID );
263
+	public function remaining($DTT_ID = 0) {
264
+		return $this->real_quantity_on_ticket('saleable', $DTT_ID);
265 265
 	}
266 266
 
267 267
 
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
      * @throws \EE_Error
274 274
      */
275 275
 	public function min() {
276
-		return $this->get( 'TKT_min' );
276
+		return $this->get('TKT_min');
277 277
 	}
278 278
 
279 279
 
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
      * @throws \EE_Error
286 286
      */
287 287
 	public function is_expired() {
288
-		return ( $this->get_raw( 'TKT_end_date' ) < time() );
288
+		return ($this->get_raw('TKT_end_date') < time());
289 289
 	}
290 290
 
291 291
 
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
      * @throws \EE_Error
298 298
      */
299 299
 	public function is_pending() {
300
-		return ( $this->get_raw( 'TKT_start_date' ) > time() );
300
+		return ($this->get_raw('TKT_start_date') > time());
301 301
 	}
302 302
 
303 303
 
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
      * @throws \EE_Error
310 310
      */
311 311
 	public function is_on_sale() {
312
-		return ( $this->get_raw( 'TKT_start_date' ) < time() && $this->get_raw( 'TKT_end_date' ) > time() );
312
+		return ($this->get_raw('TKT_start_date') < time() && $this->get_raw('TKT_end_date') > time());
313 313
 	}
314 314
 
315 315
 
@@ -322,11 +322,11 @@  discard block
 block discarded – undo
322 322
      * @return string
323 323
      * @throws \EE_Error
324 324
      */
325
-	public function date_range( $dt_frmt = '', $conjunction = ' - ' ) {
326
-		$first_date = $this->first_datetime() instanceof EE_Datetime ? $this->first_datetime()->start_date( $dt_frmt ) : '';
327
-		$last_date = $this->last_datetime() instanceof EE_Datetime ? $this->last_datetime()->end_date( $dt_frmt ) : '';
325
+	public function date_range($dt_frmt = '', $conjunction = ' - ') {
326
+		$first_date = $this->first_datetime() instanceof EE_Datetime ? $this->first_datetime()->start_date($dt_frmt) : '';
327
+		$last_date = $this->last_datetime() instanceof EE_Datetime ? $this->last_datetime()->end_date($dt_frmt) : '';
328 328
 
329
-		return $first_date && $last_date ? $first_date . $conjunction  . $last_date : '';
329
+		return $first_date && $last_date ? $first_date.$conjunction.$last_date : '';
330 330
 	}
331 331
 
332 332
 
@@ -338,8 +338,8 @@  discard block
 block discarded – undo
338 338
      * @throws \EE_Error
339 339
      */
340 340
 	public function first_datetime() {
341
-		$datetimes = $this->datetimes( array( 'limit' => 1 ) );
342
-		return reset( $datetimes );
341
+		$datetimes = $this->datetimes(array('limit' => 1));
342
+		return reset($datetimes);
343 343
 	}
344 344
 
345 345
 
@@ -352,11 +352,11 @@  discard block
 block discarded – undo
352 352
      * @return EE_Datetime[]|EE_Base_Class[]
353 353
      * @throws \EE_Error
354 354
      */
355
-	public function datetimes( $query_params = array() ) {
356
-		if ( ! isset( $query_params[ 'order_by' ] ) ) {
357
-			$query_params[ 'order_by' ][ 'DTT_order' ] = 'ASC';
355
+	public function datetimes($query_params = array()) {
356
+		if ( ! isset($query_params['order_by'])) {
357
+			$query_params['order_by']['DTT_order'] = 'ASC';
358 358
 		}
359
-		return $this->get_many_related( 'Datetime', $query_params );
359
+		return $this->get_many_related('Datetime', $query_params);
360 360
 	}
361 361
 
362 362
 
@@ -368,8 +368,8 @@  discard block
 block discarded – undo
368 368
      * @throws \EE_Error
369 369
      */
370 370
 	public function last_datetime() {
371
-		$datetimes = $this->datetimes( array( 'limit' => 1, 'order_by' => array( 'DTT_EVT_start' => 'DESC' ) ) );
372
-		return end( $datetimes );
371
+		$datetimes = $this->datetimes(array('limit' => 1, 'order_by' => array('DTT_EVT_start' => 'DESC')));
372
+		return end($datetimes);
373 373
 	}
374 374
 
375 375
 
@@ -387,22 +387,22 @@  discard block
 block discarded – undo
387 387
      * @return mixed (array|int)          how many tickets have sold
388 388
      * @throws \EE_Error
389 389
      */
390
-	public function tickets_sold( $what = 'ticket', $dtt_id = NULL ) {
390
+	public function tickets_sold($what = 'ticket', $dtt_id = NULL) {
391 391
 		$total = 0;
392 392
 		$tickets_sold = $this->_all_tickets_sold();
393
-		switch ( $what ) {
393
+		switch ($what) {
394 394
 			case 'ticket' :
395
-				return $tickets_sold[ 'ticket' ];
395
+				return $tickets_sold['ticket'];
396 396
 				break;
397 397
 			case 'datetime' :
398
-				if ( empty( $tickets_sold[ 'datetime' ] ) ) {
398
+				if (empty($tickets_sold['datetime'])) {
399 399
 					return $total;
400 400
 				}
401
-				if ( ! empty( $dtt_id ) && ! isset( $tickets_sold[ 'datetime' ][ $dtt_id ] ) ) {
402
-					EE_Error::add_error( __( 'You\'ve requested the amount of tickets sold for a given ticket and datetime, however there are no records for the datetime id you included.  Are you SURE that is a datetime related to this ticket?', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
401
+				if ( ! empty($dtt_id) && ! isset($tickets_sold['datetime'][$dtt_id])) {
402
+					EE_Error::add_error(__('You\'ve requested the amount of tickets sold for a given ticket and datetime, however there are no records for the datetime id you included.  Are you SURE that is a datetime related to this ticket?', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
403 403
 					return $total;
404 404
 				}
405
-				return empty( $dtt_id ) ? $tickets_sold[ 'datetime' ] : $tickets_sold[ 'datetime' ][ $dtt_id ];
405
+				return empty($dtt_id) ? $tickets_sold['datetime'] : $tickets_sold['datetime'][$dtt_id];
406 406
 				break;
407 407
 			default:
408 408
 				return $total;
@@ -418,15 +418,15 @@  discard block
 block discarded – undo
418 418
      * @throws \EE_Error
419 419
      */
420 420
 	protected function _all_tickets_sold() {
421
-		$datetimes = $this->get_many_related( 'Datetime' );
421
+		$datetimes = $this->get_many_related('Datetime');
422 422
 		$tickets_sold = array();
423
-		if ( ! empty( $datetimes ) ) {
424
-			foreach ( $datetimes as $datetime ) {
425
-				$tickets_sold[ 'datetime' ][ $datetime->ID() ] = $datetime->get( 'DTT_sold' );
423
+		if ( ! empty($datetimes)) {
424
+			foreach ($datetimes as $datetime) {
425
+				$tickets_sold['datetime'][$datetime->ID()] = $datetime->get('DTT_sold');
426 426
 			}
427 427
 		}
428 428
 		//Tickets sold
429
-		$tickets_sold[ 'ticket' ] = $this->sold();
429
+		$tickets_sold['ticket'] = $this->sold();
430 430
 		return $tickets_sold;
431 431
 	}
432 432
 
@@ -439,11 +439,11 @@  discard block
 block discarded – undo
439 439
      * @return EE_Price|EE_Base_Class|EE_Price[]|EE_Base_Class[]
440 440
      * @throws \EE_Error
441 441
      */
442
-	public function base_price( $return_array = FALSE ) {
443
-		$_where = array( 'Price_Type.PBT_ID' => EEM_Price_Type::base_type_base_price );
442
+	public function base_price($return_array = FALSE) {
443
+		$_where = array('Price_Type.PBT_ID' => EEM_Price_Type::base_type_base_price);
444 444
 		return $return_array
445
-            ? $this->get_many_related( 'Price', array( $_where ) )
446
-            : $this->get_first_related( 'Price', array( $_where ) );
445
+            ? $this->get_many_related('Price', array($_where))
446
+            : $this->get_first_related('Price', array($_where));
447 447
 	}
448 448
 
449 449
 
@@ -456,8 +456,8 @@  discard block
 block discarded – undo
456 456
      * @throws \EE_Error
457 457
      */
458 458
 	public function price_modifiers() {
459
-		$query_params = array( 0 => array( 'Price_Type.PBT_ID' => array( 'NOT IN', array( EEM_Price_Type::base_type_base_price, EEM_Price_Type::base_type_tax ) ) ) );
460
-		return $this->prices( $query_params );
459
+		$query_params = array(0 => array('Price_Type.PBT_ID' => array('NOT IN', array(EEM_Price_Type::base_type_base_price, EEM_Price_Type::base_type_tax))));
460
+		return $this->prices($query_params);
461 461
 	}
462 462
 
463 463
 
@@ -469,8 +469,8 @@  discard block
 block discarded – undo
469 469
      * @return EE_Price[]|EE_Base_Class[]
470 470
      * @throws \EE_Error
471 471
      */
472
-	public function prices( $query_params = array() ) {
473
-		return $this->get_many_related( 'Price', $query_params );
472
+	public function prices($query_params = array()) {
473
+		return $this->get_many_related('Price', $query_params);
474 474
 	}
475 475
 
476 476
 
@@ -482,8 +482,8 @@  discard block
 block discarded – undo
482 482
      * @return EE_Datetime_Ticket|EE_Base_Class[]
483 483
      * @throws \EE_Error
484 484
      */
485
-	public function datetime_tickets( $query_params = array() ) {
486
-		return $this->get_many_related( 'Datetime_Ticket', $query_params );
485
+	public function datetime_tickets($query_params = array()) {
486
+		return $this->get_many_related('Datetime_Ticket', $query_params);
487 487
 	}
488 488
 
489 489
 
@@ -496,8 +496,8 @@  discard block
 block discarded – undo
496 496
      * @return EE_Datetime[]
497 497
      * @throws \EE_Error
498 498
      */
499
-	public function datetimes_ordered( $show_expired = TRUE, $show_deleted = FALSE ) {
500
-		return EEM_Datetime::instance( $this->_timezone )->get_datetimes_for_ticket_ordered_by_DTT_order( $this->ID(), $show_expired, $show_deleted );
499
+	public function datetimes_ordered($show_expired = TRUE, $show_deleted = FALSE) {
500
+		return EEM_Datetime::instance($this->_timezone)->get_datetimes_for_ticket_ordered_by_DTT_order($this->ID(), $show_expired, $show_deleted);
501 501
 	}
502 502
 
503 503
 
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
      * @throws \EE_Error
510 510
      */
511 511
 	public function ID() {
512
-		return $this->get( 'TKT_ID' );
512
+		return $this->get('TKT_ID');
513 513
 	}
514 514
 
515 515
 
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
      * @throws \EE_Error
535 535
      */
536 536
 	public function template() {
537
-		return $this->get_first_related( 'Ticket_Template' );
537
+		return $this->get_first_related('Ticket_Template');
538 538
 	}
539 539
 
540 540
 
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
      * @throws \EE_Error
557 557
      */
558 558
 	public function ticket_price() {
559
-		return $this->get( 'TKT_price' );
559
+		return $this->get('TKT_price');
560 560
 	}
561 561
 
562 562
 
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
      * @throws \EE_Error
567 567
      */
568 568
 	public function pretty_price() {
569
-		return $this->get_pretty( 'TKT_price' );
569
+		return $this->get_pretty('TKT_price');
570 570
 	}
571 571
 
572 572
 
@@ -588,8 +588,8 @@  discard block
 block discarded – undo
588 588
      * @return float
589 589
      * @throws \EE_Error
590 590
      */
591
-	public function get_ticket_total_with_taxes( $no_cache = FALSE ) {
592
-		if ($this->_ticket_total_with_taxes === null || $no_cache ) {
591
+	public function get_ticket_total_with_taxes($no_cache = FALSE) {
592
+		if ($this->_ticket_total_with_taxes === null || $no_cache) {
593 593
 			$this->_ticket_total_with_taxes = $this->get_ticket_subtotal() + $this->get_ticket_taxes_total_for_admin();
594 594
 		}
595 595
 		return (float) $this->_ticket_total_with_taxes;
@@ -598,7 +598,7 @@  discard block
 block discarded – undo
598 598
 
599 599
 
600 600
 	public function ensure_TKT_Price_correct() {
601
-		$this->set( 'TKT_price', EE_Taxes::get_subtotal_for_admin( $this ) );
601
+		$this->set('TKT_price', EE_Taxes::get_subtotal_for_admin($this));
602 602
 		$this->save();
603 603
 	}
604 604
 
@@ -609,7 +609,7 @@  discard block
 block discarded – undo
609 609
      * @throws \EE_Error
610 610
      */
611 611
 	public function get_ticket_subtotal() {
612
-		return EE_Taxes::get_subtotal_for_admin( $this );
612
+		return EE_Taxes::get_subtotal_for_admin($this);
613 613
 	}
614 614
 
615 615
 
@@ -621,7 +621,7 @@  discard block
 block discarded – undo
621 621
      * @throws \EE_Error
622 622
      */
623 623
 	public function get_ticket_taxes_total_for_admin() {
624
-		return EE_Taxes::get_total_taxes_for_admin( $this );
624
+		return EE_Taxes::get_total_taxes_for_admin($this);
625 625
 	}
626 626
 
627 627
 
@@ -632,8 +632,8 @@  discard block
 block discarded – undo
632 632
      * @param string $name
633 633
      * @throws \EE_Error
634 634
      */
635
-	public function set_name( $name ) {
636
-		$this->set( 'TKT_name', $name );
635
+	public function set_name($name) {
636
+		$this->set('TKT_name', $name);
637 637
 	}
638 638
 
639 639
 
@@ -645,7 +645,7 @@  discard block
 block discarded – undo
645 645
      * @throws \EE_Error
646 646
      */
647 647
 	public function description() {
648
-		return $this->get( 'TKT_description' );
648
+		return $this->get('TKT_description');
649 649
 	}
650 650
 
651 651
 
@@ -656,8 +656,8 @@  discard block
 block discarded – undo
656 656
      * @param string $description
657 657
      * @throws \EE_Error
658 658
      */
659
-	public function set_description( $description ) {
660
-		$this->set( 'TKT_description', $description );
659
+	public function set_description($description) {
660
+		$this->set('TKT_description', $description);
661 661
 	}
662 662
 
663 663
 
@@ -670,8 +670,8 @@  discard block
 block discarded – undo
670 670
      * @return string
671 671
      * @throws \EE_Error
672 672
      */
673
-	public function start_date( $dt_frmt = '', $tm_frmt = '' ) {
674
-		return $this->_get_datetime( 'TKT_start_date', $dt_frmt, $tm_frmt );
673
+	public function start_date($dt_frmt = '', $tm_frmt = '') {
674
+		return $this->_get_datetime('TKT_start_date', $dt_frmt, $tm_frmt);
675 675
 	}
676 676
 
677 677
 
@@ -683,8 +683,8 @@  discard block
 block discarded – undo
683 683
      * @return void
684 684
      * @throws \EE_Error
685 685
      */
686
-	public function set_start_date( $start_date ) {
687
-		$this->_set_date_time( 'B', $start_date, 'TKT_start_date' );
686
+	public function set_start_date($start_date) {
687
+		$this->_set_date_time('B', $start_date, 'TKT_start_date');
688 688
 	}
689 689
 
690 690
 
@@ -697,8 +697,8 @@  discard block
 block discarded – undo
697 697
      * @return string
698 698
      * @throws \EE_Error
699 699
      */
700
-	public function end_date( $dt_frmt = '', $tm_frmt = '' ) {
701
-		return $this->_get_datetime( 'TKT_end_date', $dt_frmt, $tm_frmt );
700
+	public function end_date($dt_frmt = '', $tm_frmt = '') {
701
+		return $this->_get_datetime('TKT_end_date', $dt_frmt, $tm_frmt);
702 702
 	}
703 703
 
704 704
 
@@ -710,8 +710,8 @@  discard block
 block discarded – undo
710 710
      * @return void
711 711
      * @throws \EE_Error
712 712
      */
713
-	public function set_end_date( $end_date ) {
714
-		$this->_set_date_time( 'B', $end_date, 'TKT_end_date' );
713
+	public function set_end_date($end_date) {
714
+		$this->_set_date_time('B', $end_date, 'TKT_end_date');
715 715
 	}
716 716
 
717 717
 
@@ -723,8 +723,8 @@  discard block
 block discarded – undo
723 723
      * @param string $time a string representation of the sell until time (ex 9am or 7:30pm)
724 724
      * @throws \EE_Error
725 725
      */
726
-	public function set_end_time( $time ) {
727
-		$this->_set_time_for( $time, 'TKT_end_date' );
726
+	public function set_end_time($time) {
727
+		$this->_set_time_for($time, 'TKT_end_date');
728 728
 	}
729 729
 
730 730
 
@@ -736,8 +736,8 @@  discard block
 block discarded – undo
736 736
      * @return void
737 737
      * @throws \EE_Error
738 738
      */
739
-	public function set_min( $min ) {
740
-		$this->set( 'TKT_min', $min );
739
+	public function set_min($min) {
740
+		$this->set('TKT_min', $min);
741 741
 	}
742 742
 
743 743
 
@@ -749,7 +749,7 @@  discard block
 block discarded – undo
749 749
      * @throws \EE_Error
750 750
      */
751 751
 	public function max() {
752
-		return $this->get( 'TKT_max' );
752
+		return $this->get('TKT_max');
753 753
 	}
754 754
 
755 755
 
@@ -761,8 +761,8 @@  discard block
 block discarded – undo
761 761
      * @return void
762 762
      * @throws \EE_Error
763 763
      */
764
-	public function set_max( $max ) {
765
-		$this->set( 'TKT_max', $max );
764
+	public function set_max($max) {
765
+		$this->set('TKT_max', $max);
766 766
 	}
767 767
 
768 768
 
@@ -774,8 +774,8 @@  discard block
 block discarded – undo
774 774
      * @return void
775 775
      * @throws \EE_Error
776 776
      */
777
-	public function set_price( $price ) {
778
-		$this->set( 'TKT_price', $price );
777
+	public function set_price($price) {
778
+		$this->set('TKT_price', $price);
779 779
 	}
780 780
 
781 781
 
@@ -787,7 +787,7 @@  discard block
 block discarded – undo
787 787
      * @throws \EE_Error
788 788
      */
789 789
 	public function sold() {
790
-		return $this->get_raw( 'TKT_sold' );
790
+		return $this->get_raw('TKT_sold');
791 791
 	}
792 792
 
793 793
 
@@ -799,10 +799,10 @@  discard block
 block discarded – undo
799 799
      * @return void
800 800
      * @throws \EE_Error
801 801
      */
802
-	public function set_sold( $sold ) {
802
+	public function set_sold($sold) {
803 803
 		// sold can not go below zero
804
-		$sold = max( 0, $sold );
805
-		$this->set( 'TKT_sold', $sold );
804
+		$sold = max(0, $sold);
805
+		$this->set('TKT_sold', $sold);
806 806
 	}
807 807
 
808 808
 
@@ -814,13 +814,13 @@  discard block
 block discarded – undo
814 814
      * @return void
815 815
      * @throws \EE_Error
816 816
      */
817
-	public function increase_sold( $qty = 1 ) {
817
+	public function increase_sold($qty = 1) {
818 818
 		$sold = $this->sold() + $qty;
819 819
 		// remove ticket reservation, but don't adjust datetime reservations,  because that will happen
820 820
 		// via \EE_Datetime::increase_sold() when \EE_Ticket::_increase_sold_for_datetimes() is called
821
-		$this->decrease_reserved( $qty, false );
822
-		$this->_increase_sold_for_datetimes( $qty );
823
-		$this->set_sold( $sold );
821
+		$this->decrease_reserved($qty, false);
822
+		$this->_increase_sold_for_datetimes($qty);
823
+		$this->set_sold($sold);
824 824
 		do_action(
825 825
 		    'AHEE__EE_Ticket__increase_sold',
826 826
             $this,
@@ -838,12 +838,12 @@  discard block
 block discarded – undo
838 838
      * @return void
839 839
      * @throws \EE_Error
840 840
      */
841
-	protected function _increase_sold_for_datetimes( $qty = 1 ) {
841
+	protected function _increase_sold_for_datetimes($qty = 1) {
842 842
 		$datetimes = $this->datetimes();
843
-		if ( is_array( $datetimes ) ) {
844
-			foreach ( $datetimes as $datetime ) {
845
-				if ( $datetime instanceof EE_Datetime ) {
846
-					$datetime->increase_sold( $qty );
843
+		if (is_array($datetimes)) {
844
+			foreach ($datetimes as $datetime) {
845
+				if ($datetime instanceof EE_Datetime) {
846
+					$datetime->increase_sold($qty);
847 847
 					$datetime->save();
848 848
 				}
849 849
 			}
@@ -859,10 +859,10 @@  discard block
 block discarded – undo
859 859
      * @return void
860 860
      * @throws \EE_Error
861 861
      */
862
-	public function decrease_sold( $qty = 1 ) {
862
+	public function decrease_sold($qty = 1) {
863 863
 		$sold = $this->sold() - $qty;
864
-		$this->_decrease_sold_for_datetimes( $qty );
865
-		$this->set_sold( $sold );
864
+		$this->_decrease_sold_for_datetimes($qty);
865
+		$this->set_sold($sold);
866 866
         do_action(
867 867
             'AHEE__EE_Ticket__decrease_sold',
868 868
             $this,
@@ -880,12 +880,12 @@  discard block
 block discarded – undo
880 880
      * @return void
881 881
      * @throws \EE_Error
882 882
      */
883
-	protected function _decrease_sold_for_datetimes( $qty = 1 ) {
883
+	protected function _decrease_sold_for_datetimes($qty = 1) {
884 884
 		$datetimes = $this->datetimes();
885
-		if ( is_array( $datetimes ) ) {
886
-			foreach ( $datetimes as $datetime ) {
887
-				if ( $datetime instanceof EE_Datetime ) {
888
-					$datetime->decrease_sold( $qty );
885
+		if (is_array($datetimes)) {
886
+			foreach ($datetimes as $datetime) {
887
+				if ($datetime instanceof EE_Datetime) {
888
+					$datetime->decrease_sold($qty);
889 889
 					$datetime->save();
890 890
 				}
891 891
 			}
@@ -901,7 +901,7 @@  discard block
 block discarded – undo
901 901
      * @throws \EE_Error
902 902
      */
903 903
 	public function reserved() {
904
-		return $this->get_raw( 'TKT_reserved' );
904
+		return $this->get_raw('TKT_reserved');
905 905
 	}
906 906
 
907 907
 
@@ -913,10 +913,10 @@  discard block
 block discarded – undo
913 913
      * @return void
914 914
      * @throws \EE_Error
915 915
      */
916
-	public function set_reserved( $reserved ) {
916
+	public function set_reserved($reserved) {
917 917
 		// reserved can not go below zero
918
-		$reserved = max( 0, (int) $reserved );
919
-		$this->set( 'TKT_reserved', $reserved );
918
+		$reserved = max(0, (int) $reserved);
919
+		$this->set('TKT_reserved', $reserved);
920 920
 	}
921 921
 
922 922
 
@@ -928,11 +928,11 @@  discard block
 block discarded – undo
928 928
      * @return void
929 929
      * @throws \EE_Error
930 930
      */
931
-	public function increase_reserved( $qty = 1 ) {
932
-		$qty = absint( $qty );
931
+	public function increase_reserved($qty = 1) {
932
+		$qty = absint($qty);
933 933
 		$reserved = $this->reserved() + $qty;
934
-		$this->_increase_reserved_for_datetimes( $qty );
935
-		$this->set_reserved( $reserved );
934
+		$this->_increase_reserved_for_datetimes($qty);
935
+		$this->set_reserved($reserved);
936 936
         do_action(
937 937
             'AHEE__EE_Ticket__increase_reserved',
938 938
             $this,
@@ -950,12 +950,12 @@  discard block
 block discarded – undo
950 950
      * @return void
951 951
      * @throws \EE_Error
952 952
      */
953
-	protected function _increase_reserved_for_datetimes( $qty = 1 ) {
953
+	protected function _increase_reserved_for_datetimes($qty = 1) {
954 954
 		$datetimes = $this->datetimes();
955
-		if ( is_array( $datetimes ) ) {
956
-			foreach ( $datetimes as $datetime ) {
957
-				if ( $datetime instanceof EE_Datetime ) {
958
-					$datetime->increase_reserved( $qty );
955
+		if (is_array($datetimes)) {
956
+			foreach ($datetimes as $datetime) {
957
+				if ($datetime instanceof EE_Datetime) {
958
+					$datetime->increase_reserved($qty);
959 959
 					$datetime->save();
960 960
 				}
961 961
 			}
@@ -972,12 +972,12 @@  discard block
 block discarded – undo
972 972
      * @return void
973 973
      * @throws \EE_Error
974 974
      */
975
-	public function decrease_reserved( $qty = 1, $adjust_datetimes = true ) {
976
-		$reserved = $this->reserved() - absint( $qty );
977
-		if ( $adjust_datetimes ) {
978
-			$this->_decrease_reserved_for_datetimes( $qty );
975
+	public function decrease_reserved($qty = 1, $adjust_datetimes = true) {
976
+		$reserved = $this->reserved() - absint($qty);
977
+		if ($adjust_datetimes) {
978
+			$this->_decrease_reserved_for_datetimes($qty);
979 979
 		}
980
-		$this->set_reserved( $reserved );
980
+		$this->set_reserved($reserved);
981 981
         do_action(
982 982
             'AHEE__EE_Ticket__decrease_reserved',
983 983
             $this,
@@ -995,12 +995,12 @@  discard block
 block discarded – undo
995 995
      * @return void
996 996
      * @throws \EE_Error
997 997
      */
998
-	protected function _decrease_reserved_for_datetimes( $qty = 1 ) {
998
+	protected function _decrease_reserved_for_datetimes($qty = 1) {
999 999
 		$datetimes = $this->datetimes();
1000
-		if ( is_array( $datetimes ) ) {
1001
-			foreach ( $datetimes as $datetime ) {
1002
-				if ( $datetime instanceof EE_Datetime ) {
1003
-					$datetime->decrease_reserved( $qty );
1000
+		if (is_array($datetimes)) {
1001
+			foreach ($datetimes as $datetime) {
1002
+				if ($datetime instanceof EE_Datetime) {
1003
+					$datetime->decrease_reserved($qty);
1004 1004
 					$datetime->save();
1005 1005
 				}
1006 1006
 			}
@@ -1021,14 +1021,14 @@  discard block
 block discarded – undo
1021 1021
      * @return int
1022 1022
      * @throws \EE_Error
1023 1023
      */
1024
-	public function qty( $context = '' ) {
1025
-		switch ( $context ) {
1024
+	public function qty($context = '') {
1025
+		switch ($context) {
1026 1026
 			case 'reg_limit' :
1027 1027
 				return $this->real_quantity_on_ticket();
1028 1028
 			case 'saleable' :
1029
-				return $this->real_quantity_on_ticket( 'saleable' );
1029
+				return $this->real_quantity_on_ticket('saleable');
1030 1030
 			default:
1031
-				return $this->get_raw( 'TKT_qty' );
1031
+				return $this->get_raw('TKT_qty');
1032 1032
 		}
1033 1033
 	}
1034 1034
 
@@ -1047,15 +1047,15 @@  discard block
 block discarded – undo
1047 1047
      * @return int
1048 1048
      * @throws \EE_Error
1049 1049
      */
1050
-	public function real_quantity_on_ticket( $context = 'reg_limit', $DTT_ID = 0 ) {
1051
-		$raw = $this->get_raw( 'TKT_qty' );
1050
+	public function real_quantity_on_ticket($context = 'reg_limit', $DTT_ID = 0) {
1051
+		$raw = $this->get_raw('TKT_qty');
1052 1052
 		// return immediately if it's zero
1053
-		if ( $raw === 0 ) {
1053
+		if ($raw === 0) {
1054 1054
 			return $raw;
1055 1055
 		}
1056 1056
 		//echo "\n\n<br />Ticket: " . $this->name() . '<br />';
1057 1057
 		// ensure qty doesn't exceed raw value for THIS ticket
1058
-		$qty = min( EE_INF, $raw );
1058
+		$qty = min(EE_INF, $raw);
1059 1059
 		//echo "\n . qty: " . $qty . '<br />';
1060 1060
 		// calculate this ticket's total sales and reservations
1061 1061
 		$sold_and_reserved_for_this_ticket = $this->sold() + $this->reserved();
@@ -1064,23 +1064,23 @@  discard block
 block discarded – undo
1064 1064
 		//echo "\n . sold_and_reserved_for_this_ticket: " . $sold_and_reserved_for_this_ticket . '<br />';
1065 1065
 		// first we need to calculate the maximum number of tickets available for the datetime
1066 1066
 		// do we want data for one datetime or all of them ?
1067
-		$query_params = $DTT_ID ? array( array( 'DTT_ID' => $DTT_ID ) ) : array();
1068
-		$datetimes = $this->datetimes( $query_params );
1069
-		if ( is_array( $datetimes ) && ! empty( $datetimes ) ) {
1070
-			foreach ( $datetimes as $datetime ) {
1071
-				if ( $datetime instanceof EE_Datetime ) {
1067
+		$query_params = $DTT_ID ? array(array('DTT_ID' => $DTT_ID)) : array();
1068
+		$datetimes = $this->datetimes($query_params);
1069
+		if (is_array($datetimes) && ! empty($datetimes)) {
1070
+			foreach ($datetimes as $datetime) {
1071
+				if ($datetime instanceof EE_Datetime) {
1072 1072
 					$datetime->refresh_from_db();
1073 1073
 					//echo "\n . . datetime name: " . $datetime->name() . '<br />';
1074 1074
 					//echo "\n . . datetime ID: " . $datetime->ID() . '<br />';
1075 1075
 					// initialize with no restrictions for each datetime
1076 1076
 					// but adjust datetime qty based on datetime reg limit
1077
-					$datetime_qty = min( EE_INF, $datetime->reg_limit() );
1077
+					$datetime_qty = min(EE_INF, $datetime->reg_limit());
1078 1078
 					//echo "\n . . . datetime reg_limit: " . $datetime->reg_limit() . '<br />';
1079 1079
 					//echo "\n . . . datetime_qty: " . $datetime_qty . '<br />';
1080 1080
 					// if we want the actual saleable amount, then we need to consider OTHER ticket sales
1081 1081
 					// and reservations for this datetime, that do NOT include sales and reservations
1082 1082
 					// for this ticket (so we add $this->sold() and $this->reserved() back in)
1083
-					if ( $context === 'saleable' ) {
1083
+					if ($context === 'saleable') {
1084 1084
 						$datetime_qty = max(
1085 1085
 							$datetime_qty - $datetime->sold_and_reserved() + $sold_and_reserved_for_this_ticket,
1086 1086
 							0
@@ -1092,16 +1092,16 @@  discard block
 block discarded – undo
1092 1092
 						$datetime_qty = ! $datetime->sold_out() ? $datetime_qty : 0;
1093 1093
 						//echo "\n . . . datetime_qty: " . $datetime_qty . '<br />';
1094 1094
 					}
1095
-					$qty = min( $datetime_qty, $qty );
1095
+					$qty = min($datetime_qty, $qty);
1096 1096
 					//echo "\n . . qty: " . $qty . '<br />';
1097 1097
 				}
1098 1098
 			}
1099 1099
 		}
1100 1100
 		// NOW that we know the  maximum number of tickets available for the datetime
1101 1101
 		// we can finally factor in the details for this specific ticket
1102
-		if ( $qty > 0 && $context === 'saleable' ) {
1102
+		if ($qty > 0 && $context === 'saleable') {
1103 1103
 			// and subtract the sales for THIS ticket
1104
-			$qty = max( $qty - $sold_and_reserved_for_this_ticket, 0 );
1104
+			$qty = max($qty - $sold_and_reserved_for_this_ticket, 0);
1105 1105
 			//echo "\n . qty: " . $qty . '<br />';
1106 1106
 		}
1107 1107
 		//echo "\nFINAL QTY: " . $qty . "<br /><br />";
@@ -1117,14 +1117,14 @@  discard block
 block discarded – undo
1117 1117
 	 * @return void
1118 1118
 	 * @throws \EE_Error
1119 1119
 	 */
1120
-	public function set_qty( $qty ) {
1120
+	public function set_qty($qty) {
1121 1121
 		$datetimes = $this->datetimes();
1122
-		foreach ( $datetimes as $datetime ) {
1123
-			if ( $datetime instanceof EE_Datetime ) {
1124
-				$qty = min( $qty, $datetime->reg_limit() );
1122
+		foreach ($datetimes as $datetime) {
1123
+			if ($datetime instanceof EE_Datetime) {
1124
+				$qty = min($qty, $datetime->reg_limit());
1125 1125
 			}
1126 1126
 		}
1127
-		$this->set( 'TKT_qty', $qty );
1127
+		$this->set('TKT_qty', $qty);
1128 1128
 	}
1129 1129
 
1130 1130
 
@@ -1136,7 +1136,7 @@  discard block
 block discarded – undo
1136 1136
      * @throws \EE_Error
1137 1137
      */
1138 1138
 	public function uses() {
1139
-		return $this->get( 'TKT_uses' );
1139
+		return $this->get('TKT_uses');
1140 1140
 	}
1141 1141
 
1142 1142
 
@@ -1148,8 +1148,8 @@  discard block
 block discarded – undo
1148 1148
      * @return void
1149 1149
      * @throws \EE_Error
1150 1150
      */
1151
-	public function set_uses( $uses ) {
1152
-		$this->set( 'TKT_uses', $uses );
1151
+	public function set_uses($uses) {
1152
+		$this->set('TKT_uses', $uses);
1153 1153
 	}
1154 1154
 
1155 1155
 
@@ -1161,7 +1161,7 @@  discard block
 block discarded – undo
1161 1161
      * @throws \EE_Error
1162 1162
      */
1163 1163
 	public function required() {
1164
-		return $this->get( 'TKT_required' );
1164
+		return $this->get('TKT_required');
1165 1165
 	}
1166 1166
 
1167 1167
 
@@ -1173,8 +1173,8 @@  discard block
 block discarded – undo
1173 1173
      * @return void
1174 1174
      * @throws \EE_Error
1175 1175
      */
1176
-	public function set_required( $required ) {
1177
-		$this->set( 'TKT_required', $required );
1176
+	public function set_required($required) {
1177
+		$this->set('TKT_required', $required);
1178 1178
 	}
1179 1179
 
1180 1180
 
@@ -1186,7 +1186,7 @@  discard block
 block discarded – undo
1186 1186
      * @throws \EE_Error
1187 1187
      */
1188 1188
 	public function taxable() {
1189
-		return $this->get( 'TKT_taxable' );
1189
+		return $this->get('TKT_taxable');
1190 1190
 	}
1191 1191
 
1192 1192
 
@@ -1198,8 +1198,8 @@  discard block
 block discarded – undo
1198 1198
      * @return void
1199 1199
      * @throws \EE_Error
1200 1200
      */
1201
-	public function set_taxable( $taxable ) {
1202
-		$this->set( 'TKT_taxable', $taxable );
1201
+	public function set_taxable($taxable) {
1202
+		$this->set('TKT_taxable', $taxable);
1203 1203
 	}
1204 1204
 
1205 1205
 
@@ -1211,7 +1211,7 @@  discard block
 block discarded – undo
1211 1211
      * @throws \EE_Error
1212 1212
      */
1213 1213
 	public function is_default() {
1214
-		return $this->get( 'TKT_is_default' );
1214
+		return $this->get('TKT_is_default');
1215 1215
 	}
1216 1216
 
1217 1217
 
@@ -1223,8 +1223,8 @@  discard block
 block discarded – undo
1223 1223
      * @return void
1224 1224
      * @throws \EE_Error
1225 1225
      */
1226
-	public function set_is_default( $is_default ) {
1227
-		$this->set( 'TKT_is_default', $is_default );
1226
+	public function set_is_default($is_default) {
1227
+		$this->set('TKT_is_default', $is_default);
1228 1228
 	}
1229 1229
 
1230 1230
 
@@ -1236,7 +1236,7 @@  discard block
 block discarded – undo
1236 1236
      * @throws \EE_Error
1237 1237
      */
1238 1238
 	public function order() {
1239
-		return $this->get( 'TKT_order' );
1239
+		return $this->get('TKT_order');
1240 1240
 	}
1241 1241
 
1242 1242
 
@@ -1248,8 +1248,8 @@  discard block
 block discarded – undo
1248 1248
      * @return void
1249 1249
      * @throws \EE_Error
1250 1250
      */
1251
-	public function set_order( $order ) {
1252
-		$this->set( 'TKT_order', $order );
1251
+	public function set_order($order) {
1252
+		$this->set('TKT_order', $order);
1253 1253
 	}
1254 1254
 
1255 1255
 
@@ -1261,7 +1261,7 @@  discard block
 block discarded – undo
1261 1261
      * @throws \EE_Error
1262 1262
      */
1263 1263
 	public function row() {
1264
-		return $this->get( 'TKT_row' );
1264
+		return $this->get('TKT_row');
1265 1265
 	}
1266 1266
 
1267 1267
 
@@ -1273,8 +1273,8 @@  discard block
 block discarded – undo
1273 1273
      * @return void
1274 1274
      * @throws \EE_Error
1275 1275
      */
1276
-	public function set_row( $row ) {
1277
-		$this->set( 'TKT_row', $row );
1276
+	public function set_row($row) {
1277
+		$this->set('TKT_row', $row);
1278 1278
 	}
1279 1279
 
1280 1280
 
@@ -1286,7 +1286,7 @@  discard block
 block discarded – undo
1286 1286
      * @throws \EE_Error
1287 1287
      */
1288 1288
 	public function deleted() {
1289
-		return $this->get( 'TKT_deleted' );
1289
+		return $this->get('TKT_deleted');
1290 1290
 	}
1291 1291
 
1292 1292
 
@@ -1298,8 +1298,8 @@  discard block
 block discarded – undo
1298 1298
      * @return void
1299 1299
      * @throws \EE_Error
1300 1300
      */
1301
-	public function set_deleted( $deleted ) {
1302
-		$this->set( 'TKT_deleted', $deleted );
1301
+	public function set_deleted($deleted) {
1302
+		$this->set('TKT_deleted', $deleted);
1303 1303
 	}
1304 1304
 
1305 1305
 
@@ -1311,7 +1311,7 @@  discard block
 block discarded – undo
1311 1311
      * @throws \EE_Error
1312 1312
      */
1313 1313
 	public function parent_ID() {
1314
-		return $this->get( 'TKT_parent' );
1314
+		return $this->get('TKT_parent');
1315 1315
 	}
1316 1316
 
1317 1317
 
@@ -1323,8 +1323,8 @@  discard block
 block discarded – undo
1323 1323
      * @return void
1324 1324
      * @throws \EE_Error
1325 1325
      */
1326
-	public function set_parent_ID( $parent ) {
1327
-		$this->set( 'TKT_parent', $parent );
1326
+	public function set_parent_ID($parent) {
1327
+		$this->set('TKT_parent', $parent);
1328 1328
 	}
1329 1329
 
1330 1330
 
@@ -1337,10 +1337,10 @@  discard block
 block discarded – undo
1337 1337
      */
1338 1338
 	public function name_and_info() {
1339 1339
 		$times = array();
1340
-		foreach ( $this->datetimes() as $datetime ) {
1340
+		foreach ($this->datetimes() as $datetime) {
1341 1341
 			$times[] = $datetime->start_date_and_time();
1342 1342
 		}
1343
-		return $this->name() . ' @ ' . implode( ', ', $times ) . ' for ' . $this->pretty_price();
1343
+		return $this->name().' @ '.implode(', ', $times).' for '.$this->pretty_price();
1344 1344
 	}
1345 1345
 
1346 1346
 
@@ -1352,7 +1352,7 @@  discard block
 block discarded – undo
1352 1352
      * @throws \EE_Error
1353 1353
      */
1354 1354
 	public function name() {
1355
-		return $this->get( 'TKT_name' );
1355
+		return $this->get('TKT_name');
1356 1356
 	}
1357 1357
 
1358 1358
 
@@ -1364,7 +1364,7 @@  discard block
 block discarded – undo
1364 1364
      * @throws \EE_Error
1365 1365
      */
1366 1366
 	public function price() {
1367
-		return $this->get( 'TKT_price' );
1367
+		return $this->get('TKT_price');
1368 1368
 	}
1369 1369
 
1370 1370
 
@@ -1376,8 +1376,8 @@  discard block
 block discarded – undo
1376 1376
      * @return EE_Registration[]|EE_Base_Class[]
1377 1377
      * @throws \EE_Error
1378 1378
      */
1379
-	public function registrations( $query_params = array() ) {
1380
-		return $this->get_many_related( 'Registration', $query_params );
1379
+	public function registrations($query_params = array()) {
1380
+		return $this->get_many_related('Registration', $query_params);
1381 1381
 	}
1382 1382
 
1383 1383
 
@@ -1416,7 +1416,7 @@  discard block
 block discarded – undo
1416 1416
 	 * @param array $query_params like EEM_Base::get_all's
1417 1417
 	 * @return int
1418 1418
 	 */
1419
-	public function count_registrations( $query_params = array() ) {
1419
+	public function count_registrations($query_params = array()) {
1420 1420
 		return $this->count_related('Registration', $query_params);
1421 1421
 	}
1422 1422
 
@@ -1444,23 +1444,23 @@  discard block
 block discarded – undo
1444 1444
 	public function get_related_event() {
1445 1445
 		//get one datetime to use for getting the event
1446 1446
 		$datetime = $this->first_datetime();
1447
-		if ( ! $datetime instanceof \EE_Datetime ) {
1447
+		if ( ! $datetime instanceof \EE_Datetime) {
1448 1448
 			throw new UnexpectedEntityException(
1449 1449
 				$datetime,
1450 1450
                 'EE_Datetime',
1451 1451
 				sprintf(
1452
-					__( 'The ticket (%s) is not associated with any valid datetimes.', 'event_espresso'),
1452
+					__('The ticket (%s) is not associated with any valid datetimes.', 'event_espresso'),
1453 1453
 					$this->name()
1454 1454
 				)
1455 1455
 			);
1456 1456
 		}
1457 1457
 		$event = $datetime->event();
1458
-		if ( ! $event instanceof \EE_Event ) {
1458
+		if ( ! $event instanceof \EE_Event) {
1459 1459
 			throw new UnexpectedEntityException(
1460 1460
 				$event,
1461 1461
                 'EE_Event',
1462 1462
 				sprintf(
1463
-					__( 'The ticket (%s) is not associated with a valid event.', 'event_espresso'),
1463
+					__('The ticket (%s) is not associated with a valid event.', 'event_espresso'),
1464 1464
 					$this->name()
1465 1465
 				)
1466 1466
 			);
Please login to merge, or discard this patch.
core/domain/values/currency/UsesMoneyInterface.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -17,29 +17,29 @@
 block discarded – undo
17 17
 interface UsesMoneyInterface
18 18
 {
19 19
 
20
-    /**
21
-     * Gets a Money object for the specified field. Please note that this should only be
22
-     * used for fields corresponding to EE_Money_Fields, and it will always return a money object,
23
-     * or else it will throw an exception.
24
-     *
25
-     * @param $field_name
26
-     * @return Money
27
-     */
28
-    public function getMoneyObject($field_name);
29
-
30
-    /**
31
-     * Returns the payment's amount in subunits (and if the currency has no subunits, then it will be in the main units)
32
-     *
33
-     * @return int
34
-     */
35
-    public function amountInSubunits();
36
-
37
-    /**
38
-     * Sets the payment's amount based on the incoming monetary subunits (eg pennies). If the currency has no subunits,
39
-     * the amount is actually assumed to be in the currency's main units
40
-     *
41
-     * @param int $amount_in_subunits
42
-     * @return void
43
-     */
44
-    public function setAmountInSubunits($amount_in_subunits);
20
+	/**
21
+	 * Gets a Money object for the specified field. Please note that this should only be
22
+	 * used for fields corresponding to EE_Money_Fields, and it will always return a money object,
23
+	 * or else it will throw an exception.
24
+	 *
25
+	 * @param $field_name
26
+	 * @return Money
27
+	 */
28
+	public function getMoneyObject($field_name);
29
+
30
+	/**
31
+	 * Returns the payment's amount in subunits (and if the currency has no subunits, then it will be in the main units)
32
+	 *
33
+	 * @return int
34
+	 */
35
+	public function amountInSubunits();
36
+
37
+	/**
38
+	 * Sets the payment's amount based on the incoming monetary subunits (eg pennies). If the currency has no subunits,
39
+	 * the amount is actually assumed to be in the currency's main units
40
+	 *
41
+	 * @param int $amount_in_subunits
42
+	 * @return void
43
+	 */
44
+	public function setAmountInSubunits($amount_in_subunits);
45 45
 }
Please login to merge, or discard this patch.
core/EE_System.core.php 2 patches
Indentation   +1251 added lines, -1251 removed lines patch added patch discarded remove patch
@@ -21,1257 +21,1257 @@
 block discarded – undo
21 21
 {
22 22
 
23 23
 
24
-    /**
25
-     * indicates this is a 'normal' request. Ie, not activation, nor upgrade, nor activation.
26
-     * So examples of this would be a normal GET request on the frontend or backend, or a POST, etc
27
-     */
28
-    const req_type_normal = 0;
29
-
30
-    /**
31
-     * Indicates this is a brand new installation of EE so we should install
32
-     * tables and default data etc
33
-     */
34
-    const req_type_new_activation = 1;
35
-
36
-    /**
37
-     * we've detected that EE has been reactivated (or EE was activated during maintenance mode,
38
-     * and we just exited maintenance mode). We MUST check the database is setup properly
39
-     * and that default data is setup too
40
-     */
41
-    const req_type_reactivation = 2;
42
-
43
-    /**
44
-     * indicates that EE has been upgraded since its previous request.
45
-     * We may have data migration scripts to call and will want to trigger maintenance mode
46
-     */
47
-    const req_type_upgrade = 3;
48
-
49
-    /**
50
-     * TODO  will detect that EE has been DOWNGRADED. We probably don't want to run in this case...
51
-     */
52
-    const req_type_downgrade = 4;
53
-
54
-    /**
55
-     * @deprecated since version 4.6.0.dev.006
56
-     * Now whenever a new_activation is detected the request type is still just
57
-     * new_activation (same for reactivation, upgrade, downgrade etc), but if we'r ein maintenance mode
58
-     * EE_System::initialize_db_if_no_migrations_required and EE_Addon::initialize_db_if_no_migrations_required
59
-     * will instead enqueue that EE plugin's db initialization for when we're taken out of maintenance mode.
60
-     * (Specifically, when the migration manager indicates migrations are finished
61
-     * EE_Data_Migration_Manager::initialize_db_for_enqueued_ee_plugins() will be called)
62
-     */
63
-    const req_type_activation_but_not_installed = 5;
64
-
65
-    /**
66
-     * option prefix for recording the activation history (like core's "espresso_db_update") of addons
67
-     */
68
-    const addon_activation_history_option_prefix = 'ee_addon_activation_history_';
69
-
70
-
71
-    /**
72
-     * @var EE_System $_instance
73
-     */
74
-    private static $_instance;
75
-
76
-    /**
77
-     * @var EE_Registry $registry
78
-     */
79
-    private $registry;
80
-
81
-    /**
82
-     * @var LoaderInterface $loader
83
-     */
84
-    private $loader;
85
-
86
-    /**
87
-     * @var EE_Capabilities $capabilities
88
-     */
89
-    private $capabilities;
90
-
91
-    /**
92
-     * @var EE_Request $request
93
-     */
94
-    private $request;
95
-
96
-    /**
97
-     * @var EE_Maintenance_Mode $maintenance_mode
98
-     */
99
-    private $maintenance_mode;
100
-
101
-    /**
102
-     * Stores which type of request this is, options being one of the constants on EE_System starting with req_type_*.
103
-     * It can be a brand-new activation, a reactivation, an upgrade, a downgrade, or a normal request.
104
-     *
105
-     * @var int $_req_type
106
-     */
107
-    private $_req_type;
108
-
109
-    /**
110
-     * Whether or not there was a non-micro version change in EE core version during this request
111
-     *
112
-     * @var boolean $_major_version_change
113
-     */
114
-    private $_major_version_change = false;
115
-
116
-
117
-
118
-    /**
119
-     * @singleton method used to instantiate class object
120
-     * @param EE_Registry|null         $registry
121
-     * @param LoaderInterface|null     $loader
122
-     * @param EE_Capabilities|null     $capabilities
123
-     * @param EE_Request|null          $request
124
-     * @param EE_Maintenance_Mode|null $maintenance_mode
125
-     * @return EE_System
126
-     */
127
-    public static function instance(
128
-        EE_Registry $registry = null,
129
-        LoaderInterface $loader = null,
130
-        EE_Capabilities $capabilities = null,
131
-        EE_Request $request = null,
132
-        EE_Maintenance_Mode $maintenance_mode = null
133
-    ) {
134
-        // check if class object is instantiated
135
-        if (! self::$_instance instanceof EE_System) {
136
-            self::$_instance = new self($registry, $loader, $capabilities, $request, $maintenance_mode);
137
-        }
138
-        return self::$_instance;
139
-    }
140
-
141
-
142
-
143
-    /**
144
-     * resets the instance and returns it
145
-     *
146
-     * @return EE_System
147
-     */
148
-    public static function reset()
149
-    {
150
-        self::$_instance->_req_type = null;
151
-        //make sure none of the old hooks are left hanging around
152
-        remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations');
153
-        //we need to reset the migration manager in order for it to detect DMSs properly
154
-        EE_Data_Migration_Manager::reset();
155
-        self::instance()->detect_activations_or_upgrades();
156
-        self::instance()->perform_activations_upgrades_and_migrations();
157
-        return self::instance();
158
-    }
159
-
160
-
161
-
162
-    /**
163
-     * sets hooks for running rest of system
164
-     * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point
165
-     * starting EE Addons from any other point may lead to problems
166
-     *
167
-     * @param EE_Registry         $registry
168
-     * @param LoaderInterface     $loader
169
-     * @param EE_Capabilities     $capabilities
170
-     * @param EE_Request          $request
171
-     * @param EE_Maintenance_Mode $maintenance_mode
172
-     */
173
-    private function __construct(
174
-        EE_Registry $registry,
175
-        LoaderInterface $loader,
176
-        EE_Capabilities $capabilities,
177
-        EE_Request $request,
178
-        EE_Maintenance_Mode $maintenance_mode
179
-    ) {
180
-        $this->registry = $registry;
181
-        $this->loader = $loader;
182
-        $this->capabilities = $capabilities;
183
-        $this->request = $request;
184
-        $this->maintenance_mode = $maintenance_mode;
185
-        do_action('AHEE__EE_System__construct__begin', $this);
186
-        add_action(
187
-            'AHEE__EE_Bootstrap__load_espresso_addons',
188
-            array($this, 'loadCapabilities'),
189
-            5
190
-        );
191
-        add_action(
192
-            'AHEE__EE_Bootstrap__load_espresso_addons',
193
-            array($this, 'loadCommandBus'),
194
-            7
195
-        );
196
-        add_action(
197
-            'AHEE__EE_Bootstrap__load_espresso_addons',
198
-            array($this, 'loadPluginApi'),
199
-            9
200
-        );
201
-        // allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc
202
-        add_action(
203
-            'AHEE__EE_Bootstrap__load_espresso_addons',
204
-            array($this, 'load_espresso_addons')
205
-        );
206
-        // when an ee addon is activated, we want to call the core hook(s) again
207
-        // because the newly-activated addon didn't get a chance to run at all
208
-        add_action('activate_plugin', array($this, 'load_espresso_addons'), 1);
209
-        // detect whether install or upgrade
210
-        add_action(
211
-            'AHEE__EE_Bootstrap__detect_activations_or_upgrades',
212
-            array($this, 'detect_activations_or_upgrades'),
213
-            3
214
-        );
215
-        // load EE_Config, EE_Textdomain, etc
216
-        add_action(
217
-            'AHEE__EE_Bootstrap__load_core_configuration',
218
-            array($this, 'load_core_configuration'),
219
-            5
220
-        );
221
-        // load EE_Config, EE_Textdomain, etc
222
-        add_action(
223
-            'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets',
224
-            array($this, 'register_shortcodes_modules_and_widgets'),
225
-            7
226
-        );
227
-        // you wanna get going? I wanna get going... let's get going!
228
-        add_action(
229
-            'AHEE__EE_Bootstrap__brew_espresso',
230
-            array($this, 'brew_espresso'),
231
-            9
232
-        );
233
-        //other housekeeping
234
-        //exclude EE critical pages from wp_list_pages
235
-        add_filter(
236
-            'wp_list_pages_excludes',
237
-            array($this, 'remove_pages_from_wp_list_pages'),
238
-            10
239
-        );
240
-        // ALL EE Addons should use the following hook point to attach their initial setup too
241
-        // it's extremely important for EE Addons to register any class autoloaders so that they can be available when the EE_Config loads
242
-        do_action('AHEE__EE_System__construct__complete', $this);
243
-    }
244
-
245
-
246
-
247
-    /**
248
-     * load and setup EE_Capabilities
249
-     *
250
-     * @return void
251
-     * @throws EE_Error
252
-     */
253
-    public function loadCapabilities()
254
-    {
255
-        $this->loader->getShared('EE_Capabilities');
256
-        add_action(
257
-            'AHEE__EE_Capabilities__init_caps__before_initialization',
258
-            function() {
259
-                LoaderFactory::getLoader()->getShared('EE_Payment_Method_Manager');
260
-            }
261
-        );
262
-    }
263
-
264
-
265
-
266
-    /**
267
-     * create and cache the CommandBus, and also add middleware
268
-     * The CapChecker middleware requires the use of EE_Capabilities
269
-     * which is why we need to load the CommandBus after Caps are set up
270
-     *
271
-     * @return void
272
-     * @throws EE_Error
273
-     */
274
-    public function loadCommandBus()
275
-    {
276
-        $this->loader->getShared(
277
-            'CommandBusInterface',
278
-            array(
279
-                null,
280
-                apply_filters(
281
-                    'FHEE__EE_Load_Espresso_Core__handle_request__CommandBus_middleware',
282
-                    array(
283
-                        $this->loader->getShared('EventEspresso\core\services\commands\middleware\CapChecker'),
284
-                        $this->loader->getShared('EventEspresso\core\services\commands\middleware\AddActionHook'),
285
-                    )
286
-                ),
287
-            )
288
-        );
289
-    }
290
-
291
-
292
-
293
-    /**
294
-     * @return void
295
-     * @throws EE_Error
296
-     */
297
-    public function loadPluginApi()
298
-    {
299
-        // set autoloaders for all of the classes implementing EEI_Plugin_API
300
-        // which provide helpers for EE plugin authors to more easily register certain components with EE.
301
-        EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api');
302
-    }
303
-
304
-
305
-    /**
306
-     * @param string $addon_name
307
-     * @param string $version_constant
308
-     * @param string $min_version_required
309
-     * @param string $load_callback
310
-     * @param string $plugin_file_constant
311
-     * @return void
312
-     */
313
-    private function deactivateIncompatibleAddon(
314
-        $addon_name,
315
-        $version_constant,
316
-        $min_version_required,
317
-        $load_callback,
318
-        $plugin_file_constant
319
-    ) {
320
-        if (! defined($version_constant)) {
321
-            return;
322
-        }
323
-        $addon_version = constant($version_constant);
324
-        if ($addon_version && version_compare($addon_version, $min_version_required, '<')) {
325
-            remove_action('AHEE__EE_System__load_espresso_addons', $load_callback);
326
-            if (! function_exists('deactivate_plugins')) {
327
-                require_once ABSPATH . 'wp-admin/includes/plugin.php';
328
-            }
329
-            deactivate_plugins(plugin_basename(constant($plugin_file_constant)));
330
-            unset($_GET['activate'], $_REQUEST['activate'], $_GET['activate-multi'], $_REQUEST['activate-multi']);
331
-            EE_Error::add_error(
332
-                sprintf(
333
-                    esc_html__(
334
-                        'We\'re sorry, but the Event Espresso %1$s addon was deactivated because version %2$s or higher is required with this version of Event Espresso core.',
335
-                        'event_espresso'
336
-                    ),
337
-                    $addon_name,
338
-                    $min_version_required
339
-                ),
340
-                __FILE__, __FUNCTION__ . "({$addon_name})", __LINE__
341
-            );
342
-            EE_Error::get_notices(false, true);
343
-        }
344
-    }
345
-
346
-
347
-    /**
348
-     * load_espresso_addons
349
-     * allow addons to load first so that they can set hooks for running DMS's, etc
350
-     * this is hooked into both:
351
-     *    'AHEE__EE_Bootstrap__load_core_configuration'
352
-     *        which runs during the WP 'plugins_loaded' action at priority 5
353
-     *    and the WP 'activate_plugin' hook point
354
-     *
355
-     * @access public
356
-     * @return void
357
-     */
358
-    public function load_espresso_addons()
359
-    {
360
-        $this->deactivateIncompatibleAddon(
361
-            'Wait Lists',
362
-            'EE_WAIT_LISTS_VERSION',
363
-            '1.0.0.rc.074',
364
-            'load_espresso_wait_lists',
365
-            'EE_WAIT_LISTS_PLUGIN_FILE'
366
-        );
367
-        $this->deactivateIncompatibleAddon(
368
-            'Automated Upcoming Event Notifications',
369
-            'EE_AUTOMATED_UPCOMING_EVENT_NOTIFICATION_VERSION',
370
-            '1.0.0.rc.091',
371
-            'load_espresso_automated_upcoming_event_notification',
372
-            'EE_AUTOMATED_UPCOMING_EVENT_NOTIFICATION_PLUGIN_FILE'
373
-        );
374
-        do_action('AHEE__EE_System__load_espresso_addons');
375
-        //if the WP API basic auth plugin isn't already loaded, load it now.
376
-        //We want it for mobile apps. Just include the entire plugin
377
-        //also, don't load the basic auth when a plugin is getting activated, because
378
-        //it could be the basic auth plugin, and it doesn't check if its methods are already defined
379
-        //and causes a fatal error
380
-        if (
381
-            ! (
382
-                isset($_GET['activate'])
383
-                && $_GET['activate'] === 'true'
384
-            )
385
-            && ! function_exists('json_basic_auth_handler')
386
-            && ! function_exists('json_basic_auth_error')
387
-            && ! (
388
-                isset($_GET['action'])
389
-                && in_array($_GET['action'], array('activate', 'activate-selected'), true)
390
-            )
391
-        ) {
392
-            include_once EE_THIRD_PARTY . 'wp-api-basic-auth' . DS . 'basic-auth.php';
393
-        }
394
-        do_action('AHEE__EE_System__load_espresso_addons__complete');
395
-    }
396
-
397
-
398
-
399
-    /**
400
-     * detect_activations_or_upgrades
401
-     * Checks for activation or upgrade of core first;
402
-     * then also checks if any registered addons have been activated or upgraded
403
-     * This is hooked into 'AHEE__EE_Bootstrap__detect_activations_or_upgrades'
404
-     * which runs during the WP 'plugins_loaded' action at priority 3
405
-     *
406
-     * @access public
407
-     * @return void
408
-     */
409
-    public function detect_activations_or_upgrades()
410
-    {
411
-        //first off: let's make sure to handle core
412
-        $this->detect_if_activation_or_upgrade();
413
-        foreach ($this->registry->addons as $addon) {
414
-            if ($addon instanceof EE_Addon) {
415
-                //detect teh request type for that addon
416
-                $addon->detect_activation_or_upgrade();
417
-            }
418
-        }
419
-    }
420
-
421
-
422
-
423
-    /**
424
-     * detect_if_activation_or_upgrade
425
-     * Takes care of detecting whether this is a brand new install or code upgrade,
426
-     * and either setting up the DB or setting up maintenance mode etc.
427
-     *
428
-     * @access public
429
-     * @return void
430
-     */
431
-    public function detect_if_activation_or_upgrade()
432
-    {
433
-        do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin');
434
-        // check if db has been updated, or if its a brand-new installation
435
-        $espresso_db_update = $this->fix_espresso_db_upgrade_option();
436
-        $request_type = $this->detect_req_type($espresso_db_update);
437
-        //EEH_Debug_Tools::printr( $request_type, '$request_type', __FILE__, __LINE__ );
438
-        switch ($request_type) {
439
-            case EE_System::req_type_new_activation:
440
-                do_action('AHEE__EE_System__detect_if_activation_or_upgrade__new_activation');
441
-                $this->_handle_core_version_change($espresso_db_update);
442
-                break;
443
-            case EE_System::req_type_reactivation:
444
-                do_action('AHEE__EE_System__detect_if_activation_or_upgrade__reactivation');
445
-                $this->_handle_core_version_change($espresso_db_update);
446
-                break;
447
-            case EE_System::req_type_upgrade:
448
-                do_action('AHEE__EE_System__detect_if_activation_or_upgrade__upgrade');
449
-                //migrations may be required now that we've upgraded
450
-                $this->maintenance_mode->set_maintenance_mode_if_db_old();
451
-                $this->_handle_core_version_change($espresso_db_update);
452
-                //				echo "done upgrade";die;
453
-                break;
454
-            case EE_System::req_type_downgrade:
455
-                do_action('AHEE__EE_System__detect_if_activation_or_upgrade__downgrade');
456
-                //its possible migrations are no longer required
457
-                $this->maintenance_mode->set_maintenance_mode_if_db_old();
458
-                $this->_handle_core_version_change($espresso_db_update);
459
-                break;
460
-            case EE_System::req_type_normal:
461
-            default:
462
-                //				$this->_maybe_redirect_to_ee_about();
463
-                break;
464
-        }
465
-        do_action('AHEE__EE_System__detect_if_activation_or_upgrade__complete');
466
-    }
467
-
468
-
469
-
470
-    /**
471
-     * Updates the list of installed versions and sets hooks for
472
-     * initializing the database later during the request
473
-     *
474
-     * @param array $espresso_db_update
475
-     */
476
-    private function _handle_core_version_change($espresso_db_update)
477
-    {
478
-        $this->update_list_of_installed_versions($espresso_db_update);
479
-        //get ready to verify the DB is ok (provided we aren't in maintenance mode, of course)
480
-        add_action(
481
-            'AHEE__EE_System__perform_activations_upgrades_and_migrations',
482
-            array($this, 'initialize_db_if_no_migrations_required')
483
-        );
484
-    }
485
-
486
-
487
-
488
-    /**
489
-     * standardizes the wp option 'espresso_db_upgrade' which actually stores
490
-     * information about what versions of EE have been installed and activated,
491
-     * NOT necessarily the state of the database
492
-     *
493
-     * @param mixed $espresso_db_update the value of the WordPress option.
494
-     *                                            If not supplied, fetches it from the options table
495
-     * @return array the correct value of 'espresso_db_upgrade', after saving it, if it needed correction
496
-     */
497
-    private function fix_espresso_db_upgrade_option($espresso_db_update = null)
498
-    {
499
-        do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update);
500
-        if (! $espresso_db_update) {
501
-            $espresso_db_update = get_option('espresso_db_update');
502
-        }
503
-        // check that option is an array
504
-        if (! is_array($espresso_db_update)) {
505
-            // if option is FALSE, then it never existed
506
-            if ($espresso_db_update === false) {
507
-                // make $espresso_db_update an array and save option with autoload OFF
508
-                $espresso_db_update = array();
509
-                add_option('espresso_db_update', $espresso_db_update, '', 'no');
510
-            } else {
511
-                // option is NOT FALSE but also is NOT an array, so make it an array and save it
512
-                $espresso_db_update = array($espresso_db_update => array());
513
-                update_option('espresso_db_update', $espresso_db_update);
514
-            }
515
-        } else {
516
-            $corrected_db_update = array();
517
-            //if IS an array, but is it an array where KEYS are version numbers, and values are arrays?
518
-            foreach ($espresso_db_update as $should_be_version_string => $should_be_array) {
519
-                if (is_int($should_be_version_string) && ! is_array($should_be_array)) {
520
-                    //the key is an int, and the value IS NOT an array
521
-                    //so it must be numerically-indexed, where values are versions installed...
522
-                    //fix it!
523
-                    $version_string = $should_be_array;
524
-                    $corrected_db_update[$version_string] = array('unknown-date');
525
-                } else {
526
-                    //ok it checks out
527
-                    $corrected_db_update[$should_be_version_string] = $should_be_array;
528
-                }
529
-            }
530
-            $espresso_db_update = $corrected_db_update;
531
-            update_option('espresso_db_update', $espresso_db_update);
532
-        }
533
-        do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update);
534
-        return $espresso_db_update;
535
-    }
536
-
537
-
538
-
539
-    /**
540
-     * Does the traditional work of setting up the plugin's database and adding default data.
541
-     * If migration script/process did not exist, this is what would happen on every activation/reactivation/upgrade.
542
-     * NOTE: if we're in maintenance mode (which would be the case if we detect there are data
543
-     * migration scripts that need to be run and a version change happens), enqueues core for database initialization,
544
-     * so that it will be done when migrations are finished
545
-     *
546
-     * @param boolean $initialize_addons_too if true, we double-check addons' database tables etc too;
547
-     * @param boolean $verify_schema         if true will re-check the database tables have the correct schema.
548
-     *                                       This is a resource-intensive job
549
-     *                                       so we prefer to only do it when necessary
550
-     * @return void
551
-     * @throws EE_Error
552
-     */
553
-    public function initialize_db_if_no_migrations_required($initialize_addons_too = false, $verify_schema = true)
554
-    {
555
-        $request_type = $this->detect_req_type();
556
-        //only initialize system if we're not in maintenance mode.
557
-        if ($this->maintenance_mode->level() !== EE_Maintenance_Mode::level_2_complete_maintenance) {
558
-            update_option('ee_flush_rewrite_rules', true);
559
-            if ($verify_schema) {
560
-                EEH_Activation::initialize_db_and_folders();
561
-            }
562
-            EEH_Activation::initialize_db_content();
563
-            EEH_Activation::system_initialization();
564
-            if ($initialize_addons_too) {
565
-                $this->initialize_addons();
566
-            }
567
-        } else {
568
-            EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for('Core');
569
-        }
570
-        if ($request_type === EE_System::req_type_new_activation
571
-            || $request_type === EE_System::req_type_reactivation
572
-            || (
573
-                $request_type === EE_System::req_type_upgrade
574
-                && $this->is_major_version_change()
575
-            )
576
-        ) {
577
-            add_action('AHEE__EE_System__initialize_last', array($this, 'redirect_to_about_ee'), 9);
578
-        }
579
-    }
580
-
581
-
582
-
583
-    /**
584
-     * Initializes the db for all registered addons
585
-     *
586
-     * @throws EE_Error
587
-     */
588
-    public function initialize_addons()
589
-    {
590
-        //foreach registered addon, make sure its db is up-to-date too
591
-        foreach ($this->registry->addons as $addon) {
592
-            if ($addon instanceof EE_Addon) {
593
-                $addon->initialize_db_if_no_migrations_required();
594
-            }
595
-        }
596
-    }
597
-
598
-
599
-
600
-    /**
601
-     * Adds the current code version to the saved wp option which stores a list of all ee versions ever installed.
602
-     *
603
-     * @param    array  $version_history
604
-     * @param    string $current_version_to_add version to be added to the version history
605
-     * @return    boolean success as to whether or not this option was changed
606
-     */
607
-    public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null)
608
-    {
609
-        if (! $version_history) {
610
-            $version_history = $this->fix_espresso_db_upgrade_option($version_history);
611
-        }
612
-        if ($current_version_to_add === null) {
613
-            $current_version_to_add = espresso_version();
614
-        }
615
-        $version_history[$current_version_to_add][] = date('Y-m-d H:i:s', time());
616
-        // re-save
617
-        return update_option('espresso_db_update', $version_history);
618
-    }
619
-
620
-
621
-
622
-    /**
623
-     * Detects if the current version indicated in the has existed in the list of
624
-     * previously-installed versions of EE (espresso_db_update). Does NOT modify it (ie, no side-effect)
625
-     *
626
-     * @param array $espresso_db_update array from the wp option stored under the name 'espresso_db_update'.
627
-     *                                  If not supplied, fetches it from the options table.
628
-     *                                  Also, caches its result so later parts of the code can also know whether
629
-     *                                  there's been an update or not. This way we can add the current version to
630
-     *                                  espresso_db_update, but still know if this is a new install or not
631
-     * @return int one of the constants on EE_System::req_type_
632
-     */
633
-    public function detect_req_type($espresso_db_update = null)
634
-    {
635
-        if ($this->_req_type === null) {
636
-            $espresso_db_update = ! empty($espresso_db_update)
637
-                ? $espresso_db_update
638
-                : $this->fix_espresso_db_upgrade_option();
639
-            $this->_req_type = EE_System::detect_req_type_given_activation_history(
640
-                $espresso_db_update,
641
-                'ee_espresso_activation', espresso_version()
642
-            );
643
-            $this->_major_version_change = $this->_detect_major_version_change($espresso_db_update);
644
-        }
645
-        return $this->_req_type;
646
-    }
647
-
648
-
649
-
650
-    /**
651
-     * Returns whether or not there was a non-micro version change (ie, change in either
652
-     * the first or second number in the version. Eg 4.9.0.rc.001 to 4.10.0.rc.000,
653
-     * but not 4.9.0.rc.0001 to 4.9.1.rc.0001
654
-     *
655
-     * @param $activation_history
656
-     * @return bool
657
-     */
658
-    private function _detect_major_version_change($activation_history)
659
-    {
660
-        $previous_version = EE_System::_get_most_recently_active_version_from_activation_history($activation_history);
661
-        $previous_version_parts = explode('.', $previous_version);
662
-        $current_version_parts = explode('.', espresso_version());
663
-        return isset($previous_version_parts[0], $previous_version_parts[1], $current_version_parts[0], $current_version_parts[1])
664
-               && ($previous_version_parts[0] !== $current_version_parts[0]
665
-                   || $previous_version_parts[1] !== $current_version_parts[1]
666
-               );
667
-    }
668
-
669
-
670
-
671
-    /**
672
-     * Returns true if either the major or minor version of EE changed during this request.
673
-     * Eg 4.9.0.rc.001 to 4.10.0.rc.000, but not 4.9.0.rc.0001 to 4.9.1.rc.0001
674
-     *
675
-     * @return bool
676
-     */
677
-    public function is_major_version_change()
678
-    {
679
-        return $this->_major_version_change;
680
-    }
681
-
682
-
683
-
684
-    /**
685
-     * Determines the request type for any ee addon, given three piece of info: the current array of activation
686
-     * histories (for core that' 'espresso_db_update' wp option); the name of the WordPress option which is temporarily
687
-     * set upon activation of the plugin (for core it's 'ee_espresso_activation'); and the version that this plugin was
688
-     * just activated to (for core that will always be espresso_version())
689
-     *
690
-     * @param array  $activation_history_for_addon     the option's value which stores the activation history for this
691
-     *                                                 ee plugin. for core that's 'espresso_db_update'
692
-     * @param string $activation_indicator_option_name the name of the WordPress option that is temporarily set to
693
-     *                                                 indicate that this plugin was just activated
694
-     * @param string $version_to_upgrade_to            the version that was just upgraded to (for core that will be
695
-     *                                                 espresso_version())
696
-     * @return int one of the constants on EE_System::req_type_*
697
-     */
698
-    public static function detect_req_type_given_activation_history(
699
-        $activation_history_for_addon,
700
-        $activation_indicator_option_name,
701
-        $version_to_upgrade_to
702
-    ) {
703
-        $version_is_higher = self::_new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to);
704
-        if ($activation_history_for_addon) {
705
-            //it exists, so this isn't a completely new install
706
-            //check if this version already in that list of previously installed versions
707
-            if (! isset($activation_history_for_addon[$version_to_upgrade_to])) {
708
-                //it a version we haven't seen before
709
-                if ($version_is_higher === 1) {
710
-                    $req_type = EE_System::req_type_upgrade;
711
-                } else {
712
-                    $req_type = EE_System::req_type_downgrade;
713
-                }
714
-                delete_option($activation_indicator_option_name);
715
-            } else {
716
-                // its not an update. maybe a reactivation?
717
-                if (get_option($activation_indicator_option_name, false)) {
718
-                    if ($version_is_higher === -1) {
719
-                        $req_type = EE_System::req_type_downgrade;
720
-                    } else if ($version_is_higher === 0) {
721
-                        //we've seen this version before, but it's an activation. must be a reactivation
722
-                        $req_type = EE_System::req_type_reactivation;
723
-                    } else {//$version_is_higher === 1
724
-                        $req_type = EE_System::req_type_upgrade;
725
-                    }
726
-                    delete_option($activation_indicator_option_name);
727
-                } else {
728
-                    //we've seen this version before and the activation indicate doesn't show it was just activated
729
-                    if ($version_is_higher === -1) {
730
-                        $req_type = EE_System::req_type_downgrade;
731
-                    } else if ($version_is_higher === 0) {
732
-                        //we've seen this version before and it's not an activation. its normal request
733
-                        $req_type = EE_System::req_type_normal;
734
-                    } else {//$version_is_higher === 1
735
-                        $req_type = EE_System::req_type_upgrade;
736
-                    }
737
-                }
738
-            }
739
-        } else {
740
-            //brand new install
741
-            $req_type = EE_System::req_type_new_activation;
742
-            delete_option($activation_indicator_option_name);
743
-        }
744
-        return $req_type;
745
-    }
746
-
747
-
748
-
749
-    /**
750
-     * Detects if the $version_to_upgrade_to is higher than the most recent version in
751
-     * the $activation_history_for_addon
752
-     *
753
-     * @param array  $activation_history_for_addon (keys are versions, values are arrays of times activated,
754
-     *                                             sometimes containing 'unknown-date'
755
-     * @param string $version_to_upgrade_to        (current version)
756
-     * @return int results of version_compare( $version_to_upgrade_to, $most_recently_active_version ).
757
-     *                                             ie, -1 if $version_to_upgrade_to is LOWER (downgrade);
758
-     *                                             0 if $version_to_upgrade_to MATCHES (reactivation or normal request);
759
-     *                                             1 if $version_to_upgrade_to is HIGHER (upgrade) ;
760
-     */
761
-    private static function _new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to)
762
-    {
763
-        //find the most recently-activated version
764
-        $most_recently_active_version =
765
-            EE_System::_get_most_recently_active_version_from_activation_history($activation_history_for_addon);
766
-        return version_compare($version_to_upgrade_to, $most_recently_active_version);
767
-    }
768
-
769
-
770
-
771
-    /**
772
-     * Gets the most recently active version listed in the activation history,
773
-     * and if none are found (ie, it's a brand new install) returns '0.0.0.dev.000'.
774
-     *
775
-     * @param array $activation_history  (keys are versions, values are arrays of times activated,
776
-     *                                   sometimes containing 'unknown-date'
777
-     * @return string
778
-     */
779
-    private static function _get_most_recently_active_version_from_activation_history($activation_history)
780
-    {
781
-        $most_recently_active_version_activation = '1970-01-01 00:00:00';
782
-        $most_recently_active_version = '0.0.0.dev.000';
783
-        if (is_array($activation_history)) {
784
-            foreach ($activation_history as $version => $times_activated) {
785
-                //check there is a record of when this version was activated. Otherwise,
786
-                //mark it as unknown
787
-                if (! $times_activated) {
788
-                    $times_activated = array('unknown-date');
789
-                }
790
-                if (is_string($times_activated)) {
791
-                    $times_activated = array($times_activated);
792
-                }
793
-                foreach ($times_activated as $an_activation) {
794
-                    if ($an_activation !== 'unknown-date' && $an_activation > $most_recently_active_version_activation) {
795
-                        $most_recently_active_version = $version;
796
-                        $most_recently_active_version_activation = $an_activation === 'unknown-date'
797
-                            ? '1970-01-01 00:00:00'
798
-                            : $an_activation;
799
-                    }
800
-                }
801
-            }
802
-        }
803
-        return $most_recently_active_version;
804
-    }
805
-
806
-
807
-
808
-    /**
809
-     * This redirects to the about EE page after activation
810
-     *
811
-     * @return void
812
-     */
813
-    public function redirect_to_about_ee()
814
-    {
815
-        $notices = EE_Error::get_notices(false);
816
-        //if current user is an admin and it's not an ajax or rest request
817
-        if (
818
-            ! (defined('DOING_AJAX') && DOING_AJAX)
819
-            && ! (defined('REST_REQUEST') && REST_REQUEST)
820
-            && ! isset($notices['errors'])
821
-            && apply_filters(
822
-                'FHEE__EE_System__redirect_to_about_ee__do_redirect',
823
-                $this->capabilities->current_user_can('manage_options', 'espresso_about_default')
824
-            )
825
-        ) {
826
-            $query_params = array('page' => 'espresso_about');
827
-            if (EE_System::instance()->detect_req_type() === EE_System::req_type_new_activation) {
828
-                $query_params['new_activation'] = true;
829
-            }
830
-            if (EE_System::instance()->detect_req_type() === EE_System::req_type_reactivation) {
831
-                $query_params['reactivation'] = true;
832
-            }
833
-            $url = add_query_arg($query_params, admin_url('admin.php'));
834
-            wp_safe_redirect($url);
835
-            exit();
836
-        }
837
-    }
838
-
839
-
840
-    /**
841
-     * load_core_configuration
842
-     * this is hooked into 'AHEE__EE_Bootstrap__load_core_configuration'
843
-     * which runs during the WP 'plugins_loaded' action at priority 5
844
-     *
845
-     * @return void
846
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
847
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
848
-     * @throws \EE_Error
849
-     * @throws ReflectionException
850
-     * @throws InvalidArgumentException
851
-     */
852
-    public function load_core_configuration()
853
-    {
854
-        do_action('AHEE__EE_System__load_core_configuration__begin', $this);
855
-        $this->loader->getShared('EE_Load_Textdomain');
856
-        //load textdomain
857
-        EE_Load_Textdomain::load_textdomain();
858
-        // load and setup EE_Config and EE_Network_Config
859
-        /** @var EE_Config $config */
860
-        $config = $this->loader->getShared('EE_Config');
861
-        if($this->maintenance_mode->models_can_query()){
862
-            $country_model = $this->registry->load_model('Country');
863
-            /** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */
864
-            $table_analysis = $this->loader->getShared('EventEspresso\core\services\database\TableAnalysis');
865
-            if($table_analysis->tableExists($country_model->table())){
866
-                $country = $country_model->get_one_by_ID($config->organization->CNT_ISO);
867
-                if($country instanceof EE_Country) {
868
-                    $config->currency->setFromCountry($country);
869
-                }
870
-            }
871
-        }
872
-        $this->loader->getShared('EE_Network_Config');
873
-        // setup autoloaders
874
-        // enable logging?
875
-        if ($config->admin->use_full_logging) {
876
-            $this->loader->getShared('EE_Log');
877
-        }
878
-        // check for activation errors
879
-        $activation_errors = get_option('ee_plugin_activation_errors', false);
880
-        if ($activation_errors) {
881
-            EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__);
882
-            update_option('ee_plugin_activation_errors', false);
883
-        }
884
-        // get model names
885
-        $this->_parse_model_names();
886
-        //load caf stuff a chance to play during the activation process too.
887
-        $this->_maybe_brew_regular();
888
-        do_action('AHEE__EE_System__load_core_configuration__complete', $this);
889
-    }
890
-
891
-
892
-
893
-    /**
894
-     * cycles through all of the models/*.model.php files, and assembles an array of model names
895
-     *
896
-     * @return void
897
-     * @throws ReflectionException
898
-     */
899
-    private function _parse_model_names()
900
-    {
901
-        //get all the files in the EE_MODELS folder that end in .model.php
902
-        $models = glob(EE_MODELS . '*.model.php');
903
-        $model_names = array();
904
-        $non_abstract_db_models = array();
905
-        foreach ($models as $model) {
906
-            // get model classname
907
-            $classname = EEH_File::get_classname_from_filepath_with_standard_filename($model);
908
-            $short_name = str_replace('EEM_', '', $classname);
909
-            $reflectionClass = new ReflectionClass($classname);
910
-            if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) {
911
-                $non_abstract_db_models[$short_name] = $classname;
912
-            }
913
-            $model_names[$short_name] = $classname;
914
-        }
915
-        $this->registry->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names);
916
-        $this->registry->non_abstract_db_models = apply_filters(
917
-            'FHEE__EE_System__parse_implemented_model_names',
918
-            $non_abstract_db_models
919
-        );
920
-    }
921
-
922
-
923
-
924
-    /**
925
-     * The purpose of this method is to simply check for a file named "caffeinated/brewing_regular.php" for any hooks
926
-     * that need to be setup before our EE_System launches.
927
-     *
928
-     * @return void
929
-     */
930
-    private function _maybe_brew_regular()
931
-    {
932
-        if ((! defined('EE_DECAF') || EE_DECAF !== true) && is_readable(EE_CAFF_PATH . 'brewing_regular.php')) {
933
-            require_once EE_CAFF_PATH . 'brewing_regular.php';
934
-        }
935
-    }
936
-
937
-
938
-
939
-    /**
940
-     * register_shortcodes_modules_and_widgets
941
-     * generate lists of shortcodes and modules, then verify paths and classes
942
-     * This is hooked into 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets'
943
-     * which runs during the WP 'plugins_loaded' action at priority 7
944
-     *
945
-     * @access public
946
-     * @return void
947
-     * @throws Exception
948
-     */
949
-    public function register_shortcodes_modules_and_widgets()
950
-    {
951
-        try {
952
-            // load, register, and add shortcodes the new way
953
-            $this->loader->getShared(
954
-                'EventEspresso\core\services\shortcodes\ShortcodesManager',
955
-                array(
956
-                    // and the old way, but we'll put it under control of the new system
957
-                    EE_Config::getLegacyShortcodesManager()
958
-                )
959
-            );
960
-        } catch (Exception $exception) {
961
-            new ExceptionStackTraceDisplay($exception);
962
-        }
963
-        do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets');
964
-        // check for addons using old hook point
965
-        if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) {
966
-            $this->_incompatible_addon_error();
967
-        }
968
-    }
969
-
970
-
971
-
972
-    /**
973
-     * _incompatible_addon_error
974
-     *
975
-     * @access public
976
-     * @return void
977
-     */
978
-    private function _incompatible_addon_error()
979
-    {
980
-        // get array of classes hooking into here
981
-        $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook(
982
-            'AHEE__EE_System__register_shortcodes_modules_and_addons'
983
-        );
984
-        if (! empty($class_names)) {
985
-            $msg = __(
986
-                'The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:',
987
-                'event_espresso'
988
-            );
989
-            $msg .= '<ul>';
990
-            foreach ($class_names as $class_name) {
991
-                $msg .= '<li><b>Event Espresso - ' . str_replace(
992
-                        array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '',
993
-                        $class_name
994
-                    ) . '</b></li>';
995
-            }
996
-            $msg .= '</ul>';
997
-            $msg .= __(
998
-                'Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.',
999
-                'event_espresso'
1000
-            );
1001
-            // save list of incompatible addons to wp-options for later use
1002
-            add_option('ee_incompatible_addons', $class_names, '', 'no');
1003
-            if (is_admin()) {
1004
-                EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1005
-            }
1006
-        }
1007
-    }
1008
-
1009
-
1010
-
1011
-    /**
1012
-     * brew_espresso
1013
-     * begins the process of setting hooks for initializing EE in the correct order
1014
-     * This is happening on the 'AHEE__EE_Bootstrap__brew_espresso' hook point
1015
-     * which runs during the WP 'plugins_loaded' action at priority 9
1016
-     *
1017
-     * @return void
1018
-     */
1019
-    public function brew_espresso()
1020
-    {
1021
-        do_action('AHEE__EE_System__brew_espresso__begin', $this);
1022
-        // load some final core systems
1023
-        add_action('init', array($this, 'set_hooks_for_core'), 1);
1024
-        add_action('init', array($this, 'perform_activations_upgrades_and_migrations'), 3);
1025
-        add_action('init', array($this, 'load_CPTs_and_session'), 5);
1026
-        add_action('init', array($this, 'load_controllers'), 7);
1027
-        add_action('init', array($this, 'core_loaded_and_ready'), 9);
1028
-        add_action('init', array($this, 'initialize'), 10);
1029
-        add_action('init', array($this, 'initialize_last'), 100);
1030
-        if (is_admin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', true)) {
1031
-            // pew pew pew
1032
-            $this->loader->getShared('EE_PUE');
1033
-            do_action('AHEE__EE_System__brew_espresso__after_pue_init');
1034
-        }
1035
-        do_action('AHEE__EE_System__brew_espresso__complete', $this);
1036
-    }
1037
-
1038
-
1039
-
1040
-    /**
1041
-     *    set_hooks_for_core
1042
-     *
1043
-     * @access public
1044
-     * @return    void
1045
-     * @throws EE_Error
1046
-     */
1047
-    public function set_hooks_for_core()
1048
-    {
1049
-        $this->_deactivate_incompatible_addons();
1050
-        do_action('AHEE__EE_System__set_hooks_for_core');
1051
-        //caps need to be initialized on every request so that capability maps are set.
1052
-        //@see https://events.codebasehq.com/projects/event-espresso/tickets/8674
1053
-        $this->registry->CAP->init_caps();
1054
-    }
1055
-
1056
-
1057
-
1058
-    /**
1059
-     * Using the information gathered in EE_System::_incompatible_addon_error,
1060
-     * deactivates any addons considered incompatible with the current version of EE
1061
-     */
1062
-    private function _deactivate_incompatible_addons()
1063
-    {
1064
-        $incompatible_addons = get_option('ee_incompatible_addons', array());
1065
-        if (! empty($incompatible_addons)) {
1066
-            $active_plugins = get_option('active_plugins', array());
1067
-            foreach ($active_plugins as $active_plugin) {
1068
-                foreach ($incompatible_addons as $incompatible_addon) {
1069
-                    if (strpos($active_plugin, $incompatible_addon) !== false) {
1070
-                        unset($_GET['activate']);
1071
-                        espresso_deactivate_plugin($active_plugin);
1072
-                    }
1073
-                }
1074
-            }
1075
-        }
1076
-    }
1077
-
1078
-
1079
-
1080
-    /**
1081
-     *    perform_activations_upgrades_and_migrations
1082
-     *
1083
-     * @access public
1084
-     * @return    void
1085
-     */
1086
-    public function perform_activations_upgrades_and_migrations()
1087
-    {
1088
-        //first check if we had previously attempted to setup EE's directories but failed
1089
-        if (EEH_Activation::upload_directories_incomplete()) {
1090
-            EEH_Activation::create_upload_directories();
1091
-        }
1092
-        do_action('AHEE__EE_System__perform_activations_upgrades_and_migrations');
1093
-    }
1094
-
1095
-
1096
-
1097
-    /**
1098
-     *    load_CPTs_and_session
1099
-     *
1100
-     * @access public
1101
-     * @return    void
1102
-     */
1103
-    public function load_CPTs_and_session()
1104
-    {
1105
-        do_action('AHEE__EE_System__load_CPTs_and_session__start');
1106
-        // register Custom Post Types
1107
-        $this->loader->getShared('EE_Register_CPTs');
1108
-        do_action('AHEE__EE_System__load_CPTs_and_session__complete');
1109
-    }
1110
-
1111
-
1112
-
1113
-    /**
1114
-     * load_controllers
1115
-     * this is the best place to load any additional controllers that needs access to EE core.
1116
-     * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this
1117
-     * time
1118
-     *
1119
-     * @access public
1120
-     * @return void
1121
-     */
1122
-    public function load_controllers()
1123
-    {
1124
-        do_action('AHEE__EE_System__load_controllers__start');
1125
-        // let's get it started
1126
-        if (! is_admin() && ! $this->maintenance_mode->level()) {
1127
-            do_action('AHEE__EE_System__load_controllers__load_front_controllers');
1128
-            $this->loader->getShared('EE_Front_Controller');
1129
-        } else if (! EE_FRONT_AJAX) {
1130
-            do_action('AHEE__EE_System__load_controllers__load_admin_controllers');
1131
-            $this->loader->getShared('EE_Admin');
1132
-        }
1133
-        do_action('AHEE__EE_System__load_controllers__complete');
1134
-    }
1135
-
1136
-
1137
-
1138
-    /**
1139
-     * core_loaded_and_ready
1140
-     * all of the basic EE core should be loaded at this point and available regardless of M-Mode
1141
-     *
1142
-     * @access public
1143
-     * @return void
1144
-     */
1145
-    public function core_loaded_and_ready()
1146
-    {
1147
-        $this->loader->getShared('EE_Session');
1148
-        do_action('AHEE__EE_System__core_loaded_and_ready');
1149
-        // load_espresso_template_tags
1150
-        if (is_readable(EE_PUBLIC . 'template_tags.php')) {
1151
-            require_once(EE_PUBLIC . 'template_tags.php');
1152
-        }
1153
-        do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons');
1154
-        $this->loader->getShared('EventEspresso\core\services\assets\Registry');
1155
-    }
1156
-
1157
-
1158
-
1159
-    /**
1160
-     * initialize
1161
-     * this is the best place to begin initializing client code
1162
-     *
1163
-     * @access public
1164
-     * @return void
1165
-     */
1166
-    public function initialize()
1167
-    {
1168
-        do_action('AHEE__EE_System__initialize');
1169
-    }
1170
-
1171
-
1172
-
1173
-    /**
1174
-     * initialize_last
1175
-     * this is run really late during the WP init hook point, and ensures that mostly everything else that needs to
1176
-     * initialize has done so
1177
-     *
1178
-     * @access public
1179
-     * @return void
1180
-     */
1181
-    public function initialize_last()
1182
-    {
1183
-        do_action('AHEE__EE_System__initialize_last');
1184
-        add_action('admin_bar_init', array($this, 'addEspressoToolbar'));
1185
-    }
1186
-
1187
-
1188
-
1189
-    /**
1190
-     * @return void
1191
-     * @throws EE_Error
1192
-     */
1193
-    public function addEspressoToolbar()
1194
-    {
1195
-        $this->loader->getShared(
1196
-            'EventEspresso\core\domain\services\admin\AdminToolBar',
1197
-            array($this->registry->CAP)
1198
-        );
1199
-    }
1200
-
1201
-
1202
-
1203
-    /**
1204
-     * do_not_cache
1205
-     * sets no cache headers and defines no cache constants for WP plugins
1206
-     *
1207
-     * @access public
1208
-     * @return void
1209
-     */
1210
-    public static function do_not_cache()
1211
-    {
1212
-        // set no cache constants
1213
-        if (! defined('DONOTCACHEPAGE')) {
1214
-            define('DONOTCACHEPAGE', true);
1215
-        }
1216
-        if (! defined('DONOTCACHCEOBJECT')) {
1217
-            define('DONOTCACHCEOBJECT', true);
1218
-        }
1219
-        if (! defined('DONOTCACHEDB')) {
1220
-            define('DONOTCACHEDB', true);
1221
-        }
1222
-        // add no cache headers
1223
-        add_action('send_headers', array('EE_System', 'nocache_headers'), 10);
1224
-        // plus a little extra for nginx and Google Chrome
1225
-        add_filter('nocache_headers', array('EE_System', 'extra_nocache_headers'), 10, 1);
1226
-        // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process
1227
-        remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');
1228
-    }
1229
-
1230
-
1231
-
1232
-    /**
1233
-     *    extra_nocache_headers
1234
-     *
1235
-     * @access    public
1236
-     * @param $headers
1237
-     * @return    array
1238
-     */
1239
-    public static function extra_nocache_headers($headers)
1240
-    {
1241
-        // for NGINX
1242
-        $headers['X-Accel-Expires'] = 0;
1243
-        // plus extra for Google Chrome since it doesn't seem to respect "no-cache", but WILL respect "no-store"
1244
-        $headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0';
1245
-        return $headers;
1246
-    }
1247
-
1248
-
1249
-
1250
-    /**
1251
-     *    nocache_headers
1252
-     *
1253
-     * @access    public
1254
-     * @return    void
1255
-     */
1256
-    public static function nocache_headers()
1257
-    {
1258
-        nocache_headers();
1259
-    }
1260
-
1261
-
1262
-
1263
-
1264
-    /**
1265
-     * simply hooks into "wp_list_pages_exclude" filter (for wp_list_pages method) and makes sure EE critical pages are
1266
-     * never returned with the function.
1267
-     *
1268
-     * @param  array $exclude_array any existing pages being excluded are in this array.
1269
-     * @return array
1270
-     */
1271
-    public function remove_pages_from_wp_list_pages($exclude_array)
1272
-    {
1273
-        return array_merge($exclude_array, $this->registry->CFG->core->get_critical_pages_array());
1274
-    }
24
+	/**
25
+	 * indicates this is a 'normal' request. Ie, not activation, nor upgrade, nor activation.
26
+	 * So examples of this would be a normal GET request on the frontend or backend, or a POST, etc
27
+	 */
28
+	const req_type_normal = 0;
29
+
30
+	/**
31
+	 * Indicates this is a brand new installation of EE so we should install
32
+	 * tables and default data etc
33
+	 */
34
+	const req_type_new_activation = 1;
35
+
36
+	/**
37
+	 * we've detected that EE has been reactivated (or EE was activated during maintenance mode,
38
+	 * and we just exited maintenance mode). We MUST check the database is setup properly
39
+	 * and that default data is setup too
40
+	 */
41
+	const req_type_reactivation = 2;
42
+
43
+	/**
44
+	 * indicates that EE has been upgraded since its previous request.
45
+	 * We may have data migration scripts to call and will want to trigger maintenance mode
46
+	 */
47
+	const req_type_upgrade = 3;
48
+
49
+	/**
50
+	 * TODO  will detect that EE has been DOWNGRADED. We probably don't want to run in this case...
51
+	 */
52
+	const req_type_downgrade = 4;
53
+
54
+	/**
55
+	 * @deprecated since version 4.6.0.dev.006
56
+	 * Now whenever a new_activation is detected the request type is still just
57
+	 * new_activation (same for reactivation, upgrade, downgrade etc), but if we'r ein maintenance mode
58
+	 * EE_System::initialize_db_if_no_migrations_required and EE_Addon::initialize_db_if_no_migrations_required
59
+	 * will instead enqueue that EE plugin's db initialization for when we're taken out of maintenance mode.
60
+	 * (Specifically, when the migration manager indicates migrations are finished
61
+	 * EE_Data_Migration_Manager::initialize_db_for_enqueued_ee_plugins() will be called)
62
+	 */
63
+	const req_type_activation_but_not_installed = 5;
64
+
65
+	/**
66
+	 * option prefix for recording the activation history (like core's "espresso_db_update") of addons
67
+	 */
68
+	const addon_activation_history_option_prefix = 'ee_addon_activation_history_';
69
+
70
+
71
+	/**
72
+	 * @var EE_System $_instance
73
+	 */
74
+	private static $_instance;
75
+
76
+	/**
77
+	 * @var EE_Registry $registry
78
+	 */
79
+	private $registry;
80
+
81
+	/**
82
+	 * @var LoaderInterface $loader
83
+	 */
84
+	private $loader;
85
+
86
+	/**
87
+	 * @var EE_Capabilities $capabilities
88
+	 */
89
+	private $capabilities;
90
+
91
+	/**
92
+	 * @var EE_Request $request
93
+	 */
94
+	private $request;
95
+
96
+	/**
97
+	 * @var EE_Maintenance_Mode $maintenance_mode
98
+	 */
99
+	private $maintenance_mode;
100
+
101
+	/**
102
+	 * Stores which type of request this is, options being one of the constants on EE_System starting with req_type_*.
103
+	 * It can be a brand-new activation, a reactivation, an upgrade, a downgrade, or a normal request.
104
+	 *
105
+	 * @var int $_req_type
106
+	 */
107
+	private $_req_type;
108
+
109
+	/**
110
+	 * Whether or not there was a non-micro version change in EE core version during this request
111
+	 *
112
+	 * @var boolean $_major_version_change
113
+	 */
114
+	private $_major_version_change = false;
115
+
116
+
117
+
118
+	/**
119
+	 * @singleton method used to instantiate class object
120
+	 * @param EE_Registry|null         $registry
121
+	 * @param LoaderInterface|null     $loader
122
+	 * @param EE_Capabilities|null     $capabilities
123
+	 * @param EE_Request|null          $request
124
+	 * @param EE_Maintenance_Mode|null $maintenance_mode
125
+	 * @return EE_System
126
+	 */
127
+	public static function instance(
128
+		EE_Registry $registry = null,
129
+		LoaderInterface $loader = null,
130
+		EE_Capabilities $capabilities = null,
131
+		EE_Request $request = null,
132
+		EE_Maintenance_Mode $maintenance_mode = null
133
+	) {
134
+		// check if class object is instantiated
135
+		if (! self::$_instance instanceof EE_System) {
136
+			self::$_instance = new self($registry, $loader, $capabilities, $request, $maintenance_mode);
137
+		}
138
+		return self::$_instance;
139
+	}
140
+
141
+
142
+
143
+	/**
144
+	 * resets the instance and returns it
145
+	 *
146
+	 * @return EE_System
147
+	 */
148
+	public static function reset()
149
+	{
150
+		self::$_instance->_req_type = null;
151
+		//make sure none of the old hooks are left hanging around
152
+		remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations');
153
+		//we need to reset the migration manager in order for it to detect DMSs properly
154
+		EE_Data_Migration_Manager::reset();
155
+		self::instance()->detect_activations_or_upgrades();
156
+		self::instance()->perform_activations_upgrades_and_migrations();
157
+		return self::instance();
158
+	}
159
+
160
+
161
+
162
+	/**
163
+	 * sets hooks for running rest of system
164
+	 * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point
165
+	 * starting EE Addons from any other point may lead to problems
166
+	 *
167
+	 * @param EE_Registry         $registry
168
+	 * @param LoaderInterface     $loader
169
+	 * @param EE_Capabilities     $capabilities
170
+	 * @param EE_Request          $request
171
+	 * @param EE_Maintenance_Mode $maintenance_mode
172
+	 */
173
+	private function __construct(
174
+		EE_Registry $registry,
175
+		LoaderInterface $loader,
176
+		EE_Capabilities $capabilities,
177
+		EE_Request $request,
178
+		EE_Maintenance_Mode $maintenance_mode
179
+	) {
180
+		$this->registry = $registry;
181
+		$this->loader = $loader;
182
+		$this->capabilities = $capabilities;
183
+		$this->request = $request;
184
+		$this->maintenance_mode = $maintenance_mode;
185
+		do_action('AHEE__EE_System__construct__begin', $this);
186
+		add_action(
187
+			'AHEE__EE_Bootstrap__load_espresso_addons',
188
+			array($this, 'loadCapabilities'),
189
+			5
190
+		);
191
+		add_action(
192
+			'AHEE__EE_Bootstrap__load_espresso_addons',
193
+			array($this, 'loadCommandBus'),
194
+			7
195
+		);
196
+		add_action(
197
+			'AHEE__EE_Bootstrap__load_espresso_addons',
198
+			array($this, 'loadPluginApi'),
199
+			9
200
+		);
201
+		// allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc
202
+		add_action(
203
+			'AHEE__EE_Bootstrap__load_espresso_addons',
204
+			array($this, 'load_espresso_addons')
205
+		);
206
+		// when an ee addon is activated, we want to call the core hook(s) again
207
+		// because the newly-activated addon didn't get a chance to run at all
208
+		add_action('activate_plugin', array($this, 'load_espresso_addons'), 1);
209
+		// detect whether install or upgrade
210
+		add_action(
211
+			'AHEE__EE_Bootstrap__detect_activations_or_upgrades',
212
+			array($this, 'detect_activations_or_upgrades'),
213
+			3
214
+		);
215
+		// load EE_Config, EE_Textdomain, etc
216
+		add_action(
217
+			'AHEE__EE_Bootstrap__load_core_configuration',
218
+			array($this, 'load_core_configuration'),
219
+			5
220
+		);
221
+		// load EE_Config, EE_Textdomain, etc
222
+		add_action(
223
+			'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets',
224
+			array($this, 'register_shortcodes_modules_and_widgets'),
225
+			7
226
+		);
227
+		// you wanna get going? I wanna get going... let's get going!
228
+		add_action(
229
+			'AHEE__EE_Bootstrap__brew_espresso',
230
+			array($this, 'brew_espresso'),
231
+			9
232
+		);
233
+		//other housekeeping
234
+		//exclude EE critical pages from wp_list_pages
235
+		add_filter(
236
+			'wp_list_pages_excludes',
237
+			array($this, 'remove_pages_from_wp_list_pages'),
238
+			10
239
+		);
240
+		// ALL EE Addons should use the following hook point to attach their initial setup too
241
+		// it's extremely important for EE Addons to register any class autoloaders so that they can be available when the EE_Config loads
242
+		do_action('AHEE__EE_System__construct__complete', $this);
243
+	}
244
+
245
+
246
+
247
+	/**
248
+	 * load and setup EE_Capabilities
249
+	 *
250
+	 * @return void
251
+	 * @throws EE_Error
252
+	 */
253
+	public function loadCapabilities()
254
+	{
255
+		$this->loader->getShared('EE_Capabilities');
256
+		add_action(
257
+			'AHEE__EE_Capabilities__init_caps__before_initialization',
258
+			function() {
259
+				LoaderFactory::getLoader()->getShared('EE_Payment_Method_Manager');
260
+			}
261
+		);
262
+	}
263
+
264
+
265
+
266
+	/**
267
+	 * create and cache the CommandBus, and also add middleware
268
+	 * The CapChecker middleware requires the use of EE_Capabilities
269
+	 * which is why we need to load the CommandBus after Caps are set up
270
+	 *
271
+	 * @return void
272
+	 * @throws EE_Error
273
+	 */
274
+	public function loadCommandBus()
275
+	{
276
+		$this->loader->getShared(
277
+			'CommandBusInterface',
278
+			array(
279
+				null,
280
+				apply_filters(
281
+					'FHEE__EE_Load_Espresso_Core__handle_request__CommandBus_middleware',
282
+					array(
283
+						$this->loader->getShared('EventEspresso\core\services\commands\middleware\CapChecker'),
284
+						$this->loader->getShared('EventEspresso\core\services\commands\middleware\AddActionHook'),
285
+					)
286
+				),
287
+			)
288
+		);
289
+	}
290
+
291
+
292
+
293
+	/**
294
+	 * @return void
295
+	 * @throws EE_Error
296
+	 */
297
+	public function loadPluginApi()
298
+	{
299
+		// set autoloaders for all of the classes implementing EEI_Plugin_API
300
+		// which provide helpers for EE plugin authors to more easily register certain components with EE.
301
+		EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api');
302
+	}
303
+
304
+
305
+	/**
306
+	 * @param string $addon_name
307
+	 * @param string $version_constant
308
+	 * @param string $min_version_required
309
+	 * @param string $load_callback
310
+	 * @param string $plugin_file_constant
311
+	 * @return void
312
+	 */
313
+	private function deactivateIncompatibleAddon(
314
+		$addon_name,
315
+		$version_constant,
316
+		$min_version_required,
317
+		$load_callback,
318
+		$plugin_file_constant
319
+	) {
320
+		if (! defined($version_constant)) {
321
+			return;
322
+		}
323
+		$addon_version = constant($version_constant);
324
+		if ($addon_version && version_compare($addon_version, $min_version_required, '<')) {
325
+			remove_action('AHEE__EE_System__load_espresso_addons', $load_callback);
326
+			if (! function_exists('deactivate_plugins')) {
327
+				require_once ABSPATH . 'wp-admin/includes/plugin.php';
328
+			}
329
+			deactivate_plugins(plugin_basename(constant($plugin_file_constant)));
330
+			unset($_GET['activate'], $_REQUEST['activate'], $_GET['activate-multi'], $_REQUEST['activate-multi']);
331
+			EE_Error::add_error(
332
+				sprintf(
333
+					esc_html__(
334
+						'We\'re sorry, but the Event Espresso %1$s addon was deactivated because version %2$s or higher is required with this version of Event Espresso core.',
335
+						'event_espresso'
336
+					),
337
+					$addon_name,
338
+					$min_version_required
339
+				),
340
+				__FILE__, __FUNCTION__ . "({$addon_name})", __LINE__
341
+			);
342
+			EE_Error::get_notices(false, true);
343
+		}
344
+	}
345
+
346
+
347
+	/**
348
+	 * load_espresso_addons
349
+	 * allow addons to load first so that they can set hooks for running DMS's, etc
350
+	 * this is hooked into both:
351
+	 *    'AHEE__EE_Bootstrap__load_core_configuration'
352
+	 *        which runs during the WP 'plugins_loaded' action at priority 5
353
+	 *    and the WP 'activate_plugin' hook point
354
+	 *
355
+	 * @access public
356
+	 * @return void
357
+	 */
358
+	public function load_espresso_addons()
359
+	{
360
+		$this->deactivateIncompatibleAddon(
361
+			'Wait Lists',
362
+			'EE_WAIT_LISTS_VERSION',
363
+			'1.0.0.rc.074',
364
+			'load_espresso_wait_lists',
365
+			'EE_WAIT_LISTS_PLUGIN_FILE'
366
+		);
367
+		$this->deactivateIncompatibleAddon(
368
+			'Automated Upcoming Event Notifications',
369
+			'EE_AUTOMATED_UPCOMING_EVENT_NOTIFICATION_VERSION',
370
+			'1.0.0.rc.091',
371
+			'load_espresso_automated_upcoming_event_notification',
372
+			'EE_AUTOMATED_UPCOMING_EVENT_NOTIFICATION_PLUGIN_FILE'
373
+		);
374
+		do_action('AHEE__EE_System__load_espresso_addons');
375
+		//if the WP API basic auth plugin isn't already loaded, load it now.
376
+		//We want it for mobile apps. Just include the entire plugin
377
+		//also, don't load the basic auth when a plugin is getting activated, because
378
+		//it could be the basic auth plugin, and it doesn't check if its methods are already defined
379
+		//and causes a fatal error
380
+		if (
381
+			! (
382
+				isset($_GET['activate'])
383
+				&& $_GET['activate'] === 'true'
384
+			)
385
+			&& ! function_exists('json_basic_auth_handler')
386
+			&& ! function_exists('json_basic_auth_error')
387
+			&& ! (
388
+				isset($_GET['action'])
389
+				&& in_array($_GET['action'], array('activate', 'activate-selected'), true)
390
+			)
391
+		) {
392
+			include_once EE_THIRD_PARTY . 'wp-api-basic-auth' . DS . 'basic-auth.php';
393
+		}
394
+		do_action('AHEE__EE_System__load_espresso_addons__complete');
395
+	}
396
+
397
+
398
+
399
+	/**
400
+	 * detect_activations_or_upgrades
401
+	 * Checks for activation or upgrade of core first;
402
+	 * then also checks if any registered addons have been activated or upgraded
403
+	 * This is hooked into 'AHEE__EE_Bootstrap__detect_activations_or_upgrades'
404
+	 * which runs during the WP 'plugins_loaded' action at priority 3
405
+	 *
406
+	 * @access public
407
+	 * @return void
408
+	 */
409
+	public function detect_activations_or_upgrades()
410
+	{
411
+		//first off: let's make sure to handle core
412
+		$this->detect_if_activation_or_upgrade();
413
+		foreach ($this->registry->addons as $addon) {
414
+			if ($addon instanceof EE_Addon) {
415
+				//detect teh request type for that addon
416
+				$addon->detect_activation_or_upgrade();
417
+			}
418
+		}
419
+	}
420
+
421
+
422
+
423
+	/**
424
+	 * detect_if_activation_or_upgrade
425
+	 * Takes care of detecting whether this is a brand new install or code upgrade,
426
+	 * and either setting up the DB or setting up maintenance mode etc.
427
+	 *
428
+	 * @access public
429
+	 * @return void
430
+	 */
431
+	public function detect_if_activation_or_upgrade()
432
+	{
433
+		do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin');
434
+		// check if db has been updated, or if its a brand-new installation
435
+		$espresso_db_update = $this->fix_espresso_db_upgrade_option();
436
+		$request_type = $this->detect_req_type($espresso_db_update);
437
+		//EEH_Debug_Tools::printr( $request_type, '$request_type', __FILE__, __LINE__ );
438
+		switch ($request_type) {
439
+			case EE_System::req_type_new_activation:
440
+				do_action('AHEE__EE_System__detect_if_activation_or_upgrade__new_activation');
441
+				$this->_handle_core_version_change($espresso_db_update);
442
+				break;
443
+			case EE_System::req_type_reactivation:
444
+				do_action('AHEE__EE_System__detect_if_activation_or_upgrade__reactivation');
445
+				$this->_handle_core_version_change($espresso_db_update);
446
+				break;
447
+			case EE_System::req_type_upgrade:
448
+				do_action('AHEE__EE_System__detect_if_activation_or_upgrade__upgrade');
449
+				//migrations may be required now that we've upgraded
450
+				$this->maintenance_mode->set_maintenance_mode_if_db_old();
451
+				$this->_handle_core_version_change($espresso_db_update);
452
+				//				echo "done upgrade";die;
453
+				break;
454
+			case EE_System::req_type_downgrade:
455
+				do_action('AHEE__EE_System__detect_if_activation_or_upgrade__downgrade');
456
+				//its possible migrations are no longer required
457
+				$this->maintenance_mode->set_maintenance_mode_if_db_old();
458
+				$this->_handle_core_version_change($espresso_db_update);
459
+				break;
460
+			case EE_System::req_type_normal:
461
+			default:
462
+				//				$this->_maybe_redirect_to_ee_about();
463
+				break;
464
+		}
465
+		do_action('AHEE__EE_System__detect_if_activation_or_upgrade__complete');
466
+	}
467
+
468
+
469
+
470
+	/**
471
+	 * Updates the list of installed versions and sets hooks for
472
+	 * initializing the database later during the request
473
+	 *
474
+	 * @param array $espresso_db_update
475
+	 */
476
+	private function _handle_core_version_change($espresso_db_update)
477
+	{
478
+		$this->update_list_of_installed_versions($espresso_db_update);
479
+		//get ready to verify the DB is ok (provided we aren't in maintenance mode, of course)
480
+		add_action(
481
+			'AHEE__EE_System__perform_activations_upgrades_and_migrations',
482
+			array($this, 'initialize_db_if_no_migrations_required')
483
+		);
484
+	}
485
+
486
+
487
+
488
+	/**
489
+	 * standardizes the wp option 'espresso_db_upgrade' which actually stores
490
+	 * information about what versions of EE have been installed and activated,
491
+	 * NOT necessarily the state of the database
492
+	 *
493
+	 * @param mixed $espresso_db_update the value of the WordPress option.
494
+	 *                                            If not supplied, fetches it from the options table
495
+	 * @return array the correct value of 'espresso_db_upgrade', after saving it, if it needed correction
496
+	 */
497
+	private function fix_espresso_db_upgrade_option($espresso_db_update = null)
498
+	{
499
+		do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update);
500
+		if (! $espresso_db_update) {
501
+			$espresso_db_update = get_option('espresso_db_update');
502
+		}
503
+		// check that option is an array
504
+		if (! is_array($espresso_db_update)) {
505
+			// if option is FALSE, then it never existed
506
+			if ($espresso_db_update === false) {
507
+				// make $espresso_db_update an array and save option with autoload OFF
508
+				$espresso_db_update = array();
509
+				add_option('espresso_db_update', $espresso_db_update, '', 'no');
510
+			} else {
511
+				// option is NOT FALSE but also is NOT an array, so make it an array and save it
512
+				$espresso_db_update = array($espresso_db_update => array());
513
+				update_option('espresso_db_update', $espresso_db_update);
514
+			}
515
+		} else {
516
+			$corrected_db_update = array();
517
+			//if IS an array, but is it an array where KEYS are version numbers, and values are arrays?
518
+			foreach ($espresso_db_update as $should_be_version_string => $should_be_array) {
519
+				if (is_int($should_be_version_string) && ! is_array($should_be_array)) {
520
+					//the key is an int, and the value IS NOT an array
521
+					//so it must be numerically-indexed, where values are versions installed...
522
+					//fix it!
523
+					$version_string = $should_be_array;
524
+					$corrected_db_update[$version_string] = array('unknown-date');
525
+				} else {
526
+					//ok it checks out
527
+					$corrected_db_update[$should_be_version_string] = $should_be_array;
528
+				}
529
+			}
530
+			$espresso_db_update = $corrected_db_update;
531
+			update_option('espresso_db_update', $espresso_db_update);
532
+		}
533
+		do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update);
534
+		return $espresso_db_update;
535
+	}
536
+
537
+
538
+
539
+	/**
540
+	 * Does the traditional work of setting up the plugin's database and adding default data.
541
+	 * If migration script/process did not exist, this is what would happen on every activation/reactivation/upgrade.
542
+	 * NOTE: if we're in maintenance mode (which would be the case if we detect there are data
543
+	 * migration scripts that need to be run and a version change happens), enqueues core for database initialization,
544
+	 * so that it will be done when migrations are finished
545
+	 *
546
+	 * @param boolean $initialize_addons_too if true, we double-check addons' database tables etc too;
547
+	 * @param boolean $verify_schema         if true will re-check the database tables have the correct schema.
548
+	 *                                       This is a resource-intensive job
549
+	 *                                       so we prefer to only do it when necessary
550
+	 * @return void
551
+	 * @throws EE_Error
552
+	 */
553
+	public function initialize_db_if_no_migrations_required($initialize_addons_too = false, $verify_schema = true)
554
+	{
555
+		$request_type = $this->detect_req_type();
556
+		//only initialize system if we're not in maintenance mode.
557
+		if ($this->maintenance_mode->level() !== EE_Maintenance_Mode::level_2_complete_maintenance) {
558
+			update_option('ee_flush_rewrite_rules', true);
559
+			if ($verify_schema) {
560
+				EEH_Activation::initialize_db_and_folders();
561
+			}
562
+			EEH_Activation::initialize_db_content();
563
+			EEH_Activation::system_initialization();
564
+			if ($initialize_addons_too) {
565
+				$this->initialize_addons();
566
+			}
567
+		} else {
568
+			EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for('Core');
569
+		}
570
+		if ($request_type === EE_System::req_type_new_activation
571
+			|| $request_type === EE_System::req_type_reactivation
572
+			|| (
573
+				$request_type === EE_System::req_type_upgrade
574
+				&& $this->is_major_version_change()
575
+			)
576
+		) {
577
+			add_action('AHEE__EE_System__initialize_last', array($this, 'redirect_to_about_ee'), 9);
578
+		}
579
+	}
580
+
581
+
582
+
583
+	/**
584
+	 * Initializes the db for all registered addons
585
+	 *
586
+	 * @throws EE_Error
587
+	 */
588
+	public function initialize_addons()
589
+	{
590
+		//foreach registered addon, make sure its db is up-to-date too
591
+		foreach ($this->registry->addons as $addon) {
592
+			if ($addon instanceof EE_Addon) {
593
+				$addon->initialize_db_if_no_migrations_required();
594
+			}
595
+		}
596
+	}
597
+
598
+
599
+
600
+	/**
601
+	 * Adds the current code version to the saved wp option which stores a list of all ee versions ever installed.
602
+	 *
603
+	 * @param    array  $version_history
604
+	 * @param    string $current_version_to_add version to be added to the version history
605
+	 * @return    boolean success as to whether or not this option was changed
606
+	 */
607
+	public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null)
608
+	{
609
+		if (! $version_history) {
610
+			$version_history = $this->fix_espresso_db_upgrade_option($version_history);
611
+		}
612
+		if ($current_version_to_add === null) {
613
+			$current_version_to_add = espresso_version();
614
+		}
615
+		$version_history[$current_version_to_add][] = date('Y-m-d H:i:s', time());
616
+		// re-save
617
+		return update_option('espresso_db_update', $version_history);
618
+	}
619
+
620
+
621
+
622
+	/**
623
+	 * Detects if the current version indicated in the has existed in the list of
624
+	 * previously-installed versions of EE (espresso_db_update). Does NOT modify it (ie, no side-effect)
625
+	 *
626
+	 * @param array $espresso_db_update array from the wp option stored under the name 'espresso_db_update'.
627
+	 *                                  If not supplied, fetches it from the options table.
628
+	 *                                  Also, caches its result so later parts of the code can also know whether
629
+	 *                                  there's been an update or not. This way we can add the current version to
630
+	 *                                  espresso_db_update, but still know if this is a new install or not
631
+	 * @return int one of the constants on EE_System::req_type_
632
+	 */
633
+	public function detect_req_type($espresso_db_update = null)
634
+	{
635
+		if ($this->_req_type === null) {
636
+			$espresso_db_update = ! empty($espresso_db_update)
637
+				? $espresso_db_update
638
+				: $this->fix_espresso_db_upgrade_option();
639
+			$this->_req_type = EE_System::detect_req_type_given_activation_history(
640
+				$espresso_db_update,
641
+				'ee_espresso_activation', espresso_version()
642
+			);
643
+			$this->_major_version_change = $this->_detect_major_version_change($espresso_db_update);
644
+		}
645
+		return $this->_req_type;
646
+	}
647
+
648
+
649
+
650
+	/**
651
+	 * Returns whether or not there was a non-micro version change (ie, change in either
652
+	 * the first or second number in the version. Eg 4.9.0.rc.001 to 4.10.0.rc.000,
653
+	 * but not 4.9.0.rc.0001 to 4.9.1.rc.0001
654
+	 *
655
+	 * @param $activation_history
656
+	 * @return bool
657
+	 */
658
+	private function _detect_major_version_change($activation_history)
659
+	{
660
+		$previous_version = EE_System::_get_most_recently_active_version_from_activation_history($activation_history);
661
+		$previous_version_parts = explode('.', $previous_version);
662
+		$current_version_parts = explode('.', espresso_version());
663
+		return isset($previous_version_parts[0], $previous_version_parts[1], $current_version_parts[0], $current_version_parts[1])
664
+			   && ($previous_version_parts[0] !== $current_version_parts[0]
665
+				   || $previous_version_parts[1] !== $current_version_parts[1]
666
+			   );
667
+	}
668
+
669
+
670
+
671
+	/**
672
+	 * Returns true if either the major or minor version of EE changed during this request.
673
+	 * Eg 4.9.0.rc.001 to 4.10.0.rc.000, but not 4.9.0.rc.0001 to 4.9.1.rc.0001
674
+	 *
675
+	 * @return bool
676
+	 */
677
+	public function is_major_version_change()
678
+	{
679
+		return $this->_major_version_change;
680
+	}
681
+
682
+
683
+
684
+	/**
685
+	 * Determines the request type for any ee addon, given three piece of info: the current array of activation
686
+	 * histories (for core that' 'espresso_db_update' wp option); the name of the WordPress option which is temporarily
687
+	 * set upon activation of the plugin (for core it's 'ee_espresso_activation'); and the version that this plugin was
688
+	 * just activated to (for core that will always be espresso_version())
689
+	 *
690
+	 * @param array  $activation_history_for_addon     the option's value which stores the activation history for this
691
+	 *                                                 ee plugin. for core that's 'espresso_db_update'
692
+	 * @param string $activation_indicator_option_name the name of the WordPress option that is temporarily set to
693
+	 *                                                 indicate that this plugin was just activated
694
+	 * @param string $version_to_upgrade_to            the version that was just upgraded to (for core that will be
695
+	 *                                                 espresso_version())
696
+	 * @return int one of the constants on EE_System::req_type_*
697
+	 */
698
+	public static function detect_req_type_given_activation_history(
699
+		$activation_history_for_addon,
700
+		$activation_indicator_option_name,
701
+		$version_to_upgrade_to
702
+	) {
703
+		$version_is_higher = self::_new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to);
704
+		if ($activation_history_for_addon) {
705
+			//it exists, so this isn't a completely new install
706
+			//check if this version already in that list of previously installed versions
707
+			if (! isset($activation_history_for_addon[$version_to_upgrade_to])) {
708
+				//it a version we haven't seen before
709
+				if ($version_is_higher === 1) {
710
+					$req_type = EE_System::req_type_upgrade;
711
+				} else {
712
+					$req_type = EE_System::req_type_downgrade;
713
+				}
714
+				delete_option($activation_indicator_option_name);
715
+			} else {
716
+				// its not an update. maybe a reactivation?
717
+				if (get_option($activation_indicator_option_name, false)) {
718
+					if ($version_is_higher === -1) {
719
+						$req_type = EE_System::req_type_downgrade;
720
+					} else if ($version_is_higher === 0) {
721
+						//we've seen this version before, but it's an activation. must be a reactivation
722
+						$req_type = EE_System::req_type_reactivation;
723
+					} else {//$version_is_higher === 1
724
+						$req_type = EE_System::req_type_upgrade;
725
+					}
726
+					delete_option($activation_indicator_option_name);
727
+				} else {
728
+					//we've seen this version before and the activation indicate doesn't show it was just activated
729
+					if ($version_is_higher === -1) {
730
+						$req_type = EE_System::req_type_downgrade;
731
+					} else if ($version_is_higher === 0) {
732
+						//we've seen this version before and it's not an activation. its normal request
733
+						$req_type = EE_System::req_type_normal;
734
+					} else {//$version_is_higher === 1
735
+						$req_type = EE_System::req_type_upgrade;
736
+					}
737
+				}
738
+			}
739
+		} else {
740
+			//brand new install
741
+			$req_type = EE_System::req_type_new_activation;
742
+			delete_option($activation_indicator_option_name);
743
+		}
744
+		return $req_type;
745
+	}
746
+
747
+
748
+
749
+	/**
750
+	 * Detects if the $version_to_upgrade_to is higher than the most recent version in
751
+	 * the $activation_history_for_addon
752
+	 *
753
+	 * @param array  $activation_history_for_addon (keys are versions, values are arrays of times activated,
754
+	 *                                             sometimes containing 'unknown-date'
755
+	 * @param string $version_to_upgrade_to        (current version)
756
+	 * @return int results of version_compare( $version_to_upgrade_to, $most_recently_active_version ).
757
+	 *                                             ie, -1 if $version_to_upgrade_to is LOWER (downgrade);
758
+	 *                                             0 if $version_to_upgrade_to MATCHES (reactivation or normal request);
759
+	 *                                             1 if $version_to_upgrade_to is HIGHER (upgrade) ;
760
+	 */
761
+	private static function _new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to)
762
+	{
763
+		//find the most recently-activated version
764
+		$most_recently_active_version =
765
+			EE_System::_get_most_recently_active_version_from_activation_history($activation_history_for_addon);
766
+		return version_compare($version_to_upgrade_to, $most_recently_active_version);
767
+	}
768
+
769
+
770
+
771
+	/**
772
+	 * Gets the most recently active version listed in the activation history,
773
+	 * and if none are found (ie, it's a brand new install) returns '0.0.0.dev.000'.
774
+	 *
775
+	 * @param array $activation_history  (keys are versions, values are arrays of times activated,
776
+	 *                                   sometimes containing 'unknown-date'
777
+	 * @return string
778
+	 */
779
+	private static function _get_most_recently_active_version_from_activation_history($activation_history)
780
+	{
781
+		$most_recently_active_version_activation = '1970-01-01 00:00:00';
782
+		$most_recently_active_version = '0.0.0.dev.000';
783
+		if (is_array($activation_history)) {
784
+			foreach ($activation_history as $version => $times_activated) {
785
+				//check there is a record of when this version was activated. Otherwise,
786
+				//mark it as unknown
787
+				if (! $times_activated) {
788
+					$times_activated = array('unknown-date');
789
+				}
790
+				if (is_string($times_activated)) {
791
+					$times_activated = array($times_activated);
792
+				}
793
+				foreach ($times_activated as $an_activation) {
794
+					if ($an_activation !== 'unknown-date' && $an_activation > $most_recently_active_version_activation) {
795
+						$most_recently_active_version = $version;
796
+						$most_recently_active_version_activation = $an_activation === 'unknown-date'
797
+							? '1970-01-01 00:00:00'
798
+							: $an_activation;
799
+					}
800
+				}
801
+			}
802
+		}
803
+		return $most_recently_active_version;
804
+	}
805
+
806
+
807
+
808
+	/**
809
+	 * This redirects to the about EE page after activation
810
+	 *
811
+	 * @return void
812
+	 */
813
+	public function redirect_to_about_ee()
814
+	{
815
+		$notices = EE_Error::get_notices(false);
816
+		//if current user is an admin and it's not an ajax or rest request
817
+		if (
818
+			! (defined('DOING_AJAX') && DOING_AJAX)
819
+			&& ! (defined('REST_REQUEST') && REST_REQUEST)
820
+			&& ! isset($notices['errors'])
821
+			&& apply_filters(
822
+				'FHEE__EE_System__redirect_to_about_ee__do_redirect',
823
+				$this->capabilities->current_user_can('manage_options', 'espresso_about_default')
824
+			)
825
+		) {
826
+			$query_params = array('page' => 'espresso_about');
827
+			if (EE_System::instance()->detect_req_type() === EE_System::req_type_new_activation) {
828
+				$query_params['new_activation'] = true;
829
+			}
830
+			if (EE_System::instance()->detect_req_type() === EE_System::req_type_reactivation) {
831
+				$query_params['reactivation'] = true;
832
+			}
833
+			$url = add_query_arg($query_params, admin_url('admin.php'));
834
+			wp_safe_redirect($url);
835
+			exit();
836
+		}
837
+	}
838
+
839
+
840
+	/**
841
+	 * load_core_configuration
842
+	 * this is hooked into 'AHEE__EE_Bootstrap__load_core_configuration'
843
+	 * which runs during the WP 'plugins_loaded' action at priority 5
844
+	 *
845
+	 * @return void
846
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
847
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
848
+	 * @throws \EE_Error
849
+	 * @throws ReflectionException
850
+	 * @throws InvalidArgumentException
851
+	 */
852
+	public function load_core_configuration()
853
+	{
854
+		do_action('AHEE__EE_System__load_core_configuration__begin', $this);
855
+		$this->loader->getShared('EE_Load_Textdomain');
856
+		//load textdomain
857
+		EE_Load_Textdomain::load_textdomain();
858
+		// load and setup EE_Config and EE_Network_Config
859
+		/** @var EE_Config $config */
860
+		$config = $this->loader->getShared('EE_Config');
861
+		if($this->maintenance_mode->models_can_query()){
862
+			$country_model = $this->registry->load_model('Country');
863
+			/** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */
864
+			$table_analysis = $this->loader->getShared('EventEspresso\core\services\database\TableAnalysis');
865
+			if($table_analysis->tableExists($country_model->table())){
866
+				$country = $country_model->get_one_by_ID($config->organization->CNT_ISO);
867
+				if($country instanceof EE_Country) {
868
+					$config->currency->setFromCountry($country);
869
+				}
870
+			}
871
+		}
872
+		$this->loader->getShared('EE_Network_Config');
873
+		// setup autoloaders
874
+		// enable logging?
875
+		if ($config->admin->use_full_logging) {
876
+			$this->loader->getShared('EE_Log');
877
+		}
878
+		// check for activation errors
879
+		$activation_errors = get_option('ee_plugin_activation_errors', false);
880
+		if ($activation_errors) {
881
+			EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__);
882
+			update_option('ee_plugin_activation_errors', false);
883
+		}
884
+		// get model names
885
+		$this->_parse_model_names();
886
+		//load caf stuff a chance to play during the activation process too.
887
+		$this->_maybe_brew_regular();
888
+		do_action('AHEE__EE_System__load_core_configuration__complete', $this);
889
+	}
890
+
891
+
892
+
893
+	/**
894
+	 * cycles through all of the models/*.model.php files, and assembles an array of model names
895
+	 *
896
+	 * @return void
897
+	 * @throws ReflectionException
898
+	 */
899
+	private function _parse_model_names()
900
+	{
901
+		//get all the files in the EE_MODELS folder that end in .model.php
902
+		$models = glob(EE_MODELS . '*.model.php');
903
+		$model_names = array();
904
+		$non_abstract_db_models = array();
905
+		foreach ($models as $model) {
906
+			// get model classname
907
+			$classname = EEH_File::get_classname_from_filepath_with_standard_filename($model);
908
+			$short_name = str_replace('EEM_', '', $classname);
909
+			$reflectionClass = new ReflectionClass($classname);
910
+			if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) {
911
+				$non_abstract_db_models[$short_name] = $classname;
912
+			}
913
+			$model_names[$short_name] = $classname;
914
+		}
915
+		$this->registry->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names);
916
+		$this->registry->non_abstract_db_models = apply_filters(
917
+			'FHEE__EE_System__parse_implemented_model_names',
918
+			$non_abstract_db_models
919
+		);
920
+	}
921
+
922
+
923
+
924
+	/**
925
+	 * The purpose of this method is to simply check for a file named "caffeinated/brewing_regular.php" for any hooks
926
+	 * that need to be setup before our EE_System launches.
927
+	 *
928
+	 * @return void
929
+	 */
930
+	private function _maybe_brew_regular()
931
+	{
932
+		if ((! defined('EE_DECAF') || EE_DECAF !== true) && is_readable(EE_CAFF_PATH . 'brewing_regular.php')) {
933
+			require_once EE_CAFF_PATH . 'brewing_regular.php';
934
+		}
935
+	}
936
+
937
+
938
+
939
+	/**
940
+	 * register_shortcodes_modules_and_widgets
941
+	 * generate lists of shortcodes and modules, then verify paths and classes
942
+	 * This is hooked into 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets'
943
+	 * which runs during the WP 'plugins_loaded' action at priority 7
944
+	 *
945
+	 * @access public
946
+	 * @return void
947
+	 * @throws Exception
948
+	 */
949
+	public function register_shortcodes_modules_and_widgets()
950
+	{
951
+		try {
952
+			// load, register, and add shortcodes the new way
953
+			$this->loader->getShared(
954
+				'EventEspresso\core\services\shortcodes\ShortcodesManager',
955
+				array(
956
+					// and the old way, but we'll put it under control of the new system
957
+					EE_Config::getLegacyShortcodesManager()
958
+				)
959
+			);
960
+		} catch (Exception $exception) {
961
+			new ExceptionStackTraceDisplay($exception);
962
+		}
963
+		do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets');
964
+		// check for addons using old hook point
965
+		if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) {
966
+			$this->_incompatible_addon_error();
967
+		}
968
+	}
969
+
970
+
971
+
972
+	/**
973
+	 * _incompatible_addon_error
974
+	 *
975
+	 * @access public
976
+	 * @return void
977
+	 */
978
+	private function _incompatible_addon_error()
979
+	{
980
+		// get array of classes hooking into here
981
+		$class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook(
982
+			'AHEE__EE_System__register_shortcodes_modules_and_addons'
983
+		);
984
+		if (! empty($class_names)) {
985
+			$msg = __(
986
+				'The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:',
987
+				'event_espresso'
988
+			);
989
+			$msg .= '<ul>';
990
+			foreach ($class_names as $class_name) {
991
+				$msg .= '<li><b>Event Espresso - ' . str_replace(
992
+						array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '',
993
+						$class_name
994
+					) . '</b></li>';
995
+			}
996
+			$msg .= '</ul>';
997
+			$msg .= __(
998
+				'Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.',
999
+				'event_espresso'
1000
+			);
1001
+			// save list of incompatible addons to wp-options for later use
1002
+			add_option('ee_incompatible_addons', $class_names, '', 'no');
1003
+			if (is_admin()) {
1004
+				EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1005
+			}
1006
+		}
1007
+	}
1008
+
1009
+
1010
+
1011
+	/**
1012
+	 * brew_espresso
1013
+	 * begins the process of setting hooks for initializing EE in the correct order
1014
+	 * This is happening on the 'AHEE__EE_Bootstrap__brew_espresso' hook point
1015
+	 * which runs during the WP 'plugins_loaded' action at priority 9
1016
+	 *
1017
+	 * @return void
1018
+	 */
1019
+	public function brew_espresso()
1020
+	{
1021
+		do_action('AHEE__EE_System__brew_espresso__begin', $this);
1022
+		// load some final core systems
1023
+		add_action('init', array($this, 'set_hooks_for_core'), 1);
1024
+		add_action('init', array($this, 'perform_activations_upgrades_and_migrations'), 3);
1025
+		add_action('init', array($this, 'load_CPTs_and_session'), 5);
1026
+		add_action('init', array($this, 'load_controllers'), 7);
1027
+		add_action('init', array($this, 'core_loaded_and_ready'), 9);
1028
+		add_action('init', array($this, 'initialize'), 10);
1029
+		add_action('init', array($this, 'initialize_last'), 100);
1030
+		if (is_admin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', true)) {
1031
+			// pew pew pew
1032
+			$this->loader->getShared('EE_PUE');
1033
+			do_action('AHEE__EE_System__brew_espresso__after_pue_init');
1034
+		}
1035
+		do_action('AHEE__EE_System__brew_espresso__complete', $this);
1036
+	}
1037
+
1038
+
1039
+
1040
+	/**
1041
+	 *    set_hooks_for_core
1042
+	 *
1043
+	 * @access public
1044
+	 * @return    void
1045
+	 * @throws EE_Error
1046
+	 */
1047
+	public function set_hooks_for_core()
1048
+	{
1049
+		$this->_deactivate_incompatible_addons();
1050
+		do_action('AHEE__EE_System__set_hooks_for_core');
1051
+		//caps need to be initialized on every request so that capability maps are set.
1052
+		//@see https://events.codebasehq.com/projects/event-espresso/tickets/8674
1053
+		$this->registry->CAP->init_caps();
1054
+	}
1055
+
1056
+
1057
+
1058
+	/**
1059
+	 * Using the information gathered in EE_System::_incompatible_addon_error,
1060
+	 * deactivates any addons considered incompatible with the current version of EE
1061
+	 */
1062
+	private function _deactivate_incompatible_addons()
1063
+	{
1064
+		$incompatible_addons = get_option('ee_incompatible_addons', array());
1065
+		if (! empty($incompatible_addons)) {
1066
+			$active_plugins = get_option('active_plugins', array());
1067
+			foreach ($active_plugins as $active_plugin) {
1068
+				foreach ($incompatible_addons as $incompatible_addon) {
1069
+					if (strpos($active_plugin, $incompatible_addon) !== false) {
1070
+						unset($_GET['activate']);
1071
+						espresso_deactivate_plugin($active_plugin);
1072
+					}
1073
+				}
1074
+			}
1075
+		}
1076
+	}
1077
+
1078
+
1079
+
1080
+	/**
1081
+	 *    perform_activations_upgrades_and_migrations
1082
+	 *
1083
+	 * @access public
1084
+	 * @return    void
1085
+	 */
1086
+	public function perform_activations_upgrades_and_migrations()
1087
+	{
1088
+		//first check if we had previously attempted to setup EE's directories but failed
1089
+		if (EEH_Activation::upload_directories_incomplete()) {
1090
+			EEH_Activation::create_upload_directories();
1091
+		}
1092
+		do_action('AHEE__EE_System__perform_activations_upgrades_and_migrations');
1093
+	}
1094
+
1095
+
1096
+
1097
+	/**
1098
+	 *    load_CPTs_and_session
1099
+	 *
1100
+	 * @access public
1101
+	 * @return    void
1102
+	 */
1103
+	public function load_CPTs_and_session()
1104
+	{
1105
+		do_action('AHEE__EE_System__load_CPTs_and_session__start');
1106
+		// register Custom Post Types
1107
+		$this->loader->getShared('EE_Register_CPTs');
1108
+		do_action('AHEE__EE_System__load_CPTs_and_session__complete');
1109
+	}
1110
+
1111
+
1112
+
1113
+	/**
1114
+	 * load_controllers
1115
+	 * this is the best place to load any additional controllers that needs access to EE core.
1116
+	 * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this
1117
+	 * time
1118
+	 *
1119
+	 * @access public
1120
+	 * @return void
1121
+	 */
1122
+	public function load_controllers()
1123
+	{
1124
+		do_action('AHEE__EE_System__load_controllers__start');
1125
+		// let's get it started
1126
+		if (! is_admin() && ! $this->maintenance_mode->level()) {
1127
+			do_action('AHEE__EE_System__load_controllers__load_front_controllers');
1128
+			$this->loader->getShared('EE_Front_Controller');
1129
+		} else if (! EE_FRONT_AJAX) {
1130
+			do_action('AHEE__EE_System__load_controllers__load_admin_controllers');
1131
+			$this->loader->getShared('EE_Admin');
1132
+		}
1133
+		do_action('AHEE__EE_System__load_controllers__complete');
1134
+	}
1135
+
1136
+
1137
+
1138
+	/**
1139
+	 * core_loaded_and_ready
1140
+	 * all of the basic EE core should be loaded at this point and available regardless of M-Mode
1141
+	 *
1142
+	 * @access public
1143
+	 * @return void
1144
+	 */
1145
+	public function core_loaded_and_ready()
1146
+	{
1147
+		$this->loader->getShared('EE_Session');
1148
+		do_action('AHEE__EE_System__core_loaded_and_ready');
1149
+		// load_espresso_template_tags
1150
+		if (is_readable(EE_PUBLIC . 'template_tags.php')) {
1151
+			require_once(EE_PUBLIC . 'template_tags.php');
1152
+		}
1153
+		do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons');
1154
+		$this->loader->getShared('EventEspresso\core\services\assets\Registry');
1155
+	}
1156
+
1157
+
1158
+
1159
+	/**
1160
+	 * initialize
1161
+	 * this is the best place to begin initializing client code
1162
+	 *
1163
+	 * @access public
1164
+	 * @return void
1165
+	 */
1166
+	public function initialize()
1167
+	{
1168
+		do_action('AHEE__EE_System__initialize');
1169
+	}
1170
+
1171
+
1172
+
1173
+	/**
1174
+	 * initialize_last
1175
+	 * this is run really late during the WP init hook point, and ensures that mostly everything else that needs to
1176
+	 * initialize has done so
1177
+	 *
1178
+	 * @access public
1179
+	 * @return void
1180
+	 */
1181
+	public function initialize_last()
1182
+	{
1183
+		do_action('AHEE__EE_System__initialize_last');
1184
+		add_action('admin_bar_init', array($this, 'addEspressoToolbar'));
1185
+	}
1186
+
1187
+
1188
+
1189
+	/**
1190
+	 * @return void
1191
+	 * @throws EE_Error
1192
+	 */
1193
+	public function addEspressoToolbar()
1194
+	{
1195
+		$this->loader->getShared(
1196
+			'EventEspresso\core\domain\services\admin\AdminToolBar',
1197
+			array($this->registry->CAP)
1198
+		);
1199
+	}
1200
+
1201
+
1202
+
1203
+	/**
1204
+	 * do_not_cache
1205
+	 * sets no cache headers and defines no cache constants for WP plugins
1206
+	 *
1207
+	 * @access public
1208
+	 * @return void
1209
+	 */
1210
+	public static function do_not_cache()
1211
+	{
1212
+		// set no cache constants
1213
+		if (! defined('DONOTCACHEPAGE')) {
1214
+			define('DONOTCACHEPAGE', true);
1215
+		}
1216
+		if (! defined('DONOTCACHCEOBJECT')) {
1217
+			define('DONOTCACHCEOBJECT', true);
1218
+		}
1219
+		if (! defined('DONOTCACHEDB')) {
1220
+			define('DONOTCACHEDB', true);
1221
+		}
1222
+		// add no cache headers
1223
+		add_action('send_headers', array('EE_System', 'nocache_headers'), 10);
1224
+		// plus a little extra for nginx and Google Chrome
1225
+		add_filter('nocache_headers', array('EE_System', 'extra_nocache_headers'), 10, 1);
1226
+		// prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process
1227
+		remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');
1228
+	}
1229
+
1230
+
1231
+
1232
+	/**
1233
+	 *    extra_nocache_headers
1234
+	 *
1235
+	 * @access    public
1236
+	 * @param $headers
1237
+	 * @return    array
1238
+	 */
1239
+	public static function extra_nocache_headers($headers)
1240
+	{
1241
+		// for NGINX
1242
+		$headers['X-Accel-Expires'] = 0;
1243
+		// plus extra for Google Chrome since it doesn't seem to respect "no-cache", but WILL respect "no-store"
1244
+		$headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0';
1245
+		return $headers;
1246
+	}
1247
+
1248
+
1249
+
1250
+	/**
1251
+	 *    nocache_headers
1252
+	 *
1253
+	 * @access    public
1254
+	 * @return    void
1255
+	 */
1256
+	public static function nocache_headers()
1257
+	{
1258
+		nocache_headers();
1259
+	}
1260
+
1261
+
1262
+
1263
+
1264
+	/**
1265
+	 * simply hooks into "wp_list_pages_exclude" filter (for wp_list_pages method) and makes sure EE critical pages are
1266
+	 * never returned with the function.
1267
+	 *
1268
+	 * @param  array $exclude_array any existing pages being excluded are in this array.
1269
+	 * @return array
1270
+	 */
1271
+	public function remove_pages_from_wp_list_pages($exclude_array)
1272
+	{
1273
+		return array_merge($exclude_array, $this->registry->CFG->core->get_critical_pages_array());
1274
+	}
1275 1275
 
1276 1276
 
1277 1277
 
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
         EE_Maintenance_Mode $maintenance_mode = null
133 133
     ) {
134 134
         // check if class object is instantiated
135
-        if (! self::$_instance instanceof EE_System) {
135
+        if ( ! self::$_instance instanceof EE_System) {
136 136
             self::$_instance = new self($registry, $loader, $capabilities, $request, $maintenance_mode);
137 137
         }
138 138
         return self::$_instance;
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
     {
299 299
         // set autoloaders for all of the classes implementing EEI_Plugin_API
300 300
         // which provide helpers for EE plugin authors to more easily register certain components with EE.
301
-        EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api');
301
+        EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES.'plugin_api');
302 302
     }
303 303
 
304 304
 
@@ -317,14 +317,14 @@  discard block
 block discarded – undo
317 317
         $load_callback,
318 318
         $plugin_file_constant
319 319
     ) {
320
-        if (! defined($version_constant)) {
320
+        if ( ! defined($version_constant)) {
321 321
             return;
322 322
         }
323 323
         $addon_version = constant($version_constant);
324 324
         if ($addon_version && version_compare($addon_version, $min_version_required, '<')) {
325 325
             remove_action('AHEE__EE_System__load_espresso_addons', $load_callback);
326
-            if (! function_exists('deactivate_plugins')) {
327
-                require_once ABSPATH . 'wp-admin/includes/plugin.php';
326
+            if ( ! function_exists('deactivate_plugins')) {
327
+                require_once ABSPATH.'wp-admin/includes/plugin.php';
328 328
             }
329 329
             deactivate_plugins(plugin_basename(constant($plugin_file_constant)));
330 330
             unset($_GET['activate'], $_REQUEST['activate'], $_GET['activate-multi'], $_REQUEST['activate-multi']);
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
                     $addon_name,
338 338
                     $min_version_required
339 339
                 ),
340
-                __FILE__, __FUNCTION__ . "({$addon_name})", __LINE__
340
+                __FILE__, __FUNCTION__."({$addon_name})", __LINE__
341 341
             );
342 342
             EE_Error::get_notices(false, true);
343 343
         }
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
                 && in_array($_GET['action'], array('activate', 'activate-selected'), true)
390 390
             )
391 391
         ) {
392
-            include_once EE_THIRD_PARTY . 'wp-api-basic-auth' . DS . 'basic-auth.php';
392
+            include_once EE_THIRD_PARTY.'wp-api-basic-auth'.DS.'basic-auth.php';
393 393
         }
394 394
         do_action('AHEE__EE_System__load_espresso_addons__complete');
395 395
     }
@@ -497,11 +497,11 @@  discard block
 block discarded – undo
497 497
     private function fix_espresso_db_upgrade_option($espresso_db_update = null)
498 498
     {
499 499
         do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update);
500
-        if (! $espresso_db_update) {
500
+        if ( ! $espresso_db_update) {
501 501
             $espresso_db_update = get_option('espresso_db_update');
502 502
         }
503 503
         // check that option is an array
504
-        if (! is_array($espresso_db_update)) {
504
+        if ( ! is_array($espresso_db_update)) {
505 505
             // if option is FALSE, then it never existed
506 506
             if ($espresso_db_update === false) {
507 507
                 // make $espresso_db_update an array and save option with autoload OFF
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
      */
607 607
     public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null)
608 608
     {
609
-        if (! $version_history) {
609
+        if ( ! $version_history) {
610 610
             $version_history = $this->fix_espresso_db_upgrade_option($version_history);
611 611
         }
612 612
         if ($current_version_to_add === null) {
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
         if ($activation_history_for_addon) {
705 705
             //it exists, so this isn't a completely new install
706 706
             //check if this version already in that list of previously installed versions
707
-            if (! isset($activation_history_for_addon[$version_to_upgrade_to])) {
707
+            if ( ! isset($activation_history_for_addon[$version_to_upgrade_to])) {
708 708
                 //it a version we haven't seen before
709 709
                 if ($version_is_higher === 1) {
710 710
                     $req_type = EE_System::req_type_upgrade;
@@ -784,7 +784,7 @@  discard block
 block discarded – undo
784 784
             foreach ($activation_history as $version => $times_activated) {
785 785
                 //check there is a record of when this version was activated. Otherwise,
786 786
                 //mark it as unknown
787
-                if (! $times_activated) {
787
+                if ( ! $times_activated) {
788 788
                     $times_activated = array('unknown-date');
789 789
                 }
790 790
                 if (is_string($times_activated)) {
@@ -858,13 +858,13 @@  discard block
 block discarded – undo
858 858
         // load and setup EE_Config and EE_Network_Config
859 859
         /** @var EE_Config $config */
860 860
         $config = $this->loader->getShared('EE_Config');
861
-        if($this->maintenance_mode->models_can_query()){
861
+        if ($this->maintenance_mode->models_can_query()) {
862 862
             $country_model = $this->registry->load_model('Country');
863 863
             /** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */
864 864
             $table_analysis = $this->loader->getShared('EventEspresso\core\services\database\TableAnalysis');
865
-            if($table_analysis->tableExists($country_model->table())){
865
+            if ($table_analysis->tableExists($country_model->table())) {
866 866
                 $country = $country_model->get_one_by_ID($config->organization->CNT_ISO);
867
-                if($country instanceof EE_Country) {
867
+                if ($country instanceof EE_Country) {
868 868
                     $config->currency->setFromCountry($country);
869 869
                 }
870 870
             }
@@ -899,7 +899,7 @@  discard block
 block discarded – undo
899 899
     private function _parse_model_names()
900 900
     {
901 901
         //get all the files in the EE_MODELS folder that end in .model.php
902
-        $models = glob(EE_MODELS . '*.model.php');
902
+        $models = glob(EE_MODELS.'*.model.php');
903 903
         $model_names = array();
904 904
         $non_abstract_db_models = array();
905 905
         foreach ($models as $model) {
@@ -929,8 +929,8 @@  discard block
 block discarded – undo
929 929
      */
930 930
     private function _maybe_brew_regular()
931 931
     {
932
-        if ((! defined('EE_DECAF') || EE_DECAF !== true) && is_readable(EE_CAFF_PATH . 'brewing_regular.php')) {
933
-            require_once EE_CAFF_PATH . 'brewing_regular.php';
932
+        if (( ! defined('EE_DECAF') || EE_DECAF !== true) && is_readable(EE_CAFF_PATH.'brewing_regular.php')) {
933
+            require_once EE_CAFF_PATH.'brewing_regular.php';
934 934
         }
935 935
     }
936 936
 
@@ -981,17 +981,17 @@  discard block
 block discarded – undo
981 981
         $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook(
982 982
             'AHEE__EE_System__register_shortcodes_modules_and_addons'
983 983
         );
984
-        if (! empty($class_names)) {
984
+        if ( ! empty($class_names)) {
985 985
             $msg = __(
986 986
                 'The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:',
987 987
                 'event_espresso'
988 988
             );
989 989
             $msg .= '<ul>';
990 990
             foreach ($class_names as $class_name) {
991
-                $msg .= '<li><b>Event Espresso - ' . str_replace(
991
+                $msg .= '<li><b>Event Espresso - '.str_replace(
992 992
                         array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '',
993 993
                         $class_name
994
-                    ) . '</b></li>';
994
+                    ).'</b></li>';
995 995
             }
996 996
             $msg .= '</ul>';
997 997
             $msg .= __(
@@ -1062,7 +1062,7 @@  discard block
 block discarded – undo
1062 1062
     private function _deactivate_incompatible_addons()
1063 1063
     {
1064 1064
         $incompatible_addons = get_option('ee_incompatible_addons', array());
1065
-        if (! empty($incompatible_addons)) {
1065
+        if ( ! empty($incompatible_addons)) {
1066 1066
             $active_plugins = get_option('active_plugins', array());
1067 1067
             foreach ($active_plugins as $active_plugin) {
1068 1068
                 foreach ($incompatible_addons as $incompatible_addon) {
@@ -1123,10 +1123,10 @@  discard block
 block discarded – undo
1123 1123
     {
1124 1124
         do_action('AHEE__EE_System__load_controllers__start');
1125 1125
         // let's get it started
1126
-        if (! is_admin() && ! $this->maintenance_mode->level()) {
1126
+        if ( ! is_admin() && ! $this->maintenance_mode->level()) {
1127 1127
             do_action('AHEE__EE_System__load_controllers__load_front_controllers');
1128 1128
             $this->loader->getShared('EE_Front_Controller');
1129
-        } else if (! EE_FRONT_AJAX) {
1129
+        } else if ( ! EE_FRONT_AJAX) {
1130 1130
             do_action('AHEE__EE_System__load_controllers__load_admin_controllers');
1131 1131
             $this->loader->getShared('EE_Admin');
1132 1132
         }
@@ -1147,8 +1147,8 @@  discard block
 block discarded – undo
1147 1147
         $this->loader->getShared('EE_Session');
1148 1148
         do_action('AHEE__EE_System__core_loaded_and_ready');
1149 1149
         // load_espresso_template_tags
1150
-        if (is_readable(EE_PUBLIC . 'template_tags.php')) {
1151
-            require_once(EE_PUBLIC . 'template_tags.php');
1150
+        if (is_readable(EE_PUBLIC.'template_tags.php')) {
1151
+            require_once(EE_PUBLIC.'template_tags.php');
1152 1152
         }
1153 1153
         do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons');
1154 1154
         $this->loader->getShared('EventEspresso\core\services\assets\Registry');
@@ -1210,13 +1210,13 @@  discard block
 block discarded – undo
1210 1210
     public static function do_not_cache()
1211 1211
     {
1212 1212
         // set no cache constants
1213
-        if (! defined('DONOTCACHEPAGE')) {
1213
+        if ( ! defined('DONOTCACHEPAGE')) {
1214 1214
             define('DONOTCACHEPAGE', true);
1215 1215
         }
1216
-        if (! defined('DONOTCACHCEOBJECT')) {
1216
+        if ( ! defined('DONOTCACHCEOBJECT')) {
1217 1217
             define('DONOTCACHCEOBJECT', true);
1218 1218
         }
1219
-        if (! defined('DONOTCACHEDB')) {
1219
+        if ( ! defined('DONOTCACHEDB')) {
1220 1220
             define('DONOTCACHEDB', true);
1221 1221
         }
1222 1222
         // add no cache headers
Please login to merge, or discard this patch.
core/EE_Config.core.php 2 patches
Indentation   +3075 added lines, -3075 removed lines patch added patch discarded remove patch
@@ -20,2457 +20,2457 @@  discard block
 block discarded – undo
20 20
 final class EE_Config implements ResettableInterface
21 21
 {
22 22
 
23
-    const OPTION_NAME        = 'ee_config';
23
+	const OPTION_NAME        = 'ee_config';
24
+
25
+	const LOG_NAME           = 'ee_config_log';
26
+
27
+	const LOG_LENGTH         = 100;
28
+
29
+	const ADDON_OPTION_NAMES = 'ee_config_option_names';
30
+
31
+
32
+	/**
33
+	 *    instance of the EE_Config object
34
+	 *
35
+	 * @var    EE_Config $_instance
36
+	 * @access    private
37
+	 */
38
+	private static $_instance;
39
+
40
+	/**
41
+	 * @var boolean $_logging_enabled
42
+	 */
43
+	private static $_logging_enabled = false;
44
+
45
+	/**
46
+	 * @var LegacyShortcodesManager $legacy_shortcodes_manager
47
+	 */
48
+	private $legacy_shortcodes_manager;
49
+
50
+	/**
51
+	 * An StdClass whose property names are addon slugs,
52
+	 * and values are their config classes
53
+	 *
54
+	 * @var StdClass
55
+	 */
56
+	public $addons;
57
+
58
+	/**
59
+	 * @var EE_Admin_Config
60
+	 */
61
+	public $admin;
62
+
63
+	/**
64
+	 * @var EE_Core_Config
65
+	 */
66
+	public $core;
67
+
68
+	/**
69
+	 * @var EE_Currency_Config
70
+	 */
71
+	public $currency;
72
+
73
+	/**
74
+	 * @var EE_Organization_Config
75
+	 */
76
+	public $organization;
77
+
78
+	/**
79
+	 * @var EE_Registration_Config
80
+	 */
81
+	public $registration;
82
+
83
+	/**
84
+	 * @var EE_Template_Config
85
+	 */
86
+	public $template_settings;
87
+
88
+	/**
89
+	 * Holds EE environment values.
90
+	 *
91
+	 * @var EE_Environment_Config
92
+	 */
93
+	public $environment;
94
+
95
+	/**
96
+	 * settings pertaining to Google maps
97
+	 *
98
+	 * @var EE_Map_Config
99
+	 */
100
+	public $map_settings;
101
+
102
+	/**
103
+	 * settings pertaining to Taxes
104
+	 *
105
+	 * @var EE_Tax_Config
106
+	 */
107
+	public $tax_settings;
108
+
109
+
110
+	/**
111
+	 * Settings pertaining to global messages settings.
112
+	 *
113
+	 * @var EE_Messages_Config
114
+	 */
115
+	public $messages;
116
+
117
+	/**
118
+	 * @deprecated
119
+	 * @var EE_Gateway_Config
120
+	 */
121
+	public $gateway;
122
+
123
+	/**
124
+	 * @var    array $_addon_option_names
125
+	 * @access    private
126
+	 */
127
+	private $_addon_option_names = array();
128
+
129
+	/**
130
+	 * @var    array $_module_route_map
131
+	 * @access    private
132
+	 */
133
+	private static $_module_route_map = array();
134
+
135
+	/**
136
+	 * @var    array $_module_forward_map
137
+	 * @access    private
138
+	 */
139
+	private static $_module_forward_map = array();
140
+
141
+	/**
142
+	 * @var    array $_module_view_map
143
+	 * @access    private
144
+	 */
145
+	private static $_module_view_map = array();
146
+
147
+
148
+
149
+	/**
150
+	 * @singleton method used to instantiate class object
151
+	 * @access    public
152
+	 * @return EE_Config instance
153
+	 */
154
+	public static function instance()
155
+	{
156
+		// check if class object is instantiated, and instantiated properly
157
+		if (! self::$_instance instanceof EE_Config) {
158
+			self::$_instance = new self();
159
+		}
160
+		return self::$_instance;
161
+	}
162
+
163
+
164
+
165
+	/**
166
+	 * Resets the config
167
+	 *
168
+	 * @param bool    $hard_reset    if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE
169
+	 *                               (default) leaves the database alone, and merely resets the EE_Config object to
170
+	 *                               reflect its state in the database
171
+	 * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave
172
+	 *                               $_instance as NULL. Useful in case you want to forget about the old instance on
173
+	 *                               EE_Config, but might not be ready to instantiate EE_Config currently (eg if the
174
+	 *                               site was put into maintenance mode)
175
+	 * @return EE_Config
176
+	 */
177
+	public static function reset($hard_reset = false, $reinstantiate = true)
178
+	{
179
+		if (self::$_instance instanceof EE_Config) {
180
+			if ($hard_reset) {
181
+				self::$_instance->legacy_shortcodes_manager = null;
182
+				self::$_instance->_addon_option_names = array();
183
+				self::$_instance->_initialize_config();
184
+				self::$_instance->update_espresso_config();
185
+			}
186
+			self::$_instance->update_addon_option_names();
187
+		}
188
+		self::$_instance = null;
189
+		//we don't need to reset the static properties imo because those should
190
+		//only change when a module is added or removed. Currently we don't
191
+		//support removing a module during a request when it previously existed
192
+		if ($reinstantiate) {
193
+			return self::instance();
194
+		} else {
195
+			return null;
196
+		}
197
+	}
198
+
199
+
200
+
201
+	/**
202
+	 *    class constructor
203
+	 *
204
+	 * @access    private
205
+	 */
206
+	private function __construct()
207
+	{
208
+		do_action('AHEE__EE_Config__construct__begin', $this);
209
+		EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false);
210
+		// setup empty config classes
211
+		$this->_initialize_config();
212
+		// load existing EE site settings
213
+		$this->_load_core_config();
214
+		// confirm everything loaded correctly and set filtered defaults if not
215
+		$this->_verify_config();
216
+		//  register shortcodes and modules
217
+		add_action(
218
+			'AHEE__EE_System__register_shortcodes_modules_and_widgets',
219
+			array($this, 'register_shortcodes_and_modules'),
220
+			999
221
+		);
222
+		//  initialize shortcodes and modules
223
+		add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules'));
224
+		// register widgets
225
+		add_action('widgets_init', array($this, 'widgets_init'), 10);
226
+		// shutdown
227
+		add_action('shutdown', array($this, 'shutdown'), 10);
228
+		// construct__end hook
229
+		do_action('AHEE__EE_Config__construct__end', $this);
230
+		// hardcoded hack
231
+		$this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014';
232
+	}
233
+
234
+
235
+
236
+	/**
237
+	 * @return boolean
238
+	 */
239
+	public static function logging_enabled()
240
+	{
241
+		return self::$_logging_enabled;
242
+	}
243
+
244
+
245
+
246
+	/**
247
+	 * use to get the current theme if needed from static context
248
+	 *
249
+	 * @return string current theme set.
250
+	 */
251
+	public static function get_current_theme()
252
+	{
253
+		return isset(self::$_instance->template_settings->current_espresso_theme)
254
+			? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014';
255
+	}
256
+
257
+
258
+
259
+	/**
260
+	 *        _initialize_config
261
+	 *
262
+	 * @access private
263
+	 * @return void
264
+	 */
265
+	private function _initialize_config()
266
+	{
267
+		EE_Config::trim_log();
268
+		//set defaults
269
+		$this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array());
270
+		$this->addons = new stdClass();
271
+		// set _module_route_map
272
+		EE_Config::$_module_route_map = array();
273
+		// set _module_forward_map
274
+		EE_Config::$_module_forward_map = array();
275
+		// set _module_view_map
276
+		EE_Config::$_module_view_map = array();
277
+	}
278
+
279
+
280
+
281
+	/**
282
+	 *        load core plugin configuration
283
+	 *
284
+	 * @access private
285
+	 * @return void
286
+	 */
287
+	private function _load_core_config()
288
+	{
289
+		// load_core_config__start hook
290
+		do_action('AHEE__EE_Config___load_core_config__start', $this);
291
+		$espresso_config = $this->get_espresso_config();
292
+		foreach ($espresso_config as $config => $settings) {
293
+			// load_core_config__start hook
294
+			$settings = apply_filters(
295
+				'FHEE__EE_Config___load_core_config__config_settings',
296
+				$settings,
297
+				$config,
298
+				$this
299
+			);
300
+			if (is_object($settings) && property_exists($this, $config)) {
301
+				$this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings);
302
+				//call configs populate method to ensure any defaults are set for empty values.
303
+				if (method_exists($settings, 'populate')) {
304
+					$this->{$config}->populate();
305
+				}
306
+				if (method_exists($settings, 'do_hooks')) {
307
+					$this->{$config}->do_hooks();
308
+				}
309
+			}
310
+		}
311
+		if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) {
312
+			$this->update_espresso_config();
313
+		}
314
+		// load_core_config__end hook
315
+		do_action('AHEE__EE_Config___load_core_config__end', $this);
316
+	}
317
+
318
+
319
+	/**
320
+	 * @return void
321
+	 * @throws ReflectionException
322
+	 * @throws InvalidArgumentException
323
+	 * @throws InvalidInterfaceException
324
+	 * @throws InvalidDataTypeException
325
+	 * @throws EE_Error
326
+	 */
327
+	protected function _verify_config()
328
+	{
329
+		$this->core = $this->core instanceof EE_Core_Config
330
+			? $this->core
331
+			: new EE_Core_Config();
332
+		$this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core);
333
+		$this->organization = $this->organization instanceof EE_Organization_Config
334
+			? $this->organization
335
+			: new EE_Organization_Config();
336
+		$this->organization = apply_filters(
337
+			'FHEE__EE_Config___initialize_config__organization',
338
+			$this->organization
339
+		);
340
+		$this->currency = $this->currency instanceof EE_Currency_Config
341
+			? $this->currency
342
+			: new EE_Currency_Config($this->organization->CNT_ISO);
343
+		$this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency);
344
+		$this->registration = $this->registration instanceof EE_Registration_Config
345
+			? $this->registration
346
+			: new EE_Registration_Config();
347
+		$this->registration = apply_filters(
348
+			'FHEE__EE_Config___initialize_config__registration',
349
+			$this->registration
350
+		);
351
+		$this->admin = $this->admin instanceof EE_Admin_Config
352
+			? $this->admin
353
+			: new EE_Admin_Config();
354
+		$this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin);
355
+		$this->template_settings = $this->template_settings instanceof EE_Template_Config
356
+			? $this->template_settings
357
+			: new EE_Template_Config();
358
+		$this->template_settings = apply_filters(
359
+			'FHEE__EE_Config___initialize_config__template_settings',
360
+			$this->template_settings
361
+		);
362
+		$this->map_settings = $this->map_settings instanceof EE_Map_Config
363
+			? $this->map_settings
364
+			: new EE_Map_Config();
365
+		$this->map_settings = apply_filters('FHEE__EE_Config___initialize_config__map_settings',
366
+			$this->map_settings);
367
+		$this->environment = $this->environment instanceof EE_Environment_Config
368
+			? $this->environment
369
+			: new EE_Environment_Config();
370
+		$this->environment = apply_filters('FHEE__EE_Config___initialize_config__environment',
371
+			$this->environment);
372
+		$this->tax_settings = $this->tax_settings instanceof EE_Tax_Config
373
+			? $this->tax_settings
374
+			: new EE_Tax_Config();
375
+		$this->tax_settings = apply_filters('FHEE__EE_Config___initialize_config__tax_settings',
376
+			$this->tax_settings);
377
+		$this->messages = apply_filters('FHEE__EE_Config__initialize_config__messages', $this->messages);
378
+		$this->messages = $this->messages instanceof EE_Messages_Config
379
+			? $this->messages
380
+			: new EE_Messages_Config();
381
+		$this->gateway = $this->gateway instanceof EE_Gateway_Config
382
+			? $this->gateway
383
+			: new EE_Gateway_Config();
384
+		$this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway);
385
+		$this->legacy_shortcodes_manager = null;
386
+	}
387
+
388
+
389
+	/**
390
+	 *    get_espresso_config
391
+	 *
392
+	 * @access    public
393
+	 * @return    array of espresso config stuff
394
+	 */
395
+	public function get_espresso_config()
396
+	{
397
+		// grab espresso configuration
398
+		return apply_filters(
399
+			'FHEE__EE_Config__get_espresso_config__CFG',
400
+			get_option(EE_Config::OPTION_NAME, array())
401
+		);
402
+	}
403
+
404
+
405
+
406
+	/**
407
+	 *    double_check_config_comparison
408
+	 *
409
+	 * @access    public
410
+	 * @param string $option
411
+	 * @param        $old_value
412
+	 * @param        $value
413
+	 */
414
+	public function double_check_config_comparison($option = '', $old_value, $value)
415
+	{
416
+		// make sure we're checking the ee config
417
+		if ($option === EE_Config::OPTION_NAME) {
418
+			// run a loose comparison of the old value against the new value for type and properties,
419
+			// but NOT exact instance like WP update_option does (ie: NOT type safe comparison)
420
+			if ($value != $old_value) {
421
+				// if they are NOT the same, then remove the hook,
422
+				// which means the subsequent update results will be based solely on the update query results
423
+				// the reason we do this is because, as stated above,
424
+				// WP update_option performs an exact instance comparison (===) on any update values passed to it
425
+				// this happens PRIOR to serialization and any subsequent update.
426
+				// If values are found to match their previous old value,
427
+				// then WP bails before performing any update.
428
+				// Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version
429
+				// it just pulled from the db, with the one being passed to it (which will not match).
430
+				// HOWEVER, once the object is serialized and passed off to MySQL to update,
431
+				// MySQL MAY ALSO NOT perform the update because
432
+				// the string it sees in the db looks the same as the new one it has been passed!!!
433
+				// This results in the query returning an "affected rows" value of ZERO,
434
+				// which gets returned immediately by WP update_option and looks like an error.
435
+				remove_action('update_option', array($this, 'check_config_updated'));
436
+			}
437
+		}
438
+	}
439
+
440
+
441
+
442
+	/**
443
+	 *    update_espresso_config
444
+	 *
445
+	 * @access   public
446
+	 */
447
+	protected function _reset_espresso_addon_config()
448
+	{
449
+		$this->_addon_option_names = array();
450
+		foreach ($this->addons as $addon_name => $addon_config_obj) {
451
+			$addon_config_obj = maybe_unserialize($addon_config_obj);
452
+			$config_class = get_class($addon_config_obj);
453
+			if ($addon_config_obj instanceof $config_class && ! $addon_config_obj instanceof __PHP_Incomplete_Class) {
454
+				$this->update_config('addons', $addon_name, $addon_config_obj, false);
455
+			}
456
+			$this->addons->{$addon_name} = null;
457
+		}
458
+	}
459
+
460
+
461
+
462
+	/**
463
+	 *    update_espresso_config
464
+	 *
465
+	 * @access   public
466
+	 * @param   bool $add_success
467
+	 * @param   bool $add_error
468
+	 * @return   bool
469
+	 */
470
+	public function update_espresso_config($add_success = false, $add_error = true)
471
+	{
472
+		// don't allow config updates during WP heartbeats
473
+		if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
474
+			return false;
475
+		}
476
+		// commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197
477
+		//$clone = clone( self::$_instance );
478
+		//self::$_instance = NULL;
479
+		do_action('AHEE__EE_Config__update_espresso_config__begin', $this);
480
+		$this->_reset_espresso_addon_config();
481
+		// hook into update_option because that happens AFTER the ( $value === $old_value ) conditional
482
+		// but BEFORE the actual update occurs
483
+		add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3);
484
+		// don't want to persist legacy_shortcodes_manager, but don't want to lose it either
485
+		$legacy_shortcodes_manager = $this->legacy_shortcodes_manager;
486
+		$this->legacy_shortcodes_manager = null;
487
+		// now update "ee_config"
488
+		$saved = update_option(EE_Config::OPTION_NAME, $this);
489
+		$this->legacy_shortcodes_manager = $legacy_shortcodes_manager;
490
+		EE_Config::log(EE_Config::OPTION_NAME);
491
+		// if not saved... check if the hook we just added still exists;
492
+		// if it does, it means one of two things:
493
+		// 		that update_option bailed at the ( $value === $old_value ) conditional,
494
+		//		 or...
495
+		// 		the db update query returned 0 rows affected
496
+		// 		(probably because the data  value was the same from it's perspective)
497
+		// so the existence of the hook means that a negative result from update_option is NOT an error,
498
+		// but just means no update occurred, so don't display an error to the user.
499
+		// BUT... if update_option returns FALSE, AND the hook is missing,
500
+		// then it means that something truly went wrong
501
+		$saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved;
502
+		// remove our action since we don't want it in the system anymore
503
+		remove_action('update_option', array($this, 'double_check_config_comparison'), 1);
504
+		do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved);
505
+		//self::$_instance = $clone;
506
+		//unset( $clone );
507
+		// if config remains the same or was updated successfully
508
+		if ($saved) {
509
+			if ($add_success) {
510
+				EE_Error::add_success(
511
+					__('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'),
512
+					__FILE__,
513
+					__FUNCTION__,
514
+					__LINE__
515
+				);
516
+			}
517
+			return true;
518
+		} else {
519
+			if ($add_error) {
520
+				EE_Error::add_error(
521
+					__('The Event Espresso Configuration Settings were not updated.', 'event_espresso'),
522
+					__FILE__,
523
+					__FUNCTION__,
524
+					__LINE__
525
+				);
526
+			}
527
+			return false;
528
+		}
529
+	}
530
+
531
+
532
+
533
+	/**
534
+	 *    _verify_config_params
535
+	 *
536
+	 * @access    private
537
+	 * @param    string         $section
538
+	 * @param    string         $name
539
+	 * @param    string         $config_class
540
+	 * @param    EE_Config_Base $config_obj
541
+	 * @param    array          $tests_to_run
542
+	 * @param    bool           $display_errors
543
+	 * @return    bool    TRUE on success, FALSE on fail
544
+	 */
545
+	private function _verify_config_params(
546
+		$section = '',
547
+		$name = '',
548
+		$config_class = '',
549
+		$config_obj = null,
550
+		$tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8),
551
+		$display_errors = true
552
+	) {
553
+		try {
554
+			foreach ($tests_to_run as $test) {
555
+				switch ($test) {
556
+					// TEST #1 : check that section was set
557
+					case 1 :
558
+						if (empty($section)) {
559
+							if ($display_errors) {
560
+								throw new EE_Error(
561
+									sprintf(
562
+										__(
563
+											'No configuration section has been provided while attempting to save "%s".',
564
+											'event_espresso'
565
+										),
566
+										$config_class
567
+									)
568
+								);
569
+							}
570
+							return false;
571
+						}
572
+						break;
573
+					// TEST #2 : check that settings section exists
574
+					case 2 :
575
+						if (! isset($this->{$section})) {
576
+							if ($display_errors) {
577
+								throw new EE_Error(
578
+									sprintf(
579
+										__('The "%s" configuration section does not exist.', 'event_espresso'),
580
+										$section
581
+									)
582
+								);
583
+							}
584
+							return false;
585
+						}
586
+						break;
587
+					// TEST #3 : check that section is the proper format
588
+					case 3 :
589
+						if (
590
+						! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass)
591
+						) {
592
+							if ($display_errors) {
593
+								throw new EE_Error(
594
+									sprintf(
595
+										__(
596
+											'The "%s" configuration settings have not been formatted correctly.',
597
+											'event_espresso'
598
+										),
599
+										$section
600
+									)
601
+								);
602
+							}
603
+							return false;
604
+						}
605
+						break;
606
+					// TEST #4 : check that config section name has been set
607
+					case 4 :
608
+						if (empty($name)) {
609
+							if ($display_errors) {
610
+								throw new EE_Error(
611
+									__(
612
+										'No name has been provided for the specific configuration section.',
613
+										'event_espresso'
614
+									)
615
+								);
616
+							}
617
+							return false;
618
+						}
619
+						break;
620
+					// TEST #5 : check that a config class name has been set
621
+					case 5 :
622
+						if (empty($config_class)) {
623
+							if ($display_errors) {
624
+								throw new EE_Error(
625
+									__(
626
+										'No class name has been provided for the specific configuration section.',
627
+										'event_espresso'
628
+									)
629
+								);
630
+							}
631
+							return false;
632
+						}
633
+						break;
634
+					// TEST #6 : verify config class is accessible
635
+					case 6 :
636
+						if (! class_exists($config_class)) {
637
+							if ($display_errors) {
638
+								throw new EE_Error(
639
+									sprintf(
640
+										__(
641
+											'The "%s" class does not exist. Please ensure that an autoloader has been set for it.',
642
+											'event_espresso'
643
+										),
644
+										$config_class
645
+									)
646
+								);
647
+							}
648
+							return false;
649
+						}
650
+						break;
651
+					// TEST #7 : check that config has even been set
652
+					case 7 :
653
+						if (! isset($this->{$section}->{$name})) {
654
+							if ($display_errors) {
655
+								throw new EE_Error(
656
+									sprintf(
657
+										__('No configuration has been set for "%1$s->%2$s".', 'event_espresso'),
658
+										$section,
659
+										$name
660
+									)
661
+								);
662
+							}
663
+							return false;
664
+						} else {
665
+							// and make sure it's not serialized
666
+							$this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name});
667
+						}
668
+						break;
669
+					// TEST #8 : check that config is the requested type
670
+					case 8 :
671
+						if (! $this->{$section}->{$name} instanceof $config_class) {
672
+							if ($display_errors) {
673
+								throw new EE_Error(
674
+									sprintf(
675
+										__(
676
+											'The configuration for "%1$s->%2$s" is not of the "%3$s" class.',
677
+											'event_espresso'
678
+										),
679
+										$section,
680
+										$name,
681
+										$config_class
682
+									)
683
+								);
684
+							}
685
+							return false;
686
+						}
687
+						break;
688
+					// TEST #9 : verify config object
689
+					case 9 :
690
+						if (! $config_obj instanceof EE_Config_Base) {
691
+							if ($display_errors) {
692
+								throw new EE_Error(
693
+									sprintf(
694
+										__('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'),
695
+										print_r($config_obj, true)
696
+									)
697
+								);
698
+							}
699
+							return false;
700
+						}
701
+						break;
702
+				}
703
+			}
704
+		} catch (EE_Error $e) {
705
+			$e->get_error();
706
+		}
707
+		// you have successfully run the gauntlet
708
+		return true;
709
+	}
710
+
711
+
712
+
713
+	/**
714
+	 *    _generate_config_option_name
715
+	 *
716
+	 * @access        protected
717
+	 * @param        string $section
718
+	 * @param        string $name
719
+	 * @return        string
720
+	 */
721
+	private function _generate_config_option_name($section = '', $name = '')
722
+	{
723
+		return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name));
724
+	}
725
+
726
+
727
+
728
+	/**
729
+	 *    _set_config_class
730
+	 * ensures that a config class is set, either from a passed config class or one generated from the config name
731
+	 *
732
+	 * @access    private
733
+	 * @param    string $config_class
734
+	 * @param    string $name
735
+	 * @return    string
736
+	 */
737
+	private function _set_config_class($config_class = '', $name = '')
738
+	{
739
+		return ! empty($config_class)
740
+			? $config_class
741
+			: str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config';
742
+	}
743
+
744
+
745
+
746
+	/**
747
+	 *    set_config
748
+	 *
749
+	 * @access    protected
750
+	 * @param    string         $section
751
+	 * @param    string         $name
752
+	 * @param    string         $config_class
753
+	 * @param    EE_Config_Base $config_obj
754
+	 * @return    EE_Config_Base
755
+	 */
756
+	public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null)
757
+	{
758
+		// ensure config class is set to something
759
+		$config_class = $this->_set_config_class($config_class, $name);
760
+		// run tests 1-4, 6, and 7 to verify all config params are set and valid
761
+		if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
762
+			return null;
763
+		}
764
+		$config_option_name = $this->_generate_config_option_name($section, $name);
765
+		// if the config option name hasn't been added yet to the list of option names we're tracking, then do so now
766
+		if (! isset($this->_addon_option_names[$config_option_name])) {
767
+			$this->_addon_option_names[$config_option_name] = $config_class;
768
+			$this->update_addon_option_names();
769
+		}
770
+		// verify the incoming config object but suppress errors
771
+		if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
772
+			$config_obj = new $config_class();
773
+		}
774
+		if (get_option($config_option_name)) {
775
+			EE_Config::log($config_option_name);
776
+			update_option($config_option_name, $config_obj);
777
+			$this->{$section}->{$name} = $config_obj;
778
+			return $this->{$section}->{$name};
779
+		} else {
780
+			// create a wp-option for this config
781
+			if (add_option($config_option_name, $config_obj, '', 'no')) {
782
+				$this->{$section}->{$name} = maybe_unserialize($config_obj);
783
+				return $this->{$section}->{$name};
784
+			} else {
785
+				EE_Error::add_error(
786
+					sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class),
787
+					__FILE__,
788
+					__FUNCTION__,
789
+					__LINE__
790
+				);
791
+				return null;
792
+			}
793
+		}
794
+	}
795
+
796
+
797
+
798
+	/**
799
+	 *    update_config
800
+	 * Important: the config object must ALREADY be set, otherwise this will produce an error.
801
+	 *
802
+	 * @access    public
803
+	 * @param    string                $section
804
+	 * @param    string                $name
805
+	 * @param    EE_Config_Base|string $config_obj
806
+	 * @param    bool                  $throw_errors
807
+	 * @return    bool
808
+	 */
809
+	public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true)
810
+	{
811
+		// don't allow config updates during WP heartbeats
812
+		if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
813
+			return false;
814
+		}
815
+		$config_obj = maybe_unserialize($config_obj);
816
+		// get class name of the incoming object
817
+		$config_class = get_class($config_obj);
818
+		// run tests 1-5 and 9 to verify config
819
+		if (! $this->_verify_config_params(
820
+			$section,
821
+			$name,
822
+			$config_class,
823
+			$config_obj,
824
+			array(1, 2, 3, 4, 7, 9)
825
+		)
826
+		) {
827
+			return false;
828
+		}
829
+		$config_option_name = $this->_generate_config_option_name($section, $name);
830
+		// check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
831
+		if (! isset($this->_addon_option_names[$config_option_name])) {
832
+			// save new config to db
833
+			if ($this->set_config($section, $name, $config_class, $config_obj)) {
834
+				return true;
835
+			}
836
+		} else {
837
+			// first check if the record already exists
838
+			$existing_config = get_option($config_option_name);
839
+			$config_obj = serialize($config_obj);
840
+			// just return if db record is already up to date (NOT type safe comparison)
841
+			if ($existing_config == $config_obj) {
842
+				$this->{$section}->{$name} = $config_obj;
843
+				return true;
844
+			} else if (update_option($config_option_name, $config_obj)) {
845
+				EE_Config::log($config_option_name);
846
+				// update wp-option for this config class
847
+				$this->{$section}->{$name} = $config_obj;
848
+				return true;
849
+			} elseif ($throw_errors) {
850
+				EE_Error::add_error(
851
+					sprintf(
852
+						__(
853
+							'The "%1$s" object stored at"%2$s" was not successfully updated in the database.',
854
+							'event_espresso'
855
+						),
856
+						$config_class,
857
+						'EE_Config->' . $section . '->' . $name
858
+					),
859
+					__FILE__,
860
+					__FUNCTION__,
861
+					__LINE__
862
+				);
863
+			}
864
+		}
865
+		return false;
866
+	}
867
+
868
+
869
+
870
+	/**
871
+	 *    get_config
872
+	 *
873
+	 * @access    public
874
+	 * @param    string $section
875
+	 * @param    string $name
876
+	 * @param    string $config_class
877
+	 * @return    mixed EE_Config_Base | NULL
878
+	 */
879
+	public function get_config($section = '', $name = '', $config_class = '')
880
+	{
881
+		// ensure config class is set to something
882
+		$config_class = $this->_set_config_class($config_class, $name);
883
+		// run tests 1-4, 6 and 7 to verify that all params have been set
884
+		if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
885
+			return null;
886
+		}
887
+		// now test if the requested config object exists, but suppress errors
888
+		if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) {
889
+			// config already exists, so pass it back
890
+			return $this->{$section}->{$name};
891
+		}
892
+		// load config option from db if it exists
893
+		$config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name));
894
+		// verify the newly retrieved config object, but suppress errors
895
+		if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
896
+			// config is good, so set it and pass it back
897
+			$this->{$section}->{$name} = $config_obj;
898
+			return $this->{$section}->{$name};
899
+		}
900
+		// oops! $config_obj is not already set and does not exist in the db, so create a new one
901
+		$config_obj = $this->set_config($section, $name, $config_class);
902
+		// verify the newly created config object
903
+		if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) {
904
+			return $this->{$section}->{$name};
905
+		} else {
906
+			EE_Error::add_error(
907
+				sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class),
908
+				__FILE__,
909
+				__FUNCTION__,
910
+				__LINE__
911
+			);
912
+		}
913
+		return null;
914
+	}
915
+
916
+
917
+
918
+	/**
919
+	 *    get_config_option
920
+	 *
921
+	 * @access    public
922
+	 * @param    string $config_option_name
923
+	 * @return    mixed EE_Config_Base | FALSE
924
+	 */
925
+	public function get_config_option($config_option_name = '')
926
+	{
927
+		// retrieve the wp-option for this config class.
928
+		$config_option = maybe_unserialize(get_option($config_option_name, array()));
929
+		if (empty($config_option)) {
930
+			EE_Config::log($config_option_name . '-NOT-FOUND');
931
+		}
932
+		return $config_option;
933
+	}
934
+
935
+
936
+
937
+	/**
938
+	 * log
939
+	 *
940
+	 * @param string $config_option_name
941
+	 */
942
+	public static function log($config_option_name = '')
943
+	{
944
+		if (EE_Config::logging_enabled() && ! empty($config_option_name)) {
945
+			$config_log = get_option(EE_Config::LOG_NAME, array());
946
+			//copy incoming $_REQUEST and sanitize it so we can save it
947
+			$_request = $_REQUEST;
948
+			array_walk_recursive($_request, 'sanitize_text_field');
949
+			$config_log[(string)microtime(true)] = array(
950
+				'config_name' => $config_option_name,
951
+				'request'     => $_request,
952
+			);
953
+			update_option(EE_Config::LOG_NAME, $config_log);
954
+		}
955
+	}
956
+
957
+
958
+
959
+	/**
960
+	 * trim_log
961
+	 * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH
962
+	 */
963
+	public static function trim_log()
964
+	{
965
+		if (! EE_Config::logging_enabled()) {
966
+			return;
967
+		}
968
+		$config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
969
+		$log_length = count($config_log);
970
+		if ($log_length > EE_Config::LOG_LENGTH) {
971
+			ksort($config_log);
972
+			$config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true);
973
+			update_option(EE_Config::LOG_NAME, $config_log);
974
+		}
975
+	}
976
+
977
+
978
+
979
+	/**
980
+	 *    get_page_for_posts
981
+	 *    if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the
982
+	 *    wp-option "page_for_posts", or "posts" if no page is selected
983
+	 *
984
+	 * @access    public
985
+	 * @return    string
986
+	 */
987
+	public static function get_page_for_posts()
988
+	{
989
+		$page_for_posts = get_option('page_for_posts');
990
+		if (! $page_for_posts) {
991
+			return 'posts';
992
+		}
993
+		/** @type WPDB $wpdb */
994
+		global $wpdb;
995
+		$SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d";
996
+		return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts));
997
+	}
998
+
999
+
1000
+
1001
+	/**
1002
+	 *    register_shortcodes_and_modules.
1003
+	 *    At this point, it's too early to tell if we're maintenance mode or not.
1004
+	 *    In fact, this is where we give modules a chance to let core know they exist
1005
+	 *    so they can help trigger maintenance mode if it's needed
1006
+	 *
1007
+	 * @access    public
1008
+	 * @return    void
1009
+	 */
1010
+	public function register_shortcodes_and_modules()
1011
+	{
1012
+		// allow modules to set hooks for the rest of the system
1013
+		EE_Registry::instance()->modules = $this->_register_modules();
1014
+	}
1015
+
1016
+
1017
+
1018
+	/**
1019
+	 *    initialize_shortcodes_and_modules
1020
+	 *    meaning they can start adding their hooks to get stuff done
1021
+	 *
1022
+	 * @access    public
1023
+	 * @return    void
1024
+	 */
1025
+	public function initialize_shortcodes_and_modules()
1026
+	{
1027
+		// allow modules to set hooks for the rest of the system
1028
+		$this->_initialize_modules();
1029
+	}
1030
+
1031
+
1032
+
1033
+	/**
1034
+	 *    widgets_init
1035
+	 *
1036
+	 * @access private
1037
+	 * @return void
1038
+	 */
1039
+	public function widgets_init()
1040
+	{
1041
+		//only init widgets on admin pages when not in complete maintenance, and
1042
+		//on frontend when not in any maintenance mode
1043
+		if (
1044
+			! EE_Maintenance_Mode::instance()->level()
1045
+			|| (
1046
+				is_admin()
1047
+				&& EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance
1048
+			)
1049
+		) {
1050
+			// grab list of installed widgets
1051
+			$widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
1052
+			// filter list of modules to register
1053
+			$widgets_to_register = apply_filters(
1054
+				'FHEE__EE_Config__register_widgets__widgets_to_register',
1055
+				$widgets_to_register
1056
+			);
1057
+			if (! empty($widgets_to_register)) {
1058
+				// cycle thru widget folders
1059
+				foreach ($widgets_to_register as $widget_path) {
1060
+					// add to list of installed widget modules
1061
+					EE_Config::register_ee_widget($widget_path);
1062
+				}
1063
+			}
1064
+			// filter list of installed modules
1065
+			EE_Registry::instance()->widgets = apply_filters(
1066
+				'FHEE__EE_Config__register_widgets__installed_widgets',
1067
+				EE_Registry::instance()->widgets
1068
+			);
1069
+		}
1070
+	}
1071
+
1072
+
1073
+
1074
+	/**
1075
+	 *    register_ee_widget - makes core aware of this widget
1076
+	 *
1077
+	 * @access    public
1078
+	 * @param    string $widget_path - full path up to and including widget folder
1079
+	 * @return    void
1080
+	 */
1081
+	public static function register_ee_widget($widget_path = null)
1082
+	{
1083
+		do_action('AHEE__EE_Config__register_widget__begin', $widget_path);
1084
+		$widget_ext = '.widget.php';
1085
+		// make all separators match
1086
+		$widget_path = rtrim(str_replace('/\\', DS, $widget_path), DS);
1087
+		// does the file path INCLUDE the actual file name as part of the path ?
1088
+		if (strpos($widget_path, $widget_ext) !== false) {
1089
+			// grab and shortcode file name from directory name and break apart at dots
1090
+			$file_name = explode('.', basename($widget_path));
1091
+			// take first segment from file name pieces and remove class prefix if it exists
1092
+			$widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0];
1093
+			// sanitize shortcode directory name
1094
+			$widget = sanitize_key($widget);
1095
+			// now we need to rebuild the shortcode path
1096
+			$widget_path = explode(DS, $widget_path);
1097
+			// remove last segment
1098
+			array_pop($widget_path);
1099
+			// glue it back together
1100
+			$widget_path = implode(DS, $widget_path);
1101
+		} else {
1102
+			// grab and sanitize widget directory name
1103
+			$widget = sanitize_key(basename($widget_path));
1104
+		}
1105
+		// create classname from widget directory name
1106
+		$widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1107
+		// add class prefix
1108
+		$widget_class = 'EEW_' . $widget;
1109
+		// does the widget exist ?
1110
+		if (! is_readable($widget_path . DS . $widget_class . $widget_ext)) {
1111
+			$msg = sprintf(
1112
+				__(
1113
+					'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s',
1114
+					'event_espresso'
1115
+				),
1116
+				$widget_class,
1117
+				$widget_path . DS . $widget_class . $widget_ext
1118
+			);
1119
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1120
+			return;
1121
+		}
1122
+		// load the widget class file
1123
+		require_once($widget_path . DS . $widget_class . $widget_ext);
1124
+		// verify that class exists
1125
+		if (! class_exists($widget_class)) {
1126
+			$msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1127
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1128
+			return;
1129
+		}
1130
+		register_widget($widget_class);
1131
+		// add to array of registered widgets
1132
+		EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext;
1133
+	}
1134
+
1135
+
1136
+
1137
+	/**
1138
+	 *        _register_modules
1139
+	 *
1140
+	 * @access private
1141
+	 * @return array
1142
+	 */
1143
+	private function _register_modules()
1144
+	{
1145
+		// grab list of installed modules
1146
+		$modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1147
+		// filter list of modules to register
1148
+		$modules_to_register = apply_filters(
1149
+			'FHEE__EE_Config__register_modules__modules_to_register',
1150
+			$modules_to_register
1151
+		);
1152
+		if (! empty($modules_to_register)) {
1153
+			// loop through folders
1154
+			foreach ($modules_to_register as $module_path) {
1155
+				/**TEMPORARILY EXCLUDE gateways from modules for time being**/
1156
+				if (
1157
+					$module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1158
+					&& $module_path !== EE_MODULES . 'gateways'
1159
+				) {
1160
+					// add to list of installed modules
1161
+					EE_Config::register_module($module_path);
1162
+				}
1163
+			}
1164
+		}
1165
+		// filter list of installed modules
1166
+		return apply_filters(
1167
+			'FHEE__EE_Config___register_modules__installed_modules',
1168
+			EE_Registry::instance()->modules
1169
+		);
1170
+	}
1171
+
1172
+
1173
+
1174
+	/**
1175
+	 *    register_module - makes core aware of this module
1176
+	 *
1177
+	 * @access    public
1178
+	 * @param    string $module_path - full path up to and including module folder
1179
+	 * @return    bool
1180
+	 */
1181
+	public static function register_module($module_path = null)
1182
+	{
1183
+		do_action('AHEE__EE_Config__register_module__begin', $module_path);
1184
+		$module_ext = '.module.php';
1185
+		// make all separators match
1186
+		$module_path = str_replace(array('\\', '/'), DS, $module_path);
1187
+		// does the file path INCLUDE the actual file name as part of the path ?
1188
+		if (strpos($module_path, $module_ext) !== false) {
1189
+			// grab and shortcode file name from directory name and break apart at dots
1190
+			$module_file = explode('.', basename($module_path));
1191
+			// now we need to rebuild the shortcode path
1192
+			$module_path = explode(DS, $module_path);
1193
+			// remove last segment
1194
+			array_pop($module_path);
1195
+			// glue it back together
1196
+			$module_path = implode(DS, $module_path) . DS;
1197
+			// take first segment from file name pieces and sanitize it
1198
+			$module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1199
+			// ensure class prefix is added
1200
+			$module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1201
+		} else {
1202
+			// we need to generate the filename based off of the folder name
1203
+			// grab and sanitize module name
1204
+			$module = strtolower(basename($module_path));
1205
+			$module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1206
+			// like trailingslashit()
1207
+			$module_path = rtrim($module_path, DS) . DS;
1208
+			// create classname from module directory name
1209
+			$module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1210
+			// add class prefix
1211
+			$module_class = 'EED_' . $module;
1212
+		}
1213
+		// does the module exist ?
1214
+		if (! is_readable($module_path . DS . $module_class . $module_ext)) {
1215
+			$msg = sprintf(
1216
+				__(
1217
+					'The requested %s module file could not be found or is not readable due to file permissions.',
1218
+					'event_espresso'
1219
+				),
1220
+				$module
1221
+			);
1222
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1223
+			return false;
1224
+		}
1225
+		// load the module class file
1226
+		require_once($module_path . $module_class . $module_ext);
1227
+		// verify that class exists
1228
+		if (! class_exists($module_class)) {
1229
+			$msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1230
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1231
+			return false;
1232
+		}
1233
+		// add to array of registered modules
1234
+		EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1235
+		do_action(
1236
+			'AHEE__EE_Config__register_module__complete',
1237
+			$module_class,
1238
+			EE_Registry::instance()->modules->{$module_class}
1239
+		);
1240
+		return true;
1241
+	}
1242
+
1243
+
1244
+
1245
+	/**
1246
+	 *    _initialize_modules
1247
+	 *    allow modules to set hooks for the rest of the system
1248
+	 *
1249
+	 * @access private
1250
+	 * @return void
1251
+	 */
1252
+	private function _initialize_modules()
1253
+	{
1254
+		// cycle thru shortcode folders
1255
+		foreach (EE_Registry::instance()->modules as $module_class => $module_path) {
1256
+			// fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1257
+			// which set hooks ?
1258
+			if (is_admin()) {
1259
+				// fire immediately
1260
+				call_user_func(array($module_class, 'set_hooks_admin'));
1261
+			} else {
1262
+				// delay until other systems are online
1263
+				add_action(
1264
+					'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
1265
+					array($module_class, 'set_hooks')
1266
+				);
1267
+			}
1268
+		}
1269
+	}
1270
+
1271
+
1272
+
1273
+	/**
1274
+	 *    register_route - adds module method routes to route_map
1275
+	 *
1276
+	 * @access    public
1277
+	 * @param    string $route       - "pretty" public alias for module method
1278
+	 * @param    string $module      - module name (classname without EED_ prefix)
1279
+	 * @param    string $method_name - the actual module method to be routed to
1280
+	 * @param    string $key         - url param key indicating a route is being called
1281
+	 * @return    bool
1282
+	 */
1283
+	public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee')
1284
+	{
1285
+		do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1286
+		$module = str_replace('EED_', '', $module);
1287
+		$module_class = 'EED_' . $module;
1288
+		if (! isset(EE_Registry::instance()->modules->{$module_class})) {
1289
+			$msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module);
1290
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1291
+			return false;
1292
+		}
1293
+		if (empty($route)) {
1294
+			$msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route);
1295
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1296
+			return false;
1297
+		}
1298
+		if (! method_exists('EED_' . $module, $method_name)) {
1299
+			$msg = sprintf(
1300
+				__('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1301
+				$route
1302
+			);
1303
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1304
+			return false;
1305
+		}
1306
+		EE_Config::$_module_route_map[$key][$route] = array('EED_' . $module, $method_name);
1307
+		return true;
1308
+	}
1309
+
1310
+
1311
+
1312
+	/**
1313
+	 *    get_route - get module method route
1314
+	 *
1315
+	 * @access    public
1316
+	 * @param    string $route - "pretty" public alias for module method
1317
+	 * @param    string $key   - url param key indicating a route is being called
1318
+	 * @return    string
1319
+	 */
1320
+	public static function get_route($route = null, $key = 'ee')
1321
+	{
1322
+		do_action('AHEE__EE_Config__get_route__begin', $route);
1323
+		$route = (string)apply_filters('FHEE__EE_Config__get_route', $route);
1324
+		if (isset(EE_Config::$_module_route_map[$key][$route])) {
1325
+			return EE_Config::$_module_route_map[$key][$route];
1326
+		}
1327
+		return null;
1328
+	}
1329
+
1330
+
1331
+
1332
+	/**
1333
+	 *    get_routes - get ALL module method routes
1334
+	 *
1335
+	 * @access    public
1336
+	 * @return    array
1337
+	 */
1338
+	public static function get_routes()
1339
+	{
1340
+		return EE_Config::$_module_route_map;
1341
+	}
1342
+
1343
+
1344
+
1345
+	/**
1346
+	 *    register_forward - allows modules to forward request to another module for further processing
1347
+	 *
1348
+	 * @access    public
1349
+	 * @param    string       $route   - "pretty" public alias for module method
1350
+	 * @param    integer      $status  - integer value corresponding  to status constant strings set in module parent
1351
+	 *                                 class, allows different forwards to be served based on status
1352
+	 * @param    array|string $forward - function name or array( class, method )
1353
+	 * @param    string       $key     - url param key indicating a route is being called
1354
+	 * @return    bool
1355
+	 */
1356
+	public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee')
1357
+	{
1358
+		do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1359
+		if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1360
+			$msg = sprintf(
1361
+				__('The module route %s for this forward has not been registered.', 'event_espresso'),
1362
+				$route
1363
+			);
1364
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1365
+			return false;
1366
+		}
1367
+		if (empty($forward)) {
1368
+			$msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route);
1369
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1370
+			return false;
1371
+		}
1372
+		if (is_array($forward)) {
1373
+			if (! isset($forward[1])) {
1374
+				$msg = sprintf(
1375
+					__('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1376
+					$route
1377
+				);
1378
+				EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1379
+				return false;
1380
+			}
1381
+			if (! method_exists($forward[0], $forward[1])) {
1382
+				$msg = sprintf(
1383
+					__('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1384
+					$forward[1],
1385
+					$route
1386
+				);
1387
+				EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1388
+				return false;
1389
+			}
1390
+		} else if (! function_exists($forward)) {
1391
+			$msg = sprintf(
1392
+				__('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1393
+				$forward,
1394
+				$route
1395
+			);
1396
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1397
+			return false;
1398
+		}
1399
+		EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward;
1400
+		return true;
1401
+	}
1402
+
1403
+
1404
+
1405
+	/**
1406
+	 *    get_forward - get forwarding route
1407
+	 *
1408
+	 * @access    public
1409
+	 * @param    string  $route  - "pretty" public alias for module method
1410
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1411
+	 *                           allows different forwards to be served based on status
1412
+	 * @param    string  $key    - url param key indicating a route is being called
1413
+	 * @return    string
1414
+	 */
1415
+	public static function get_forward($route = null, $status = 0, $key = 'ee')
1416
+	{
1417
+		do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1418
+		if (isset(EE_Config::$_module_forward_map[$key][$route][$status])) {
1419
+			return apply_filters(
1420
+				'FHEE__EE_Config__get_forward',
1421
+				EE_Config::$_module_forward_map[$key][$route][$status],
1422
+				$route,
1423
+				$status
1424
+			);
1425
+		}
1426
+		return null;
1427
+	}
1428
+
1429
+
1430
+
1431
+	/**
1432
+	 *    register_forward - allows modules to specify different view templates for different method routes and status
1433
+	 *    results
1434
+	 *
1435
+	 * @access    public
1436
+	 * @param    string  $route  - "pretty" public alias for module method
1437
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1438
+	 *                           allows different views to be served based on status
1439
+	 * @param    string  $view
1440
+	 * @param    string  $key    - url param key indicating a route is being called
1441
+	 * @return    bool
1442
+	 */
1443
+	public static function register_view($route = null, $status = 0, $view = null, $key = 'ee')
1444
+	{
1445
+		do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1446
+		if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1447
+			$msg = sprintf(
1448
+				__('The module route %s for this view has not been registered.', 'event_espresso'),
1449
+				$route
1450
+			);
1451
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1452
+			return false;
1453
+		}
1454
+		if (! is_readable($view)) {
1455
+			$msg = sprintf(
1456
+				__(
1457
+					'The %s view file could not be found or is not readable due to file permissions.',
1458
+					'event_espresso'
1459
+				),
1460
+				$view
1461
+			);
1462
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1463
+			return false;
1464
+		}
1465
+		EE_Config::$_module_view_map[$key][$route][absint($status)] = $view;
1466
+		return true;
1467
+	}
1468
+
1469
+
1470
+
1471
+	/**
1472
+	 *    get_view - get view for route and status
1473
+	 *
1474
+	 * @access    public
1475
+	 * @param    string  $route  - "pretty" public alias for module method
1476
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1477
+	 *                           allows different views to be served based on status
1478
+	 * @param    string  $key    - url param key indicating a route is being called
1479
+	 * @return    string
1480
+	 */
1481
+	public static function get_view($route = null, $status = 0, $key = 'ee')
1482
+	{
1483
+		do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1484
+		if (isset(EE_Config::$_module_view_map[$key][$route][$status])) {
1485
+			return apply_filters(
1486
+				'FHEE__EE_Config__get_view',
1487
+				EE_Config::$_module_view_map[$key][$route][$status],
1488
+				$route,
1489
+				$status
1490
+			);
1491
+		}
1492
+		return null;
1493
+	}
1494
+
1495
+
1496
+
1497
+	public function update_addon_option_names()
1498
+	{
1499
+		update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names);
1500
+	}
1501
+
1502
+
1503
+
1504
+	public function shutdown()
1505
+	{
1506
+		$this->update_addon_option_names();
1507
+	}
1508
+
1509
+
1510
+
1511
+	/**
1512
+	 * @return LegacyShortcodesManager
1513
+	 */
1514
+	public static function getLegacyShortcodesManager()
1515
+	{
1516
+
1517
+		if ( ! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) {
1518
+			EE_Config::instance()->legacy_shortcodes_manager = new LegacyShortcodesManager(
1519
+				EE_Registry::instance()
1520
+			);
1521
+		}
1522
+		return EE_Config::instance()->legacy_shortcodes_manager;
1523
+	}
1524
+
1525
+
1526
+
1527
+	/**
1528
+	 * register_shortcode - makes core aware of this shortcode
1529
+	 *
1530
+	 * @deprecated 4.9.26
1531
+	 * @param    string $shortcode_path - full path up to and including shortcode folder
1532
+	 * @return    bool
1533
+	 */
1534
+	public static function register_shortcode($shortcode_path = null)
1535
+	{
1536
+		EE_Error::doing_it_wrong(
1537
+			__METHOD__,
1538
+			__(
1539
+				'Usage is deprecated. Use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::registerShortcode() as direct replacement, or better yet, please see the new \EventEspresso\core\services\shortcodes\ShortcodesManager class.',
1540
+				'event_espresso'
1541
+			),
1542
+			'4.9.26'
1543
+		);
1544
+		return EE_Config::instance()->getLegacyShortcodesManager()->registerShortcode($shortcode_path);
1545
+	}
24 1546
 
25
-    const LOG_NAME           = 'ee_config_log';
26 1547
 
27
-    const LOG_LENGTH         = 100;
28 1548
 
29
-    const ADDON_OPTION_NAMES = 'ee_config_option_names';
30
-
31
-
32
-    /**
33
-     *    instance of the EE_Config object
34
-     *
35
-     * @var    EE_Config $_instance
36
-     * @access    private
37
-     */
38
-    private static $_instance;
39
-
40
-    /**
41
-     * @var boolean $_logging_enabled
42
-     */
43
-    private static $_logging_enabled = false;
44
-
45
-    /**
46
-     * @var LegacyShortcodesManager $legacy_shortcodes_manager
47
-     */
48
-    private $legacy_shortcodes_manager;
49
-
50
-    /**
51
-     * An StdClass whose property names are addon slugs,
52
-     * and values are their config classes
53
-     *
54
-     * @var StdClass
55
-     */
56
-    public $addons;
57
-
58
-    /**
59
-     * @var EE_Admin_Config
60
-     */
61
-    public $admin;
62
-
63
-    /**
64
-     * @var EE_Core_Config
65
-     */
66
-    public $core;
67
-
68
-    /**
69
-     * @var EE_Currency_Config
70
-     */
71
-    public $currency;
72
-
73
-    /**
74
-     * @var EE_Organization_Config
75
-     */
76
-    public $organization;
77
-
78
-    /**
79
-     * @var EE_Registration_Config
80
-     */
81
-    public $registration;
82
-
83
-    /**
84
-     * @var EE_Template_Config
85
-     */
86
-    public $template_settings;
87
-
88
-    /**
89
-     * Holds EE environment values.
90
-     *
91
-     * @var EE_Environment_Config
92
-     */
93
-    public $environment;
94
-
95
-    /**
96
-     * settings pertaining to Google maps
97
-     *
98
-     * @var EE_Map_Config
99
-     */
100
-    public $map_settings;
101
-
102
-    /**
103
-     * settings pertaining to Taxes
104
-     *
105
-     * @var EE_Tax_Config
106
-     */
107
-    public $tax_settings;
108
-
109
-
110
-    /**
111
-     * Settings pertaining to global messages settings.
112
-     *
113
-     * @var EE_Messages_Config
114
-     */
115
-    public $messages;
116
-
117
-    /**
118
-     * @deprecated
119
-     * @var EE_Gateway_Config
120
-     */
121
-    public $gateway;
122
-
123
-    /**
124
-     * @var    array $_addon_option_names
125
-     * @access    private
126
-     */
127
-    private $_addon_option_names = array();
128
-
129
-    /**
130
-     * @var    array $_module_route_map
131
-     * @access    private
132
-     */
133
-    private static $_module_route_map = array();
134
-
135
-    /**
136
-     * @var    array $_module_forward_map
137
-     * @access    private
138
-     */
139
-    private static $_module_forward_map = array();
140
-
141
-    /**
142
-     * @var    array $_module_view_map
143
-     * @access    private
144
-     */
145
-    private static $_module_view_map = array();
146
-
147
-
148
-
149
-    /**
150
-     * @singleton method used to instantiate class object
151
-     * @access    public
152
-     * @return EE_Config instance
153
-     */
154
-    public static function instance()
155
-    {
156
-        // check if class object is instantiated, and instantiated properly
157
-        if (! self::$_instance instanceof EE_Config) {
158
-            self::$_instance = new self();
159
-        }
160
-        return self::$_instance;
161
-    }
162
-
163
-
164
-
165
-    /**
166
-     * Resets the config
167
-     *
168
-     * @param bool    $hard_reset    if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE
169
-     *                               (default) leaves the database alone, and merely resets the EE_Config object to
170
-     *                               reflect its state in the database
171
-     * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave
172
-     *                               $_instance as NULL. Useful in case you want to forget about the old instance on
173
-     *                               EE_Config, but might not be ready to instantiate EE_Config currently (eg if the
174
-     *                               site was put into maintenance mode)
175
-     * @return EE_Config
176
-     */
177
-    public static function reset($hard_reset = false, $reinstantiate = true)
178
-    {
179
-        if (self::$_instance instanceof EE_Config) {
180
-            if ($hard_reset) {
181
-                self::$_instance->legacy_shortcodes_manager = null;
182
-                self::$_instance->_addon_option_names = array();
183
-                self::$_instance->_initialize_config();
184
-                self::$_instance->update_espresso_config();
185
-            }
186
-            self::$_instance->update_addon_option_names();
187
-        }
188
-        self::$_instance = null;
189
-        //we don't need to reset the static properties imo because those should
190
-        //only change when a module is added or removed. Currently we don't
191
-        //support removing a module during a request when it previously existed
192
-        if ($reinstantiate) {
193
-            return self::instance();
194
-        } else {
195
-            return null;
196
-        }
197
-    }
198
-
199
-
200
-
201
-    /**
202
-     *    class constructor
203
-     *
204
-     * @access    private
205
-     */
206
-    private function __construct()
207
-    {
208
-        do_action('AHEE__EE_Config__construct__begin', $this);
209
-        EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false);
210
-        // setup empty config classes
211
-        $this->_initialize_config();
212
-        // load existing EE site settings
213
-        $this->_load_core_config();
214
-        // confirm everything loaded correctly and set filtered defaults if not
215
-        $this->_verify_config();
216
-        //  register shortcodes and modules
217
-        add_action(
218
-            'AHEE__EE_System__register_shortcodes_modules_and_widgets',
219
-            array($this, 'register_shortcodes_and_modules'),
220
-            999
221
-        );
222
-        //  initialize shortcodes and modules
223
-        add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules'));
224
-        // register widgets
225
-        add_action('widgets_init', array($this, 'widgets_init'), 10);
226
-        // shutdown
227
-        add_action('shutdown', array($this, 'shutdown'), 10);
228
-        // construct__end hook
229
-        do_action('AHEE__EE_Config__construct__end', $this);
230
-        // hardcoded hack
231
-        $this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014';
232
-    }
233
-
234
-
235
-
236
-    /**
237
-     * @return boolean
238
-     */
239
-    public static function logging_enabled()
240
-    {
241
-        return self::$_logging_enabled;
242
-    }
243
-
244
-
245
-
246
-    /**
247
-     * use to get the current theme if needed from static context
248
-     *
249
-     * @return string current theme set.
250
-     */
251
-    public static function get_current_theme()
252
-    {
253
-        return isset(self::$_instance->template_settings->current_espresso_theme)
254
-            ? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014';
255
-    }
256
-
257
-
258
-
259
-    /**
260
-     *        _initialize_config
261
-     *
262
-     * @access private
263
-     * @return void
264
-     */
265
-    private function _initialize_config()
266
-    {
267
-        EE_Config::trim_log();
268
-        //set defaults
269
-        $this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array());
270
-        $this->addons = new stdClass();
271
-        // set _module_route_map
272
-        EE_Config::$_module_route_map = array();
273
-        // set _module_forward_map
274
-        EE_Config::$_module_forward_map = array();
275
-        // set _module_view_map
276
-        EE_Config::$_module_view_map = array();
277
-    }
278
-
279
-
280
-
281
-    /**
282
-     *        load core plugin configuration
283
-     *
284
-     * @access private
285
-     * @return void
286
-     */
287
-    private function _load_core_config()
288
-    {
289
-        // load_core_config__start hook
290
-        do_action('AHEE__EE_Config___load_core_config__start', $this);
291
-        $espresso_config = $this->get_espresso_config();
292
-        foreach ($espresso_config as $config => $settings) {
293
-            // load_core_config__start hook
294
-            $settings = apply_filters(
295
-                'FHEE__EE_Config___load_core_config__config_settings',
296
-                $settings,
297
-                $config,
298
-                $this
299
-            );
300
-            if (is_object($settings) && property_exists($this, $config)) {
301
-                $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings);
302
-                //call configs populate method to ensure any defaults are set for empty values.
303
-                if (method_exists($settings, 'populate')) {
304
-                    $this->{$config}->populate();
305
-                }
306
-                if (method_exists($settings, 'do_hooks')) {
307
-                    $this->{$config}->do_hooks();
308
-                }
309
-            }
310
-        }
311
-        if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) {
312
-            $this->update_espresso_config();
313
-        }
314
-        // load_core_config__end hook
315
-        do_action('AHEE__EE_Config___load_core_config__end', $this);
316
-    }
317
-
318
-
319
-    /**
320
-     * @return void
321
-     * @throws ReflectionException
322
-     * @throws InvalidArgumentException
323
-     * @throws InvalidInterfaceException
324
-     * @throws InvalidDataTypeException
325
-     * @throws EE_Error
326
-     */
327
-    protected function _verify_config()
328
-    {
329
-        $this->core = $this->core instanceof EE_Core_Config
330
-            ? $this->core
331
-            : new EE_Core_Config();
332
-        $this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core);
333
-        $this->organization = $this->organization instanceof EE_Organization_Config
334
-            ? $this->organization
335
-            : new EE_Organization_Config();
336
-        $this->organization = apply_filters(
337
-            'FHEE__EE_Config___initialize_config__organization',
338
-            $this->organization
339
-        );
340
-        $this->currency = $this->currency instanceof EE_Currency_Config
341
-            ? $this->currency
342
-            : new EE_Currency_Config($this->organization->CNT_ISO);
343
-        $this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency);
344
-        $this->registration = $this->registration instanceof EE_Registration_Config
345
-            ? $this->registration
346
-            : new EE_Registration_Config();
347
-        $this->registration = apply_filters(
348
-            'FHEE__EE_Config___initialize_config__registration',
349
-            $this->registration
350
-        );
351
-        $this->admin = $this->admin instanceof EE_Admin_Config
352
-            ? $this->admin
353
-            : new EE_Admin_Config();
354
-        $this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin);
355
-        $this->template_settings = $this->template_settings instanceof EE_Template_Config
356
-            ? $this->template_settings
357
-            : new EE_Template_Config();
358
-        $this->template_settings = apply_filters(
359
-            'FHEE__EE_Config___initialize_config__template_settings',
360
-            $this->template_settings
361
-        );
362
-        $this->map_settings = $this->map_settings instanceof EE_Map_Config
363
-            ? $this->map_settings
364
-            : new EE_Map_Config();
365
-        $this->map_settings = apply_filters('FHEE__EE_Config___initialize_config__map_settings',
366
-            $this->map_settings);
367
-        $this->environment = $this->environment instanceof EE_Environment_Config
368
-            ? $this->environment
369
-            : new EE_Environment_Config();
370
-        $this->environment = apply_filters('FHEE__EE_Config___initialize_config__environment',
371
-            $this->environment);
372
-        $this->tax_settings = $this->tax_settings instanceof EE_Tax_Config
373
-            ? $this->tax_settings
374
-            : new EE_Tax_Config();
375
-        $this->tax_settings = apply_filters('FHEE__EE_Config___initialize_config__tax_settings',
376
-            $this->tax_settings);
377
-        $this->messages = apply_filters('FHEE__EE_Config__initialize_config__messages', $this->messages);
378
-        $this->messages = $this->messages instanceof EE_Messages_Config
379
-            ? $this->messages
380
-            : new EE_Messages_Config();
381
-        $this->gateway = $this->gateway instanceof EE_Gateway_Config
382
-            ? $this->gateway
383
-            : new EE_Gateway_Config();
384
-        $this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway);
385
-        $this->legacy_shortcodes_manager = null;
386
-    }
387
-
388
-
389
-    /**
390
-     *    get_espresso_config
391
-     *
392
-     * @access    public
393
-     * @return    array of espresso config stuff
394
-     */
395
-    public function get_espresso_config()
396
-    {
397
-        // grab espresso configuration
398
-        return apply_filters(
399
-            'FHEE__EE_Config__get_espresso_config__CFG',
400
-            get_option(EE_Config::OPTION_NAME, array())
401
-        );
402
-    }
403
-
404
-
405
-
406
-    /**
407
-     *    double_check_config_comparison
408
-     *
409
-     * @access    public
410
-     * @param string $option
411
-     * @param        $old_value
412
-     * @param        $value
413
-     */
414
-    public function double_check_config_comparison($option = '', $old_value, $value)
415
-    {
416
-        // make sure we're checking the ee config
417
-        if ($option === EE_Config::OPTION_NAME) {
418
-            // run a loose comparison of the old value against the new value for type and properties,
419
-            // but NOT exact instance like WP update_option does (ie: NOT type safe comparison)
420
-            if ($value != $old_value) {
421
-                // if they are NOT the same, then remove the hook,
422
-                // which means the subsequent update results will be based solely on the update query results
423
-                // the reason we do this is because, as stated above,
424
-                // WP update_option performs an exact instance comparison (===) on any update values passed to it
425
-                // this happens PRIOR to serialization and any subsequent update.
426
-                // If values are found to match their previous old value,
427
-                // then WP bails before performing any update.
428
-                // Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version
429
-                // it just pulled from the db, with the one being passed to it (which will not match).
430
-                // HOWEVER, once the object is serialized and passed off to MySQL to update,
431
-                // MySQL MAY ALSO NOT perform the update because
432
-                // the string it sees in the db looks the same as the new one it has been passed!!!
433
-                // This results in the query returning an "affected rows" value of ZERO,
434
-                // which gets returned immediately by WP update_option and looks like an error.
435
-                remove_action('update_option', array($this, 'check_config_updated'));
436
-            }
437
-        }
438
-    }
439
-
440
-
441
-
442
-    /**
443
-     *    update_espresso_config
444
-     *
445
-     * @access   public
446
-     */
447
-    protected function _reset_espresso_addon_config()
448
-    {
449
-        $this->_addon_option_names = array();
450
-        foreach ($this->addons as $addon_name => $addon_config_obj) {
451
-            $addon_config_obj = maybe_unserialize($addon_config_obj);
452
-            $config_class = get_class($addon_config_obj);
453
-            if ($addon_config_obj instanceof $config_class && ! $addon_config_obj instanceof __PHP_Incomplete_Class) {
454
-                $this->update_config('addons', $addon_name, $addon_config_obj, false);
455
-            }
456
-            $this->addons->{$addon_name} = null;
457
-        }
458
-    }
459
-
460
-
461
-
462
-    /**
463
-     *    update_espresso_config
464
-     *
465
-     * @access   public
466
-     * @param   bool $add_success
467
-     * @param   bool $add_error
468
-     * @return   bool
469
-     */
470
-    public function update_espresso_config($add_success = false, $add_error = true)
471
-    {
472
-        // don't allow config updates during WP heartbeats
473
-        if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
474
-            return false;
475
-        }
476
-        // commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197
477
-        //$clone = clone( self::$_instance );
478
-        //self::$_instance = NULL;
479
-        do_action('AHEE__EE_Config__update_espresso_config__begin', $this);
480
-        $this->_reset_espresso_addon_config();
481
-        // hook into update_option because that happens AFTER the ( $value === $old_value ) conditional
482
-        // but BEFORE the actual update occurs
483
-        add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3);
484
-        // don't want to persist legacy_shortcodes_manager, but don't want to lose it either
485
-        $legacy_shortcodes_manager = $this->legacy_shortcodes_manager;
486
-        $this->legacy_shortcodes_manager = null;
487
-        // now update "ee_config"
488
-        $saved = update_option(EE_Config::OPTION_NAME, $this);
489
-        $this->legacy_shortcodes_manager = $legacy_shortcodes_manager;
490
-        EE_Config::log(EE_Config::OPTION_NAME);
491
-        // if not saved... check if the hook we just added still exists;
492
-        // if it does, it means one of two things:
493
-        // 		that update_option bailed at the ( $value === $old_value ) conditional,
494
-        //		 or...
495
-        // 		the db update query returned 0 rows affected
496
-        // 		(probably because the data  value was the same from it's perspective)
497
-        // so the existence of the hook means that a negative result from update_option is NOT an error,
498
-        // but just means no update occurred, so don't display an error to the user.
499
-        // BUT... if update_option returns FALSE, AND the hook is missing,
500
-        // then it means that something truly went wrong
501
-        $saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved;
502
-        // remove our action since we don't want it in the system anymore
503
-        remove_action('update_option', array($this, 'double_check_config_comparison'), 1);
504
-        do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved);
505
-        //self::$_instance = $clone;
506
-        //unset( $clone );
507
-        // if config remains the same or was updated successfully
508
-        if ($saved) {
509
-            if ($add_success) {
510
-                EE_Error::add_success(
511
-                    __('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'),
512
-                    __FILE__,
513
-                    __FUNCTION__,
514
-                    __LINE__
515
-                );
516
-            }
517
-            return true;
518
-        } else {
519
-            if ($add_error) {
520
-                EE_Error::add_error(
521
-                    __('The Event Espresso Configuration Settings were not updated.', 'event_espresso'),
522
-                    __FILE__,
523
-                    __FUNCTION__,
524
-                    __LINE__
525
-                );
526
-            }
527
-            return false;
528
-        }
529
-    }
530
-
531
-
532
-
533
-    /**
534
-     *    _verify_config_params
535
-     *
536
-     * @access    private
537
-     * @param    string         $section
538
-     * @param    string         $name
539
-     * @param    string         $config_class
540
-     * @param    EE_Config_Base $config_obj
541
-     * @param    array          $tests_to_run
542
-     * @param    bool           $display_errors
543
-     * @return    bool    TRUE on success, FALSE on fail
544
-     */
545
-    private function _verify_config_params(
546
-        $section = '',
547
-        $name = '',
548
-        $config_class = '',
549
-        $config_obj = null,
550
-        $tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8),
551
-        $display_errors = true
552
-    ) {
553
-        try {
554
-            foreach ($tests_to_run as $test) {
555
-                switch ($test) {
556
-                    // TEST #1 : check that section was set
557
-                    case 1 :
558
-                        if (empty($section)) {
559
-                            if ($display_errors) {
560
-                                throw new EE_Error(
561
-                                    sprintf(
562
-                                        __(
563
-                                            'No configuration section has been provided while attempting to save "%s".',
564
-                                            'event_espresso'
565
-                                        ),
566
-                                        $config_class
567
-                                    )
568
-                                );
569
-                            }
570
-                            return false;
571
-                        }
572
-                        break;
573
-                    // TEST #2 : check that settings section exists
574
-                    case 2 :
575
-                        if (! isset($this->{$section})) {
576
-                            if ($display_errors) {
577
-                                throw new EE_Error(
578
-                                    sprintf(
579
-                                        __('The "%s" configuration section does not exist.', 'event_espresso'),
580
-                                        $section
581
-                                    )
582
-                                );
583
-                            }
584
-                            return false;
585
-                        }
586
-                        break;
587
-                    // TEST #3 : check that section is the proper format
588
-                    case 3 :
589
-                        if (
590
-                        ! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass)
591
-                        ) {
592
-                            if ($display_errors) {
593
-                                throw new EE_Error(
594
-                                    sprintf(
595
-                                        __(
596
-                                            'The "%s" configuration settings have not been formatted correctly.',
597
-                                            'event_espresso'
598
-                                        ),
599
-                                        $section
600
-                                    )
601
-                                );
602
-                            }
603
-                            return false;
604
-                        }
605
-                        break;
606
-                    // TEST #4 : check that config section name has been set
607
-                    case 4 :
608
-                        if (empty($name)) {
609
-                            if ($display_errors) {
610
-                                throw new EE_Error(
611
-                                    __(
612
-                                        'No name has been provided for the specific configuration section.',
613
-                                        'event_espresso'
614
-                                    )
615
-                                );
616
-                            }
617
-                            return false;
618
-                        }
619
-                        break;
620
-                    // TEST #5 : check that a config class name has been set
621
-                    case 5 :
622
-                        if (empty($config_class)) {
623
-                            if ($display_errors) {
624
-                                throw new EE_Error(
625
-                                    __(
626
-                                        'No class name has been provided for the specific configuration section.',
627
-                                        'event_espresso'
628
-                                    )
629
-                                );
630
-                            }
631
-                            return false;
632
-                        }
633
-                        break;
634
-                    // TEST #6 : verify config class is accessible
635
-                    case 6 :
636
-                        if (! class_exists($config_class)) {
637
-                            if ($display_errors) {
638
-                                throw new EE_Error(
639
-                                    sprintf(
640
-                                        __(
641
-                                            'The "%s" class does not exist. Please ensure that an autoloader has been set for it.',
642
-                                            'event_espresso'
643
-                                        ),
644
-                                        $config_class
645
-                                    )
646
-                                );
647
-                            }
648
-                            return false;
649
-                        }
650
-                        break;
651
-                    // TEST #7 : check that config has even been set
652
-                    case 7 :
653
-                        if (! isset($this->{$section}->{$name})) {
654
-                            if ($display_errors) {
655
-                                throw new EE_Error(
656
-                                    sprintf(
657
-                                        __('No configuration has been set for "%1$s->%2$s".', 'event_espresso'),
658
-                                        $section,
659
-                                        $name
660
-                                    )
661
-                                );
662
-                            }
663
-                            return false;
664
-                        } else {
665
-                            // and make sure it's not serialized
666
-                            $this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name});
667
-                        }
668
-                        break;
669
-                    // TEST #8 : check that config is the requested type
670
-                    case 8 :
671
-                        if (! $this->{$section}->{$name} instanceof $config_class) {
672
-                            if ($display_errors) {
673
-                                throw new EE_Error(
674
-                                    sprintf(
675
-                                        __(
676
-                                            'The configuration for "%1$s->%2$s" is not of the "%3$s" class.',
677
-                                            'event_espresso'
678
-                                        ),
679
-                                        $section,
680
-                                        $name,
681
-                                        $config_class
682
-                                    )
683
-                                );
684
-                            }
685
-                            return false;
686
-                        }
687
-                        break;
688
-                    // TEST #9 : verify config object
689
-                    case 9 :
690
-                        if (! $config_obj instanceof EE_Config_Base) {
691
-                            if ($display_errors) {
692
-                                throw new EE_Error(
693
-                                    sprintf(
694
-                                        __('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'),
695
-                                        print_r($config_obj, true)
696
-                                    )
697
-                                );
698
-                            }
699
-                            return false;
700
-                        }
701
-                        break;
702
-                }
703
-            }
704
-        } catch (EE_Error $e) {
705
-            $e->get_error();
706
-        }
707
-        // you have successfully run the gauntlet
708
-        return true;
709
-    }
710
-
711
-
712
-
713
-    /**
714
-     *    _generate_config_option_name
715
-     *
716
-     * @access        protected
717
-     * @param        string $section
718
-     * @param        string $name
719
-     * @return        string
720
-     */
721
-    private function _generate_config_option_name($section = '', $name = '')
722
-    {
723
-        return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name));
724
-    }
725
-
726
-
727
-
728
-    /**
729
-     *    _set_config_class
730
-     * ensures that a config class is set, either from a passed config class or one generated from the config name
731
-     *
732
-     * @access    private
733
-     * @param    string $config_class
734
-     * @param    string $name
735
-     * @return    string
736
-     */
737
-    private function _set_config_class($config_class = '', $name = '')
738
-    {
739
-        return ! empty($config_class)
740
-            ? $config_class
741
-            : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config';
742
-    }
743
-
744
-
745
-
746
-    /**
747
-     *    set_config
748
-     *
749
-     * @access    protected
750
-     * @param    string         $section
751
-     * @param    string         $name
752
-     * @param    string         $config_class
753
-     * @param    EE_Config_Base $config_obj
754
-     * @return    EE_Config_Base
755
-     */
756
-    public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null)
757
-    {
758
-        // ensure config class is set to something
759
-        $config_class = $this->_set_config_class($config_class, $name);
760
-        // run tests 1-4, 6, and 7 to verify all config params are set and valid
761
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
762
-            return null;
763
-        }
764
-        $config_option_name = $this->_generate_config_option_name($section, $name);
765
-        // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now
766
-        if (! isset($this->_addon_option_names[$config_option_name])) {
767
-            $this->_addon_option_names[$config_option_name] = $config_class;
768
-            $this->update_addon_option_names();
769
-        }
770
-        // verify the incoming config object but suppress errors
771
-        if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
772
-            $config_obj = new $config_class();
773
-        }
774
-        if (get_option($config_option_name)) {
775
-            EE_Config::log($config_option_name);
776
-            update_option($config_option_name, $config_obj);
777
-            $this->{$section}->{$name} = $config_obj;
778
-            return $this->{$section}->{$name};
779
-        } else {
780
-            // create a wp-option for this config
781
-            if (add_option($config_option_name, $config_obj, '', 'no')) {
782
-                $this->{$section}->{$name} = maybe_unserialize($config_obj);
783
-                return $this->{$section}->{$name};
784
-            } else {
785
-                EE_Error::add_error(
786
-                    sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class),
787
-                    __FILE__,
788
-                    __FUNCTION__,
789
-                    __LINE__
790
-                );
791
-                return null;
792
-            }
793
-        }
794
-    }
795
-
796
-
797
-
798
-    /**
799
-     *    update_config
800
-     * Important: the config object must ALREADY be set, otherwise this will produce an error.
801
-     *
802
-     * @access    public
803
-     * @param    string                $section
804
-     * @param    string                $name
805
-     * @param    EE_Config_Base|string $config_obj
806
-     * @param    bool                  $throw_errors
807
-     * @return    bool
808
-     */
809
-    public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true)
810
-    {
811
-        // don't allow config updates during WP heartbeats
812
-        if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
813
-            return false;
814
-        }
815
-        $config_obj = maybe_unserialize($config_obj);
816
-        // get class name of the incoming object
817
-        $config_class = get_class($config_obj);
818
-        // run tests 1-5 and 9 to verify config
819
-        if (! $this->_verify_config_params(
820
-            $section,
821
-            $name,
822
-            $config_class,
823
-            $config_obj,
824
-            array(1, 2, 3, 4, 7, 9)
825
-        )
826
-        ) {
827
-            return false;
828
-        }
829
-        $config_option_name = $this->_generate_config_option_name($section, $name);
830
-        // check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
831
-        if (! isset($this->_addon_option_names[$config_option_name])) {
832
-            // save new config to db
833
-            if ($this->set_config($section, $name, $config_class, $config_obj)) {
834
-                return true;
835
-            }
836
-        } else {
837
-            // first check if the record already exists
838
-            $existing_config = get_option($config_option_name);
839
-            $config_obj = serialize($config_obj);
840
-            // just return if db record is already up to date (NOT type safe comparison)
841
-            if ($existing_config == $config_obj) {
842
-                $this->{$section}->{$name} = $config_obj;
843
-                return true;
844
-            } else if (update_option($config_option_name, $config_obj)) {
845
-                EE_Config::log($config_option_name);
846
-                // update wp-option for this config class
847
-                $this->{$section}->{$name} = $config_obj;
848
-                return true;
849
-            } elseif ($throw_errors) {
850
-                EE_Error::add_error(
851
-                    sprintf(
852
-                        __(
853
-                            'The "%1$s" object stored at"%2$s" was not successfully updated in the database.',
854
-                            'event_espresso'
855
-                        ),
856
-                        $config_class,
857
-                        'EE_Config->' . $section . '->' . $name
858
-                    ),
859
-                    __FILE__,
860
-                    __FUNCTION__,
861
-                    __LINE__
862
-                );
863
-            }
864
-        }
865
-        return false;
866
-    }
867
-
868
-
869
-
870
-    /**
871
-     *    get_config
872
-     *
873
-     * @access    public
874
-     * @param    string $section
875
-     * @param    string $name
876
-     * @param    string $config_class
877
-     * @return    mixed EE_Config_Base | NULL
878
-     */
879
-    public function get_config($section = '', $name = '', $config_class = '')
880
-    {
881
-        // ensure config class is set to something
882
-        $config_class = $this->_set_config_class($config_class, $name);
883
-        // run tests 1-4, 6 and 7 to verify that all params have been set
884
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
885
-            return null;
886
-        }
887
-        // now test if the requested config object exists, but suppress errors
888
-        if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) {
889
-            // config already exists, so pass it back
890
-            return $this->{$section}->{$name};
891
-        }
892
-        // load config option from db if it exists
893
-        $config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name));
894
-        // verify the newly retrieved config object, but suppress errors
895
-        if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
896
-            // config is good, so set it and pass it back
897
-            $this->{$section}->{$name} = $config_obj;
898
-            return $this->{$section}->{$name};
899
-        }
900
-        // oops! $config_obj is not already set and does not exist in the db, so create a new one
901
-        $config_obj = $this->set_config($section, $name, $config_class);
902
-        // verify the newly created config object
903
-        if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) {
904
-            return $this->{$section}->{$name};
905
-        } else {
906
-            EE_Error::add_error(
907
-                sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class),
908
-                __FILE__,
909
-                __FUNCTION__,
910
-                __LINE__
911
-            );
912
-        }
913
-        return null;
914
-    }
915
-
916
-
917
-
918
-    /**
919
-     *    get_config_option
920
-     *
921
-     * @access    public
922
-     * @param    string $config_option_name
923
-     * @return    mixed EE_Config_Base | FALSE
924
-     */
925
-    public function get_config_option($config_option_name = '')
926
-    {
927
-        // retrieve the wp-option for this config class.
928
-        $config_option = maybe_unserialize(get_option($config_option_name, array()));
929
-        if (empty($config_option)) {
930
-            EE_Config::log($config_option_name . '-NOT-FOUND');
931
-        }
932
-        return $config_option;
933
-    }
934
-
935
-
936
-
937
-    /**
938
-     * log
939
-     *
940
-     * @param string $config_option_name
941
-     */
942
-    public static function log($config_option_name = '')
943
-    {
944
-        if (EE_Config::logging_enabled() && ! empty($config_option_name)) {
945
-            $config_log = get_option(EE_Config::LOG_NAME, array());
946
-            //copy incoming $_REQUEST and sanitize it so we can save it
947
-            $_request = $_REQUEST;
948
-            array_walk_recursive($_request, 'sanitize_text_field');
949
-            $config_log[(string)microtime(true)] = array(
950
-                'config_name' => $config_option_name,
951
-                'request'     => $_request,
952
-            );
953
-            update_option(EE_Config::LOG_NAME, $config_log);
954
-        }
955
-    }
956
-
957
-
958
-
959
-    /**
960
-     * trim_log
961
-     * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH
962
-     */
963
-    public static function trim_log()
964
-    {
965
-        if (! EE_Config::logging_enabled()) {
966
-            return;
967
-        }
968
-        $config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
969
-        $log_length = count($config_log);
970
-        if ($log_length > EE_Config::LOG_LENGTH) {
971
-            ksort($config_log);
972
-            $config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true);
973
-            update_option(EE_Config::LOG_NAME, $config_log);
974
-        }
975
-    }
976
-
977
-
978
-
979
-    /**
980
-     *    get_page_for_posts
981
-     *    if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the
982
-     *    wp-option "page_for_posts", or "posts" if no page is selected
983
-     *
984
-     * @access    public
985
-     * @return    string
986
-     */
987
-    public static function get_page_for_posts()
988
-    {
989
-        $page_for_posts = get_option('page_for_posts');
990
-        if (! $page_for_posts) {
991
-            return 'posts';
992
-        }
993
-        /** @type WPDB $wpdb */
994
-        global $wpdb;
995
-        $SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d";
996
-        return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts));
997
-    }
998
-
999
-
1000
-
1001
-    /**
1002
-     *    register_shortcodes_and_modules.
1003
-     *    At this point, it's too early to tell if we're maintenance mode or not.
1004
-     *    In fact, this is where we give modules a chance to let core know they exist
1005
-     *    so they can help trigger maintenance mode if it's needed
1006
-     *
1007
-     * @access    public
1008
-     * @return    void
1009
-     */
1010
-    public function register_shortcodes_and_modules()
1011
-    {
1012
-        // allow modules to set hooks for the rest of the system
1013
-        EE_Registry::instance()->modules = $this->_register_modules();
1014
-    }
1015
-
1016
-
1017
-
1018
-    /**
1019
-     *    initialize_shortcodes_and_modules
1020
-     *    meaning they can start adding their hooks to get stuff done
1021
-     *
1022
-     * @access    public
1023
-     * @return    void
1024
-     */
1025
-    public function initialize_shortcodes_and_modules()
1026
-    {
1027
-        // allow modules to set hooks for the rest of the system
1028
-        $this->_initialize_modules();
1029
-    }
1030
-
1031
-
1032
-
1033
-    /**
1034
-     *    widgets_init
1035
-     *
1036
-     * @access private
1037
-     * @return void
1038
-     */
1039
-    public function widgets_init()
1040
-    {
1041
-        //only init widgets on admin pages when not in complete maintenance, and
1042
-        //on frontend when not in any maintenance mode
1043
-        if (
1044
-            ! EE_Maintenance_Mode::instance()->level()
1045
-            || (
1046
-                is_admin()
1047
-                && EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance
1048
-            )
1049
-        ) {
1050
-            // grab list of installed widgets
1051
-            $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
1052
-            // filter list of modules to register
1053
-            $widgets_to_register = apply_filters(
1054
-                'FHEE__EE_Config__register_widgets__widgets_to_register',
1055
-                $widgets_to_register
1056
-            );
1057
-            if (! empty($widgets_to_register)) {
1058
-                // cycle thru widget folders
1059
-                foreach ($widgets_to_register as $widget_path) {
1060
-                    // add to list of installed widget modules
1061
-                    EE_Config::register_ee_widget($widget_path);
1062
-                }
1063
-            }
1064
-            // filter list of installed modules
1065
-            EE_Registry::instance()->widgets = apply_filters(
1066
-                'FHEE__EE_Config__register_widgets__installed_widgets',
1067
-                EE_Registry::instance()->widgets
1068
-            );
1069
-        }
1070
-    }
1071
-
1072
-
1073
-
1074
-    /**
1075
-     *    register_ee_widget - makes core aware of this widget
1076
-     *
1077
-     * @access    public
1078
-     * @param    string $widget_path - full path up to and including widget folder
1079
-     * @return    void
1080
-     */
1081
-    public static function register_ee_widget($widget_path = null)
1082
-    {
1083
-        do_action('AHEE__EE_Config__register_widget__begin', $widget_path);
1084
-        $widget_ext = '.widget.php';
1085
-        // make all separators match
1086
-        $widget_path = rtrim(str_replace('/\\', DS, $widget_path), DS);
1087
-        // does the file path INCLUDE the actual file name as part of the path ?
1088
-        if (strpos($widget_path, $widget_ext) !== false) {
1089
-            // grab and shortcode file name from directory name and break apart at dots
1090
-            $file_name = explode('.', basename($widget_path));
1091
-            // take first segment from file name pieces and remove class prefix if it exists
1092
-            $widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0];
1093
-            // sanitize shortcode directory name
1094
-            $widget = sanitize_key($widget);
1095
-            // now we need to rebuild the shortcode path
1096
-            $widget_path = explode(DS, $widget_path);
1097
-            // remove last segment
1098
-            array_pop($widget_path);
1099
-            // glue it back together
1100
-            $widget_path = implode(DS, $widget_path);
1101
-        } else {
1102
-            // grab and sanitize widget directory name
1103
-            $widget = sanitize_key(basename($widget_path));
1104
-        }
1105
-        // create classname from widget directory name
1106
-        $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1107
-        // add class prefix
1108
-        $widget_class = 'EEW_' . $widget;
1109
-        // does the widget exist ?
1110
-        if (! is_readable($widget_path . DS . $widget_class . $widget_ext)) {
1111
-            $msg = sprintf(
1112
-                __(
1113
-                    'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s',
1114
-                    'event_espresso'
1115
-                ),
1116
-                $widget_class,
1117
-                $widget_path . DS . $widget_class . $widget_ext
1118
-            );
1119
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1120
-            return;
1121
-        }
1122
-        // load the widget class file
1123
-        require_once($widget_path . DS . $widget_class . $widget_ext);
1124
-        // verify that class exists
1125
-        if (! class_exists($widget_class)) {
1126
-            $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1127
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1128
-            return;
1129
-        }
1130
-        register_widget($widget_class);
1131
-        // add to array of registered widgets
1132
-        EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext;
1133
-    }
1134
-
1135
-
1136
-
1137
-    /**
1138
-     *        _register_modules
1139
-     *
1140
-     * @access private
1141
-     * @return array
1142
-     */
1143
-    private function _register_modules()
1144
-    {
1145
-        // grab list of installed modules
1146
-        $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1147
-        // filter list of modules to register
1148
-        $modules_to_register = apply_filters(
1149
-            'FHEE__EE_Config__register_modules__modules_to_register',
1150
-            $modules_to_register
1151
-        );
1152
-        if (! empty($modules_to_register)) {
1153
-            // loop through folders
1154
-            foreach ($modules_to_register as $module_path) {
1155
-                /**TEMPORARILY EXCLUDE gateways from modules for time being**/
1156
-                if (
1157
-                    $module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1158
-                    && $module_path !== EE_MODULES . 'gateways'
1159
-                ) {
1160
-                    // add to list of installed modules
1161
-                    EE_Config::register_module($module_path);
1162
-                }
1163
-            }
1164
-        }
1165
-        // filter list of installed modules
1166
-        return apply_filters(
1167
-            'FHEE__EE_Config___register_modules__installed_modules',
1168
-            EE_Registry::instance()->modules
1169
-        );
1170
-    }
1171
-
1172
-
1173
-
1174
-    /**
1175
-     *    register_module - makes core aware of this module
1176
-     *
1177
-     * @access    public
1178
-     * @param    string $module_path - full path up to and including module folder
1179
-     * @return    bool
1180
-     */
1181
-    public static function register_module($module_path = null)
1182
-    {
1183
-        do_action('AHEE__EE_Config__register_module__begin', $module_path);
1184
-        $module_ext = '.module.php';
1185
-        // make all separators match
1186
-        $module_path = str_replace(array('\\', '/'), DS, $module_path);
1187
-        // does the file path INCLUDE the actual file name as part of the path ?
1188
-        if (strpos($module_path, $module_ext) !== false) {
1189
-            // grab and shortcode file name from directory name and break apart at dots
1190
-            $module_file = explode('.', basename($module_path));
1191
-            // now we need to rebuild the shortcode path
1192
-            $module_path = explode(DS, $module_path);
1193
-            // remove last segment
1194
-            array_pop($module_path);
1195
-            // glue it back together
1196
-            $module_path = implode(DS, $module_path) . DS;
1197
-            // take first segment from file name pieces and sanitize it
1198
-            $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1199
-            // ensure class prefix is added
1200
-            $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1201
-        } else {
1202
-            // we need to generate the filename based off of the folder name
1203
-            // grab and sanitize module name
1204
-            $module = strtolower(basename($module_path));
1205
-            $module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1206
-            // like trailingslashit()
1207
-            $module_path = rtrim($module_path, DS) . DS;
1208
-            // create classname from module directory name
1209
-            $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1210
-            // add class prefix
1211
-            $module_class = 'EED_' . $module;
1212
-        }
1213
-        // does the module exist ?
1214
-        if (! is_readable($module_path . DS . $module_class . $module_ext)) {
1215
-            $msg = sprintf(
1216
-                __(
1217
-                    'The requested %s module file could not be found or is not readable due to file permissions.',
1218
-                    'event_espresso'
1219
-                ),
1220
-                $module
1221
-            );
1222
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1223
-            return false;
1224
-        }
1225
-        // load the module class file
1226
-        require_once($module_path . $module_class . $module_ext);
1227
-        // verify that class exists
1228
-        if (! class_exists($module_class)) {
1229
-            $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1230
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1231
-            return false;
1232
-        }
1233
-        // add to array of registered modules
1234
-        EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1235
-        do_action(
1236
-            'AHEE__EE_Config__register_module__complete',
1237
-            $module_class,
1238
-            EE_Registry::instance()->modules->{$module_class}
1239
-        );
1240
-        return true;
1241
-    }
1242
-
1243
-
1244
-
1245
-    /**
1246
-     *    _initialize_modules
1247
-     *    allow modules to set hooks for the rest of the system
1248
-     *
1249
-     * @access private
1250
-     * @return void
1251
-     */
1252
-    private function _initialize_modules()
1253
-    {
1254
-        // cycle thru shortcode folders
1255
-        foreach (EE_Registry::instance()->modules as $module_class => $module_path) {
1256
-            // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1257
-            // which set hooks ?
1258
-            if (is_admin()) {
1259
-                // fire immediately
1260
-                call_user_func(array($module_class, 'set_hooks_admin'));
1261
-            } else {
1262
-                // delay until other systems are online
1263
-                add_action(
1264
-                    'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
1265
-                    array($module_class, 'set_hooks')
1266
-                );
1267
-            }
1268
-        }
1269
-    }
1270
-
1271
-
1272
-
1273
-    /**
1274
-     *    register_route - adds module method routes to route_map
1275
-     *
1276
-     * @access    public
1277
-     * @param    string $route       - "pretty" public alias for module method
1278
-     * @param    string $module      - module name (classname without EED_ prefix)
1279
-     * @param    string $method_name - the actual module method to be routed to
1280
-     * @param    string $key         - url param key indicating a route is being called
1281
-     * @return    bool
1282
-     */
1283
-    public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee')
1284
-    {
1285
-        do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1286
-        $module = str_replace('EED_', '', $module);
1287
-        $module_class = 'EED_' . $module;
1288
-        if (! isset(EE_Registry::instance()->modules->{$module_class})) {
1289
-            $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module);
1290
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1291
-            return false;
1292
-        }
1293
-        if (empty($route)) {
1294
-            $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route);
1295
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1296
-            return false;
1297
-        }
1298
-        if (! method_exists('EED_' . $module, $method_name)) {
1299
-            $msg = sprintf(
1300
-                __('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1301
-                $route
1302
-            );
1303
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1304
-            return false;
1305
-        }
1306
-        EE_Config::$_module_route_map[$key][$route] = array('EED_' . $module, $method_name);
1307
-        return true;
1308
-    }
1309
-
1310
-
1311
-
1312
-    /**
1313
-     *    get_route - get module method route
1314
-     *
1315
-     * @access    public
1316
-     * @param    string $route - "pretty" public alias for module method
1317
-     * @param    string $key   - url param key indicating a route is being called
1318
-     * @return    string
1319
-     */
1320
-    public static function get_route($route = null, $key = 'ee')
1321
-    {
1322
-        do_action('AHEE__EE_Config__get_route__begin', $route);
1323
-        $route = (string)apply_filters('FHEE__EE_Config__get_route', $route);
1324
-        if (isset(EE_Config::$_module_route_map[$key][$route])) {
1325
-            return EE_Config::$_module_route_map[$key][$route];
1326
-        }
1327
-        return null;
1328
-    }
1329
-
1330
-
1331
-
1332
-    /**
1333
-     *    get_routes - get ALL module method routes
1334
-     *
1335
-     * @access    public
1336
-     * @return    array
1337
-     */
1338
-    public static function get_routes()
1339
-    {
1340
-        return EE_Config::$_module_route_map;
1341
-    }
1342
-
1343
-
1344
-
1345
-    /**
1346
-     *    register_forward - allows modules to forward request to another module for further processing
1347
-     *
1348
-     * @access    public
1349
-     * @param    string       $route   - "pretty" public alias for module method
1350
-     * @param    integer      $status  - integer value corresponding  to status constant strings set in module parent
1351
-     *                                 class, allows different forwards to be served based on status
1352
-     * @param    array|string $forward - function name or array( class, method )
1353
-     * @param    string       $key     - url param key indicating a route is being called
1354
-     * @return    bool
1355
-     */
1356
-    public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee')
1357
-    {
1358
-        do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1359
-        if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1360
-            $msg = sprintf(
1361
-                __('The module route %s for this forward has not been registered.', 'event_espresso'),
1362
-                $route
1363
-            );
1364
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1365
-            return false;
1366
-        }
1367
-        if (empty($forward)) {
1368
-            $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route);
1369
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1370
-            return false;
1371
-        }
1372
-        if (is_array($forward)) {
1373
-            if (! isset($forward[1])) {
1374
-                $msg = sprintf(
1375
-                    __('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1376
-                    $route
1377
-                );
1378
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1379
-                return false;
1380
-            }
1381
-            if (! method_exists($forward[0], $forward[1])) {
1382
-                $msg = sprintf(
1383
-                    __('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1384
-                    $forward[1],
1385
-                    $route
1386
-                );
1387
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1388
-                return false;
1389
-            }
1390
-        } else if (! function_exists($forward)) {
1391
-            $msg = sprintf(
1392
-                __('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1393
-                $forward,
1394
-                $route
1395
-            );
1396
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1397
-            return false;
1398
-        }
1399
-        EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward;
1400
-        return true;
1401
-    }
1402
-
1403
-
1404
-
1405
-    /**
1406
-     *    get_forward - get forwarding route
1407
-     *
1408
-     * @access    public
1409
-     * @param    string  $route  - "pretty" public alias for module method
1410
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1411
-     *                           allows different forwards to be served based on status
1412
-     * @param    string  $key    - url param key indicating a route is being called
1413
-     * @return    string
1414
-     */
1415
-    public static function get_forward($route = null, $status = 0, $key = 'ee')
1416
-    {
1417
-        do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1418
-        if (isset(EE_Config::$_module_forward_map[$key][$route][$status])) {
1419
-            return apply_filters(
1420
-                'FHEE__EE_Config__get_forward',
1421
-                EE_Config::$_module_forward_map[$key][$route][$status],
1422
-                $route,
1423
-                $status
1424
-            );
1425
-        }
1426
-        return null;
1427
-    }
1428
-
1429
-
1430
-
1431
-    /**
1432
-     *    register_forward - allows modules to specify different view templates for different method routes and status
1433
-     *    results
1434
-     *
1435
-     * @access    public
1436
-     * @param    string  $route  - "pretty" public alias for module method
1437
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1438
-     *                           allows different views to be served based on status
1439
-     * @param    string  $view
1440
-     * @param    string  $key    - url param key indicating a route is being called
1441
-     * @return    bool
1442
-     */
1443
-    public static function register_view($route = null, $status = 0, $view = null, $key = 'ee')
1444
-    {
1445
-        do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1446
-        if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1447
-            $msg = sprintf(
1448
-                __('The module route %s for this view has not been registered.', 'event_espresso'),
1449
-                $route
1450
-            );
1451
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1452
-            return false;
1453
-        }
1454
-        if (! is_readable($view)) {
1455
-            $msg = sprintf(
1456
-                __(
1457
-                    'The %s view file could not be found or is not readable due to file permissions.',
1458
-                    'event_espresso'
1459
-                ),
1460
-                $view
1461
-            );
1462
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1463
-            return false;
1464
-        }
1465
-        EE_Config::$_module_view_map[$key][$route][absint($status)] = $view;
1466
-        return true;
1467
-    }
1468
-
1469
-
1470
-
1471
-    /**
1472
-     *    get_view - get view for route and status
1473
-     *
1474
-     * @access    public
1475
-     * @param    string  $route  - "pretty" public alias for module method
1476
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1477
-     *                           allows different views to be served based on status
1478
-     * @param    string  $key    - url param key indicating a route is being called
1479
-     * @return    string
1480
-     */
1481
-    public static function get_view($route = null, $status = 0, $key = 'ee')
1482
-    {
1483
-        do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1484
-        if (isset(EE_Config::$_module_view_map[$key][$route][$status])) {
1485
-            return apply_filters(
1486
-                'FHEE__EE_Config__get_view',
1487
-                EE_Config::$_module_view_map[$key][$route][$status],
1488
-                $route,
1489
-                $status
1490
-            );
1491
-        }
1492
-        return null;
1493
-    }
1494
-
1495
-
1496
-
1497
-    public function update_addon_option_names()
1498
-    {
1499
-        update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names);
1500
-    }
1501
-
1502
-
1503
-
1504
-    public function shutdown()
1505
-    {
1506
-        $this->update_addon_option_names();
1507
-    }
1508
-
1509
-
1510
-
1511
-    /**
1512
-     * @return LegacyShortcodesManager
1513
-     */
1514
-    public static function getLegacyShortcodesManager()
1515
-    {
1516
-
1517
-        if ( ! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) {
1518
-            EE_Config::instance()->legacy_shortcodes_manager = new LegacyShortcodesManager(
1519
-                EE_Registry::instance()
1520
-            );
1521
-        }
1522
-        return EE_Config::instance()->legacy_shortcodes_manager;
1523
-    }
1524
-
1525
-
1526
-
1527
-    /**
1528
-     * register_shortcode - makes core aware of this shortcode
1529
-     *
1530
-     * @deprecated 4.9.26
1531
-     * @param    string $shortcode_path - full path up to and including shortcode folder
1532
-     * @return    bool
1533
-     */
1534
-    public static function register_shortcode($shortcode_path = null)
1535
-    {
1536
-        EE_Error::doing_it_wrong(
1537
-            __METHOD__,
1538
-            __(
1539
-                'Usage is deprecated. Use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::registerShortcode() as direct replacement, or better yet, please see the new \EventEspresso\core\services\shortcodes\ShortcodesManager class.',
1540
-                'event_espresso'
1541
-            ),
1542
-            '4.9.26'
1543
-        );
1544
-        return EE_Config::instance()->getLegacyShortcodesManager()->registerShortcode($shortcode_path);
1545
-    }
1546
-
1547
-
1548
-
1549
-}
1550
-
1551
-
1552
-
1553
-/**
1554
- * Base class used for config classes. These classes should generally not have
1555
- * magic functions in use, except we'll allow them to magically set and get stuff...
1556
- * basically, they should just be well-defined stdClasses
1557
- */
1558
-class EE_Config_Base
1559
-{
1560
-
1561
-    /**
1562
-     * Utility function for escaping the value of a property and returning.
1563
-     *
1564
-     * @param string $property property name (checks to see if exists).
1565
-     * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1566
-     * @throws EE_Error
1567
-     */
1568
-    public function get_pretty($property)
1569
-    {
1570
-        if (! property_exists($this, $property)) {
1571
-            throw new EE_Error(
1572
-                sprintf(
1573
-                    __(
1574
-                        '%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.',
1575
-                        'event_espresso'
1576
-                    ),
1577
-                    get_class($this),
1578
-                    $property
1579
-                )
1580
-            );
1581
-        }
1582
-        //just handling escaping of strings for now.
1583
-        if (is_string($this->{$property})) {
1584
-            return stripslashes($this->{$property});
1585
-        }
1586
-        return $this->{$property};
1587
-    }
1588
-
1589
-
1590
-
1591
-    public function populate()
1592
-    {
1593
-        //grab defaults via a new instance of this class.
1594
-        $class_name = get_class($this);
1595
-        $defaults = new $class_name;
1596
-        //loop through the properties for this class and see if they are set.  If they are NOT, then grab the
1597
-        //default from our $defaults object.
1598
-        foreach (get_object_vars($defaults) as $property => $value) {
1599
-            if ($this->{$property} === null) {
1600
-                $this->{$property} = $value;
1601
-            }
1602
-        }
1603
-        //cleanup
1604
-        unset($defaults);
1605
-    }
1606
-
1607
-
1608
-
1609
-    /**
1610
-     *        __isset
1611
-     *
1612
-     * @param $a
1613
-     * @return bool
1614
-     */
1615
-    public function __isset($a)
1616
-    {
1617
-        return false;
1618
-    }
1619
-
1620
-
1621
-
1622
-    /**
1623
-     *        __unset
1624
-     *
1625
-     * @param $a
1626
-     * @return bool
1627
-     */
1628
-    public function __unset($a)
1629
-    {
1630
-        return false;
1631
-    }
1632
-
1633
-
1634
-
1635
-    /**
1636
-     *        __clone
1637
-     */
1638
-    public function __clone()
1639
-    {
1640
-    }
1641
-
1642
-
1643
-
1644
-    /**
1645
-     *        __wakeup
1646
-     */
1647
-    public function __wakeup()
1648
-    {
1649
-    }
1650
-
1651
-
1652
-
1653
-    /**
1654
-     *        __destruct
1655
-     */
1656
-    public function __destruct()
1657
-    {
1658
-    }
1659
-}
1660
-
1661
-
1662
-
1663
-/**
1664
- * Class for defining what's in the EE_Config relating to registration settings
1665
- */
1666
-class EE_Core_Config extends EE_Config_Base
1667
-{
1668
-
1669
-    public $current_blog_id;
1670
-
1671
-    public $ee_ueip_optin;
1672
-
1673
-    public $ee_ueip_has_notified;
1674
-
1675
-    /**
1676
-     * Not to be confused with the 4 critical page variables (See
1677
-     * get_critical_pages_array()), this is just an array of wp posts that have EE
1678
-     * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode
1679
-     * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array.
1680
-     *
1681
-     * @var array
1682
-     */
1683
-    public $post_shortcodes;
1684
-
1685
-    public $module_route_map;
1686
-
1687
-    public $module_forward_map;
1688
-
1689
-    public $module_view_map;
1690
-
1691
-    /**
1692
-     * The next 4 vars are the IDs of critical EE pages.
1693
-     *
1694
-     * @var int
1695
-     */
1696
-    public $reg_page_id;
1697
-
1698
-    public $txn_page_id;
1699
-
1700
-    public $thank_you_page_id;
1701
-
1702
-    public $cancel_page_id;
1703
-
1704
-    /**
1705
-     * The next 4 vars are the URLs of critical EE pages.
1706
-     *
1707
-     * @var int
1708
-     */
1709
-    public $reg_page_url;
1710
-
1711
-    public $txn_page_url;
1712
-
1713
-    public $thank_you_page_url;
1714
-
1715
-    public $cancel_page_url;
1716
-
1717
-    /**
1718
-     * The next vars relate to the custom slugs for EE CPT routes
1719
-     */
1720
-    public $event_cpt_slug;
1721
-
1722
-
1723
-    /**
1724
-     * This caches the _ee_ueip_option in case this config is reset in the same
1725
-     * request across blog switches in a multisite context.
1726
-     * Avoids extra queries to the db for this option.
1727
-     *
1728
-     * @var bool
1729
-     */
1730
-    public static $ee_ueip_option;
1731
-
1732
-
1733
-
1734
-    /**
1735
-     *    class constructor
1736
-     *
1737
-     * @access    public
1738
-     */
1739
-    public function __construct()
1740
-    {
1741
-        // set default organization settings
1742
-        $this->current_blog_id = get_current_blog_id();
1743
-        $this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id;
1744
-        $this->ee_ueip_optin = $this->_get_main_ee_ueip_optin();
1745
-        $this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true;
1746
-        $this->post_shortcodes = array();
1747
-        $this->module_route_map = array();
1748
-        $this->module_forward_map = array();
1749
-        $this->module_view_map = array();
1750
-        // critical EE page IDs
1751
-        $this->reg_page_id = 0;
1752
-        $this->txn_page_id = 0;
1753
-        $this->thank_you_page_id = 0;
1754
-        $this->cancel_page_id = 0;
1755
-        // critical EE page URLs
1756
-        $this->reg_page_url = '';
1757
-        $this->txn_page_url = '';
1758
-        $this->thank_you_page_url = '';
1759
-        $this->cancel_page_url = '';
1760
-        //cpt slugs
1761
-        $this->event_cpt_slug = __('events', 'event_espresso');
1762
-        //ueip constant check
1763
-        if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) {
1764
-            $this->ee_ueip_optin = false;
1765
-            $this->ee_ueip_has_notified = true;
1766
-        }
1767
-    }
1768
-
1769
-
1770
-
1771
-    /**
1772
-     * @return array
1773
-     */
1774
-    public function get_critical_pages_array()
1775
-    {
1776
-        return array(
1777
-            $this->reg_page_id,
1778
-            $this->txn_page_id,
1779
-            $this->thank_you_page_id,
1780
-            $this->cancel_page_id,
1781
-        );
1782
-    }
1783
-
1784
-
1785
-
1786
-    /**
1787
-     * @return array
1788
-     */
1789
-    public function get_critical_pages_shortcodes_array()
1790
-    {
1791
-        return array(
1792
-            $this->reg_page_id       => 'ESPRESSO_CHECKOUT',
1793
-            $this->txn_page_id       => 'ESPRESSO_TXN_PAGE',
1794
-            $this->thank_you_page_id => 'ESPRESSO_THANK_YOU',
1795
-            $this->cancel_page_id    => 'ESPRESSO_CANCELLED',
1796
-        );
1797
-    }
1798
-
1799
-
1800
-
1801
-    /**
1802
-     *  gets/returns URL for EE reg_page
1803
-     *
1804
-     * @access    public
1805
-     * @return    string
1806
-     */
1807
-    public function reg_page_url()
1808
-    {
1809
-        if (! $this->reg_page_url) {
1810
-            $this->reg_page_url = add_query_arg(
1811
-                                      array('uts' => time()),
1812
-                                      get_permalink($this->reg_page_id)
1813
-                                  ) . '#checkout';
1814
-        }
1815
-        return $this->reg_page_url;
1816
-    }
1817
-
1818
-
1819
-
1820
-    /**
1821
-     *  gets/returns URL for EE txn_page
1822
-     *
1823
-     * @param array $query_args like what gets passed to
1824
-     *                          add_query_arg() as the first argument
1825
-     * @access    public
1826
-     * @return    string
1827
-     */
1828
-    public function txn_page_url($query_args = array())
1829
-    {
1830
-        if (! $this->txn_page_url) {
1831
-            $this->txn_page_url = get_permalink($this->txn_page_id);
1832
-        }
1833
-        if ($query_args) {
1834
-            return add_query_arg($query_args, $this->txn_page_url);
1835
-        } else {
1836
-            return $this->txn_page_url;
1837
-        }
1838
-    }
1839
-
1840
-
1841
-
1842
-    /**
1843
-     *  gets/returns URL for EE thank_you_page
1844
-     *
1845
-     * @param array $query_args like what gets passed to
1846
-     *                          add_query_arg() as the first argument
1847
-     * @access    public
1848
-     * @return    string
1849
-     */
1850
-    public function thank_you_page_url($query_args = array())
1851
-    {
1852
-        if (! $this->thank_you_page_url) {
1853
-            $this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1854
-        }
1855
-        if ($query_args) {
1856
-            return add_query_arg($query_args, $this->thank_you_page_url);
1857
-        } else {
1858
-            return $this->thank_you_page_url;
1859
-        }
1860
-    }
1861
-
1862
-
1863
-
1864
-    /**
1865
-     *  gets/returns URL for EE cancel_page
1866
-     *
1867
-     * @access    public
1868
-     * @return    string
1869
-     */
1870
-    public function cancel_page_url()
1871
-    {
1872
-        if (! $this->cancel_page_url) {
1873
-            $this->cancel_page_url = get_permalink($this->cancel_page_id);
1874
-        }
1875
-        return $this->cancel_page_url;
1876
-    }
1877
-
1878
-
1879
-
1880
-    /**
1881
-     * Resets all critical page urls to their original state.  Used primarily by the __sleep() magic method currently.
1882
-     *
1883
-     * @since 4.7.5
1884
-     */
1885
-    protected function _reset_urls()
1886
-    {
1887
-        $this->reg_page_url = '';
1888
-        $this->txn_page_url = '';
1889
-        $this->cancel_page_url = '';
1890
-        $this->thank_you_page_url = '';
1891
-    }
1892
-
1893
-
1894
-
1895
-    /**
1896
-     * Used to return what the opt-in value is set for the EE User Experience Program.
1897
-     * This accounts for multisite and this value being requested for a subsite.  In multisite, the value is set
1898
-     * on the main site only.
1899
-     *
1900
-     * @return mixed
1901
-     */
1902
-    protected function _get_main_ee_ueip_optin()
1903
-    {
1904
-        //if this is the main site then we can just bypass our direct query.
1905
-        if (is_main_site()) {
1906
-            return get_option('ee_ueip_optin', false);
1907
-        }
1908
-        //is this already cached for this request?  If so use it.
1909
-        if ( ! empty(EE_Core_Config::$ee_ueip_option)) {
1910
-            return EE_Core_Config::$ee_ueip_option;
1911
-        }
1912
-        global $wpdb;
1913
-        $current_network_main_site = is_multisite() ? get_current_site() : null;
1914
-        $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1915
-        $option = 'ee_ueip_optin';
1916
-        //set correct table for query
1917
-        $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1918
-        //rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
1919
-        //get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be
1920
-        //re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1921
-        //this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1922
-        //for the purpose of caching.
1923
-        $pre = apply_filters('pre_option_' . $option, false, $option);
1924
-        if (false !== $pre) {
1925
-            EE_Core_Config::$ee_ueip_option = $pre;
1926
-            return EE_Core_Config::$ee_ueip_option;
1927
-        }
1928
-        $row = $wpdb->get_row($wpdb->prepare("SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1",
1929
-            $option));
1930
-        if (is_object($row)) {
1931
-            $value = $row->option_value;
1932
-        } else { //option does not exist so use default.
1933
-            return apply_filters('default_option_' . $option, false, $option);
1934
-        }
1935
-        EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
1936
-        return EE_Core_Config::$ee_ueip_option;
1937
-    }
1938
-
1939
-
1940
-
1941
-    /**
1942
-     * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values
1943
-     * on the object.
1944
-     *
1945
-     * @return array
1946
-     */
1947
-    public function __sleep()
1948
-    {
1949
-        //reset all url properties
1950
-        $this->_reset_urls();
1951
-        //return what to save to db
1952
-        return array_keys(get_object_vars($this));
1953
-    }
1954
-
1955
-}
1956
-
1957
-
1958
-
1959
-/**
1960
- * Config class for storing info on the Organization
1961
- */
1962
-class EE_Organization_Config extends EE_Config_Base
1963
-{
1964
-
1965
-    /**
1966
-     * @var string $name
1967
-     * eg EE4.1
1968
-     */
1969
-    public $name;
1970
-
1971
-    /**
1972
-     * @var string $address_1
1973
-     * eg 123 Onna Road
1974
-     */
1975
-    public $address_1;
1976
-
1977
-    /**
1978
-     * @var string $address_2
1979
-     * eg PO Box 123
1980
-     */
1981
-    public $address_2;
1982
-
1983
-    /**
1984
-     * @var string $city
1985
-     * eg Inna City
1986
-     */
1987
-    public $city;
1988
-
1989
-    /**
1990
-     * @var int $STA_ID
1991
-     * eg 4
1992
-     */
1993
-    public $STA_ID;
1994
-
1995
-    /**
1996
-     * @var string $CNT_ISO
1997
-     * eg US
1998
-     */
1999
-    public $CNT_ISO;
2000
-
2001
-    /**
2002
-     * @var string $zip
2003
-     * eg 12345  or V1A 2B3
2004
-     */
2005
-    public $zip;
2006
-
2007
-    /**
2008
-     * @var string $email
2009
-     * eg [email protected]
2010
-     */
2011
-    public $email;
2012
-
2013
-
2014
-    /**
2015
-     * @var string $phone
2016
-     * eg. 111-111-1111
2017
-     */
2018
-    public $phone;
2019
-
2020
-
2021
-    /**
2022
-     * @var string $vat
2023
-     * VAT/Tax Number
2024
-     */
2025
-    public $vat;
2026
-
2027
-    /**
2028
-     * @var string $logo_url
2029
-     * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg
2030
-     */
2031
-    public $logo_url;
2032
-
2033
-
2034
-    /**
2035
-     * The below are all various properties for holding links to organization social network profiles
2036
-     *
2037
-     * @var string
2038
-     */
2039
-    /**
2040
-     * facebook (facebook.com/profile.name)
2041
-     *
2042
-     * @var string
2043
-     */
2044
-    public $facebook;
2045
-
2046
-
2047
-    /**
2048
-     * twitter (twitter.com/twitter_handle)
2049
-     *
2050
-     * @var string
2051
-     */
2052
-    public $twitter;
2053
-
2054
-
2055
-    /**
2056
-     * linkedin (linkedin.com/in/profile_name)
2057
-     *
2058
-     * @var string
2059
-     */
2060
-    public $linkedin;
2061
-
2062
-
2063
-    /**
2064
-     * pinterest (www.pinterest.com/profile_name)
2065
-     *
2066
-     * @var string
2067
-     */
2068
-    public $pinterest;
2069
-
2070
-
2071
-    /**
2072
-     * google+ (google.com/+profileName)
2073
-     *
2074
-     * @var string
2075
-     */
2076
-    public $google;
2077
-
2078
-
2079
-    /**
2080
-     * instagram (instagram.com/handle)
2081
-     *
2082
-     * @var string
2083
-     */
2084
-    public $instagram;
2085
-
2086
-
2087
-
2088
-    /**
2089
-     *    class constructor
2090
-     *
2091
-     * @access    public
2092
-     */
2093
-    public function __construct()
2094
-    {
2095
-        // set default organization settings
2096
-        $this->name = get_bloginfo('name');
2097
-        $this->address_1 = '123 Onna Road';
2098
-        $this->address_2 = 'PO Box 123';
2099
-        $this->city = 'Inna City';
2100
-        $this->STA_ID = 4;
2101
-        $this->CNT_ISO = 'US';
2102
-        $this->zip = '12345';
2103
-        $this->email = get_bloginfo('admin_email');
2104
-        $this->phone = '';
2105
-        $this->vat = '123456789';
2106
-        $this->logo_url = '';
2107
-        $this->facebook = '';
2108
-        $this->twitter = '';
2109
-        $this->linkedin = '';
2110
-        $this->pinterest = '';
2111
-        $this->google = '';
2112
-        $this->instagram = '';
2113
-    }
2114
-
2115
-}
2116
-
2117
-
2118
-
2119
-/**
2120
- * Class for defining what's in the EE_Config relating to currency
2121
- */
2122
-class EE_Currency_Config extends EE_Config_Base
2123
-{
2124
-
2125
-    /**
2126
-     * @var string $code
2127
-     * eg 'US'
2128
-     */
2129
-    public $code;
2130
-
2131
-    /**
2132
-     * @var string $name
2133
-     * eg 'Dollar'
2134
-     */
2135
-    public $name;
2136
-
2137
-    /**
2138
-     * plural name
2139
-     *
2140
-     * @var string $plural
2141
-     * eg 'Dollars'
2142
-     */
2143
-    public $plural;
2144
-
2145
-    /**
2146
-     * currency sign
2147
-     *
2148
-     * @var string $sign
2149
-     * eg '$'
2150
-     */
2151
-    public $sign;
2152
-
2153
-    /**
2154
-     * Whether the currency sign should come before the number or not
2155
-     *
2156
-     * @var boolean $sign_b4
2157
-     */
2158
-    public $sign_b4;
2159
-
2160
-    /**
2161
-     * How many digits should come after the decimal place
2162
-     *
2163
-     * @var int $dec_plc
2164
-     */
2165
-    public $dec_plc;
2166
-
2167
-    /**
2168
-     * Symbol to use for decimal mark
2169
-     *
2170
-     * @var string $dec_mrk
2171
-     * eg '.'
2172
-     */
2173
-    public $dec_mrk;
2174
-
2175
-    /**
2176
-     * Symbol to use for thousands
2177
-     *
2178
-     * @var string $thsnds
2179
-     * eg ','
2180
-     */
2181
-    public $thsnds;
2182
-
2183
-
2184
-    /**
2185
-     *    class constructor
2186
-     *
2187
-     * @access    public
2188
-     * @param string             $CNT_ISO
2189
-     * @param CountryCurrencyDao $country_currencies
2190
-     * @throws EE_Error
2191
-     * @throws InvalidArgumentException
2192
-     * @throws ReflectionException
2193
-     * @throws InvalidDataTypeException
2194
-     * @throws InvalidInterfaceException
2195
-     */
2196
-    public function __construct($CNT_ISO = '', CountryCurrencyDao $country_currencies = null)
2197
-    {
2198
-        if(! $country_currencies instanceof CountryCurrencyDao){
2199
-            $country_currencies = new CountryCurrencyDao();
2200
-        }
2201
-        // so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists
2202
-        if (! empty($CNT_ISO)) {
2203
-            // retrieve the country settings from the db, just in case they have been customized
2204
-            $country_currency = $country_currencies->getCountryCurrencyByIsoCode($CNT_ISO);
2205
-            $this->code = $country_currency['CurrencyCode'];    // currency code: USD, CAD, EUR
2206
-            $this->name = $country_currency['CurrencyNameSingle'];    // Dollar
2207
-            $this->plural = $country_currency['CurrencyNamePlural'];    // Dollars
2208
-            $this->sign = $country_currency['CurrencySign'];            // currency sign: $
2209
-            $this->sign_b4 = $country_currency['CurrencySignB4'];        // currency sign before or after: $TRUE  or  FALSE$
2210
-            $this->dec_plc = $country_currency['CurrencyDecimalPlaces'];    // decimal places: 2 = 0.00  3 = 0.000
2211
-            $this->dec_mrk = $country_currency['CurrencyDecimalMark'];    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2212
-            $this->thsnds = $country_currency['CurrencyThousands'];    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2213
-        }
2214
-        // fallback to hardcoded defaults, in case the above failed
2215
-        if (empty($this->code)) {
2216
-            // set default currency settings
2217
-            $this->code = 'USD';    // currency code: USD, CAD, EUR
2218
-            $this->name = esc_html__('Dollar', 'event_espresso');    // Dollar
2219
-            $this->plural = esc_html__('Dollars', 'event_espresso');    // Dollars
2220
-            $this->sign = '$';    // currency sign: $
2221
-            $this->sign_b4 = true;    // currency sign before or after: $TRUE  or  FALSE$
2222
-            $this->dec_plc = 2;    // decimal places: 2 = 0.00  3 = 0.000
2223
-            $this->dec_mrk = '.';    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2224
-            $this->thsnds = ',';    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2225
-        }
2226
-    }
2227
-
2228
-
2229
-    /**
2230
-     * @param EE_Country $country
2231
-     * @throws EE_Error
2232
-     * @throws InvalidArgumentException
2233
-     * @throws InvalidDataTypeException
2234
-     * @throws InvalidInterfaceException
2235
-     * @throws ReflectionException
2236
-     */
2237
-    public function setFromCountry(EE_Country $country)
2238
-    {
2239
-        $this->code    = $country->currency_code();    // currency code: USD, CAD, EUR
2240
-        $this->name    = $country->currency_name_single();    // Dollar
2241
-        $this->plural  = $country->currency_name_plural();    // Dollars
2242
-        $this->sign    = $country->currency_sign();            // currency sign: $
2243
-        $this->sign_b4 = $country->currency_sign_before();        // currency sign before or after: $TRUE  or  FALSE$
2244
-        $this->dec_plc = $country->currency_decimal_places();    // decimal places: 2 = 0.00  3 = 0.000
2245
-        $this->dec_mrk = $country->currency_decimal_mark();    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2246
-        $this->thsnds  = $country->currency_thousands_separator();    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2247
-    }
2248
-}
2249
-
2250
-
2251
-
2252
-/**
2253
- * Class for defining what's in the EE_Config relating to registration settings
2254
- */
2255
-class EE_Registration_Config extends EE_Config_Base
2256
-{
2257
-
2258
-    /**
2259
-     * Default registration status
2260
-     *
2261
-     * @var string $default_STS_ID
2262
-     * eg 'RPP'
2263
-     */
2264
-    public $default_STS_ID;
2265
-
2266
-
2267
-    /**
2268
-     * For new events, this will be the default value for the maximum number of tickets (equivalent to maximum number of
2269
-     * registrations)
2270
-     * @var int
2271
-     */
2272
-    public $default_maximum_number_of_tickets;
2273
-
2274
-
2275
-    /**
2276
-     * level of validation to apply to email addresses
2277
-     *
2278
-     * @var string $email_validation_level
2279
-     * options: 'basic', 'wp_default', 'i18n', 'i18n_dns'
2280
-     */
2281
-    public $email_validation_level;
2282
-
2283
-    /**
2284
-     *    whether or not to show alternate payment options during the reg process if payment status is pending
2285
-     *
2286
-     * @var boolean $show_pending_payment_options
2287
-     */
2288
-    public $show_pending_payment_options;
2289
-
2290
-    /**
2291
-     * Whether to skip the registration confirmation page
2292
-     *
2293
-     * @var boolean $skip_reg_confirmation
2294
-     */
2295
-    public $skip_reg_confirmation;
2296
-
2297
-    /**
2298
-     * an array of SPCO reg steps where:
2299
-     *        the keys denotes the reg step order
2300
-     *        each element consists of an array with the following elements:
2301
-     *            "file_path" => the file path to the EE_SPCO_Reg_Step class
2302
-     *            "class_name" => the specific EE_SPCO_Reg_Step child class name
2303
-     *            "slug" => the URL param used to trigger the reg step
2304
-     *
2305
-     * @var array $reg_steps
2306
-     */
2307
-    public $reg_steps;
2308
-
2309
-    /**
2310
-     * Whether registration confirmation should be the last page of SPCO
2311
-     *
2312
-     * @var boolean $reg_confirmation_last
2313
-     */
2314
-    public $reg_confirmation_last;
2315
-
2316
-    /**
2317
-     * Whether or not to enable the EE Bot Trap
2318
-     *
2319
-     * @var boolean $use_bot_trap
2320
-     */
2321
-    public $use_bot_trap;
2322
-
2323
-    /**
2324
-     * Whether or not to encrypt some data sent by the EE Bot Trap
2325
-     *
2326
-     * @var boolean $use_encryption
2327
-     */
2328
-    public $use_encryption;
1549
+}
2329 1550
 
2330
-    /**
2331
-     * Whether or not to use ReCaptcha
2332
-     *
2333
-     * @var boolean $use_captcha
2334
-     */
2335
-    public $use_captcha;
2336 1551
 
2337
-    /**
2338
-     * ReCaptcha Theme
2339
-     *
2340
-     * @var string $recaptcha_theme
2341
-     *    options: 'dark    ', 'light'
2342
-     */
2343
-    public $recaptcha_theme;
2344 1552
 
2345
-    /**
2346
-     * ReCaptcha Type
2347
-     *
2348
-     * @var string $recaptcha_type
2349
-     *    options: 'audio', 'image'
2350
-     */
2351
-    public $recaptcha_type;
1553
+/**
1554
+ * Base class used for config classes. These classes should generally not have
1555
+ * magic functions in use, except we'll allow them to magically set and get stuff...
1556
+ * basically, they should just be well-defined stdClasses
1557
+ */
1558
+class EE_Config_Base
1559
+{
2352 1560
 
2353
-    /**
2354
-     * ReCaptcha language
2355
-     *
2356
-     * @var string $recaptcha_language
2357
-     * eg 'en'
2358
-     */
2359
-    public $recaptcha_language;
1561
+	/**
1562
+	 * Utility function for escaping the value of a property and returning.
1563
+	 *
1564
+	 * @param string $property property name (checks to see if exists).
1565
+	 * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1566
+	 * @throws EE_Error
1567
+	 */
1568
+	public function get_pretty($property)
1569
+	{
1570
+		if (! property_exists($this, $property)) {
1571
+			throw new EE_Error(
1572
+				sprintf(
1573
+					__(
1574
+						'%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.',
1575
+						'event_espresso'
1576
+					),
1577
+					get_class($this),
1578
+					$property
1579
+				)
1580
+			);
1581
+		}
1582
+		//just handling escaping of strings for now.
1583
+		if (is_string($this->{$property})) {
1584
+			return stripslashes($this->{$property});
1585
+		}
1586
+		return $this->{$property};
1587
+	}
1588
+
1589
+
1590
+
1591
+	public function populate()
1592
+	{
1593
+		//grab defaults via a new instance of this class.
1594
+		$class_name = get_class($this);
1595
+		$defaults = new $class_name;
1596
+		//loop through the properties for this class and see if they are set.  If they are NOT, then grab the
1597
+		//default from our $defaults object.
1598
+		foreach (get_object_vars($defaults) as $property => $value) {
1599
+			if ($this->{$property} === null) {
1600
+				$this->{$property} = $value;
1601
+			}
1602
+		}
1603
+		//cleanup
1604
+		unset($defaults);
1605
+	}
1606
+
1607
+
1608
+
1609
+	/**
1610
+	 *        __isset
1611
+	 *
1612
+	 * @param $a
1613
+	 * @return bool
1614
+	 */
1615
+	public function __isset($a)
1616
+	{
1617
+		return false;
1618
+	}
1619
+
1620
+
1621
+
1622
+	/**
1623
+	 *        __unset
1624
+	 *
1625
+	 * @param $a
1626
+	 * @return bool
1627
+	 */
1628
+	public function __unset($a)
1629
+	{
1630
+		return false;
1631
+	}
1632
+
1633
+
1634
+
1635
+	/**
1636
+	 *        __clone
1637
+	 */
1638
+	public function __clone()
1639
+	{
1640
+	}
1641
+
1642
+
1643
+
1644
+	/**
1645
+	 *        __wakeup
1646
+	 */
1647
+	public function __wakeup()
1648
+	{
1649
+	}
1650
+
1651
+
1652
+
1653
+	/**
1654
+	 *        __destruct
1655
+	 */
1656
+	public function __destruct()
1657
+	{
1658
+	}
1659
+}
2360 1660
 
2361
-    /**
2362
-     * ReCaptcha public key
2363
-     *
2364
-     * @var string $recaptcha_publickey
2365
-     */
2366
-    public $recaptcha_publickey;
2367 1661
 
2368
-    /**
2369
-     * ReCaptcha private key
2370
-     *
2371
-     * @var string $recaptcha_privatekey
2372
-     */
2373
-    public $recaptcha_privatekey;
2374 1662
 
2375
-    /**
2376
-     * ReCaptcha width
2377
-     *
2378
-     * @var int $recaptcha_width
2379
-     * @deprecated
2380
-     */
2381
-    public $recaptcha_width;
1663
+/**
1664
+ * Class for defining what's in the EE_Config relating to registration settings
1665
+ */
1666
+class EE_Core_Config extends EE_Config_Base
1667
+{
2382 1668
 
2383
-    /**
2384
-     * Whether or not invalid attempts to directly access the registration checkout page should be tracked.
2385
-     *
2386
-     * @var boolean $track_invalid_checkout_access
2387
-     */
2388
-    protected $track_invalid_checkout_access = true;
1669
+	public $current_blog_id;
1670
+
1671
+	public $ee_ueip_optin;
1672
+
1673
+	public $ee_ueip_has_notified;
1674
+
1675
+	/**
1676
+	 * Not to be confused with the 4 critical page variables (See
1677
+	 * get_critical_pages_array()), this is just an array of wp posts that have EE
1678
+	 * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode
1679
+	 * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array.
1680
+	 *
1681
+	 * @var array
1682
+	 */
1683
+	public $post_shortcodes;
1684
+
1685
+	public $module_route_map;
1686
+
1687
+	public $module_forward_map;
1688
+
1689
+	public $module_view_map;
1690
+
1691
+	/**
1692
+	 * The next 4 vars are the IDs of critical EE pages.
1693
+	 *
1694
+	 * @var int
1695
+	 */
1696
+	public $reg_page_id;
1697
+
1698
+	public $txn_page_id;
1699
+
1700
+	public $thank_you_page_id;
1701
+
1702
+	public $cancel_page_id;
1703
+
1704
+	/**
1705
+	 * The next 4 vars are the URLs of critical EE pages.
1706
+	 *
1707
+	 * @var int
1708
+	 */
1709
+	public $reg_page_url;
1710
+
1711
+	public $txn_page_url;
1712
+
1713
+	public $thank_you_page_url;
1714
+
1715
+	public $cancel_page_url;
1716
+
1717
+	/**
1718
+	 * The next vars relate to the custom slugs for EE CPT routes
1719
+	 */
1720
+	public $event_cpt_slug;
1721
+
1722
+
1723
+	/**
1724
+	 * This caches the _ee_ueip_option in case this config is reset in the same
1725
+	 * request across blog switches in a multisite context.
1726
+	 * Avoids extra queries to the db for this option.
1727
+	 *
1728
+	 * @var bool
1729
+	 */
1730
+	public static $ee_ueip_option;
1731
+
1732
+
1733
+
1734
+	/**
1735
+	 *    class constructor
1736
+	 *
1737
+	 * @access    public
1738
+	 */
1739
+	public function __construct()
1740
+	{
1741
+		// set default organization settings
1742
+		$this->current_blog_id = get_current_blog_id();
1743
+		$this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id;
1744
+		$this->ee_ueip_optin = $this->_get_main_ee_ueip_optin();
1745
+		$this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true;
1746
+		$this->post_shortcodes = array();
1747
+		$this->module_route_map = array();
1748
+		$this->module_forward_map = array();
1749
+		$this->module_view_map = array();
1750
+		// critical EE page IDs
1751
+		$this->reg_page_id = 0;
1752
+		$this->txn_page_id = 0;
1753
+		$this->thank_you_page_id = 0;
1754
+		$this->cancel_page_id = 0;
1755
+		// critical EE page URLs
1756
+		$this->reg_page_url = '';
1757
+		$this->txn_page_url = '';
1758
+		$this->thank_you_page_url = '';
1759
+		$this->cancel_page_url = '';
1760
+		//cpt slugs
1761
+		$this->event_cpt_slug = __('events', 'event_espresso');
1762
+		//ueip constant check
1763
+		if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) {
1764
+			$this->ee_ueip_optin = false;
1765
+			$this->ee_ueip_has_notified = true;
1766
+		}
1767
+	}
1768
+
1769
+
1770
+
1771
+	/**
1772
+	 * @return array
1773
+	 */
1774
+	public function get_critical_pages_array()
1775
+	{
1776
+		return array(
1777
+			$this->reg_page_id,
1778
+			$this->txn_page_id,
1779
+			$this->thank_you_page_id,
1780
+			$this->cancel_page_id,
1781
+		);
1782
+	}
1783
+
1784
+
1785
+
1786
+	/**
1787
+	 * @return array
1788
+	 */
1789
+	public function get_critical_pages_shortcodes_array()
1790
+	{
1791
+		return array(
1792
+			$this->reg_page_id       => 'ESPRESSO_CHECKOUT',
1793
+			$this->txn_page_id       => 'ESPRESSO_TXN_PAGE',
1794
+			$this->thank_you_page_id => 'ESPRESSO_THANK_YOU',
1795
+			$this->cancel_page_id    => 'ESPRESSO_CANCELLED',
1796
+		);
1797
+	}
1798
+
1799
+
1800
+
1801
+	/**
1802
+	 *  gets/returns URL for EE reg_page
1803
+	 *
1804
+	 * @access    public
1805
+	 * @return    string
1806
+	 */
1807
+	public function reg_page_url()
1808
+	{
1809
+		if (! $this->reg_page_url) {
1810
+			$this->reg_page_url = add_query_arg(
1811
+									  array('uts' => time()),
1812
+									  get_permalink($this->reg_page_id)
1813
+								  ) . '#checkout';
1814
+		}
1815
+		return $this->reg_page_url;
1816
+	}
1817
+
1818
+
1819
+
1820
+	/**
1821
+	 *  gets/returns URL for EE txn_page
1822
+	 *
1823
+	 * @param array $query_args like what gets passed to
1824
+	 *                          add_query_arg() as the first argument
1825
+	 * @access    public
1826
+	 * @return    string
1827
+	 */
1828
+	public function txn_page_url($query_args = array())
1829
+	{
1830
+		if (! $this->txn_page_url) {
1831
+			$this->txn_page_url = get_permalink($this->txn_page_id);
1832
+		}
1833
+		if ($query_args) {
1834
+			return add_query_arg($query_args, $this->txn_page_url);
1835
+		} else {
1836
+			return $this->txn_page_url;
1837
+		}
1838
+	}
1839
+
1840
+
1841
+
1842
+	/**
1843
+	 *  gets/returns URL for EE thank_you_page
1844
+	 *
1845
+	 * @param array $query_args like what gets passed to
1846
+	 *                          add_query_arg() as the first argument
1847
+	 * @access    public
1848
+	 * @return    string
1849
+	 */
1850
+	public function thank_you_page_url($query_args = array())
1851
+	{
1852
+		if (! $this->thank_you_page_url) {
1853
+			$this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1854
+		}
1855
+		if ($query_args) {
1856
+			return add_query_arg($query_args, $this->thank_you_page_url);
1857
+		} else {
1858
+			return $this->thank_you_page_url;
1859
+		}
1860
+	}
1861
+
1862
+
1863
+
1864
+	/**
1865
+	 *  gets/returns URL for EE cancel_page
1866
+	 *
1867
+	 * @access    public
1868
+	 * @return    string
1869
+	 */
1870
+	public function cancel_page_url()
1871
+	{
1872
+		if (! $this->cancel_page_url) {
1873
+			$this->cancel_page_url = get_permalink($this->cancel_page_id);
1874
+		}
1875
+		return $this->cancel_page_url;
1876
+	}
1877
+
1878
+
1879
+
1880
+	/**
1881
+	 * Resets all critical page urls to their original state.  Used primarily by the __sleep() magic method currently.
1882
+	 *
1883
+	 * @since 4.7.5
1884
+	 */
1885
+	protected function _reset_urls()
1886
+	{
1887
+		$this->reg_page_url = '';
1888
+		$this->txn_page_url = '';
1889
+		$this->cancel_page_url = '';
1890
+		$this->thank_you_page_url = '';
1891
+	}
1892
+
1893
+
1894
+
1895
+	/**
1896
+	 * Used to return what the opt-in value is set for the EE User Experience Program.
1897
+	 * This accounts for multisite and this value being requested for a subsite.  In multisite, the value is set
1898
+	 * on the main site only.
1899
+	 *
1900
+	 * @return mixed
1901
+	 */
1902
+	protected function _get_main_ee_ueip_optin()
1903
+	{
1904
+		//if this is the main site then we can just bypass our direct query.
1905
+		if (is_main_site()) {
1906
+			return get_option('ee_ueip_optin', false);
1907
+		}
1908
+		//is this already cached for this request?  If so use it.
1909
+		if ( ! empty(EE_Core_Config::$ee_ueip_option)) {
1910
+			return EE_Core_Config::$ee_ueip_option;
1911
+		}
1912
+		global $wpdb;
1913
+		$current_network_main_site = is_multisite() ? get_current_site() : null;
1914
+		$current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1915
+		$option = 'ee_ueip_optin';
1916
+		//set correct table for query
1917
+		$table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1918
+		//rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
1919
+		//get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be
1920
+		//re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1921
+		//this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1922
+		//for the purpose of caching.
1923
+		$pre = apply_filters('pre_option_' . $option, false, $option);
1924
+		if (false !== $pre) {
1925
+			EE_Core_Config::$ee_ueip_option = $pre;
1926
+			return EE_Core_Config::$ee_ueip_option;
1927
+		}
1928
+		$row = $wpdb->get_row($wpdb->prepare("SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1",
1929
+			$option));
1930
+		if (is_object($row)) {
1931
+			$value = $row->option_value;
1932
+		} else { //option does not exist so use default.
1933
+			return apply_filters('default_option_' . $option, false, $option);
1934
+		}
1935
+		EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
1936
+		return EE_Core_Config::$ee_ueip_option;
1937
+	}
1938
+
1939
+
1940
+
1941
+	/**
1942
+	 * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values
1943
+	 * on the object.
1944
+	 *
1945
+	 * @return array
1946
+	 */
1947
+	public function __sleep()
1948
+	{
1949
+		//reset all url properties
1950
+		$this->_reset_urls();
1951
+		//return what to save to db
1952
+		return array_keys(get_object_vars($this));
1953
+	}
2389 1954
 
1955
+}
2390 1956
 
2391 1957
 
2392
-    /**
2393
-     *    class constructor
2394
-     *
2395
-     * @access    public
2396
-     */
2397
-    public function __construct()
2398
-    {
2399
-        // set default registration settings
2400
-        $this->default_STS_ID = EEM_Registration::status_id_pending_payment;
2401
-        $this->email_validation_level = 'wp_default';
2402
-        $this->show_pending_payment_options = true;
2403
-        $this->skip_reg_confirmation = false;
2404
-        $this->reg_steps = array();
2405
-        $this->reg_confirmation_last = false;
2406
-        $this->use_bot_trap = true;
2407
-        $this->use_encryption = true;
2408
-        $this->use_captcha = false;
2409
-        $this->recaptcha_theme = 'light';
2410
-        $this->recaptcha_type = 'image';
2411
-        $this->recaptcha_language = 'en';
2412
-        $this->recaptcha_publickey = null;
2413
-        $this->recaptcha_privatekey = null;
2414
-        $this->recaptcha_width = 500;
2415
-        $this->default_maximum_number_of_tickets = 10;
2416
-    }
2417
-
2418
-
2419
-
2420
-    /**
2421
-     * This is called by the config loader and hooks are initialized AFTER the config has been populated.
2422
-     *
2423
-     * @since 4.8.8.rc.019
2424
-     */
2425
-    public function do_hooks()
2426
-    {
2427
-        add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event'));
2428
-        add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_max_ticket_on_EEM_Event'));
2429
-    }
2430 1958
 
1959
+/**
1960
+ * Config class for storing info on the Organization
1961
+ */
1962
+class EE_Organization_Config extends EE_Config_Base
1963
+{
2431 1964
 
1965
+	/**
1966
+	 * @var string $name
1967
+	 * eg EE4.1
1968
+	 */
1969
+	public $name;
1970
+
1971
+	/**
1972
+	 * @var string $address_1
1973
+	 * eg 123 Onna Road
1974
+	 */
1975
+	public $address_1;
1976
+
1977
+	/**
1978
+	 * @var string $address_2
1979
+	 * eg PO Box 123
1980
+	 */
1981
+	public $address_2;
1982
+
1983
+	/**
1984
+	 * @var string $city
1985
+	 * eg Inna City
1986
+	 */
1987
+	public $city;
1988
+
1989
+	/**
1990
+	 * @var int $STA_ID
1991
+	 * eg 4
1992
+	 */
1993
+	public $STA_ID;
1994
+
1995
+	/**
1996
+	 * @var string $CNT_ISO
1997
+	 * eg US
1998
+	 */
1999
+	public $CNT_ISO;
2000
+
2001
+	/**
2002
+	 * @var string $zip
2003
+	 * eg 12345  or V1A 2B3
2004
+	 */
2005
+	public $zip;
2006
+
2007
+	/**
2008
+	 * @var string $email
2009
+	 * eg [email protected]
2010
+	 */
2011
+	public $email;
2012
+
2013
+
2014
+	/**
2015
+	 * @var string $phone
2016
+	 * eg. 111-111-1111
2017
+	 */
2018
+	public $phone;
2019
+
2020
+
2021
+	/**
2022
+	 * @var string $vat
2023
+	 * VAT/Tax Number
2024
+	 */
2025
+	public $vat;
2026
+
2027
+	/**
2028
+	 * @var string $logo_url
2029
+	 * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg
2030
+	 */
2031
+	public $logo_url;
2032
+
2033
+
2034
+	/**
2035
+	 * The below are all various properties for holding links to organization social network profiles
2036
+	 *
2037
+	 * @var string
2038
+	 */
2039
+	/**
2040
+	 * facebook (facebook.com/profile.name)
2041
+	 *
2042
+	 * @var string
2043
+	 */
2044
+	public $facebook;
2045
+
2046
+
2047
+	/**
2048
+	 * twitter (twitter.com/twitter_handle)
2049
+	 *
2050
+	 * @var string
2051
+	 */
2052
+	public $twitter;
2053
+
2054
+
2055
+	/**
2056
+	 * linkedin (linkedin.com/in/profile_name)
2057
+	 *
2058
+	 * @var string
2059
+	 */
2060
+	public $linkedin;
2061
+
2062
+
2063
+	/**
2064
+	 * pinterest (www.pinterest.com/profile_name)
2065
+	 *
2066
+	 * @var string
2067
+	 */
2068
+	public $pinterest;
2069
+
2070
+
2071
+	/**
2072
+	 * google+ (google.com/+profileName)
2073
+	 *
2074
+	 * @var string
2075
+	 */
2076
+	public $google;
2077
+
2078
+
2079
+	/**
2080
+	 * instagram (instagram.com/handle)
2081
+	 *
2082
+	 * @var string
2083
+	 */
2084
+	public $instagram;
2085
+
2086
+
2087
+
2088
+	/**
2089
+	 *    class constructor
2090
+	 *
2091
+	 * @access    public
2092
+	 */
2093
+	public function __construct()
2094
+	{
2095
+		// set default organization settings
2096
+		$this->name = get_bloginfo('name');
2097
+		$this->address_1 = '123 Onna Road';
2098
+		$this->address_2 = 'PO Box 123';
2099
+		$this->city = 'Inna City';
2100
+		$this->STA_ID = 4;
2101
+		$this->CNT_ISO = 'US';
2102
+		$this->zip = '12345';
2103
+		$this->email = get_bloginfo('admin_email');
2104
+		$this->phone = '';
2105
+		$this->vat = '123456789';
2106
+		$this->logo_url = '';
2107
+		$this->facebook = '';
2108
+		$this->twitter = '';
2109
+		$this->linkedin = '';
2110
+		$this->pinterest = '';
2111
+		$this->google = '';
2112
+		$this->instagram = '';
2113
+	}
2432 2114
 
2433
-    /**
2434
-     * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_default_registration_status
2435
-     * field matches the config setting for default_STS_ID.
2436
-     */
2437
-    public function set_default_reg_status_on_EEM_Event()
2438
-    {
2439
-        EEM_Event::set_default_reg_status($this->default_STS_ID);
2440
-    }
2115
+}
2441 2116
 
2442 2117
 
2443
-    /**
2444
-     * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_additional_limit field
2445
-     * for Events matches the config setting for default_maximum_number_of_tickets
2446
-     */
2447
-    public function set_default_max_ticket_on_EEM_Event()
2448
-    {
2449
-        EEM_Event::set_default_additional_limit($this->default_maximum_number_of_tickets);
2450
-    }
2451 2118
 
2119
+/**
2120
+ * Class for defining what's in the EE_Config relating to currency
2121
+ */
2122
+class EE_Currency_Config extends EE_Config_Base
2123
+{
2452 2124
 
2125
+	/**
2126
+	 * @var string $code
2127
+	 * eg 'US'
2128
+	 */
2129
+	public $code;
2130
+
2131
+	/**
2132
+	 * @var string $name
2133
+	 * eg 'Dollar'
2134
+	 */
2135
+	public $name;
2136
+
2137
+	/**
2138
+	 * plural name
2139
+	 *
2140
+	 * @var string $plural
2141
+	 * eg 'Dollars'
2142
+	 */
2143
+	public $plural;
2144
+
2145
+	/**
2146
+	 * currency sign
2147
+	 *
2148
+	 * @var string $sign
2149
+	 * eg '$'
2150
+	 */
2151
+	public $sign;
2152
+
2153
+	/**
2154
+	 * Whether the currency sign should come before the number or not
2155
+	 *
2156
+	 * @var boolean $sign_b4
2157
+	 */
2158
+	public $sign_b4;
2159
+
2160
+	/**
2161
+	 * How many digits should come after the decimal place
2162
+	 *
2163
+	 * @var int $dec_plc
2164
+	 */
2165
+	public $dec_plc;
2166
+
2167
+	/**
2168
+	 * Symbol to use for decimal mark
2169
+	 *
2170
+	 * @var string $dec_mrk
2171
+	 * eg '.'
2172
+	 */
2173
+	public $dec_mrk;
2174
+
2175
+	/**
2176
+	 * Symbol to use for thousands
2177
+	 *
2178
+	 * @var string $thsnds
2179
+	 * eg ','
2180
+	 */
2181
+	public $thsnds;
2182
+
2183
+
2184
+	/**
2185
+	 *    class constructor
2186
+	 *
2187
+	 * @access    public
2188
+	 * @param string             $CNT_ISO
2189
+	 * @param CountryCurrencyDao $country_currencies
2190
+	 * @throws EE_Error
2191
+	 * @throws InvalidArgumentException
2192
+	 * @throws ReflectionException
2193
+	 * @throws InvalidDataTypeException
2194
+	 * @throws InvalidInterfaceException
2195
+	 */
2196
+	public function __construct($CNT_ISO = '', CountryCurrencyDao $country_currencies = null)
2197
+	{
2198
+		if(! $country_currencies instanceof CountryCurrencyDao){
2199
+			$country_currencies = new CountryCurrencyDao();
2200
+		}
2201
+		// so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists
2202
+		if (! empty($CNT_ISO)) {
2203
+			// retrieve the country settings from the db, just in case they have been customized
2204
+			$country_currency = $country_currencies->getCountryCurrencyByIsoCode($CNT_ISO);
2205
+			$this->code = $country_currency['CurrencyCode'];    // currency code: USD, CAD, EUR
2206
+			$this->name = $country_currency['CurrencyNameSingle'];    // Dollar
2207
+			$this->plural = $country_currency['CurrencyNamePlural'];    // Dollars
2208
+			$this->sign = $country_currency['CurrencySign'];            // currency sign: $
2209
+			$this->sign_b4 = $country_currency['CurrencySignB4'];        // currency sign before or after: $TRUE  or  FALSE$
2210
+			$this->dec_plc = $country_currency['CurrencyDecimalPlaces'];    // decimal places: 2 = 0.00  3 = 0.000
2211
+			$this->dec_mrk = $country_currency['CurrencyDecimalMark'];    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2212
+			$this->thsnds = $country_currency['CurrencyThousands'];    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2213
+		}
2214
+		// fallback to hardcoded defaults, in case the above failed
2215
+		if (empty($this->code)) {
2216
+			// set default currency settings
2217
+			$this->code = 'USD';    // currency code: USD, CAD, EUR
2218
+			$this->name = esc_html__('Dollar', 'event_espresso');    // Dollar
2219
+			$this->plural = esc_html__('Dollars', 'event_espresso');    // Dollars
2220
+			$this->sign = '$';    // currency sign: $
2221
+			$this->sign_b4 = true;    // currency sign before or after: $TRUE  or  FALSE$
2222
+			$this->dec_plc = 2;    // decimal places: 2 = 0.00  3 = 0.000
2223
+			$this->dec_mrk = '.';    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2224
+			$this->thsnds = ',';    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2225
+		}
2226
+	}
2227
+
2228
+
2229
+	/**
2230
+	 * @param EE_Country $country
2231
+	 * @throws EE_Error
2232
+	 * @throws InvalidArgumentException
2233
+	 * @throws InvalidDataTypeException
2234
+	 * @throws InvalidInterfaceException
2235
+	 * @throws ReflectionException
2236
+	 */
2237
+	public function setFromCountry(EE_Country $country)
2238
+	{
2239
+		$this->code    = $country->currency_code();    // currency code: USD, CAD, EUR
2240
+		$this->name    = $country->currency_name_single();    // Dollar
2241
+		$this->plural  = $country->currency_name_plural();    // Dollars
2242
+		$this->sign    = $country->currency_sign();            // currency sign: $
2243
+		$this->sign_b4 = $country->currency_sign_before();        // currency sign before or after: $TRUE  or  FALSE$
2244
+		$this->dec_plc = $country->currency_decimal_places();    // decimal places: 2 = 0.00  3 = 0.000
2245
+		$this->dec_mrk = $country->currency_decimal_mark();    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2246
+		$this->thsnds  = $country->currency_thousands_separator();    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2247
+	}
2248
+}
2453 2249
 
2454
-    /**
2455
-     * @return boolean
2456
-     */
2457
-    public function track_invalid_checkout_access()
2458
-    {
2459
-        return $this->track_invalid_checkout_access;
2460
-    }
2461 2250
 
2462 2251
 
2252
+/**
2253
+ * Class for defining what's in the EE_Config relating to registration settings
2254
+ */
2255
+class EE_Registration_Config extends EE_Config_Base
2256
+{
2463 2257
 
2464
-    /**
2465
-     * @param boolean $track_invalid_checkout_access
2466
-     */
2467
-    public function set_track_invalid_checkout_access($track_invalid_checkout_access)
2468
-    {
2469
-        $this->track_invalid_checkout_access = filter_var(
2470
-            $track_invalid_checkout_access,
2471
-            FILTER_VALIDATE_BOOLEAN
2472
-        );
2473
-    }
2258
+	/**
2259
+	 * Default registration status
2260
+	 *
2261
+	 * @var string $default_STS_ID
2262
+	 * eg 'RPP'
2263
+	 */
2264
+	public $default_STS_ID;
2265
+
2266
+
2267
+	/**
2268
+	 * For new events, this will be the default value for the maximum number of tickets (equivalent to maximum number of
2269
+	 * registrations)
2270
+	 * @var int
2271
+	 */
2272
+	public $default_maximum_number_of_tickets;
2273
+
2274
+
2275
+	/**
2276
+	 * level of validation to apply to email addresses
2277
+	 *
2278
+	 * @var string $email_validation_level
2279
+	 * options: 'basic', 'wp_default', 'i18n', 'i18n_dns'
2280
+	 */
2281
+	public $email_validation_level;
2282
+
2283
+	/**
2284
+	 *    whether or not to show alternate payment options during the reg process if payment status is pending
2285
+	 *
2286
+	 * @var boolean $show_pending_payment_options
2287
+	 */
2288
+	public $show_pending_payment_options;
2289
+
2290
+	/**
2291
+	 * Whether to skip the registration confirmation page
2292
+	 *
2293
+	 * @var boolean $skip_reg_confirmation
2294
+	 */
2295
+	public $skip_reg_confirmation;
2296
+
2297
+	/**
2298
+	 * an array of SPCO reg steps where:
2299
+	 *        the keys denotes the reg step order
2300
+	 *        each element consists of an array with the following elements:
2301
+	 *            "file_path" => the file path to the EE_SPCO_Reg_Step class
2302
+	 *            "class_name" => the specific EE_SPCO_Reg_Step child class name
2303
+	 *            "slug" => the URL param used to trigger the reg step
2304
+	 *
2305
+	 * @var array $reg_steps
2306
+	 */
2307
+	public $reg_steps;
2308
+
2309
+	/**
2310
+	 * Whether registration confirmation should be the last page of SPCO
2311
+	 *
2312
+	 * @var boolean $reg_confirmation_last
2313
+	 */
2314
+	public $reg_confirmation_last;
2315
+
2316
+	/**
2317
+	 * Whether or not to enable the EE Bot Trap
2318
+	 *
2319
+	 * @var boolean $use_bot_trap
2320
+	 */
2321
+	public $use_bot_trap;
2322
+
2323
+	/**
2324
+	 * Whether or not to encrypt some data sent by the EE Bot Trap
2325
+	 *
2326
+	 * @var boolean $use_encryption
2327
+	 */
2328
+	public $use_encryption;
2329
+
2330
+	/**
2331
+	 * Whether or not to use ReCaptcha
2332
+	 *
2333
+	 * @var boolean $use_captcha
2334
+	 */
2335
+	public $use_captcha;
2336
+
2337
+	/**
2338
+	 * ReCaptcha Theme
2339
+	 *
2340
+	 * @var string $recaptcha_theme
2341
+	 *    options: 'dark    ', 'light'
2342
+	 */
2343
+	public $recaptcha_theme;
2344
+
2345
+	/**
2346
+	 * ReCaptcha Type
2347
+	 *
2348
+	 * @var string $recaptcha_type
2349
+	 *    options: 'audio', 'image'
2350
+	 */
2351
+	public $recaptcha_type;
2352
+
2353
+	/**
2354
+	 * ReCaptcha language
2355
+	 *
2356
+	 * @var string $recaptcha_language
2357
+	 * eg 'en'
2358
+	 */
2359
+	public $recaptcha_language;
2360
+
2361
+	/**
2362
+	 * ReCaptcha public key
2363
+	 *
2364
+	 * @var string $recaptcha_publickey
2365
+	 */
2366
+	public $recaptcha_publickey;
2367
+
2368
+	/**
2369
+	 * ReCaptcha private key
2370
+	 *
2371
+	 * @var string $recaptcha_privatekey
2372
+	 */
2373
+	public $recaptcha_privatekey;
2374
+
2375
+	/**
2376
+	 * ReCaptcha width
2377
+	 *
2378
+	 * @var int $recaptcha_width
2379
+	 * @deprecated
2380
+	 */
2381
+	public $recaptcha_width;
2382
+
2383
+	/**
2384
+	 * Whether or not invalid attempts to directly access the registration checkout page should be tracked.
2385
+	 *
2386
+	 * @var boolean $track_invalid_checkout_access
2387
+	 */
2388
+	protected $track_invalid_checkout_access = true;
2389
+
2390
+
2391
+
2392
+	/**
2393
+	 *    class constructor
2394
+	 *
2395
+	 * @access    public
2396
+	 */
2397
+	public function __construct()
2398
+	{
2399
+		// set default registration settings
2400
+		$this->default_STS_ID = EEM_Registration::status_id_pending_payment;
2401
+		$this->email_validation_level = 'wp_default';
2402
+		$this->show_pending_payment_options = true;
2403
+		$this->skip_reg_confirmation = false;
2404
+		$this->reg_steps = array();
2405
+		$this->reg_confirmation_last = false;
2406
+		$this->use_bot_trap = true;
2407
+		$this->use_encryption = true;
2408
+		$this->use_captcha = false;
2409
+		$this->recaptcha_theme = 'light';
2410
+		$this->recaptcha_type = 'image';
2411
+		$this->recaptcha_language = 'en';
2412
+		$this->recaptcha_publickey = null;
2413
+		$this->recaptcha_privatekey = null;
2414
+		$this->recaptcha_width = 500;
2415
+		$this->default_maximum_number_of_tickets = 10;
2416
+	}
2417
+
2418
+
2419
+
2420
+	/**
2421
+	 * This is called by the config loader and hooks are initialized AFTER the config has been populated.
2422
+	 *
2423
+	 * @since 4.8.8.rc.019
2424
+	 */
2425
+	public function do_hooks()
2426
+	{
2427
+		add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event'));
2428
+		add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_max_ticket_on_EEM_Event'));
2429
+	}
2430
+
2431
+
2432
+
2433
+	/**
2434
+	 * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_default_registration_status
2435
+	 * field matches the config setting for default_STS_ID.
2436
+	 */
2437
+	public function set_default_reg_status_on_EEM_Event()
2438
+	{
2439
+		EEM_Event::set_default_reg_status($this->default_STS_ID);
2440
+	}
2441
+
2442
+
2443
+	/**
2444
+	 * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_additional_limit field
2445
+	 * for Events matches the config setting for default_maximum_number_of_tickets
2446
+	 */
2447
+	public function set_default_max_ticket_on_EEM_Event()
2448
+	{
2449
+		EEM_Event::set_default_additional_limit($this->default_maximum_number_of_tickets);
2450
+	}
2451
+
2452
+
2453
+
2454
+	/**
2455
+	 * @return boolean
2456
+	 */
2457
+	public function track_invalid_checkout_access()
2458
+	{
2459
+		return $this->track_invalid_checkout_access;
2460
+	}
2461
+
2462
+
2463
+
2464
+	/**
2465
+	 * @param boolean $track_invalid_checkout_access
2466
+	 */
2467
+	public function set_track_invalid_checkout_access($track_invalid_checkout_access)
2468
+	{
2469
+		$this->track_invalid_checkout_access = filter_var(
2470
+			$track_invalid_checkout_access,
2471
+			FILTER_VALIDATE_BOOLEAN
2472
+		);
2473
+	}
2474 2474
 
2475 2475
 
2476 2476
 
@@ -2484,160 +2484,160 @@  discard block
 block discarded – undo
2484 2484
 class EE_Admin_Config extends EE_Config_Base
2485 2485
 {
2486 2486
 
2487
-    /**
2488
-     * @var boolean $use_personnel_manager
2489
-     */
2490
-    public $use_personnel_manager;
2491
-
2492
-    /**
2493
-     * @var boolean $use_dashboard_widget
2494
-     */
2495
-    public $use_dashboard_widget;
2496
-
2497
-    /**
2498
-     * @var int $events_in_dashboard
2499
-     */
2500
-    public $events_in_dashboard;
2501
-
2502
-    /**
2503
-     * @var boolean $use_event_timezones
2504
-     */
2505
-    public $use_event_timezones;
2506
-
2507
-    /**
2508
-     * @var boolean $use_full_logging
2509
-     */
2510
-    public $use_full_logging;
2511
-
2512
-    /**
2513
-     * @var string $log_file_name
2514
-     */
2515
-    public $log_file_name;
2516
-
2517
-    /**
2518
-     * @var string $debug_file_name
2519
-     */
2520
-    public $debug_file_name;
2521
-
2522
-    /**
2523
-     * @var boolean $use_remote_logging
2524
-     */
2525
-    public $use_remote_logging;
2526
-
2527
-    /**
2528
-     * @var string $remote_logging_url
2529
-     */
2530
-    public $remote_logging_url;
2531
-
2532
-    /**
2533
-     * @var boolean $show_reg_footer
2534
-     */
2535
-    public $show_reg_footer;
2536
-
2537
-    /**
2538
-     * @var string $affiliate_id
2539
-     */
2540
-    public $affiliate_id;
2541
-
2542
-    /**
2543
-     * help tours on or off (global setting)
2544
-     *
2545
-     * @var boolean
2546
-     */
2547
-    public $help_tour_activation;
2548
-
2549
-    /**
2550
-     * adds extra layer of encoding to session data to prevent serialization errors
2551
-     * but is incompatible with some server configuration errors
2552
-     * if you get "500 internal server errors" during registration, try turning this on
2553
-     * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off
2554
-     *
2555
-     * @var boolean $encode_session_data
2556
-     */
2557
-    private $encode_session_data = false;
2558
-
2559
-
2560
-
2561
-    /**
2562
-     *    class constructor
2563
-     *
2564
-     * @access    public
2565
-     */
2566
-    public function __construct()
2567
-    {
2568
-        // set default general admin settings
2569
-        $this->use_personnel_manager = true;
2570
-        $this->use_dashboard_widget = true;
2571
-        $this->events_in_dashboard = 30;
2572
-        $this->use_event_timezones = false;
2573
-        $this->use_full_logging = false;
2574
-        $this->use_remote_logging = false;
2575
-        $this->remote_logging_url = null;
2576
-        $this->show_reg_footer = true;
2577
-        $this->affiliate_id = 'default';
2578
-        $this->help_tour_activation = true;
2579
-        $this->encode_session_data = false;
2580
-    }
2581
-
2582
-
2583
-
2584
-    /**
2585
-     * @param bool $reset
2586
-     * @return string
2587
-     */
2588
-    public function log_file_name($reset = false)
2589
-    {
2590
-        if (empty($this->log_file_name) || $reset) {
2591
-            $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2592
-            EE_Config::instance()->update_espresso_config(false, false);
2593
-        }
2594
-        return $this->log_file_name;
2595
-    }
2596
-
2597
-
2598
-
2599
-    /**
2600
-     * @param bool $reset
2601
-     * @return string
2602
-     */
2603
-    public function debug_file_name($reset = false)
2604
-    {
2605
-        if (empty($this->debug_file_name) || $reset) {
2606
-            $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2607
-            EE_Config::instance()->update_espresso_config(false, false);
2608
-        }
2609
-        return $this->debug_file_name;
2610
-    }
2611
-
2612
-
2613
-
2614
-    /**
2615
-     * @return string
2616
-     */
2617
-    public function affiliate_id()
2618
-    {
2619
-        return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default';
2620
-    }
2621
-
2622
-
2623
-
2624
-    /**
2625
-     * @return boolean
2626
-     */
2627
-    public function encode_session_data()
2628
-    {
2629
-        return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN);
2630
-    }
2631
-
2632
-
2633
-
2634
-    /**
2635
-     * @param boolean $encode_session_data
2636
-     */
2637
-    public function set_encode_session_data($encode_session_data)
2638
-    {
2639
-        $this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN);
2640
-    }
2487
+	/**
2488
+	 * @var boolean $use_personnel_manager
2489
+	 */
2490
+	public $use_personnel_manager;
2491
+
2492
+	/**
2493
+	 * @var boolean $use_dashboard_widget
2494
+	 */
2495
+	public $use_dashboard_widget;
2496
+
2497
+	/**
2498
+	 * @var int $events_in_dashboard
2499
+	 */
2500
+	public $events_in_dashboard;
2501
+
2502
+	/**
2503
+	 * @var boolean $use_event_timezones
2504
+	 */
2505
+	public $use_event_timezones;
2506
+
2507
+	/**
2508
+	 * @var boolean $use_full_logging
2509
+	 */
2510
+	public $use_full_logging;
2511
+
2512
+	/**
2513
+	 * @var string $log_file_name
2514
+	 */
2515
+	public $log_file_name;
2516
+
2517
+	/**
2518
+	 * @var string $debug_file_name
2519
+	 */
2520
+	public $debug_file_name;
2521
+
2522
+	/**
2523
+	 * @var boolean $use_remote_logging
2524
+	 */
2525
+	public $use_remote_logging;
2526
+
2527
+	/**
2528
+	 * @var string $remote_logging_url
2529
+	 */
2530
+	public $remote_logging_url;
2531
+
2532
+	/**
2533
+	 * @var boolean $show_reg_footer
2534
+	 */
2535
+	public $show_reg_footer;
2536
+
2537
+	/**
2538
+	 * @var string $affiliate_id
2539
+	 */
2540
+	public $affiliate_id;
2541
+
2542
+	/**
2543
+	 * help tours on or off (global setting)
2544
+	 *
2545
+	 * @var boolean
2546
+	 */
2547
+	public $help_tour_activation;
2548
+
2549
+	/**
2550
+	 * adds extra layer of encoding to session data to prevent serialization errors
2551
+	 * but is incompatible with some server configuration errors
2552
+	 * if you get "500 internal server errors" during registration, try turning this on
2553
+	 * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off
2554
+	 *
2555
+	 * @var boolean $encode_session_data
2556
+	 */
2557
+	private $encode_session_data = false;
2558
+
2559
+
2560
+
2561
+	/**
2562
+	 *    class constructor
2563
+	 *
2564
+	 * @access    public
2565
+	 */
2566
+	public function __construct()
2567
+	{
2568
+		// set default general admin settings
2569
+		$this->use_personnel_manager = true;
2570
+		$this->use_dashboard_widget = true;
2571
+		$this->events_in_dashboard = 30;
2572
+		$this->use_event_timezones = false;
2573
+		$this->use_full_logging = false;
2574
+		$this->use_remote_logging = false;
2575
+		$this->remote_logging_url = null;
2576
+		$this->show_reg_footer = true;
2577
+		$this->affiliate_id = 'default';
2578
+		$this->help_tour_activation = true;
2579
+		$this->encode_session_data = false;
2580
+	}
2581
+
2582
+
2583
+
2584
+	/**
2585
+	 * @param bool $reset
2586
+	 * @return string
2587
+	 */
2588
+	public function log_file_name($reset = false)
2589
+	{
2590
+		if (empty($this->log_file_name) || $reset) {
2591
+			$this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2592
+			EE_Config::instance()->update_espresso_config(false, false);
2593
+		}
2594
+		return $this->log_file_name;
2595
+	}
2596
+
2597
+
2598
+
2599
+	/**
2600
+	 * @param bool $reset
2601
+	 * @return string
2602
+	 */
2603
+	public function debug_file_name($reset = false)
2604
+	{
2605
+		if (empty($this->debug_file_name) || $reset) {
2606
+			$this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2607
+			EE_Config::instance()->update_espresso_config(false, false);
2608
+		}
2609
+		return $this->debug_file_name;
2610
+	}
2611
+
2612
+
2613
+
2614
+	/**
2615
+	 * @return string
2616
+	 */
2617
+	public function affiliate_id()
2618
+	{
2619
+		return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default';
2620
+	}
2621
+
2622
+
2623
+
2624
+	/**
2625
+	 * @return boolean
2626
+	 */
2627
+	public function encode_session_data()
2628
+	{
2629
+		return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN);
2630
+	}
2631
+
2632
+
2633
+
2634
+	/**
2635
+	 * @param boolean $encode_session_data
2636
+	 */
2637
+	public function set_encode_session_data($encode_session_data)
2638
+	{
2639
+		$this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN);
2640
+	}
2641 2641
 
2642 2642
 
2643 2643
 
@@ -2651,71 +2651,71 @@  discard block
 block discarded – undo
2651 2651
 class EE_Template_Config extends EE_Config_Base
2652 2652
 {
2653 2653
 
2654
-    /**
2655
-     * @var boolean $enable_default_style
2656
-     */
2657
-    public $enable_default_style;
2658
-
2659
-    /**
2660
-     * @var string $custom_style_sheet
2661
-     */
2662
-    public $custom_style_sheet;
2663
-
2664
-    /**
2665
-     * @var boolean $display_address_in_regform
2666
-     */
2667
-    public $display_address_in_regform;
2668
-
2669
-    /**
2670
-     * @var int $display_description_on_multi_reg_page
2671
-     */
2672
-    public $display_description_on_multi_reg_page;
2673
-
2674
-    /**
2675
-     * @var boolean $use_custom_templates
2676
-     */
2677
-    public $use_custom_templates;
2678
-
2679
-    /**
2680
-     * @var string $current_espresso_theme
2681
-     */
2682
-    public $current_espresso_theme;
2683
-
2684
-    /**
2685
-     * @var EE_Ticket_Selector_Config $EED_Ticket_Selector
2686
-     */
2687
-    public $EED_Ticket_Selector;
2688
-
2689
-    /**
2690
-     * @var EE_Event_Single_Config $EED_Event_Single
2691
-     */
2692
-    public $EED_Event_Single;
2693
-
2694
-    /**
2695
-     * @var EE_Events_Archive_Config $EED_Events_Archive
2696
-     */
2697
-    public $EED_Events_Archive;
2698
-
2699
-
2700
-
2701
-    /**
2702
-     *    class constructor
2703
-     *
2704
-     * @access    public
2705
-     */
2706
-    public function __construct()
2707
-    {
2708
-        // set default template settings
2709
-        $this->enable_default_style = true;
2710
-        $this->custom_style_sheet = null;
2711
-        $this->display_address_in_regform = true;
2712
-        $this->display_description_on_multi_reg_page = false;
2713
-        $this->use_custom_templates = false;
2714
-        $this->current_espresso_theme = 'Espresso_Arabica_2014';
2715
-        $this->EED_Event_Single = null;
2716
-        $this->EED_Events_Archive = null;
2717
-        $this->EED_Ticket_Selector = null;
2718
-    }
2654
+	/**
2655
+	 * @var boolean $enable_default_style
2656
+	 */
2657
+	public $enable_default_style;
2658
+
2659
+	/**
2660
+	 * @var string $custom_style_sheet
2661
+	 */
2662
+	public $custom_style_sheet;
2663
+
2664
+	/**
2665
+	 * @var boolean $display_address_in_regform
2666
+	 */
2667
+	public $display_address_in_regform;
2668
+
2669
+	/**
2670
+	 * @var int $display_description_on_multi_reg_page
2671
+	 */
2672
+	public $display_description_on_multi_reg_page;
2673
+
2674
+	/**
2675
+	 * @var boolean $use_custom_templates
2676
+	 */
2677
+	public $use_custom_templates;
2678
+
2679
+	/**
2680
+	 * @var string $current_espresso_theme
2681
+	 */
2682
+	public $current_espresso_theme;
2683
+
2684
+	/**
2685
+	 * @var EE_Ticket_Selector_Config $EED_Ticket_Selector
2686
+	 */
2687
+	public $EED_Ticket_Selector;
2688
+
2689
+	/**
2690
+	 * @var EE_Event_Single_Config $EED_Event_Single
2691
+	 */
2692
+	public $EED_Event_Single;
2693
+
2694
+	/**
2695
+	 * @var EE_Events_Archive_Config $EED_Events_Archive
2696
+	 */
2697
+	public $EED_Events_Archive;
2698
+
2699
+
2700
+
2701
+	/**
2702
+	 *    class constructor
2703
+	 *
2704
+	 * @access    public
2705
+	 */
2706
+	public function __construct()
2707
+	{
2708
+		// set default template settings
2709
+		$this->enable_default_style = true;
2710
+		$this->custom_style_sheet = null;
2711
+		$this->display_address_in_regform = true;
2712
+		$this->display_description_on_multi_reg_page = false;
2713
+		$this->use_custom_templates = false;
2714
+		$this->current_espresso_theme = 'Espresso_Arabica_2014';
2715
+		$this->EED_Event_Single = null;
2716
+		$this->EED_Events_Archive = null;
2717
+		$this->EED_Ticket_Selector = null;
2718
+	}
2719 2719
 
2720 2720
 }
2721 2721
 
@@ -2727,115 +2727,115 @@  discard block
 block discarded – undo
2727 2727
 class EE_Map_Config extends EE_Config_Base
2728 2728
 {
2729 2729
 
2730
-    /**
2731
-     * @var boolean $use_google_maps
2732
-     */
2733
-    public $use_google_maps;
2734
-
2735
-    /**
2736
-     * @var string $api_key
2737
-     */
2738
-    public $google_map_api_key;
2739
-
2740
-    /**
2741
-     * @var int $event_details_map_width
2742
-     */
2743
-    public $event_details_map_width;
2744
-
2745
-    /**
2746
-     * @var int $event_details_map_height
2747
-     */
2748
-    public $event_details_map_height;
2749
-
2750
-    /**
2751
-     * @var int $event_details_map_zoom
2752
-     */
2753
-    public $event_details_map_zoom;
2754
-
2755
-    /**
2756
-     * @var boolean $event_details_display_nav
2757
-     */
2758
-    public $event_details_display_nav;
2759
-
2760
-    /**
2761
-     * @var boolean $event_details_nav_size
2762
-     */
2763
-    public $event_details_nav_size;
2764
-
2765
-    /**
2766
-     * @var string $event_details_control_type
2767
-     */
2768
-    public $event_details_control_type;
2769
-
2770
-    /**
2771
-     * @var string $event_details_map_align
2772
-     */
2773
-    public $event_details_map_align;
2774
-
2775
-    /**
2776
-     * @var int $event_list_map_width
2777
-     */
2778
-    public $event_list_map_width;
2779
-
2780
-    /**
2781
-     * @var int $event_list_map_height
2782
-     */
2783
-    public $event_list_map_height;
2784
-
2785
-    /**
2786
-     * @var int $event_list_map_zoom
2787
-     */
2788
-    public $event_list_map_zoom;
2789
-
2790
-    /**
2791
-     * @var boolean $event_list_display_nav
2792
-     */
2793
-    public $event_list_display_nav;
2794
-
2795
-    /**
2796
-     * @var boolean $event_list_nav_size
2797
-     */
2798
-    public $event_list_nav_size;
2799
-
2800
-    /**
2801
-     * @var string $event_list_control_type
2802
-     */
2803
-    public $event_list_control_type;
2804
-
2805
-    /**
2806
-     * @var string $event_list_map_align
2807
-     */
2808
-    public $event_list_map_align;
2809
-
2810
-
2811
-
2812
-    /**
2813
-     *    class constructor
2814
-     *
2815
-     * @access    public
2816
-     */
2817
-    public function __construct()
2818
-    {
2819
-        // set default map settings
2820
-        $this->use_google_maps = true;
2821
-        $this->google_map_api_key = '';
2822
-        // for event details pages (reg page)
2823
-        $this->event_details_map_width = 585;            // ee_map_width_single
2824
-        $this->event_details_map_height = 362;            // ee_map_height_single
2825
-        $this->event_details_map_zoom = 14;            // ee_map_zoom_single
2826
-        $this->event_details_display_nav = true;            // ee_map_nav_display_single
2827
-        $this->event_details_nav_size = false;            // ee_map_nav_size_single
2828
-        $this->event_details_control_type = 'default';        // ee_map_type_control_single
2829
-        $this->event_details_map_align = 'center';            // ee_map_align_single
2830
-        // for event list pages
2831
-        $this->event_list_map_width = 300;            // ee_map_width
2832
-        $this->event_list_map_height = 185;        // ee_map_height
2833
-        $this->event_list_map_zoom = 12;            // ee_map_zoom
2834
-        $this->event_list_display_nav = false;        // ee_map_nav_display
2835
-        $this->event_list_nav_size = true;            // ee_map_nav_size
2836
-        $this->event_list_control_type = 'dropdown';        // ee_map_type_control
2837
-        $this->event_list_map_align = 'center';            // ee_map_align
2838
-    }
2730
+	/**
2731
+	 * @var boolean $use_google_maps
2732
+	 */
2733
+	public $use_google_maps;
2734
+
2735
+	/**
2736
+	 * @var string $api_key
2737
+	 */
2738
+	public $google_map_api_key;
2739
+
2740
+	/**
2741
+	 * @var int $event_details_map_width
2742
+	 */
2743
+	public $event_details_map_width;
2744
+
2745
+	/**
2746
+	 * @var int $event_details_map_height
2747
+	 */
2748
+	public $event_details_map_height;
2749
+
2750
+	/**
2751
+	 * @var int $event_details_map_zoom
2752
+	 */
2753
+	public $event_details_map_zoom;
2754
+
2755
+	/**
2756
+	 * @var boolean $event_details_display_nav
2757
+	 */
2758
+	public $event_details_display_nav;
2759
+
2760
+	/**
2761
+	 * @var boolean $event_details_nav_size
2762
+	 */
2763
+	public $event_details_nav_size;
2764
+
2765
+	/**
2766
+	 * @var string $event_details_control_type
2767
+	 */
2768
+	public $event_details_control_type;
2769
+
2770
+	/**
2771
+	 * @var string $event_details_map_align
2772
+	 */
2773
+	public $event_details_map_align;
2774
+
2775
+	/**
2776
+	 * @var int $event_list_map_width
2777
+	 */
2778
+	public $event_list_map_width;
2779
+
2780
+	/**
2781
+	 * @var int $event_list_map_height
2782
+	 */
2783
+	public $event_list_map_height;
2784
+
2785
+	/**
2786
+	 * @var int $event_list_map_zoom
2787
+	 */
2788
+	public $event_list_map_zoom;
2789
+
2790
+	/**
2791
+	 * @var boolean $event_list_display_nav
2792
+	 */
2793
+	public $event_list_display_nav;
2794
+
2795
+	/**
2796
+	 * @var boolean $event_list_nav_size
2797
+	 */
2798
+	public $event_list_nav_size;
2799
+
2800
+	/**
2801
+	 * @var string $event_list_control_type
2802
+	 */
2803
+	public $event_list_control_type;
2804
+
2805
+	/**
2806
+	 * @var string $event_list_map_align
2807
+	 */
2808
+	public $event_list_map_align;
2809
+
2810
+
2811
+
2812
+	/**
2813
+	 *    class constructor
2814
+	 *
2815
+	 * @access    public
2816
+	 */
2817
+	public function __construct()
2818
+	{
2819
+		// set default map settings
2820
+		$this->use_google_maps = true;
2821
+		$this->google_map_api_key = '';
2822
+		// for event details pages (reg page)
2823
+		$this->event_details_map_width = 585;            // ee_map_width_single
2824
+		$this->event_details_map_height = 362;            // ee_map_height_single
2825
+		$this->event_details_map_zoom = 14;            // ee_map_zoom_single
2826
+		$this->event_details_display_nav = true;            // ee_map_nav_display_single
2827
+		$this->event_details_nav_size = false;            // ee_map_nav_size_single
2828
+		$this->event_details_control_type = 'default';        // ee_map_type_control_single
2829
+		$this->event_details_map_align = 'center';            // ee_map_align_single
2830
+		// for event list pages
2831
+		$this->event_list_map_width = 300;            // ee_map_width
2832
+		$this->event_list_map_height = 185;        // ee_map_height
2833
+		$this->event_list_map_zoom = 12;            // ee_map_zoom
2834
+		$this->event_list_display_nav = false;        // ee_map_nav_display
2835
+		$this->event_list_nav_size = true;            // ee_map_nav_size
2836
+		$this->event_list_control_type = 'dropdown';        // ee_map_type_control
2837
+		$this->event_list_map_align = 'center';            // ee_map_align
2838
+	}
2839 2839
 
2840 2840
 }
2841 2841
 
@@ -2847,47 +2847,47 @@  discard block
 block discarded – undo
2847 2847
 class EE_Events_Archive_Config extends EE_Config_Base
2848 2848
 {
2849 2849
 
2850
-    public $display_status_banner;
2850
+	public $display_status_banner;
2851 2851
 
2852
-    public $display_description;
2852
+	public $display_description;
2853 2853
 
2854
-    public $display_ticket_selector;
2854
+	public $display_ticket_selector;
2855 2855
 
2856
-    public $display_datetimes;
2856
+	public $display_datetimes;
2857 2857
 
2858
-    public $display_venue;
2858
+	public $display_venue;
2859 2859
 
2860
-    public $display_expired_events;
2860
+	public $display_expired_events;
2861 2861
 
2862
-    public $use_sortable_display_order;
2862
+	public $use_sortable_display_order;
2863 2863
 
2864
-    public $display_order_tickets;
2864
+	public $display_order_tickets;
2865 2865
 
2866
-    public $display_order_datetimes;
2866
+	public $display_order_datetimes;
2867 2867
 
2868
-    public $display_order_event;
2868
+	public $display_order_event;
2869 2869
 
2870
-    public $display_order_venue;
2870
+	public $display_order_venue;
2871 2871
 
2872 2872
 
2873 2873
 
2874
-    /**
2875
-     *    class constructor
2876
-     */
2877
-    public function __construct()
2878
-    {
2879
-        $this->display_status_banner = 0;
2880
-        $this->display_description = 1;
2881
-        $this->display_ticket_selector = 0;
2882
-        $this->display_datetimes = 1;
2883
-        $this->display_venue = 0;
2884
-        $this->display_expired_events = 0;
2885
-        $this->use_sortable_display_order = false;
2886
-        $this->display_order_tickets = 100;
2887
-        $this->display_order_datetimes = 110;
2888
-        $this->display_order_event = 120;
2889
-        $this->display_order_venue = 130;
2890
-    }
2874
+	/**
2875
+	 *    class constructor
2876
+	 */
2877
+	public function __construct()
2878
+	{
2879
+		$this->display_status_banner = 0;
2880
+		$this->display_description = 1;
2881
+		$this->display_ticket_selector = 0;
2882
+		$this->display_datetimes = 1;
2883
+		$this->display_venue = 0;
2884
+		$this->display_expired_events = 0;
2885
+		$this->use_sortable_display_order = false;
2886
+		$this->display_order_tickets = 100;
2887
+		$this->display_order_datetimes = 110;
2888
+		$this->display_order_event = 120;
2889
+		$this->display_order_venue = 130;
2890
+	}
2891 2891
 }
2892 2892
 
2893 2893
 
@@ -2898,35 +2898,35 @@  discard block
 block discarded – undo
2898 2898
 class EE_Event_Single_Config extends EE_Config_Base
2899 2899
 {
2900 2900
 
2901
-    public $display_status_banner_single;
2901
+	public $display_status_banner_single;
2902 2902
 
2903
-    public $display_venue;
2903
+	public $display_venue;
2904 2904
 
2905
-    public $use_sortable_display_order;
2905
+	public $use_sortable_display_order;
2906 2906
 
2907
-    public $display_order_tickets;
2907
+	public $display_order_tickets;
2908 2908
 
2909
-    public $display_order_datetimes;
2909
+	public $display_order_datetimes;
2910 2910
 
2911
-    public $display_order_event;
2911
+	public $display_order_event;
2912 2912
 
2913
-    public $display_order_venue;
2913
+	public $display_order_venue;
2914 2914
 
2915 2915
 
2916 2916
 
2917
-    /**
2918
-     *    class constructor
2919
-     */
2920
-    public function __construct()
2921
-    {
2922
-        $this->display_status_banner_single = 0;
2923
-        $this->display_venue = 1;
2924
-        $this->use_sortable_display_order = false;
2925
-        $this->display_order_tickets = 100;
2926
-        $this->display_order_datetimes = 110;
2927
-        $this->display_order_event = 120;
2928
-        $this->display_order_venue = 130;
2929
-    }
2917
+	/**
2918
+	 *    class constructor
2919
+	 */
2920
+	public function __construct()
2921
+	{
2922
+		$this->display_status_banner_single = 0;
2923
+		$this->display_venue = 1;
2924
+		$this->use_sortable_display_order = false;
2925
+		$this->display_order_tickets = 100;
2926
+		$this->display_order_datetimes = 110;
2927
+		$this->display_order_event = 120;
2928
+		$this->display_order_venue = 130;
2929
+	}
2930 2930
 }
2931 2931
 
2932 2932
 
@@ -2937,152 +2937,152 @@  discard block
 block discarded – undo
2937 2937
 class EE_Ticket_Selector_Config extends EE_Config_Base
2938 2938
 {
2939 2939
 
2940
-    /**
2941
-     * constant to indicate that a datetime selector should NEVER be shown for ticket selectors
2942
-     */
2943
-    const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector';
2944
-
2945
-    /**
2946
-     * constant to indicate that a datetime selector should only be shown for ticket selectors
2947
-     * when the number of datetimes for the event matches the value set for $datetime_selector_threshold
2948
-     */
2949
-    const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector';
2950
-
2951
-    /**
2952
-     * @var boolean $show_ticket_sale_columns
2953
-     */
2954
-    public $show_ticket_sale_columns;
2955
-
2956
-    /**
2957
-     * @var boolean $show_ticket_details
2958
-     */
2959
-    public $show_ticket_details;
2960
-
2961
-    /**
2962
-     * @var boolean $show_expired_tickets
2963
-     */
2964
-    public $show_expired_tickets;
2965
-
2966
-    /**
2967
-     * whether or not to display a dropdown box populated with event datetimes
2968
-     * that toggles which tickets are displayed for a ticket selector.
2969
-     * uses one of the *_DATETIME_SELECTOR constants defined above
2970
-     *
2971
-     * @var string $show_datetime_selector
2972
-     */
2973
-    private $show_datetime_selector = 'no_datetime_selector';
2974
-
2975
-    /**
2976
-     * the number of datetimes an event has to have before conditionally displaying a datetime selector
2977
-     *
2978
-     * @var int $datetime_selector_threshold
2979
-     */
2980
-    private $datetime_selector_threshold = 3;
2981
-
2982
-
2983
-
2984
-    /**
2985
-     *    class constructor
2986
-     */
2987
-    public function __construct()
2988
-    {
2989
-        $this->show_ticket_sale_columns = true;
2990
-        $this->show_ticket_details = true;
2991
-        $this->show_expired_tickets = true;
2992
-        $this->show_datetime_selector = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
2993
-        $this->datetime_selector_threshold = 3;
2994
-    }
2995
-
2996
-
2997
-
2998
-    /**
2999
-     * returns true if a datetime selector should be displayed
3000
-     *
3001
-     * @param array $datetimes
3002
-     * @return bool
3003
-     */
3004
-    public function showDatetimeSelector(array $datetimes)
3005
-    {
3006
-        // if the settings are NOT: don't show OR below threshold, THEN active = true
3007
-        return ! (
3008
-            $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR
3009
-            || (
3010
-                $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR
3011
-                && count($datetimes) < $this->getDatetimeSelectorThreshold()
3012
-            )
3013
-        );
3014
-    }
3015
-
3016
-
3017
-
3018
-    /**
3019
-     * @return string
3020
-     */
3021
-    public function getShowDatetimeSelector()
3022
-    {
3023
-        return $this->show_datetime_selector;
3024
-    }
3025
-
3026
-
3027
-
3028
-    /**
3029
-     * @param bool $keys_only
3030
-     * @return array
3031
-     */
3032
-    public function getShowDatetimeSelectorOptions($keys_only = true)
3033
-    {
3034
-        return $keys_only
3035
-            ? array(
3036
-                \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR,
3037
-                \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR,
3038
-            )
3039
-            : array(
3040
-                \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__(
3041
-                    'Do not show date & time filter', 'event_espresso'
3042
-                ),
3043
-                \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR  => esc_html__(
3044
-                    'Maybe show date & time filter', 'event_espresso'
3045
-                ),
3046
-            );
3047
-    }
3048
-
3049
-
3050
-
3051
-    /**
3052
-     * @param string $show_datetime_selector
3053
-     */
3054
-    public function setShowDatetimeSelector($show_datetime_selector)
3055
-    {
3056
-        $this->show_datetime_selector = in_array(
3057
-            $show_datetime_selector,
3058
-            $this->getShowDatetimeSelectorOptions(),
3059
-            true
3060
-        )
3061
-            ? $show_datetime_selector
3062
-            : \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3063
-    }
3064
-
3065
-
3066
-
3067
-    /**
3068
-     * @return int
3069
-     */
3070
-    public function getDatetimeSelectorThreshold()
3071
-    {
3072
-        return $this->datetime_selector_threshold;
3073
-    }
3074
-
3075
-
3076
-
3077
-
3078
-    /**
3079
-     * @param int $datetime_selector_threshold
3080
-     */
3081
-    public function setDatetimeSelectorThreshold($datetime_selector_threshold)
3082
-    {
3083
-        $datetime_selector_threshold = absint($datetime_selector_threshold);
3084
-        $this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3;
3085
-    }
2940
+	/**
2941
+	 * constant to indicate that a datetime selector should NEVER be shown for ticket selectors
2942
+	 */
2943
+	const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector';
2944
+
2945
+	/**
2946
+	 * constant to indicate that a datetime selector should only be shown for ticket selectors
2947
+	 * when the number of datetimes for the event matches the value set for $datetime_selector_threshold
2948
+	 */
2949
+	const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector';
2950
+
2951
+	/**
2952
+	 * @var boolean $show_ticket_sale_columns
2953
+	 */
2954
+	public $show_ticket_sale_columns;
2955
+
2956
+	/**
2957
+	 * @var boolean $show_ticket_details
2958
+	 */
2959
+	public $show_ticket_details;
2960
+
2961
+	/**
2962
+	 * @var boolean $show_expired_tickets
2963
+	 */
2964
+	public $show_expired_tickets;
2965
+
2966
+	/**
2967
+	 * whether or not to display a dropdown box populated with event datetimes
2968
+	 * that toggles which tickets are displayed for a ticket selector.
2969
+	 * uses one of the *_DATETIME_SELECTOR constants defined above
2970
+	 *
2971
+	 * @var string $show_datetime_selector
2972
+	 */
2973
+	private $show_datetime_selector = 'no_datetime_selector';
2974
+
2975
+	/**
2976
+	 * the number of datetimes an event has to have before conditionally displaying a datetime selector
2977
+	 *
2978
+	 * @var int $datetime_selector_threshold
2979
+	 */
2980
+	private $datetime_selector_threshold = 3;
2981
+
2982
+
2983
+
2984
+	/**
2985
+	 *    class constructor
2986
+	 */
2987
+	public function __construct()
2988
+	{
2989
+		$this->show_ticket_sale_columns = true;
2990
+		$this->show_ticket_details = true;
2991
+		$this->show_expired_tickets = true;
2992
+		$this->show_datetime_selector = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
2993
+		$this->datetime_selector_threshold = 3;
2994
+	}
2995
+
2996
+
2997
+
2998
+	/**
2999
+	 * returns true if a datetime selector should be displayed
3000
+	 *
3001
+	 * @param array $datetimes
3002
+	 * @return bool
3003
+	 */
3004
+	public function showDatetimeSelector(array $datetimes)
3005
+	{
3006
+		// if the settings are NOT: don't show OR below threshold, THEN active = true
3007
+		return ! (
3008
+			$this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR
3009
+			|| (
3010
+				$this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR
3011
+				&& count($datetimes) < $this->getDatetimeSelectorThreshold()
3012
+			)
3013
+		);
3014
+	}
3015
+
3016
+
3017
+
3018
+	/**
3019
+	 * @return string
3020
+	 */
3021
+	public function getShowDatetimeSelector()
3022
+	{
3023
+		return $this->show_datetime_selector;
3024
+	}
3025
+
3026
+
3027
+
3028
+	/**
3029
+	 * @param bool $keys_only
3030
+	 * @return array
3031
+	 */
3032
+	public function getShowDatetimeSelectorOptions($keys_only = true)
3033
+	{
3034
+		return $keys_only
3035
+			? array(
3036
+				\EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR,
3037
+				\EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR,
3038
+			)
3039
+			: array(
3040
+				\EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__(
3041
+					'Do not show date & time filter', 'event_espresso'
3042
+				),
3043
+				\EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR  => esc_html__(
3044
+					'Maybe show date & time filter', 'event_espresso'
3045
+				),
3046
+			);
3047
+	}
3048
+
3049
+
3050
+
3051
+	/**
3052
+	 * @param string $show_datetime_selector
3053
+	 */
3054
+	public function setShowDatetimeSelector($show_datetime_selector)
3055
+	{
3056
+		$this->show_datetime_selector = in_array(
3057
+			$show_datetime_selector,
3058
+			$this->getShowDatetimeSelectorOptions(),
3059
+			true
3060
+		)
3061
+			? $show_datetime_selector
3062
+			: \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3063
+	}
3064
+
3065
+
3066
+
3067
+	/**
3068
+	 * @return int
3069
+	 */
3070
+	public function getDatetimeSelectorThreshold()
3071
+	{
3072
+		return $this->datetime_selector_threshold;
3073
+	}
3074
+
3075
+
3076
+
3077
+
3078
+	/**
3079
+	 * @param int $datetime_selector_threshold
3080
+	 */
3081
+	public function setDatetimeSelectorThreshold($datetime_selector_threshold)
3082
+	{
3083
+		$datetime_selector_threshold = absint($datetime_selector_threshold);
3084
+		$this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3;
3085
+	}
3086 3086
 
3087 3087
 
3088 3088
 
@@ -3100,85 +3100,85 @@  discard block
 block discarded – undo
3100 3100
 class EE_Environment_Config extends EE_Config_Base
3101 3101
 {
3102 3102
 
3103
-    /**
3104
-     * Hold any php environment variables that we want to track.
3105
-     *
3106
-     * @var stdClass;
3107
-     */
3108
-    public $php;
3109
-
3110
-
3111
-
3112
-    /**
3113
-     *    constructor
3114
-     */
3115
-    public function __construct()
3116
-    {
3117
-        $this->php = new stdClass();
3118
-        $this->_set_php_values();
3119
-    }
3120
-
3121
-
3122
-
3123
-    /**
3124
-     * This sets the php environment variables.
3125
-     *
3126
-     * @since 4.4.0
3127
-     * @return void
3128
-     */
3129
-    protected function _set_php_values()
3130
-    {
3131
-        $this->php->max_input_vars = ini_get('max_input_vars');
3132
-        $this->php->version = phpversion();
3133
-    }
3134
-
3135
-
3136
-
3137
-    /**
3138
-     * helper method for determining whether input_count is
3139
-     * reaching the potential maximum the server can handle
3140
-     * according to max_input_vars
3141
-     *
3142
-     * @param int   $input_count the count of input vars.
3143
-     * @return array {
3144
-     *                           An array that represents whether available space and if no available space the error
3145
-     *                           message.
3146
-     * @type bool   $has_space   whether more inputs can be added.
3147
-     * @type string $msg         Any message to be displayed.
3148
-     *                           }
3149
-     */
3150
-    public function max_input_vars_limit_check($input_count = 0)
3151
-    {
3152
-        if (! empty($this->php->max_input_vars)
3153
-            && ($input_count >= $this->php->max_input_vars)
3154
-            && (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9)
3155
-        ) {
3156
-            return sprintf(
3157
-                __(
3158
-                    'The maximum number of inputs on this page has been exceeded.  You cannot add anymore items (i.e. tickets, datetimes, custom fields) on this page because of your servers PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.',
3159
-                    'event_espresso'
3160
-                ),
3161
-                '<br>',
3162
-                $input_count,
3163
-                $this->php->max_input_vars
3164
-            );
3165
-        } else {
3166
-            return '';
3167
-        }
3168
-    }
3169
-
3170
-
3171
-
3172
-    /**
3173
-     * The purpose of this method is just to force rechecking php values so if they've changed, they get updated.
3174
-     *
3175
-     * @since 4.4.1
3176
-     * @return void
3177
-     */
3178
-    public function recheck_values()
3179
-    {
3180
-        $this->_set_php_values();
3181
-    }
3103
+	/**
3104
+	 * Hold any php environment variables that we want to track.
3105
+	 *
3106
+	 * @var stdClass;
3107
+	 */
3108
+	public $php;
3109
+
3110
+
3111
+
3112
+	/**
3113
+	 *    constructor
3114
+	 */
3115
+	public function __construct()
3116
+	{
3117
+		$this->php = new stdClass();
3118
+		$this->_set_php_values();
3119
+	}
3120
+
3121
+
3122
+
3123
+	/**
3124
+	 * This sets the php environment variables.
3125
+	 *
3126
+	 * @since 4.4.0
3127
+	 * @return void
3128
+	 */
3129
+	protected function _set_php_values()
3130
+	{
3131
+		$this->php->max_input_vars = ini_get('max_input_vars');
3132
+		$this->php->version = phpversion();
3133
+	}
3134
+
3135
+
3136
+
3137
+	/**
3138
+	 * helper method for determining whether input_count is
3139
+	 * reaching the potential maximum the server can handle
3140
+	 * according to max_input_vars
3141
+	 *
3142
+	 * @param int   $input_count the count of input vars.
3143
+	 * @return array {
3144
+	 *                           An array that represents whether available space and if no available space the error
3145
+	 *                           message.
3146
+	 * @type bool   $has_space   whether more inputs can be added.
3147
+	 * @type string $msg         Any message to be displayed.
3148
+	 *                           }
3149
+	 */
3150
+	public function max_input_vars_limit_check($input_count = 0)
3151
+	{
3152
+		if (! empty($this->php->max_input_vars)
3153
+			&& ($input_count >= $this->php->max_input_vars)
3154
+			&& (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9)
3155
+		) {
3156
+			return sprintf(
3157
+				__(
3158
+					'The maximum number of inputs on this page has been exceeded.  You cannot add anymore items (i.e. tickets, datetimes, custom fields) on this page because of your servers PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.',
3159
+					'event_espresso'
3160
+				),
3161
+				'<br>',
3162
+				$input_count,
3163
+				$this->php->max_input_vars
3164
+			);
3165
+		} else {
3166
+			return '';
3167
+		}
3168
+	}
3169
+
3170
+
3171
+
3172
+	/**
3173
+	 * The purpose of this method is just to force rechecking php values so if they've changed, they get updated.
3174
+	 *
3175
+	 * @since 4.4.1
3176
+	 * @return void
3177
+	 */
3178
+	public function recheck_values()
3179
+	{
3180
+		$this->_set_php_values();
3181
+	}
3182 3182
 
3183 3183
 
3184 3184
 
@@ -3196,22 +3196,22 @@  discard block
 block discarded – undo
3196 3196
 class EE_Tax_Config extends EE_Config_Base
3197 3197
 {
3198 3198
 
3199
-    /*
3199
+	/*
3200 3200
      * flag to indicate whether or not to display ticket prices with the taxes included
3201 3201
      *
3202 3202
      * @var boolean $prices_displayed_including_taxes
3203 3203
      */
3204
-    public $prices_displayed_including_taxes;
3204
+	public $prices_displayed_including_taxes;
3205 3205
 
3206 3206
 
3207 3207
 
3208
-    /**
3209
-     *    class constructor
3210
-     */
3211
-    public function __construct()
3212
-    {
3213
-        $this->prices_displayed_including_taxes = true;
3214
-    }
3208
+	/**
3209
+	 *    class constructor
3210
+	 */
3211
+	public function __construct()
3212
+	{
3213
+		$this->prices_displayed_including_taxes = true;
3214
+	}
3215 3215
 }
3216 3216
 
3217 3217
 
@@ -3226,17 +3226,17 @@  discard block
 block discarded – undo
3226 3226
 class EE_Messages_Config extends EE_Config_Base
3227 3227
 {
3228 3228
 
3229
-    /**
3230
-     * This is an integer representing the deletion threshold in months for when old messages will get deleted.
3231
-     * A value of 0 represents never deleting.  Default is 0.
3232
-     *
3233
-     * @var integer
3234
-     */
3235
-    public $delete_threshold;
3236
-
3237
-    public function __construct() {
3238
-        $this->delete_threshold = 0;
3239
-    }
3229
+	/**
3230
+	 * This is an integer representing the deletion threshold in months for when old messages will get deleted.
3231
+	 * A value of 0 represents never deleting.  Default is 0.
3232
+	 *
3233
+	 * @var integer
3234
+	 */
3235
+	public $delete_threshold;
3236
+
3237
+	public function __construct() {
3238
+		$this->delete_threshold = 0;
3239
+	}
3240 3240
 }
3241 3241
 
3242 3242
 
@@ -3248,34 +3248,34 @@  discard block
 block discarded – undo
3248 3248
 class EE_Gateway_Config extends EE_Config_Base
3249 3249
 {
3250 3250
 
3251
-    /**
3252
-     * Array with keys that are payment gateways slugs, and values are arrays
3253
-     * with any config info the gateway wants to store
3254
-     *
3255
-     * @var array
3256
-     */
3257
-    public $payment_settings;
3258
-
3259
-    /**
3260
-     * Where keys are gateway slugs, and values are booleans indicating whether or not
3261
-     * the gateway is stored in the uploads directory
3262
-     *
3263
-     * @var array
3264
-     */
3265
-    public $active_gateways;
3266
-
3267
-
3268
-
3269
-    /**
3270
-     *    class constructor
3271
-     *
3272
-     * @deprecated
3273
-     */
3274
-    public function __construct()
3275
-    {
3276
-        $this->payment_settings = array();
3277
-        $this->active_gateways = array('Invoice' => false);
3278
-    }
3251
+	/**
3252
+	 * Array with keys that are payment gateways slugs, and values are arrays
3253
+	 * with any config info the gateway wants to store
3254
+	 *
3255
+	 * @var array
3256
+	 */
3257
+	public $payment_settings;
3258
+
3259
+	/**
3260
+	 * Where keys are gateway slugs, and values are booleans indicating whether or not
3261
+	 * the gateway is stored in the uploads directory
3262
+	 *
3263
+	 * @var array
3264
+	 */
3265
+	public $active_gateways;
3266
+
3267
+
3268
+
3269
+	/**
3270
+	 *    class constructor
3271
+	 *
3272
+	 * @deprecated
3273
+	 */
3274
+	public function __construct()
3275
+	{
3276
+		$this->payment_settings = array();
3277
+		$this->active_gateways = array('Invoice' => false);
3278
+	}
3279 3279
 }
3280 3280
 
3281 3281
 // End of file EE_Config.core.php
Please login to merge, or discard this patch.
Spacing   +118 added lines, -118 removed lines patch added patch discarded remove patch
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
     public static function instance()
155 155
     {
156 156
         // check if class object is instantiated, and instantiated properly
157
-        if (! self::$_instance instanceof EE_Config) {
157
+        if ( ! self::$_instance instanceof EE_Config) {
158 158
             self::$_instance = new self();
159 159
         }
160 160
         return self::$_instance;
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
                 $this
299 299
             );
300 300
             if (is_object($settings) && property_exists($this, $config)) {
301
-                $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings);
301
+                $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__'.$config, $settings);
302 302
                 //call configs populate method to ensure any defaults are set for empty values.
303 303
                 if (method_exists($settings, 'populate')) {
304 304
                     $this->{$config}->populate();
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
                         break;
573 573
                     // TEST #2 : check that settings section exists
574 574
                     case 2 :
575
-                        if (! isset($this->{$section})) {
575
+                        if ( ! isset($this->{$section})) {
576 576
                             if ($display_errors) {
577 577
                                 throw new EE_Error(
578 578
                                     sprintf(
@@ -633,7 +633,7 @@  discard block
 block discarded – undo
633 633
                         break;
634 634
                     // TEST #6 : verify config class is accessible
635 635
                     case 6 :
636
-                        if (! class_exists($config_class)) {
636
+                        if ( ! class_exists($config_class)) {
637 637
                             if ($display_errors) {
638 638
                                 throw new EE_Error(
639 639
                                     sprintf(
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
                         break;
651 651
                     // TEST #7 : check that config has even been set
652 652
                     case 7 :
653
-                        if (! isset($this->{$section}->{$name})) {
653
+                        if ( ! isset($this->{$section}->{$name})) {
654 654
                             if ($display_errors) {
655 655
                                 throw new EE_Error(
656 656
                                     sprintf(
@@ -668,7 +668,7 @@  discard block
 block discarded – undo
668 668
                         break;
669 669
                     // TEST #8 : check that config is the requested type
670 670
                     case 8 :
671
-                        if (! $this->{$section}->{$name} instanceof $config_class) {
671
+                        if ( ! $this->{$section}->{$name} instanceof $config_class) {
672 672
                             if ($display_errors) {
673 673
                                 throw new EE_Error(
674 674
                                     sprintf(
@@ -687,7 +687,7 @@  discard block
 block discarded – undo
687 687
                         break;
688 688
                     // TEST #9 : verify config object
689 689
                     case 9 :
690
-                        if (! $config_obj instanceof EE_Config_Base) {
690
+                        if ( ! $config_obj instanceof EE_Config_Base) {
691 691
                             if ($display_errors) {
692 692
                                 throw new EE_Error(
693 693
                                     sprintf(
@@ -720,7 +720,7 @@  discard block
 block discarded – undo
720 720
      */
721 721
     private function _generate_config_option_name($section = '', $name = '')
722 722
     {
723
-        return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name));
723
+        return 'ee_config-'.strtolower($section.'-'.str_replace(array('EE_', 'EED_'), '', $name));
724 724
     }
725 725
 
726 726
 
@@ -738,7 +738,7 @@  discard block
 block discarded – undo
738 738
     {
739 739
         return ! empty($config_class)
740 740
             ? $config_class
741
-            : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config';
741
+            : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))).'_Config';
742 742
     }
743 743
 
744 744
 
@@ -758,17 +758,17 @@  discard block
 block discarded – undo
758 758
         // ensure config class is set to something
759 759
         $config_class = $this->_set_config_class($config_class, $name);
760 760
         // run tests 1-4, 6, and 7 to verify all config params are set and valid
761
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
761
+        if ( ! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
762 762
             return null;
763 763
         }
764 764
         $config_option_name = $this->_generate_config_option_name($section, $name);
765 765
         // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now
766
-        if (! isset($this->_addon_option_names[$config_option_name])) {
766
+        if ( ! isset($this->_addon_option_names[$config_option_name])) {
767 767
             $this->_addon_option_names[$config_option_name] = $config_class;
768 768
             $this->update_addon_option_names();
769 769
         }
770 770
         // verify the incoming config object but suppress errors
771
-        if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
771
+        if ( ! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
772 772
             $config_obj = new $config_class();
773 773
         }
774 774
         if (get_option($config_option_name)) {
@@ -816,7 +816,7 @@  discard block
 block discarded – undo
816 816
         // get class name of the incoming object
817 817
         $config_class = get_class($config_obj);
818 818
         // run tests 1-5 and 9 to verify config
819
-        if (! $this->_verify_config_params(
819
+        if ( ! $this->_verify_config_params(
820 820
             $section,
821 821
             $name,
822 822
             $config_class,
@@ -828,7 +828,7 @@  discard block
 block discarded – undo
828 828
         }
829 829
         $config_option_name = $this->_generate_config_option_name($section, $name);
830 830
         // check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
831
-        if (! isset($this->_addon_option_names[$config_option_name])) {
831
+        if ( ! isset($this->_addon_option_names[$config_option_name])) {
832 832
             // save new config to db
833 833
             if ($this->set_config($section, $name, $config_class, $config_obj)) {
834 834
                 return true;
@@ -854,7 +854,7 @@  discard block
 block discarded – undo
854 854
                             'event_espresso'
855 855
                         ),
856 856
                         $config_class,
857
-                        'EE_Config->' . $section . '->' . $name
857
+                        'EE_Config->'.$section.'->'.$name
858 858
                     ),
859 859
                     __FILE__,
860 860
                     __FUNCTION__,
@@ -881,7 +881,7 @@  discard block
 block discarded – undo
881 881
         // ensure config class is set to something
882 882
         $config_class = $this->_set_config_class($config_class, $name);
883 883
         // run tests 1-4, 6 and 7 to verify that all params have been set
884
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
884
+        if ( ! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
885 885
             return null;
886 886
         }
887 887
         // now test if the requested config object exists, but suppress errors
@@ -927,7 +927,7 @@  discard block
 block discarded – undo
927 927
         // retrieve the wp-option for this config class.
928 928
         $config_option = maybe_unserialize(get_option($config_option_name, array()));
929 929
         if (empty($config_option)) {
930
-            EE_Config::log($config_option_name . '-NOT-FOUND');
930
+            EE_Config::log($config_option_name.'-NOT-FOUND');
931 931
         }
932 932
         return $config_option;
933 933
     }
@@ -946,7 +946,7 @@  discard block
 block discarded – undo
946 946
             //copy incoming $_REQUEST and sanitize it so we can save it
947 947
             $_request = $_REQUEST;
948 948
             array_walk_recursive($_request, 'sanitize_text_field');
949
-            $config_log[(string)microtime(true)] = array(
949
+            $config_log[(string) microtime(true)] = array(
950 950
                 'config_name' => $config_option_name,
951 951
                 'request'     => $_request,
952 952
             );
@@ -962,7 +962,7 @@  discard block
 block discarded – undo
962 962
      */
963 963
     public static function trim_log()
964 964
     {
965
-        if (! EE_Config::logging_enabled()) {
965
+        if ( ! EE_Config::logging_enabled()) {
966 966
             return;
967 967
         }
968 968
         $config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
@@ -987,7 +987,7 @@  discard block
 block discarded – undo
987 987
     public static function get_page_for_posts()
988 988
     {
989 989
         $page_for_posts = get_option('page_for_posts');
990
-        if (! $page_for_posts) {
990
+        if ( ! $page_for_posts) {
991 991
             return 'posts';
992 992
         }
993 993
         /** @type WPDB $wpdb */
@@ -1048,13 +1048,13 @@  discard block
 block discarded – undo
1048 1048
             )
1049 1049
         ) {
1050 1050
             // grab list of installed widgets
1051
-            $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
1051
+            $widgets_to_register = glob(EE_WIDGETS.'*', GLOB_ONLYDIR);
1052 1052
             // filter list of modules to register
1053 1053
             $widgets_to_register = apply_filters(
1054 1054
                 'FHEE__EE_Config__register_widgets__widgets_to_register',
1055 1055
                 $widgets_to_register
1056 1056
             );
1057
-            if (! empty($widgets_to_register)) {
1057
+            if ( ! empty($widgets_to_register)) {
1058 1058
                 // cycle thru widget folders
1059 1059
                 foreach ($widgets_to_register as $widget_path) {
1060 1060
                     // add to list of installed widget modules
@@ -1105,31 +1105,31 @@  discard block
 block discarded – undo
1105 1105
         // create classname from widget directory name
1106 1106
         $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1107 1107
         // add class prefix
1108
-        $widget_class = 'EEW_' . $widget;
1108
+        $widget_class = 'EEW_'.$widget;
1109 1109
         // does the widget exist ?
1110
-        if (! is_readable($widget_path . DS . $widget_class . $widget_ext)) {
1110
+        if ( ! is_readable($widget_path.DS.$widget_class.$widget_ext)) {
1111 1111
             $msg = sprintf(
1112 1112
                 __(
1113 1113
                     'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s',
1114 1114
                     'event_espresso'
1115 1115
                 ),
1116 1116
                 $widget_class,
1117
-                $widget_path . DS . $widget_class . $widget_ext
1117
+                $widget_path.DS.$widget_class.$widget_ext
1118 1118
             );
1119
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1119
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1120 1120
             return;
1121 1121
         }
1122 1122
         // load the widget class file
1123
-        require_once($widget_path . DS . $widget_class . $widget_ext);
1123
+        require_once($widget_path.DS.$widget_class.$widget_ext);
1124 1124
         // verify that class exists
1125
-        if (! class_exists($widget_class)) {
1125
+        if ( ! class_exists($widget_class)) {
1126 1126
             $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1127
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1127
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1128 1128
             return;
1129 1129
         }
1130 1130
         register_widget($widget_class);
1131 1131
         // add to array of registered widgets
1132
-        EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext;
1132
+        EE_Registry::instance()->widgets->{$widget_class} = $widget_path.DS.$widget_class.$widget_ext;
1133 1133
     }
1134 1134
 
1135 1135
 
@@ -1143,19 +1143,19 @@  discard block
 block discarded – undo
1143 1143
     private function _register_modules()
1144 1144
     {
1145 1145
         // grab list of installed modules
1146
-        $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1146
+        $modules_to_register = glob(EE_MODULES.'*', GLOB_ONLYDIR);
1147 1147
         // filter list of modules to register
1148 1148
         $modules_to_register = apply_filters(
1149 1149
             'FHEE__EE_Config__register_modules__modules_to_register',
1150 1150
             $modules_to_register
1151 1151
         );
1152
-        if (! empty($modules_to_register)) {
1152
+        if ( ! empty($modules_to_register)) {
1153 1153
             // loop through folders
1154 1154
             foreach ($modules_to_register as $module_path) {
1155 1155
                 /**TEMPORARILY EXCLUDE gateways from modules for time being**/
1156 1156
                 if (
1157
-                    $module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1158
-                    && $module_path !== EE_MODULES . 'gateways'
1157
+                    $module_path !== EE_MODULES.'zzz-copy-this-module-template'
1158
+                    && $module_path !== EE_MODULES.'gateways'
1159 1159
                 ) {
1160 1160
                     // add to list of installed modules
1161 1161
                     EE_Config::register_module($module_path);
@@ -1193,25 +1193,25 @@  discard block
 block discarded – undo
1193 1193
             // remove last segment
1194 1194
             array_pop($module_path);
1195 1195
             // glue it back together
1196
-            $module_path = implode(DS, $module_path) . DS;
1196
+            $module_path = implode(DS, $module_path).DS;
1197 1197
             // take first segment from file name pieces and sanitize it
1198 1198
             $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1199 1199
             // ensure class prefix is added
1200
-            $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1200
+            $module_class = strpos($module, 'EED_') !== 0 ? 'EED_'.$module : $module;
1201 1201
         } else {
1202 1202
             // we need to generate the filename based off of the folder name
1203 1203
             // grab and sanitize module name
1204 1204
             $module = strtolower(basename($module_path));
1205 1205
             $module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1206 1206
             // like trailingslashit()
1207
-            $module_path = rtrim($module_path, DS) . DS;
1207
+            $module_path = rtrim($module_path, DS).DS;
1208 1208
             // create classname from module directory name
1209 1209
             $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1210 1210
             // add class prefix
1211
-            $module_class = 'EED_' . $module;
1211
+            $module_class = 'EED_'.$module;
1212 1212
         }
1213 1213
         // does the module exist ?
1214
-        if (! is_readable($module_path . DS . $module_class . $module_ext)) {
1214
+        if ( ! is_readable($module_path.DS.$module_class.$module_ext)) {
1215 1215
             $msg = sprintf(
1216 1216
                 __(
1217 1217
                     'The requested %s module file could not be found or is not readable due to file permissions.',
@@ -1219,19 +1219,19 @@  discard block
 block discarded – undo
1219 1219
                 ),
1220 1220
                 $module
1221 1221
             );
1222
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1222
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1223 1223
             return false;
1224 1224
         }
1225 1225
         // load the module class file
1226
-        require_once($module_path . $module_class . $module_ext);
1226
+        require_once($module_path.$module_class.$module_ext);
1227 1227
         // verify that class exists
1228
-        if (! class_exists($module_class)) {
1228
+        if ( ! class_exists($module_class)) {
1229 1229
             $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1230
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1230
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1231 1231
             return false;
1232 1232
         }
1233 1233
         // add to array of registered modules
1234
-        EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1234
+        EE_Registry::instance()->modules->{$module_class} = $module_path.$module_class.$module_ext;
1235 1235
         do_action(
1236 1236
             'AHEE__EE_Config__register_module__complete',
1237 1237
             $module_class,
@@ -1284,26 +1284,26 @@  discard block
 block discarded – undo
1284 1284
     {
1285 1285
         do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1286 1286
         $module = str_replace('EED_', '', $module);
1287
-        $module_class = 'EED_' . $module;
1288
-        if (! isset(EE_Registry::instance()->modules->{$module_class})) {
1287
+        $module_class = 'EED_'.$module;
1288
+        if ( ! isset(EE_Registry::instance()->modules->{$module_class})) {
1289 1289
             $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module);
1290
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1290
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1291 1291
             return false;
1292 1292
         }
1293 1293
         if (empty($route)) {
1294 1294
             $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route);
1295
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1295
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1296 1296
             return false;
1297 1297
         }
1298
-        if (! method_exists('EED_' . $module, $method_name)) {
1298
+        if ( ! method_exists('EED_'.$module, $method_name)) {
1299 1299
             $msg = sprintf(
1300 1300
                 __('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1301 1301
                 $route
1302 1302
             );
1303
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1303
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1304 1304
             return false;
1305 1305
         }
1306
-        EE_Config::$_module_route_map[$key][$route] = array('EED_' . $module, $method_name);
1306
+        EE_Config::$_module_route_map[$key][$route] = array('EED_'.$module, $method_name);
1307 1307
         return true;
1308 1308
     }
1309 1309
 
@@ -1320,7 +1320,7 @@  discard block
 block discarded – undo
1320 1320
     public static function get_route($route = null, $key = 'ee')
1321 1321
     {
1322 1322
         do_action('AHEE__EE_Config__get_route__begin', $route);
1323
-        $route = (string)apply_filters('FHEE__EE_Config__get_route', $route);
1323
+        $route = (string) apply_filters('FHEE__EE_Config__get_route', $route);
1324 1324
         if (isset(EE_Config::$_module_route_map[$key][$route])) {
1325 1325
             return EE_Config::$_module_route_map[$key][$route];
1326 1326
         }
@@ -1356,44 +1356,44 @@  discard block
 block discarded – undo
1356 1356
     public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee')
1357 1357
     {
1358 1358
         do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1359
-        if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1359
+        if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1360 1360
             $msg = sprintf(
1361 1361
                 __('The module route %s for this forward has not been registered.', 'event_espresso'),
1362 1362
                 $route
1363 1363
             );
1364
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1364
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1365 1365
             return false;
1366 1366
         }
1367 1367
         if (empty($forward)) {
1368 1368
             $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route);
1369
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1369
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1370 1370
             return false;
1371 1371
         }
1372 1372
         if (is_array($forward)) {
1373
-            if (! isset($forward[1])) {
1373
+            if ( ! isset($forward[1])) {
1374 1374
                 $msg = sprintf(
1375 1375
                     __('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1376 1376
                     $route
1377 1377
                 );
1378
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1378
+                EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1379 1379
                 return false;
1380 1380
             }
1381
-            if (! method_exists($forward[0], $forward[1])) {
1381
+            if ( ! method_exists($forward[0], $forward[1])) {
1382 1382
                 $msg = sprintf(
1383 1383
                     __('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1384 1384
                     $forward[1],
1385 1385
                     $route
1386 1386
                 );
1387
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1387
+                EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1388 1388
                 return false;
1389 1389
             }
1390
-        } else if (! function_exists($forward)) {
1390
+        } else if ( ! function_exists($forward)) {
1391 1391
             $msg = sprintf(
1392 1392
                 __('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1393 1393
                 $forward,
1394 1394
                 $route
1395 1395
             );
1396
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1396
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1397 1397
             return false;
1398 1398
         }
1399 1399
         EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward;
@@ -1443,15 +1443,15 @@  discard block
 block discarded – undo
1443 1443
     public static function register_view($route = null, $status = 0, $view = null, $key = 'ee')
1444 1444
     {
1445 1445
         do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1446
-        if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1446
+        if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1447 1447
             $msg = sprintf(
1448 1448
                 __('The module route %s for this view has not been registered.', 'event_espresso'),
1449 1449
                 $route
1450 1450
             );
1451
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1451
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1452 1452
             return false;
1453 1453
         }
1454
-        if (! is_readable($view)) {
1454
+        if ( ! is_readable($view)) {
1455 1455
             $msg = sprintf(
1456 1456
                 __(
1457 1457
                     'The %s view file could not be found or is not readable due to file permissions.',
@@ -1459,7 +1459,7 @@  discard block
 block discarded – undo
1459 1459
                 ),
1460 1460
                 $view
1461 1461
             );
1462
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1462
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1463 1463
             return false;
1464 1464
         }
1465 1465
         EE_Config::$_module_view_map[$key][$route][absint($status)] = $view;
@@ -1567,7 +1567,7 @@  discard block
 block discarded – undo
1567 1567
      */
1568 1568
     public function get_pretty($property)
1569 1569
     {
1570
-        if (! property_exists($this, $property)) {
1570
+        if ( ! property_exists($this, $property)) {
1571 1571
             throw new EE_Error(
1572 1572
                 sprintf(
1573 1573
                     __(
@@ -1806,11 +1806,11 @@  discard block
 block discarded – undo
1806 1806
      */
1807 1807
     public function reg_page_url()
1808 1808
     {
1809
-        if (! $this->reg_page_url) {
1809
+        if ( ! $this->reg_page_url) {
1810 1810
             $this->reg_page_url = add_query_arg(
1811 1811
                                       array('uts' => time()),
1812 1812
                                       get_permalink($this->reg_page_id)
1813
-                                  ) . '#checkout';
1813
+                                  ).'#checkout';
1814 1814
         }
1815 1815
         return $this->reg_page_url;
1816 1816
     }
@@ -1827,7 +1827,7 @@  discard block
 block discarded – undo
1827 1827
      */
1828 1828
     public function txn_page_url($query_args = array())
1829 1829
     {
1830
-        if (! $this->txn_page_url) {
1830
+        if ( ! $this->txn_page_url) {
1831 1831
             $this->txn_page_url = get_permalink($this->txn_page_id);
1832 1832
         }
1833 1833
         if ($query_args) {
@@ -1849,7 +1849,7 @@  discard block
 block discarded – undo
1849 1849
      */
1850 1850
     public function thank_you_page_url($query_args = array())
1851 1851
     {
1852
-        if (! $this->thank_you_page_url) {
1852
+        if ( ! $this->thank_you_page_url) {
1853 1853
             $this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1854 1854
         }
1855 1855
         if ($query_args) {
@@ -1869,7 +1869,7 @@  discard block
 block discarded – undo
1869 1869
      */
1870 1870
     public function cancel_page_url()
1871 1871
     {
1872
-        if (! $this->cancel_page_url) {
1872
+        if ( ! $this->cancel_page_url) {
1873 1873
             $this->cancel_page_url = get_permalink($this->cancel_page_id);
1874 1874
         }
1875 1875
         return $this->cancel_page_url;
@@ -1914,13 +1914,13 @@  discard block
 block discarded – undo
1914 1914
         $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1915 1915
         $option = 'ee_ueip_optin';
1916 1916
         //set correct table for query
1917
-        $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1917
+        $table_name = $wpdb->get_blog_prefix($current_main_site_id).'options';
1918 1918
         //rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
1919 1919
         //get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be
1920 1920
         //re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1921 1921
         //this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1922 1922
         //for the purpose of caching.
1923
-        $pre = apply_filters('pre_option_' . $option, false, $option);
1923
+        $pre = apply_filters('pre_option_'.$option, false, $option);
1924 1924
         if (false !== $pre) {
1925 1925
             EE_Core_Config::$ee_ueip_option = $pre;
1926 1926
             return EE_Core_Config::$ee_ueip_option;
@@ -1930,9 +1930,9 @@  discard block
 block discarded – undo
1930 1930
         if (is_object($row)) {
1931 1931
             $value = $row->option_value;
1932 1932
         } else { //option does not exist so use default.
1933
-            return apply_filters('default_option_' . $option, false, $option);
1933
+            return apply_filters('default_option_'.$option, false, $option);
1934 1934
         }
1935
-        EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
1935
+        EE_Core_Config::$ee_ueip_option = apply_filters('option_'.$option, maybe_unserialize($value), $option);
1936 1936
         return EE_Core_Config::$ee_ueip_option;
1937 1937
     }
1938 1938
 
@@ -2195,33 +2195,33 @@  discard block
 block discarded – undo
2195 2195
      */
2196 2196
     public function __construct($CNT_ISO = '', CountryCurrencyDao $country_currencies = null)
2197 2197
     {
2198
-        if(! $country_currencies instanceof CountryCurrencyDao){
2198
+        if ( ! $country_currencies instanceof CountryCurrencyDao) {
2199 2199
             $country_currencies = new CountryCurrencyDao();
2200 2200
         }
2201 2201
         // so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists
2202
-        if (! empty($CNT_ISO)) {
2202
+        if ( ! empty($CNT_ISO)) {
2203 2203
             // retrieve the country settings from the db, just in case they have been customized
2204 2204
             $country_currency = $country_currencies->getCountryCurrencyByIsoCode($CNT_ISO);
2205
-            $this->code = $country_currency['CurrencyCode'];    // currency code: USD, CAD, EUR
2206
-            $this->name = $country_currency['CurrencyNameSingle'];    // Dollar
2207
-            $this->plural = $country_currency['CurrencyNamePlural'];    // Dollars
2208
-            $this->sign = $country_currency['CurrencySign'];            // currency sign: $
2209
-            $this->sign_b4 = $country_currency['CurrencySignB4'];        // currency sign before or after: $TRUE  or  FALSE$
2210
-            $this->dec_plc = $country_currency['CurrencyDecimalPlaces'];    // decimal places: 2 = 0.00  3 = 0.000
2211
-            $this->dec_mrk = $country_currency['CurrencyDecimalMark'];    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2212
-            $this->thsnds = $country_currency['CurrencyThousands'];    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2205
+            $this->code = $country_currency['CurrencyCode']; // currency code: USD, CAD, EUR
2206
+            $this->name = $country_currency['CurrencyNameSingle']; // Dollar
2207
+            $this->plural = $country_currency['CurrencyNamePlural']; // Dollars
2208
+            $this->sign = $country_currency['CurrencySign']; // currency sign: $
2209
+            $this->sign_b4 = $country_currency['CurrencySignB4']; // currency sign before or after: $TRUE  or  FALSE$
2210
+            $this->dec_plc = $country_currency['CurrencyDecimalPlaces']; // decimal places: 2 = 0.00  3 = 0.000
2211
+            $this->dec_mrk = $country_currency['CurrencyDecimalMark']; // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2212
+            $this->thsnds = $country_currency['CurrencyThousands']; // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2213 2213
         }
2214 2214
         // fallback to hardcoded defaults, in case the above failed
2215 2215
         if (empty($this->code)) {
2216 2216
             // set default currency settings
2217
-            $this->code = 'USD';    // currency code: USD, CAD, EUR
2218
-            $this->name = esc_html__('Dollar', 'event_espresso');    // Dollar
2219
-            $this->plural = esc_html__('Dollars', 'event_espresso');    // Dollars
2220
-            $this->sign = '$';    // currency sign: $
2221
-            $this->sign_b4 = true;    // currency sign before or after: $TRUE  or  FALSE$
2222
-            $this->dec_plc = 2;    // decimal places: 2 = 0.00  3 = 0.000
2223
-            $this->dec_mrk = '.';    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2224
-            $this->thsnds = ',';    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2217
+            $this->code = 'USD'; // currency code: USD, CAD, EUR
2218
+            $this->name = esc_html__('Dollar', 'event_espresso'); // Dollar
2219
+            $this->plural = esc_html__('Dollars', 'event_espresso'); // Dollars
2220
+            $this->sign = '$'; // currency sign: $
2221
+            $this->sign_b4 = true; // currency sign before or after: $TRUE  or  FALSE$
2222
+            $this->dec_plc = 2; // decimal places: 2 = 0.00  3 = 0.000
2223
+            $this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2224
+            $this->thsnds = ','; // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2225 2225
         }
2226 2226
     }
2227 2227
 
@@ -2236,14 +2236,14 @@  discard block
 block discarded – undo
2236 2236
      */
2237 2237
     public function setFromCountry(EE_Country $country)
2238 2238
     {
2239
-        $this->code    = $country->currency_code();    // currency code: USD, CAD, EUR
2240
-        $this->name    = $country->currency_name_single();    // Dollar
2241
-        $this->plural  = $country->currency_name_plural();    // Dollars
2242
-        $this->sign    = $country->currency_sign();            // currency sign: $
2243
-        $this->sign_b4 = $country->currency_sign_before();        // currency sign before or after: $TRUE  or  FALSE$
2244
-        $this->dec_plc = $country->currency_decimal_places();    // decimal places: 2 = 0.00  3 = 0.000
2245
-        $this->dec_mrk = $country->currency_decimal_mark();    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2246
-        $this->thsnds  = $country->currency_thousands_separator();    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2239
+        $this->code    = $country->currency_code(); // currency code: USD, CAD, EUR
2240
+        $this->name    = $country->currency_name_single(); // Dollar
2241
+        $this->plural  = $country->currency_name_plural(); // Dollars
2242
+        $this->sign    = $country->currency_sign(); // currency sign: $
2243
+        $this->sign_b4 = $country->currency_sign_before(); // currency sign before or after: $TRUE  or  FALSE$
2244
+        $this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00  3 = 0.000
2245
+        $this->dec_mrk = $country->currency_decimal_mark(); // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2246
+        $this->thsnds  = $country->currency_thousands_separator(); // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2247 2247
     }
2248 2248
 }
2249 2249
 
@@ -2588,7 +2588,7 @@  discard block
 block discarded – undo
2588 2588
     public function log_file_name($reset = false)
2589 2589
     {
2590 2590
         if (empty($this->log_file_name) || $reset) {
2591
-            $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2591
+            $this->log_file_name = sanitize_key('espresso_log_'.md5(uniqid('', true))).'.txt';
2592 2592
             EE_Config::instance()->update_espresso_config(false, false);
2593 2593
         }
2594 2594
         return $this->log_file_name;
@@ -2603,7 +2603,7 @@  discard block
 block discarded – undo
2603 2603
     public function debug_file_name($reset = false)
2604 2604
     {
2605 2605
         if (empty($this->debug_file_name) || $reset) {
2606
-            $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2606
+            $this->debug_file_name = sanitize_key('espresso_debug_'.md5(uniqid('', true))).'.txt';
2607 2607
             EE_Config::instance()->update_espresso_config(false, false);
2608 2608
         }
2609 2609
         return $this->debug_file_name;
@@ -2820,21 +2820,21 @@  discard block
 block discarded – undo
2820 2820
         $this->use_google_maps = true;
2821 2821
         $this->google_map_api_key = '';
2822 2822
         // for event details pages (reg page)
2823
-        $this->event_details_map_width = 585;            // ee_map_width_single
2824
-        $this->event_details_map_height = 362;            // ee_map_height_single
2825
-        $this->event_details_map_zoom = 14;            // ee_map_zoom_single
2826
-        $this->event_details_display_nav = true;            // ee_map_nav_display_single
2827
-        $this->event_details_nav_size = false;            // ee_map_nav_size_single
2828
-        $this->event_details_control_type = 'default';        // ee_map_type_control_single
2829
-        $this->event_details_map_align = 'center';            // ee_map_align_single
2823
+        $this->event_details_map_width = 585; // ee_map_width_single
2824
+        $this->event_details_map_height = 362; // ee_map_height_single
2825
+        $this->event_details_map_zoom = 14; // ee_map_zoom_single
2826
+        $this->event_details_display_nav = true; // ee_map_nav_display_single
2827
+        $this->event_details_nav_size = false; // ee_map_nav_size_single
2828
+        $this->event_details_control_type = 'default'; // ee_map_type_control_single
2829
+        $this->event_details_map_align = 'center'; // ee_map_align_single
2830 2830
         // for event list pages
2831
-        $this->event_list_map_width = 300;            // ee_map_width
2832
-        $this->event_list_map_height = 185;        // ee_map_height
2833
-        $this->event_list_map_zoom = 12;            // ee_map_zoom
2834
-        $this->event_list_display_nav = false;        // ee_map_nav_display
2835
-        $this->event_list_nav_size = true;            // ee_map_nav_size
2836
-        $this->event_list_control_type = 'dropdown';        // ee_map_type_control
2837
-        $this->event_list_map_align = 'center';            // ee_map_align
2831
+        $this->event_list_map_width = 300; // ee_map_width
2832
+        $this->event_list_map_height = 185; // ee_map_height
2833
+        $this->event_list_map_zoom = 12; // ee_map_zoom
2834
+        $this->event_list_display_nav = false; // ee_map_nav_display
2835
+        $this->event_list_nav_size = true; // ee_map_nav_size
2836
+        $this->event_list_control_type = 'dropdown'; // ee_map_type_control
2837
+        $this->event_list_map_align = 'center'; // ee_map_align
2838 2838
     }
2839 2839
 
2840 2840
 }
@@ -3149,7 +3149,7 @@  discard block
 block discarded – undo
3149 3149
      */
3150 3150
     public function max_input_vars_limit_check($input_count = 0)
3151 3151
     {
3152
-        if (! empty($this->php->max_input_vars)
3152
+        if ( ! empty($this->php->max_input_vars)
3153 3153
             && ($input_count >= $this->php->max_input_vars)
3154 3154
             && (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9)
3155 3155
         ) {
Please login to merge, or discard this patch.
core/helpers/EEH_Money.helper.php 2 patches
Indentation   +321 added lines, -321 removed lines patch added patch discarded remove patch
@@ -19,337 +19,337 @@
 block discarded – undo
19 19
 class EEH_Money extends EEH_Base
20 20
 {
21 21
 
22
-    /**
23
-     * This removes all localized money formatting from the incoming value
24
-     * Note: uses this site's currency settings for deciding what is considered a
25
-     * "thousands separator" (usually the character "," )
26
-     * and what is a "decimal mark" (usually the character ".")
27
-     *
28
-     * @param int|float|string $money_value
29
-     * @param string           $CNT_ISO
30
-     * @return float
31
-     * @throws EE_Error
32
-     * @throws InvalidArgumentException
33
-     * @throws ReflectionException
34
-     * @throws InvalidDataTypeException
35
-     * @throws InvalidInterfaceException
36
-     */
37
-    public static function strip_localized_money_formatting($money_value, $CNT_ISO = '')
38
-    {
39
-        $currency_config = EEH_Money::get_currency_config($CNT_ISO);
40
-        $money_value     = str_replace(
41
-            array(
42
-                $currency_config->thsnds,
43
-                $currency_config->dec_mrk,
44
-            ),
45
-            array(
46
-                '', // remove thousands separator
47
-                '.', // convert decimal mark to what PHP expects
48
-            ),
49
-            $money_value
50
-        );
51
-        $money_value     = filter_var(
52
-            $money_value,
53
-            FILTER_SANITIZE_NUMBER_FLOAT,
54
-            FILTER_FLAG_ALLOW_FRACTION
55
-        );
56
-        return $money_value;
57
-    }
22
+	/**
23
+	 * This removes all localized money formatting from the incoming value
24
+	 * Note: uses this site's currency settings for deciding what is considered a
25
+	 * "thousands separator" (usually the character "," )
26
+	 * and what is a "decimal mark" (usually the character ".")
27
+	 *
28
+	 * @param int|float|string $money_value
29
+	 * @param string           $CNT_ISO
30
+	 * @return float
31
+	 * @throws EE_Error
32
+	 * @throws InvalidArgumentException
33
+	 * @throws ReflectionException
34
+	 * @throws InvalidDataTypeException
35
+	 * @throws InvalidInterfaceException
36
+	 */
37
+	public static function strip_localized_money_formatting($money_value, $CNT_ISO = '')
38
+	{
39
+		$currency_config = EEH_Money::get_currency_config($CNT_ISO);
40
+		$money_value     = str_replace(
41
+			array(
42
+				$currency_config->thsnds,
43
+				$currency_config->dec_mrk,
44
+			),
45
+			array(
46
+				'', // remove thousands separator
47
+				'.', // convert decimal mark to what PHP expects
48
+			),
49
+			$money_value
50
+		);
51
+		$money_value     = filter_var(
52
+			$money_value,
53
+			FILTER_SANITIZE_NUMBER_FLOAT,
54
+			FILTER_FLAG_ALLOW_FRACTION
55
+		);
56
+		return $money_value;
57
+	}
58 58
 
59 59
 
60
-    /**
61
-     * This converts an incoming localized money value into a standard float item (to three decimal places)
62
-     * Only use this if you know the $money_value follows your currency configuration's
63
-     * settings. Note: this uses this site's currency settings for deciding what is considered a
64
-     * "thousands separator" (usually the character "," )
65
-     * and what is a "decimal mark" (usually the character ".")
66
-     *
67
-     * @param int|string $money_value
68
-     * @return float
69
-     * @throws EE_Error
70
-     * @throws InvalidArgumentException
71
-     * @throws ReflectionException
72
-     * @throws InvalidDataTypeException
73
-     * @throws InvalidInterfaceException
74
-     */
75
-    public static function convert_to_float_from_localized_money($money_value)
76
-    {
77
-        //float it! and round to three decimal places
78
-        return round((float) EEH_Money::strip_localized_money_formatting($money_value), 3);
79
-    }
60
+	/**
61
+	 * This converts an incoming localized money value into a standard float item (to three decimal places)
62
+	 * Only use this if you know the $money_value follows your currency configuration's
63
+	 * settings. Note: this uses this site's currency settings for deciding what is considered a
64
+	 * "thousands separator" (usually the character "," )
65
+	 * and what is a "decimal mark" (usually the character ".")
66
+	 *
67
+	 * @param int|string $money_value
68
+	 * @return float
69
+	 * @throws EE_Error
70
+	 * @throws InvalidArgumentException
71
+	 * @throws ReflectionException
72
+	 * @throws InvalidDataTypeException
73
+	 * @throws InvalidInterfaceException
74
+	 */
75
+	public static function convert_to_float_from_localized_money($money_value)
76
+	{
77
+		//float it! and round to three decimal places
78
+		return round((float) EEH_Money::strip_localized_money_formatting($money_value), 3);
79
+	}
80 80
 
81 81
 
82
-    /**
83
-     * For comparing floats. Default operator is '=', but see the $operator below for all options.
84
-     * This should be used to compare floats instead of normal '==' because floats
85
-     * are inherently imprecise, and so you can sometimes have two floats that appear to be identical
86
-     * but actually differ by 0.00000001.
87
-     *
88
-     * @see http://biostall.com/php-function-to-compare-floating-point-numbers
89
-     * @param float  $float1
90
-     * @param float  $float2
91
-     * @param string $operator The operator. Valid options are =, <=, <, >=, >, <>, eq, lt, lte, gt, gte, ne
92
-     * @return bool whether the equation is true or false
93
-     * @throws EE_Error
94
-     */
95
-    public static function compare_floats($float1, $float2, $operator = '=')
96
-    {
97
-        // Check numbers to 5 digits of precision
98
-        $epsilon = 0.00001;
99
-        $float1  = (float) $float1;
100
-        $float2  = (float) $float2;
101
-        switch ($operator) {
102
-            // equal
103
-            case '=':
104
-            case '==':
105
-            case '===':
106
-            case 'eq':
107
-                if (abs($float1 - $float2) < $epsilon) {
108
-                    return true;
109
-                }
110
-                break;
111
-            // less than
112
-            case '<':
113
-            case 'lt':
114
-                if (abs($float1 - $float2) < $epsilon) {
115
-                    return false;
116
-                }
117
-                if ($float1 < $float2) {
118
-                    return true;
119
-                }
120
-                break;
121
-            // less than or equal
122
-            case '<=':
123
-            case 'lte':
124
-                if (
125
-                    self::compare_floats($float1, $float2, '<')
126
-                    || self::compare_floats($float1, $float2)
127
-                ) {
128
-                    return true;
129
-                }
130
-                break;
131
-            // greater than
132
-            case '>':
133
-            case 'gt':
134
-                if (abs($float1 - $float2) < $epsilon) {
135
-                    return false;
136
-                }
137
-                if ($float1 > $float2) {
138
-                    return true;
139
-                }
140
-                break;
141
-            // greater than or equal
142
-            case '>=':
143
-            case 'gte':
144
-                if (
145
-                    self::compare_floats($float1, $float2, '>')
146
-                    || self::compare_floats($float1, $float2)
147
-                ) {
148
-                    return true;
149
-                }
150
-                break;
151
-            case '<>':
152
-            case '!=':
153
-            case 'ne':
154
-                if (abs($float1 - $float2) > $epsilon) {
155
-                    return true;
156
-                }
157
-                break;
158
-            default:
159
-                throw new EE_Error(
160
-                    esc_html__(
161
-                        "Unknown operator '" . $operator . "' in EEH_Money::compare_floats()",
162
-                        'event_espresso'
163
-                    )
164
-                );
165
-        }
166
-        return false;
167
-    }
82
+	/**
83
+	 * For comparing floats. Default operator is '=', but see the $operator below for all options.
84
+	 * This should be used to compare floats instead of normal '==' because floats
85
+	 * are inherently imprecise, and so you can sometimes have two floats that appear to be identical
86
+	 * but actually differ by 0.00000001.
87
+	 *
88
+	 * @see http://biostall.com/php-function-to-compare-floating-point-numbers
89
+	 * @param float  $float1
90
+	 * @param float  $float2
91
+	 * @param string $operator The operator. Valid options are =, <=, <, >=, >, <>, eq, lt, lte, gt, gte, ne
92
+	 * @return bool whether the equation is true or false
93
+	 * @throws EE_Error
94
+	 */
95
+	public static function compare_floats($float1, $float2, $operator = '=')
96
+	{
97
+		// Check numbers to 5 digits of precision
98
+		$epsilon = 0.00001;
99
+		$float1  = (float) $float1;
100
+		$float2  = (float) $float2;
101
+		switch ($operator) {
102
+			// equal
103
+			case '=':
104
+			case '==':
105
+			case '===':
106
+			case 'eq':
107
+				if (abs($float1 - $float2) < $epsilon) {
108
+					return true;
109
+				}
110
+				break;
111
+			// less than
112
+			case '<':
113
+			case 'lt':
114
+				if (abs($float1 - $float2) < $epsilon) {
115
+					return false;
116
+				}
117
+				if ($float1 < $float2) {
118
+					return true;
119
+				}
120
+				break;
121
+			// less than or equal
122
+			case '<=':
123
+			case 'lte':
124
+				if (
125
+					self::compare_floats($float1, $float2, '<')
126
+					|| self::compare_floats($float1, $float2)
127
+				) {
128
+					return true;
129
+				}
130
+				break;
131
+			// greater than
132
+			case '>':
133
+			case 'gt':
134
+				if (abs($float1 - $float2) < $epsilon) {
135
+					return false;
136
+				}
137
+				if ($float1 > $float2) {
138
+					return true;
139
+				}
140
+				break;
141
+			// greater than or equal
142
+			case '>=':
143
+			case 'gte':
144
+				if (
145
+					self::compare_floats($float1, $float2, '>')
146
+					|| self::compare_floats($float1, $float2)
147
+				) {
148
+					return true;
149
+				}
150
+				break;
151
+			case '<>':
152
+			case '!=':
153
+			case 'ne':
154
+				if (abs($float1 - $float2) > $epsilon) {
155
+					return true;
156
+				}
157
+				break;
158
+			default:
159
+				throw new EE_Error(
160
+					esc_html__(
161
+						"Unknown operator '" . $operator . "' in EEH_Money::compare_floats()",
162
+						'event_espresso'
163
+					)
164
+				);
165
+		}
166
+		return false;
167
+	}
168 168
 
169 169
 
170
-    /**
171
-     * This returns a localized format string suitable for jqPlot.
172
-     *
173
-     * @param string $CNT_ISO  If this is provided, then will attempt to get the currency settings for the country.
174
-     *                         Otherwise will use currency settings for current active country on site.
175
-     * @return string
176
-     * @throws EE_Error
177
-     * @throws InvalidArgumentException
178
-     * @throws ReflectionException
179
-     * @throws InvalidDataTypeException
180
-     * @throws InvalidInterfaceException
181
-     */
182
-    public static function get_format_for_jqplot($CNT_ISO = '')
183
-    {
184
-        //default format
185
-        $format          = 'f';
186
-        $currency_config = $currency_config = EEH_Money::get_currency_config($CNT_ISO);
187
-        //first get the decimal place and number of places
188
-        $format = "%'." . $currency_config->dec_plc . $format;
189
-        //currency symbol on right side.
190
-        $format = $currency_config->sign_b4 ? $currency_config->sign . $format : $format . $currency_config->sign;
191
-        return $format;
192
-    }
170
+	/**
171
+	 * This returns a localized format string suitable for jqPlot.
172
+	 *
173
+	 * @param string $CNT_ISO  If this is provided, then will attempt to get the currency settings for the country.
174
+	 *                         Otherwise will use currency settings for current active country on site.
175
+	 * @return string
176
+	 * @throws EE_Error
177
+	 * @throws InvalidArgumentException
178
+	 * @throws ReflectionException
179
+	 * @throws InvalidDataTypeException
180
+	 * @throws InvalidInterfaceException
181
+	 */
182
+	public static function get_format_for_jqplot($CNT_ISO = '')
183
+	{
184
+		//default format
185
+		$format          = 'f';
186
+		$currency_config = $currency_config = EEH_Money::get_currency_config($CNT_ISO);
187
+		//first get the decimal place and number of places
188
+		$format = "%'." . $currency_config->dec_plc . $format;
189
+		//currency symbol on right side.
190
+		$format = $currency_config->sign_b4 ? $currency_config->sign . $format : $format . $currency_config->sign;
191
+		return $format;
192
+	}
193 193
 
194 194
 
195
-    /**
196
-     * This returns a localized format string suitable for usage with the Google Charts API format param.
197
-     *
198
-     * @param string $CNT_ISO  If this is provided, then will attempt to get the currency settings for the country.
199
-     *                         Otherwise will use currency settings for current active country on site.
200
-     *                         Note: GoogleCharts uses ICU pattern set
201
-     *                         (@see http://icu-project.org/apiref/icu4c/classDecimalFormat.html#_details)
202
-     * @return array
203
-     * @throws EE_Error
204
-     * @throws InvalidArgumentException
205
-     * @throws ReflectionException
206
-     * @throws InvalidDataTypeException
207
-     * @throws InvalidInterfaceException
208
-     */
209
-    public static function get_format_for_google_charts($CNT_ISO = '')
210
-    {
211
-        $currency_config            = EEH_Money::get_currency_config($CNT_ISO);
212
-        $decimal_places_placeholder = str_pad('', $currency_config->dec_plc, '0');
213
-        //first get the decimal place and number of places
214
-        $format = '#,##0.' . $decimal_places_placeholder;
215
-        //currency symbol on right side.
216
-        $format          = $currency_config->sign_b4
217
-            ? $currency_config->sign . $format
218
-            : $format
219
-              . $currency_config->sign;
220
-        $formatterObject = array(
221
-            'decimalSymbol'  => $currency_config->dec_mrk,
222
-            'groupingSymbol' => $currency_config->thsnds,
223
-            'fractionDigits' => $currency_config->dec_plc,
224
-        );
225
-        if ($currency_config->sign_b4) {
226
-            $formatterObject['prefix'] = $currency_config->sign;
227
-        } else {
228
-            $formatterObject['suffix'] = $currency_config->sign;
229
-        }
230
-        return array(
231
-            'format'          => $format,
232
-            'formatterObject' => $formatterObject,
233
-        );
234
-    }
195
+	/**
196
+	 * This returns a localized format string suitable for usage with the Google Charts API format param.
197
+	 *
198
+	 * @param string $CNT_ISO  If this is provided, then will attempt to get the currency settings for the country.
199
+	 *                         Otherwise will use currency settings for current active country on site.
200
+	 *                         Note: GoogleCharts uses ICU pattern set
201
+	 *                         (@see http://icu-project.org/apiref/icu4c/classDecimalFormat.html#_details)
202
+	 * @return array
203
+	 * @throws EE_Error
204
+	 * @throws InvalidArgumentException
205
+	 * @throws ReflectionException
206
+	 * @throws InvalidDataTypeException
207
+	 * @throws InvalidInterfaceException
208
+	 */
209
+	public static function get_format_for_google_charts($CNT_ISO = '')
210
+	{
211
+		$currency_config            = EEH_Money::get_currency_config($CNT_ISO);
212
+		$decimal_places_placeholder = str_pad('', $currency_config->dec_plc, '0');
213
+		//first get the decimal place and number of places
214
+		$format = '#,##0.' . $decimal_places_placeholder;
215
+		//currency symbol on right side.
216
+		$format          = $currency_config->sign_b4
217
+			? $currency_config->sign . $format
218
+			: $format
219
+			  . $currency_config->sign;
220
+		$formatterObject = array(
221
+			'decimalSymbol'  => $currency_config->dec_mrk,
222
+			'groupingSymbol' => $currency_config->thsnds,
223
+			'fractionDigits' => $currency_config->dec_plc,
224
+		);
225
+		if ($currency_config->sign_b4) {
226
+			$formatterObject['prefix'] = $currency_config->sign;
227
+		} else {
228
+			$formatterObject['suffix'] = $currency_config->sign;
229
+		}
230
+		return array(
231
+			'format'          => $format,
232
+			'formatterObject' => $formatterObject,
233
+		);
234
+	}
235 235
 
236 236
 
237
-    /**
238
-     * @param string $CNT_ISO
239
-     * @param bool   $from_db whether to fetch currency data from the admin editable DB, or the immutable JSON file
240
-     * @return EE_Currency_Config
241
-     * @throws EE_Error
242
-     * @throws InvalidArgumentException
243
-     * @throws ReflectionException
244
-     * @throws InvalidDataTypeException
245
-     * @throws InvalidInterfaceException
246
-     */
247
-    public static function get_currency_config($CNT_ISO = '', $from_db = true)
248
-    {
249
-        //if CNT_ISO passed lets try to get currency settings for it.
250
-        $currency_config = $CNT_ISO !== ''
251
-            ? new EE_Currency_Config($CNT_ISO)
252
-            : null;
253
-        if ($from_db) {
254
-            $country = EEM_Country::instance()->get_one_by_ID($CNT_ISO);
255
-            if ($country instanceof EE_Country) {
256
-                $currency_config->setFromCountry($country);
257
-            }
258
-        }
259
-        //default currency settings for site if not set
260
-        if (! $currency_config instanceof EE_Currency_Config) {
261
-            $currency_config = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config
262
-                ? EE_Registry::instance()->CFG->currency
263
-                : new EE_Currency_Config();
264
-        }
265
-        return $currency_config;
266
-    }
237
+	/**
238
+	 * @param string $CNT_ISO
239
+	 * @param bool   $from_db whether to fetch currency data from the admin editable DB, or the immutable JSON file
240
+	 * @return EE_Currency_Config
241
+	 * @throws EE_Error
242
+	 * @throws InvalidArgumentException
243
+	 * @throws ReflectionException
244
+	 * @throws InvalidDataTypeException
245
+	 * @throws InvalidInterfaceException
246
+	 */
247
+	public static function get_currency_config($CNT_ISO = '', $from_db = true)
248
+	{
249
+		//if CNT_ISO passed lets try to get currency settings for it.
250
+		$currency_config = $CNT_ISO !== ''
251
+			? new EE_Currency_Config($CNT_ISO)
252
+			: null;
253
+		if ($from_db) {
254
+			$country = EEM_Country::instance()->get_one_by_ID($CNT_ISO);
255
+			if ($country instanceof EE_Country) {
256
+				$currency_config->setFromCountry($country);
257
+			}
258
+		}
259
+		//default currency settings for site if not set
260
+		if (! $currency_config instanceof EE_Currency_Config) {
261
+			$currency_config = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config
262
+				? EE_Registry::instance()->CFG->currency
263
+				: new EE_Currency_Config();
264
+		}
265
+		return $currency_config;
266
+	}
267 267
 
268 268
 
269
-    /**
270
-     * replacement for EEH_Template::format_currency
271
-     * This helper takes a raw float value and formats it according to the default config country currency settings, or
272
-     * the country currency settings from the supplied country ISO code
273
-     *
274
-     * @param  float   $amount       raw money value
275
-     * @param  boolean $return_raw   whether to return the formatted float value only with no currency sign or code
276
-     * @param  boolean $display_code whether to display the country code (USD). Default = TRUE
277
-     * @param string   $CNT_ISO      2 letter ISO code for a country
278
-     * @param string   $cur_code_span_class
279
-     * @param boolean  $from_db whether to fetch configuration data from the database (which a site admin can change)
280
-     *                          or from our JSON file, which admins can't change. Setting to true is usually better
281
-     *                          if the value will be displayed to a user; but if communicating with another server,
282
-     *                          setting to false will return more reliable formatting.
283
-     * @since $VID:$
284
-     * @return string        the html output for the formatted money value
285
-     * @throws EE_Error
286
-     * @throws InvalidArgumentException
287
-     * @throws ReflectionException
288
-     * @throws InvalidDataTypeException
289
-     * @throws InvalidInterfaceException
290
-     */
291
-    public static function format_currency(
292
-        $amount = null,
293
-        $return_raw = false,
294
-        $display_code = true,
295
-        $CNT_ISO = '',
296
-        $cur_code_span_class = 'currency-code',
297
-        $from_db = true
298
-    ) {
299
-        // ensure amount was received
300
-        if ($amount === null) {
301
-            $msg = esc_html__('In order to format currency, an amount needs to be passed.', 'event_espresso');
302
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
303
-            return '';
304
-        }
305
-        //ensure amount is float
306
-        $amount  = (float)filter_var(
307
-            apply_filters('FHEE__EEH_Template__format_currency__raw_amount', $amount),
308
-            FILTER_SANITIZE_NUMBER_FLOAT,
309
-            FILTER_FLAG_ALLOW_FRACTION
310
-        );
311
-        $CNT_ISO = (string) apply_filters('FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount);
312
-        // filter raw amount (allows 0.00 to be changed to "free" for example)
313
-        $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw);
314
-        // still a number or was amount converted to a string like "free" ?
315
-        if (is_float($amount_formatted)) {
316
-            // get currency config object for that country
317
-            $mny = EEH_Money::get_currency_config($CNT_ISO, $from_db);
318
-            // format float
319
-            $amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds);
320
-            // add formatting ?
321
-            if (! $return_raw) {
322
-                // add currency sign
323
-                if ($mny->sign_b4) {
324
-                    if ($amount >= 0) {
325
-                        $amount_formatted = $mny->sign . $amount_formatted;
326
-                    } else {
327
-                        $amount_formatted = '-' . $mny->sign . str_replace('-', '', $amount_formatted);
328
-                    }
329
-                } else {
330
-                    $amount_formatted .= $mny->sign;
331
-                }
332
-                // filter to allow global setting of display_code
333
-                $display_code = filter_var(
334
-                    apply_filters('FHEE__EEH_Template__format_currency__display_code', $display_code),
335
-                    FILTER_VALIDATE_BOOLEAN
336
-                );
337
-                // add currency code ?
338
-                $amount_formatted = $display_code
339
-                    ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>'
340
-                    : $amount_formatted;
341
-            }
342
-            // filter results
343
-            $amount_formatted = (string) apply_filters(
344
-                'FHEE__EEH_Template__format_currency__amount_formatted',
345
-                $amount_formatted,
346
-                $mny,
347
-                $return_raw
348
-            );
349
-        }
350
-        // clean up vars
351
-        unset($mny);
352
-        // return formatted currency amount
353
-        return $amount_formatted;
354
-    }
269
+	/**
270
+	 * replacement for EEH_Template::format_currency
271
+	 * This helper takes a raw float value and formats it according to the default config country currency settings, or
272
+	 * the country currency settings from the supplied country ISO code
273
+	 *
274
+	 * @param  float   $amount       raw money value
275
+	 * @param  boolean $return_raw   whether to return the formatted float value only with no currency sign or code
276
+	 * @param  boolean $display_code whether to display the country code (USD). Default = TRUE
277
+	 * @param string   $CNT_ISO      2 letter ISO code for a country
278
+	 * @param string   $cur_code_span_class
279
+	 * @param boolean  $from_db whether to fetch configuration data from the database (which a site admin can change)
280
+	 *                          or from our JSON file, which admins can't change. Setting to true is usually better
281
+	 *                          if the value will be displayed to a user; but if communicating with another server,
282
+	 *                          setting to false will return more reliable formatting.
283
+	 * @since $VID:$
284
+	 * @return string        the html output for the formatted money value
285
+	 * @throws EE_Error
286
+	 * @throws InvalidArgumentException
287
+	 * @throws ReflectionException
288
+	 * @throws InvalidDataTypeException
289
+	 * @throws InvalidInterfaceException
290
+	 */
291
+	public static function format_currency(
292
+		$amount = null,
293
+		$return_raw = false,
294
+		$display_code = true,
295
+		$CNT_ISO = '',
296
+		$cur_code_span_class = 'currency-code',
297
+		$from_db = true
298
+	) {
299
+		// ensure amount was received
300
+		if ($amount === null) {
301
+			$msg = esc_html__('In order to format currency, an amount needs to be passed.', 'event_espresso');
302
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
303
+			return '';
304
+		}
305
+		//ensure amount is float
306
+		$amount  = (float)filter_var(
307
+			apply_filters('FHEE__EEH_Template__format_currency__raw_amount', $amount),
308
+			FILTER_SANITIZE_NUMBER_FLOAT,
309
+			FILTER_FLAG_ALLOW_FRACTION
310
+		);
311
+		$CNT_ISO = (string) apply_filters('FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount);
312
+		// filter raw amount (allows 0.00 to be changed to "free" for example)
313
+		$amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw);
314
+		// still a number or was amount converted to a string like "free" ?
315
+		if (is_float($amount_formatted)) {
316
+			// get currency config object for that country
317
+			$mny = EEH_Money::get_currency_config($CNT_ISO, $from_db);
318
+			// format float
319
+			$amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds);
320
+			// add formatting ?
321
+			if (! $return_raw) {
322
+				// add currency sign
323
+				if ($mny->sign_b4) {
324
+					if ($amount >= 0) {
325
+						$amount_formatted = $mny->sign . $amount_formatted;
326
+					} else {
327
+						$amount_formatted = '-' . $mny->sign . str_replace('-', '', $amount_formatted);
328
+					}
329
+				} else {
330
+					$amount_formatted .= $mny->sign;
331
+				}
332
+				// filter to allow global setting of display_code
333
+				$display_code = filter_var(
334
+					apply_filters('FHEE__EEH_Template__format_currency__display_code', $display_code),
335
+					FILTER_VALIDATE_BOOLEAN
336
+				);
337
+				// add currency code ?
338
+				$amount_formatted = $display_code
339
+					? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>'
340
+					: $amount_formatted;
341
+			}
342
+			// filter results
343
+			$amount_formatted = (string) apply_filters(
344
+				'FHEE__EEH_Template__format_currency__amount_formatted',
345
+				$amount_formatted,
346
+				$mny,
347
+				$return_raw
348
+			);
349
+		}
350
+		// clean up vars
351
+		unset($mny);
352
+		// return formatted currency amount
353
+		return $amount_formatted;
354
+	}
355 355
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
             ),
49 49
             $money_value
50 50
         );
51
-        $money_value     = filter_var(
51
+        $money_value = filter_var(
52 52
             $money_value,
53 53
             FILTER_SANITIZE_NUMBER_FLOAT,
54 54
             FILTER_FLAG_ALLOW_FRACTION
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
             default:
159 159
                 throw new EE_Error(
160 160
                     esc_html__(
161
-                        "Unknown operator '" . $operator . "' in EEH_Money::compare_floats()",
161
+                        "Unknown operator '".$operator."' in EEH_Money::compare_floats()",
162 162
                         'event_espresso'
163 163
                     )
164 164
                 );
@@ -185,9 +185,9 @@  discard block
 block discarded – undo
185 185
         $format          = 'f';
186 186
         $currency_config = $currency_config = EEH_Money::get_currency_config($CNT_ISO);
187 187
         //first get the decimal place and number of places
188
-        $format = "%'." . $currency_config->dec_plc . $format;
188
+        $format = "%'.".$currency_config->dec_plc.$format;
189 189
         //currency symbol on right side.
190
-        $format = $currency_config->sign_b4 ? $currency_config->sign . $format : $format . $currency_config->sign;
190
+        $format = $currency_config->sign_b4 ? $currency_config->sign.$format : $format.$currency_config->sign;
191 191
         return $format;
192 192
     }
193 193
 
@@ -211,10 +211,10 @@  discard block
 block discarded – undo
211 211
         $currency_config            = EEH_Money::get_currency_config($CNT_ISO);
212 212
         $decimal_places_placeholder = str_pad('', $currency_config->dec_plc, '0');
213 213
         //first get the decimal place and number of places
214
-        $format = '#,##0.' . $decimal_places_placeholder;
214
+        $format = '#,##0.'.$decimal_places_placeholder;
215 215
         //currency symbol on right side.
216
-        $format          = $currency_config->sign_b4
217
-            ? $currency_config->sign . $format
216
+        $format = $currency_config->sign_b4
217
+            ? $currency_config->sign.$format
218 218
             : $format
219 219
               . $currency_config->sign;
220 220
         $formatterObject = array(
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
             }
258 258
         }
259 259
         //default currency settings for site if not set
260
-        if (! $currency_config instanceof EE_Currency_Config) {
260
+        if ( ! $currency_config instanceof EE_Currency_Config) {
261 261
             $currency_config = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config
262 262
                 ? EE_Registry::instance()->CFG->currency
263 263
                 : new EE_Currency_Config();
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
             return '';
304 304
         }
305 305
         //ensure amount is float
306
-        $amount  = (float)filter_var(
306
+        $amount = (float) filter_var(
307 307
             apply_filters('FHEE__EEH_Template__format_currency__raw_amount', $amount),
308 308
             FILTER_SANITIZE_NUMBER_FLOAT,
309 309
             FILTER_FLAG_ALLOW_FRACTION
@@ -318,13 +318,13 @@  discard block
 block discarded – undo
318 318
             // format float
319 319
             $amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds);
320 320
             // add formatting ?
321
-            if (! $return_raw) {
321
+            if ( ! $return_raw) {
322 322
                 // add currency sign
323 323
                 if ($mny->sign_b4) {
324 324
                     if ($amount >= 0) {
325
-                        $amount_formatted = $mny->sign . $amount_formatted;
325
+                        $amount_formatted = $mny->sign.$amount_formatted;
326 326
                     } else {
327
-                        $amount_formatted = '-' . $mny->sign . str_replace('-', '', $amount_formatted);
327
+                        $amount_formatted = '-'.$mny->sign.str_replace('-', '', $amount_formatted);
328 328
                     }
329 329
                 } else {
330 330
                     $amount_formatted .= $mny->sign;
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
                 );
337 337
                 // add currency code ?
338 338
                 $amount_formatted = $display_code
339
-                    ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>'
339
+                    ? $amount_formatted.' <span class="'.$cur_code_span_class.'">('.$mny->code.')</span>'
340 340
                     : $amount_formatted;
341 341
             }
342 342
             // filter results
Please login to merge, or discard this patch.
core/helpers/EEH_Template.helper.php 2 patches
Indentation   +890 added lines, -890 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 use EventEspresso\core\exceptions\InvalidInterfaceException;
5 5
 
6 6
 if (! defined('EVENT_ESPRESSO_VERSION')) {
7
-    exit('NO direct script access allowed');
7
+	exit('NO direct script access allowed');
8 8
 }
9 9
 /**
10 10
  * Event Espresso
@@ -20,35 +20,35 @@  discard block
 block discarded – undo
20 20
 
21 21
 
22 22
 if ( ! function_exists('espresso_get_template_part')) {
23
-    /**
24
-     * espresso_get_template_part
25
-     * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, and doesn't add base versions of files
26
-     * so not a very useful function at all except that it adds familiarity PLUS filtering based off of the entire template part name
27
-     *
28
-     * @param string $slug The slug name for the generic template.
29
-     * @param string $name The name of the specialised template.
30
-     * @return string        the html output for the formatted money value
31
-     */
32
-    function espresso_get_template_part($slug = null, $name = null)
33
-    {
34
-        EEH_Template::get_template_part($slug, $name);
35
-    }
23
+	/**
24
+	 * espresso_get_template_part
25
+	 * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, and doesn't add base versions of files
26
+	 * so not a very useful function at all except that it adds familiarity PLUS filtering based off of the entire template part name
27
+	 *
28
+	 * @param string $slug The slug name for the generic template.
29
+	 * @param string $name The name of the specialised template.
30
+	 * @return string        the html output for the formatted money value
31
+	 */
32
+	function espresso_get_template_part($slug = null, $name = null)
33
+	{
34
+		EEH_Template::get_template_part($slug, $name);
35
+	}
36 36
 }
37 37
 
38 38
 
39 39
 if ( ! function_exists('espresso_get_object_css_class')) {
40
-    /**
41
-     * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed
42
-     *
43
-     * @param EE_Base_Class $object the EE object the css class is being generated for
44
-     * @param  string       $prefix added to the beginning of the generated class
45
-     * @param  string       $suffix added to the end of the generated class
46
-     * @return string
47
-     */
48
-    function espresso_get_object_css_class($object = null, $prefix = '', $suffix = '')
49
-    {
50
-        return EEH_Template::get_object_css_class($object, $prefix, $suffix);
51
-    }
40
+	/**
41
+	 * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed
42
+	 *
43
+	 * @param EE_Base_Class $object the EE object the css class is being generated for
44
+	 * @param  string       $prefix added to the beginning of the generated class
45
+	 * @param  string       $suffix added to the end of the generated class
46
+	 * @return string
47
+	 */
48
+	function espresso_get_object_css_class($object = null, $prefix = '', $suffix = '')
49
+	{
50
+		return EEH_Template::get_object_css_class($object, $prefix, $suffix);
51
+	}
52 52
 }
53 53
 
54 54
 
@@ -63,610 +63,610 @@  discard block
 block discarded – undo
63 63
 class EEH_Template
64 64
 {
65 65
 
66
-    private static $_espresso_themes = array();
67
-
68
-
69
-    /**
70
-     *    is_espresso_theme - returns TRUE or FALSE on whether the currently active WP theme is an espresso theme
71
-     *
72
-     * @return boolean
73
-     */
74
-    public static function is_espresso_theme()
75
-    {
76
-        return wp_get_theme()->get('TextDomain') == 'event_espresso' ? true : false;
77
-    }
78
-
79
-    /**
80
-     *    load_espresso_theme_functions - if current theme is an espresso theme, or uses ee theme template parts, then
81
-     *    load it's functions.php file ( if not already loaded )
82
-     *
83
-     * @return void
84
-     */
85
-    public static function load_espresso_theme_functions()
86
-    {
87
-        if ( ! defined('EE_THEME_FUNCTIONS_LOADED')) {
88
-            if (is_readable(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php')) {
89
-                require_once(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php');
90
-            }
91
-        }
92
-    }
93
-
94
-
95
-    /**
96
-     *    get_espresso_themes - returns an array of Espresso Child themes located in the /templates/ directory
97
-     *
98
-     * @return array
99
-     */
100
-    public static function get_espresso_themes()
101
-    {
102
-        if (empty(EEH_Template::$_espresso_themes)) {
103
-            $espresso_themes = glob(EE_PUBLIC . '*', GLOB_ONLYDIR);
104
-            if (empty($espresso_themes)) {
105
-                return array();
106
-            }
107
-            if (($key = array_search('global_assets', $espresso_themes)) !== false) {
108
-                unset($espresso_themes[$key]);
109
-            }
110
-            EEH_Template::$_espresso_themes = array();
111
-            foreach ($espresso_themes as $espresso_theme) {
112
-                EEH_Template::$_espresso_themes[basename($espresso_theme)] = $espresso_theme;
113
-            }
114
-        }
115
-        return EEH_Template::$_espresso_themes;
116
-    }
117
-
118
-
119
-    /**
120
-     * EEH_Template::get_template_part
121
-     * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead,
122
-     * and doesn't add base versions of files so not a very useful function at all except that it adds familiarity PLUS
123
-     * filtering based off of the entire template part name
124
-     *
125
-     * @param string $slug The slug name for the generic template.
126
-     * @param string $name The name of the specialised template.
127
-     * @param array  $template_args
128
-     * @param bool   $return_string
129
-     * @return string        the html output for the formatted money value
130
-     */
131
-    public static function get_template_part(
132
-        $slug = null,
133
-        $name = null,
134
-        $template_args = array(),
135
-        $return_string = false
136
-    ) {
137
-        do_action("get_template_part_{$slug}-{$name}", $slug, $name);
138
-        $templates = array();
139
-        $name      = (string)$name;
140
-        if ($name != '') {
141
-            $templates[] = "{$slug}-{$name}.php";
142
-        }
143
-        // allow template parts to be turned off via something like: add_filter( 'FHEE__content_espresso_events_tickets_template__display_datetimes', '__return_false' );
144
-        if (apply_filters("FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", true)) {
145
-            EEH_Template::locate_template($templates, $template_args, true, $return_string);
146
-        }
147
-    }
148
-
149
-
150
-    /**
151
-     *    locate_template
152
-     *    locate a template file by looking in the following places, in the following order:
153
-     *        <server path up to>/wp-content/themes/<current active WordPress theme>/
154
-     *        <assumed full absolute server path>
155
-     *        <server path up to>/wp-content/uploads/espresso/templates/<current EE theme>/
156
-     *        <server path up to>/wp-content/uploads/espresso/templates/
157
-     *        <server path up to>/wp-content/plugins/<EE4 folder>/public/<current EE theme>/
158
-     *        <server path up to>/wp-content/plugins/<EE4 folder>/core/templates/<current EE theme>/
159
-     *        <server path up to>/wp-content/plugins/<EE4 folder>/
160
-     *    as soon as the template is found in one of these locations, it will be returned or loaded
161
-     *        Example:
162
-     *          You are using the WordPress Twenty Sixteen theme,
163
-     *        and you want to customize the "some-event.template.php" template,
164
-     *          which is located in the "/relative/path/to/" folder relative to the main EE plugin folder.
165
-     *          Assuming WP is installed on your server in the "/home/public_html/" folder,
166
-     *        EEH_Template::locate_template() will look at the following paths in order until the template is found:
167
-     *        /home/public_html/wp-content/themes/twentysixteen/some-event.template.php
168
-     *        /relative/path/to/some-event.template.php
169
-     *        /home/public_html/wp-content/uploads/espresso/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php
170
-     *        /home/public_html/wp-content/uploads/espresso/templates/relative/path/to/some-event.template.php
171
-     *        /home/public_html/wp-content/plugins/event-espresso-core-reg/public/Espresso_Arabica_2014/relative/path/to/some-event.template.php
172
-     *        /home/public_html/wp-content/plugins/event-espresso-core-reg/core/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php
173
-     *        /home/public_html/wp-content/plugins/event-espresso-core-reg/relative/path/to/some-event.template.php
174
-     *          Had you passed an absolute path to your template that was in some other location,
175
-     *        ie: "/absolute/path/to/some-event.template.php"
176
-     *          then the search would have been :
177
-     *        /home/public_html/wp-content/themes/twentysixteen/some-event.template.php
178
-     *        /absolute/path/to/some-event.template.php
179
-     *          and stopped there upon finding it in the second location
180
-     *
181
-     * @param array|string $templates       array of template file names including extension (or just a single string)
182
-     * @param  array       $template_args   an array of arguments to be extracted for use in the template
183
-     * @param  boolean     $load            whether to pass the located template path on to the
184
-     *                                      EEH_Template::display_template() method or simply return it
185
-     * @param  boolean     $return_string   whether to send output immediately to screen, or capture and return as a
186
-     *                                      string
187
-     * @param boolean      $check_if_custom If TRUE, this flags this method to return boolean for whether this will
188
-     *                                      generate a custom template or not. Used in places where you don't actually
189
-     *                                      load the template, you just want to know if there's a custom version of it.
190
-     * @return mixed
191
-     */
192
-    public static function locate_template(
193
-        $templates = array(),
194
-        $template_args = array(),
195
-        $load = true,
196
-        $return_string = true,
197
-        $check_if_custom = false
198
-    ) {
199
-        // first use WP locate_template to check for template in the current theme folder
200
-        $template_path = locate_template($templates);
201
-
202
-        if ($check_if_custom && ! empty($template_path)) {
203
-            return true;
204
-        }
205
-
206
-        // not in the theme
207
-        if (empty($template_path)) {
208
-            // not even a template to look for ?
209
-            if (empty($templates)) {
210
-                // get post_type
211
-                $post_type = EE_Registry::instance()->REQ->get('post_type');
212
-                // get array of EE Custom Post Types
213
-                $EE_CPTs = EE_Register_CPTs::get_CPTs();
214
-                // build template name based on request
215
-                if (isset($EE_CPTs[$post_type])) {
216
-                    $archive_or_single = is_archive() ? 'archive' : '';
217
-                    $archive_or_single = is_single() ? 'single' : $archive_or_single;
218
-                    $templates         = $archive_or_single . '-' . $post_type . '.php';
219
-                }
220
-            }
221
-            // currently active EE template theme
222
-            $current_theme = EE_Config::get_current_theme();
223
-
224
-            // array of paths to folders that may contain templates
225
-            $template_folder_paths = array(
226
-                // first check the /wp-content/uploads/espresso/templates/(current EE theme)/  folder for an EE theme template file
227
-                EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme,
228
-                // then in the root of the /wp-content/uploads/espresso/templates/ folder
229
-                EVENT_ESPRESSO_TEMPLATE_DIR,
230
-            );
231
-
232
-            //add core plugin folders for checking only if we're not $check_if_custom
233
-            if ( ! $check_if_custom) {
234
-                $core_paths            = array(
235
-                    // in the  /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin
236
-                    EE_PUBLIC . $current_theme,
237
-                    // in the  /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin
238
-                    EE_TEMPLATES . $current_theme,
239
-                    // or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/
240
-                    EE_PLUGIN_DIR_PATH,
241
-                );
242
-                $template_folder_paths = array_merge($template_folder_paths, $core_paths);
243
-            }
244
-
245
-            // now filter that array
246
-            $template_folder_paths = apply_filters('FHEE__EEH_Template__locate_template__template_folder_paths',
247
-                $template_folder_paths);
248
-            $templates             = is_array($templates) ? $templates : array($templates);
249
-            $template_folder_paths = is_array($template_folder_paths) ? $template_folder_paths : array($template_folder_paths);
250
-            // array to hold all possible template paths
251
-            $full_template_paths = array();
252
-
253
-            // loop through $templates
254
-            foreach ($templates as $template) {
255
-                // normalize directory separators
256
-                $template                      = EEH_File::standardise_directory_separators($template);
257
-                $file_name                     = basename($template);
258
-                $template_path_minus_file_name = substr($template, 0, (strlen($file_name) * -1));
259
-                // while looping through all template folder paths
260
-                foreach ($template_folder_paths as $template_folder_path) {
261
-                    // normalize directory separators
262
-                    $template_folder_path = EEH_File::standardise_directory_separators($template_folder_path);
263
-                    // determine if any common base path exists between the two paths
264
-                    $common_base_path = EEH_Template::_find_common_base_path(
265
-                        array($template_folder_path, $template_path_minus_file_name)
266
-                    );
267
-                    if ($common_base_path !== '') {
268
-                        // both paths have a common base, so just tack the filename onto our search path
269
-                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $file_name;
270
-                    } else {
271
-                        // no common base path, so let's just concatenate
272
-                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $template;
273
-                    }
274
-                    // build up our template locations array by adding our resolved paths
275
-                    $full_template_paths[] = $resolved_path;
276
-                }
277
-                // if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first
278
-                array_unshift($full_template_paths, $template);
279
-                // path to the directory of the current theme: /wp-content/themes/(current WP theme)/
280
-                array_unshift($full_template_paths, get_stylesheet_directory() . DS . $file_name);
281
-            }
282
-            // filter final array of full template paths
283
-            $full_template_paths = apply_filters('FHEE__EEH_Template__locate_template__full_template_paths',
284
-                $full_template_paths, $file_name);
285
-            // now loop through our final array of template location paths and check each location
286
-            foreach ((array)$full_template_paths as $full_template_path) {
287
-                if (is_readable($full_template_path)) {
288
-                    $template_path = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $full_template_path);
289
-                    break;
290
-                }
291
-            }
292
-        }
293
-
294
-        // hook that can be used to display the full template path that will be used
295
-        do_action('AHEE__EEH_Template__locate_template__full_template_path', $template_path);
296
-
297
-        // if we got it and you want to see it...
298
-        if ($template_path && $load && ! $check_if_custom) {
299
-            if ($return_string) {
300
-                return EEH_Template::display_template($template_path, $template_args, true);
301
-            } else {
302
-                EEH_Template::display_template($template_path, $template_args, false);
303
-            }
304
-        }
305
-        return $check_if_custom && ! empty($template_path) ? true : $template_path;
306
-    }
307
-
308
-
309
-    /**
310
-     * _find_common_base_path
311
-     * given two paths, this determines if there is a common base path between the two
312
-     *
313
-     * @param array $paths
314
-     * @return string
315
-     */
316
-    protected static function _find_common_base_path($paths)
317
-    {
318
-        $last_offset      = 0;
319
-        $common_base_path = '';
320
-        while (($index = strpos($paths[0], DS, $last_offset)) !== false) {
321
-            $dir_length = $index - $last_offset + 1;
322
-            $directory  = substr($paths[0], $last_offset, $dir_length);
323
-            foreach ($paths as $path) {
324
-                if (substr($path, $last_offset, $dir_length) != $directory) {
325
-                    return $common_base_path;
326
-                }
327
-            }
328
-            $common_base_path .= $directory;
329
-            $last_offset = $index + 1;
330
-        }
331
-        return substr($common_base_path, 0, -1);
332
-    }
333
-
334
-
335
-    /**
336
-     * load and display a template
337
-     *
338
-     * @param bool|string $template_path server path to the file to be loaded, including file name and extension
339
-     * @param  array      $template_args an array of arguments to be extracted for use in the template
340
-     * @param  boolean    $return_string whether to send output immediately to screen, or capture and return as a string
341
-     * @param bool        $throw_exceptions if set to true, will throw an exception if the template is either
342
-     *                                      not found or is not readable
343
-     * @return mixed string
344
-     * @throws \DomainException
345
-     */
66
+	private static $_espresso_themes = array();
67
+
68
+
69
+	/**
70
+	 *    is_espresso_theme - returns TRUE or FALSE on whether the currently active WP theme is an espresso theme
71
+	 *
72
+	 * @return boolean
73
+	 */
74
+	public static function is_espresso_theme()
75
+	{
76
+		return wp_get_theme()->get('TextDomain') == 'event_espresso' ? true : false;
77
+	}
78
+
79
+	/**
80
+	 *    load_espresso_theme_functions - if current theme is an espresso theme, or uses ee theme template parts, then
81
+	 *    load it's functions.php file ( if not already loaded )
82
+	 *
83
+	 * @return void
84
+	 */
85
+	public static function load_espresso_theme_functions()
86
+	{
87
+		if ( ! defined('EE_THEME_FUNCTIONS_LOADED')) {
88
+			if (is_readable(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php')) {
89
+				require_once(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php');
90
+			}
91
+		}
92
+	}
93
+
94
+
95
+	/**
96
+	 *    get_espresso_themes - returns an array of Espresso Child themes located in the /templates/ directory
97
+	 *
98
+	 * @return array
99
+	 */
100
+	public static function get_espresso_themes()
101
+	{
102
+		if (empty(EEH_Template::$_espresso_themes)) {
103
+			$espresso_themes = glob(EE_PUBLIC . '*', GLOB_ONLYDIR);
104
+			if (empty($espresso_themes)) {
105
+				return array();
106
+			}
107
+			if (($key = array_search('global_assets', $espresso_themes)) !== false) {
108
+				unset($espresso_themes[$key]);
109
+			}
110
+			EEH_Template::$_espresso_themes = array();
111
+			foreach ($espresso_themes as $espresso_theme) {
112
+				EEH_Template::$_espresso_themes[basename($espresso_theme)] = $espresso_theme;
113
+			}
114
+		}
115
+		return EEH_Template::$_espresso_themes;
116
+	}
117
+
118
+
119
+	/**
120
+	 * EEH_Template::get_template_part
121
+	 * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead,
122
+	 * and doesn't add base versions of files so not a very useful function at all except that it adds familiarity PLUS
123
+	 * filtering based off of the entire template part name
124
+	 *
125
+	 * @param string $slug The slug name for the generic template.
126
+	 * @param string $name The name of the specialised template.
127
+	 * @param array  $template_args
128
+	 * @param bool   $return_string
129
+	 * @return string        the html output for the formatted money value
130
+	 */
131
+	public static function get_template_part(
132
+		$slug = null,
133
+		$name = null,
134
+		$template_args = array(),
135
+		$return_string = false
136
+	) {
137
+		do_action("get_template_part_{$slug}-{$name}", $slug, $name);
138
+		$templates = array();
139
+		$name      = (string)$name;
140
+		if ($name != '') {
141
+			$templates[] = "{$slug}-{$name}.php";
142
+		}
143
+		// allow template parts to be turned off via something like: add_filter( 'FHEE__content_espresso_events_tickets_template__display_datetimes', '__return_false' );
144
+		if (apply_filters("FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", true)) {
145
+			EEH_Template::locate_template($templates, $template_args, true, $return_string);
146
+		}
147
+	}
148
+
149
+
150
+	/**
151
+	 *    locate_template
152
+	 *    locate a template file by looking in the following places, in the following order:
153
+	 *        <server path up to>/wp-content/themes/<current active WordPress theme>/
154
+	 *        <assumed full absolute server path>
155
+	 *        <server path up to>/wp-content/uploads/espresso/templates/<current EE theme>/
156
+	 *        <server path up to>/wp-content/uploads/espresso/templates/
157
+	 *        <server path up to>/wp-content/plugins/<EE4 folder>/public/<current EE theme>/
158
+	 *        <server path up to>/wp-content/plugins/<EE4 folder>/core/templates/<current EE theme>/
159
+	 *        <server path up to>/wp-content/plugins/<EE4 folder>/
160
+	 *    as soon as the template is found in one of these locations, it will be returned or loaded
161
+	 *        Example:
162
+	 *          You are using the WordPress Twenty Sixteen theme,
163
+	 *        and you want to customize the "some-event.template.php" template,
164
+	 *          which is located in the "/relative/path/to/" folder relative to the main EE plugin folder.
165
+	 *          Assuming WP is installed on your server in the "/home/public_html/" folder,
166
+	 *        EEH_Template::locate_template() will look at the following paths in order until the template is found:
167
+	 *        /home/public_html/wp-content/themes/twentysixteen/some-event.template.php
168
+	 *        /relative/path/to/some-event.template.php
169
+	 *        /home/public_html/wp-content/uploads/espresso/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php
170
+	 *        /home/public_html/wp-content/uploads/espresso/templates/relative/path/to/some-event.template.php
171
+	 *        /home/public_html/wp-content/plugins/event-espresso-core-reg/public/Espresso_Arabica_2014/relative/path/to/some-event.template.php
172
+	 *        /home/public_html/wp-content/plugins/event-espresso-core-reg/core/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php
173
+	 *        /home/public_html/wp-content/plugins/event-espresso-core-reg/relative/path/to/some-event.template.php
174
+	 *          Had you passed an absolute path to your template that was in some other location,
175
+	 *        ie: "/absolute/path/to/some-event.template.php"
176
+	 *          then the search would have been :
177
+	 *        /home/public_html/wp-content/themes/twentysixteen/some-event.template.php
178
+	 *        /absolute/path/to/some-event.template.php
179
+	 *          and stopped there upon finding it in the second location
180
+	 *
181
+	 * @param array|string $templates       array of template file names including extension (or just a single string)
182
+	 * @param  array       $template_args   an array of arguments to be extracted for use in the template
183
+	 * @param  boolean     $load            whether to pass the located template path on to the
184
+	 *                                      EEH_Template::display_template() method or simply return it
185
+	 * @param  boolean     $return_string   whether to send output immediately to screen, or capture and return as a
186
+	 *                                      string
187
+	 * @param boolean      $check_if_custom If TRUE, this flags this method to return boolean for whether this will
188
+	 *                                      generate a custom template or not. Used in places where you don't actually
189
+	 *                                      load the template, you just want to know if there's a custom version of it.
190
+	 * @return mixed
191
+	 */
192
+	public static function locate_template(
193
+		$templates = array(),
194
+		$template_args = array(),
195
+		$load = true,
196
+		$return_string = true,
197
+		$check_if_custom = false
198
+	) {
199
+		// first use WP locate_template to check for template in the current theme folder
200
+		$template_path = locate_template($templates);
201
+
202
+		if ($check_if_custom && ! empty($template_path)) {
203
+			return true;
204
+		}
205
+
206
+		// not in the theme
207
+		if (empty($template_path)) {
208
+			// not even a template to look for ?
209
+			if (empty($templates)) {
210
+				// get post_type
211
+				$post_type = EE_Registry::instance()->REQ->get('post_type');
212
+				// get array of EE Custom Post Types
213
+				$EE_CPTs = EE_Register_CPTs::get_CPTs();
214
+				// build template name based on request
215
+				if (isset($EE_CPTs[$post_type])) {
216
+					$archive_or_single = is_archive() ? 'archive' : '';
217
+					$archive_or_single = is_single() ? 'single' : $archive_or_single;
218
+					$templates         = $archive_or_single . '-' . $post_type . '.php';
219
+				}
220
+			}
221
+			// currently active EE template theme
222
+			$current_theme = EE_Config::get_current_theme();
223
+
224
+			// array of paths to folders that may contain templates
225
+			$template_folder_paths = array(
226
+				// first check the /wp-content/uploads/espresso/templates/(current EE theme)/  folder for an EE theme template file
227
+				EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme,
228
+				// then in the root of the /wp-content/uploads/espresso/templates/ folder
229
+				EVENT_ESPRESSO_TEMPLATE_DIR,
230
+			);
231
+
232
+			//add core plugin folders for checking only if we're not $check_if_custom
233
+			if ( ! $check_if_custom) {
234
+				$core_paths            = array(
235
+					// in the  /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin
236
+					EE_PUBLIC . $current_theme,
237
+					// in the  /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin
238
+					EE_TEMPLATES . $current_theme,
239
+					// or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/
240
+					EE_PLUGIN_DIR_PATH,
241
+				);
242
+				$template_folder_paths = array_merge($template_folder_paths, $core_paths);
243
+			}
244
+
245
+			// now filter that array
246
+			$template_folder_paths = apply_filters('FHEE__EEH_Template__locate_template__template_folder_paths',
247
+				$template_folder_paths);
248
+			$templates             = is_array($templates) ? $templates : array($templates);
249
+			$template_folder_paths = is_array($template_folder_paths) ? $template_folder_paths : array($template_folder_paths);
250
+			// array to hold all possible template paths
251
+			$full_template_paths = array();
252
+
253
+			// loop through $templates
254
+			foreach ($templates as $template) {
255
+				// normalize directory separators
256
+				$template                      = EEH_File::standardise_directory_separators($template);
257
+				$file_name                     = basename($template);
258
+				$template_path_minus_file_name = substr($template, 0, (strlen($file_name) * -1));
259
+				// while looping through all template folder paths
260
+				foreach ($template_folder_paths as $template_folder_path) {
261
+					// normalize directory separators
262
+					$template_folder_path = EEH_File::standardise_directory_separators($template_folder_path);
263
+					// determine if any common base path exists between the two paths
264
+					$common_base_path = EEH_Template::_find_common_base_path(
265
+						array($template_folder_path, $template_path_minus_file_name)
266
+					);
267
+					if ($common_base_path !== '') {
268
+						// both paths have a common base, so just tack the filename onto our search path
269
+						$resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $file_name;
270
+					} else {
271
+						// no common base path, so let's just concatenate
272
+						$resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $template;
273
+					}
274
+					// build up our template locations array by adding our resolved paths
275
+					$full_template_paths[] = $resolved_path;
276
+				}
277
+				// if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first
278
+				array_unshift($full_template_paths, $template);
279
+				// path to the directory of the current theme: /wp-content/themes/(current WP theme)/
280
+				array_unshift($full_template_paths, get_stylesheet_directory() . DS . $file_name);
281
+			}
282
+			// filter final array of full template paths
283
+			$full_template_paths = apply_filters('FHEE__EEH_Template__locate_template__full_template_paths',
284
+				$full_template_paths, $file_name);
285
+			// now loop through our final array of template location paths and check each location
286
+			foreach ((array)$full_template_paths as $full_template_path) {
287
+				if (is_readable($full_template_path)) {
288
+					$template_path = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $full_template_path);
289
+					break;
290
+				}
291
+			}
292
+		}
293
+
294
+		// hook that can be used to display the full template path that will be used
295
+		do_action('AHEE__EEH_Template__locate_template__full_template_path', $template_path);
296
+
297
+		// if we got it and you want to see it...
298
+		if ($template_path && $load && ! $check_if_custom) {
299
+			if ($return_string) {
300
+				return EEH_Template::display_template($template_path, $template_args, true);
301
+			} else {
302
+				EEH_Template::display_template($template_path, $template_args, false);
303
+			}
304
+		}
305
+		return $check_if_custom && ! empty($template_path) ? true : $template_path;
306
+	}
307
+
308
+
309
+	/**
310
+	 * _find_common_base_path
311
+	 * given two paths, this determines if there is a common base path between the two
312
+	 *
313
+	 * @param array $paths
314
+	 * @return string
315
+	 */
316
+	protected static function _find_common_base_path($paths)
317
+	{
318
+		$last_offset      = 0;
319
+		$common_base_path = '';
320
+		while (($index = strpos($paths[0], DS, $last_offset)) !== false) {
321
+			$dir_length = $index - $last_offset + 1;
322
+			$directory  = substr($paths[0], $last_offset, $dir_length);
323
+			foreach ($paths as $path) {
324
+				if (substr($path, $last_offset, $dir_length) != $directory) {
325
+					return $common_base_path;
326
+				}
327
+			}
328
+			$common_base_path .= $directory;
329
+			$last_offset = $index + 1;
330
+		}
331
+		return substr($common_base_path, 0, -1);
332
+	}
333
+
334
+
335
+	/**
336
+	 * load and display a template
337
+	 *
338
+	 * @param bool|string $template_path server path to the file to be loaded, including file name and extension
339
+	 * @param  array      $template_args an array of arguments to be extracted for use in the template
340
+	 * @param  boolean    $return_string whether to send output immediately to screen, or capture and return as a string
341
+	 * @param bool        $throw_exceptions if set to true, will throw an exception if the template is either
342
+	 *                                      not found or is not readable
343
+	 * @return mixed string
344
+	 * @throws \DomainException
345
+	 */
346 346
 	public static function display_template(
347
-        $template_path    = false,
348
-        $template_args    = array(),
349
-        $return_string    = false,
350
-        $throw_exceptions = false
351
-    ) {
352
-
353
-        /**
354
-         * These two filters are intended for last minute changes to templates being loaded and/or template arg
355
-         * modifications.  NOTE... modifying these things can cause breakage as most templates running through
356
-         * the display_template method are templates we DON'T want modified (usually because of js
357
-         * dependencies etc).  So unless you know what you are doing, do NOT filter templates or template args
358
-         * using this.
359
-         *
360
-         * @since 4.6.0
361
-         */
362
-        $template_path = (string) apply_filters('FHEE__EEH_Template__display_template__template_path', $template_path);
363
-        $template_args = (array) apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args);
364
-
365
-        // you gimme nuttin - YOU GET NUTTIN !!
366
-        if ( ! $template_path || ! is_readable($template_path)) {
367
-            return '';
368
-        }
369
-        // if $template_args are not in an array, then make it so
370
-        if ( ! is_array($template_args) && ! is_object($template_args)) {
371
-            $template_args = array($template_args);
372
-        }
373
-        extract( $template_args, EXTR_SKIP );
374
-        // ignore whether template is accessible ?
375
-        if ( $throw_exceptions && ! is_readable( $template_path ) ) {
376
-            throw new \DomainException(
377
-                    esc_html__(
378
-                            'Invalid, unreadable, or missing file.',
379
-                            'event_espresso'
380
-                    )
381
-            );
382
-        }
383
-
384
-
385
-        if ($return_string) {
386
-            // because we want to return a string, we are going to capture the output
387
-            ob_start();
388
-            include($template_path);
389
-            return ob_get_clean();
390
-        } else {
391
-            include($template_path);
392
-        }
393
-        return '';
394
-    }
395
-
396
-
397
-    /**
398
-     * get_object_css_class - attempts to generate a css class based on the type of EE object passed
399
-     *
400
-     * @param EE_Base_Class $object the EE object the css class is being generated for
401
-     * @param  string       $prefix added to the beginning of the generated class
402
-     * @param  string       $suffix added to the end of the generated class
403
-     * @return string
404
-     */
405
-    public static function get_object_css_class($object = null, $prefix = '', $suffix = '')
406
-    {
407
-        // in the beginning...
408
-        $prefix = ! empty($prefix) ? rtrim($prefix, '-') . '-' : '';
409
-        // da muddle
410
-        $class = '';
411
-        // the end
412
-        $suffix = ! empty($suffix) ? '-' . ltrim($suffix, '-') : '';
413
-        // is the passed object an EE object ?
414
-        if ($object instanceof EE_Base_Class) {
415
-            // grab the exact type of object
416
-            $obj_class = get_class($object);
417
-            // depending on the type of object...
418
-            switch ($obj_class) {
419
-                // no specifics just yet...
420
-                default :
421
-                    $class = strtolower(str_replace('_', '-', $obj_class));
422
-                    $class .= method_exists($obj_class, 'name') ? '-' . sanitize_title($object->name()) : '';
423
-
424
-            }
425
-        }
426
-        return $prefix . $class . $suffix;
427
-    }
428
-
429
-
430
-
431
-    /**
432
-     * EEH_Template::format_currency
433
-     * This helper takes a raw float value and formats it according to the default config country currency settings, or
434
-     * the country currency settings from the supplied country ISO code
435
-     *
436
-     * @deprecated $VID:$
437
-     * @param  float   $amount       raw money value
438
-     * @param  boolean $return_raw   whether to return the formatted float value only with no currency sign or code
439
-     * @param  boolean $display_code whether to display the country code (USD). Default = TRUE
440
-     * @param string   $CNT_ISO      2 letter ISO code for a country
441
-     * @param string   $cur_code_span_class
442
-     * @return string        the html output for the formatted money value
443
-     * @throws EE_Error
444
-     * @throws InvalidArgumentException
445
-     * @throws ReflectionException
446
-     * @throws InvalidDataTypeException
447
-     * @throws InvalidInterfaceException
448
-     */
449
-    public static function format_currency(
450
-        $amount = null,
451
-        $return_raw = false,
452
-        $display_code = true,
453
-        $CNT_ISO = '',
454
-        $cur_code_span_class = 'currency-code'
455
-    ) {
456
-        return EEH_Money::format_currency(
457
-            $amount,
458
-            $return_raw,
459
-            $display_code,
460
-            $CNT_ISO,
461
-            $cur_code_span_class
462
-        );
463
-    }
464
-
465
-
466
-    /**
467
-     * This function is used for outputting the localized label for a given status id in the schema requested (and
468
-     * possibly plural).  The intended use of this function is only for cases where wanting a label outside of a
469
-     * related status model or model object (i.e. in documentation etc.)
470
-     *
471
-     * @param  string  $status_id Status ID matching a registered status in the esp_status table.  If there is no
472
-     *                            match, then 'Unknown' will be returned.
473
-     * @param  boolean $plural    Whether to return plural or not
474
-     * @param  string  $schema    'UPPER', 'lower', or 'Sentence'
475
-     * @return string             The localized label for the status id.
476
-     */
477
-    public static function pretty_status($status_id, $plural = false, $schema = 'upper')
478
-    {
479
-        /** @type EEM_Status $EEM_Status */
480
-        $EEM_Status = EE_Registry::instance()->load_model('Status');
481
-        $status     = $EEM_Status->localized_status(array($status_id => __('unknown', 'event_espresso')), $plural,
482
-            $schema);
483
-        return $status[$status_id];
484
-    }
485
-
486
-
487
-    /**
488
-     * This helper just returns a button or link for the given parameters
489
-     *
490
-     * @param  string $url   the url for the link, note that `esc_url` will be called on it
491
-     * @param  string $label What is the label you want displayed for the button
492
-     * @param  string $class what class is used for the button (defaults to 'button-primary')
493
-     * @param string  $icon
494
-     * @param string  $title
495
-     * @return string the html output for the button
496
-     */
497
-    public static function get_button_or_link($url, $label, $class = 'button-primary', $icon = '', $title = '')
498
-    {
499
-        $icon_html = '';
500
-        if ( ! empty($icon)) {
501
-            $dashicons = preg_split("(ee-icon |dashicons )", $icon);
502
-            $dashicons = array_filter($dashicons);
503
-            $count     = count($dashicons);
504
-            $icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : '';
505
-            foreach ($dashicons as $dashicon) {
506
-                $type = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons ';
507
-                $icon_html .= '<span class="' . $type . $dashicon . '"></span>';
508
-            }
509
-            $icon_html .= $count > 1 ? '</span>' : '';
510
-        }
511
-        $label  = ! empty($icon) ? $icon_html . $label : $label;
512
-        $button = '<a id="' . sanitize_title_with_dashes($label) . '" href="' . esc_url($url) . '" class="' . $class . '" title="' . $title . '">' . $label . '</a>';
513
-        return $button;
514
-    }
515
-
516
-
517
-    /**
518
-     * This returns a generated link that will load the related help tab on admin pages.
519
-     *
520
-     * @param  string     $help_tab_id the id for the connected help tab
521
-     * @param bool|string $page        The page identifier for the page the help tab is on
522
-     * @param bool|string $action      The action (route) for the admin page the help tab is on.
523
-     * @param bool|string $icon_style  (optional) include css class for the style you want to use for the help icon.
524
-     * @param bool|string $help_text   (optional) send help text you want to use for the link if default not to be used
525
-     * @return string              generated link
526
-     */
527
-    public static function get_help_tab_link(
528
-        $help_tab_id,
529
-        $page = false,
530
-        $action = false,
531
-        $icon_style = false,
532
-        $help_text = false
533
-    ) {
534
-
535
-        if ( ! $page) {
536
-            $page = isset($_REQUEST['page']) && ! empty($_REQUEST['page']) ? sanitize_key($_REQUEST['page']) : $page;
537
-        }
538
-
539
-        if ( ! $action) {
540
-            $action = isset($_REQUEST['action']) && ! empty($_REQUEST['action']) ? sanitize_key($_REQUEST['action']) : $action;
541
-        }
542
-
543
-        $action = empty($action) ? 'default' : $action;
544
-
545
-
546
-        $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id;
547
-        $icon         = ! $icon_style ? ' dashicons-editor-help' : $icon_style;
548
-        $help_text    = ! $help_text ? '' : $help_text;
549
-        return '<a id="' . $help_tab_lnk . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22' . $icon . '" title="' . esc_attr__('Click to open the \'Help\' tab for more information about this feature.',
550
-                'event_espresso') . '" > ' . $help_text . ' </a>';
551
-    }
552
-
553
-
554
-    /**
555
-     * This helper generates the html structure for the jquery joyride plugin with the given params.
556
-     *
557
-     * @link http://zurb.com/playground/jquery-joyride-feature-tour-plugin
558
-     * @see  EE_Admin_Page->_stop_callback() for the construct expected for the $stops param.
559
-     * @param EE_Help_Tour
560
-     * @return string         html
561
-     */
562
-    public static function help_tour_stops_generator(EE_Help_Tour $tour)
563
-    {
564
-        $id    = $tour->get_slug();
565
-        $stops = $tour->get_stops();
566
-
567
-        $content = '<ol style="display:none" id="' . $id . '">';
568
-
569
-        foreach ($stops as $stop) {
570
-            $data_id    = ! empty($stop['id']) ? ' data-id="' . $stop['id'] . '"' : '';
571
-            $data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="' . $stop['class'] . '"' : '';
572
-
573
-            //if container is set to modal then let's make sure we set the options accordingly
574
-            if (empty($data_id) && empty($data_class)) {
575
-                $stop['options']['modal']  = true;
576
-                $stop['options']['expose'] = true;
577
-            }
578
-
579
-            $custom_class  = ! empty($stop['custom_class']) ? ' class="' . $stop['custom_class'] . '"' : '';
580
-            $button_text   = ! empty($stop['button_text']) ? ' data-button="' . $stop['button_text'] . '"' : '';
581
-            $inner_content = isset($stop['content']) ? $stop['content'] : '';
582
-
583
-            //options
584
-            if (isset($stop['options']) && is_array($stop['options'])) {
585
-                $options = ' data-options="';
586
-                foreach ($stop['options'] as $option => $value) {
587
-                    $options .= $option . ':' . $value . ';';
588
-                }
589
-                $options .= '"';
590
-            } else {
591
-                $options = '';
592
-            }
593
-
594
-            //let's put all together
595
-            $content .= '<li' . $data_id . $data_class . $custom_class . $button_text . $options . '>' . $inner_content . '</li>';
596
-        }
597
-
598
-        $content .= '</ol>';
599
-        return $content;
600
-    }
601
-
602
-
603
-    /**
604
-     * This is a helper method to generate a status legend for a given status array.
605
-     * Note this will only work if the incoming statuses have a key in the EEM_Status->localized_status() methods
606
-     * status_array.
607
-     *
608
-     * @param  array  $status_array  array of statuses that will make up the legend. In format:
609
-     *                               array(
610
-     *                               'status_item' => 'status_name'
611
-     *                               )
612
-     * @param  string $active_status This is used to indicate what the active status is IF that is to be highlighted in
613
-     *                               the legend.
614
-     * @throws EE_Error
615
-     * @return string               html structure for status.
616
-     */
617
-    public static function status_legend($status_array, $active_status = '')
618
-    {
619
-        if ( ! is_array($status_array)) {
620
-            throw new EE_Error(esc_html__('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!',
621
-                'event_espresso'));
622
-        }
623
-
624
-        $setup_array = array();
625
-        foreach ($status_array as $item => $status) {
626
-            $setup_array[$item] = array(
627
-                'class'  => 'ee-status-legend ee-status-legend-' . $status,
628
-                'desc'   => EEH_Template::pretty_status($status, false, 'sentence'),
629
-                'status' => $status,
630
-            );
631
-        }
632
-
633
-        $content = '<div class="ee-list-table-legend-container">' . "\n";
634
-        $content .= '<h4 class="status-legend-title">' . esc_html__('Status Legend', 'event_espresso') . '</h4>' . "\n";
635
-        $content .= '<dl class="ee-list-table-legend">' . "\n\t";
636
-        foreach ($setup_array as $item => $details) {
637
-            $active_class = $active_status == $details['status'] ? ' class="ee-is-active-status"' : '';
638
-            $content .= '<dt id="ee-legend-item-tooltip-' . $item . '"' . $active_class . '>' . "\n\t\t";
639
-            $content .= '<span class="' . $details['class'] . '"></span>' . "\n\t\t";
640
-            $content .= '<span class="ee-legend-description">' . $details['desc'] . '</span>' . "\n\t";
641
-            $content .= '</dt>' . "\n";
642
-        }
643
-        $content .= '</dl>' . "\n";
644
-        $content .= '</div>' . "\n";
645
-        return $content;
646
-    }
647
-
648
-
649
-    /**
650
-     * Gets HTML for laying out a deeply-nested array (and objects) in a format
651
-     * that's nice for presenting in the wp admin
652
-     *
653
-     * @param mixed $data
654
-     * @return string
655
-     */
656
-    public static function layout_array_as_table($data)
657
-    {
658
-        if (is_object($data) || $data instanceof __PHP_Incomplete_Class) {
659
-            $data = (array)$data;
660
-        }
661
-        ob_start();
662
-        if (is_array($data)) {
663
-            if (EEH_Array::is_associative_array($data)) {
664
-                ?>
347
+		$template_path    = false,
348
+		$template_args    = array(),
349
+		$return_string    = false,
350
+		$throw_exceptions = false
351
+	) {
352
+
353
+		/**
354
+		 * These two filters are intended for last minute changes to templates being loaded and/or template arg
355
+		 * modifications.  NOTE... modifying these things can cause breakage as most templates running through
356
+		 * the display_template method are templates we DON'T want modified (usually because of js
357
+		 * dependencies etc).  So unless you know what you are doing, do NOT filter templates or template args
358
+		 * using this.
359
+		 *
360
+		 * @since 4.6.0
361
+		 */
362
+		$template_path = (string) apply_filters('FHEE__EEH_Template__display_template__template_path', $template_path);
363
+		$template_args = (array) apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args);
364
+
365
+		// you gimme nuttin - YOU GET NUTTIN !!
366
+		if ( ! $template_path || ! is_readable($template_path)) {
367
+			return '';
368
+		}
369
+		// if $template_args are not in an array, then make it so
370
+		if ( ! is_array($template_args) && ! is_object($template_args)) {
371
+			$template_args = array($template_args);
372
+		}
373
+		extract( $template_args, EXTR_SKIP );
374
+		// ignore whether template is accessible ?
375
+		if ( $throw_exceptions && ! is_readable( $template_path ) ) {
376
+			throw new \DomainException(
377
+					esc_html__(
378
+							'Invalid, unreadable, or missing file.',
379
+							'event_espresso'
380
+					)
381
+			);
382
+		}
383
+
384
+
385
+		if ($return_string) {
386
+			// because we want to return a string, we are going to capture the output
387
+			ob_start();
388
+			include($template_path);
389
+			return ob_get_clean();
390
+		} else {
391
+			include($template_path);
392
+		}
393
+		return '';
394
+	}
395
+
396
+
397
+	/**
398
+	 * get_object_css_class - attempts to generate a css class based on the type of EE object passed
399
+	 *
400
+	 * @param EE_Base_Class $object the EE object the css class is being generated for
401
+	 * @param  string       $prefix added to the beginning of the generated class
402
+	 * @param  string       $suffix added to the end of the generated class
403
+	 * @return string
404
+	 */
405
+	public static function get_object_css_class($object = null, $prefix = '', $suffix = '')
406
+	{
407
+		// in the beginning...
408
+		$prefix = ! empty($prefix) ? rtrim($prefix, '-') . '-' : '';
409
+		// da muddle
410
+		$class = '';
411
+		// the end
412
+		$suffix = ! empty($suffix) ? '-' . ltrim($suffix, '-') : '';
413
+		// is the passed object an EE object ?
414
+		if ($object instanceof EE_Base_Class) {
415
+			// grab the exact type of object
416
+			$obj_class = get_class($object);
417
+			// depending on the type of object...
418
+			switch ($obj_class) {
419
+				// no specifics just yet...
420
+				default :
421
+					$class = strtolower(str_replace('_', '-', $obj_class));
422
+					$class .= method_exists($obj_class, 'name') ? '-' . sanitize_title($object->name()) : '';
423
+
424
+			}
425
+		}
426
+		return $prefix . $class . $suffix;
427
+	}
428
+
429
+
430
+
431
+	/**
432
+	 * EEH_Template::format_currency
433
+	 * This helper takes a raw float value and formats it according to the default config country currency settings, or
434
+	 * the country currency settings from the supplied country ISO code
435
+	 *
436
+	 * @deprecated $VID:$
437
+	 * @param  float   $amount       raw money value
438
+	 * @param  boolean $return_raw   whether to return the formatted float value only with no currency sign or code
439
+	 * @param  boolean $display_code whether to display the country code (USD). Default = TRUE
440
+	 * @param string   $CNT_ISO      2 letter ISO code for a country
441
+	 * @param string   $cur_code_span_class
442
+	 * @return string        the html output for the formatted money value
443
+	 * @throws EE_Error
444
+	 * @throws InvalidArgumentException
445
+	 * @throws ReflectionException
446
+	 * @throws InvalidDataTypeException
447
+	 * @throws InvalidInterfaceException
448
+	 */
449
+	public static function format_currency(
450
+		$amount = null,
451
+		$return_raw = false,
452
+		$display_code = true,
453
+		$CNT_ISO = '',
454
+		$cur_code_span_class = 'currency-code'
455
+	) {
456
+		return EEH_Money::format_currency(
457
+			$amount,
458
+			$return_raw,
459
+			$display_code,
460
+			$CNT_ISO,
461
+			$cur_code_span_class
462
+		);
463
+	}
464
+
465
+
466
+	/**
467
+	 * This function is used for outputting the localized label for a given status id in the schema requested (and
468
+	 * possibly plural).  The intended use of this function is only for cases where wanting a label outside of a
469
+	 * related status model or model object (i.e. in documentation etc.)
470
+	 *
471
+	 * @param  string  $status_id Status ID matching a registered status in the esp_status table.  If there is no
472
+	 *                            match, then 'Unknown' will be returned.
473
+	 * @param  boolean $plural    Whether to return plural or not
474
+	 * @param  string  $schema    'UPPER', 'lower', or 'Sentence'
475
+	 * @return string             The localized label for the status id.
476
+	 */
477
+	public static function pretty_status($status_id, $plural = false, $schema = 'upper')
478
+	{
479
+		/** @type EEM_Status $EEM_Status */
480
+		$EEM_Status = EE_Registry::instance()->load_model('Status');
481
+		$status     = $EEM_Status->localized_status(array($status_id => __('unknown', 'event_espresso')), $plural,
482
+			$schema);
483
+		return $status[$status_id];
484
+	}
485
+
486
+
487
+	/**
488
+	 * This helper just returns a button or link for the given parameters
489
+	 *
490
+	 * @param  string $url   the url for the link, note that `esc_url` will be called on it
491
+	 * @param  string $label What is the label you want displayed for the button
492
+	 * @param  string $class what class is used for the button (defaults to 'button-primary')
493
+	 * @param string  $icon
494
+	 * @param string  $title
495
+	 * @return string the html output for the button
496
+	 */
497
+	public static function get_button_or_link($url, $label, $class = 'button-primary', $icon = '', $title = '')
498
+	{
499
+		$icon_html = '';
500
+		if ( ! empty($icon)) {
501
+			$dashicons = preg_split("(ee-icon |dashicons )", $icon);
502
+			$dashicons = array_filter($dashicons);
503
+			$count     = count($dashicons);
504
+			$icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : '';
505
+			foreach ($dashicons as $dashicon) {
506
+				$type = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons ';
507
+				$icon_html .= '<span class="' . $type . $dashicon . '"></span>';
508
+			}
509
+			$icon_html .= $count > 1 ? '</span>' : '';
510
+		}
511
+		$label  = ! empty($icon) ? $icon_html . $label : $label;
512
+		$button = '<a id="' . sanitize_title_with_dashes($label) . '" href="' . esc_url($url) . '" class="' . $class . '" title="' . $title . '">' . $label . '</a>';
513
+		return $button;
514
+	}
515
+
516
+
517
+	/**
518
+	 * This returns a generated link that will load the related help tab on admin pages.
519
+	 *
520
+	 * @param  string     $help_tab_id the id for the connected help tab
521
+	 * @param bool|string $page        The page identifier for the page the help tab is on
522
+	 * @param bool|string $action      The action (route) for the admin page the help tab is on.
523
+	 * @param bool|string $icon_style  (optional) include css class for the style you want to use for the help icon.
524
+	 * @param bool|string $help_text   (optional) send help text you want to use for the link if default not to be used
525
+	 * @return string              generated link
526
+	 */
527
+	public static function get_help_tab_link(
528
+		$help_tab_id,
529
+		$page = false,
530
+		$action = false,
531
+		$icon_style = false,
532
+		$help_text = false
533
+	) {
534
+
535
+		if ( ! $page) {
536
+			$page = isset($_REQUEST['page']) && ! empty($_REQUEST['page']) ? sanitize_key($_REQUEST['page']) : $page;
537
+		}
538
+
539
+		if ( ! $action) {
540
+			$action = isset($_REQUEST['action']) && ! empty($_REQUEST['action']) ? sanitize_key($_REQUEST['action']) : $action;
541
+		}
542
+
543
+		$action = empty($action) ? 'default' : $action;
544
+
545
+
546
+		$help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id;
547
+		$icon         = ! $icon_style ? ' dashicons-editor-help' : $icon_style;
548
+		$help_text    = ! $help_text ? '' : $help_text;
549
+		return '<a id="' . $help_tab_lnk . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22' . $icon . '" title="' . esc_attr__('Click to open the \'Help\' tab for more information about this feature.',
550
+				'event_espresso') . '" > ' . $help_text . ' </a>';
551
+	}
552
+
553
+
554
+	/**
555
+	 * This helper generates the html structure for the jquery joyride plugin with the given params.
556
+	 *
557
+	 * @link http://zurb.com/playground/jquery-joyride-feature-tour-plugin
558
+	 * @see  EE_Admin_Page->_stop_callback() for the construct expected for the $stops param.
559
+	 * @param EE_Help_Tour
560
+	 * @return string         html
561
+	 */
562
+	public static function help_tour_stops_generator(EE_Help_Tour $tour)
563
+	{
564
+		$id    = $tour->get_slug();
565
+		$stops = $tour->get_stops();
566
+
567
+		$content = '<ol style="display:none" id="' . $id . '">';
568
+
569
+		foreach ($stops as $stop) {
570
+			$data_id    = ! empty($stop['id']) ? ' data-id="' . $stop['id'] . '"' : '';
571
+			$data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="' . $stop['class'] . '"' : '';
572
+
573
+			//if container is set to modal then let's make sure we set the options accordingly
574
+			if (empty($data_id) && empty($data_class)) {
575
+				$stop['options']['modal']  = true;
576
+				$stop['options']['expose'] = true;
577
+			}
578
+
579
+			$custom_class  = ! empty($stop['custom_class']) ? ' class="' . $stop['custom_class'] . '"' : '';
580
+			$button_text   = ! empty($stop['button_text']) ? ' data-button="' . $stop['button_text'] . '"' : '';
581
+			$inner_content = isset($stop['content']) ? $stop['content'] : '';
582
+
583
+			//options
584
+			if (isset($stop['options']) && is_array($stop['options'])) {
585
+				$options = ' data-options="';
586
+				foreach ($stop['options'] as $option => $value) {
587
+					$options .= $option . ':' . $value . ';';
588
+				}
589
+				$options .= '"';
590
+			} else {
591
+				$options = '';
592
+			}
593
+
594
+			//let's put all together
595
+			$content .= '<li' . $data_id . $data_class . $custom_class . $button_text . $options . '>' . $inner_content . '</li>';
596
+		}
597
+
598
+		$content .= '</ol>';
599
+		return $content;
600
+	}
601
+
602
+
603
+	/**
604
+	 * This is a helper method to generate a status legend for a given status array.
605
+	 * Note this will only work if the incoming statuses have a key in the EEM_Status->localized_status() methods
606
+	 * status_array.
607
+	 *
608
+	 * @param  array  $status_array  array of statuses that will make up the legend. In format:
609
+	 *                               array(
610
+	 *                               'status_item' => 'status_name'
611
+	 *                               )
612
+	 * @param  string $active_status This is used to indicate what the active status is IF that is to be highlighted in
613
+	 *                               the legend.
614
+	 * @throws EE_Error
615
+	 * @return string               html structure for status.
616
+	 */
617
+	public static function status_legend($status_array, $active_status = '')
618
+	{
619
+		if ( ! is_array($status_array)) {
620
+			throw new EE_Error(esc_html__('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!',
621
+				'event_espresso'));
622
+		}
623
+
624
+		$setup_array = array();
625
+		foreach ($status_array as $item => $status) {
626
+			$setup_array[$item] = array(
627
+				'class'  => 'ee-status-legend ee-status-legend-' . $status,
628
+				'desc'   => EEH_Template::pretty_status($status, false, 'sentence'),
629
+				'status' => $status,
630
+			);
631
+		}
632
+
633
+		$content = '<div class="ee-list-table-legend-container">' . "\n";
634
+		$content .= '<h4 class="status-legend-title">' . esc_html__('Status Legend', 'event_espresso') . '</h4>' . "\n";
635
+		$content .= '<dl class="ee-list-table-legend">' . "\n\t";
636
+		foreach ($setup_array as $item => $details) {
637
+			$active_class = $active_status == $details['status'] ? ' class="ee-is-active-status"' : '';
638
+			$content .= '<dt id="ee-legend-item-tooltip-' . $item . '"' . $active_class . '>' . "\n\t\t";
639
+			$content .= '<span class="' . $details['class'] . '"></span>' . "\n\t\t";
640
+			$content .= '<span class="ee-legend-description">' . $details['desc'] . '</span>' . "\n\t";
641
+			$content .= '</dt>' . "\n";
642
+		}
643
+		$content .= '</dl>' . "\n";
644
+		$content .= '</div>' . "\n";
645
+		return $content;
646
+	}
647
+
648
+
649
+	/**
650
+	 * Gets HTML for laying out a deeply-nested array (and objects) in a format
651
+	 * that's nice for presenting in the wp admin
652
+	 *
653
+	 * @param mixed $data
654
+	 * @return string
655
+	 */
656
+	public static function layout_array_as_table($data)
657
+	{
658
+		if (is_object($data) || $data instanceof __PHP_Incomplete_Class) {
659
+			$data = (array)$data;
660
+		}
661
+		ob_start();
662
+		if (is_array($data)) {
663
+			if (EEH_Array::is_associative_array($data)) {
664
+				?>
665 665
                 <table class="widefat">
666 666
                     <tbody>
667 667
                     <?php
668
-                    foreach ($data as $data_key => $data_values) {
669
-                        ?>
668
+					foreach ($data as $data_key => $data_values) {
669
+						?>
670 670
                         <tr>
671 671
                             <td>
672 672
                                 <?php echo $data_key; ?>
@@ -676,248 +676,248 @@  discard block
 block discarded – undo
676 676
                             </td>
677 677
                         </tr>
678 678
                         <?php
679
-                    } ?>
679
+					} ?>
680 680
                     </tbody>
681 681
                 </table>
682 682
                 <?php
683
-            } else {
684
-                ?>
683
+			} else {
684
+				?>
685 685
                 <ul>
686 686
                     <?php
687
-                    foreach ($data as $datum) {
688
-                        echo "<li>";
689
-                        echo self::layout_array_as_table($datum);
690
-                        echo "</li>";
691
-                    } ?>
687
+					foreach ($data as $datum) {
688
+						echo "<li>";
689
+						echo self::layout_array_as_table($datum);
690
+						echo "</li>";
691
+					} ?>
692 692
                 </ul>
693 693
                 <?php
694
-            }
695
-        } else {
696
-            //simple value
697
-            echo esc_html($data);
698
-        }
699
-        return ob_get_clean();
700
-    }
701
-
702
-
703
-    /**
704
-     * wrapper for self::get_paging_html() that simply echos the generated paging html
705
-     *
706
-     * @since 4.4.0
707
-     * @see   self:get_paging_html() for argument docs.
708
-     * @param        $total_items
709
-     * @param        $current
710
-     * @param        $per_page
711
-     * @param        $url
712
-     * @param bool   $show_num_field
713
-     * @param string $paged_arg_name
714
-     * @param array  $items_label
715
-     * @return string
716
-     */
717
-    public static function paging_html(
718
-        $total_items,
719
-        $current,
720
-        $per_page,
721
-        $url,
722
-        $show_num_field = true,
723
-        $paged_arg_name = 'paged',
724
-        $items_label = array()
725
-    ) {
726
-        echo self::get_paging_html($total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name,
727
-            $items_label);
728
-    }
729
-
730
-
731
-    /**
732
-     * A method for generating paging similar to WP_List_Table
733
-     *
734
-     * @since    4.4.0
735
-     * @see      wp-admin/includes/class-wp-list-table.php WP_List_Table::pagination()
736
-     * @param  integer $total_items     How many total items there are to page.
737
-     * @param  integer $current         What the current page is.
738
-     * @param  integer $per_page        How many items per page.
739
-     * @param  string  $url             What the base url for page links is.
740
-     * @param  boolean $show_num_field  Whether to show the input for changing page number.
741
-     * @param  string  $paged_arg_name  The name of the key for the paged query argument.
742
-     * @param  array   $items_label     An array of singular/plural values for the items label:
743
-     *                                  array(
744
-     *                                  'single' => 'item',
745
-     *                                  'plural' => 'items'
746
-     *                                  )
747
-     * @return  string
748
-     */
749
-    public static function get_paging_html(
750
-        $total_items,
751
-        $current,
752
-        $per_page,
753
-        $url,
754
-        $show_num_field = true,
755
-        $paged_arg_name = 'paged',
756
-        $items_label = array()
757
-    ) {
758
-        $page_links     = array();
759
-        $disable_first  = $disable_last = '';
760
-        $total_items    = (int)$total_items;
761
-        $per_page       = (int)$per_page;
762
-        $current        = (int)$current;
763
-        $paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name);
764
-
765
-        //filter items_label
766
-        $items_label = apply_filters(
767
-            'FHEE__EEH_Template__get_paging_html__items_label',
768
-            $items_label
769
-        );
770
-
771
-        if (empty($items_label)
772
-            || ! is_array($items_label)
773
-            || ! isset($items_label['single'])
774
-            || ! isset($items_label['plural'])
775
-        ) {
776
-            $items_label = array(
777
-                'single' => __('1 item', 'event_espresso'),
778
-                'plural' => __('%s items', 'event_espresso'),
779
-            );
780
-        } else {
781
-            $items_label = array(
782
-                'single' => '1 ' . esc_html($items_label['single']),
783
-                'plural' => '%s ' . esc_html($items_label['plural']),
784
-            );
785
-        }
786
-
787
-        $total_pages = ceil($total_items / $per_page);
788
-
789
-        if ($total_pages <= 1) {
790
-            return '';
791
-        }
792
-
793
-        $item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single'];
794
-
795
-        $output = '<span class="displaying-num">' . $item_label . '</span>';
796
-
797
-        if ($current === 1) {
798
-            $disable_first = ' disabled';
799
-        }
800
-        if ($current == $total_pages) {
801
-            $disable_last = ' disabled';
802
-        }
803
-
804
-        $page_links[] = sprintf("<a class='%s' title='%s' href='%s'>%s</a>",
805
-            'first-page' . $disable_first,
806
-            esc_attr__('Go to the first page'),
807
-            esc_url(remove_query_arg($paged_arg_name, $url)),
808
-            '&laquo;'
809
-        );
810
-
811
-        $page_links[] = sprintf(
812
-            '<a class="%s" title="%s" href="%s">%s</a>',
813
-            'prev-page' . $disable_first,
814
-            esc_attr__('Go to the previous page'),
815
-            esc_url(add_query_arg($paged_arg_name, max(1, $current - 1), $url)),
816
-            '&lsaquo;'
817
-        );
818
-
819
-        if ( ! $show_num_field) {
820
-            $html_current_page = $current;
821
-        } else {
822
-            $html_current_page = sprintf("<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />",
823
-                esc_attr__('Current page'),
824
-                $current,
825
-                strlen($total_pages)
826
-            );
827
-        }
828
-
829
-        $html_total_pages = sprintf(
830
-            '<span class="total-pages">%s</span>',
831
-            number_format_i18n($total_pages)
832
-        );
833
-        $page_links[]     = sprintf(
834
-            _x('%3$s%1$s of %2$s%4$s', 'paging'),
835
-            $html_current_page,
836
-            $html_total_pages,
837
-            '<span class="paging-input">',
838
-            '</span>'
839
-        );
840
-
841
-        $page_links[] = sprintf(
842
-            '<a class="%s" title="%s" href="%s">%s</a>',
843
-            'next-page' . $disable_last,
844
-            esc_attr__('Go to the next page'),
845
-            esc_url(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)),
846
-            '&rsaquo;'
847
-        );
848
-
849
-        $page_links[] = sprintf(
850
-            '<a class="%s" title="%s" href="%s">%s</a>',
851
-            'last-page' . $disable_last,
852
-            esc_attr__('Go to the last page'),
853
-            esc_url(add_query_arg($paged_arg_name, $total_pages, $url)),
854
-            '&raquo;'
855
-        );
856
-
857
-        $output .= "\n" . '<span class="pagination-links">' . join("\n", $page_links) . '</span>';
858
-        // set page class
859
-        if ($total_pages) {
860
-            $page_class = $total_pages < 2 ? ' one-page' : '';
861
-        } else {
862
-            $page_class = ' no-pages';
863
-        }
864
-
865
-        return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>';
866
-    }
867
-
868
-
869
-    /**
870
-     * @param string $wrap_class
871
-     * @param string $wrap_id
872
-     * @return string
873
-     */
874
-    public static function powered_by_event_espresso($wrap_class = '', $wrap_id = '', array $query_args = array())
875
-    {
876
-        $admin = is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX);
877
-        if (
878
-            ! $admin &&
879
-            ! apply_filters(
880
-                'FHEE__EEH_Template__powered_by_event_espresso__show_reg_footer',
881
-                EE_Registry::instance()->CFG->admin->show_reg_footer
882
-            )
883
-        ) {
884
-            return '';
885
-        }
886
-        $tag        = $admin ? 'span' : 'div';
887
-        $attributes = ! empty($wrap_id) ? " id=\"{$wrap_id}\"" : '';
888
-        $wrap_class = $admin ? "{$wrap_class} float-left" : $wrap_class;
889
-        $attributes .= ! empty($wrap_class)
890
-            ? " class=\"{$wrap_class} powered-by-event-espresso-credit\""
891
-            : ' class="powered-by-event-espresso-credit"';
892
-        $query_args = array_merge(
893
-            array(
894
-                'ap_id'        => EE_Registry::instance()->CFG->admin->affiliate_id(),
895
-                'utm_source'   => 'powered_by_event_espresso',
896
-                'utm_medium'   => 'link',
897
-                'utm_campaign' => 'powered_by',
898
-            ),
899
-            $query_args
900
-        );
901
-        $powered_by = apply_filters('FHEE__EEH_Template__powered_by_event_espresso_text',
902
-            $admin ? 'Event Espresso - ' . EVENT_ESPRESSO_VERSION : 'Event Espresso');
903
-        $url        = add_query_arg($query_args, 'https://eventespresso.com/');
904
-        $url        = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url);
905
-        return (string)apply_filters(
906
-            'FHEE__EEH_Template__powered_by_event_espresso__html',
907
-            sprintf(
908
-                esc_html_x(
909
-                    '%3$s%1$sOnline event registration and ticketing powered by %2$s%3$s',
910
-                    'Online event registration and ticketing powered by [link to eventespresso.com]',
911
-                    'event_espresso'
912
-                ),
913
-                "<{$tag}{$attributes}>",
914
-                "<a href=\"{$url}\" target=\"_blank\" rel=\"nofollow\">{$powered_by}</a></{$tag}>",
915
-                $admin ? '' : '<br />'
916
-            ),
917
-            $wrap_class,
918
-            $wrap_id
919
-        );
920
-    }
694
+			}
695
+		} else {
696
+			//simple value
697
+			echo esc_html($data);
698
+		}
699
+		return ob_get_clean();
700
+	}
701
+
702
+
703
+	/**
704
+	 * wrapper for self::get_paging_html() that simply echos the generated paging html
705
+	 *
706
+	 * @since 4.4.0
707
+	 * @see   self:get_paging_html() for argument docs.
708
+	 * @param        $total_items
709
+	 * @param        $current
710
+	 * @param        $per_page
711
+	 * @param        $url
712
+	 * @param bool   $show_num_field
713
+	 * @param string $paged_arg_name
714
+	 * @param array  $items_label
715
+	 * @return string
716
+	 */
717
+	public static function paging_html(
718
+		$total_items,
719
+		$current,
720
+		$per_page,
721
+		$url,
722
+		$show_num_field = true,
723
+		$paged_arg_name = 'paged',
724
+		$items_label = array()
725
+	) {
726
+		echo self::get_paging_html($total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name,
727
+			$items_label);
728
+	}
729
+
730
+
731
+	/**
732
+	 * A method for generating paging similar to WP_List_Table
733
+	 *
734
+	 * @since    4.4.0
735
+	 * @see      wp-admin/includes/class-wp-list-table.php WP_List_Table::pagination()
736
+	 * @param  integer $total_items     How many total items there are to page.
737
+	 * @param  integer $current         What the current page is.
738
+	 * @param  integer $per_page        How many items per page.
739
+	 * @param  string  $url             What the base url for page links is.
740
+	 * @param  boolean $show_num_field  Whether to show the input for changing page number.
741
+	 * @param  string  $paged_arg_name  The name of the key for the paged query argument.
742
+	 * @param  array   $items_label     An array of singular/plural values for the items label:
743
+	 *                                  array(
744
+	 *                                  'single' => 'item',
745
+	 *                                  'plural' => 'items'
746
+	 *                                  )
747
+	 * @return  string
748
+	 */
749
+	public static function get_paging_html(
750
+		$total_items,
751
+		$current,
752
+		$per_page,
753
+		$url,
754
+		$show_num_field = true,
755
+		$paged_arg_name = 'paged',
756
+		$items_label = array()
757
+	) {
758
+		$page_links     = array();
759
+		$disable_first  = $disable_last = '';
760
+		$total_items    = (int)$total_items;
761
+		$per_page       = (int)$per_page;
762
+		$current        = (int)$current;
763
+		$paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name);
764
+
765
+		//filter items_label
766
+		$items_label = apply_filters(
767
+			'FHEE__EEH_Template__get_paging_html__items_label',
768
+			$items_label
769
+		);
770
+
771
+		if (empty($items_label)
772
+			|| ! is_array($items_label)
773
+			|| ! isset($items_label['single'])
774
+			|| ! isset($items_label['plural'])
775
+		) {
776
+			$items_label = array(
777
+				'single' => __('1 item', 'event_espresso'),
778
+				'plural' => __('%s items', 'event_espresso'),
779
+			);
780
+		} else {
781
+			$items_label = array(
782
+				'single' => '1 ' . esc_html($items_label['single']),
783
+				'plural' => '%s ' . esc_html($items_label['plural']),
784
+			);
785
+		}
786
+
787
+		$total_pages = ceil($total_items / $per_page);
788
+
789
+		if ($total_pages <= 1) {
790
+			return '';
791
+		}
792
+
793
+		$item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single'];
794
+
795
+		$output = '<span class="displaying-num">' . $item_label . '</span>';
796
+
797
+		if ($current === 1) {
798
+			$disable_first = ' disabled';
799
+		}
800
+		if ($current == $total_pages) {
801
+			$disable_last = ' disabled';
802
+		}
803
+
804
+		$page_links[] = sprintf("<a class='%s' title='%s' href='%s'>%s</a>",
805
+			'first-page' . $disable_first,
806
+			esc_attr__('Go to the first page'),
807
+			esc_url(remove_query_arg($paged_arg_name, $url)),
808
+			'&laquo;'
809
+		);
810
+
811
+		$page_links[] = sprintf(
812
+			'<a class="%s" title="%s" href="%s">%s</a>',
813
+			'prev-page' . $disable_first,
814
+			esc_attr__('Go to the previous page'),
815
+			esc_url(add_query_arg($paged_arg_name, max(1, $current - 1), $url)),
816
+			'&lsaquo;'
817
+		);
818
+
819
+		if ( ! $show_num_field) {
820
+			$html_current_page = $current;
821
+		} else {
822
+			$html_current_page = sprintf("<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />",
823
+				esc_attr__('Current page'),
824
+				$current,
825
+				strlen($total_pages)
826
+			);
827
+		}
828
+
829
+		$html_total_pages = sprintf(
830
+			'<span class="total-pages">%s</span>',
831
+			number_format_i18n($total_pages)
832
+		);
833
+		$page_links[]     = sprintf(
834
+			_x('%3$s%1$s of %2$s%4$s', 'paging'),
835
+			$html_current_page,
836
+			$html_total_pages,
837
+			'<span class="paging-input">',
838
+			'</span>'
839
+		);
840
+
841
+		$page_links[] = sprintf(
842
+			'<a class="%s" title="%s" href="%s">%s</a>',
843
+			'next-page' . $disable_last,
844
+			esc_attr__('Go to the next page'),
845
+			esc_url(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)),
846
+			'&rsaquo;'
847
+		);
848
+
849
+		$page_links[] = sprintf(
850
+			'<a class="%s" title="%s" href="%s">%s</a>',
851
+			'last-page' . $disable_last,
852
+			esc_attr__('Go to the last page'),
853
+			esc_url(add_query_arg($paged_arg_name, $total_pages, $url)),
854
+			'&raquo;'
855
+		);
856
+
857
+		$output .= "\n" . '<span class="pagination-links">' . join("\n", $page_links) . '</span>';
858
+		// set page class
859
+		if ($total_pages) {
860
+			$page_class = $total_pages < 2 ? ' one-page' : '';
861
+		} else {
862
+			$page_class = ' no-pages';
863
+		}
864
+
865
+		return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>';
866
+	}
867
+
868
+
869
+	/**
870
+	 * @param string $wrap_class
871
+	 * @param string $wrap_id
872
+	 * @return string
873
+	 */
874
+	public static function powered_by_event_espresso($wrap_class = '', $wrap_id = '', array $query_args = array())
875
+	{
876
+		$admin = is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX);
877
+		if (
878
+			! $admin &&
879
+			! apply_filters(
880
+				'FHEE__EEH_Template__powered_by_event_espresso__show_reg_footer',
881
+				EE_Registry::instance()->CFG->admin->show_reg_footer
882
+			)
883
+		) {
884
+			return '';
885
+		}
886
+		$tag        = $admin ? 'span' : 'div';
887
+		$attributes = ! empty($wrap_id) ? " id=\"{$wrap_id}\"" : '';
888
+		$wrap_class = $admin ? "{$wrap_class} float-left" : $wrap_class;
889
+		$attributes .= ! empty($wrap_class)
890
+			? " class=\"{$wrap_class} powered-by-event-espresso-credit\""
891
+			: ' class="powered-by-event-espresso-credit"';
892
+		$query_args = array_merge(
893
+			array(
894
+				'ap_id'        => EE_Registry::instance()->CFG->admin->affiliate_id(),
895
+				'utm_source'   => 'powered_by_event_espresso',
896
+				'utm_medium'   => 'link',
897
+				'utm_campaign' => 'powered_by',
898
+			),
899
+			$query_args
900
+		);
901
+		$powered_by = apply_filters('FHEE__EEH_Template__powered_by_event_espresso_text',
902
+			$admin ? 'Event Espresso - ' . EVENT_ESPRESSO_VERSION : 'Event Espresso');
903
+		$url        = add_query_arg($query_args, 'https://eventespresso.com/');
904
+		$url        = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url);
905
+		return (string)apply_filters(
906
+			'FHEE__EEH_Template__powered_by_event_espresso__html',
907
+			sprintf(
908
+				esc_html_x(
909
+					'%3$s%1$sOnline event registration and ticketing powered by %2$s%3$s',
910
+					'Online event registration and ticketing powered by [link to eventespresso.com]',
911
+					'event_espresso'
912
+				),
913
+				"<{$tag}{$attributes}>",
914
+				"<a href=\"{$url}\" target=\"_blank\" rel=\"nofollow\">{$powered_by}</a></{$tag}>",
915
+				$admin ? '' : '<br />'
916
+			),
917
+			$wrap_class,
918
+			$wrap_id
919
+		);
920
+	}
921 921
 
922 922
 
923 923
 } //end EEH_Template class
@@ -926,33 +926,33 @@  discard block
 block discarded – undo
926 926
 
927 927
 
928 928
 if ( ! function_exists('espresso_pagination')) {
929
-    /**
930
-     *    espresso_pagination
931
-     *
932
-     * @access    public
933
-     * @return    void
934
-     */
935
-    function espresso_pagination()
936
-    {
937
-        global $wp_query;
938
-        $big        = 999999999; // need an unlikely integer
939
-        $pagination = paginate_links(
940
-            array(
941
-                'base'         => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
942
-                'format'       => '?paged=%#%',
943
-                'current'      => max(1, get_query_var('paged')),
944
-                'total'        => $wp_query->max_num_pages,
945
-                'show_all'     => true,
946
-                'end_size'     => 10,
947
-                'mid_size'     => 6,
948
-                'prev_next'    => true,
949
-                'prev_text'    => __('&lsaquo; PREV', 'event_espresso'),
950
-                'next_text'    => __('NEXT &rsaquo;', 'event_espresso'),
951
-                'type'         => 'plain',
952
-                'add_args'     => false,
953
-                'add_fragment' => '',
954
-            )
955
-        );
956
-        echo ! empty($pagination) ? '<div class="ee-pagination-dv ee-clear-float">' . $pagination . '</div>' : '';
957
-    }
929
+	/**
930
+	 *    espresso_pagination
931
+	 *
932
+	 * @access    public
933
+	 * @return    void
934
+	 */
935
+	function espresso_pagination()
936
+	{
937
+		global $wp_query;
938
+		$big        = 999999999; // need an unlikely integer
939
+		$pagination = paginate_links(
940
+			array(
941
+				'base'         => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
942
+				'format'       => '?paged=%#%',
943
+				'current'      => max(1, get_query_var('paged')),
944
+				'total'        => $wp_query->max_num_pages,
945
+				'show_all'     => true,
946
+				'end_size'     => 10,
947
+				'mid_size'     => 6,
948
+				'prev_next'    => true,
949
+				'prev_text'    => __('&lsaquo; PREV', 'event_espresso'),
950
+				'next_text'    => __('NEXT &rsaquo;', 'event_espresso'),
951
+				'type'         => 'plain',
952
+				'add_args'     => false,
953
+				'add_fragment' => '',
954
+			)
955
+		);
956
+		echo ! empty($pagination) ? '<div class="ee-pagination-dv ee-clear-float">' . $pagination . '</div>' : '';
957
+	}
958 958
 }
Please login to merge, or discard this patch.
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 use EventEspresso\core\exceptions\InvalidDataTypeException;
4 4
 use EventEspresso\core\exceptions\InvalidInterfaceException;
5 5
 
6
-if (! defined('EVENT_ESPRESSO_VERSION')) {
6
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
7 7
     exit('NO direct script access allowed');
8 8
 }
9 9
 /**
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
     public static function load_espresso_theme_functions()
86 86
     {
87 87
         if ( ! defined('EE_THEME_FUNCTIONS_LOADED')) {
88
-            if (is_readable(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php')) {
89
-                require_once(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php');
88
+            if (is_readable(EE_PUBLIC.EE_Config::get_current_theme().DS.'functions.php')) {
89
+                require_once(EE_PUBLIC.EE_Config::get_current_theme().DS.'functions.php');
90 90
             }
91 91
         }
92 92
     }
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
     public static function get_espresso_themes()
101 101
     {
102 102
         if (empty(EEH_Template::$_espresso_themes)) {
103
-            $espresso_themes = glob(EE_PUBLIC . '*', GLOB_ONLYDIR);
103
+            $espresso_themes = glob(EE_PUBLIC.'*', GLOB_ONLYDIR);
104 104
             if (empty($espresso_themes)) {
105 105
                 return array();
106 106
             }
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
     ) {
137 137
         do_action("get_template_part_{$slug}-{$name}", $slug, $name);
138 138
         $templates = array();
139
-        $name      = (string)$name;
139
+        $name      = (string) $name;
140 140
         if ($name != '') {
141 141
             $templates[] = "{$slug}-{$name}.php";
142 142
         }
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
                 if (isset($EE_CPTs[$post_type])) {
216 216
                     $archive_or_single = is_archive() ? 'archive' : '';
217 217
                     $archive_or_single = is_single() ? 'single' : $archive_or_single;
218
-                    $templates         = $archive_or_single . '-' . $post_type . '.php';
218
+                    $templates         = $archive_or_single.'-'.$post_type.'.php';
219 219
                 }
220 220
             }
221 221
             // currently active EE template theme
@@ -224,18 +224,18 @@  discard block
 block discarded – undo
224 224
             // array of paths to folders that may contain templates
225 225
             $template_folder_paths = array(
226 226
                 // first check the /wp-content/uploads/espresso/templates/(current EE theme)/  folder for an EE theme template file
227
-                EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme,
227
+                EVENT_ESPRESSO_TEMPLATE_DIR.$current_theme,
228 228
                 // then in the root of the /wp-content/uploads/espresso/templates/ folder
229 229
                 EVENT_ESPRESSO_TEMPLATE_DIR,
230 230
             );
231 231
 
232 232
             //add core plugin folders for checking only if we're not $check_if_custom
233 233
             if ( ! $check_if_custom) {
234
-                $core_paths            = array(
234
+                $core_paths = array(
235 235
                     // in the  /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin
236
-                    EE_PUBLIC . $current_theme,
236
+                    EE_PUBLIC.$current_theme,
237 237
                     // in the  /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin
238
-                    EE_TEMPLATES . $current_theme,
238
+                    EE_TEMPLATES.$current_theme,
239 239
                     // or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/
240 240
                     EE_PLUGIN_DIR_PATH,
241 241
                 );
@@ -266,10 +266,10 @@  discard block
 block discarded – undo
266 266
                     );
267 267
                     if ($common_base_path !== '') {
268 268
                         // both paths have a common base, so just tack the filename onto our search path
269
-                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $file_name;
269
+                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$file_name;
270 270
                     } else {
271 271
                         // no common base path, so let's just concatenate
272
-                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $template;
272
+                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$template;
273 273
                     }
274 274
                     // build up our template locations array by adding our resolved paths
275 275
                     $full_template_paths[] = $resolved_path;
@@ -277,13 +277,13 @@  discard block
 block discarded – undo
277 277
                 // if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first
278 278
                 array_unshift($full_template_paths, $template);
279 279
                 // path to the directory of the current theme: /wp-content/themes/(current WP theme)/
280
-                array_unshift($full_template_paths, get_stylesheet_directory() . DS . $file_name);
280
+                array_unshift($full_template_paths, get_stylesheet_directory().DS.$file_name);
281 281
             }
282 282
             // filter final array of full template paths
283 283
             $full_template_paths = apply_filters('FHEE__EEH_Template__locate_template__full_template_paths',
284 284
                 $full_template_paths, $file_name);
285 285
             // now loop through our final array of template location paths and check each location
286
-            foreach ((array)$full_template_paths as $full_template_path) {
286
+            foreach ((array) $full_template_paths as $full_template_path) {
287 287
                 if (is_readable($full_template_path)) {
288 288
                     $template_path = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $full_template_path);
289 289
                     break;
@@ -370,9 +370,9 @@  discard block
 block discarded – undo
370 370
         if ( ! is_array($template_args) && ! is_object($template_args)) {
371 371
             $template_args = array($template_args);
372 372
         }
373
-        extract( $template_args, EXTR_SKIP );
373
+        extract($template_args, EXTR_SKIP);
374 374
         // ignore whether template is accessible ?
375
-        if ( $throw_exceptions && ! is_readable( $template_path ) ) {
375
+        if ($throw_exceptions && ! is_readable($template_path)) {
376 376
             throw new \DomainException(
377 377
                     esc_html__(
378 378
                             'Invalid, unreadable, or missing file.',
@@ -405,11 +405,11 @@  discard block
 block discarded – undo
405 405
     public static function get_object_css_class($object = null, $prefix = '', $suffix = '')
406 406
     {
407 407
         // in the beginning...
408
-        $prefix = ! empty($prefix) ? rtrim($prefix, '-') . '-' : '';
408
+        $prefix = ! empty($prefix) ? rtrim($prefix, '-').'-' : '';
409 409
         // da muddle
410 410
         $class = '';
411 411
         // the end
412
-        $suffix = ! empty($suffix) ? '-' . ltrim($suffix, '-') : '';
412
+        $suffix = ! empty($suffix) ? '-'.ltrim($suffix, '-') : '';
413 413
         // is the passed object an EE object ?
414 414
         if ($object instanceof EE_Base_Class) {
415 415
             // grab the exact type of object
@@ -419,11 +419,11 @@  discard block
 block discarded – undo
419 419
                 // no specifics just yet...
420 420
                 default :
421 421
                     $class = strtolower(str_replace('_', '-', $obj_class));
422
-                    $class .= method_exists($obj_class, 'name') ? '-' . sanitize_title($object->name()) : '';
422
+                    $class .= method_exists($obj_class, 'name') ? '-'.sanitize_title($object->name()) : '';
423 423
 
424 424
             }
425 425
         }
426
-        return $prefix . $class . $suffix;
426
+        return $prefix.$class.$suffix;
427 427
     }
428 428
 
429 429
 
@@ -504,12 +504,12 @@  discard block
 block discarded – undo
504 504
             $icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : '';
505 505
             foreach ($dashicons as $dashicon) {
506 506
                 $type = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons ';
507
-                $icon_html .= '<span class="' . $type . $dashicon . '"></span>';
507
+                $icon_html .= '<span class="'.$type.$dashicon.'"></span>';
508 508
             }
509 509
             $icon_html .= $count > 1 ? '</span>' : '';
510 510
         }
511
-        $label  = ! empty($icon) ? $icon_html . $label : $label;
512
-        $button = '<a id="' . sanitize_title_with_dashes($label) . '" href="' . esc_url($url) . '" class="' . $class . '" title="' . $title . '">' . $label . '</a>';
511
+        $label  = ! empty($icon) ? $icon_html.$label : $label;
512
+        $button = '<a id="'.sanitize_title_with_dashes($label).'" href="'.esc_url($url).'" class="'.$class.'" title="'.$title.'">'.$label.'</a>';
513 513
         return $button;
514 514
     }
515 515
 
@@ -543,11 +543,11 @@  discard block
 block discarded – undo
543 543
         $action = empty($action) ? 'default' : $action;
544 544
 
545 545
 
546
-        $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id;
546
+        $help_tab_lnk = $page.'-'.$action.'-'.$help_tab_id;
547 547
         $icon         = ! $icon_style ? ' dashicons-editor-help' : $icon_style;
548 548
         $help_text    = ! $help_text ? '' : $help_text;
549
-        return '<a id="' . $help_tab_lnk . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22' . $icon . '" title="' . esc_attr__('Click to open the \'Help\' tab for more information about this feature.',
550
-                'event_espresso') . '" > ' . $help_text . ' </a>';
549
+        return '<a id="'.$help_tab_lnk.'" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22'.$icon.'" title="'.esc_attr__('Click to open the \'Help\' tab for more information about this feature.',
550
+                'event_espresso').'" > '.$help_text.' </a>';
551 551
     }
552 552
 
553 553
 
@@ -564,11 +564,11 @@  discard block
 block discarded – undo
564 564
         $id    = $tour->get_slug();
565 565
         $stops = $tour->get_stops();
566 566
 
567
-        $content = '<ol style="display:none" id="' . $id . '">';
567
+        $content = '<ol style="display:none" id="'.$id.'">';
568 568
 
569 569
         foreach ($stops as $stop) {
570
-            $data_id    = ! empty($stop['id']) ? ' data-id="' . $stop['id'] . '"' : '';
571
-            $data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="' . $stop['class'] . '"' : '';
570
+            $data_id    = ! empty($stop['id']) ? ' data-id="'.$stop['id'].'"' : '';
571
+            $data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="'.$stop['class'].'"' : '';
572 572
 
573 573
             //if container is set to modal then let's make sure we set the options accordingly
574 574
             if (empty($data_id) && empty($data_class)) {
@@ -576,15 +576,15 @@  discard block
 block discarded – undo
576 576
                 $stop['options']['expose'] = true;
577 577
             }
578 578
 
579
-            $custom_class  = ! empty($stop['custom_class']) ? ' class="' . $stop['custom_class'] . '"' : '';
580
-            $button_text   = ! empty($stop['button_text']) ? ' data-button="' . $stop['button_text'] . '"' : '';
579
+            $custom_class  = ! empty($stop['custom_class']) ? ' class="'.$stop['custom_class'].'"' : '';
580
+            $button_text   = ! empty($stop['button_text']) ? ' data-button="'.$stop['button_text'].'"' : '';
581 581
             $inner_content = isset($stop['content']) ? $stop['content'] : '';
582 582
 
583 583
             //options
584 584
             if (isset($stop['options']) && is_array($stop['options'])) {
585 585
                 $options = ' data-options="';
586 586
                 foreach ($stop['options'] as $option => $value) {
587
-                    $options .= $option . ':' . $value . ';';
587
+                    $options .= $option.':'.$value.';';
588 588
                 }
589 589
                 $options .= '"';
590 590
             } else {
@@ -592,7 +592,7 @@  discard block
 block discarded – undo
592 592
             }
593 593
 
594 594
             //let's put all together
595
-            $content .= '<li' . $data_id . $data_class . $custom_class . $button_text . $options . '>' . $inner_content . '</li>';
595
+            $content .= '<li'.$data_id.$data_class.$custom_class.$button_text.$options.'>'.$inner_content.'</li>';
596 596
         }
597 597
 
598 598
         $content .= '</ol>';
@@ -624,24 +624,24 @@  discard block
 block discarded – undo
624 624
         $setup_array = array();
625 625
         foreach ($status_array as $item => $status) {
626 626
             $setup_array[$item] = array(
627
-                'class'  => 'ee-status-legend ee-status-legend-' . $status,
627
+                'class'  => 'ee-status-legend ee-status-legend-'.$status,
628 628
                 'desc'   => EEH_Template::pretty_status($status, false, 'sentence'),
629 629
                 'status' => $status,
630 630
             );
631 631
         }
632 632
 
633
-        $content = '<div class="ee-list-table-legend-container">' . "\n";
634
-        $content .= '<h4 class="status-legend-title">' . esc_html__('Status Legend', 'event_espresso') . '</h4>' . "\n";
635
-        $content .= '<dl class="ee-list-table-legend">' . "\n\t";
633
+        $content = '<div class="ee-list-table-legend-container">'."\n";
634
+        $content .= '<h4 class="status-legend-title">'.esc_html__('Status Legend', 'event_espresso').'</h4>'."\n";
635
+        $content .= '<dl class="ee-list-table-legend">'."\n\t";
636 636
         foreach ($setup_array as $item => $details) {
637 637
             $active_class = $active_status == $details['status'] ? ' class="ee-is-active-status"' : '';
638
-            $content .= '<dt id="ee-legend-item-tooltip-' . $item . '"' . $active_class . '>' . "\n\t\t";
639
-            $content .= '<span class="' . $details['class'] . '"></span>' . "\n\t\t";
640
-            $content .= '<span class="ee-legend-description">' . $details['desc'] . '</span>' . "\n\t";
641
-            $content .= '</dt>' . "\n";
638
+            $content .= '<dt id="ee-legend-item-tooltip-'.$item.'"'.$active_class.'>'."\n\t\t";
639
+            $content .= '<span class="'.$details['class'].'"></span>'."\n\t\t";
640
+            $content .= '<span class="ee-legend-description">'.$details['desc'].'</span>'."\n\t";
641
+            $content .= '</dt>'."\n";
642 642
         }
643
-        $content .= '</dl>' . "\n";
644
-        $content .= '</div>' . "\n";
643
+        $content .= '</dl>'."\n";
644
+        $content .= '</div>'."\n";
645 645
         return $content;
646 646
     }
647 647
 
@@ -656,7 +656,7 @@  discard block
 block discarded – undo
656 656
     public static function layout_array_as_table($data)
657 657
     {
658 658
         if (is_object($data) || $data instanceof __PHP_Incomplete_Class) {
659
-            $data = (array)$data;
659
+            $data = (array) $data;
660 660
         }
661 661
         ob_start();
662 662
         if (is_array($data)) {
@@ -757,9 +757,9 @@  discard block
 block discarded – undo
757 757
     ) {
758 758
         $page_links     = array();
759 759
         $disable_first  = $disable_last = '';
760
-        $total_items    = (int)$total_items;
761
-        $per_page       = (int)$per_page;
762
-        $current        = (int)$current;
760
+        $total_items    = (int) $total_items;
761
+        $per_page       = (int) $per_page;
762
+        $current        = (int) $current;
763 763
         $paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name);
764 764
 
765 765
         //filter items_label
@@ -779,8 +779,8 @@  discard block
 block discarded – undo
779 779
             );
780 780
         } else {
781 781
             $items_label = array(
782
-                'single' => '1 ' . esc_html($items_label['single']),
783
-                'plural' => '%s ' . esc_html($items_label['plural']),
782
+                'single' => '1 '.esc_html($items_label['single']),
783
+                'plural' => '%s '.esc_html($items_label['plural']),
784 784
             );
785 785
         }
786 786
 
@@ -792,7 +792,7 @@  discard block
 block discarded – undo
792 792
 
793 793
         $item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single'];
794 794
 
795
-        $output = '<span class="displaying-num">' . $item_label . '</span>';
795
+        $output = '<span class="displaying-num">'.$item_label.'</span>';
796 796
 
797 797
         if ($current === 1) {
798 798
             $disable_first = ' disabled';
@@ -802,7 +802,7 @@  discard block
 block discarded – undo
802 802
         }
803 803
 
804 804
         $page_links[] = sprintf("<a class='%s' title='%s' href='%s'>%s</a>",
805
-            'first-page' . $disable_first,
805
+            'first-page'.$disable_first,
806 806
             esc_attr__('Go to the first page'),
807 807
             esc_url(remove_query_arg($paged_arg_name, $url)),
808 808
             '&laquo;'
@@ -810,7 +810,7 @@  discard block
 block discarded – undo
810 810
 
811 811
         $page_links[] = sprintf(
812 812
             '<a class="%s" title="%s" href="%s">%s</a>',
813
-            'prev-page' . $disable_first,
813
+            'prev-page'.$disable_first,
814 814
             esc_attr__('Go to the previous page'),
815 815
             esc_url(add_query_arg($paged_arg_name, max(1, $current - 1), $url)),
816 816
             '&lsaquo;'
@@ -830,7 +830,7 @@  discard block
 block discarded – undo
830 830
             '<span class="total-pages">%s</span>',
831 831
             number_format_i18n($total_pages)
832 832
         );
833
-        $page_links[]     = sprintf(
833
+        $page_links[] = sprintf(
834 834
             _x('%3$s%1$s of %2$s%4$s', 'paging'),
835 835
             $html_current_page,
836 836
             $html_total_pages,
@@ -840,7 +840,7 @@  discard block
 block discarded – undo
840 840
 
841 841
         $page_links[] = sprintf(
842 842
             '<a class="%s" title="%s" href="%s">%s</a>',
843
-            'next-page' . $disable_last,
843
+            'next-page'.$disable_last,
844 844
             esc_attr__('Go to the next page'),
845 845
             esc_url(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)),
846 846
             '&rsaquo;'
@@ -848,13 +848,13 @@  discard block
 block discarded – undo
848 848
 
849 849
         $page_links[] = sprintf(
850 850
             '<a class="%s" title="%s" href="%s">%s</a>',
851
-            'last-page' . $disable_last,
851
+            'last-page'.$disable_last,
852 852
             esc_attr__('Go to the last page'),
853 853
             esc_url(add_query_arg($paged_arg_name, $total_pages, $url)),
854 854
             '&raquo;'
855 855
         );
856 856
 
857
-        $output .= "\n" . '<span class="pagination-links">' . join("\n", $page_links) . '</span>';
857
+        $output .= "\n".'<span class="pagination-links">'.join("\n", $page_links).'</span>';
858 858
         // set page class
859 859
         if ($total_pages) {
860 860
             $page_class = $total_pages < 2 ? ' one-page' : '';
@@ -862,7 +862,7 @@  discard block
 block discarded – undo
862 862
             $page_class = ' no-pages';
863 863
         }
864 864
 
865
-        return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>';
865
+        return '<div class="tablenav"><div class="tablenav-pages'.$page_class.'">'.$output.'</div></div>';
866 866
     }
867 867
 
868 868
 
@@ -899,10 +899,10 @@  discard block
 block discarded – undo
899 899
             $query_args
900 900
         );
901 901
         $powered_by = apply_filters('FHEE__EEH_Template__powered_by_event_espresso_text',
902
-            $admin ? 'Event Espresso - ' . EVENT_ESPRESSO_VERSION : 'Event Espresso');
902
+            $admin ? 'Event Espresso - '.EVENT_ESPRESSO_VERSION : 'Event Espresso');
903 903
         $url        = add_query_arg($query_args, 'https://eventespresso.com/');
904 904
         $url        = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url);
905
-        return (string)apply_filters(
905
+        return (string) apply_filters(
906 906
             'FHEE__EEH_Template__powered_by_event_espresso__html',
907 907
             sprintf(
908 908
                 esc_html_x(
@@ -953,6 +953,6 @@  discard block
 block discarded – undo
953 953
                 'add_fragment' => '',
954 954
             )
955 955
         );
956
-        echo ! empty($pagination) ? '<div class="ee-pagination-dv ee-clear-float">' . $pagination . '</div>' : '';
956
+        echo ! empty($pagination) ? '<div class="ee-pagination-dv ee-clear-float">'.$pagination.'</div>' : '';
957 957
     }
958 958
 }
Please login to merge, or discard this patch.
core/domain/values/currency/Currency.php 1 patch
Indentation   +231 added lines, -231 removed lines patch added patch discarded remove patch
@@ -19,245 +19,245 @@
 block discarded – undo
19 19
 class Currency
20 20
 {
21 21
 
22
-    /**
23
-     * eg 'US'
24
-     *
25
-     * @var string $code
26
-     */
27
-    private $code;
28
-
29
-    /**
30
-     * @var Label $label
31
-     */
32
-    private $label;
33
-
34
-    /**
35
-     * currency sign
36
-     *
37
-     * @var string $sign
38
-     * eg '$'
39
-     */
40
-    private $sign;
41
-
42
-    /**
43
-     * Whether the currency sign should come before the amount or not
44
-     *
45
-     * @var boolean $sign_b4
46
-     */
47
-    private $sign_b4;
48
-
49
-    /**
50
-     * Space (or nothing) displayed between currency sign and amount
51
-     *
52
-     * @var string $sign_separator
53
-     */
54
-    private $sign_separator;
55
-
56
-    /**
57
-     * How many digits should come after the decimal place
58
-     * Although not theoretically true, it can effectively
59
-     * be considered that all currencies are decimal based.
60
-     * Therefore the number of decimal places can be used
61
-     * to calculate number of subunits like so:
62
-     *  subunits = pow( 10, decimal places  )
63
-     *
64
-     * @var int $decimal_places
65
-     */
66
-    private $decimal_places;
67
-
68
-    /**
69
-     * Symbol to use for decimal mark
70
-     *
71
-     * @var string $decimal_mark
72
-     * eg '.'
73
-     */
74
-    private $decimal_mark;
75
-
76
-    /**
77
-     * Symbol to use for thousands
78
-     *
79
-     * @var string $thousands
80
-     * eg ','
81
-     */
82
-    private $thousands;
83
-
84
-    /**
85
-     * The number of fractional divisions of a currency's main unit
86
-     * Can be used to determine the number of decimal places used.
87
-     * Because
88
-     *  subunits = pow( 10, decimal places )
89
-     * then
90
-     *  decimal places = log( subunits )
91
-     * except that a result of 1 means there are zero decimal places
92
-     *
93
-     * @var int
94
-     */
95
-    private $subunits;
96
-
97
-
98
-    /**
99
-     * Currency constructor.
100
-     *
101
-     * @param string $code
102
-     * @param Label  $label
103
-     * @param string $sign
104
-     * @param bool   $sign_b4
105
-     * @param int    $decimal_places the number of decimal places to use when DISPLAYING the currency
106
-     * @param string $decimal_mark
107
-     * @param string $thousands
108
-     * @param int    $subunits       number of fractional divisions of a currency's main unit
109
-     * @param string $sign_separator
110
-     */
111
-    public function __construct(
112
-        $code,
113
-        Label $label,
114
-        $sign,
115
-        $sign_b4,
116
-        $decimal_places,
117
-        $decimal_mark,
118
-        $thousands,
119
-        $subunits,
120
-        $sign_separator = ''
121
-    ) {
122
-        $this->code           = $code;
123
-        $this->label          = $label;
124
-        $this->sign           = $sign;
125
-        $this->sign_b4        = $sign_b4;
126
-        $this->decimal_places = $decimal_places;
127
-        $this->decimal_mark   = $decimal_mark;
128
-        $this->thousands      = $thousands;
129
-        $this->subunits       = $subunits;
130
-        $this->sign_separator = $sign_separator;
131
-    }
132
-
133
-
134
-
135
-    /**
136
-     * returns true if this currency is the same as the supplied currency
137
-     *
138
-     * @param Currency $other
139
-     * @return bool
140
-     */
141
-    public function equals(Currency $other)
142
-    {
143
-        return $this->code() === $other->code();
144
-    }
145
-
146
-
147
-
148
-    /**
149
-     * @return string
150
-     */
151
-    public function code()
152
-    {
153
-        return $this->code;
154
-    }
155
-
156
-
157
-
158
-    /**
159
-     * @return string
160
-     */
161
-    public function name()
162
-    {
163
-        return $this->label->singular();
164
-    }
165
-
166
-
167
-
168
-    /**
169
-     * @return string
170
-     */
171
-    public function plural()
172
-    {
173
-        return $this->label->plural();
174
-    }
175
-
176
-
177
-
178
-    /**
179
-     * @return string
180
-     */
181
-    public function sign()
182
-    {
183
-        return $this->sign;
184
-    }
185
-
186
-
187
-
188
-    /**
189
-     * @return bool
190
-     */
191
-    public function signB4()
192
-    {
193
-        return $this->sign_b4;
194
-    }
195
-
196
-
197
-    /**
198
-     * @return string
199
-     */
200
-    public function signSeparator()
201
-    {
202
-        return $this->sign_separator;
203
-    }
204
-
205
-
206
-
207
-    /**
208
-     * @return int
209
-     */
210
-    public function decimalPlaces()
211
-    {
212
-        return $this->decimal_places;
213
-    }
214
-
215
-
216
-
217
-    /**
218
-     * @return string
219
-     */
220
-    public function decimalMark()
221
-    {
222
-        return $this->decimal_mark;
223
-    }
22
+	/**
23
+	 * eg 'US'
24
+	 *
25
+	 * @var string $code
26
+	 */
27
+	private $code;
28
+
29
+	/**
30
+	 * @var Label $label
31
+	 */
32
+	private $label;
33
+
34
+	/**
35
+	 * currency sign
36
+	 *
37
+	 * @var string $sign
38
+	 * eg '$'
39
+	 */
40
+	private $sign;
41
+
42
+	/**
43
+	 * Whether the currency sign should come before the amount or not
44
+	 *
45
+	 * @var boolean $sign_b4
46
+	 */
47
+	private $sign_b4;
48
+
49
+	/**
50
+	 * Space (or nothing) displayed between currency sign and amount
51
+	 *
52
+	 * @var string $sign_separator
53
+	 */
54
+	private $sign_separator;
55
+
56
+	/**
57
+	 * How many digits should come after the decimal place
58
+	 * Although not theoretically true, it can effectively
59
+	 * be considered that all currencies are decimal based.
60
+	 * Therefore the number of decimal places can be used
61
+	 * to calculate number of subunits like so:
62
+	 *  subunits = pow( 10, decimal places  )
63
+	 *
64
+	 * @var int $decimal_places
65
+	 */
66
+	private $decimal_places;
67
+
68
+	/**
69
+	 * Symbol to use for decimal mark
70
+	 *
71
+	 * @var string $decimal_mark
72
+	 * eg '.'
73
+	 */
74
+	private $decimal_mark;
75
+
76
+	/**
77
+	 * Symbol to use for thousands
78
+	 *
79
+	 * @var string $thousands
80
+	 * eg ','
81
+	 */
82
+	private $thousands;
83
+
84
+	/**
85
+	 * The number of fractional divisions of a currency's main unit
86
+	 * Can be used to determine the number of decimal places used.
87
+	 * Because
88
+	 *  subunits = pow( 10, decimal places )
89
+	 * then
90
+	 *  decimal places = log( subunits )
91
+	 * except that a result of 1 means there are zero decimal places
92
+	 *
93
+	 * @var int
94
+	 */
95
+	private $subunits;
96
+
97
+
98
+	/**
99
+	 * Currency constructor.
100
+	 *
101
+	 * @param string $code
102
+	 * @param Label  $label
103
+	 * @param string $sign
104
+	 * @param bool   $sign_b4
105
+	 * @param int    $decimal_places the number of decimal places to use when DISPLAYING the currency
106
+	 * @param string $decimal_mark
107
+	 * @param string $thousands
108
+	 * @param int    $subunits       number of fractional divisions of a currency's main unit
109
+	 * @param string $sign_separator
110
+	 */
111
+	public function __construct(
112
+		$code,
113
+		Label $label,
114
+		$sign,
115
+		$sign_b4,
116
+		$decimal_places,
117
+		$decimal_mark,
118
+		$thousands,
119
+		$subunits,
120
+		$sign_separator = ''
121
+	) {
122
+		$this->code           = $code;
123
+		$this->label          = $label;
124
+		$this->sign           = $sign;
125
+		$this->sign_b4        = $sign_b4;
126
+		$this->decimal_places = $decimal_places;
127
+		$this->decimal_mark   = $decimal_mark;
128
+		$this->thousands      = $thousands;
129
+		$this->subunits       = $subunits;
130
+		$this->sign_separator = $sign_separator;
131
+	}
132
+
133
+
134
+
135
+	/**
136
+	 * returns true if this currency is the same as the supplied currency
137
+	 *
138
+	 * @param Currency $other
139
+	 * @return bool
140
+	 */
141
+	public function equals(Currency $other)
142
+	{
143
+		return $this->code() === $other->code();
144
+	}
145
+
146
+
147
+
148
+	/**
149
+	 * @return string
150
+	 */
151
+	public function code()
152
+	{
153
+		return $this->code;
154
+	}
155
+
156
+
157
+
158
+	/**
159
+	 * @return string
160
+	 */
161
+	public function name()
162
+	{
163
+		return $this->label->singular();
164
+	}
165
+
166
+
167
+
168
+	/**
169
+	 * @return string
170
+	 */
171
+	public function plural()
172
+	{
173
+		return $this->label->plural();
174
+	}
175
+
176
+
177
+
178
+	/**
179
+	 * @return string
180
+	 */
181
+	public function sign()
182
+	{
183
+		return $this->sign;
184
+	}
185
+
186
+
187
+
188
+	/**
189
+	 * @return bool
190
+	 */
191
+	public function signB4()
192
+	{
193
+		return $this->sign_b4;
194
+	}
195
+
196
+
197
+	/**
198
+	 * @return string
199
+	 */
200
+	public function signSeparator()
201
+	{
202
+		return $this->sign_separator;
203
+	}
204
+
205
+
206
+
207
+	/**
208
+	 * @return int
209
+	 */
210
+	public function decimalPlaces()
211
+	{
212
+		return $this->decimal_places;
213
+	}
214
+
215
+
216
+
217
+	/**
218
+	 * @return string
219
+	 */
220
+	public function decimalMark()
221
+	{
222
+		return $this->decimal_mark;
223
+	}
224 224
 
225 225
 
226 226
 
227
-    /**
228
-     * @return string
229
-     */
230
-    public function thousands()
231
-    {
232
-        return $this->thousands;
233
-    }
227
+	/**
228
+	 * @return string
229
+	 */
230
+	public function thousands()
231
+	{
232
+		return $this->thousands;
233
+	}
234 234
 
235 235
 
236
-    /**
237
-     * The number of divisions of the currency's main unit that comprises the smallest units
238
-     * ex: 1 US Dollar has 100 Pennies, so USD subunits = 100
239
-     * **WARNING**
240
-     * Some currencies, such as the Japanese Yen have no subunits,
241
-     * ie: the main unit is the smallest division
242
-     * so you need to always check that subunits is not zero
243
-     * before performing multiplication or division with it
244
-     *
245
-     * @return int
246
-     */
247
-    public function subunits()
248
-    {
249
-        return $this->subunits;
250
-    }
236
+	/**
237
+	 * The number of divisions of the currency's main unit that comprises the smallest units
238
+	 * ex: 1 US Dollar has 100 Pennies, so USD subunits = 100
239
+	 * **WARNING**
240
+	 * Some currencies, such as the Japanese Yen have no subunits,
241
+	 * ie: the main unit is the smallest division
242
+	 * so you need to always check that subunits is not zero
243
+	 * before performing multiplication or division with it
244
+	 *
245
+	 * @return int
246
+	 */
247
+	public function subunits()
248
+	{
249
+		return $this->subunits;
250
+	}
251 251
 
252 252
 
253 253
 
254
-    /**
255
-     * @return string
256
-     */
257
-    public function __toString()
258
-    {
259
-        return $this->code();
260
-    }
254
+	/**
255
+	 * @return string
256
+	 */
257
+	public function __toString()
258
+	{
259
+		return $this->code();
260
+	}
261 261
 
262 262
 
263 263
 
Please login to merge, or discard this patch.
core/services/currency/CurrencyFactory.php 2 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,6 @@
 block discarded – undo
33 33
      * CurrencyFactory constructor.
34 34
      *
35 35
      * @param CountryCurrencyDao     $country_currencies
36
-     * @param EE_Organization_Config $organization_config
37 36
      */
38 37
     public function __construct(CountryCurrencyDao $country_currencies)
39 38
     {
Please login to merge, or discard this patch.
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -23,78 +23,78 @@
 block discarded – undo
23 23
 class CurrencyFactory
24 24
 {
25 25
 
26
-    /**
27
-     * @var CountryCurrencyDao $country_currencies
28
-     */
29
-    private $country_currencies;
26
+	/**
27
+	 * @var CountryCurrencyDao $country_currencies
28
+	 */
29
+	private $country_currencies;
30 30
 
31 31
 
32
-    /**
33
-     * CurrencyFactory constructor.
34
-     *
35
-     * @param CountryCurrencyDao     $country_currencies
36
-     * @param EE_Organization_Config $organization_config
37
-     */
38
-    public function __construct(CountryCurrencyDao $country_currencies)
39
-    {
40
-        $this->country_currencies = $country_currencies;
41
-    }
32
+	/**
33
+	 * CurrencyFactory constructor.
34
+	 *
35
+	 * @param CountryCurrencyDao     $country_currencies
36
+	 * @param EE_Organization_Config $organization_config
37
+	 */
38
+	public function __construct(CountryCurrencyDao $country_currencies)
39
+	{
40
+		$this->country_currencies = $country_currencies;
41
+	}
42 42
 
43 43
 
44
-    /**
45
-     * @param array $country_currency
46
-     * @return Currency
47
-     */
48
-    private function createCurrencyFromCountryCurrency(array $country_currency)
49
-    {
50
-        return new Currency(
51
-            $country_currency['CurrencyCode'],
52
-            new Label(
53
-                $country_currency['CurrencyNameSingle'],
54
-                $country_currency['CurrencyNamePlural']
55
-            ),
56
-            $country_currency['CurrencySign'],
57
-            $country_currency['CurrencySignB4'],
58
-            $country_currency['CurrencyDecimalPlaces'],
59
-            $country_currency['CurrencyDecimalMark'],
60
-            $country_currency['CurrencyThousands'],
61
-            $country_currency['CurrencySubunits'],
62
-            $country_currency['CurrencySignSeparator']
63
-        );
64
-    }
44
+	/**
45
+	 * @param array $country_currency
46
+	 * @return Currency
47
+	 */
48
+	private function createCurrencyFromCountryCurrency(array $country_currency)
49
+	{
50
+		return new Currency(
51
+			$country_currency['CurrencyCode'],
52
+			new Label(
53
+				$country_currency['CurrencyNameSingle'],
54
+				$country_currency['CurrencyNamePlural']
55
+			),
56
+			$country_currency['CurrencySign'],
57
+			$country_currency['CurrencySignB4'],
58
+			$country_currency['CurrencyDecimalPlaces'],
59
+			$country_currency['CurrencyDecimalMark'],
60
+			$country_currency['CurrencyThousands'],
61
+			$country_currency['CurrencySubunits'],
62
+			$country_currency['CurrencySignSeparator']
63
+		);
64
+	}
65 65
 
66 66
 
67
-    /**
68
-     * returns a Currency object for the supplied country code
69
-     *
70
-     * @param string $CNT_ISO
71
-     * @return Currency
72
-     * @throws EE_Error
73
-     * @throws InvalidArgumentException
74
-     */
75
-    public function createFromCountryCode($CNT_ISO)
76
-    {
77
-        return $this->createCurrencyFromCountryCurrency(
78
-            $this->country_currencies->getCountryCurrencyByIsoCode($CNT_ISO)
79
-        );
80
-    }
67
+	/**
68
+	 * returns a Currency object for the supplied country code
69
+	 *
70
+	 * @param string $CNT_ISO
71
+	 * @return Currency
72
+	 * @throws EE_Error
73
+	 * @throws InvalidArgumentException
74
+	 */
75
+	public function createFromCountryCode($CNT_ISO)
76
+	{
77
+		return $this->createCurrencyFromCountryCurrency(
78
+			$this->country_currencies->getCountryCurrencyByIsoCode($CNT_ISO)
79
+		);
80
+	}
81 81
 
82 82
 
83
-    /**
84
-     * returns a Currency object for the supplied currency code
85
-     * PLZ NOTE: variations may exist between how different countries display the same currency,
86
-     * so it may be necessary to use CreateCurrency::fromCountryCode() to achieve the desired results
87
-     *
88
-     * @param string $code
89
-     * @return Currency
90
-     * @throws InvalidArgumentException
91
-     * @throws EE_Error
92
-     */
93
-    public function createFromCode($code)
94
-    {
95
-        return $this->createCurrencyFromCountryCurrency(
96
-            $this->country_currencies->getCountryCurrencyByCurrencyCode($code)
97
-        );
98
-    }
83
+	/**
84
+	 * returns a Currency object for the supplied currency code
85
+	 * PLZ NOTE: variations may exist between how different countries display the same currency,
86
+	 * so it may be necessary to use CreateCurrency::fromCountryCode() to achieve the desired results
87
+	 *
88
+	 * @param string $code
89
+	 * @return Currency
90
+	 * @throws InvalidArgumentException
91
+	 * @throws EE_Error
92
+	 */
93
+	public function createFromCode($code)
94
+	{
95
+		return $this->createCurrencyFromCountryCurrency(
96
+			$this->country_currencies->getCountryCurrencyByCurrencyCode($code)
97
+		);
98
+	}
99 99
 }
100 100
 // Location: CreateCurrency.php
Please login to merge, or discard this patch.