Completed
Branch BUG/error-finding-widgets-on-w... (7df8e7)
by
unknown
13:46 queued 22s
created
core/data_migration_scripts/EE_DMS_Core_4_8_0.dms.php 1 patch
Indentation   +357 added lines, -357 removed lines patch added patch discarded remove patch
@@ -17,9 +17,9 @@  discard block
 block discarded – undo
17 17
 $stages = glob(EE_CORE . 'data_migration_scripts/4_8_0_stages/*');
18 18
 $class_to_filepath = array();
19 19
 foreach ($stages as $filepath) {
20
-    $matches = array();
21
-    preg_match('~4_8_0_stages/(.*).dmsstage.php~', $filepath, $matches);
22
-    $class_to_filepath[ $matches[1] ] = $filepath;
20
+	$matches = array();
21
+	preg_match('~4_8_0_stages/(.*).dmsstage.php~', $filepath, $matches);
22
+	$class_to_filepath[ $matches[1] ] = $filepath;
23 23
 }
24 24
 // give addons a chance to autoload their stages too
25 25
 $class_to_filepath = apply_filters('FHEE__EE_DMS_4_8_0__autoloaded_stages', $class_to_filepath);
@@ -38,71 +38,71 @@  discard block
 block discarded – undo
38 38
 class EE_DMS_Core_4_8_0 extends EE_Data_Migration_Script_Base
39 39
 {
40 40
 
41
-    /**
42
-     * return EE_DMS_Core_4_8_0
43
-     *
44
-     * @param TableManager  $table_manager
45
-     * @param TableAnalysis $table_analysis
46
-     */
47
-    public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
48
-    {
49
-        $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.8.0", "event_espresso");
50
-        $this->_priority = 10;
51
-        $this->_migration_stages = array(
52
-            new EE_DMS_4_8_0_pretax_totals(),
53
-            new EE_DMS_4_8_0_event_subtotals(),
54
-        );
55
-        parent::__construct($table_manager, $table_analysis);
56
-    }
41
+	/**
42
+	 * return EE_DMS_Core_4_8_0
43
+	 *
44
+	 * @param TableManager  $table_manager
45
+	 * @param TableAnalysis $table_analysis
46
+	 */
47
+	public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
48
+	{
49
+		$this->_pretty_name = esc_html__("Data Update to Event Espresso 4.8.0", "event_espresso");
50
+		$this->_priority = 10;
51
+		$this->_migration_stages = array(
52
+			new EE_DMS_4_8_0_pretax_totals(),
53
+			new EE_DMS_4_8_0_event_subtotals(),
54
+		);
55
+		parent::__construct($table_manager, $table_analysis);
56
+	}
57 57
 
58 58
 
59 59
 
60
-    /**
61
-     * Because this is being done at basically the same time as the MER-ready branch
62
-     * of core, it's possible people might have installed MEr-ready branch first,
63
-     * and then this one, in which case we still want to perform this migration,
64
-     * even though the version might not have increased
65
-     *
66
-     * @param array $version_array
67
-     * @return bool
68
-     */
69
-    public function can_migrate_from_version($version_array)
70
-    {
71
-        $version_string = $version_array['Core'];
72
-        if (version_compare($version_string, '4.8.0', '<=') && version_compare($version_string, '4.7.0', '>=')) {
60
+	/**
61
+	 * Because this is being done at basically the same time as the MER-ready branch
62
+	 * of core, it's possible people might have installed MEr-ready branch first,
63
+	 * and then this one, in which case we still want to perform this migration,
64
+	 * even though the version might not have increased
65
+	 *
66
+	 * @param array $version_array
67
+	 * @return bool
68
+	 */
69
+	public function can_migrate_from_version($version_array)
70
+	{
71
+		$version_string = $version_array['Core'];
72
+		if (version_compare($version_string, '4.8.0', '<=') && version_compare($version_string, '4.7.0', '>=')) {
73 73
 //          echo "$version_string can be migrated from";
74
-            return true;
75
-        } elseif (! $version_string) {
74
+			return true;
75
+		} elseif (! $version_string) {
76 76
 //          echo "no version string provided: $version_string";
77
-            // no version string provided... this must be pre 4.3
78
-            return false;// changed mind. dont want people thinking they should migrate yet because they cant
79
-        } else {
77
+			// no version string provided... this must be pre 4.3
78
+			return false;// changed mind. dont want people thinking they should migrate yet because they cant
79
+		} else {
80 80
 //          echo "$version_string doesnt apply";
81
-            return false;
82
-        }
83
-    }
81
+			return false;
82
+		}
83
+	}
84 84
 
85 85
 
86 86
 
87
-    /**
88
-     * @return bool
89
-     */
90
-    public function schema_changes_before_migration()
91
-    {
92
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
93
-        $now_in_mysql = current_time('mysql', true);
94
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
95
-        $table_name = 'esp_answer';
96
-        $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
87
+	/**
88
+	 * @return bool
89
+	 */
90
+	public function schema_changes_before_migration()
91
+	{
92
+		require_once(EE_HELPERS . 'EEH_Activation.helper.php');
93
+		$now_in_mysql = current_time('mysql', true);
94
+		require_once(EE_HELPERS . 'EEH_Activation.helper.php');
95
+		$table_name = 'esp_answer';
96
+		$sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
97 97
 					REG_ID int(10) unsigned NOT NULL,
98 98
 					QST_ID int(10) unsigned NOT NULL,
99 99
 					ANS_value text NOT NULL,
100 100
 					PRIMARY KEY  (ANS_ID),
101 101
 					KEY REG_ID (REG_ID),
102 102
 					KEY QST_ID (QST_ID)";
103
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
104
-        $table_name = 'esp_attendee_meta';
105
-        $sql = "ATTM_ID int(10) unsigned NOT	NULL AUTO_INCREMENT,
103
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
104
+		$table_name = 'esp_attendee_meta';
105
+		$sql = "ATTM_ID int(10) unsigned NOT	NULL AUTO_INCREMENT,
106 106
 						ATT_ID bigint(20) unsigned NOT NULL,
107 107
 						ATT_fname varchar(45) NOT NULL,
108 108
 						ATT_lname varchar(45) NOT	NULL,
@@ -117,9 +117,9 @@  discard block
 block discarded – undo
117 117
 							PRIMARY KEY  (ATTM_ID),
118 118
 								KEY ATT_ID (ATT_ID),
119 119
 								KEY ATT_email (ATT_email(191))";
120
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
121
-        $table_name = 'esp_country';
122
-        $sql = "CNT_ISO varchar(2) collate utf8_bin NOT NULL,
120
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
121
+		$table_name = 'esp_country';
122
+		$sql = "CNT_ISO varchar(2) collate utf8_bin NOT NULL,
123 123
 					  CNT_ISO3 varchar(3) collate utf8_bin NOT NULL,
124 124
 					  RGN_ID tinyint(3) unsigned DEFAULT NULL,
125 125
 					  CNT_name varchar(45) collate utf8_bin NOT NULL,
@@ -135,25 +135,25 @@  discard block
 block discarded – undo
135 135
 					  CNT_is_EU tinyint(1) DEFAULT '0',
136 136
 					  CNT_active tinyint(1) DEFAULT '0',
137 137
 					  PRIMARY KEY  (CNT_ISO)";
138
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
139
-        $table_name = 'esp_currency';
140
-        $sql = "CUR_code varchar(6) collate utf8_bin NOT NULL,
138
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
139
+		$table_name = 'esp_currency';
140
+		$sql = "CUR_code varchar(6) collate utf8_bin NOT NULL,
141 141
 				CUR_single varchar(45) collate utf8_bin DEFAULT 'dollar',
142 142
 				CUR_plural varchar(45) collate utf8_bin DEFAULT 'dollars',
143 143
 				CUR_sign varchar(45) collate utf8_bin DEFAULT '$',
144 144
 				CUR_dec_plc varchar(1) collate utf8_bin NOT NULL DEFAULT '2',
145 145
 				CUR_active tinyint(1) DEFAULT '0',
146 146
 				PRIMARY KEY  (CUR_code)";
147
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
148
-        $table_name = 'esp_currency_payment_method';
149
-        $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT,
147
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
148
+		$table_name = 'esp_currency_payment_method';
149
+		$sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT,
150 150
 				CUR_code varchar(6) collate utf8_bin NOT NULL,
151 151
 				PMD_ID int(11) NOT NULL,
152 152
 				PRIMARY KEY  (CPM_ID),
153 153
 				KEY PMD_ID (PMD_ID)";
154
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
155
-        $table_name = 'esp_datetime';
156
-        $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
154
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
155
+		$table_name = 'esp_datetime';
156
+		$sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
157 157
 				  EVT_ID bigint(20) unsigned NOT NULL,
158 158
 				  DTT_name varchar(255) NOT NULL DEFAULT '',
159 159
 				  DTT_description text NOT NULL,
@@ -169,9 +169,9 @@  discard block
 block discarded – undo
169 169
 						KEY DTT_EVT_start (DTT_EVT_start),
170 170
 						KEY EVT_ID (EVT_ID),
171 171
 						KEY DTT_is_primary (DTT_is_primary)";
172
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
173
-        $table_name = 'esp_event_meta';
174
-        $sql = "
172
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
173
+		$table_name = 'esp_event_meta';
174
+		$sql = "
175 175
 			EVTM_ID int(10) NOT NULL AUTO_INCREMENT,
176 176
 			EVT_ID bigint(20) unsigned NOT NULL,
177 177
 			EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1,
@@ -187,34 +187,34 @@  discard block
 block discarded – undo
187 187
 			EVT_donations tinyint(1) NULL,
188 188
 			PRIMARY KEY  (EVTM_ID),
189 189
 			KEY EVT_ID (EVT_ID)";
190
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
191
-        $table_name = 'esp_event_question_group';
192
-        $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
190
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
191
+		$table_name = 'esp_event_question_group';
192
+		$sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
193 193
 					EVT_ID bigint(20) unsigned NOT NULL,
194 194
 					QSG_ID int(10) unsigned NOT NULL,
195 195
 					EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
196 196
 					PRIMARY KEY  (EQG_ID),
197 197
 					KEY EVT_ID (EVT_ID),
198 198
 					KEY QSG_ID (QSG_ID)";
199
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
200
-        $table_name = 'esp_event_venue';
201
-        $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
199
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
200
+		$table_name = 'esp_event_venue';
201
+		$sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
202 202
 				EVT_ID bigint(20) unsigned NOT NULL,
203 203
 				VNU_ID bigint(20) unsigned NOT NULL,
204 204
 				EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
205 205
 				PRIMARY KEY  (EVV_ID)";
206
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
207
-        $table_name = 'esp_extra_meta';
208
-        $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
206
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
207
+		$table_name = 'esp_extra_meta';
208
+		$sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
209 209
 				OBJ_ID int(11) DEFAULT NULL,
210 210
 				EXM_type varchar(45) DEFAULT NULL,
211 211
 				EXM_key varchar(45) DEFAULT NULL,
212 212
 				EXM_value text,
213 213
 				PRIMARY KEY  (EXM_ID),
214 214
 				KEY EXM_type (EXM_type,OBJ_ID,EXM_key)";
215
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
216
-        $table_name = 'esp_extra_join';
217
-        $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT,
215
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
216
+		$table_name = 'esp_extra_join';
217
+		$sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT,
218 218
 				EXJ_first_model_id varchar(6) NOT NULL,
219 219
 				EXJ_first_model_name varchar(20) NOT NULL,
220 220
 				EXJ_second_model_id varchar(6) NOT NULL,
@@ -222,9 +222,9 @@  discard block
 block discarded – undo
222 222
 				PRIMARY KEY  (EXJ_ID),
223 223
 				KEY first_model (EXJ_first_model_name,EXJ_first_model_id),
224 224
 				KEY second_model (EXJ_second_model_name,EXJ_second_model_id)";
225
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
226
-        $table_name = 'esp_line_item';
227
-        $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
225
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
226
+		$table_name = 'esp_line_item';
227
+		$sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
228 228
 				LIN_code varchar(245) NOT NULL DEFAULT '',
229 229
 				TXN_ID int(11) DEFAULT NULL,
230 230
 				LIN_name varchar(245) NOT NULL DEFAULT '',
@@ -243,9 +243,9 @@  discard block
 block discarded – undo
243 243
 				PRIMARY KEY  (LIN_ID),
244 244
 				KEY LIN_code (LIN_code(191)),
245 245
 				KEY TXN_ID (TXN_ID)";
246
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
247
-        $table_name = 'esp_log';
248
-        $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT,
246
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
247
+		$table_name = 'esp_log';
248
+		$sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT,
249 249
 				LOG_time datetime DEFAULT NULL,
250 250
 				OBJ_ID varchar(45) DEFAULT NULL,
251 251
 				OBJ_type varchar(45) DEFAULT NULL,
@@ -256,18 +256,18 @@  discard block
 block discarded – undo
256 256
 				KEY LOG_time (LOG_time),
257 257
 				KEY OBJ (OBJ_type,OBJ_ID),
258 258
 				KEY LOG_type (LOG_type)";
259
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
260
-        $table_name = 'esp_message_template';
261
-        $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
259
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
260
+		$table_name = 'esp_message_template';
261
+		$sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
262 262
 					GRP_ID int(10) unsigned NOT NULL,
263 263
 					MTP_context varchar(50) NOT NULL,
264 264
 					MTP_template_field varchar(30) NOT NULL,
265 265
 					MTP_content text NOT NULL,
266 266
 					PRIMARY KEY  (MTP_ID),
267 267
 					KEY GRP_ID (GRP_ID)";
268
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
269
-        $table_name = 'esp_message_template_group';
270
-        $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
268
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
269
+		$table_name = 'esp_message_template_group';
270
+		$sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
271 271
 					MTP_user_id int(10) NOT NULL DEFAULT '1',
272 272
 					MTP_name varchar(245) NOT NULL DEFAULT '',
273 273
 					MTP_description varchar(245) NOT NULL DEFAULT '',
@@ -279,17 +279,17 @@  discard block
 block discarded – undo
279 279
 					MTP_is_active tinyint(1) NOT NULL DEFAULT '1',
280 280
 					PRIMARY KEY  (GRP_ID),
281 281
 					KEY MTP_user_id (MTP_user_id)";
282
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
283
-        $table_name = 'esp_event_message_template';
284
-        $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
282
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
283
+		$table_name = 'esp_event_message_template';
284
+		$sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
285 285
 					EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0,
286 286
 					GRP_ID int(10) unsigned NOT NULL DEFAULT 0,
287 287
 					PRIMARY KEY  (EMT_ID),
288 288
 					KEY EVT_ID (EVT_ID),
289 289
 					KEY GRP_ID (GRP_ID)";
290
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
291
-        $table_name = 'esp_payment';
292
-        $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
290
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
291
+		$table_name = 'esp_payment';
292
+		$sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
293 293
 					TXN_ID int(10) unsigned DEFAULT NULL,
294 294
 					STS_ID varchar(3) collate utf8_bin DEFAULT NULL,
295 295
 					PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
@@ -306,9 +306,9 @@  discard block
 block discarded – undo
306 306
 					PRIMARY KEY  (PAY_ID),
307 307
 					KEY PAY_timestamp (PAY_timestamp),
308 308
 					KEY TXN_ID (TXN_ID)";
309
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
310
-        $table_name = 'esp_payment_method';
311
-        $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT,
309
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
310
+		$table_name = 'esp_payment_method';
311
+		$sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT,
312 312
 				PMD_type varchar(124) DEFAULT NULL,
313 313
 				PMD_name varchar(255) DEFAULT NULL,
314 314
 				PMD_desc text,
@@ -324,32 +324,32 @@  discard block
 block discarded – undo
324 324
 				PRIMARY KEY  (PMD_ID),
325 325
 				UNIQUE KEY PMD_slug_UNIQUE (PMD_slug),
326 326
 				KEY PMD_type (PMD_type)";
327
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
328
-        $table_name = "esp_ticket_price";
329
-        $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
327
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
328
+		$table_name = "esp_ticket_price";
329
+		$sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
330 330
 					  TKT_ID int(10) unsigned NOT NULL,
331 331
 					  PRC_ID int(10) unsigned NOT NULL,
332 332
 					  PRIMARY KEY  (TKP_ID),
333 333
 					  KEY TKT_ID (TKT_ID),
334 334
 					  KEY PRC_ID (PRC_ID)";
335
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
336
-        $table_name = "esp_datetime_ticket";
337
-        $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
335
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
336
+		$table_name = "esp_datetime_ticket";
337
+		$sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
338 338
 					  DTT_ID int(10) unsigned NOT NULL,
339 339
 					  TKT_ID int(10) unsigned NOT NULL,
340 340
 					  PRIMARY KEY  (DTK_ID),
341 341
 					  KEY DTT_ID (DTT_ID),
342 342
 					  KEY TKT_ID (TKT_ID)";
343
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
344
-        $table_name = "esp_ticket_template";
345
-        $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
343
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
344
+		$table_name = "esp_ticket_template";
345
+		$sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
346 346
 					  TTM_name varchar(45) NOT NULL,
347 347
 					  TTM_description text,
348 348
 					  TTM_file varchar(45),
349 349
 					  PRIMARY KEY  (TTM_ID)";
350
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
351
-        $table_name = 'esp_question';
352
-        $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
350
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
351
+		$table_name = 'esp_question';
352
+		$sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
353 353
 					QST_display_text text NOT NULL,
354 354
 					QST_admin_label varchar(255) NOT NULL,
355 355
 					QST_system varchar(25) NOT NULL DEFAULT "",
@@ -363,18 +363,18 @@  discard block
 block discarded – undo
363 363
 					QST_deleted tinyint(2) unsigned NOT NULL DEFAULT 0,
364 364
 					PRIMARY KEY  (QST_ID),
365 365
 					KEY QST_order (QST_order)';
366
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
367
-        $table_name = 'esp_question_group_question';
368
-        $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
366
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
367
+		$table_name = 'esp_question_group_question';
368
+		$sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
369 369
 					QSG_ID int(10) unsigned NOT NULL,
370 370
 					QST_ID int(10) unsigned NOT NULL,
371 371
 					QGQ_order int(10) unsigned NOT NULL DEFAULT 0,
372 372
 					PRIMARY KEY  (QGQ_ID),
373 373
 					KEY QST_ID (QST_ID),
374 374
 					KEY QSG_ID_order (QSG_ID,QGQ_order)";
375
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
376
-        $table_name = 'esp_question_option';
377
-        $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
375
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
376
+		$table_name = 'esp_question_option';
377
+		$sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
378 378
 					QSO_value varchar(255) NOT NULL,
379 379
 					QSO_desc text NOT NULL,
380 380
 					QST_ID int(10) unsigned NOT NULL,
@@ -384,9 +384,9 @@  discard block
 block discarded – undo
384 384
 					PRIMARY KEY  (QSO_ID),
385 385
 					KEY QST_ID (QST_ID),
386 386
 					KEY QSO_order (QSO_order)";
387
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
388
-        $table_name = 'esp_registration';
389
-        $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
387
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
388
+		$table_name = 'esp_registration';
389
+		$sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
390 390
 					  EVT_ID bigint(20) unsigned NOT NULL,
391 391
 					  ATT_ID bigint(20) unsigned NOT NULL,
392 392
 					  TXN_ID int(10) unsigned NOT NULL,
@@ -410,18 +410,18 @@  discard block
 block discarded – undo
410 410
 					  KEY TKT_ID (TKT_ID),
411 411
 					  KEY EVT_ID (EVT_ID),
412 412
 					  KEY STS_ID (STS_ID)";
413
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
414
-        $table_name = 'esp_registration_payment';
415
-        $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
413
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
414
+		$table_name = 'esp_registration_payment';
415
+		$sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
416 416
 					  REG_ID int(10) unsigned NOT NULL,
417 417
 					  PAY_ID int(10) unsigned NULL,
418 418
 					  RPY_amount decimal(10,3) NOT NULL DEFAULT '0.00',
419 419
 					  PRIMARY KEY  (RPY_ID),
420 420
 					  KEY REG_ID (REG_ID),
421 421
 					  KEY PAY_ID (PAY_ID)";
422
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
423
-        $table_name = 'esp_checkin';
424
-        $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
422
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
423
+		$table_name = 'esp_checkin';
424
+		$sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
425 425
 					REG_ID int(10) unsigned NOT NULL,
426 426
 					DTT_ID int(10) unsigned NOT NULL,
427 427
 					CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1,
@@ -429,9 +429,9 @@  discard block
 block discarded – undo
429 429
 					PRIMARY KEY  (CHK_ID),
430 430
 					KEY REG_ID (REG_ID),
431 431
 					KEY DTT_ID (DTT_ID)";
432
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
433
-        $table_name = 'esp_state';
434
-        $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
432
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
433
+		$table_name = 'esp_state';
434
+		$sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
435 435
 					  CNT_ISO varchar(2) collate utf8_bin NOT NULL,
436 436
 					  STA_abbrev varchar(24) collate utf8_bin NOT NULL,
437 437
 					  STA_name varchar(100) collate utf8_bin NOT NULL,
@@ -439,9 +439,9 @@  discard block
 block discarded – undo
439 439
 					  PRIMARY KEY  (STA_ID),
440 440
 					  KEY STA_abbrev (STA_abbrev),
441 441
 					  KEY CNT_ISO (CNT_ISO)";
442
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
443
-        $table_name = 'esp_status';
444
-        $sql = "STS_ID varchar(3) NOT NULL,
442
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
443
+		$table_name = 'esp_status';
444
+		$sql = "STS_ID varchar(3) NOT NULL,
445 445
 					  STS_code varchar(45) NOT NULL,
446 446
 					  STS_type varchar(45) NOT NULL,
447 447
 					  STS_can_edit tinyint(1) NOT NULL DEFAULT 0,
@@ -449,9 +449,9 @@  discard block
 block discarded – undo
449 449
 					  STS_open tinyint(1) NOT NULL DEFAULT 1,
450 450
 					  UNIQUE KEY STS_ID_UNIQUE (STS_ID),
451 451
 					  KEY STS_type (STS_type)";
452
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
453
-        $table_name = 'esp_transaction';
454
-        $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
452
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
453
+		$table_name = 'esp_transaction';
454
+		$sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
455 455
 					  TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
456 456
 					  TXN_total decimal(10,3) DEFAULT '0.00',
457 457
 					  TXN_paid decimal(10,3) NOT NULL DEFAULT '0.00',
@@ -463,9 +463,9 @@  discard block
 block discarded – undo
463 463
 					  PRIMARY KEY  (TXN_ID),
464 464
 					  KEY TXN_timestamp (TXN_timestamp),
465 465
 					  KEY STS_ID (STS_ID)";
466
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
467
-        $table_name = 'esp_venue_meta';
468
-        $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
466
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
467
+		$table_name = 'esp_venue_meta';
468
+		$sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
469 469
 			VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0,
470 470
 			VNU_address varchar(255) DEFAULT NULL,
471 471
 			VNU_address2 varchar(255) DEFAULT NULL,
@@ -484,10 +484,10 @@  discard block
 block discarded – undo
484 484
 			KEY VNU_ID (VNU_ID),
485 485
 			KEY STA_ID (STA_ID),
486 486
 			KEY CNT_ISO (CNT_ISO)";
487
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
488
-        // modified tables
489
-        $table_name = "esp_price";
490
-        $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
487
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
488
+		// modified tables
489
+		$table_name = "esp_price";
490
+		$sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
491 491
 					  PRT_ID tinyint(3) unsigned NOT NULL,
492 492
 					  PRC_amount decimal(10,3) NOT NULL DEFAULT '0.00',
493 493
 					  PRC_name varchar(245) NOT NULL,
@@ -500,9 +500,9 @@  discard block
 block discarded – undo
500 500
 					  PRC_parent int(10) unsigned DEFAULT 0,
501 501
 					  PRIMARY KEY  (PRC_ID),
502 502
 					  KEY PRT_ID (PRT_ID)";
503
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
504
-        $table_name = "esp_price_type";
505
-        $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
503
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
504
+		$table_name = "esp_price_type";
505
+		$sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
506 506
 				  PRT_name varchar(45) NOT NULL,
507 507
 				  PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1',
508 508
 				  PRT_is_percent tinyint(1) NOT NULL DEFAULT '0',
@@ -511,9 +511,9 @@  discard block
 block discarded – undo
511 511
 				  PRT_deleted tinyint(1) NOT NULL DEFAULT '0',
512 512
 				  UNIQUE KEY PRT_name_UNIQUE (PRT_name),
513 513
 				  PRIMARY KEY  (PRT_ID)";
514
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
515
-        $table_name = "esp_ticket";
516
-        $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
514
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
515
+		$table_name = "esp_ticket";
516
+		$sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
517 517
 					  TTM_ID int(10) unsigned NOT NULL,
518 518
 					  TKT_name varchar(245) NOT NULL DEFAULT '',
519 519
 					  TKT_description text NOT NULL,
@@ -535,9 +535,9 @@  discard block
 block discarded – undo
535 535
 					  TKT_deleted tinyint(1) NOT NULL DEFAULT '0',
536 536
 					  PRIMARY KEY  (TKT_ID),
537 537
 					  KEY TKT_start_date (TKT_start_date)";
538
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
539
-        $table_name = 'esp_question_group';
540
-        $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
538
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
539
+		$table_name = 'esp_question_group';
540
+		$sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
541 541
 					QSG_name varchar(255) NOT NULL,
542 542
 					QSG_identifier varchar(100) NOT NULL,
543 543
 					QSG_desc text NULL,
@@ -550,223 +550,223 @@  discard block
 block discarded – undo
550 550
 					PRIMARY KEY  (QSG_ID),
551 551
 					UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier),
552 552
 					KEY QSG_order (QSG_order)';
553
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
554
-        /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */
555
-        $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
556
-        // (because many need to convert old string states to foreign keys into the states table)
557
-        $script_4_1_defaults->insert_default_states();
558
-        $script_4_1_defaults->insert_default_countries();
559
-        /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */
560
-        $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0');
561
-        $script_4_5_defaults->insert_default_price_types();
562
-        $script_4_5_defaults->insert_default_prices();
563
-        $script_4_5_defaults->insert_default_tickets();
564
-        /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */
565
-        $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0');
566
-        $script_4_6_defaults->add_default_admin_only_payments();
567
-        $script_4_6_defaults->insert_default_currencies();
568
-        $this->verify_new_countries();
569
-        $this->verify_new_currencies();
570
-        return true;
571
-    }
553
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
554
+		/** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */
555
+		$script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
556
+		// (because many need to convert old string states to foreign keys into the states table)
557
+		$script_4_1_defaults->insert_default_states();
558
+		$script_4_1_defaults->insert_default_countries();
559
+		/** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */
560
+		$script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0');
561
+		$script_4_5_defaults->insert_default_price_types();
562
+		$script_4_5_defaults->insert_default_prices();
563
+		$script_4_5_defaults->insert_default_tickets();
564
+		/** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */
565
+		$script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0');
566
+		$script_4_6_defaults->add_default_admin_only_payments();
567
+		$script_4_6_defaults->insert_default_currencies();
568
+		$this->verify_new_countries();
569
+		$this->verify_new_currencies();
570
+		return true;
571
+	}
572 572
 
573 573
 
574 574
 
575
-    /**
576
-     * @return boolean
577
-     */
578
-    public function schema_changes_after_migration()
579
-    {
580
-        $this->fix_non_default_taxes();
581
-        // this is actually the same as the last DMS
582
-        /** @var EE_DMS_Core_4_7_0 $script_4_7_defaults */
583
-        $script_4_7_defaults = EE_Registry::instance()->load_dms('Core_4_7_0');
584
-        return $script_4_7_defaults->schema_changes_after_migration();
585
-    }
575
+	/**
576
+	 * @return boolean
577
+	 */
578
+	public function schema_changes_after_migration()
579
+	{
580
+		$this->fix_non_default_taxes();
581
+		// this is actually the same as the last DMS
582
+		/** @var EE_DMS_Core_4_7_0 $script_4_7_defaults */
583
+		$script_4_7_defaults = EE_Registry::instance()->load_dms('Core_4_7_0');
584
+		return $script_4_7_defaults->schema_changes_after_migration();
585
+	}
586 586
 
587 587
 
588 588
 
589
-    public function migration_page_hooks()
590
-    {
591
-    }
589
+	public function migration_page_hooks()
590
+	{
591
+	}
592 592
 
593 593
 
594 594
 
595
-    /**
596
-     * verifies each of the new countries exists that somehow we missed in 4.1
597
-     */
598
-    public function verify_new_countries()
599
-    {
600
-        // a list of countries (and specifically some which were missed in another list):https://gist.github.com/adhipg/1600028
601
-        // how many decimal places? https://en.wikipedia.org/wiki/ISO_4217
602
-        // currency symbols: http://www.xe.com/symbols.php
603
-        // CNT_ISO, CNT_ISO3, RGN_ID, CNT_name, CNT_cur_code, CNT_cur_single, CNT_cur_plural, CNT_cur_sign, CNT_cur_sign_b4, CNT_cur_dec_plc, CNT_tel_code, CNT_is_EU, CNT_active
604
-        // ('AD', 'AND', 0, 'Andorra', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+376', 0, 0),
605
-        $newer_countries = array(
606
-            array('AX', 'ALA', 0, '&#197;land Islands', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+358', 1, 0),
607
-            array('BL', 'BLM', 0, 'Saint Barthelemy', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+590', 1, 0),
608
-            array('CW', 'CUW', 0, 'Curacao', 'ANG', 'Guilder', 'Guilders', 'ƒ', 1, 2, '+599', 1, 0),
609
-            array('GG', 'GGY', 0, 'Guernsey', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+44', 0, 0),
610
-            array('IM', 'IMN', 0, 'Isle of Man', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+44', 0, 0),
611
-            array('JE', 'JEY', 0, 'Jersey', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+44', 0, 0),
612
-            array('MF', 'MAF', 0, 'Saint Martin', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+590', 1, 0),
613
-            array('ME', 'MNE', 0, 'Montenegro', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+382', 0, 0),
614
-            array('RS', 'SRB', 0, 'Serbia', 'RSD', 'Dinar', 'Dinars', '', 0, 2, '+381', 1, 0),
615
-            array('SS', 'SSD', 0, 'South Sudan', 'SSP', 'Pound', 'Pounds', '£', 1, 2, '+211', 0, 0),
616
-            array('SX', 'SXM', 0, 'Sint Maarten', 'ANG', 'Guilder', 'Guilders', 'ƒ', 1, 2, '+1', 1, 0),
617
-            array('XK', 'XKX', 0, 'Kosovo', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+383', 0, 0),
618
-            array('YT', 'MYT', 0, 'Mayotte', 'EUR', 'Euro', 'Euros', '€', 0, 2, '+262', 1, 0),
619
-            array(
620
-                'BQ',
621
-                'BES',
622
-                0,
623
-                'Bonaire, Saint Eustatius and Saba',
624
-                'USD',
625
-                'Dollar',
626
-                'Dollars',
627
-                '$',
628
-                1,
629
-                2,
630
-                '+599',
631
-                0,
632
-                0,
633
-            ),
634
-            array('BV', 'BVT', 0, 'Bouvet Island', 'NOK', 'Krone', 'Krones', 'kr', 1, 2, '+47', 0, 0),
635
-            array('IO', 'IOT', 0, 'British Indian Ocean Territory', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+246', 0, 0),
636
-            array('CX', 'CXR', 0, 'Christmas Island', 'AUD', 'Dollar', 'Dollars', '$', 1, 2, '+61', 0, 0),
637
-            array('CC', 'CCK', 0, 'Cocos (Keeling) Islands', 'AUD', 'Dollar', 'Dollars', '$', 1, 2, '+891', 0, 0),
638
-            array(
639
-                'HM',
640
-                'HMD',
641
-                0,
642
-                'Heard Island and McDonald Islands',
643
-                'AUD',
644
-                'Dollar',
645
-                'Dollars',
646
-                '$',
647
-                1,
648
-                2,
649
-                '+891',
650
-                0,
651
-                0,
652
-            ),
653
-            array('PS', 'PSE', 0, 'Palestinian Territory', 'ILS', 'Shekel', 'Shekels', '₪', 1, 2, '+970', 0, 0),
654
-            array(
655
-                'GS',
656
-                'SGS',
657
-                0,
658
-                'South Georgia and the South Sandwich Islands',
659
-                'GBP',
660
-                'Pound',
661
-                'Pounds',
662
-                '£',
663
-                1,
664
-                2,
665
-                '+500',
666
-                0,
667
-                0,
668
-            ),
669
-            array('TL', 'TLS', 0, 'Timor-Leste', 'USD', 'Dollar', 'Dollars', '$', 1, 2, '+670', 0, 0),
670
-            array('TF', 'ATF', 0, 'French Southern Territories', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+262', 0, 0),
671
-            array(
672
-                'UM',
673
-                'UMI',
674
-                0,
675
-                'United States Minor Outlying Islands',
676
-                'USD',
677
-                'Dollar',
678
-                'Dollars',
679
-                '$',
680
-                1,
681
-                2,
682
-                '+1',
683
-                0,
684
-                0,
685
-            ),
686
-        );
687
-        global $wpdb;
688
-        $country_table = $wpdb->prefix . "esp_country";
689
-        $country_format = array(
690
-            "CNT_ISO"         => '%s',
691
-            "CNT_ISO3"        => '%s',
692
-            "RGN_ID"          => '%d',
693
-            "CNT_name"        => '%s',
694
-            "CNT_cur_code"    => '%s',
695
-            "CNT_cur_single"  => '%s',
696
-            "CNT_cur_plural"  => '%s',
697
-            "CNT_cur_sign"    => '%s',
698
-            "CNT_cur_sign_b4" => '%d',
699
-            "CNT_cur_dec_plc" => '%d',
700
-            "CNT_tel_code"    => '%s',
701
-            "CNT_is_EU"       => '%d',
702
-            "CNT_active"      => '%d',
703
-        );
704
-        if ($this->_get_table_analysis()->tableExists($country_table)) {
705
-            foreach ($newer_countries as $country) {
706
-                $SQL = "SELECT COUNT('CNT_ISO') FROM {$country_table} WHERE CNT_ISO='{$country[0]}' LIMIT 1";
707
-                $countries = $wpdb->get_var($SQL);
708
-                if (! $countries) {
709
-                    $wpdb->insert(
710
-                        $country_table,
711
-                        array_combine(array_keys($country_format), $country),
712
-                        $country_format
713
-                    );
714
-                }
715
-            }
716
-        }
717
-    }
595
+	/**
596
+	 * verifies each of the new countries exists that somehow we missed in 4.1
597
+	 */
598
+	public function verify_new_countries()
599
+	{
600
+		// a list of countries (and specifically some which were missed in another list):https://gist.github.com/adhipg/1600028
601
+		// how many decimal places? https://en.wikipedia.org/wiki/ISO_4217
602
+		// currency symbols: http://www.xe.com/symbols.php
603
+		// CNT_ISO, CNT_ISO3, RGN_ID, CNT_name, CNT_cur_code, CNT_cur_single, CNT_cur_plural, CNT_cur_sign, CNT_cur_sign_b4, CNT_cur_dec_plc, CNT_tel_code, CNT_is_EU, CNT_active
604
+		// ('AD', 'AND', 0, 'Andorra', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+376', 0, 0),
605
+		$newer_countries = array(
606
+			array('AX', 'ALA', 0, '&#197;land Islands', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+358', 1, 0),
607
+			array('BL', 'BLM', 0, 'Saint Barthelemy', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+590', 1, 0),
608
+			array('CW', 'CUW', 0, 'Curacao', 'ANG', 'Guilder', 'Guilders', 'ƒ', 1, 2, '+599', 1, 0),
609
+			array('GG', 'GGY', 0, 'Guernsey', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+44', 0, 0),
610
+			array('IM', 'IMN', 0, 'Isle of Man', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+44', 0, 0),
611
+			array('JE', 'JEY', 0, 'Jersey', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+44', 0, 0),
612
+			array('MF', 'MAF', 0, 'Saint Martin', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+590', 1, 0),
613
+			array('ME', 'MNE', 0, 'Montenegro', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+382', 0, 0),
614
+			array('RS', 'SRB', 0, 'Serbia', 'RSD', 'Dinar', 'Dinars', '', 0, 2, '+381', 1, 0),
615
+			array('SS', 'SSD', 0, 'South Sudan', 'SSP', 'Pound', 'Pounds', '£', 1, 2, '+211', 0, 0),
616
+			array('SX', 'SXM', 0, 'Sint Maarten', 'ANG', 'Guilder', 'Guilders', 'ƒ', 1, 2, '+1', 1, 0),
617
+			array('XK', 'XKX', 0, 'Kosovo', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+383', 0, 0),
618
+			array('YT', 'MYT', 0, 'Mayotte', 'EUR', 'Euro', 'Euros', '€', 0, 2, '+262', 1, 0),
619
+			array(
620
+				'BQ',
621
+				'BES',
622
+				0,
623
+				'Bonaire, Saint Eustatius and Saba',
624
+				'USD',
625
+				'Dollar',
626
+				'Dollars',
627
+				'$',
628
+				1,
629
+				2,
630
+				'+599',
631
+				0,
632
+				0,
633
+			),
634
+			array('BV', 'BVT', 0, 'Bouvet Island', 'NOK', 'Krone', 'Krones', 'kr', 1, 2, '+47', 0, 0),
635
+			array('IO', 'IOT', 0, 'British Indian Ocean Territory', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+246', 0, 0),
636
+			array('CX', 'CXR', 0, 'Christmas Island', 'AUD', 'Dollar', 'Dollars', '$', 1, 2, '+61', 0, 0),
637
+			array('CC', 'CCK', 0, 'Cocos (Keeling) Islands', 'AUD', 'Dollar', 'Dollars', '$', 1, 2, '+891', 0, 0),
638
+			array(
639
+				'HM',
640
+				'HMD',
641
+				0,
642
+				'Heard Island and McDonald Islands',
643
+				'AUD',
644
+				'Dollar',
645
+				'Dollars',
646
+				'$',
647
+				1,
648
+				2,
649
+				'+891',
650
+				0,
651
+				0,
652
+			),
653
+			array('PS', 'PSE', 0, 'Palestinian Territory', 'ILS', 'Shekel', 'Shekels', '₪', 1, 2, '+970', 0, 0),
654
+			array(
655
+				'GS',
656
+				'SGS',
657
+				0,
658
+				'South Georgia and the South Sandwich Islands',
659
+				'GBP',
660
+				'Pound',
661
+				'Pounds',
662
+				'£',
663
+				1,
664
+				2,
665
+				'+500',
666
+				0,
667
+				0,
668
+			),
669
+			array('TL', 'TLS', 0, 'Timor-Leste', 'USD', 'Dollar', 'Dollars', '$', 1, 2, '+670', 0, 0),
670
+			array('TF', 'ATF', 0, 'French Southern Territories', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+262', 0, 0),
671
+			array(
672
+				'UM',
673
+				'UMI',
674
+				0,
675
+				'United States Minor Outlying Islands',
676
+				'USD',
677
+				'Dollar',
678
+				'Dollars',
679
+				'$',
680
+				1,
681
+				2,
682
+				'+1',
683
+				0,
684
+				0,
685
+			),
686
+		);
687
+		global $wpdb;
688
+		$country_table = $wpdb->prefix . "esp_country";
689
+		$country_format = array(
690
+			"CNT_ISO"         => '%s',
691
+			"CNT_ISO3"        => '%s',
692
+			"RGN_ID"          => '%d',
693
+			"CNT_name"        => '%s',
694
+			"CNT_cur_code"    => '%s',
695
+			"CNT_cur_single"  => '%s',
696
+			"CNT_cur_plural"  => '%s',
697
+			"CNT_cur_sign"    => '%s',
698
+			"CNT_cur_sign_b4" => '%d',
699
+			"CNT_cur_dec_plc" => '%d',
700
+			"CNT_tel_code"    => '%s',
701
+			"CNT_is_EU"       => '%d',
702
+			"CNT_active"      => '%d',
703
+		);
704
+		if ($this->_get_table_analysis()->tableExists($country_table)) {
705
+			foreach ($newer_countries as $country) {
706
+				$SQL = "SELECT COUNT('CNT_ISO') FROM {$country_table} WHERE CNT_ISO='{$country[0]}' LIMIT 1";
707
+				$countries = $wpdb->get_var($SQL);
708
+				if (! $countries) {
709
+					$wpdb->insert(
710
+						$country_table,
711
+						array_combine(array_keys($country_format), $country),
712
+						$country_format
713
+					);
714
+				}
715
+			}
716
+		}
717
+	}
718 718
 
719 719
 
720 720
 
721
-    /**
722
-     * verifies each of the new currencies exists that somehow we missed in 4.6
723
-     */
724
-    public function verify_new_currencies()
725
-    {
726
-        // a list of countries (and specifically some which were missed in another list):https://gist.github.com/adhipg/1600028
727
-        // how many decimal places? https://en.wikipedia.org/wiki/ISO_4217
728
-        // currency symbols: http://www.xe.com/symbols.php
729
-        // CUR_code, CUR_single, CUR_plural, CUR_sign, CUR_dec_plc, CUR_active
730
-        // ( 'EUR',  'Euro',  'Euros',  '€',  2,1),
731
-        $newer_currencies = array(
732
-            array('RSD', 'Dinar', 'Dinars', '', 3, 1),
733
-        );
734
-        global $wpdb;
735
-        $currency_table = $wpdb->prefix . "esp_currency";
736
-        $currency_format = array(
737
-            "CUR_code"    => '%s',
738
-            "CUR_single"  => '%s',
739
-            "CUR_plural"  => '%s',
740
-            "CUR_sign"    => '%s',
741
-            "CUR_dec_plc" => '%d',
742
-            "CUR_active"  => '%d',
743
-        );
744
-        if ($this->_get_table_analysis()->tableExists($currency_table)) {
745
-            foreach ($newer_currencies as $currency) {
746
-                $SQL = "SELECT COUNT('CUR_code') FROM {$currency_table} WHERE CUR_code='{$currency[0]}' LIMIT 1";
747
-                $countries = $wpdb->get_var($SQL);
748
-                if (! $countries) {
749
-                    $wpdb->insert(
750
-                        $currency_table,
751
-                        array_combine(array_keys($currency_format), $currency),
752
-                        $currency_format
753
-                    );
754
-                }
755
-            }
756
-        }
757
-    }
721
+	/**
722
+	 * verifies each of the new currencies exists that somehow we missed in 4.6
723
+	 */
724
+	public function verify_new_currencies()
725
+	{
726
+		// a list of countries (and specifically some which were missed in another list):https://gist.github.com/adhipg/1600028
727
+		// how many decimal places? https://en.wikipedia.org/wiki/ISO_4217
728
+		// currency symbols: http://www.xe.com/symbols.php
729
+		// CUR_code, CUR_single, CUR_plural, CUR_sign, CUR_dec_plc, CUR_active
730
+		// ( 'EUR',  'Euro',  'Euros',  '€',  2,1),
731
+		$newer_currencies = array(
732
+			array('RSD', 'Dinar', 'Dinars', '', 3, 1),
733
+		);
734
+		global $wpdb;
735
+		$currency_table = $wpdb->prefix . "esp_currency";
736
+		$currency_format = array(
737
+			"CUR_code"    => '%s',
738
+			"CUR_single"  => '%s',
739
+			"CUR_plural"  => '%s',
740
+			"CUR_sign"    => '%s',
741
+			"CUR_dec_plc" => '%d',
742
+			"CUR_active"  => '%d',
743
+		);
744
+		if ($this->_get_table_analysis()->tableExists($currency_table)) {
745
+			foreach ($newer_currencies as $currency) {
746
+				$SQL = "SELECT COUNT('CUR_code') FROM {$currency_table} WHERE CUR_code='{$currency[0]}' LIMIT 1";
747
+				$countries = $wpdb->get_var($SQL);
748
+				if (! $countries) {
749
+					$wpdb->insert(
750
+						$currency_table,
751
+						array_combine(array_keys($currency_format), $currency),
752
+						$currency_format
753
+					);
754
+				}
755
+			}
756
+		}
757
+	}
758 758
 
759 759
 
760 760
 
761
-    /**
762
-     * addresses https://events.codebasehq.com/projects/event-espresso/tickets/8731
763
-     * which should just be a temporary issue for folks who installed 4.8.0-4.8.5;
764
-     * we should be able to stop doing this in 4.9
765
-     */
766
-    public function fix_non_default_taxes()
767
-    {
768
-        global $wpdb;
769
-        $query = $wpdb->prepare("UPDATE
761
+	/**
762
+	 * addresses https://events.codebasehq.com/projects/event-espresso/tickets/8731
763
+	 * which should just be a temporary issue for folks who installed 4.8.0-4.8.5;
764
+	 * we should be able to stop doing this in 4.9
765
+	 */
766
+	public function fix_non_default_taxes()
767
+	{
768
+		global $wpdb;
769
+		$query = $wpdb->prepare("UPDATE
770 770
 				{$wpdb->prefix}esp_price p INNER JOIN
771 771
 				{$wpdb->prefix}esp_price_type pt ON p.PRT_ID = pt.PRT_ID
772 772
 			SET
@@ -775,6 +775,6 @@  discard block
 block discarded – undo
775 775
 				p.PRC_is_default = 0 AND
776 776
 				pt.PBT_ID = %d
777 777
 					", EEM_Price_Type::base_type_tax);
778
-        $wpdb->query($query);
779
-    }
778
+		$wpdb->query($query);
779
+	}
780 780
 }
Please login to merge, or discard this patch.
core/data_migration_scripts/EE_DMS_Core_4_6_0.dms.php 1 patch
Indentation   +259 added lines, -259 removed lines patch added patch discarded remove patch
@@ -14,9 +14,9 @@  discard block
 block discarded – undo
14 14
 $stages = glob(EE_CORE . 'data_migration_scripts/4_6_0_stages/*');
15 15
 $class_to_filepath = array();
16 16
 foreach ($stages as $filepath) {
17
-    $matches = array();
18
-    preg_match('~4_6_0_stages/(.*).dmsstage.php~', $filepath, $matches);
19
-    $class_to_filepath[ $matches[1] ] = $filepath;
17
+	$matches = array();
18
+	preg_match('~4_6_0_stages/(.*).dmsstage.php~', $filepath, $matches);
19
+	$class_to_filepath[ $matches[1] ] = $filepath;
20 20
 }
21 21
 // give addons a chance to autoload their stages too
22 22
 $class_to_filepath = apply_filters('FHEE__EE_DMS_4_6_0__autoloaded_stages', $class_to_filepath);
@@ -35,69 +35,69 @@  discard block
 block discarded – undo
35 35
 class EE_DMS_Core_4_6_0 extends EE_Data_Migration_Script_Base
36 36
 {
37 37
 
38
-    /**
39
-     * return EE_DMS_Core_4_6_0
40
-     *
41
-     * @param TableManager  $table_manager
42
-     * @param TableAnalysis $table_analysis
43
-     */
44
-    public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
45
-    {
46
-        $this->_pretty_name = __("Data Update to Event Espresso 4.6.0", "event_espresso");
47
-        $this->_priority = 10;
48
-        $this->_migration_stages = array(
49
-            new EE_DMS_4_6_0_gateways(),
50
-            new EE_DMS_4_6_0_question_types(),
51
-            new EE_DMS_4_6_0_country_system_question(),
52
-            new EE_DMS_4_6_0_state_system_question(),
53
-            new EE_DMS_4_6_0_billing_info(),
54
-            new EE_DMS_4_6_0_transactions(),
55
-            new EE_DMS_4_6_0_payments(),
56
-            new EE_DMS_4_6_0_invoice_settings(),
57
-        );
58
-        parent::__construct($table_manager, $table_analysis);
59
-    }
38
+	/**
39
+	 * return EE_DMS_Core_4_6_0
40
+	 *
41
+	 * @param TableManager  $table_manager
42
+	 * @param TableAnalysis $table_analysis
43
+	 */
44
+	public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
45
+	{
46
+		$this->_pretty_name = __("Data Update to Event Espresso 4.6.0", "event_espresso");
47
+		$this->_priority = 10;
48
+		$this->_migration_stages = array(
49
+			new EE_DMS_4_6_0_gateways(),
50
+			new EE_DMS_4_6_0_question_types(),
51
+			new EE_DMS_4_6_0_country_system_question(),
52
+			new EE_DMS_4_6_0_state_system_question(),
53
+			new EE_DMS_4_6_0_billing_info(),
54
+			new EE_DMS_4_6_0_transactions(),
55
+			new EE_DMS_4_6_0_payments(),
56
+			new EE_DMS_4_6_0_invoice_settings(),
57
+		);
58
+		parent::__construct($table_manager, $table_analysis);
59
+	}
60 60
 
61 61
 
62 62
 
63
-    /**
64
-     * @param array $version_array
65
-     * @return bool
66
-     */
67
-    public function can_migrate_from_version($version_array)
68
-    {
69
-        $version_string = $version_array['Core'];
70
-        if (version_compare($version_string, '4.6.0', '<=') && version_compare($version_string, '4.5.0', '>=')) {
63
+	/**
64
+	 * @param array $version_array
65
+	 * @return bool
66
+	 */
67
+	public function can_migrate_from_version($version_array)
68
+	{
69
+		$version_string = $version_array['Core'];
70
+		if (version_compare($version_string, '4.6.0', '<=') && version_compare($version_string, '4.5.0', '>=')) {
71 71
 //          echo "$version_string can be migrated from";
72
-            return true;
73
-        } elseif (! $version_string) {
72
+			return true;
73
+		} elseif (! $version_string) {
74 74
 //          echo "no version string provided: $version_string";
75
-            // no version string provided... this must be pre 4.3
76
-            return false;// changed mind. dont want people thinking they should migrate yet because they cant
77
-        } else {
75
+			// no version string provided... this must be pre 4.3
76
+			return false;// changed mind. dont want people thinking they should migrate yet because they cant
77
+		} else {
78 78
 //          echo "$version_string doesnt apply";
79
-            return false;
80
-        }
81
-    }
79
+			return false;
80
+		}
81
+	}
82 82
 
83 83
 
84 84
 
85
-    /**
86
-     * @return bool
87
-     */
88
-    public function schema_changes_before_migration()
89
-    {
90
-        // relies on 4.1's EEH_Activation::create_table
91
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
92
-        $table_name = 'esp_answer';
93
-        $sql = " ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
85
+	/**
86
+	 * @return bool
87
+	 */
88
+	public function schema_changes_before_migration()
89
+	{
90
+		// relies on 4.1's EEH_Activation::create_table
91
+		require_once(EE_HELPERS . 'EEH_Activation.helper.php');
92
+		$table_name = 'esp_answer';
93
+		$sql = " ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
94 94
 					REG_ID INT UNSIGNED NOT NULL,
95 95
 					QST_ID INT UNSIGNED NOT NULL,
96 96
 					ANS_value TEXT NOT NULL,
97 97
 					PRIMARY KEY  (ANS_ID)";
98
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
99
-        $table_name = 'esp_attendee_meta';
100
-        $sql = "ATTM_ID INT(10) UNSIGNED NOT	NULL AUTO_INCREMENT,
98
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
99
+		$table_name = 'esp_attendee_meta';
100
+		$sql = "ATTM_ID INT(10) UNSIGNED NOT	NULL AUTO_INCREMENT,
101 101
 						ATT_ID BIGINT(20) UNSIGNED NOT NULL,
102 102
 						ATT_fname VARCHAR(45) NOT NULL,
103 103
 						ATT_lname VARCHAR(45) NOT	NULL,
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
 								KEY ATT_fname (ATT_fname),
114 114
 								KEY ATT_lname (ATT_lname),
115 115
 								KEY ATT_email (ATT_email(191))";
116
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
117
-        $table_name = 'esp_country';
118
-        $sql = "CNT_ISO VARCHAR(2) COLLATE utf8_bin NOT NULL,
116
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
117
+		$table_name = 'esp_country';
118
+		$sql = "CNT_ISO VARCHAR(2) COLLATE utf8_bin NOT NULL,
119 119
 					  CNT_ISO3 VARCHAR(3) COLLATE utf8_bin NOT NULL,
120 120
 					  RGN_ID TINYINT(3) UNSIGNED DEFAULT NULL,
121 121
 					  CNT_name VARCHAR(45) COLLATE utf8_bin NOT NULL,
@@ -131,24 +131,24 @@  discard block
 block discarded – undo
131 131
 					  CNT_is_EU TINYINT(1) DEFAULT '0',
132 132
 					  CNT_active TINYINT(1) DEFAULT '0',
133 133
 					  PRIMARY KEY  (CNT_ISO)";
134
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
135
-        $table_name = 'esp_currency';
136
-        $sql = "CUR_code VARCHAR(6) COLLATE utf8_bin NOT NULL,
134
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
135
+		$table_name = 'esp_currency';
136
+		$sql = "CUR_code VARCHAR(6) COLLATE utf8_bin NOT NULL,
137 137
 				CUR_single VARCHAR(45) COLLATE utf8_bin DEFAULT 'dollar',
138 138
 				CUR_plural VARCHAR(45) COLLATE utf8_bin DEFAULT 'dollars',
139 139
 				CUR_sign VARCHAR(45) COLLATE utf8_bin DEFAULT '$',
140 140
 				CUR_dec_plc VARCHAR(1) COLLATE utf8_bin NOT NULL DEFAULT '2',
141 141
 				CUR_active TINYINT(1) DEFAULT '0',
142 142
 				PRIMARY KEY  (CUR_code)";
143
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
144
-        $table_name = 'esp_currency_payment_method';
145
-        $sql = "CPM_ID INT(11) NOT NULL AUTO_INCREMENT,
143
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
144
+		$table_name = 'esp_currency_payment_method';
145
+		$sql = "CPM_ID INT(11) NOT NULL AUTO_INCREMENT,
146 146
 				CUR_code  VARCHAR(6) COLLATE utf8_bin NOT NULL,
147 147
 				PMD_ID INT(11) NOT NULL,
148 148
 				PRIMARY KEY  (CPM_ID)";
149
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
150
-        $table_name = 'esp_datetime';
151
-        $sql = "DTT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
149
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
150
+		$table_name = 'esp_datetime';
151
+		$sql = "DTT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
152 152
 				  EVT_ID BIGINT(20) UNSIGNED NOT NULL,
153 153
 				  DTT_name VARCHAR(255) NOT NULL DEFAULT '',
154 154
 				  DTT_description TEXT NOT NULL,
@@ -163,9 +163,9 @@  discard block
 block discarded – undo
163 163
 						PRIMARY KEY  (DTT_ID),
164 164
 						KEY EVT_ID (EVT_ID),
165 165
 						KEY DTT_is_primary (DTT_is_primary)";
166
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
167
-        $table_name = 'esp_event_meta';
168
-        $sql = "
166
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
167
+		$table_name = 'esp_event_meta';
168
+		$sql = "
169 169
 			EVTM_ID INT NOT NULL AUTO_INCREMENT,
170 170
 			EVT_ID BIGINT(20) UNSIGNED NOT NULL,
171 171
 			EVT_display_desc TINYINT(1) UNSIGNED NOT NULL DEFAULT 1,
@@ -180,31 +180,31 @@  discard block
 block discarded – undo
180 180
 			EVT_external_URL VARCHAR(200) NULL,
181 181
 			EVT_donations TINYINT(1) NULL,
182 182
 			PRIMARY KEY  (EVTM_ID)";
183
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
184
-        $table_name = 'esp_event_question_group';
185
-        $sql = "EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
183
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
184
+		$table_name = 'esp_event_question_group';
185
+		$sql = "EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
186 186
 					EVT_ID BIGINT(20) UNSIGNED NOT NULL,
187 187
 					QSG_ID INT UNSIGNED NOT NULL,
188 188
 					EQG_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
189 189
 					PRIMARY KEY  (EQG_ID)";
190
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
191
-        $table_name = 'esp_event_venue';
192
-        $sql = "EVV_ID INT(11) NOT NULL AUTO_INCREMENT,
190
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
191
+		$table_name = 'esp_event_venue';
192
+		$sql = "EVV_ID INT(11) NOT NULL AUTO_INCREMENT,
193 193
 				EVT_ID BIGINT(20) UNSIGNED NOT NULL,
194 194
 				VNU_ID BIGINT(20) UNSIGNED NOT NULL,
195 195
 				EVV_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
196 196
 				PRIMARY KEY  (EVV_ID)";
197
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
198
-        $table_name = 'esp_extra_meta';
199
-        $sql = "EXM_ID INT(11) NOT NULL AUTO_INCREMENT,
197
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
198
+		$table_name = 'esp_extra_meta';
199
+		$sql = "EXM_ID INT(11) NOT NULL AUTO_INCREMENT,
200 200
 				OBJ_ID INT(11) DEFAULT NULL,
201 201
 				EXM_type VARCHAR(45) DEFAULT NULL,
202 202
 				EXM_key VARCHAR(45) DEFAULT NULL,
203 203
 				EXM_value TEXT,
204 204
 				PRIMARY KEY  (EXM_ID)";
205
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
206
-        $table_name = 'esp_line_item';
207
-        $sql = "LIN_ID INT(11) NOT NULL AUTO_INCREMENT,
205
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
206
+		$table_name = 'esp_line_item';
207
+		$sql = "LIN_ID INT(11) NOT NULL AUTO_INCREMENT,
208 208
 				LIN_code VARCHAR(245) NOT NULL DEFAULT '',
209 209
 				TXN_ID INT(11) DEFAULT NULL,
210 210
 				LIN_name VARCHAR(245) NOT NULL DEFAULT '',
@@ -220,9 +220,9 @@  discard block
 block discarded – undo
220 220
 				OBJ_ID INT(11) DEFAULT NULL,
221 221
 				OBJ_type VARCHAR(45)DEFAULT NULL,
222 222
 				PRIMARY KEY  (LIN_ID)";
223
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
224
-        $table_name = 'esp_log';
225
-        $sql = "LOG_ID INT(11) NOT NULL AUTO_INCREMENT,
223
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
224
+		$table_name = 'esp_log';
225
+		$sql = "LOG_ID INT(11) NOT NULL AUTO_INCREMENT,
226 226
 				LOG_time DATETIME DEFAULT NULL,
227 227
 				OBJ_ID VARCHAR(45) DEFAULT NULL,
228 228
 				OBJ_type VARCHAR(45) DEFAULT NULL,
@@ -230,19 +230,19 @@  discard block
 block discarded – undo
230 230
 				LOG_message TEXT,
231 231
 				LOG_wp_user INT(11) DEFAULT NULL,
232 232
 				PRIMARY KEY  (LOG_ID)";
233
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
234
-        $table_name = 'esp_message_template';
235
-        $sql = "MTP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
233
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
234
+		$table_name = 'esp_message_template';
235
+		$sql = "MTP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
236 236
 					GRP_ID INT(10) UNSIGNED NOT NULL,
237 237
 					MTP_context VARCHAR(50) NOT NULL,
238 238
 					MTP_template_field VARCHAR(30) NOT NULL,
239 239
 					MTP_content TEXT NOT NULL,
240 240
 					PRIMARY KEY  (MTP_ID),
241 241
 					KEY GRP_ID (GRP_ID)";
242
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
243
-        $this->_get_table_manager()->dropIndex('esp_message_template_group', 'EVT_ID');
244
-        $table_name = 'esp_message_template_group';
245
-        $sql = "GRP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
242
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
243
+		$this->_get_table_manager()->dropIndex('esp_message_template_group', 'EVT_ID');
244
+		$table_name = 'esp_message_template_group';
245
+		$sql = "GRP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
246 246
 					MTP_user_id INT(10) NOT NULL DEFAULT '1',
247 247
 					MTP_name VARCHAR(245) NOT NULL DEFAULT '',
248 248
 					MTP_description VARCHAR(245) NOT NULL DEFAULT '',
@@ -254,17 +254,17 @@  discard block
 block discarded – undo
254 254
 					MTP_is_active TINYINT(1) NOT NULL DEFAULT '1',
255 255
 					PRIMARY KEY  (GRP_ID),
256 256
 					KEY MTP_user_id (MTP_user_id)";
257
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
258
-        $table_name = 'esp_event_message_template';
259
-        $sql = "EMT_ID BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
257
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
258
+		$table_name = 'esp_event_message_template';
259
+		$sql = "EMT_ID BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
260 260
 					EVT_ID BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
261 261
 					GRP_ID INT(10) UNSIGNED NOT NULL DEFAULT 0,
262 262
 					PRIMARY KEY  (EMT_ID),
263 263
 					KEY EVT_ID (EVT_ID),
264 264
 					KEY GRP_ID (GRP_ID)";
265
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
266
-        $table_name = 'esp_payment';
267
-        $sql = "PAY_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
265
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
266
+		$table_name = 'esp_payment';
267
+		$sql = "PAY_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
268 268
 					TXN_ID INT(10) UNSIGNED DEFAULT NULL,
269 269
 					STS_ID VARCHAR(3) COLLATE utf8_bin DEFAULT NULL,
270 270
 					PAY_timestamp DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
@@ -281,9 +281,9 @@  discard block
 block discarded – undo
281 281
 					PRIMARY KEY  (PAY_ID),
282 282
 					KEY TXN_ID (TXN_ID),
283 283
 					KEY PAY_timestamp (PAY_timestamp)";
284
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
285
-        $table_name = 'esp_payment_method';
286
-        $sql = "PMD_ID INT(11) NOT NULL AUTO_INCREMENT,
284
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
285
+		$table_name = 'esp_payment_method';
286
+		$sql = "PMD_ID INT(11) NOT NULL AUTO_INCREMENT,
287 287
 				PMD_type VARCHAR(124) DEFAULT NULL,
288 288
 				PMD_name VARCHAR(255) DEFAULT NULL,
289 289
 				PMD_desc TEXT,
@@ -298,28 +298,28 @@  discard block
 block discarded – undo
298 298
 				PMD_scope VARCHAR(255) NULL DEFAULT 'frontend',
299 299
 				PRIMARY KEY  (PMD_ID),
300 300
 				UNIQUE KEY PMD_slug_UNIQUE (PMD_slug)";
301
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
302
-        $table_name = "esp_ticket_price";
303
-        $sql = "TKP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
301
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
302
+		$table_name = "esp_ticket_price";
303
+		$sql = "TKP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
304 304
 					  TKT_ID INT(10) UNSIGNED NOT NULL,
305 305
 					  PRC_ID INT(10) UNSIGNED NOT NULL,
306 306
 					  PRIMARY KEY  (TKP_ID)";
307
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
308
-        $table_name = "esp_datetime_ticket";
309
-        $sql = "DTK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
307
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
308
+		$table_name = "esp_datetime_ticket";
309
+		$sql = "DTK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
310 310
 					  DTT_ID INT(10) UNSIGNED NOT NULL,
311 311
 					  TKT_ID INT(10) UNSIGNED NOT NULL,
312 312
 					  PRIMARY KEY  (DTK_ID)";
313
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
314
-        $table_name = "esp_ticket_template";
315
-        $sql = "TTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
313
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
314
+		$table_name = "esp_ticket_template";
315
+		$sql = "TTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
316 316
 					  TTM_name VARCHAR(45) NOT NULL,
317 317
 					  TTM_description TEXT,
318 318
 					  TTM_file VARCHAR(45),
319 319
 					  PRIMARY KEY  (TTM_ID)";
320
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
321
-        $table_name = 'esp_question';
322
-        $sql = 'QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
320
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
321
+		$table_name = 'esp_question';
322
+		$sql = 'QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
323 323
 					QST_display_text TEXT NOT NULL,
324 324
 					QST_admin_label VARCHAR(255) NOT NULL,
325 325
 					QST_system VARCHAR(25) DEFAULT NULL,
@@ -331,25 +331,25 @@  discard block
 block discarded – undo
331 331
 					QST_wp_user BIGINT UNSIGNED NULL,
332 332
 					QST_deleted TINYINT UNSIGNED NOT NULL DEFAULT 0,
333 333
 					PRIMARY KEY  (QST_ID)';
334
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
335
-        $table_name = 'esp_question_group_question';
336
-        $sql = "QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
334
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
335
+		$table_name = 'esp_question_group_question';
336
+		$sql = "QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
337 337
 					QSG_ID INT UNSIGNED NOT NULL,
338 338
 					QST_ID INT UNSIGNED NOT NULL,
339 339
 					QGQ_order INT UNSIGNED NOT NULL DEFAULT 0,
340 340
 					PRIMARY KEY  (QGQ_ID) ";
341
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
342
-        $table_name = 'esp_question_option';
343
-        $sql = "QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
341
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
342
+		$table_name = 'esp_question_option';
343
+		$sql = "QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
344 344
 					QSO_value VARCHAR(255) NOT NULL,
345 345
 					QSO_desc TEXT NOT NULL,
346 346
 					QST_ID INT UNSIGNED NOT NULL,
347 347
 					QSO_order INT UNSIGNED NOT NULL DEFAULT 0,
348 348
 					QSO_deleted TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
349 349
 					PRIMARY KEY  (QSO_ID)";
350
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
351
-        $table_name = 'esp_registration';
352
-        $sql = "REG_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
350
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
351
+		$table_name = 'esp_registration';
352
+		$sql = "REG_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
353 353
 					  EVT_ID BIGINT(20) UNSIGNED NOT NULL,
354 354
 					  ATT_ID BIGINT(20) UNSIGNED NOT NULL,
355 355
 					  TXN_ID INT(10) UNSIGNED NOT NULL,
@@ -372,25 +372,25 @@  discard block
 block discarded – undo
372 372
 					  KEY STS_ID (STS_ID),
373 373
 					  KEY REG_url_link (REG_url_link),
374 374
 					  KEY REG_code (REG_code)";
375
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
376
-        $table_name = 'esp_checkin';
377
-        $sql = "CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
375
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
376
+		$table_name = 'esp_checkin';
377
+		$sql = "CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
378 378
 					REG_ID INT(10) UNSIGNED NOT NULL,
379 379
 					DTT_ID INT(10) UNSIGNED NOT NULL,
380 380
 					CHK_in TINYINT(1) UNSIGNED NOT NULL DEFAULT 1,
381 381
 					CHK_timestamp DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
382 382
 					PRIMARY KEY  (CHK_ID)";
383
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
384
-        $table_name = 'esp_state';
385
-        $sql = "STA_ID smallint(5) UNSIGNED NOT NULL AUTO_INCREMENT,
383
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
384
+		$table_name = 'esp_state';
385
+		$sql = "STA_ID smallint(5) UNSIGNED NOT NULL AUTO_INCREMENT,
386 386
 					  CNT_ISO VARCHAR(2) COLLATE utf8_bin NOT NULL,
387 387
 					  STA_abbrev VARCHAR(24) COLLATE utf8_bin NOT NULL,
388 388
 					  STA_name VARCHAR(100) COLLATE utf8_bin NOT NULL,
389 389
 					  STA_active TINYINT(1) DEFAULT '1',
390 390
 					  PRIMARY KEY  (STA_ID)";
391
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
392
-        $table_name = 'esp_status';
393
-        $sql = "STS_ID VARCHAR(3) COLLATE utf8_bin NOT NULL,
391
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
392
+		$table_name = 'esp_status';
393
+		$sql = "STS_ID VARCHAR(3) COLLATE utf8_bin NOT NULL,
394 394
 					  STS_code VARCHAR(45) COLLATE utf8_bin NOT NULL,
395 395
 					  STS_type set('event','registration','transaction','payment','email') COLLATE utf8_bin NOT NULL,
396 396
 					  STS_can_edit TINYINT(1) NOT NULL DEFAULT 0,
@@ -398,9 +398,9 @@  discard block
 block discarded – undo
398 398
 					  STS_open TINYINT(1) NOT NULL DEFAULT 1,
399 399
 					  UNIQUE KEY STS_ID_UNIQUE (STS_ID),
400 400
 					  KEY STS_type (STS_type)";
401
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
402
-        $table_name = 'esp_transaction';
403
-        $sql = "TXN_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
401
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
402
+		$table_name = 'esp_transaction';
403
+		$sql = "TXN_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
404 404
 					  TXN_timestamp DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
405 405
 					  TXN_total DECIMAL(10,3) DEFAULT '0.00',
406 406
 					  TXN_paid DECIMAL(10,3) NOT NULL DEFAULT '0.00',
@@ -412,9 +412,9 @@  discard block
 block discarded – undo
412 412
 					  PRIMARY KEY  (TXN_ID),
413 413
 					  KEY TXN_timestamp (TXN_timestamp),
414 414
 					  KEY STS_ID (STS_ID)";
415
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
416
-        $table_name = 'esp_venue_meta';
417
-        $sql = "VNUM_ID INT(11) NOT NULL AUTO_INCREMENT,
415
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
416
+		$table_name = 'esp_venue_meta';
417
+		$sql = "VNUM_ID INT(11) NOT NULL AUTO_INCREMENT,
418 418
 			VNU_ID BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
419 419
 			VNU_address VARCHAR(255) DEFAULT NULL,
420 420
 			VNU_address2 VARCHAR(255) DEFAULT NULL,
@@ -432,10 +432,10 @@  discard block
 block discarded – undo
432 432
 			PRIMARY KEY  (VNUM_ID),
433 433
 			KEY STA_ID (STA_ID),
434 434
 			KEY CNT_ISO (CNT_ISO)";
435
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
436
-        // modified tables
437
-        $table_name = "esp_price";
438
-        $sql = "PRC_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
435
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
436
+		// modified tables
437
+		$table_name = "esp_price";
438
+		$sql = "PRC_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
439 439
 					  PRT_ID TINYINT(3) UNSIGNED NOT NULL,
440 440
 					  PRC_amount DECIMAL(10,3) NOT NULL DEFAULT '0.00',
441 441
 					  PRC_name VARCHAR(245) NOT NULL,
@@ -447,9 +447,9 @@  discard block
 block discarded – undo
447 447
 					  PRC_wp_user BIGINT UNSIGNED NULL,
448 448
 					  PRC_parent INT(10) UNSIGNED DEFAULT 0,
449 449
 					  PRIMARY KEY  (PRC_ID)";
450
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
451
-        $table_name = "esp_price_type";
452
-        $sql = "PRT_ID TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT,
450
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
451
+		$table_name = "esp_price_type";
452
+		$sql = "PRT_ID TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT,
453 453
 				  PRT_name VARCHAR(45) NOT NULL,
454 454
 				  PBT_ID TINYINT(3) UNSIGNED NOT NULL DEFAULT '1',
455 455
 				  PRT_is_percent TINYINT(1) NOT NULL DEFAULT '0',
@@ -458,9 +458,9 @@  discard block
 block discarded – undo
458 458
 				  PRT_deleted TINYINT(1) NOT NULL DEFAULT '0',
459 459
 				  UNIQUE KEY PRT_name_UNIQUE (PRT_name),
460 460
 				  PRIMARY KEY  (PRT_ID)";
461
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
462
-        $table_name = "esp_ticket";
463
-        $sql = "TKT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
461
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
462
+		$table_name = "esp_ticket";
463
+		$sql = "TKT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
464 464
 					  TTM_ID INT(10) UNSIGNED NOT NULL,
465 465
 					  TKT_name VARCHAR(245) NOT NULL DEFAULT '',
466 466
 					  TKT_description TEXT NOT NULL,
@@ -481,10 +481,10 @@  discard block
 block discarded – undo
481 481
 					  TKT_parent INT(10) UNSIGNED DEFAULT '0',
482 482
 					  TKT_deleted TINYINT(1) NOT NULL DEFAULT '0',
483 483
 					  PRIMARY KEY  (TKT_ID)";
484
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
485
-        $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE');
486
-        $table_name = 'esp_question_group';
487
-        $sql = 'QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
484
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
485
+		$this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE');
486
+		$table_name = 'esp_question_group';
487
+		$sql = 'QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
488 488
 					QSG_name VARCHAR(255) NOT NULL,
489 489
 					QSG_identifier VARCHAR(100) NOT NULL,
490 490
 					QSG_desc TEXT NULL,
@@ -496,124 +496,124 @@  discard block
 block discarded – undo
496 496
 					QSG_wp_user BIGINT UNSIGNED NULL,
497 497
 					PRIMARY KEY  (QSG_ID),
498 498
 					UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)';
499
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
500
-        /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */
501
-        $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
502
-        // (because many need to convert old string states to foreign keys into the states table)
503
-        $script_4_1_defaults->insert_default_states();
504
-        $script_4_1_defaults->insert_default_countries();
505
-        /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */
506
-        $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0');
507
-        $script_4_5_defaults->insert_default_price_types();
508
-        $script_4_5_defaults->insert_default_prices();
509
-        $script_4_5_defaults->insert_default_tickets();
510
-        // setting up the config wp option pretty well counts as a 'schema change', or at least should happen here
511
-        EE_Config::instance()->update_espresso_config(false, true);
512
-        $this->add_default_admin_only_payments();
513
-        $this->insert_default_currencies();
514
-        return true;
515
-    }
499
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
500
+		/** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */
501
+		$script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
502
+		// (because many need to convert old string states to foreign keys into the states table)
503
+		$script_4_1_defaults->insert_default_states();
504
+		$script_4_1_defaults->insert_default_countries();
505
+		/** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */
506
+		$script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0');
507
+		$script_4_5_defaults->insert_default_price_types();
508
+		$script_4_5_defaults->insert_default_prices();
509
+		$script_4_5_defaults->insert_default_tickets();
510
+		// setting up the config wp option pretty well counts as a 'schema change', or at least should happen here
511
+		EE_Config::instance()->update_espresso_config(false, true);
512
+		$this->add_default_admin_only_payments();
513
+		$this->insert_default_currencies();
514
+		return true;
515
+	}
516 516
 
517 517
 
518 518
 
519
-    /**
520
-     * @return boolean
521
-     */
522
-    public function schema_changes_after_migration()
523
-    {
524
-        return true;
525
-    }
519
+	/**
520
+	 * @return boolean
521
+	 */
522
+	public function schema_changes_after_migration()
523
+	{
524
+		return true;
525
+	}
526 526
 
527 527
 
528 528
 
529
-    public function migration_page_hooks()
530
-    {
531
-    }
529
+	public function migration_page_hooks()
530
+	{
531
+	}
532 532
 
533 533
 
534 534
 
535
-    public function add_default_admin_only_payments()
536
-    {
537
-        global $wpdb;
538
-        $table_name = $wpdb->prefix . "esp_payment_method";
539
-        $user_id = EEH_Activation::get_default_creator_id();
540
-        if ($this->_get_table_analysis()->tableExists($table_name)) {
541
-            $SQL = "SELECT COUNT( * ) FROM $table_name";
542
-            $existing_payment_methods = $wpdb->get_var($SQL);
543
-            $default_admin_only_payment_methods = apply_filters(
544
-                'FHEE__EEH_Activation__add_default_admin_only_payments__default_admin_only_payment_methods',
545
-                array(
546
-                    __("Bank", 'event_espresso')        => __("Bank Draft", 'event_espresso'),
547
-                    __("Cash", 'event_espresso')        => __("Cash Delivered Physically", 'event_espresso'),
548
-                    __("Check", 'event_espresso')       => __("Paper Check", 'event_espresso'),
549
-                    __("Credit Card", 'event_espresso') => __("Offline Credit Card Payment", 'event_espresso'),
550
-                    __("Debit Card", 'event_espresso')  => __("Offline Debit Payment", 'event_espresso'),
551
-                    __("Invoice", 'event_espresso')     => __(
552
-                        "Invoice received with monies included",
553
-                        'event_espresso'
554
-                    ),
555
-                    __("Money Order", 'event_espresso') => '',
556
-                    __("Paypal", 'event_espresso')      => __("Paypal eCheck, Invoice, etc", 'event_espresso'),
557
-                    __('Other', 'event_espresso')       => __('Other method of payment', 'event_espresso'),
558
-                )
559
-            );
560
-            // make sure we hae payment method records for the following
561
-            // so admins can record payments for them from the admin page
562
-            foreach ($default_admin_only_payment_methods as $nicename => $description) {
563
-                $slug = sanitize_key($nicename);
564
-                // check that such a payment method exists
565
-                $exists = $wpdb->get_var($wpdb->prepare("SELECT count(*) FROM $table_name WHERE PMD_slug = %s", $slug));
566
-                if (! $exists) {
567
-                    $values = array(
568
-                        'PMD_type'       => 'Admin_Only',
569
-                        'PMD_name'       => $nicename,
570
-                        'PMD_admin_name' => $nicename,
571
-                        'PMD_admin_desc' => $description,
572
-                        'PMD_slug'       => $slug,
573
-                        'PMD_wp_user'    => $user_id,
574
-                        'PMD_scope'      => serialize(array('ADMIN')),
575
-                    );
576
-                    $success = $wpdb->insert(
577
-                        $table_name,
578
-                        $values,
579
-                        array(
580
-                            '%s',// PMD_type
581
-                            '%s',// PMD_name
582
-                            '%s',// PMD_admin_name
583
-                            '%s',// PMD_admin_desc
584
-                            '%s',// PMD_slug
585
-                            '%d',// PMD_wp_user
586
-                            '%s',// PMD_scope
587
-                        )
588
-                    );
589
-                    if (! $success) {
590
-                        $this->add_error(sprintf(__(
591
-                            "Could not insert new admin-only payment method with values %s during migration",
592
-                            "event_espresso"
593
-                        ), $this->_json_encode($values)));
594
-                    }
595
-                }
596
-            }
597
-        }
598
-    }
535
+	public function add_default_admin_only_payments()
536
+	{
537
+		global $wpdb;
538
+		$table_name = $wpdb->prefix . "esp_payment_method";
539
+		$user_id = EEH_Activation::get_default_creator_id();
540
+		if ($this->_get_table_analysis()->tableExists($table_name)) {
541
+			$SQL = "SELECT COUNT( * ) FROM $table_name";
542
+			$existing_payment_methods = $wpdb->get_var($SQL);
543
+			$default_admin_only_payment_methods = apply_filters(
544
+				'FHEE__EEH_Activation__add_default_admin_only_payments__default_admin_only_payment_methods',
545
+				array(
546
+					__("Bank", 'event_espresso')        => __("Bank Draft", 'event_espresso'),
547
+					__("Cash", 'event_espresso')        => __("Cash Delivered Physically", 'event_espresso'),
548
+					__("Check", 'event_espresso')       => __("Paper Check", 'event_espresso'),
549
+					__("Credit Card", 'event_espresso') => __("Offline Credit Card Payment", 'event_espresso'),
550
+					__("Debit Card", 'event_espresso')  => __("Offline Debit Payment", 'event_espresso'),
551
+					__("Invoice", 'event_espresso')     => __(
552
+						"Invoice received with monies included",
553
+						'event_espresso'
554
+					),
555
+					__("Money Order", 'event_espresso') => '',
556
+					__("Paypal", 'event_espresso')      => __("Paypal eCheck, Invoice, etc", 'event_espresso'),
557
+					__('Other', 'event_espresso')       => __('Other method of payment', 'event_espresso'),
558
+				)
559
+			);
560
+			// make sure we hae payment method records for the following
561
+			// so admins can record payments for them from the admin page
562
+			foreach ($default_admin_only_payment_methods as $nicename => $description) {
563
+				$slug = sanitize_key($nicename);
564
+				// check that such a payment method exists
565
+				$exists = $wpdb->get_var($wpdb->prepare("SELECT count(*) FROM $table_name WHERE PMD_slug = %s", $slug));
566
+				if (! $exists) {
567
+					$values = array(
568
+						'PMD_type'       => 'Admin_Only',
569
+						'PMD_name'       => $nicename,
570
+						'PMD_admin_name' => $nicename,
571
+						'PMD_admin_desc' => $description,
572
+						'PMD_slug'       => $slug,
573
+						'PMD_wp_user'    => $user_id,
574
+						'PMD_scope'      => serialize(array('ADMIN')),
575
+					);
576
+					$success = $wpdb->insert(
577
+						$table_name,
578
+						$values,
579
+						array(
580
+							'%s',// PMD_type
581
+							'%s',// PMD_name
582
+							'%s',// PMD_admin_name
583
+							'%s',// PMD_admin_desc
584
+							'%s',// PMD_slug
585
+							'%d',// PMD_wp_user
586
+							'%s',// PMD_scope
587
+						)
588
+					);
589
+					if (! $success) {
590
+						$this->add_error(sprintf(__(
591
+							"Could not insert new admin-only payment method with values %s during migration",
592
+							"event_espresso"
593
+						), $this->_json_encode($values)));
594
+					}
595
+				}
596
+			}
597
+		}
598
+	}
599 599
 
600 600
 
601 601
 
602
-    /**
603
-     * insert_default_countries
604
-     *
605
-     * @static
606
-     * @return void
607
-     */
608
-    public function insert_default_currencies()
609
-    {
610
-        global $wpdb;
611
-        $currency_table = $wpdb->prefix . "esp_currency";
612
-        if ($this->_get_table_analysis()->tableExists($currency_table)) {
613
-            $SQL = "SELECT COUNT('CUR_code') FROM $currency_table";
614
-            $countries = $wpdb->get_var($SQL);
615
-            if (! $countries) {
616
-                $SQL = "INSERT INTO $currency_table
602
+	/**
603
+	 * insert_default_countries
604
+	 *
605
+	 * @static
606
+	 * @return void
607
+	 */
608
+	public function insert_default_currencies()
609
+	{
610
+		global $wpdb;
611
+		$currency_table = $wpdb->prefix . "esp_currency";
612
+		if ($this->_get_table_analysis()->tableExists($currency_table)) {
613
+			$SQL = "SELECT COUNT('CUR_code') FROM $currency_table";
614
+			$countries = $wpdb->get_var($SQL);
615
+			if (! $countries) {
616
+				$SQL = "INSERT INTO $currency_table
617 617
 				( CUR_code, CUR_single, CUR_plural, CUR_sign, CUR_dec_plc, CUR_active) VALUES
618 618
 				( 'EUR',  'Euro',  'Euros',  '€',  2,1),
619 619
 				( 'AED',  'Dirham',  'Dirhams', 'د.إ',2,1),
@@ -767,8 +767,8 @@  discard block
 block discarded – undo
767 767
 				( 'ZAR',  'Rand',  'Rands',  'R',  2,1),
768 768
 				( 'ZMK',  'Kwacha',  'Kwachas',  '',  2,1),
769 769
 				( 'ZWD', 'Dollar', 'Dollars', 'Z$', 2,1);";
770
-                $wpdb->query($SQL);
771
-            }
772
-        }
773
-    }
770
+				$wpdb->query($SQL);
771
+			}
772
+		}
773
+	}
774 774
 }
Please login to merge, or discard this patch.
core/helpers/EEH_Venue_View.helper.php 1 patch
Indentation   +534 added lines, -535 removed lines patch added patch discarded remove patch
@@ -11,539 +11,538 @@
 block discarded – undo
11 11
 class EEH_Venue_View extends EEH_Base
12 12
 {
13 13
 
14
-    /**
15
-     * @access    private
16
-     * @var EE_Venue
17
-     */
18
-    private static $_venue = null;
19
-
20
-
21
-
22
-    /**
23
-     *    get_venue
24
-     *    attempts to retrieve an EE_Venue object any way it can
25
-     *
26
-     * @access    public
27
-     * @param int  $VNU_ID
28
-     * @param bool $look_in_event
29
-     * @param bool $privacy_check   Defaults to true.
30
-     *                              When false, means even if the venue is private we return it regardless of access.
31
-     * @param bool $password_check
32
-     * @return \EE_Venue|null
33
-     */
34
-    public static function get_venue($VNU_ID = 0, $look_in_event = true, $privacy_check = true, $password_check = true)
35
-    {
36
-        $VNU_ID = absint($VNU_ID);
37
-        // do we already have the Venue you are looking for?
38
-        if (EEH_Venue_View::$_venue instanceof EE_Venue && $VNU_ID) {
39
-            // If the Venue ID matches $VNU_ID, return the venue.
40
-            if (EEH_Venue_View::$_venue->ID() === $VNU_ID) {
41
-                return EEH_Venue_View::_get_venue($privacy_check);
42
-            }
43
-            // If the Venue ID does not match, try pulling a venue using $VNU_ID.
44
-            $venue = EEM_Venue::instance()->get_one_by_ID($VNU_ID);
45
-            if ($venue instanceof EE_Venue) {
46
-                EEH_Venue_View::$_venue = $venue;
47
-                return EEH_Venue_View::_get_venue($privacy_check);
48
-            }
49
-        }
50
-        // international newspaper?
51
-        global $post;
52
-        if ($post instanceof WP_Post) {
53
-            switch ($post->post_type) {
54
-                // if this is being called from an EE_Venue post,
55
-                // and the EE_Venue post corresponds to the EE_Venue that is being asked for,
56
-                // then we can try to just grab the attached EE_Venue object
57
-                case 'espresso_venues':
58
-                    // the post already contains the related EE_Venue object AND one of the following is TRUE:
59
-                    // the requested Venue ID matches the post ID OR...
60
-                    // there was no specific Venue ID requested
61
-                    if (isset($post->EE_Venue) && ( $VNU_ID == $post->ID || ! $VNU_ID )) {
62
-                        // use existing related EE_Venue object
63
-                        EEH_Venue_View::$_venue =  $post->EE_Venue;
64
-                    } elseif ($VNU_ID) {
65
-                        // there WAS a specific Venue ID requested, but it's NOT the current post object
66
-                        EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID($VNU_ID);
67
-                    } else {
68
-                        // no specific Venue ID requested, so use post ID to generate EE_Venue object
69
-                        EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID($post->ID);
70
-                    }
71
-                    break;
72
-
73
-                case 'espresso_events':
74
-                    if ($look_in_event) {
75
-                        // grab the events related venues
76
-                        $venues = EEH_Venue_View::get_event_venues();
77
-                        // make sure the result is an array
78
-                        $venues = is_array($venues) ? $venues : array();
79
-                        // do we have an ID for a specific venue?
80
-                        if ($VNU_ID) {
81
-                            // loop thru the related venues
82
-                            foreach ($venues as $venue) {
83
-                                if ($venue instanceof EE_Venue) {
84
-                                    // until we find the venue we're looking for
85
-                                    if ($venue->ID() == $VNU_ID) {
86
-                                        EEH_Venue_View::$_venue = $venue;
87
-                                        break;
88
-                                    }
89
-                                }
90
-                            }
91
-                        // no venue ID ?
92
-                        // then the global post is an events post and this function was called with no argument
93
-                        } else {
94
-                            // just grab the first related event venue
95
-                            EEH_Venue_View::$_venue = reset($venues);
96
-                        }
97
-                    }
98
-                    break;
99
-            }
100
-        }
101
-        // now if we STILL do NOT have an EE_Venue model object, BUT we have a Venue ID...
102
-        if (! EEH_Venue_View::$_venue instanceof EE_Venue && $VNU_ID) {
103
-            // sigh... pull it from the db
104
-            EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID($VNU_ID);
105
-        }
106
-        return EEH_Venue_View::_get_venue($privacy_check, $password_check);
107
-    }
108
-
109
-
110
-
111
-    /**
112
-     * return a single venue
113
-     *
114
-     * @param bool $privacy_check   Defaults to true.
115
-     *                              When false, means even if the venue is private we return it regardless of access.
116
-     * @param bool $password_check
117
-     * @return  EE_Venue
118
-     */
119
-    protected static function _get_venue($privacy_check = true, $password_check = true)
120
-    {
121
-        // check for private venues.
122
-        if (EEH_Venue_View::$_venue instanceof EE_Venue
123
-            && EEH_Venue_View::$_venue->status() == 'private'
124
-            && $privacy_check
125
-            && ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_venues', 'get_venues')
126
-        ) {
127
-            return null;
128
-        }
129
-        // check for password protected venues
130
-        if (EEH_Venue_View::$_venue instanceof EE_Venue
131
-            && $password_check
132
-            && post_password_required(EEH_Venue_View::$_venue->ID())
133
-        ) {
134
-            return null;
135
-        }
136
-        return EEH_Venue_View::$_venue instanceof EE_Venue ? EEH_Venue_View::$_venue : null;
137
-    }
138
-
139
-
140
-
141
-    /**
142
-     *  get_event_venues
143
-     *
144
-     *  @access     public
145
-     *  @return     EE_Venue[]
146
-     */
147
-    public static function get_event_venues()
148
-    {
149
-        global $post;
150
-        if ($post->post_type == 'espresso_events') {
151
-            if (isset($post->EE_Event) && $post->EE_Event instanceof EE_Event) {
152
-                return $post->EE_Event->venues();
153
-            }
154
-        }
155
-        return array();
156
-    }
157
-
158
-
159
-
160
-
161
-    /**
162
-     * Simply checks whether a venue for the given ID (or the internally derived venue is private).
163
-     *
164
-     * Note: This will return true if its private, null if the venue doesn't exist, and false, if the venue exists but is not
165
-     *    private.  So it is important to do explicit boolean checks when using this conditional.
166
-     *
167
-     * @param bool $VNU_ID venue to check (optional). If not included will use internally derived venue object.
168
-     *
169
-     * @return bool|null
170
-     */
171
-    public static function is_venue_private($VNU_ID = false)
172
-    {
173
-        $venue = EEH_Venue_View::get_venue($VNU_ID, true, true);
174
-        if (! $venue instanceof EE_Venue) {
175
-            return null;
176
-        }
177
-
178
-        return $venue->status() == 'private' ? true : false;
179
-    }
180
-
181
-
182
-
183
-
184
-    /**
185
-     * returns true or false if a venue is password protected or not
186
-     * @param bool $VNU_ID venue to check (optional). If not included will use internally derived venue object.
187
-     * @return bool
188
-     */
189
-    public static function is_venue_password_protected($VNU_ID = false)
190
-    {
191
-        $venue = EEH_Venue_View::get_venue($VNU_ID, true, true, false);
192
-        if ($venue instanceof EE_Venue
193
-            && post_password_required($venue->ID())
194
-        ) {
195
-            return true;
196
-        }
197
-        return false;
198
-    }
199
-
200
-
201
-
202
-    /**
203
-     * If a venue is password protected, this will return the password form for gaining access
204
-     * returns an empty string otherwise
205
-
206
-     * @param bool $VNU_ID venue to check (optional). If not included will use internally derived venue object.
207
-     *
208
-     * @return string
209
-     */
210
-    public static function password_protected_venue_form($VNU_ID = false)
211
-    {
212
-        $venue = EEH_Venue_View::get_venue($VNU_ID, true, true, false);
213
-        if ($venue instanceof EE_Venue
214
-            && post_password_required($venue->ID())
215
-        ) {
216
-            return get_the_password_form($venue->ID());
217
-        }
218
-        return '';
219
-    }
220
-
221
-
222
-
223
-    /**
224
-     *    venue_description
225
-     *
226
-     * @access    public
227
-     * @param int $VNU_ID
228
-     * @return string
229
-     */
230
-    public static function venue_description($VNU_ID = 0)
231
-    {
232
-        $venue = EEH_Venue_View::get_venue($VNU_ID);
233
-        if ($venue instanceof EE_Venue) {
234
-            return $venue->get_pretty('VNU_desc');
235
-        }
236
-        return '';
237
-    }
238
-
239
-
240
-
241
-    /**
242
-     *    venue_excerpt
243
-     *
244
-     * @access    public
245
-     * @param int $VNU_ID
246
-     * @return string
247
-     */
248
-    public static function venue_excerpt($VNU_ID = 0)
249
-    {
250
-        $venue = EEH_Venue_View::get_venue($VNU_ID);
251
-        if ($venue instanceof EE_Venue) {
252
-            $excerpt = $venue->excerpt() != null && $venue->excerpt() ? $venue->excerpt() : $venue->description();
253
-            $venue_link = ' ' . EEH_Venue_View::venue_details_link($venue->ID(), __('more', 'event_espresso') . '&hellip;');
254
-            return ! empty($excerpt) ? wp_trim_words($excerpt, 25, '') . $venue_link : '';
255
-        }
256
-        return '';
257
-    }
258
-
259
-
260
-
261
-    /**
262
-     *    venue_categories
263
-     *
264
-     * @access    public
265
-     * @param int $VNU_ID
266
-     * @param bool $hide_uncategorized
267
-     * @return string
268
-     */
269
-    public static function venue_categories($VNU_ID = 0, $hide_uncategorized = true)
270
-    {
271
-        $category_links = array();
272
-        $venue = EEH_Venue_View::get_venue($VNU_ID);
273
-        if ($venue instanceof EE_Venue) {
274
-            // get category terms
275
-            if ($venue_categories = get_the_terms($venue->ID(), 'espresso_venue_categories')) {
276
-                // loop thru terms and create links
277
-                foreach ($venue_categories as $term) {
278
-                    $url = get_term_link($term, 'espresso_venue_categories');
279
-                    if (! is_wp_error($url) && (( $hide_uncategorized && strtolower($term->name) != __('uncategorized', 'event_espresso')) || ! $hide_uncategorized )) {
280
-                        $category_links[] = '<a href="' . esc_url($url) . '" rel="tag">' . $term->name . '</a> ';
281
-                    }
282
-                }
283
-            }
284
-        }
285
-        return implode(', ', $category_links);
286
-    }
287
-
288
-
289
-
290
-    /**
291
-     *    venue_address
292
-     *
293
-     * @access    public
294
-     * @param string $type
295
-     * @param int $VNU_ID
296
-     * @param bool $use_schema
297
-     * @param bool $add_wrapper
298
-     * @return string
299
-     */
300
-    public static function venue_address($type = 'multiline', $VNU_ID = 0, $use_schema = true, $add_wrapper = true)
301
-    {
302
-        $venue = EEH_Venue_View::get_venue($VNU_ID);
303
-        if ($venue instanceof EE_Venue) {
304
-            return EEH_Address::format($venue, $type, $use_schema, $add_wrapper);
305
-        }
306
-        return '';
307
-    }
308
-
309
-
310
-
311
-    /**
312
-     *    venue_has_address
313
-     *
314
-     * @access    public
315
-     * @param int $VNU_ID
316
-     * @return bool|string
317
-     */
318
-    public static function venue_has_address($VNU_ID = 0)
319
-    {
320
-        $venue = EEH_Venue_View::get_venue($VNU_ID);
321
-        if ($venue instanceof EE_Venue) {
322
-            return EEH_Address::format($venue, 'inline', false, false);
323
-        }
324
-        return false;
325
-    }
326
-
327
-
328
-
329
-    /**
330
-     *    venue_name
331
-     *
332
-     * @access    public
333
-     * @param    string $link_to - options( details, website, none ) whether to turn Venue name into a clickable link to the Venue's details page or website
334
-     * @param int $VNU_ID
335
-     * @return string
336
-     */
337
-    public static function venue_name($link_to = 'details', $VNU_ID = 0)
338
-    {
339
-        $venue = EEH_Venue_View::get_venue($VNU_ID);
340
-        if ($venue instanceof EE_Venue) {
341
-            $venue_name = apply_filters(
342
-                'FHEE__EEH_Venue__venue_name__append_private_venue_name',
343
-                EEH_Venue_View::is_venue_private()
344
-                    ? EEH_Venue_View::$_venue->name() . "&nbsp;" . __('(Private)', 'event_espresso')
345
-                    : EEH_Venue_View::$_venue->name(),
346
-                EEH_Venue_View::$_venue
347
-            );
348
-            $venue_name = EEH_Schema::name($venue_name);
349
-
350
-            // if venue is trashed then ignore the "link to" setting because the venue is trashed.
351
-            if ($venue->get('status') == 'trash') {
352
-                $link_to = '';
353
-            }
354
-            switch ($link_to) {
355
-                case 'details':
356
-                    return EEH_Venue_View::venue_details_link($venue->ID(), $venue_name);
357
-                break;
358
-
359
-                case 'website':
360
-                    return EEH_Venue_View::venue_website_link($venue->ID(), $venue_name);
361
-                break;
362
-
363
-                default:
364
-                    return $venue_name;
365
-            }
366
-        }
367
-        return '';
368
-    }
369
-
370
-
371
-
372
-    /**
373
-     *    venue_details_link
374
-     *
375
-     * @access    public
376
-     * @param int $VNU_ID
377
-     * @param    string $text
378
-     * @return string
379
-     */
380
-    public static function venue_details_link($VNU_ID = 0, $text = '')
381
-    {
382
-        $venue = EEH_Venue_View::get_venue($VNU_ID);
383
-        if ($venue instanceof EE_Venue) {
384
-            return EEH_Schema::url(get_permalink($venue->ID()), $text);
385
-        }
386
-        return '';
387
-    }
388
-
389
-
390
-
391
-    /**
392
-     *    venue_website_link
393
-     *
394
-     * @access    public
395
-     * @param int $VNU_ID
396
-     * @param    string $text
397
-     * @return string
398
-     */
399
-    public static function venue_website_link($VNU_ID = 0, $text = '')
400
-    {
401
-        $venue = EEH_Venue_View::get_venue($VNU_ID);
402
-        if ($venue instanceof EE_Venue) {
403
-            $url = $venue->venue_url();
404
-            $text = ! empty($text) ? $text : $url;
405
-            return ! empty($url) ? EEH_Schema::url($url, $text) : '';
406
-        }
407
-        return '';
408
-    }
409
-
410
-
411
-
412
-    /**
413
-     *    venue_phone
414
-     *
415
-     * @access    public
416
-     * @param int $VNU_ID
417
-     * @return string
418
-     */
419
-    public static function venue_phone($VNU_ID = 0)
420
-    {
421
-        $venue = EEH_Venue_View::get_venue($VNU_ID);
422
-        if ($venue instanceof EE_Venue) {
423
-            return EEH_Schema::telephone($venue->phone());
424
-        }
425
-        return '';
426
-    }
427
-
428
-
429
-
430
-    /**
431
-     *    venue_gmap
432
-     *
433
-     * @access    public
434
-     * @param int $VNU_ID
435
-     * @param bool|string $map_ID a unique identifier for this map
436
-     * @param    array $gmap map options
437
-     * @return string
438
-     */
439
-    public static function venue_gmap($VNU_ID = 0, $map_ID = false, $gmap = array())
440
-    {
441
-
442
-        $venue = EEH_Venue_View::get_venue($VNU_ID);
443
-        if ($venue instanceof EE_Venue) {
444
-            // check for global espresso_events post and use it's ID if no map_ID is set
445
-            global $post;
446
-            $map_ID = empty($map_ID) && $post->post_type == 'espresso_events' ? $post->ID : $map_ID;
447
-            // grab map settings
448
-            $map_cfg = EE_Registry::instance()->CFG->map_settings;
449
-            // are maps enabled ?
450
-            if ($map_cfg->use_google_maps && $venue->enable_for_gmap()) {
451
-                $details_page = is_single();
452
-                $options = array();
453
-                $options['map_ID'] = $map_ID && $map_ID != $venue->ID() ? $map_ID . '-' . $venue->ID()/* . '-' . $static_map_id*/ : $venue->ID()/* . '-' . $static_map_id*/;
454
-
455
-                $options['location'] = EEH_Address::format($venue, 'inline', false, false);
456
-
457
-                $options['ee_map_width'] = $details_page ? $map_cfg->event_details_map_width : $map_cfg->event_list_map_width;
458
-                $options['ee_map_width'] = isset($gmap['ee_map_width']) && ! empty($gmap['ee_map_width']) ? $gmap['ee_map_width'] : $options['ee_map_width'];
459
-
460
-                $options['ee_map_height'] = $details_page ? $map_cfg->event_details_map_height : $map_cfg->event_list_map_height;
461
-                $options['ee_map_height'] = isset($gmap['ee_map_height']) && ! empty($gmap['ee_map_height']) ? $gmap['ee_map_height'] : $options['ee_map_height'];
462
-
463
-                $options['ee_map_zoom'] = $details_page ? $map_cfg->event_details_map_zoom : $map_cfg->event_list_map_zoom;
464
-                $options['ee_map_zoom'] = isset($gmap['ee_map_zoom']) && ! empty($gmap['ee_map_zoom']) ? $gmap['ee_map_zoom'] : $options['ee_map_zoom'];
465
-
466
-                $options['ee_map_nav_display'] = $details_page ? $map_cfg->event_details_display_nav : $map_cfg->event_list_display_nav;
467
-                $options['ee_map_nav_display'] = isset($gmap['ee_map_nav_display']) && ! empty($gmap['ee_map_nav_display']) ? 'true' : $options['ee_map_nav_display'];
468
-                ;
469
-
470
-                $options['ee_map_nav_size'] = $details_page ? $map_cfg->event_details_nav_size : $map_cfg->event_list_nav_size;
471
-                $options['ee_map_nav_size'] =  isset($gmap['ee_map_nav_size']) && ! empty($gmap['ee_map_nav_size'])? $gmap['ee_map_nav_size'] : $options['ee_map_nav_size'];
472
-
473
-                $options['ee_map_type_control'] = $details_page ? $map_cfg->event_details_control_type : $map_cfg->event_list_control_type;
474
-                $options['ee_map_type_control'] =  isset($gmap['ee_map_type_control']) && ! empty($gmap['ee_map_type_control'])? $gmap['ee_map_type_control'] : $options['ee_map_type_control'];
475
-
476
-                $options['ee_map_align'] = $details_page ? $map_cfg->event_details_map_align : $map_cfg->event_list_map_align;
477
-                $options['ee_map_align'] =  isset($gmap['ee_map_align']) && ! empty($gmap['ee_map_align'])? $gmap['ee_map_align'] : $options['ee_map_align'];
478
-
479
-                $options['ee_static_url'] =  isset($gmap['ee_static_url']) && ! empty($gmap['ee_static_url']) ? (bool) absint($gmap['ee_static_url']) : $venue->google_map_link();
480
-
481
-                return EEH_Maps::google_map($options);
482
-            }
483
-        }
484
-
485
-        return '';
486
-    }
487
-
488
-    /**
489
-     * Gets the HTML to display a static map of the venue
490
-     * @param EE_Venue $venue
491
-     * @param array $atts like EEH_Maps::google_map_link
492
-     * @return string
493
-     */
494
-    public static function espresso_google_static_map(EE_Venue $venue, $atts = array())
495
-    {
496
-        $state = $venue->state_obj();
497
-        $country = $venue->country_obj();
498
-        $atts = shortcode_atts(
499
-            array(
500
-                    'id' => $venue->ID(),
501
-                    'address' => $venue->get('VNU_address'),
502
-                    'city' => $venue->get('VNU_city'),
503
-                    'state' => $state instanceof EE_State ? $state->name() : '',
504
-                    'zip' => $venue->get('VNU_zip'),
505
-                    'country' => $country instanceof EE_Country ? $country->name() : '',
506
-                    'type' => 'map',
507
-                    'map_w' => 200,
508
-                    'map_h' => 200
509
-                    ),
510
-            $atts
511
-        );
512
-        return EEH_Maps::google_map_link($atts);
513
-    }
514
-
515
-
516
-
517
-    /**
518
-     *    edit_venue_link
519
-     *
520
-     * @access    public
521
-     * @param int $VNU_ID
522
-     * @param string $link
523
-     * @param string $before
524
-     * @param string $after
525
-     * @return string
526
-     */
527
-    public static function edit_venue_link($VNU_ID = 0, $link = '', $before = '<p class="edit-venue-lnk small-txt">', $after = '</p>')
528
-    {
529
-        $venue = EEH_Venue_View::get_venue($VNU_ID);
530
-        if ($venue instanceof EE_Venue) {
531
-            // can the user edit this post ?
532
-            if (current_user_can('edit_post', $venue->ID())) {
533
-                // set link text
534
-                $link = ! empty($link) ? $link : __('edit this venue', 'event_espresso');
535
-                // generate nonce
536
-                $nonce = wp_create_nonce('edit_nonce');
537
-                // generate url to venue editor for this venue
538
-                $url = add_query_arg(array( 'page' => 'espresso_venues', 'action' => 'edit', 'post' => $venue->ID(), 'edit_nonce' => $nonce ), admin_url('admin.php'));
539
-                // get edit CPT text
540
-                $post_type_obj = get_post_type_object('espresso_venues');
541
-                // build final link html
542
-                $link = '<a class="post-edit-link" href="' . $url . '" title="' . esc_attr($post_type_obj->labels->edit_item) . '">' . $link . '</a>';
543
-                // put it all together
544
-                return $before . apply_filters('edit_post_link', $link, $venue->ID()) . $after;
545
-            }
546
-        }
547
-        return '';
548
-    }
14
+	/**
15
+	 * @access    private
16
+	 * @var EE_Venue
17
+	 */
18
+	private static $_venue = null;
19
+
20
+
21
+
22
+	/**
23
+	 *    get_venue
24
+	 *    attempts to retrieve an EE_Venue object any way it can
25
+	 *
26
+	 * @access    public
27
+	 * @param int  $VNU_ID
28
+	 * @param bool $look_in_event
29
+	 * @param bool $privacy_check   Defaults to true.
30
+	 *                              When false, means even if the venue is private we return it regardless of access.
31
+	 * @param bool $password_check
32
+	 * @return \EE_Venue|null
33
+	 */
34
+	public static function get_venue($VNU_ID = 0, $look_in_event = true, $privacy_check = true, $password_check = true)
35
+	{
36
+		$VNU_ID = absint($VNU_ID);
37
+		// do we already have the Venue you are looking for?
38
+		if (EEH_Venue_View::$_venue instanceof EE_Venue && $VNU_ID) {
39
+			// If the Venue ID matches $VNU_ID, return the venue.
40
+			if (EEH_Venue_View::$_venue->ID() === $VNU_ID) {
41
+				return EEH_Venue_View::_get_venue($privacy_check);
42
+			}
43
+			// If the Venue ID does not match, try pulling a venue using $VNU_ID.
44
+			$venue = EEM_Venue::instance()->get_one_by_ID($VNU_ID);
45
+			if ($venue instanceof EE_Venue) {
46
+				EEH_Venue_View::$_venue = $venue;
47
+				return EEH_Venue_View::_get_venue($privacy_check);
48
+			}
49
+		}
50
+		// international newspaper?
51
+		global $post;
52
+		if ($post instanceof WP_Post) {
53
+			switch ($post->post_type) {
54
+				// if this is being called from an EE_Venue post,
55
+				// and the EE_Venue post corresponds to the EE_Venue that is being asked for,
56
+				// then we can try to just grab the attached EE_Venue object
57
+				case 'espresso_venues':
58
+					// the post already contains the related EE_Venue object AND one of the following is TRUE:
59
+					// the requested Venue ID matches the post ID OR...
60
+					// there was no specific Venue ID requested
61
+					if (isset($post->EE_Venue) && ( $VNU_ID == $post->ID || ! $VNU_ID )) {
62
+						// use existing related EE_Venue object
63
+						EEH_Venue_View::$_venue =  $post->EE_Venue;
64
+					} elseif ($VNU_ID) {
65
+						// there WAS a specific Venue ID requested, but it's NOT the current post object
66
+						EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID($VNU_ID);
67
+					} else {
68
+						// no specific Venue ID requested, so use post ID to generate EE_Venue object
69
+						EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID($post->ID);
70
+					}
71
+					break;
72
+
73
+				case 'espresso_events':
74
+					if ($look_in_event) {
75
+						// grab the events related venues
76
+						$venues = EEH_Venue_View::get_event_venues();
77
+						// make sure the result is an array
78
+						$venues = is_array($venues) ? $venues : array();
79
+						// do we have an ID for a specific venue?
80
+						if ($VNU_ID) {
81
+							// loop thru the related venues
82
+							foreach ($venues as $venue) {
83
+								if ($venue instanceof EE_Venue) {
84
+									// until we find the venue we're looking for
85
+									if ($venue->ID() == $VNU_ID) {
86
+										EEH_Venue_View::$_venue = $venue;
87
+										break;
88
+									}
89
+								}
90
+							}
91
+						// no venue ID ?
92
+						// then the global post is an events post and this function was called with no argument
93
+						} else {
94
+							// just grab the first related event venue
95
+							EEH_Venue_View::$_venue = reset($venues);
96
+						}
97
+					}
98
+					break;
99
+			}
100
+		}
101
+		// now if we STILL do NOT have an EE_Venue model object, BUT we have a Venue ID...
102
+		if (! EEH_Venue_View::$_venue instanceof EE_Venue && $VNU_ID) {
103
+			// sigh... pull it from the db
104
+			EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID($VNU_ID);
105
+		}
106
+		return EEH_Venue_View::_get_venue($privacy_check, $password_check);
107
+	}
108
+
109
+
110
+
111
+	/**
112
+	 * return a single venue
113
+	 *
114
+	 * @param bool $privacy_check   Defaults to true.
115
+	 *                              When false, means even if the venue is private we return it regardless of access.
116
+	 * @param bool $password_check
117
+	 * @return  EE_Venue
118
+	 */
119
+	protected static function _get_venue($privacy_check = true, $password_check = true)
120
+	{
121
+		// check for private venues.
122
+		if (EEH_Venue_View::$_venue instanceof EE_Venue
123
+			&& EEH_Venue_View::$_venue->status() == 'private'
124
+			&& $privacy_check
125
+			&& ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_venues', 'get_venues')
126
+		) {
127
+			return null;
128
+		}
129
+		// check for password protected venues
130
+		if (EEH_Venue_View::$_venue instanceof EE_Venue
131
+			&& $password_check
132
+			&& post_password_required(EEH_Venue_View::$_venue->ID())
133
+		) {
134
+			return null;
135
+		}
136
+		return EEH_Venue_View::$_venue instanceof EE_Venue ? EEH_Venue_View::$_venue : null;
137
+	}
138
+
139
+
140
+
141
+	/**
142
+	 *  get_event_venues
143
+	 *
144
+	 *  @access     public
145
+	 *  @return     EE_Venue[]
146
+	 */
147
+	public static function get_event_venues()
148
+	{
149
+		global $post;
150
+		if ($post->post_type == 'espresso_events') {
151
+			if (isset($post->EE_Event) && $post->EE_Event instanceof EE_Event) {
152
+				return $post->EE_Event->venues();
153
+			}
154
+		}
155
+		return array();
156
+	}
157
+
158
+
159
+
160
+
161
+	/**
162
+	 * Simply checks whether a venue for the given ID (or the internally derived venue is private).
163
+	 *
164
+	 * Note: This will return true if its private, null if the venue doesn't exist, and false, if the venue exists but is not
165
+	 *    private.  So it is important to do explicit boolean checks when using this conditional.
166
+	 *
167
+	 * @param bool $VNU_ID venue to check (optional). If not included will use internally derived venue object.
168
+	 *
169
+	 * @return bool|null
170
+	 */
171
+	public static function is_venue_private($VNU_ID = false)
172
+	{
173
+		$venue = EEH_Venue_View::get_venue($VNU_ID, true, true);
174
+		if (! $venue instanceof EE_Venue) {
175
+			return null;
176
+		}
177
+
178
+		return $venue->status() == 'private' ? true : false;
179
+	}
180
+
181
+
182
+
183
+
184
+	/**
185
+	 * returns true or false if a venue is password protected or not
186
+	 * @param bool $VNU_ID venue to check (optional). If not included will use internally derived venue object.
187
+	 * @return bool
188
+	 */
189
+	public static function is_venue_password_protected($VNU_ID = false)
190
+	{
191
+		$venue = EEH_Venue_View::get_venue($VNU_ID, true, true, false);
192
+		if ($venue instanceof EE_Venue
193
+			&& post_password_required($venue->ID())
194
+		) {
195
+			return true;
196
+		}
197
+		return false;
198
+	}
199
+
200
+
201
+
202
+	/**
203
+	 * If a venue is password protected, this will return the password form for gaining access
204
+	 * returns an empty string otherwise
205
+	 * @param bool $VNU_ID venue to check (optional). If not included will use internally derived venue object.
206
+	 *
207
+	 * @return string
208
+	 */
209
+	public static function password_protected_venue_form($VNU_ID = false)
210
+	{
211
+		$venue = EEH_Venue_View::get_venue($VNU_ID, true, true, false);
212
+		if ($venue instanceof EE_Venue
213
+			&& post_password_required($venue->ID())
214
+		) {
215
+			return get_the_password_form($venue->ID());
216
+		}
217
+		return '';
218
+	}
219
+
220
+
221
+
222
+	/**
223
+	 *    venue_description
224
+	 *
225
+	 * @access    public
226
+	 * @param int $VNU_ID
227
+	 * @return string
228
+	 */
229
+	public static function venue_description($VNU_ID = 0)
230
+	{
231
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
232
+		if ($venue instanceof EE_Venue) {
233
+			return $venue->get_pretty('VNU_desc');
234
+		}
235
+		return '';
236
+	}
237
+
238
+
239
+
240
+	/**
241
+	 *    venue_excerpt
242
+	 *
243
+	 * @access    public
244
+	 * @param int $VNU_ID
245
+	 * @return string
246
+	 */
247
+	public static function venue_excerpt($VNU_ID = 0)
248
+	{
249
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
250
+		if ($venue instanceof EE_Venue) {
251
+			$excerpt = $venue->excerpt() != null && $venue->excerpt() ? $venue->excerpt() : $venue->description();
252
+			$venue_link = ' ' . EEH_Venue_View::venue_details_link($venue->ID(), __('more', 'event_espresso') . '&hellip;');
253
+			return ! empty($excerpt) ? wp_trim_words($excerpt, 25, '') . $venue_link : '';
254
+		}
255
+		return '';
256
+	}
257
+
258
+
259
+
260
+	/**
261
+	 *    venue_categories
262
+	 *
263
+	 * @access    public
264
+	 * @param int $VNU_ID
265
+	 * @param bool $hide_uncategorized
266
+	 * @return string
267
+	 */
268
+	public static function venue_categories($VNU_ID = 0, $hide_uncategorized = true)
269
+	{
270
+		$category_links = array();
271
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
272
+		if ($venue instanceof EE_Venue) {
273
+			// get category terms
274
+			if ($venue_categories = get_the_terms($venue->ID(), 'espresso_venue_categories')) {
275
+				// loop thru terms and create links
276
+				foreach ($venue_categories as $term) {
277
+					$url = get_term_link($term, 'espresso_venue_categories');
278
+					if (! is_wp_error($url) && (( $hide_uncategorized && strtolower($term->name) != __('uncategorized', 'event_espresso')) || ! $hide_uncategorized )) {
279
+						$category_links[] = '<a href="' . esc_url($url) . '" rel="tag">' . $term->name . '</a> ';
280
+					}
281
+				}
282
+			}
283
+		}
284
+		return implode(', ', $category_links);
285
+	}
286
+
287
+
288
+
289
+	/**
290
+	 *    venue_address
291
+	 *
292
+	 * @access    public
293
+	 * @param string $type
294
+	 * @param int $VNU_ID
295
+	 * @param bool $use_schema
296
+	 * @param bool $add_wrapper
297
+	 * @return string
298
+	 */
299
+	public static function venue_address($type = 'multiline', $VNU_ID = 0, $use_schema = true, $add_wrapper = true)
300
+	{
301
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
302
+		if ($venue instanceof EE_Venue) {
303
+			return EEH_Address::format($venue, $type, $use_schema, $add_wrapper);
304
+		}
305
+		return '';
306
+	}
307
+
308
+
309
+
310
+	/**
311
+	 *    venue_has_address
312
+	 *
313
+	 * @access    public
314
+	 * @param int $VNU_ID
315
+	 * @return bool|string
316
+	 */
317
+	public static function venue_has_address($VNU_ID = 0)
318
+	{
319
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
320
+		if ($venue instanceof EE_Venue) {
321
+			return EEH_Address::format($venue, 'inline', false, false);
322
+		}
323
+		return false;
324
+	}
325
+
326
+
327
+
328
+	/**
329
+	 *    venue_name
330
+	 *
331
+	 * @access    public
332
+	 * @param    string $link_to - options( details, website, none ) whether to turn Venue name into a clickable link to the Venue's details page or website
333
+	 * @param int $VNU_ID
334
+	 * @return string
335
+	 */
336
+	public static function venue_name($link_to = 'details', $VNU_ID = 0)
337
+	{
338
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
339
+		if ($venue instanceof EE_Venue) {
340
+			$venue_name = apply_filters(
341
+				'FHEE__EEH_Venue__venue_name__append_private_venue_name',
342
+				EEH_Venue_View::is_venue_private()
343
+					? EEH_Venue_View::$_venue->name() . "&nbsp;" . __('(Private)', 'event_espresso')
344
+					: EEH_Venue_View::$_venue->name(),
345
+				EEH_Venue_View::$_venue
346
+			);
347
+			$venue_name = EEH_Schema::name($venue_name);
348
+
349
+			// if venue is trashed then ignore the "link to" setting because the venue is trashed.
350
+			if ($venue->get('status') == 'trash') {
351
+				$link_to = '';
352
+			}
353
+			switch ($link_to) {
354
+				case 'details':
355
+					return EEH_Venue_View::venue_details_link($venue->ID(), $venue_name);
356
+				break;
357
+
358
+				case 'website':
359
+					return EEH_Venue_View::venue_website_link($venue->ID(), $venue_name);
360
+				break;
361
+
362
+				default:
363
+					return $venue_name;
364
+			}
365
+		}
366
+		return '';
367
+	}
368
+
369
+
370
+
371
+	/**
372
+	 *    venue_details_link
373
+	 *
374
+	 * @access    public
375
+	 * @param int $VNU_ID
376
+	 * @param    string $text
377
+	 * @return string
378
+	 */
379
+	public static function venue_details_link($VNU_ID = 0, $text = '')
380
+	{
381
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
382
+		if ($venue instanceof EE_Venue) {
383
+			return EEH_Schema::url(get_permalink($venue->ID()), $text);
384
+		}
385
+		return '';
386
+	}
387
+
388
+
389
+
390
+	/**
391
+	 *    venue_website_link
392
+	 *
393
+	 * @access    public
394
+	 * @param int $VNU_ID
395
+	 * @param    string $text
396
+	 * @return string
397
+	 */
398
+	public static function venue_website_link($VNU_ID = 0, $text = '')
399
+	{
400
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
401
+		if ($venue instanceof EE_Venue) {
402
+			$url = $venue->venue_url();
403
+			$text = ! empty($text) ? $text : $url;
404
+			return ! empty($url) ? EEH_Schema::url($url, $text) : '';
405
+		}
406
+		return '';
407
+	}
408
+
409
+
410
+
411
+	/**
412
+	 *    venue_phone
413
+	 *
414
+	 * @access    public
415
+	 * @param int $VNU_ID
416
+	 * @return string
417
+	 */
418
+	public static function venue_phone($VNU_ID = 0)
419
+	{
420
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
421
+		if ($venue instanceof EE_Venue) {
422
+			return EEH_Schema::telephone($venue->phone());
423
+		}
424
+		return '';
425
+	}
426
+
427
+
428
+
429
+	/**
430
+	 *    venue_gmap
431
+	 *
432
+	 * @access    public
433
+	 * @param int $VNU_ID
434
+	 * @param bool|string $map_ID a unique identifier for this map
435
+	 * @param    array $gmap map options
436
+	 * @return string
437
+	 */
438
+	public static function venue_gmap($VNU_ID = 0, $map_ID = false, $gmap = array())
439
+	{
440
+
441
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
442
+		if ($venue instanceof EE_Venue) {
443
+			// check for global espresso_events post and use it's ID if no map_ID is set
444
+			global $post;
445
+			$map_ID = empty($map_ID) && $post->post_type == 'espresso_events' ? $post->ID : $map_ID;
446
+			// grab map settings
447
+			$map_cfg = EE_Registry::instance()->CFG->map_settings;
448
+			// are maps enabled ?
449
+			if ($map_cfg->use_google_maps && $venue->enable_for_gmap()) {
450
+				$details_page = is_single();
451
+				$options = array();
452
+				$options['map_ID'] = $map_ID && $map_ID != $venue->ID() ? $map_ID . '-' . $venue->ID()/* . '-' . $static_map_id*/ : $venue->ID()/* . '-' . $static_map_id*/;
453
+
454
+				$options['location'] = EEH_Address::format($venue, 'inline', false, false);
455
+
456
+				$options['ee_map_width'] = $details_page ? $map_cfg->event_details_map_width : $map_cfg->event_list_map_width;
457
+				$options['ee_map_width'] = isset($gmap['ee_map_width']) && ! empty($gmap['ee_map_width']) ? $gmap['ee_map_width'] : $options['ee_map_width'];
458
+
459
+				$options['ee_map_height'] = $details_page ? $map_cfg->event_details_map_height : $map_cfg->event_list_map_height;
460
+				$options['ee_map_height'] = isset($gmap['ee_map_height']) && ! empty($gmap['ee_map_height']) ? $gmap['ee_map_height'] : $options['ee_map_height'];
461
+
462
+				$options['ee_map_zoom'] = $details_page ? $map_cfg->event_details_map_zoom : $map_cfg->event_list_map_zoom;
463
+				$options['ee_map_zoom'] = isset($gmap['ee_map_zoom']) && ! empty($gmap['ee_map_zoom']) ? $gmap['ee_map_zoom'] : $options['ee_map_zoom'];
464
+
465
+				$options['ee_map_nav_display'] = $details_page ? $map_cfg->event_details_display_nav : $map_cfg->event_list_display_nav;
466
+				$options['ee_map_nav_display'] = isset($gmap['ee_map_nav_display']) && ! empty($gmap['ee_map_nav_display']) ? 'true' : $options['ee_map_nav_display'];
467
+				;
468
+
469
+				$options['ee_map_nav_size'] = $details_page ? $map_cfg->event_details_nav_size : $map_cfg->event_list_nav_size;
470
+				$options['ee_map_nav_size'] =  isset($gmap['ee_map_nav_size']) && ! empty($gmap['ee_map_nav_size'])? $gmap['ee_map_nav_size'] : $options['ee_map_nav_size'];
471
+
472
+				$options['ee_map_type_control'] = $details_page ? $map_cfg->event_details_control_type : $map_cfg->event_list_control_type;
473
+				$options['ee_map_type_control'] =  isset($gmap['ee_map_type_control']) && ! empty($gmap['ee_map_type_control'])? $gmap['ee_map_type_control'] : $options['ee_map_type_control'];
474
+
475
+				$options['ee_map_align'] = $details_page ? $map_cfg->event_details_map_align : $map_cfg->event_list_map_align;
476
+				$options['ee_map_align'] =  isset($gmap['ee_map_align']) && ! empty($gmap['ee_map_align'])? $gmap['ee_map_align'] : $options['ee_map_align'];
477
+
478
+				$options['ee_static_url'] =  isset($gmap['ee_static_url']) && ! empty($gmap['ee_static_url']) ? (bool) absint($gmap['ee_static_url']) : $venue->google_map_link();
479
+
480
+				return EEH_Maps::google_map($options);
481
+			}
482
+		}
483
+
484
+		return '';
485
+	}
486
+
487
+	/**
488
+	 * Gets the HTML to display a static map of the venue
489
+	 * @param EE_Venue $venue
490
+	 * @param array $atts like EEH_Maps::google_map_link
491
+	 * @return string
492
+	 */
493
+	public static function espresso_google_static_map(EE_Venue $venue, $atts = array())
494
+	{
495
+		$state = $venue->state_obj();
496
+		$country = $venue->country_obj();
497
+		$atts = shortcode_atts(
498
+			array(
499
+					'id' => $venue->ID(),
500
+					'address' => $venue->get('VNU_address'),
501
+					'city' => $venue->get('VNU_city'),
502
+					'state' => $state instanceof EE_State ? $state->name() : '',
503
+					'zip' => $venue->get('VNU_zip'),
504
+					'country' => $country instanceof EE_Country ? $country->name() : '',
505
+					'type' => 'map',
506
+					'map_w' => 200,
507
+					'map_h' => 200
508
+					),
509
+			$atts
510
+		);
511
+		return EEH_Maps::google_map_link($atts);
512
+	}
513
+
514
+
515
+
516
+	/**
517
+	 *    edit_venue_link
518
+	 *
519
+	 * @access    public
520
+	 * @param int $VNU_ID
521
+	 * @param string $link
522
+	 * @param string $before
523
+	 * @param string $after
524
+	 * @return string
525
+	 */
526
+	public static function edit_venue_link($VNU_ID = 0, $link = '', $before = '<p class="edit-venue-lnk small-txt">', $after = '</p>')
527
+	{
528
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
529
+		if ($venue instanceof EE_Venue) {
530
+			// can the user edit this post ?
531
+			if (current_user_can('edit_post', $venue->ID())) {
532
+				// set link text
533
+				$link = ! empty($link) ? $link : __('edit this venue', 'event_espresso');
534
+				// generate nonce
535
+				$nonce = wp_create_nonce('edit_nonce');
536
+				// generate url to venue editor for this venue
537
+				$url = add_query_arg(array( 'page' => 'espresso_venues', 'action' => 'edit', 'post' => $venue->ID(), 'edit_nonce' => $nonce ), admin_url('admin.php'));
538
+				// get edit CPT text
539
+				$post_type_obj = get_post_type_object('espresso_venues');
540
+				// build final link html
541
+				$link = '<a class="post-edit-link" href="' . $url . '" title="' . esc_attr($post_type_obj->labels->edit_item) . '">' . $link . '</a>';
542
+				// put it all together
543
+				return $before . apply_filters('edit_post_link', $link, $venue->ID()) . $after;
544
+			}
545
+		}
546
+		return '';
547
+	}
549 548
 }
Please login to merge, or discard this patch.
core/libraries/rest_api/calculations/Attendee.php 2 patches
Unused Use Statements   -6 removed lines patch added patch discarded remove patch
@@ -2,14 +2,8 @@
 block discarded – undo
2 2
 
3 3
 namespace EventEspresso\core\libraries\rest_api\calculations;
4 4
 
5
-use EE_Attendee;
6
-use EE_Error;
7
-use EEM_Attendee;
8
-use EventEspresso\core\exceptions\InvalidDataTypeException;
9
-use EventEspresso\core\exceptions\InvalidInterfaceException;
10 5
 use EventEspresso\core\libraries\rest_api\calculations\Base as Calculations_Base;
11 6
 use EventEspresso\core\libraries\rest_api\controllers\model\Base;
12
-use InvalidArgumentException;
13 7
 use WP_REST_Request;
14 8
 
15 9
 /**
Please login to merge, or discard this patch.
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -23,22 +23,22 @@
 block discarded – undo
23 23
 class Attendee extends Calculations_Base
24 24
 {
25 25
 
26
-    /**
27
-     * @param array           $wpdb_row
28
-     * @param WP_REST_Request $request
29
-     * @param Base            $controller
30
-     * @since $VID:$
31
-     * @return string
32
-     */
33
-    public static function userAvatar(array $wpdb_row, WP_REST_Request $request, Base $controller)
34
-    {
35
-        if (is_array($wpdb_row) && isset($wpdb_row['Attendee_Meta.ATT_email'])) {
36
-            $email_address = $wpdb_row['Attendee_Meta.ATT_email'];
37
-        }
38
-        if (empty($email_address)) {
39
-            return '';
40
-        }
41
-        $avatar = get_avatar_url($email_address);
42
-        return $avatar ? $avatar : '';
43
-    }
26
+	/**
27
+	 * @param array           $wpdb_row
28
+	 * @param WP_REST_Request $request
29
+	 * @param Base            $controller
30
+	 * @since $VID:$
31
+	 * @return string
32
+	 */
33
+	public static function userAvatar(array $wpdb_row, WP_REST_Request $request, Base $controller)
34
+	{
35
+		if (is_array($wpdb_row) && isset($wpdb_row['Attendee_Meta.ATT_email'])) {
36
+			$email_address = $wpdb_row['Attendee_Meta.ATT_email'];
37
+		}
38
+		if (empty($email_address)) {
39
+			return '';
40
+		}
41
+		$avatar = get_avatar_url($email_address);
42
+		return $avatar ? $avatar : '';
43
+	}
44 44
 }
Please login to merge, or discard this patch.
public/template_tags.php 1 patch
Spacing   +291 added lines, -291 removed lines patch added patch discarded remove patch
@@ -14,12 +14,12 @@  discard block
 block discarded – undo
14 14
  * @param int | \EE_Event $event
15 15
  * @return bool
16 16
  */
17
-function is_espresso_event( $event = NULL ) {
18
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
17
+function is_espresso_event($event = NULL) {
18
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
19 19
 		// extract EE_Event object from passed param regardless of what it is (within reason of course)
20
-		$event = EEH_Event_View::get_event( $event );
20
+		$event = EEH_Event_View::get_event($event);
21 21
 		// do we have a valid event ?
22
-		return $event instanceof EE_Event  ? TRUE : FALSE;
22
+		return $event instanceof EE_Event ? TRUE : FALSE;
23 23
 	}
24 24
 	return FALSE;
25 25
 }
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
  * @return bool
32 32
  */
33 33
 function is_espresso_event_single() {
34
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
34
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
35 35
 		global $wp_query;
36 36
 		// return conditionals set by CPTs
37 37
 		return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_single : FALSE;
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
  * @return bool
47 47
  */
48 48
 function is_espresso_event_archive() {
49
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
49
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
50 50
 		global $wp_query;
51 51
 		return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_archive : FALSE;
52 52
 	}
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
  * @return bool
61 61
  */
62 62
 function is_espresso_event_taxonomy() {
63
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
63
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
64 64
 		global $wp_query;
65 65
 		return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_taxonomy : FALSE;
66 66
 	}
@@ -74,10 +74,10 @@  discard block
 block discarded – undo
74 74
  * @param int | \EE_Venue $venue
75 75
  * @return bool
76 76
  */
77
-function is_espresso_venue( $venue = NULL ) {
78
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
77
+function is_espresso_venue($venue = NULL) {
78
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
79 79
 		// extract EE_Venue object from passed param regardless of what it is (within reason of course)
80
-		$venue = EEH_Venue_View::get_venue( $venue, FALSE );
80
+		$venue = EEH_Venue_View::get_venue($venue, FALSE);
81 81
 		// do we have a valid event ?
82 82
 		return $venue instanceof EE_Venue ? TRUE : FALSE;
83 83
 	}
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
  * @return bool
92 92
  */
93 93
 function is_espresso_venue_single() {
94
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
94
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
95 95
 		global $wp_query;
96 96
 		return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_single : FALSE;
97 97
 	}
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
  * @return bool
106 106
  */
107 107
 function is_espresso_venue_archive() {
108
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
108
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
109 109
 		global $wp_query;
110 110
 		return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_archive : FALSE;
111 111
 	}
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
  * @return bool
120 120
  */
121 121
 function is_espresso_venue_taxonomy() {
122
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
122
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
123 123
 		global $wp_query;
124 124
 		return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_taxonomy : FALSE;
125 125
 	}
@@ -133,12 +133,12 @@  discard block
 block discarded – undo
133 133
  * @param $conditional_tag
134 134
  * @return bool
135 135
  */
136
-function can_use_espresso_conditionals( $conditional_tag ) {
137
-	if ( ! did_action( 'AHEE__EE_System__initialize' )) {
136
+function can_use_espresso_conditionals($conditional_tag) {
137
+	if ( ! did_action('AHEE__EE_System__initialize')) {
138 138
 		EE_Error::doing_it_wrong(
139 139
 			__FUNCTION__,
140 140
 			sprintf(
141
-				__( 'The "%s" conditional tag can not be used until after the "init" hook has run, but works best when used within a theme\'s template files.','event_espresso'),
141
+				__('The "%s" conditional tag can not be used until after the "init" hook has run, but works best when used within a theme\'s template files.', 'event_espresso'),
142 142
 				$conditional_tag
143 143
 			),
144 144
 			'4.4.0'
@@ -153,13 +153,13 @@  discard block
 block discarded – undo
153 153
 
154 154
 /*************************** Event Queries ***************************/
155 155
 
156
-if ( ! function_exists( 'espresso_get_events' )) {
156
+if ( ! function_exists('espresso_get_events')) {
157 157
 	/**
158 158
 	 * 	espresso_get_events
159 159
 	 * @param array $params
160 160
 	 * @return array
161 161
 	 */
162
-	function espresso_get_events( $params = array() ) {
162
+	function espresso_get_events($params = array()) {
163 163
 		//set default params
164 164
 		$default_espresso_events_params = array(
165 165
 			'limit' => 10,
@@ -170,18 +170,18 @@  discard block
 block discarded – undo
170 170
 			'sort' => 'ASC'
171 171
 		);
172 172
 		// allow the defaults to be filtered
173
-		$default_espresso_events_params = apply_filters( 'espresso_get_events__default_espresso_events_params', $default_espresso_events_params );
173
+		$default_espresso_events_params = apply_filters('espresso_get_events__default_espresso_events_params', $default_espresso_events_params);
174 174
 		// grab params and merge with defaults, then extract
175
-		$params = array_merge( $default_espresso_events_params, $params );
175
+		$params = array_merge($default_espresso_events_params, $params);
176 176
 		// run the query
177
-		$events_query = new EventEspresso\core\domain\services\wp_queries\EventListQuery( $params );
177
+		$events_query = new EventEspresso\core\domain\services\wp_queries\EventListQuery($params);
178 178
 		// assign results to a variable so we can return it
179 179
 		$events = $events_query->have_posts() ? $events_query->posts : array();
180 180
 		// but first reset the query and postdata
181 181
 		wp_reset_query();
182 182
 		wp_reset_postdata();
183 183
 		EED_Events_Archive::remove_all_events_archive_filters();
184
-		unset( $events_query );
184
+		unset($events_query);
185 185
 		return $events;
186 186
 	}
187 187
 }
@@ -195,33 +195,33 @@  discard block
 block discarded – undo
195 195
  * espresso_load_ticket_selector
196 196
  */
197 197
 function espresso_load_ticket_selector() {
198
-	EE_Registry::instance()->load_file( EE_MODULES . 'ticket_selector', 'EED_Ticket_Selector', 'module' );
198
+	EE_Registry::instance()->load_file(EE_MODULES.'ticket_selector', 'EED_Ticket_Selector', 'module');
199 199
 }
200 200
 
201
-if ( ! function_exists( 'espresso_ticket_selector' )) {
201
+if ( ! function_exists('espresso_ticket_selector')) {
202 202
 	/**
203 203
 	 * espresso_ticket_selector
204 204
 	 * @param null $event
205 205
 	 */
206
-	function espresso_ticket_selector( $event = NULL ) {
207
-		if (  ! apply_filters( 'FHEE_disable_espresso_ticket_selector', FALSE ) ) {
206
+	function espresso_ticket_selector($event = NULL) {
207
+		if ( ! apply_filters('FHEE_disable_espresso_ticket_selector', FALSE)) {
208 208
 			espresso_load_ticket_selector();
209 209
             \EED_Ticket_Selector::set_definitions();
210
-			echo EED_Ticket_Selector::display_ticket_selector( $event );
210
+			echo EED_Ticket_Selector::display_ticket_selector($event);
211 211
 		}
212 212
 	}
213 213
 }
214 214
 
215 215
 
216
-	if ( ! function_exists( 'espresso_view_details_btn' )) {
216
+	if ( ! function_exists('espresso_view_details_btn')) {
217 217
 	/**
218 218
 	 * espresso_view_details_btn
219 219
 	 * @param null $event
220 220
 	 */
221
-	function espresso_view_details_btn( $event = NULL ) {
222
-		if (  ! apply_filters( 'FHEE_disable_espresso_view_details_btn', FALSE ) ) {
221
+	function espresso_view_details_btn($event = NULL) {
222
+		if ( ! apply_filters('FHEE_disable_espresso_view_details_btn', FALSE)) {
223 223
 			espresso_load_ticket_selector();
224
-			echo EED_Ticket_Selector::display_ticket_selector( $event, TRUE );
224
+			echo EED_Ticket_Selector::display_ticket_selector($event, TRUE);
225 225
 		}
226 226
 	}
227 227
 }
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 
232 232
 /*************************** EEH_Event_View ***************************/
233 233
 
234
-if ( ! function_exists( 'espresso_load_event_list_assets' )) {
234
+if ( ! function_exists('espresso_load_event_list_assets')) {
235 235
 	/**
236 236
 	 * espresso_load_event_list_assets
237 237
 	 * ensures that event list styles and scripts are loaded
@@ -240,13 +240,13 @@  discard block
 block discarded – undo
240 240
 	 */
241 241
 	function espresso_load_event_list_assets() {
242 242
 		$event_list = EED_Events_Archive::instance();
243
-		add_action( 'AHEE__EE_System__initialize_last', array( $event_list, 'load_event_list_assets' ), 10 );
244
-		add_filter( 'FHEE_enable_default_espresso_css', '__return_true' );
243
+		add_action('AHEE__EE_System__initialize_last', array($event_list, 'load_event_list_assets'), 10);
244
+		add_filter('FHEE_enable_default_espresso_css', '__return_true');
245 245
 	}
246 246
 }
247 247
 
248 248
 
249
-if ( ! function_exists( 'espresso_event_reg_button' )) {
249
+if ( ! function_exists('espresso_event_reg_button')) {
250 250
 	/**
251 251
 	 * espresso_event_reg_button
252 252
 	 * returns the "Register Now" button if event is active,
@@ -258,9 +258,9 @@  discard block
 block discarded – undo
258 258
 	 * @param bool $EVT_ID
259 259
 	 * @return string
260 260
 	 */
261
-	function espresso_event_reg_button( $btn_text_if_active = NULL, $btn_text_if_inactive = FALSE, $EVT_ID = FALSE ) {
262
-		$event_status = EEH_Event_View::event_active_status( $EVT_ID );
263
-		switch ( $event_status ) {
261
+	function espresso_event_reg_button($btn_text_if_active = NULL, $btn_text_if_inactive = FALSE, $EVT_ID = FALSE) {
262
+		$event_status = EEH_Event_View::event_active_status($EVT_ID);
263
+		switch ($event_status) {
264 264
 			case EE_Datetime::sold_out :
265 265
 				$btn_text = __('Sold Out', 'event_espresso');
266 266
 				$class = 'ee-pink';
@@ -276,10 +276,10 @@  discard block
 block discarded – undo
276 276
 			case EE_Datetime::upcoming :
277 277
 			case EE_Datetime::active :
278 278
 			default :
279
-				$btn_text =! empty( $btn_text_if_active ) ? $btn_text_if_active : __( 'Register Now', 'event_espresso' );
279
+				$btn_text = ! empty($btn_text_if_active) ? $btn_text_if_active : __('Register Now', 'event_espresso');
280 280
 				$class = 'ee-green';
281 281
 		}
282
-		if ( $event_status < 1 && ! empty( $btn_text_if_inactive )) {
282
+		if ($event_status < 1 && ! empty($btn_text_if_inactive)) {
283 283
 			$btn_text = $btn_text_if_inactive;
284 284
 			$class = 'ee-grey';
285 285
 		}
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 
294 294
 
295 295
 
296
-if ( ! function_exists( 'espresso_display_ticket_selector' )) {
296
+if ( ! function_exists('espresso_display_ticket_selector')) {
297 297
 	/**
298 298
 	 * espresso_display_ticket_selector
299 299
 	 * whether or not to display the Ticket Selector for an event
@@ -301,14 +301,14 @@  discard block
 block discarded – undo
301 301
 	 * @param bool $EVT_ID
302 302
 	 * @return boolean
303 303
 	 */
304
-	function espresso_display_ticket_selector( $EVT_ID = FALSE ) {
305
-		return EEH_Event_View::display_ticket_selector( $EVT_ID );
304
+	function espresso_display_ticket_selector($EVT_ID = FALSE) {
305
+		return EEH_Event_View::display_ticket_selector($EVT_ID);
306 306
 	}
307 307
 }
308 308
 
309 309
 
310 310
 
311
-if ( ! function_exists( 'espresso_event_status_banner' )) {
311
+if ( ! function_exists('espresso_event_status_banner')) {
312 312
 	/**
313 313
 	 * espresso_event_status
314 314
 	 * returns a banner showing the event status if it is sold out, expired, or inactive
@@ -316,13 +316,13 @@  discard block
 block discarded – undo
316 316
 	 * @param bool $EVT_ID
317 317
 	 * @return string
318 318
 	 */
319
-	function espresso_event_status_banner( $EVT_ID = FALSE ) {
320
-		return EEH_Event_View::event_status( $EVT_ID );
319
+	function espresso_event_status_banner($EVT_ID = FALSE) {
320
+		return EEH_Event_View::event_status($EVT_ID);
321 321
 	}
322 322
 }
323 323
 
324 324
 
325
-if ( ! function_exists( 'espresso_event_status' )) {
325
+if ( ! function_exists('espresso_event_status')) {
326 326
 	/**
327 327
 	 * espresso_event_status
328 328
 	 * returns the event status if it is sold out, expired, or inactive
@@ -331,17 +331,17 @@  discard block
 block discarded – undo
331 331
 	 * @param bool $echo
332 332
 	 * @return string
333 333
 	 */
334
-	function espresso_event_status( $EVT_ID = 0, $echo = TRUE ) {
335
-		if ( $echo ) {
336
-			echo EEH_Event_View::event_active_status( $EVT_ID );
334
+	function espresso_event_status($EVT_ID = 0, $echo = TRUE) {
335
+		if ($echo) {
336
+			echo EEH_Event_View::event_active_status($EVT_ID);
337 337
 			return '';
338 338
 		}
339
-		return EEH_Event_View::event_active_status( $EVT_ID );
339
+		return EEH_Event_View::event_active_status($EVT_ID);
340 340
 	}
341 341
 }
342 342
 
343 343
 
344
-if ( ! function_exists( 'espresso_event_categories' )) {
344
+if ( ! function_exists('espresso_event_categories')) {
345 345
 	/**
346 346
 	 * espresso_event_categories
347 347
 	 * returns the terms associated with an event
@@ -351,17 +351,17 @@  discard block
 block discarded – undo
351 351
 	 * @param bool $echo
352 352
 	 * @return string
353 353
 	 */
354
-	function espresso_event_categories( $EVT_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE ) {
355
-		if ( $echo ) {
356
-			echo EEH_Event_View::event_categories( $EVT_ID, $hide_uncategorized );
354
+	function espresso_event_categories($EVT_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE) {
355
+		if ($echo) {
356
+			echo EEH_Event_View::event_categories($EVT_ID, $hide_uncategorized);
357 357
 			return '';
358 358
 		}
359
-		return EEH_Event_View::event_categories( $EVT_ID, $hide_uncategorized );
359
+		return EEH_Event_View::event_categories($EVT_ID, $hide_uncategorized);
360 360
 	}
361 361
 }
362 362
 
363 363
 
364
-if ( ! function_exists( 'espresso_event_tickets_available' )) {
364
+if ( ! function_exists('espresso_event_tickets_available')) {
365 365
 	/**
366 366
 	 * espresso_event_tickets_available
367 367
 	 * returns the ticket types available for purchase for an event
@@ -371,26 +371,26 @@  discard block
 block discarded – undo
371 371
 	 * @param bool $format
372 372
 	 * @return string
373 373
 	 */
374
-	function espresso_event_tickets_available( $EVT_ID = 0, $echo = TRUE, $format = TRUE ) {
375
-		$tickets = EEH_Event_View::event_tickets_available( $EVT_ID );
376
-		if ( is_array( $tickets ) && ! empty( $tickets )) {
374
+	function espresso_event_tickets_available($EVT_ID = 0, $echo = TRUE, $format = TRUE) {
375
+		$tickets = EEH_Event_View::event_tickets_available($EVT_ID);
376
+		if (is_array($tickets) && ! empty($tickets)) {
377 377
 			// if formatting then $html will be a string, else it will be an array of ticket objects
378
-			$html = $format ? '<ul id="ee-event-tickets-ul-' . $EVT_ID . '" class="ee-event-tickets-ul">' : array();
379
-			foreach ( $tickets as $ticket ) {
380
-				if ( $ticket instanceof EE_Ticket ) {
381
-					if ( $format ) {
382
-						$html .= '<li id="ee-event-tickets-li-' . $ticket->ID() . '" class="ee-event-tickets-li">';
383
-						$html .= $ticket->name() . ' ' . EEH_Template::format_currency( $ticket->get_ticket_total_with_taxes() );
378
+			$html = $format ? '<ul id="ee-event-tickets-ul-'.$EVT_ID.'" class="ee-event-tickets-ul">' : array();
379
+			foreach ($tickets as $ticket) {
380
+				if ($ticket instanceof EE_Ticket) {
381
+					if ($format) {
382
+						$html .= '<li id="ee-event-tickets-li-'.$ticket->ID().'" class="ee-event-tickets-li">';
383
+						$html .= $ticket->name().' '.EEH_Template::format_currency($ticket->get_ticket_total_with_taxes());
384 384
 						$html .= '</li>';
385 385
 					} else {
386 386
 						$html[] = $ticket;
387 387
 					}
388 388
 				}
389 389
 			}
390
-			if ( $format ) {
390
+			if ($format) {
391 391
 				$html .= '</ul>';
392 392
 			}
393
-			if ( $echo && $format ) {
393
+			if ($echo && $format) {
394 394
 				echo $html;
395 395
 				return '';
396 396
 			}
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
 	}
401 401
 }
402 402
 
403
-if ( ! function_exists( 'espresso_event_date_obj' )) {
403
+if ( ! function_exists('espresso_event_date_obj')) {
404 404
 	/**
405 405
 	 * espresso_event_date_obj
406 406
 	 * returns the primary date object for an event
@@ -408,13 +408,13 @@  discard block
 block discarded – undo
408 408
 	 * @param bool $EVT_ID
409 409
 	 * @return object
410 410
 	 */
411
-	function espresso_event_date_obj( $EVT_ID = FALSE ) {
412
-		return EEH_Event_View::get_primary_date_obj( $EVT_ID );
411
+	function espresso_event_date_obj($EVT_ID = FALSE) {
412
+		return EEH_Event_View::get_primary_date_obj($EVT_ID);
413 413
 	}
414 414
 }
415 415
 
416 416
 
417
-if ( ! function_exists( 'espresso_event_date' )) {
417
+if ( ! function_exists('espresso_event_date')) {
418 418
 	/**
419 419
 	 * espresso_event_date
420 420
 	 * returns the primary date for an event
@@ -425,22 +425,22 @@  discard block
 block discarded – undo
425 425
 	 * @param bool $echo
426 426
 	 * @return string
427 427
 	 */
428
-	function espresso_event_date( $date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE ) {
429
-		$date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' );
430
-		$time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' );
431
-		$date_format = apply_filters( 'FHEE__espresso_event_date__date_format', $date_format );
432
-		$time_format = apply_filters( 'FHEE__espresso_event_date__time_format', $time_format );
433
-		if($echo){
434
-			echo EEH_Event_View::the_event_date( $date_format, $time_format, $EVT_ID );
428
+	function espresso_event_date($date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE) {
429
+		$date_format = ! empty($date_format) ? $date_format : get_option('date_format');
430
+		$time_format = ! empty($time_format) ? $time_format : get_option('time_format');
431
+		$date_format = apply_filters('FHEE__espresso_event_date__date_format', $date_format);
432
+		$time_format = apply_filters('FHEE__espresso_event_date__time_format', $time_format);
433
+		if ($echo) {
434
+			echo EEH_Event_View::the_event_date($date_format, $time_format, $EVT_ID);
435 435
 			return '';
436 436
 		}
437
-		return EEH_Event_View::the_event_date( $date_format, $time_format, $EVT_ID );
437
+		return EEH_Event_View::the_event_date($date_format, $time_format, $EVT_ID);
438 438
 
439 439
 	}
440 440
 }
441 441
 
442 442
 
443
-if ( ! function_exists( 'espresso_list_of_event_dates' )) {
443
+if ( ! function_exists('espresso_list_of_event_dates')) {
444 444
 	/**
445 445
 	 * espresso_list_of_event_dates
446 446
 	 * returns a unordered list of dates for an event
@@ -455,40 +455,40 @@  discard block
 block discarded – undo
455 455
 	 * @param null   $limit
456 456
 	 * @return string
457 457
 	 */
458
-	function espresso_list_of_event_dates( $EVT_ID = 0, $date_format = '', $time_format = '', $echo = TRUE, $show_expired = NULL, $format = TRUE, $add_breaks = TRUE, $limit = NULL ) {
459
-		$date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' );
460
-		$time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' );
461
-		$date_format = apply_filters( 'FHEE__espresso_list_of_event_dates__date_format', $date_format );
462
-		$time_format = apply_filters( 'FHEE__espresso_list_of_event_dates__time_format', $time_format );
463
-		$datetimes = EEH_Event_View::get_all_date_obj( $EVT_ID, $show_expired, FALSE, $limit );
464
-		if ( ! $format ) {
465
-			return apply_filters( 'FHEE__espresso_list_of_event_dates__datetimes', $datetimes );
458
+	function espresso_list_of_event_dates($EVT_ID = 0, $date_format = '', $time_format = '', $echo = TRUE, $show_expired = NULL, $format = TRUE, $add_breaks = TRUE, $limit = NULL) {
459
+		$date_format = ! empty($date_format) ? $date_format : get_option('date_format');
460
+		$time_format = ! empty($time_format) ? $time_format : get_option('time_format');
461
+		$date_format = apply_filters('FHEE__espresso_list_of_event_dates__date_format', $date_format);
462
+		$time_format = apply_filters('FHEE__espresso_list_of_event_dates__time_format', $time_format);
463
+		$datetimes = EEH_Event_View::get_all_date_obj($EVT_ID, $show_expired, FALSE, $limit);
464
+		if ( ! $format) {
465
+			return apply_filters('FHEE__espresso_list_of_event_dates__datetimes', $datetimes);
466 466
 		}
467 467
 		//d( $datetimes );
468
-		if ( is_array( $datetimes ) && ! empty( $datetimes )) {
468
+		if (is_array($datetimes) && ! empty($datetimes)) {
469 469
 			global $post;
470
-			$html = $format ? '<ul id="ee-event-datetimes-ul-' . $post->ID . '" class="ee-event-datetimes-ul ee-clearfix">' : '';
471
-			foreach ( $datetimes as $datetime ) {
472
-				if ( $datetime instanceof EE_Datetime ) {
473
-					$html .= '<li id="ee-event-datetimes-li-' . $datetime->ID();
474
-					$html .= '" class="ee-event-datetimes-li ee-event-datetimes-li-' . $datetime->get_active_status() . '">';
470
+			$html = $format ? '<ul id="ee-event-datetimes-ul-'.$post->ID.'" class="ee-event-datetimes-ul ee-clearfix">' : '';
471
+			foreach ($datetimes as $datetime) {
472
+				if ($datetime instanceof EE_Datetime) {
473
+					$html .= '<li id="ee-event-datetimes-li-'.$datetime->ID();
474
+					$html .= '" class="ee-event-datetimes-li ee-event-datetimes-li-'.$datetime->get_active_status().'">';
475 475
 					$datetime_name = $datetime->name();
476
-					$html .= ! empty( $datetime_name ) ? '<strong>' . $datetime_name . '</strong>' : '';
477
-					$html .= ! empty( $datetime_name )  && $add_breaks ? '<br />' : '';
478
-					$html .= '<span class="dashicons dashicons-calendar"></span><span class="ee-event-datetimes-li-daterange">' . $datetime->date_range( $date_format ) . '</span><br/>';
479
-					$html .= '<span class="dashicons dashicons-clock"></span><span class="ee-event-datetimes-li-timerange">' . $datetime->time_range( $time_format ) . '</span>';
476
+					$html .= ! empty($datetime_name) ? '<strong>'.$datetime_name.'</strong>' : '';
477
+					$html .= ! empty($datetime_name) && $add_breaks ? '<br />' : '';
478
+					$html .= '<span class="dashicons dashicons-calendar"></span><span class="ee-event-datetimes-li-daterange">'.$datetime->date_range($date_format).'</span><br/>';
479
+					$html .= '<span class="dashicons dashicons-clock"></span><span class="ee-event-datetimes-li-timerange">'.$datetime->time_range($time_format).'</span>';
480 480
 					$datetime_description = $datetime->description();
481
-					$html .= ! empty( $datetime_description )  && $add_breaks ? '<br />' : '';
482
-					$html .= ! empty( $datetime_description ) ? ' - ' . $datetime_description : '';
483
-					$html = apply_filters( 'FHEE__espresso_list_of_event_dates__datetime_html', $html, $datetime );
481
+					$html .= ! empty($datetime_description) && $add_breaks ? '<br />' : '';
482
+					$html .= ! empty($datetime_description) ? ' - '.$datetime_description : '';
483
+					$html = apply_filters('FHEE__espresso_list_of_event_dates__datetime_html', $html, $datetime);
484 484
 					$html .= '</li>';
485 485
 				}
486 486
 			}
487 487
 			$html .= $format ? '</ul>' : '';
488 488
 		} else {
489
-			$html = $format ?  '<p><span class="dashicons dashicons-marker pink-text"></span>' . __( 'There are no upcoming dates for this event.', 'event_espresso' ) . '</p><br/>' : '';
489
+			$html = $format ? '<p><span class="dashicons dashicons-marker pink-text"></span>'.__('There are no upcoming dates for this event.', 'event_espresso').'</p><br/>' : '';
490 490
 		}
491
-		if ( $echo ) {
491
+		if ($echo) {
492 492
 			echo $html;
493 493
 			return '';
494 494
 		}
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
 }
498 498
 
499 499
 
500
-if ( ! function_exists( 'espresso_event_end_date' )) {
500
+if ( ! function_exists('espresso_event_end_date')) {
501 501
 	/**
502 502
 	 * espresso_event_end_date
503 503
 	 * returns the last date for an event
@@ -508,20 +508,20 @@  discard block
 block discarded – undo
508 508
 	 * @param bool   $echo
509 509
 	 * @return string
510 510
 	 */
511
-	function espresso_event_end_date( $date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE ) {
512
-		$date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' );
513
-		$time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' );
514
-		$date_format = apply_filters( 'FHEE__espresso_event_end_date__date_format', $date_format );
515
-		$time_format = apply_filters( 'FHEE__espresso_event_end_date__time_format', $time_format );
516
-		if($echo){
517
-			echo EEH_Event_View::the_event_end_date( $date_format, $time_format, $EVT_ID );
511
+	function espresso_event_end_date($date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE) {
512
+		$date_format = ! empty($date_format) ? $date_format : get_option('date_format');
513
+		$time_format = ! empty($time_format) ? $time_format : get_option('time_format');
514
+		$date_format = apply_filters('FHEE__espresso_event_end_date__date_format', $date_format);
515
+		$time_format = apply_filters('FHEE__espresso_event_end_date__time_format', $time_format);
516
+		if ($echo) {
517
+			echo EEH_Event_View::the_event_end_date($date_format, $time_format, $EVT_ID);
518 518
 			return '';
519 519
 		}
520
-		return EEH_Event_View::the_event_end_date( $date_format, $time_format, $EVT_ID );
520
+		return EEH_Event_View::the_event_end_date($date_format, $time_format, $EVT_ID);
521 521
 	}
522 522
 }
523 523
 
524
-if ( ! function_exists( 'espresso_event_date_range' )) {
524
+if ( ! function_exists('espresso_event_date_range')) {
525 525
 	/**
526 526
 	 * espresso_event_date_range
527 527
 	 * returns the first and last chronologically ordered dates for an event (if different)
@@ -534,31 +534,31 @@  discard block
 block discarded – undo
534 534
 	 * @param bool   $echo
535 535
 	 * @return string
536 536
 	 */
537
-	function espresso_event_date_range( $date_format = '', $time_format = '', $single_date_format = '', $single_time_format = '', $EVT_ID = FALSE, $echo = TRUE ) {
537
+	function espresso_event_date_range($date_format = '', $time_format = '', $single_date_format = '', $single_time_format = '', $EVT_ID = FALSE, $echo = TRUE) {
538 538
 		// set and filter date and time formats when a range is returned
539
-		$date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' );
540
-		$date_format = apply_filters( 'FHEE__espresso_event_date_range__date_format', $date_format );
539
+		$date_format = ! empty($date_format) ? $date_format : get_option('date_format');
540
+		$date_format = apply_filters('FHEE__espresso_event_date_range__date_format', $date_format);
541 541
 		// get the start and end date with NO time portion
542
-		$the_event_date = EEH_Event_View::the_earliest_event_date( $date_format, '', $EVT_ID );
543
-		$the_event_end_date = EEH_Event_View::the_latest_event_date( $date_format, '', $EVT_ID );
542
+		$the_event_date = EEH_Event_View::the_earliest_event_date($date_format, '', $EVT_ID);
543
+		$the_event_end_date = EEH_Event_View::the_latest_event_date($date_format, '', $EVT_ID);
544 544
 		// now we can determine if date range spans more than one day
545
-		if ( $the_event_date != $the_event_end_date ) {
546
-			$time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' );
547
-			$time_format = apply_filters( 'FHEE__espresso_event_date_range__time_format', $time_format );
545
+		if ($the_event_date != $the_event_end_date) {
546
+			$time_format = ! empty($time_format) ? $time_format : get_option('time_format');
547
+			$time_format = apply_filters('FHEE__espresso_event_date_range__time_format', $time_format);
548 548
 			$html = sprintf(
549
-				__( '%1$s - %2$s', 'event_espresso' ),
550
-				EEH_Event_View::the_earliest_event_date( $date_format, $time_format, $EVT_ID ),
551
-				EEH_Event_View::the_latest_event_date( $date_format, $time_format, $EVT_ID )
549
+				__('%1$s - %2$s', 'event_espresso'),
550
+				EEH_Event_View::the_earliest_event_date($date_format, $time_format, $EVT_ID),
551
+				EEH_Event_View::the_latest_event_date($date_format, $time_format, $EVT_ID)
552 552
 			);
553 553
 		} else {
554 554
 			// set and filter date and time formats when only a single datetime is returned
555
-			$single_date_format = ! empty( $single_date_format ) ? $single_date_format : get_option( 'date_format' );
556
-			$single_time_format = ! empty( $single_time_format ) ? $single_time_format : get_option( 'time_format' );
557
-			$single_date_format = apply_filters( 'FHEE__espresso_event_date_range__single_date_format', $single_date_format );
558
-			$single_time_format = apply_filters( 'FHEE__espresso_event_date_range__single_time_format', $single_time_format );
559
-			$html = EEH_Event_View::the_earliest_event_date( $single_date_format, $single_time_format, $EVT_ID );
555
+			$single_date_format = ! empty($single_date_format) ? $single_date_format : get_option('date_format');
556
+			$single_time_format = ! empty($single_time_format) ? $single_time_format : get_option('time_format');
557
+			$single_date_format = apply_filters('FHEE__espresso_event_date_range__single_date_format', $single_date_format);
558
+			$single_time_format = apply_filters('FHEE__espresso_event_date_range__single_time_format', $single_time_format);
559
+			$html = EEH_Event_View::the_earliest_event_date($single_date_format, $single_time_format, $EVT_ID);
560 560
 		}
561
-		if ( $echo ) {
561
+		if ($echo) {
562 562
 			echo $html;
563 563
 			return '';
564 564
 		}
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
 	}
567 567
 }
568 568
 
569
-if ( ! function_exists( 'espresso_next_upcoming_datetime_obj' )) {
569
+if ( ! function_exists('espresso_next_upcoming_datetime_obj')) {
570 570
 	/**
571 571
 	 * espresso_next_upcoming_datetime_obj
572 572
 	 * returns the next upcoming datetime object for an event
@@ -574,12 +574,12 @@  discard block
 block discarded – undo
574 574
 	 * @param int $EVT_ID
575 575
 	 * @return EE_Datetime|null
576 576
 	 */
577
-	function espresso_next_upcoming_datetime_obj( $EVT_ID = 0 ) {
578
-		return EEH_Event_View::get_next_upcoming_date_obj( $EVT_ID );
577
+	function espresso_next_upcoming_datetime_obj($EVT_ID = 0) {
578
+		return EEH_Event_View::get_next_upcoming_date_obj($EVT_ID);
579 579
 	}
580 580
 }
581 581
 
582
-if ( ! function_exists( 'espresso_next_upcoming_datetime' ) ) {
582
+if ( ! function_exists('espresso_next_upcoming_datetime')) {
583 583
 	/**
584 584
 	 * espresso_next_upcoming_datetime
585 585
 	 * returns the start date and time for the next upcoming event.
@@ -590,30 +590,30 @@  discard block
 block discarded – undo
590 590
 	 * @param bool $echo
591 591
 	 * @return string
592 592
 	 */
593
-	function espresso_next_upcoming_datetime( $date_format = '', $time_format = '', $EVT_ID = 0, $echo = true ) {
593
+	function espresso_next_upcoming_datetime($date_format = '', $time_format = '', $EVT_ID = 0, $echo = true) {
594 594
 
595
-		$date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' );
596
-		$date_format = apply_filters( 'FHEE__espresso_next_upcoming_datetime__date_format', $date_format );
595
+		$date_format = ! empty($date_format) ? $date_format : get_option('date_format');
596
+		$date_format = apply_filters('FHEE__espresso_next_upcoming_datetime__date_format', $date_format);
597 597
 
598
-		$time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' );
599
-		$time_format = apply_filters( 'FHEE__espresso_next_upcoming_datetime__time_format', $time_format );
598
+		$time_format = ! empty($time_format) ? $time_format : get_option('time_format');
599
+		$time_format = apply_filters('FHEE__espresso_next_upcoming_datetime__time_format', $time_format);
600 600
 
601
-		$datetime_format = trim( $date_format . ' ' . $time_format);
601
+		$datetime_format = trim($date_format.' '.$time_format);
602 602
 
603
-		$datetime = espresso_next_upcoming_datetime_obj( $EVT_ID );
603
+		$datetime = espresso_next_upcoming_datetime_obj($EVT_ID);
604 604
 
605
-		if( ! $datetime instanceof EE_Datetime ) {
605
+		if ( ! $datetime instanceof EE_Datetime) {
606 606
 			return '';
607 607
 		}
608
-		if ( $echo ){
609
-			echo $datetime->get_i18n_datetime( 'DTT_EVT_start', $datetime_format );
608
+		if ($echo) {
609
+			echo $datetime->get_i18n_datetime('DTT_EVT_start', $datetime_format);
610 610
 			return '';
611 611
 		}
612
-		return $datetime->get_i18n_datetime( 'DTT_EVT_start', $datetime_format );
612
+		return $datetime->get_i18n_datetime('DTT_EVT_start', $datetime_format);
613 613
 	}
614 614
 }
615 615
 
616
-if ( ! function_exists( 'espresso_event_date_as_calendar_page' )) {
616
+if ( ! function_exists('espresso_event_date_as_calendar_page')) {
617 617
 	/**
618 618
 	 * espresso_event_date_as_calendar_page
619 619
 	 * returns the primary date for an event, stylized to appear as the page of a calendar
@@ -621,15 +621,15 @@  discard block
 block discarded – undo
621 621
 	 * @param bool $EVT_ID
622 622
 	 * @return string
623 623
 	 */
624
-	function espresso_event_date_as_calendar_page( $EVT_ID = FALSE ) {
625
-		EEH_Event_View::event_date_as_calendar_page( $EVT_ID );
624
+	function espresso_event_date_as_calendar_page($EVT_ID = FALSE) {
625
+		EEH_Event_View::event_date_as_calendar_page($EVT_ID);
626 626
 	}
627 627
 }
628 628
 
629 629
 
630 630
 
631 631
 
632
-if ( ! function_exists( 'espresso_event_link_url' )) {
632
+if ( ! function_exists('espresso_event_link_url')) {
633 633
 	/**
634 634
 	 * espresso_event_link_url
635 635
 	 *
@@ -637,18 +637,18 @@  discard block
 block discarded – undo
637 637
 	 * @param bool $echo
638 638
 	 * @return string
639 639
 	 */
640
-	function espresso_event_link_url( $EVT_ID = 0, $echo = TRUE ) {
641
-		if ( $echo ) {
642
-			echo EEH_Event_View::event_link_url( $EVT_ID );
640
+	function espresso_event_link_url($EVT_ID = 0, $echo = TRUE) {
641
+		if ($echo) {
642
+			echo EEH_Event_View::event_link_url($EVT_ID);
643 643
 			return '';
644 644
 		}
645
-		return EEH_Event_View::event_link_url( $EVT_ID );
645
+		return EEH_Event_View::event_link_url($EVT_ID);
646 646
 	}
647 647
 }
648 648
 
649 649
 
650 650
 
651
-if ( ! function_exists( 'espresso_event_has_content_or_excerpt' )) {
651
+if ( ! function_exists('espresso_event_has_content_or_excerpt')) {
652 652
 	/**
653 653
 	 *    espresso_event_has_content_or_excerpt
654 654
 	 *
@@ -656,15 +656,15 @@  discard block
 block discarded – undo
656 656
 	 * @param bool $EVT_ID
657 657
 	 * @return    boolean
658 658
 	 */
659
-	function espresso_event_has_content_or_excerpt( $EVT_ID = FALSE ) {
660
-		return EEH_Event_View::event_has_content_or_excerpt( $EVT_ID );
659
+	function espresso_event_has_content_or_excerpt($EVT_ID = FALSE) {
660
+		return EEH_Event_View::event_has_content_or_excerpt($EVT_ID);
661 661
 	}
662 662
 }
663 663
 
664 664
 
665 665
 
666 666
 
667
-if ( ! function_exists( 'espresso_event_content_or_excerpt' )) {
667
+if ( ! function_exists('espresso_event_content_or_excerpt')) {
668 668
 	/**
669 669
 	 * espresso_event_content_or_excerpt
670 670
 	 *
@@ -673,18 +673,18 @@  discard block
 block discarded – undo
673 673
 	 * @param bool $echo
674 674
 	 * @return string
675 675
 	 */
676
-	function espresso_event_content_or_excerpt( $num_words = 55, $more = NULL, $echo = TRUE ) {
677
-		if ( $echo ) {
678
-			echo EEH_Event_View::event_content_or_excerpt( $num_words, $more );
676
+	function espresso_event_content_or_excerpt($num_words = 55, $more = NULL, $echo = TRUE) {
677
+		if ($echo) {
678
+			echo EEH_Event_View::event_content_or_excerpt($num_words, $more);
679 679
 			return '';
680 680
 		}
681
-		return EEH_Event_View::event_content_or_excerpt( $num_words, $more );
681
+		return EEH_Event_View::event_content_or_excerpt($num_words, $more);
682 682
 	}
683 683
 }
684 684
 
685 685
 
686 686
 
687
-if ( ! function_exists( 'espresso_event_phone' )) {
687
+if ( ! function_exists('espresso_event_phone')) {
688 688
 	/**
689 689
 	 * espresso_event_phone
690 690
 	 *
@@ -692,18 +692,18 @@  discard block
 block discarded – undo
692 692
 	 * @param bool $echo
693 693
 	 * @return string
694 694
 	 */
695
-	function espresso_event_phone( $EVT_ID = 0, $echo = TRUE ) {
696
-		if ( $echo ) {
697
-			echo EEH_Event_View::event_phone( $EVT_ID );
695
+	function espresso_event_phone($EVT_ID = 0, $echo = TRUE) {
696
+		if ($echo) {
697
+			echo EEH_Event_View::event_phone($EVT_ID);
698 698
 			return '';
699 699
 		}
700
-		return EEH_Event_View::event_phone( $EVT_ID );
700
+		return EEH_Event_View::event_phone($EVT_ID);
701 701
 	}
702 702
 }
703 703
 
704 704
 
705 705
 
706
-if ( ! function_exists( 'espresso_edit_event_link' )) {
706
+if ( ! function_exists('espresso_edit_event_link')) {
707 707
 	/**
708 708
 	 * espresso_edit_event_link
709 709
 	 * returns a link to edit an event
@@ -712,39 +712,39 @@  discard block
 block discarded – undo
712 712
 	 * @param bool $echo
713 713
 	 * @return string
714 714
 	 */
715
-	function espresso_edit_event_link( $EVT_ID = 0, $echo = TRUE ) {
716
-		if ( $echo ) {
717
-			echo EEH_Event_View::edit_event_link( $EVT_ID );
715
+	function espresso_edit_event_link($EVT_ID = 0, $echo = TRUE) {
716
+		if ($echo) {
717
+			echo EEH_Event_View::edit_event_link($EVT_ID);
718 718
 			return '';
719 719
 		}
720
-		return EEH_Event_View::edit_event_link( $EVT_ID );
720
+		return EEH_Event_View::edit_event_link($EVT_ID);
721 721
 	}
722 722
 }
723 723
 
724 724
 
725
-if ( ! function_exists( 'espresso_organization_name' )) {
725
+if ( ! function_exists('espresso_organization_name')) {
726 726
 	/**
727 727
 	 * espresso_organization_name
728 728
 	 * @param bool $echo
729 729
 	 * @return string
730 730
 	 */
731 731
 	function espresso_organization_name($echo = TRUE) {
732
-		if($echo){
733
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'name' );
732
+		if ($echo) {
733
+			echo EE_Registry::instance()->CFG->organization->get_pretty('name');
734 734
 			return '';
735 735
 		}
736
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'name' );
736
+		return EE_Registry::instance()->CFG->organization->get_pretty('name');
737 737
 	}
738 738
 }
739 739
 
740
-if ( ! function_exists( 'espresso_organization_address' )) {
740
+if ( ! function_exists('espresso_organization_address')) {
741 741
 	/**
742 742
 	 * espresso_organization_address
743 743
 	 * @param string $type
744 744
 	 * @return string
745 745
 	 */
746
-	function espresso_organization_address( $type = 'inline' ) {
747
-		if ( EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config ) {
746
+	function espresso_organization_address($type = 'inline') {
747
+		if (EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config) {
748 748
 			$address = new EventEspresso\core\domain\entities\GenericAddress(
749 749
 				EE_Registry::instance()->CFG->organization->address_1,
750 750
 				EE_Registry::instance()->CFG->organization->address_2,
@@ -753,129 +753,129 @@  discard block
 block discarded – undo
753 753
 				EE_Registry::instance()->CFG->organization->zip,
754 754
 				EE_Registry::instance()->CFG->organization->CNT_ISO
755 755
 			);
756
-			return EEH_Address::format( $address, $type );
756
+			return EEH_Address::format($address, $type);
757 757
 		}
758 758
 		return '';
759 759
 	}
760 760
 }
761 761
 
762
-if ( ! function_exists( 'espresso_organization_email' )) {
762
+if ( ! function_exists('espresso_organization_email')) {
763 763
 	/**
764 764
 	 * espresso_organization_email
765 765
 	 * @param bool $echo
766 766
 	 * @return string
767 767
 	 */
768
-	function espresso_organization_email( $echo = TRUE ) {
769
-		if($echo){
770
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'email' );
768
+	function espresso_organization_email($echo = TRUE) {
769
+		if ($echo) {
770
+			echo EE_Registry::instance()->CFG->organization->get_pretty('email');
771 771
 			return '';
772 772
 		}
773
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'email' );
773
+		return EE_Registry::instance()->CFG->organization->get_pretty('email');
774 774
 	}
775 775
 }
776 776
 
777
-if ( ! function_exists( 'espresso_organization_logo_url' )) {
777
+if ( ! function_exists('espresso_organization_logo_url')) {
778 778
 	/**
779 779
 	 * espresso_organization_logo_url
780 780
 	 * @param bool $echo
781 781
 	 * @return string
782 782
 	 */
783
-	function espresso_organization_logo_url( $echo = TRUE ) {
784
-		if($echo){
785
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'logo_url' );
783
+	function espresso_organization_logo_url($echo = TRUE) {
784
+		if ($echo) {
785
+			echo EE_Registry::instance()->CFG->organization->get_pretty('logo_url');
786 786
 			return '';
787 787
 		}
788
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'logo_url' );
788
+		return EE_Registry::instance()->CFG->organization->get_pretty('logo_url');
789 789
 	}
790 790
 }
791 791
 
792
-if ( ! function_exists( 'espresso_organization_facebook' )) {
792
+if ( ! function_exists('espresso_organization_facebook')) {
793 793
 	/**
794 794
 	 * espresso_organization_facebook
795 795
 	 * @param bool $echo
796 796
 	 * @return string
797 797
 	 */
798
-	function espresso_organization_facebook( $echo = TRUE ) {
799
-		if($echo){
800
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'facebook' );
798
+	function espresso_organization_facebook($echo = TRUE) {
799
+		if ($echo) {
800
+			echo EE_Registry::instance()->CFG->organization->get_pretty('facebook');
801 801
 			return '';
802 802
 		}
803
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'facebook' );
803
+		return EE_Registry::instance()->CFG->organization->get_pretty('facebook');
804 804
 	}
805 805
 }
806 806
 
807
-if ( ! function_exists( 'espresso_organization_twitter' )) {
807
+if ( ! function_exists('espresso_organization_twitter')) {
808 808
 	/**
809 809
 	 * espresso_organization_twitter
810 810
 	 * @param bool $echo
811 811
 	 * @return string
812 812
 	 */
813
-	function espresso_organization_twitter( $echo = TRUE ) {
814
-		if($echo){
815
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'twitter' );
813
+	function espresso_organization_twitter($echo = TRUE) {
814
+		if ($echo) {
815
+			echo EE_Registry::instance()->CFG->organization->get_pretty('twitter');
816 816
 			return '';
817 817
 		}
818
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'twitter' );
818
+		return EE_Registry::instance()->CFG->organization->get_pretty('twitter');
819 819
 	}
820 820
 }
821 821
 
822
-if ( ! function_exists( 'espresso_organization_linkedin' )) {
822
+if ( ! function_exists('espresso_organization_linkedin')) {
823 823
 	/**
824 824
 	 * espresso_organization_linkedin
825 825
 	 * @param bool $echo
826 826
 	 * @return string
827 827
 	 */
828
-	function espresso_organization_linkedin( $echo = TRUE ) {
829
-		if($echo){
830
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'linkedin' );
828
+	function espresso_organization_linkedin($echo = TRUE) {
829
+		if ($echo) {
830
+			echo EE_Registry::instance()->CFG->organization->get_pretty('linkedin');
831 831
 			return '';
832 832
 		}
833
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'linkedin' );
833
+		return EE_Registry::instance()->CFG->organization->get_pretty('linkedin');
834 834
 	}
835 835
 }
836 836
 
837
-if ( ! function_exists( 'espresso_organization_pinterest' )) {
837
+if ( ! function_exists('espresso_organization_pinterest')) {
838 838
 	/**
839 839
 	 * espresso_organization_pinterest
840 840
 	 * @param bool $echo
841 841
 	 * @return string
842 842
 	 */
843
-	function espresso_organization_pinterest( $echo = TRUE ) {
844
-		if($echo){
845
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'pinterest' );
843
+	function espresso_organization_pinterest($echo = TRUE) {
844
+		if ($echo) {
845
+			echo EE_Registry::instance()->CFG->organization->get_pretty('pinterest');
846 846
 			return '';
847 847
 		}
848
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'pinterest' );
848
+		return EE_Registry::instance()->CFG->organization->get_pretty('pinterest');
849 849
 	}
850 850
 }
851 851
 
852
-if ( ! function_exists( 'espresso_organization_google' )) {
852
+if ( ! function_exists('espresso_organization_google')) {
853 853
 	/**
854 854
 	 * espresso_organization_google
855 855
 	 * @param bool $echo
856 856
 	 * @return string
857 857
 	 */
858
-	function espresso_organization_google( $echo = TRUE ) {
859
-		if($echo){
860
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'google' );
858
+	function espresso_organization_google($echo = TRUE) {
859
+		if ($echo) {
860
+			echo EE_Registry::instance()->CFG->organization->get_pretty('google');
861 861
 			return '';
862 862
 		}
863
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'google' );
863
+		return EE_Registry::instance()->CFG->organization->get_pretty('google');
864 864
 	}
865 865
 }
866 866
 
867
-if ( ! function_exists( 'espresso_organization_instagram' )) {
867
+if ( ! function_exists('espresso_organization_instagram')) {
868 868
 	/**
869 869
 	 * espresso_organization_instagram
870 870
 	 * @param bool $echo
871 871
 	 * @return string
872 872
 	 */
873
-	function espresso_organization_instagram( $echo = TRUE ) {
874
-		if($echo){
875
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'instagram' );
873
+	function espresso_organization_instagram($echo = TRUE) {
874
+		if ($echo) {
875
+			echo EE_Registry::instance()->CFG->organization->get_pretty('instagram');
876 876
 			return '';
877 877
 		}
878
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'instagram' );
878
+		return EE_Registry::instance()->CFG->organization->get_pretty('instagram');
879 879
 	}
880 880
 }
881 881
 
@@ -885,7 +885,7 @@  discard block
 block discarded – undo
885 885
 
886 886
 
887 887
 
888
-if ( ! function_exists( 'espresso_event_venues' )) {
888
+if ( ! function_exists('espresso_event_venues')) {
889 889
 	/**
890 890
 	 * espresso_event_venues
891 891
 	 *
@@ -899,7 +899,7 @@  discard block
 block discarded – undo
899 899
 
900 900
 
901 901
 
902
-if ( ! function_exists( 'espresso_venue_id' )) {
902
+if ( ! function_exists('espresso_venue_id')) {
903 903
 	/**
904 904
 	 *    espresso_venue_name
905 905
 	 *
@@ -907,15 +907,15 @@  discard block
 block discarded – undo
907 907
 	 * @param     int $EVT_ID
908 908
 	 * @return    string
909 909
 	 */
910
-	function espresso_venue_id( $EVT_ID = 0 ) {
911
-		$venue = EEH_Venue_View::get_venue( $EVT_ID );
910
+	function espresso_venue_id($EVT_ID = 0) {
911
+		$venue = EEH_Venue_View::get_venue($EVT_ID);
912 912
 		return $venue instanceof EE_Venue ? $venue->ID() : 0;
913 913
 	}
914 914
 }
915 915
 
916 916
 
917 917
 
918
-if ( ! function_exists( 'espresso_is_venue_private' ) ) {
918
+if ( ! function_exists('espresso_is_venue_private')) {
919 919
 	/**
920 920
 	 * Return whether a venue is private or not.
921 921
 	 * @see EEH_Venue_View::get_venue() for more info on expected return results.
@@ -924,45 +924,45 @@  discard block
 block discarded – undo
924 924
 	 *
925 925
 	 * @return bool | null
926 926
 	 */
927
-	function espresso_is_venue_private( $VNU_ID = 0 ) {
928
-		return EEH_Venue_View::is_venue_private( $VNU_ID );
927
+	function espresso_is_venue_private($VNU_ID = 0) {
928
+		return EEH_Venue_View::is_venue_private($VNU_ID);
929 929
 	}
930 930
 }
931 931
 
932 932
 
933 933
 
934
-if ( ! function_exists( 'espresso_venue_is_password_protected' ) ) {
934
+if ( ! function_exists('espresso_venue_is_password_protected')) {
935 935
 	/**
936 936
 	 * returns true or false if a venue is password protected or not
937 937
 	 *
938 938
 	 * @param int     $VNU_ID optional, the venue id to check.
939 939
 	 * @return string
940 940
 	 */
941
-	function espresso_venue_is_password_protected( $VNU_ID = 0 ) {
942
-		EE_Registry::instance()->load_helper( 'Venue_View' );
943
-		return EEH_Venue_View::is_venue_password_protected( $VNU_ID );
941
+	function espresso_venue_is_password_protected($VNU_ID = 0) {
942
+		EE_Registry::instance()->load_helper('Venue_View');
943
+		return EEH_Venue_View::is_venue_password_protected($VNU_ID);
944 944
 	}
945 945
 }
946 946
 
947 947
 
948 948
 
949
-if ( ! function_exists( 'espresso_password_protected_venue_form' ) ) {
949
+if ( ! function_exists('espresso_password_protected_venue_form')) {
950 950
 	/**
951 951
 	 * Returns a password form if venue is password protected.
952 952
 	 *
953 953
 	 * @param int     $VNU_ID optional, the venue id to check.
954 954
 	 * @return string
955 955
 	 */
956
-	function espresso_password_protected_venue_form( $VNU_ID = 0 ) {
957
-		EE_Registry::instance()->load_helper( 'Venue_View' );
958
-		return EEH_Venue_View::password_protected_venue_form( $VNU_ID );
956
+	function espresso_password_protected_venue_form($VNU_ID = 0) {
957
+		EE_Registry::instance()->load_helper('Venue_View');
958
+		return EEH_Venue_View::password_protected_venue_form($VNU_ID);
959 959
 	}
960 960
 }
961 961
 
962 962
 
963 963
 
964 964
 
965
-if ( ! function_exists( 'espresso_venue_name' )) {
965
+if ( ! function_exists('espresso_venue_name')) {
966 966
 	/**
967 967
 	 *    espresso_venue_name
968 968
 	 *
@@ -972,19 +972,19 @@  discard block
 block discarded – undo
972 972
 	 * @param bool   $echo
973 973
 	 * @return    string
974 974
 	 */
975
-	function espresso_venue_name( $VNU_ID = 0, $link_to = 'details', $echo = TRUE ) {
976
-		if($echo){
977
-			echo EEH_Venue_View::venue_name( $link_to, $VNU_ID );
975
+	function espresso_venue_name($VNU_ID = 0, $link_to = 'details', $echo = TRUE) {
976
+		if ($echo) {
977
+			echo EEH_Venue_View::venue_name($link_to, $VNU_ID);
978 978
 			return '';
979 979
 		}
980
-		return EEH_Venue_View::venue_name( $link_to, $VNU_ID );
980
+		return EEH_Venue_View::venue_name($link_to, $VNU_ID);
981 981
 	}
982 982
 }
983 983
 
984 984
 
985 985
 
986 986
 
987
-if ( ! function_exists( 'espresso_venue_link' )) {
987
+if ( ! function_exists('espresso_venue_link')) {
988 988
 	/**
989 989
 	 * 	espresso_venue_link
990 990
 	 *
@@ -993,14 +993,14 @@  discard block
 block discarded – undo
993 993
 	 *  @param 	string 	$text
994 994
 	 *  @return 	string
995 995
 	 */
996
-	function espresso_venue_link( $VNU_ID = 0, $text = '' ) {
997
-		return EEH_Venue_View::venue_details_link( $VNU_ID, $text );
996
+	function espresso_venue_link($VNU_ID = 0, $text = '') {
997
+		return EEH_Venue_View::venue_details_link($VNU_ID, $text);
998 998
 	}
999 999
 }
1000 1000
 
1001 1001
 
1002 1002
 
1003
-if ( ! function_exists( 'espresso_venue_description' )) {
1003
+if ( ! function_exists('espresso_venue_description')) {
1004 1004
 	/**
1005 1005
 	 *    espresso_venue_description
1006 1006
 	 *
@@ -1009,17 +1009,17 @@  discard block
 block discarded – undo
1009 1009
 	 * @param bool $echo
1010 1010
 	 * @return    string
1011 1011
 	 */
1012
-	function espresso_venue_description( $VNU_ID = FALSE, $echo = TRUE ) {
1013
-		if($echo){
1014
-			echo EEH_Venue_View::venue_description( $VNU_ID );
1012
+	function espresso_venue_description($VNU_ID = FALSE, $echo = TRUE) {
1013
+		if ($echo) {
1014
+			echo EEH_Venue_View::venue_description($VNU_ID);
1015 1015
 			return '';
1016 1016
 		}
1017
-		return EEH_Venue_View::venue_description( $VNU_ID );
1017
+		return EEH_Venue_View::venue_description($VNU_ID);
1018 1018
 	}
1019 1019
 }
1020 1020
 
1021 1021
 
1022
-if ( ! function_exists( 'espresso_venue_excerpt' )) {
1022
+if ( ! function_exists('espresso_venue_excerpt')) {
1023 1023
 	/**
1024 1024
 	 *    espresso_venue_excerpt
1025 1025
 	 *
@@ -1028,18 +1028,18 @@  discard block
 block discarded – undo
1028 1028
 	 * @param bool $echo
1029 1029
 	 * @return    string
1030 1030
 	 */
1031
-	function espresso_venue_excerpt( $VNU_ID = 0,  $echo = TRUE ) {
1032
-		if ( $echo ) {
1033
-			echo EEH_Venue_View::venue_excerpt( $VNU_ID );
1031
+	function espresso_venue_excerpt($VNU_ID = 0, $echo = TRUE) {
1032
+		if ($echo) {
1033
+			echo EEH_Venue_View::venue_excerpt($VNU_ID);
1034 1034
 			return '';
1035 1035
 		}
1036
-		return EEH_Venue_View::venue_excerpt( $VNU_ID );
1036
+		return EEH_Venue_View::venue_excerpt($VNU_ID);
1037 1037
 	}
1038 1038
 }
1039 1039
 
1040 1040
 
1041 1041
 
1042
-if ( ! function_exists( 'espresso_venue_categories' )) {
1042
+if ( ! function_exists('espresso_venue_categories')) {
1043 1043
 	/**
1044 1044
 	 * espresso_venue_categories
1045 1045
 	 * returns the terms associated with a venue
@@ -1049,17 +1049,17 @@  discard block
 block discarded – undo
1049 1049
 	 * @param bool $echo
1050 1050
 	 * @return string
1051 1051
 	 */
1052
-	function espresso_venue_categories( $VNU_ID = 0, $hide_uncategorized = TRUE,  $echo = TRUE ) {
1053
-		if ( $echo ) {
1054
-			echo EEH_Venue_View::venue_categories( $VNU_ID, $hide_uncategorized );
1052
+	function espresso_venue_categories($VNU_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE) {
1053
+		if ($echo) {
1054
+			echo EEH_Venue_View::venue_categories($VNU_ID, $hide_uncategorized);
1055 1055
 			return '';
1056 1056
 		}
1057
-		return EEH_Venue_View::venue_categories( $VNU_ID, $hide_uncategorized );
1057
+		return EEH_Venue_View::venue_categories($VNU_ID, $hide_uncategorized);
1058 1058
 	}
1059 1059
 }
1060 1060
 
1061 1061
 
1062
-if ( ! function_exists( 'espresso_venue_address' )) {
1062
+if ( ! function_exists('espresso_venue_address')) {
1063 1063
 	/**
1064 1064
 	 * espresso_venue_address
1065 1065
 	 * returns a formatted block of html  for displaying a venue's address
@@ -1069,17 +1069,17 @@  discard block
 block discarded – undo
1069 1069
 	 * @param bool   $echo
1070 1070
 	 * @return string
1071 1071
 	 */
1072
-	function espresso_venue_address( $type = 'multiline', $VNU_ID = 0, $echo = TRUE ) {
1073
-		if ( $echo ) {
1074
-			echo EEH_Venue_View::venue_address( $type, $VNU_ID );
1072
+	function espresso_venue_address($type = 'multiline', $VNU_ID = 0, $echo = TRUE) {
1073
+		if ($echo) {
1074
+			echo EEH_Venue_View::venue_address($type, $VNU_ID);
1075 1075
 			return '';
1076 1076
 		}
1077
-		return EEH_Venue_View::venue_address( $type, $VNU_ID );
1077
+		return EEH_Venue_View::venue_address($type, $VNU_ID);
1078 1078
 	}
1079 1079
 }
1080 1080
 
1081 1081
 
1082
-if ( ! function_exists( 'espresso_venue_raw_address' )) {
1082
+if ( ! function_exists('espresso_venue_raw_address')) {
1083 1083
 	/**
1084 1084
 	 * espresso_venue_address
1085 1085
 	 * returns an UN-formatted string containing a venue's address
@@ -1089,17 +1089,17 @@  discard block
 block discarded – undo
1089 1089
 	 * @param bool     $echo
1090 1090
 	 * @return string
1091 1091
 	 */
1092
-	function espresso_venue_raw_address( $type = 'multiline', $VNU_ID = 0, $echo = TRUE ) {
1093
-		if ( $echo ) {
1094
-			echo EEH_Venue_View::venue_address( $type, $VNU_ID, FALSE, FALSE );
1092
+	function espresso_venue_raw_address($type = 'multiline', $VNU_ID = 0, $echo = TRUE) {
1093
+		if ($echo) {
1094
+			echo EEH_Venue_View::venue_address($type, $VNU_ID, FALSE, FALSE);
1095 1095
 			return '';
1096 1096
 		}
1097
-		return EEH_Venue_View::venue_address( $type, $VNU_ID, FALSE, FALSE );
1097
+		return EEH_Venue_View::venue_address($type, $VNU_ID, FALSE, FALSE);
1098 1098
 	}
1099 1099
 }
1100 1100
 
1101 1101
 
1102
-if ( ! function_exists( 'espresso_venue_has_address' )) {
1102
+if ( ! function_exists('espresso_venue_has_address')) {
1103 1103
 	/**
1104 1104
 	 * espresso_venue_has_address
1105 1105
 	 * returns TRUE or FALSE if a Venue has address information
@@ -1107,13 +1107,13 @@  discard block
 block discarded – undo
1107 1107
 	 * @param int $VNU_ID
1108 1108
 	 * @return bool
1109 1109
 	 */
1110
-	function espresso_venue_has_address( $VNU_ID = 0 ) {
1111
-		return EEH_Venue_View::venue_has_address( $VNU_ID );
1110
+	function espresso_venue_has_address($VNU_ID = 0) {
1111
+		return EEH_Venue_View::venue_has_address($VNU_ID);
1112 1112
 	}
1113 1113
 }
1114 1114
 
1115 1115
 
1116
-if ( ! function_exists( 'espresso_venue_gmap' )) {
1116
+if ( ! function_exists('espresso_venue_gmap')) {
1117 1117
 	/**
1118 1118
 	 * espresso_venue_gmap
1119 1119
 	 * returns a google map for the venue address
@@ -1124,17 +1124,17 @@  discard block
 block discarded – undo
1124 1124
 	 * @param bool     $echo
1125 1125
 	 * @return string
1126 1126
 	 */
1127
-	function espresso_venue_gmap( $VNU_ID = 0, $map_ID = FALSE, $gmap = array(), $echo = TRUE  ) {
1128
-		if ( $echo ) {
1129
-			echo EEH_Venue_View::venue_gmap( $VNU_ID, $map_ID, $gmap );
1127
+	function espresso_venue_gmap($VNU_ID = 0, $map_ID = FALSE, $gmap = array(), $echo = TRUE) {
1128
+		if ($echo) {
1129
+			echo EEH_Venue_View::venue_gmap($VNU_ID, $map_ID, $gmap);
1130 1130
 			return '';
1131 1131
 		}
1132
-		return EEH_Venue_View::venue_gmap( $VNU_ID, $map_ID, $gmap );
1132
+		return EEH_Venue_View::venue_gmap($VNU_ID, $map_ID, $gmap);
1133 1133
 	}
1134 1134
 }
1135 1135
 
1136 1136
 
1137
-if ( ! function_exists( 'espresso_venue_phone' )) {
1137
+if ( ! function_exists('espresso_venue_phone')) {
1138 1138
 	/**
1139 1139
 	 * espresso_venue_phone
1140 1140
 	 *
@@ -1142,18 +1142,18 @@  discard block
 block discarded – undo
1142 1142
 	 * @param bool $echo
1143 1143
 	 * @return string
1144 1144
 	 */
1145
-	function espresso_venue_phone( $VNU_ID = 0, $echo = TRUE ) {
1146
-		if ( $echo ) {
1147
-			echo EEH_Venue_View::venue_phone( $VNU_ID );
1145
+	function espresso_venue_phone($VNU_ID = 0, $echo = TRUE) {
1146
+		if ($echo) {
1147
+			echo EEH_Venue_View::venue_phone($VNU_ID);
1148 1148
 			return '';
1149 1149
 		}
1150
-		return EEH_Venue_View::venue_phone( $VNU_ID );
1150
+		return EEH_Venue_View::venue_phone($VNU_ID);
1151 1151
 	}
1152 1152
 }
1153 1153
 
1154 1154
 
1155 1155
 
1156
-if ( ! function_exists( 'espresso_venue_website' )) {
1156
+if ( ! function_exists('espresso_venue_website')) {
1157 1157
 	/**
1158 1158
 	 * espresso_venue_website
1159 1159
 	 *
@@ -1161,18 +1161,18 @@  discard block
 block discarded – undo
1161 1161
 	 * @param bool $echo
1162 1162
 	 * @return string
1163 1163
 	 */
1164
-	function espresso_venue_website( $VNU_ID = 0, $echo = TRUE ) {
1165
-		if ( $echo ) {
1166
-			echo EEH_Venue_View::venue_website_link( $VNU_ID );
1164
+	function espresso_venue_website($VNU_ID = 0, $echo = TRUE) {
1165
+		if ($echo) {
1166
+			echo EEH_Venue_View::venue_website_link($VNU_ID);
1167 1167
 			return '';
1168 1168
 		}
1169
-		return EEH_Venue_View::venue_website_link( $VNU_ID );
1169
+		return EEH_Venue_View::venue_website_link($VNU_ID);
1170 1170
 	}
1171 1171
 }
1172 1172
 
1173 1173
 
1174 1174
 
1175
-if ( ! function_exists( 'espresso_edit_venue_link' )) {
1175
+if ( ! function_exists('espresso_edit_venue_link')) {
1176 1176
 	/**
1177 1177
 	 * espresso_edit_venue_link
1178 1178
 	 *
@@ -1180,12 +1180,12 @@  discard block
 block discarded – undo
1180 1180
 	 * @param bool $echo
1181 1181
 	 * @return string
1182 1182
 	 */
1183
-	function espresso_edit_venue_link( $VNU_ID = 0, $echo = TRUE ) {
1184
-		if($echo){
1185
-			echo EEH_Venue_View::edit_venue_link( $VNU_ID );
1183
+	function espresso_edit_venue_link($VNU_ID = 0, $echo = TRUE) {
1184
+		if ($echo) {
1185
+			echo EEH_Venue_View::edit_venue_link($VNU_ID);
1186 1186
 			return '';
1187 1187
 		}
1188
-		return EEH_Venue_View::edit_venue_link( $VNU_ID );
1188
+		return EEH_Venue_View::edit_venue_link($VNU_ID);
1189 1189
 	}
1190 1190
 }
1191 1191
 
Please login to merge, or discard this patch.
core/services/notifications/PersistentAdminNoticeManager.php 2 patches
Indentation   +381 added lines, -381 removed lines patch added patch discarded remove patch
@@ -31,385 +31,385 @@
 block discarded – undo
31 31
 class PersistentAdminNoticeManager
32 32
 {
33 33
 
34
-    const WP_OPTION_KEY = 'ee_pers_admin_notices';
35
-
36
-    /**
37
-     * @var Collection|PersistentAdminNotice[] $notice_collection
38
-     */
39
-    private $notice_collection;
40
-
41
-    /**
42
-     * if AJAX is not enabled, then the return URL will be used for redirecting back to the admin page where the
43
-     * persistent admin notice was displayed, and ultimately dismissed from.
44
-     *
45
-     * @var string $return_url
46
-     */
47
-    private $return_url;
48
-
49
-    /**
50
-     * @var CapabilitiesChecker $capabilities_checker
51
-     */
52
-    private $capabilities_checker;
53
-
54
-    /**
55
-     * @var RequestInterface $request
56
-     */
57
-    private $request;
58
-
59
-
60
-    /**
61
-     * PersistentAdminNoticeManager constructor
62
-     *
63
-     * @param string              $return_url where to  redirect to after dismissing notices
64
-     * @param CapabilitiesChecker $capabilities_checker
65
-     * @param RequestInterface          $request
66
-     * @throws InvalidDataTypeException
67
-     */
68
-    public function __construct($return_url = '', CapabilitiesChecker $capabilities_checker, RequestInterface $request)
69
-    {
70
-        $this->setReturnUrl($return_url);
71
-        $this->capabilities_checker = $capabilities_checker;
72
-        $this->request = $request;
73
-        // setup up notices at priority 9 because `EE_Admin::display_admin_notices()` runs at priority 10,
74
-        // and we want to retrieve and generate any nag notices at the last possible moment
75
-        add_action('admin_notices', array($this, 'displayNotices'), 9);
76
-        add_action('network_admin_notices', array($this, 'displayNotices'), 9);
77
-        add_action('wp_ajax_dismiss_ee_nag_notice', array($this, 'dismissNotice'));
78
-        add_action('shutdown', array($this, 'registerAndSaveNotices'), 998);
79
-    }
80
-
81
-
82
-    /**
83
-     * @param string $return_url
84
-     * @throws InvalidDataTypeException
85
-     */
86
-    public function setReturnUrl($return_url)
87
-    {
88
-        if (! is_string($return_url)) {
89
-            throw new InvalidDataTypeException('$return_url', $return_url, 'string');
90
-        }
91
-        $this->return_url = $return_url;
92
-    }
93
-
94
-
95
-    /**
96
-     * @return Collection
97
-     * @throws InvalidEntityException
98
-     * @throws InvalidInterfaceException
99
-     * @throws InvalidDataTypeException
100
-     * @throws DomainException
101
-     * @throws DuplicateCollectionIdentifierException
102
-     */
103
-    protected function getPersistentAdminNoticeCollection()
104
-    {
105
-        if (! $this->notice_collection instanceof Collection) {
106
-            $this->notice_collection = new Collection(
107
-                'EventEspresso\core\domain\entities\notifications\PersistentAdminNotice'
108
-            );
109
-            $this->retrieveStoredNotices();
110
-            $this->registerNotices();
111
-        }
112
-        return $this->notice_collection;
113
-    }
114
-
115
-
116
-    /**
117
-     * generates PersistentAdminNotice objects for all non-dismissed notices saved to the db
118
-     *
119
-     * @return void
120
-     * @throws InvalidEntityException
121
-     * @throws DomainException
122
-     * @throws InvalidDataTypeException
123
-     * @throws DuplicateCollectionIdentifierException
124
-     */
125
-    protected function retrieveStoredNotices()
126
-    {
127
-        $persistent_admin_notices = get_option(PersistentAdminNoticeManager::WP_OPTION_KEY, array());
128
-        if (! empty($persistent_admin_notices)) {
129
-            foreach ($persistent_admin_notices as $name => $details) {
130
-                if (is_array($details)) {
131
-                    if (! isset(
132
-                        $details['message'],
133
-                        $details['capability'],
134
-                        $details['cap_context'],
135
-                        $details['dismissed']
136
-                    )) {
137
-                        throw new DomainException(
138
-                            sprintf(
139
-                                esc_html__(
140
-                                    'The "%1$s" PersistentAdminNotice could not be retrieved from the database.',
141
-                                    'event_espresso'
142
-                                ),
143
-                                $name
144
-                            )
145
-                        );
146
-                    }
147
-                    // new format for nag notices
148
-                    $this->notice_collection->add(
149
-                        new PersistentAdminNotice(
150
-                            $name,
151
-                            $details['message'],
152
-                            false,
153
-                            $details['capability'],
154
-                            $details['cap_context'],
155
-                            $details['dismissed']
156
-                        ),
157
-                        sanitize_key($name)
158
-                    );
159
-                } else {
160
-                    try {
161
-                        // old nag notices, that we want to convert to the new format
162
-                        $this->notice_collection->add(
163
-                            new PersistentAdminNotice(
164
-                                $name,
165
-                                (string) $details,
166
-                                false,
167
-                                '',
168
-                                '',
169
-                                empty($details)
170
-                            ),
171
-                            sanitize_key($name)
172
-                        );
173
-                    } catch (Exception $e) {
174
-                        EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
175
-                    }
176
-                }
177
-                // each notice will self register when the action hook in registerNotices is triggered
178
-            }
179
-        }
180
-    }
181
-
182
-
183
-    /**
184
-     * exposes the Persistent Admin Notice Collection via an action
185
-     * so that PersistentAdminNotice objects can be added and/or removed
186
-     * without compromising the actual collection like a filter would
187
-     */
188
-    protected function registerNotices()
189
-    {
190
-        do_action(
191
-            'AHEE__EventEspresso_core_services_notifications_PersistentAdminNoticeManager__registerNotices',
192
-            $this->notice_collection
193
-        );
194
-    }
195
-
196
-
197
-    /**
198
-     * @throws DomainException
199
-     * @throws InvalidClassException
200
-     * @throws InvalidDataTypeException
201
-     * @throws InvalidInterfaceException
202
-     * @throws InvalidEntityException
203
-     * @throws DuplicateCollectionIdentifierException
204
-     */
205
-    public function displayNotices()
206
-    {
207
-        $this->notice_collection = $this->getPersistentAdminNoticeCollection();
208
-        if ($this->notice_collection->hasObjects()) {
209
-            $enqueue_assets = false;
210
-            // and display notices
211
-            foreach ($this->notice_collection as $persistent_admin_notice) {
212
-                /** @var PersistentAdminNotice $persistent_admin_notice */
213
-                // don't display notices that have already been dismissed
214
-                if ($persistent_admin_notice->getDismissed()) {
215
-                    continue;
216
-                }
217
-                try {
218
-                    $this->capabilities_checker->processCapCheck(
219
-                        $persistent_admin_notice->getCapCheck()
220
-                    );
221
-                } catch (InsufficientPermissionsException $e) {
222
-                    // user does not have required cap, so skip to next notice
223
-                    // and just eat the exception - nom nom nom nom
224
-                    continue;
225
-                }
226
-                if ($persistent_admin_notice->getMessage() === '') {
227
-                    continue;
228
-                }
229
-                $this->displayPersistentAdminNotice($persistent_admin_notice);
230
-                $enqueue_assets = true;
231
-            }
232
-            if ($enqueue_assets) {
233
-                $this->enqueueAssets();
234
-            }
235
-        }
236
-    }
237
-
238
-
239
-    /**
240
-     * does what it's named
241
-     *
242
-     * @return void
243
-     */
244
-    public function enqueueAssets()
245
-    {
246
-        wp_register_script(
247
-            'espresso_core',
248
-            EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
249
-            array('jquery'),
250
-            EVENT_ESPRESSO_VERSION,
251
-            true
252
-        );
253
-        wp_register_script(
254
-            'ee_error_js',
255
-            EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js',
256
-            array('espresso_core'),
257
-            EVENT_ESPRESSO_VERSION,
258
-            true
259
-        );
260
-        wp_localize_script(
261
-            'ee_error_js',
262
-            'ee_dismiss',
263
-            array(
264
-                'return_url'    => urlencode($this->return_url),
265
-                'ajax_url'      => WP_AJAX_URL,
266
-                'unknown_error' => esc_html__(
267
-                    'An unknown error has occurred on the server while attempting to dismiss this notice.',
268
-                    'event_espresso'
269
-                ),
270
-            )
271
-        );
272
-        wp_enqueue_script('ee_error_js');
273
-    }
274
-
275
-
276
-    /**
277
-     * displayPersistentAdminNoticeHtml
278
-     *
279
-     * @param  PersistentAdminNotice $persistent_admin_notice
280
-     */
281
-    protected function displayPersistentAdminNotice(PersistentAdminNotice $persistent_admin_notice)
282
-    {
283
-        // used in template
284
-        $persistent_admin_notice_name = $persistent_admin_notice->getName();
285
-        $persistent_admin_notice_message = $persistent_admin_notice->getMessage();
286
-        require EE_TEMPLATES . DS . 'notifications' . DS . 'persistent_admin_notice.template.php';
287
-    }
288
-
289
-
290
-    /**
291
-     * dismissNotice
292
-     *
293
-     * @param string $pan_name the name, or key of the Persistent Admin Notice to be dismissed
294
-     * @param bool   $purge    if true, then delete it from the db
295
-     * @param bool   $return   forget all of this AJAX or redirect nonsense, and just return
296
-     * @return void
297
-     * @throws InvalidEntityException
298
-     * @throws InvalidInterfaceException
299
-     * @throws InvalidDataTypeException
300
-     * @throws DomainException
301
-     * @throws InvalidArgumentException
302
-     * @throws InvalidArgumentException
303
-     * @throws InvalidArgumentException
304
-     * @throws InvalidArgumentException
305
-     * @throws DuplicateCollectionIdentifierException
306
-     */
307
-    public function dismissNotice($pan_name = '', $purge = false, $return = false)
308
-    {
309
-        $pan_name = $this->request->getRequestParam('ee_nag_notice', $pan_name);
310
-        $this->notice_collection = $this->getPersistentAdminNoticeCollection();
311
-        if (! empty($pan_name) && $this->notice_collection->has($pan_name)) {
312
-            /** @var PersistentAdminNotice $persistent_admin_notice */
313
-            $persistent_admin_notice = $this->notice_collection->get($pan_name);
314
-            $persistent_admin_notice->setDismissed(true);
315
-            $persistent_admin_notice->setPurge($purge);
316
-            $this->saveNotices();
317
-        }
318
-        if ($return) {
319
-            return;
320
-        }
321
-        if ($this->request->isAjax()) {
322
-            // grab any notices and concatenate into string
323
-            echo wp_json_encode(
324
-                array(
325
-                    'errors' => implode('<br />', EE_Error::get_notices(false)),
326
-                )
327
-            );
328
-            exit();
329
-        }
330
-        // save errors to a transient to be displayed on next request (after redirect)
331
-        EE_Error::get_notices(false, true);
332
-        wp_safe_redirect(
333
-            urldecode(
334
-                $this->request->getRequestParam('return_url', '')
335
-            )
336
-        );
337
-    }
338
-
339
-
340
-    /**
341
-     * saveNotices
342
-     *
343
-     * @throws DomainException
344
-     * @throws InvalidDataTypeException
345
-     * @throws InvalidInterfaceException
346
-     * @throws InvalidEntityException
347
-     * @throws DuplicateCollectionIdentifierException
348
-     */
349
-    public function saveNotices()
350
-    {
351
-        $this->notice_collection = $this->getPersistentAdminNoticeCollection();
352
-        if ($this->notice_collection->hasObjects()) {
353
-            $persistent_admin_notices = get_option(PersistentAdminNoticeManager::WP_OPTION_KEY, array());
354
-            // maybe initialize persistent_admin_notices
355
-            if (empty($persistent_admin_notices)) {
356
-                add_option(PersistentAdminNoticeManager::WP_OPTION_KEY, array(), '', 'no');
357
-            }
358
-            foreach ($this->notice_collection as $persistent_admin_notice) {
359
-                // are we deleting this notice ?
360
-                if ($persistent_admin_notice->getPurge()) {
361
-                    unset($persistent_admin_notices[ $persistent_admin_notice->getName() ]);
362
-                } else {
363
-                    /** @var PersistentAdminNotice $persistent_admin_notice */
364
-                    $persistent_admin_notices[ $persistent_admin_notice->getName() ] = array(
365
-                        'message'     => $persistent_admin_notice->getMessage(),
366
-                        'capability'  => $persistent_admin_notice->getCapability(),
367
-                        'cap_context' => $persistent_admin_notice->getCapContext(),
368
-                        'dismissed'   => $persistent_admin_notice->getDismissed(),
369
-                    );
370
-                }
371
-            }
372
-            update_option(PersistentAdminNoticeManager::WP_OPTION_KEY, $persistent_admin_notices);
373
-        }
374
-    }
375
-
376
-
377
-    /**
378
-     * @throws DomainException
379
-     * @throws InvalidDataTypeException
380
-     * @throws InvalidEntityException
381
-     * @throws InvalidInterfaceException
382
-     * @throws DuplicateCollectionIdentifierException
383
-     */
384
-    public function registerAndSaveNotices()
385
-    {
386
-        $this->getPersistentAdminNoticeCollection();
387
-        $this->registerNotices();
388
-        $this->saveNotices();
389
-        add_filter(
390
-            'PersistentAdminNoticeManager__registerAndSaveNotices__complete',
391
-            '__return_true'
392
-        );
393
-    }
394
-
395
-
396
-    /**
397
-     * @throws DomainException
398
-     * @throws InvalidDataTypeException
399
-     * @throws InvalidEntityException
400
-     * @throws InvalidInterfaceException
401
-     * @throws InvalidArgumentException
402
-     * @throws DuplicateCollectionIdentifierException
403
-     */
404
-    public static function loadRegisterAndSaveNotices()
405
-    {
406
-        /** @var PersistentAdminNoticeManager $persistent_admin_notice_manager */
407
-        $persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared(
408
-            'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
409
-        );
410
-        // if shutdown has already run, then call registerAndSaveNotices() manually
411
-        if (did_action('shutdown')) {
412
-            $persistent_admin_notice_manager->registerAndSaveNotices();
413
-        }
414
-    }
34
+	const WP_OPTION_KEY = 'ee_pers_admin_notices';
35
+
36
+	/**
37
+	 * @var Collection|PersistentAdminNotice[] $notice_collection
38
+	 */
39
+	private $notice_collection;
40
+
41
+	/**
42
+	 * if AJAX is not enabled, then the return URL will be used for redirecting back to the admin page where the
43
+	 * persistent admin notice was displayed, and ultimately dismissed from.
44
+	 *
45
+	 * @var string $return_url
46
+	 */
47
+	private $return_url;
48
+
49
+	/**
50
+	 * @var CapabilitiesChecker $capabilities_checker
51
+	 */
52
+	private $capabilities_checker;
53
+
54
+	/**
55
+	 * @var RequestInterface $request
56
+	 */
57
+	private $request;
58
+
59
+
60
+	/**
61
+	 * PersistentAdminNoticeManager constructor
62
+	 *
63
+	 * @param string              $return_url where to  redirect to after dismissing notices
64
+	 * @param CapabilitiesChecker $capabilities_checker
65
+	 * @param RequestInterface          $request
66
+	 * @throws InvalidDataTypeException
67
+	 */
68
+	public function __construct($return_url = '', CapabilitiesChecker $capabilities_checker, RequestInterface $request)
69
+	{
70
+		$this->setReturnUrl($return_url);
71
+		$this->capabilities_checker = $capabilities_checker;
72
+		$this->request = $request;
73
+		// setup up notices at priority 9 because `EE_Admin::display_admin_notices()` runs at priority 10,
74
+		// and we want to retrieve and generate any nag notices at the last possible moment
75
+		add_action('admin_notices', array($this, 'displayNotices'), 9);
76
+		add_action('network_admin_notices', array($this, 'displayNotices'), 9);
77
+		add_action('wp_ajax_dismiss_ee_nag_notice', array($this, 'dismissNotice'));
78
+		add_action('shutdown', array($this, 'registerAndSaveNotices'), 998);
79
+	}
80
+
81
+
82
+	/**
83
+	 * @param string $return_url
84
+	 * @throws InvalidDataTypeException
85
+	 */
86
+	public function setReturnUrl($return_url)
87
+	{
88
+		if (! is_string($return_url)) {
89
+			throw new InvalidDataTypeException('$return_url', $return_url, 'string');
90
+		}
91
+		$this->return_url = $return_url;
92
+	}
93
+
94
+
95
+	/**
96
+	 * @return Collection
97
+	 * @throws InvalidEntityException
98
+	 * @throws InvalidInterfaceException
99
+	 * @throws InvalidDataTypeException
100
+	 * @throws DomainException
101
+	 * @throws DuplicateCollectionIdentifierException
102
+	 */
103
+	protected function getPersistentAdminNoticeCollection()
104
+	{
105
+		if (! $this->notice_collection instanceof Collection) {
106
+			$this->notice_collection = new Collection(
107
+				'EventEspresso\core\domain\entities\notifications\PersistentAdminNotice'
108
+			);
109
+			$this->retrieveStoredNotices();
110
+			$this->registerNotices();
111
+		}
112
+		return $this->notice_collection;
113
+	}
114
+
115
+
116
+	/**
117
+	 * generates PersistentAdminNotice objects for all non-dismissed notices saved to the db
118
+	 *
119
+	 * @return void
120
+	 * @throws InvalidEntityException
121
+	 * @throws DomainException
122
+	 * @throws InvalidDataTypeException
123
+	 * @throws DuplicateCollectionIdentifierException
124
+	 */
125
+	protected function retrieveStoredNotices()
126
+	{
127
+		$persistent_admin_notices = get_option(PersistentAdminNoticeManager::WP_OPTION_KEY, array());
128
+		if (! empty($persistent_admin_notices)) {
129
+			foreach ($persistent_admin_notices as $name => $details) {
130
+				if (is_array($details)) {
131
+					if (! isset(
132
+						$details['message'],
133
+						$details['capability'],
134
+						$details['cap_context'],
135
+						$details['dismissed']
136
+					)) {
137
+						throw new DomainException(
138
+							sprintf(
139
+								esc_html__(
140
+									'The "%1$s" PersistentAdminNotice could not be retrieved from the database.',
141
+									'event_espresso'
142
+								),
143
+								$name
144
+							)
145
+						);
146
+					}
147
+					// new format for nag notices
148
+					$this->notice_collection->add(
149
+						new PersistentAdminNotice(
150
+							$name,
151
+							$details['message'],
152
+							false,
153
+							$details['capability'],
154
+							$details['cap_context'],
155
+							$details['dismissed']
156
+						),
157
+						sanitize_key($name)
158
+					);
159
+				} else {
160
+					try {
161
+						// old nag notices, that we want to convert to the new format
162
+						$this->notice_collection->add(
163
+							new PersistentAdminNotice(
164
+								$name,
165
+								(string) $details,
166
+								false,
167
+								'',
168
+								'',
169
+								empty($details)
170
+							),
171
+							sanitize_key($name)
172
+						);
173
+					} catch (Exception $e) {
174
+						EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
175
+					}
176
+				}
177
+				// each notice will self register when the action hook in registerNotices is triggered
178
+			}
179
+		}
180
+	}
181
+
182
+
183
+	/**
184
+	 * exposes the Persistent Admin Notice Collection via an action
185
+	 * so that PersistentAdminNotice objects can be added and/or removed
186
+	 * without compromising the actual collection like a filter would
187
+	 */
188
+	protected function registerNotices()
189
+	{
190
+		do_action(
191
+			'AHEE__EventEspresso_core_services_notifications_PersistentAdminNoticeManager__registerNotices',
192
+			$this->notice_collection
193
+		);
194
+	}
195
+
196
+
197
+	/**
198
+	 * @throws DomainException
199
+	 * @throws InvalidClassException
200
+	 * @throws InvalidDataTypeException
201
+	 * @throws InvalidInterfaceException
202
+	 * @throws InvalidEntityException
203
+	 * @throws DuplicateCollectionIdentifierException
204
+	 */
205
+	public function displayNotices()
206
+	{
207
+		$this->notice_collection = $this->getPersistentAdminNoticeCollection();
208
+		if ($this->notice_collection->hasObjects()) {
209
+			$enqueue_assets = false;
210
+			// and display notices
211
+			foreach ($this->notice_collection as $persistent_admin_notice) {
212
+				/** @var PersistentAdminNotice $persistent_admin_notice */
213
+				// don't display notices that have already been dismissed
214
+				if ($persistent_admin_notice->getDismissed()) {
215
+					continue;
216
+				}
217
+				try {
218
+					$this->capabilities_checker->processCapCheck(
219
+						$persistent_admin_notice->getCapCheck()
220
+					);
221
+				} catch (InsufficientPermissionsException $e) {
222
+					// user does not have required cap, so skip to next notice
223
+					// and just eat the exception - nom nom nom nom
224
+					continue;
225
+				}
226
+				if ($persistent_admin_notice->getMessage() === '') {
227
+					continue;
228
+				}
229
+				$this->displayPersistentAdminNotice($persistent_admin_notice);
230
+				$enqueue_assets = true;
231
+			}
232
+			if ($enqueue_assets) {
233
+				$this->enqueueAssets();
234
+			}
235
+		}
236
+	}
237
+
238
+
239
+	/**
240
+	 * does what it's named
241
+	 *
242
+	 * @return void
243
+	 */
244
+	public function enqueueAssets()
245
+	{
246
+		wp_register_script(
247
+			'espresso_core',
248
+			EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
249
+			array('jquery'),
250
+			EVENT_ESPRESSO_VERSION,
251
+			true
252
+		);
253
+		wp_register_script(
254
+			'ee_error_js',
255
+			EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js',
256
+			array('espresso_core'),
257
+			EVENT_ESPRESSO_VERSION,
258
+			true
259
+		);
260
+		wp_localize_script(
261
+			'ee_error_js',
262
+			'ee_dismiss',
263
+			array(
264
+				'return_url'    => urlencode($this->return_url),
265
+				'ajax_url'      => WP_AJAX_URL,
266
+				'unknown_error' => esc_html__(
267
+					'An unknown error has occurred on the server while attempting to dismiss this notice.',
268
+					'event_espresso'
269
+				),
270
+			)
271
+		);
272
+		wp_enqueue_script('ee_error_js');
273
+	}
274
+
275
+
276
+	/**
277
+	 * displayPersistentAdminNoticeHtml
278
+	 *
279
+	 * @param  PersistentAdminNotice $persistent_admin_notice
280
+	 */
281
+	protected function displayPersistentAdminNotice(PersistentAdminNotice $persistent_admin_notice)
282
+	{
283
+		// used in template
284
+		$persistent_admin_notice_name = $persistent_admin_notice->getName();
285
+		$persistent_admin_notice_message = $persistent_admin_notice->getMessage();
286
+		require EE_TEMPLATES . DS . 'notifications' . DS . 'persistent_admin_notice.template.php';
287
+	}
288
+
289
+
290
+	/**
291
+	 * dismissNotice
292
+	 *
293
+	 * @param string $pan_name the name, or key of the Persistent Admin Notice to be dismissed
294
+	 * @param bool   $purge    if true, then delete it from the db
295
+	 * @param bool   $return   forget all of this AJAX or redirect nonsense, and just return
296
+	 * @return void
297
+	 * @throws InvalidEntityException
298
+	 * @throws InvalidInterfaceException
299
+	 * @throws InvalidDataTypeException
300
+	 * @throws DomainException
301
+	 * @throws InvalidArgumentException
302
+	 * @throws InvalidArgumentException
303
+	 * @throws InvalidArgumentException
304
+	 * @throws InvalidArgumentException
305
+	 * @throws DuplicateCollectionIdentifierException
306
+	 */
307
+	public function dismissNotice($pan_name = '', $purge = false, $return = false)
308
+	{
309
+		$pan_name = $this->request->getRequestParam('ee_nag_notice', $pan_name);
310
+		$this->notice_collection = $this->getPersistentAdminNoticeCollection();
311
+		if (! empty($pan_name) && $this->notice_collection->has($pan_name)) {
312
+			/** @var PersistentAdminNotice $persistent_admin_notice */
313
+			$persistent_admin_notice = $this->notice_collection->get($pan_name);
314
+			$persistent_admin_notice->setDismissed(true);
315
+			$persistent_admin_notice->setPurge($purge);
316
+			$this->saveNotices();
317
+		}
318
+		if ($return) {
319
+			return;
320
+		}
321
+		if ($this->request->isAjax()) {
322
+			// grab any notices and concatenate into string
323
+			echo wp_json_encode(
324
+				array(
325
+					'errors' => implode('<br />', EE_Error::get_notices(false)),
326
+				)
327
+			);
328
+			exit();
329
+		}
330
+		// save errors to a transient to be displayed on next request (after redirect)
331
+		EE_Error::get_notices(false, true);
332
+		wp_safe_redirect(
333
+			urldecode(
334
+				$this->request->getRequestParam('return_url', '')
335
+			)
336
+		);
337
+	}
338
+
339
+
340
+	/**
341
+	 * saveNotices
342
+	 *
343
+	 * @throws DomainException
344
+	 * @throws InvalidDataTypeException
345
+	 * @throws InvalidInterfaceException
346
+	 * @throws InvalidEntityException
347
+	 * @throws DuplicateCollectionIdentifierException
348
+	 */
349
+	public function saveNotices()
350
+	{
351
+		$this->notice_collection = $this->getPersistentAdminNoticeCollection();
352
+		if ($this->notice_collection->hasObjects()) {
353
+			$persistent_admin_notices = get_option(PersistentAdminNoticeManager::WP_OPTION_KEY, array());
354
+			// maybe initialize persistent_admin_notices
355
+			if (empty($persistent_admin_notices)) {
356
+				add_option(PersistentAdminNoticeManager::WP_OPTION_KEY, array(), '', 'no');
357
+			}
358
+			foreach ($this->notice_collection as $persistent_admin_notice) {
359
+				// are we deleting this notice ?
360
+				if ($persistent_admin_notice->getPurge()) {
361
+					unset($persistent_admin_notices[ $persistent_admin_notice->getName() ]);
362
+				} else {
363
+					/** @var PersistentAdminNotice $persistent_admin_notice */
364
+					$persistent_admin_notices[ $persistent_admin_notice->getName() ] = array(
365
+						'message'     => $persistent_admin_notice->getMessage(),
366
+						'capability'  => $persistent_admin_notice->getCapability(),
367
+						'cap_context' => $persistent_admin_notice->getCapContext(),
368
+						'dismissed'   => $persistent_admin_notice->getDismissed(),
369
+					);
370
+				}
371
+			}
372
+			update_option(PersistentAdminNoticeManager::WP_OPTION_KEY, $persistent_admin_notices);
373
+		}
374
+	}
375
+
376
+
377
+	/**
378
+	 * @throws DomainException
379
+	 * @throws InvalidDataTypeException
380
+	 * @throws InvalidEntityException
381
+	 * @throws InvalidInterfaceException
382
+	 * @throws DuplicateCollectionIdentifierException
383
+	 */
384
+	public function registerAndSaveNotices()
385
+	{
386
+		$this->getPersistentAdminNoticeCollection();
387
+		$this->registerNotices();
388
+		$this->saveNotices();
389
+		add_filter(
390
+			'PersistentAdminNoticeManager__registerAndSaveNotices__complete',
391
+			'__return_true'
392
+		);
393
+	}
394
+
395
+
396
+	/**
397
+	 * @throws DomainException
398
+	 * @throws InvalidDataTypeException
399
+	 * @throws InvalidEntityException
400
+	 * @throws InvalidInterfaceException
401
+	 * @throws InvalidArgumentException
402
+	 * @throws DuplicateCollectionIdentifierException
403
+	 */
404
+	public static function loadRegisterAndSaveNotices()
405
+	{
406
+		/** @var PersistentAdminNoticeManager $persistent_admin_notice_manager */
407
+		$persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared(
408
+			'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
409
+		);
410
+		// if shutdown has already run, then call registerAndSaveNotices() manually
411
+		if (did_action('shutdown')) {
412
+			$persistent_admin_notice_manager->registerAndSaveNotices();
413
+		}
414
+	}
415 415
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
      */
86 86
     public function setReturnUrl($return_url)
87 87
     {
88
-        if (! is_string($return_url)) {
88
+        if ( ! is_string($return_url)) {
89 89
             throw new InvalidDataTypeException('$return_url', $return_url, 'string');
90 90
         }
91 91
         $this->return_url = $return_url;
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
      */
103 103
     protected function getPersistentAdminNoticeCollection()
104 104
     {
105
-        if (! $this->notice_collection instanceof Collection) {
105
+        if ( ! $this->notice_collection instanceof Collection) {
106 106
             $this->notice_collection = new Collection(
107 107
                 'EventEspresso\core\domain\entities\notifications\PersistentAdminNotice'
108 108
             );
@@ -125,10 +125,10 @@  discard block
 block discarded – undo
125 125
     protected function retrieveStoredNotices()
126 126
     {
127 127
         $persistent_admin_notices = get_option(PersistentAdminNoticeManager::WP_OPTION_KEY, array());
128
-        if (! empty($persistent_admin_notices)) {
128
+        if ( ! empty($persistent_admin_notices)) {
129 129
             foreach ($persistent_admin_notices as $name => $details) {
130 130
                 if (is_array($details)) {
131
-                    if (! isset(
131
+                    if ( ! isset(
132 132
                         $details['message'],
133 133
                         $details['capability'],
134 134
                         $details['cap_context'],
@@ -245,14 +245,14 @@  discard block
 block discarded – undo
245 245
     {
246 246
         wp_register_script(
247 247
             'espresso_core',
248
-            EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
248
+            EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js',
249 249
             array('jquery'),
250 250
             EVENT_ESPRESSO_VERSION,
251 251
             true
252 252
         );
253 253
         wp_register_script(
254 254
             'ee_error_js',
255
-            EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js',
255
+            EE_GLOBAL_ASSETS_URL.'scripts/EE_Error.js',
256 256
             array('espresso_core'),
257 257
             EVENT_ESPRESSO_VERSION,
258 258
             true
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
         // used in template
284 284
         $persistent_admin_notice_name = $persistent_admin_notice->getName();
285 285
         $persistent_admin_notice_message = $persistent_admin_notice->getMessage();
286
-        require EE_TEMPLATES . DS . 'notifications' . DS . 'persistent_admin_notice.template.php';
286
+        require EE_TEMPLATES.DS.'notifications'.DS.'persistent_admin_notice.template.php';
287 287
     }
288 288
 
289 289
 
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
     {
309 309
         $pan_name = $this->request->getRequestParam('ee_nag_notice', $pan_name);
310 310
         $this->notice_collection = $this->getPersistentAdminNoticeCollection();
311
-        if (! empty($pan_name) && $this->notice_collection->has($pan_name)) {
311
+        if ( ! empty($pan_name) && $this->notice_collection->has($pan_name)) {
312 312
             /** @var PersistentAdminNotice $persistent_admin_notice */
313 313
             $persistent_admin_notice = $this->notice_collection->get($pan_name);
314 314
             $persistent_admin_notice->setDismissed(true);
@@ -358,10 +358,10 @@  discard block
 block discarded – undo
358 358
             foreach ($this->notice_collection as $persistent_admin_notice) {
359 359
                 // are we deleting this notice ?
360 360
                 if ($persistent_admin_notice->getPurge()) {
361
-                    unset($persistent_admin_notices[ $persistent_admin_notice->getName() ]);
361
+                    unset($persistent_admin_notices[$persistent_admin_notice->getName()]);
362 362
                 } else {
363 363
                     /** @var PersistentAdminNotice $persistent_admin_notice */
364
-                    $persistent_admin_notices[ $persistent_admin_notice->getName() ] = array(
364
+                    $persistent_admin_notices[$persistent_admin_notice->getName()] = array(
365 365
                         'message'     => $persistent_admin_notice->getMessage(),
366 366
                         'capability'  => $persistent_admin_notice->getCapability(),
367 367
                         'cap_context' => $persistent_admin_notice->getCapContext(),
Please login to merge, or discard this patch.
core/EE_Dependency_Map.core.php 1 patch
Indentation   +994 added lines, -994 removed lines patch added patch discarded remove patch
@@ -20,998 +20,998 @@
 block discarded – undo
20 20
 class EE_Dependency_Map
21 21
 {
22 22
 
23
-    /**
24
-     * This means that the requested class dependency is not present in the dependency map
25
-     */
26
-    const not_registered = 0;
27
-
28
-    /**
29
-     * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class.
30
-     */
31
-    const load_new_object = 1;
32
-
33
-    /**
34
-     * This instructs class loaders to return a previously instantiated and cached object for the requested class.
35
-     * IF a previously instantiated object does not exist, a new one will be created and added to the cache.
36
-     */
37
-    const load_from_cache = 2;
38
-
39
-    /**
40
-     * When registering a dependency,
41
-     * this indicates to keep any existing dependencies that already exist,
42
-     * and simply discard any new dependencies declared in the incoming data
43
-     */
44
-    const KEEP_EXISTING_DEPENDENCIES = 0;
45
-
46
-    /**
47
-     * When registering a dependency,
48
-     * this indicates to overwrite any existing dependencies that already exist using the incoming data
49
-     */
50
-    const OVERWRITE_DEPENDENCIES = 1;
51
-
52
-
53
-    /**
54
-     * @type EE_Dependency_Map $_instance
55
-     */
56
-    protected static $_instance;
57
-
58
-    /**
59
-     * @var ClassInterfaceCache $class_cache
60
-     */
61
-    private $class_cache;
62
-
63
-    /**
64
-     * @type RequestInterface $request
65
-     */
66
-    protected $request;
67
-
68
-    /**
69
-     * @type LegacyRequestInterface $legacy_request
70
-     */
71
-    protected $legacy_request;
72
-
73
-    /**
74
-     * @type ResponseInterface $response
75
-     */
76
-    protected $response;
77
-
78
-    /**
79
-     * @type LoaderInterface $loader
80
-     */
81
-    protected $loader;
82
-
83
-    /**
84
-     * @type array $_dependency_map
85
-     */
86
-    protected $_dependency_map = array();
87
-
88
-    /**
89
-     * @type array $_class_loaders
90
-     */
91
-    protected $_class_loaders = array();
92
-
93
-
94
-    /**
95
-     * EE_Dependency_Map constructor.
96
-     *
97
-     * @param ClassInterfaceCache $class_cache
98
-     */
99
-    protected function __construct(ClassInterfaceCache $class_cache)
100
-    {
101
-        $this->class_cache = $class_cache;
102
-        do_action('EE_Dependency_Map____construct', $this);
103
-    }
104
-
105
-
106
-    /**
107
-     * @return void
108
-     */
109
-    public function initialize()
110
-    {
111
-        $this->_register_core_dependencies();
112
-        $this->_register_core_class_loaders();
113
-        $this->_register_core_aliases();
114
-    }
115
-
116
-
117
-    /**
118
-     * @singleton method used to instantiate class object
119
-     * @param ClassInterfaceCache|null $class_cache
120
-     * @return EE_Dependency_Map
121
-     */
122
-    public static function instance(ClassInterfaceCache $class_cache = null)
123
-    {
124
-        // check if class object is instantiated, and instantiated properly
125
-        if (! self::$_instance instanceof EE_Dependency_Map
126
-            && $class_cache instanceof ClassInterfaceCache
127
-        ) {
128
-            self::$_instance = new EE_Dependency_Map($class_cache);
129
-        }
130
-        return self::$_instance;
131
-    }
132
-
133
-
134
-    /**
135
-     * @param RequestInterface $request
136
-     */
137
-    public function setRequest(RequestInterface $request)
138
-    {
139
-        $this->request = $request;
140
-    }
141
-
142
-
143
-    /**
144
-     * @param LegacyRequestInterface $legacy_request
145
-     */
146
-    public function setLegacyRequest(LegacyRequestInterface $legacy_request)
147
-    {
148
-        $this->legacy_request = $legacy_request;
149
-    }
150
-
151
-
152
-    /**
153
-     * @param ResponseInterface $response
154
-     */
155
-    public function setResponse(ResponseInterface $response)
156
-    {
157
-        $this->response = $response;
158
-    }
159
-
160
-
161
-    /**
162
-     * @param LoaderInterface $loader
163
-     */
164
-    public function setLoader(LoaderInterface $loader)
165
-    {
166
-        $this->loader = $loader;
167
-    }
168
-
169
-
170
-    /**
171
-     * @param string $class
172
-     * @param array  $dependencies
173
-     * @param int    $overwrite
174
-     * @return bool
175
-     */
176
-    public static function register_dependencies(
177
-        $class,
178
-        array $dependencies,
179
-        $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
180
-    ) {
181
-        return self::$_instance->registerDependencies($class, $dependencies, $overwrite);
182
-    }
183
-
184
-
185
-    /**
186
-     * Assigns an array of class names and corresponding load sources (new or cached)
187
-     * to the class specified by the first parameter.
188
-     * IMPORTANT !!!
189
-     * The order of elements in the incoming $dependencies array MUST match
190
-     * the order of the constructor parameters for the class in question.
191
-     * This is especially important when overriding any existing dependencies that are registered.
192
-     * the third parameter controls whether any duplicate dependencies are overwritten or not.
193
-     *
194
-     * @param string $class
195
-     * @param array  $dependencies
196
-     * @param int    $overwrite
197
-     * @return bool
198
-     */
199
-    public function registerDependencies(
200
-        $class,
201
-        array $dependencies,
202
-        $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
203
-    ) {
204
-        $class = trim($class, '\\');
205
-        $registered = false;
206
-        if (empty(self::$_instance->_dependency_map[ $class ])) {
207
-            self::$_instance->_dependency_map[ $class ] = array();
208
-        }
209
-        // we need to make sure that any aliases used when registering a dependency
210
-        // get resolved to the correct class name
211
-        foreach ($dependencies as $dependency => $load_source) {
212
-            $alias = self::$_instance->getFqnForAlias($dependency);
213
-            if ($overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
214
-                || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ])
215
-            ) {
216
-                unset($dependencies[ $dependency ]);
217
-                $dependencies[ $alias ] = $load_source;
218
-                $registered = true;
219
-            }
220
-        }
221
-        // now add our two lists of dependencies together.
222
-        // using Union (+=) favours the arrays in precedence from left to right,
223
-        // so $dependencies is NOT overwritten because it is listed first
224
-        // ie: with A = B + C, entries in B take precedence over duplicate entries in C
225
-        // Union is way faster than array_merge() but should be used with caution...
226
-        // especially with numerically indexed arrays
227
-        $dependencies += self::$_instance->_dependency_map[ $class ];
228
-        // now we need to ensure that the resulting dependencies
229
-        // array only has the entries that are required for the class
230
-        // so first count how many dependencies were originally registered for the class
231
-        $dependency_count = count(self::$_instance->_dependency_map[ $class ]);
232
-        // if that count is non-zero (meaning dependencies were already registered)
233
-        self::$_instance->_dependency_map[ $class ] = $dependency_count
234
-            // then truncate the  final array to match that count
235
-            ? array_slice($dependencies, 0, $dependency_count)
236
-            // otherwise just take the incoming array because nothing previously existed
237
-            : $dependencies;
238
-        return $registered;
239
-    }
240
-
241
-
242
-    /**
243
-     * @param string $class_name
244
-     * @param string $loader
245
-     * @return bool
246
-     * @throws DomainException
247
-     */
248
-    public static function register_class_loader($class_name, $loader = 'load_core')
249
-    {
250
-        if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
251
-            throw new DomainException(
252
-                esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
253
-            );
254
-        }
255
-        // check that loader is callable or method starts with "load_" and exists in EE_Registry
256
-        if (! is_callable($loader)
257
-            && (
258
-                strpos($loader, 'load_') !== 0
259
-                || ! method_exists('EE_Registry', $loader)
260
-            )
261
-        ) {
262
-            throw new DomainException(
263
-                sprintf(
264
-                    esc_html__(
265
-                        '"%1$s" is not a valid loader method on EE_Registry.',
266
-                        'event_espresso'
267
-                    ),
268
-                    $loader
269
-                )
270
-            );
271
-        }
272
-        $class_name = self::$_instance->getFqnForAlias($class_name);
273
-        if (! isset(self::$_instance->_class_loaders[ $class_name ])) {
274
-            self::$_instance->_class_loaders[ $class_name ] = $loader;
275
-            return true;
276
-        }
277
-        return false;
278
-    }
279
-
280
-
281
-    /**
282
-     * @return array
283
-     */
284
-    public function dependency_map()
285
-    {
286
-        return $this->_dependency_map;
287
-    }
288
-
289
-
290
-    /**
291
-     * returns TRUE if dependency map contains a listing for the provided class name
292
-     *
293
-     * @param string $class_name
294
-     * @return boolean
295
-     */
296
-    public function has($class_name = '')
297
-    {
298
-        // all legacy models have the same dependencies
299
-        if (strpos($class_name, 'EEM_') === 0) {
300
-            $class_name = 'LEGACY_MODELS';
301
-        }
302
-        return isset($this->_dependency_map[ $class_name ]) ? true : false;
303
-    }
304
-
305
-
306
-    /**
307
-     * returns TRUE if dependency map contains a listing for the provided class name AND dependency
308
-     *
309
-     * @param string $class_name
310
-     * @param string $dependency
311
-     * @return bool
312
-     */
313
-    public function has_dependency_for_class($class_name = '', $dependency = '')
314
-    {
315
-        // all legacy models have the same dependencies
316
-        if (strpos($class_name, 'EEM_') === 0) {
317
-            $class_name = 'LEGACY_MODELS';
318
-        }
319
-        $dependency = $this->getFqnForAlias($dependency, $class_name);
320
-        return isset($this->_dependency_map[ $class_name ][ $dependency ])
321
-            ? true
322
-            : false;
323
-    }
324
-
325
-
326
-    /**
327
-     * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned
328
-     *
329
-     * @param string $class_name
330
-     * @param string $dependency
331
-     * @return int
332
-     */
333
-    public function loading_strategy_for_class_dependency($class_name = '', $dependency = '')
334
-    {
335
-        // all legacy models have the same dependencies
336
-        if (strpos($class_name, 'EEM_') === 0) {
337
-            $class_name = 'LEGACY_MODELS';
338
-        }
339
-        $dependency = $this->getFqnForAlias($dependency);
340
-        return $this->has_dependency_for_class($class_name, $dependency)
341
-            ? $this->_dependency_map[ $class_name ][ $dependency ]
342
-            : EE_Dependency_Map::not_registered;
343
-    }
344
-
345
-
346
-    /**
347
-     * @param string $class_name
348
-     * @return string | Closure
349
-     */
350
-    public function class_loader($class_name)
351
-    {
352
-        // all legacy models use load_model()
353
-        if (strpos($class_name, 'EEM_') === 0) {
354
-            return 'load_model';
355
-        }
356
-        // EE_CPT_*_Strategy classes like EE_CPT_Event_Strategy, EE_CPT_Venue_Strategy, etc
357
-        // perform strpos() first to avoid loading regex every time we load a class
358
-        if (strpos($class_name, 'EE_CPT_') === 0
359
-            && preg_match('/^EE_CPT_([a-zA-Z]+)_Strategy$/', $class_name)
360
-        ) {
361
-            return 'load_core';
362
-        }
363
-        $class_name = $this->getFqnForAlias($class_name);
364
-        return isset($this->_class_loaders[ $class_name ]) ? $this->_class_loaders[ $class_name ] : '';
365
-    }
366
-
367
-
368
-    /**
369
-     * @return array
370
-     */
371
-    public function class_loaders()
372
-    {
373
-        return $this->_class_loaders;
374
-    }
375
-
376
-
377
-    /**
378
-     * adds an alias for a classname
379
-     *
380
-     * @param string $fqcn      the class name that should be used (concrete class to replace interface)
381
-     * @param string $alias     the class name that would be type hinted for (abstract parent or interface)
382
-     * @param string $for_class the class that has the dependency (is type hinting for the interface)
383
-     */
384
-    public function add_alias($fqcn, $alias, $for_class = '')
385
-    {
386
-        $this->class_cache->addAlias($fqcn, $alias, $for_class);
387
-    }
388
-
389
-
390
-    /**
391
-     * Returns TRUE if the provided fully qualified name IS an alias
392
-     * WHY?
393
-     * Because if a class is type hinting for a concretion,
394
-     * then why would we need to find another class to supply it?
395
-     * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
396
-     * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
397
-     * Don't go looking for some substitute.
398
-     * Whereas if a class is type hinting for an interface...
399
-     * then we need to find an actual class to use.
400
-     * So the interface IS the alias for some other FQN,
401
-     * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
402
-     * represents some other class.
403
-     *
404
-     * @param string $fqn
405
-     * @param string $for_class
406
-     * @return bool
407
-     */
408
-    public function isAlias($fqn = '', $for_class = '')
409
-    {
410
-        return $this->class_cache->isAlias($fqn, $for_class);
411
-    }
412
-
413
-
414
-    /**
415
-     * Returns a FQN for provided alias if one exists, otherwise returns the original $alias
416
-     * functions recursively, so that multiple aliases can be used to drill down to a FQN
417
-     *  for example:
418
-     *      if the following two entries were added to the _aliases array:
419
-     *          array(
420
-     *              'interface_alias'           => 'some\namespace\interface'
421
-     *              'some\namespace\interface'  => 'some\namespace\classname'
422
-     *          )
423
-     *      then one could use EE_Registry::instance()->create( 'interface_alias' )
424
-     *      to load an instance of 'some\namespace\classname'
425
-     *
426
-     * @param string $alias
427
-     * @param string $for_class
428
-     * @return string
429
-     */
430
-    public function getFqnForAlias($alias = '', $for_class = '')
431
-    {
432
-        return (string) $this->class_cache->getFqnForAlias($alias, $for_class);
433
-    }
434
-
435
-
436
-    /**
437
-     * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache,
438
-     * if one exists, or whether a new object should be generated every time the requested class is loaded.
439
-     * This is done by using the following class constants:
440
-     *        EE_Dependency_Map::load_from_cache - loads previously instantiated object
441
-     *        EE_Dependency_Map::load_new_object - generates a new object every time
442
-     */
443
-    protected function _register_core_dependencies()
444
-    {
445
-        $this->_dependency_map = array(
446
-            'EE_Request_Handler'                                                                                          => array(
447
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
448
-            ),
449
-            'EE_System'                                                                                                   => array(
450
-                'EE_Registry'                                 => EE_Dependency_Map::load_from_cache,
451
-                'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
452
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
453
-                'EE_Maintenance_Mode'                         => EE_Dependency_Map::load_from_cache,
454
-            ),
455
-            'EE_Session'                                                                                                  => array(
456
-                'EventEspresso\core\services\cache\TransientCacheStorage'  => EE_Dependency_Map::load_from_cache,
457
-                'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
458
-                'EventEspresso\core\services\request\Request'              => EE_Dependency_Map::load_from_cache,
459
-                'EE_Encryption'                                            => EE_Dependency_Map::load_from_cache,
460
-            ),
461
-            'EE_Cart'                                                                                                     => array(
462
-                'EE_Session' => EE_Dependency_Map::load_from_cache,
463
-            ),
464
-            'EE_Front_Controller'                                                                                         => array(
465
-                'EE_Registry'              => EE_Dependency_Map::load_from_cache,
466
-                'EE_Request_Handler'       => EE_Dependency_Map::load_from_cache,
467
-                'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache,
468
-            ),
469
-            'EE_Messenger_Collection_Loader'                                                                              => array(
470
-                'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object,
471
-            ),
472
-            'EE_Message_Type_Collection_Loader'                                                                           => array(
473
-                'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object,
474
-            ),
475
-            'EE_Message_Resource_Manager'                                                                                 => array(
476
-                'EE_Messenger_Collection_Loader'    => EE_Dependency_Map::load_new_object,
477
-                'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object,
478
-                'EEM_Message_Template_Group'        => EE_Dependency_Map::load_from_cache,
479
-            ),
480
-            'EE_Message_Factory'                                                                                          => array(
481
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
482
-            ),
483
-            'EE_messages'                                                                                                 => array(
484
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
485
-            ),
486
-            'EE_Messages_Generator'                                                                                       => array(
487
-                'EE_Messages_Queue'                    => EE_Dependency_Map::load_new_object,
488
-                'EE_Messages_Data_Handler_Collection'  => EE_Dependency_Map::load_new_object,
489
-                'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object,
490
-                'EEH_Parse_Shortcodes'                 => EE_Dependency_Map::load_from_cache,
491
-            ),
492
-            'EE_Messages_Processor'                                                                                       => array(
493
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
494
-            ),
495
-            'EE_Messages_Queue'                                                                                           => array(
496
-                'EE_Message_Repository' => EE_Dependency_Map::load_new_object,
497
-            ),
498
-            'EE_Messages_Template_Defaults'                                                                               => array(
499
-                'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache,
500
-                'EEM_Message_Template'       => EE_Dependency_Map::load_from_cache,
501
-            ),
502
-            'EE_Message_To_Generate_From_Request'                                                                         => array(
503
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
504
-                'EE_Request_Handler'          => EE_Dependency_Map::load_from_cache,
505
-            ),
506
-            'EventEspresso\core\services\commands\CommandBus'                                                             => array(
507
-                'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache,
508
-            ),
509
-            'EventEspresso\services\commands\CommandHandler'                                                              => array(
510
-                'EE_Registry'         => EE_Dependency_Map::load_from_cache,
511
-                'CommandBusInterface' => EE_Dependency_Map::load_from_cache,
512
-            ),
513
-            'EventEspresso\core\services\commands\CommandHandlerManager'                                                  => array(
514
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
515
-            ),
516
-            'EventEspresso\core\services\commands\CompositeCommandHandler'                                                => array(
517
-                'EventEspresso\core\services\commands\CommandBus'     => EE_Dependency_Map::load_from_cache,
518
-                'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache,
519
-            ),
520
-            'EventEspresso\core\services\commands\CommandFactory'                                                         => array(
521
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
522
-            ),
523
-            'EventEspresso\core\services\commands\middleware\CapChecker'                                                  => array(
524
-                'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
525
-            ),
526
-            'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker'                                         => array(
527
-                'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
528
-            ),
529
-            'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker'                                     => array(
530
-                'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
531
-            ),
532
-            'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler'                          => array(
533
-                'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache,
534
-            ),
535
-            'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler'                     => array(
536
-                'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
537
-            ),
538
-            'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler'                    => array(
539
-                'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
540
-            ),
541
-            'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler'         => array(
542
-                'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
543
-            ),
544
-            'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array(
545
-                'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache,
546
-            ),
547
-            'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler'                              => array(
548
-                'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache,
549
-            ),
550
-            'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler'                              => array(
551
-                'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
552
-            ),
553
-            'EventEspresso\core\domain\services\registration\CancelRegistrationService'                                   => array(
554
-                'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
555
-            ),
556
-            'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler'                                  => array(
557
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
558
-            ),
559
-            'EventEspresso\core\services\database\TableManager'                                                           => array(
560
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
561
-            ),
562
-            'EE_Data_Migration_Class_Base'                                                                                => array(
563
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
564
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
565
-            ),
566
-            'EE_DMS_Core_4_1_0'                                                                                           => array(
567
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
568
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
569
-            ),
570
-            'EE_DMS_Core_4_2_0'                                                                                           => array(
571
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
572
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
573
-            ),
574
-            'EE_DMS_Core_4_3_0'                                                                                           => array(
575
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
576
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
577
-            ),
578
-            'EE_DMS_Core_4_4_0'                                                                                           => array(
579
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
580
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
581
-            ),
582
-            'EE_DMS_Core_4_5_0'                                                                                           => array(
583
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
584
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
585
-            ),
586
-            'EE_DMS_Core_4_6_0'                                                                                           => array(
587
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
588
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
589
-            ),
590
-            'EE_DMS_Core_4_7_0'                                                                                           => array(
591
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
592
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
593
-            ),
594
-            'EE_DMS_Core_4_8_0'                                                                                           => array(
595
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
596
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
597
-            ),
598
-            'EE_DMS_Core_4_9_0'                                                                                           => array(
599
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
600
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
601
-            ),
602
-            'EventEspresso\core\services\assets\I18nRegistry'                                                             => array(
603
-                array(),
604
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
605
-            ),
606
-            'EventEspresso\core\services\assets\Registry'                                                                 => array(
607
-                'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
608
-                'EventEspresso\core\services\assets\I18nRegistry'    => EE_Dependency_Map::load_from_cache,
609
-            ),
610
-            'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled'                                             => array(
611
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
612
-            ),
613
-            'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout'                                              => array(
614
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
615
-            ),
616
-            'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees'                                        => array(
617
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
618
-            ),
619
-            'EventEspresso\core\domain\entities\shortcodes\EspressoEvents'                                                => array(
620
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
621
-            ),
622
-            'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou'                                              => array(
623
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
624
-            ),
625
-            'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector'                                        => array(
626
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
627
-            ),
628
-            'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage'                                               => array(
629
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
630
-            ),
631
-            'EventEspresso\core\services\cache\BasicCacheManager'                                                         => array(
632
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
633
-            ),
634
-            'EventEspresso\core\services\cache\PostRelatedCacheManager'                                                   => array(
635
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
636
-            ),
637
-            'EventEspresso\core\domain\services\validation\email\EmailValidationService'                                  => array(
638
-                'EE_Registration_Config'                     => EE_Dependency_Map::load_from_cache,
639
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
640
-            ),
641
-            'EventEspresso\core\domain\values\EmailAddress'                                                               => array(
642
-                null,
643
-                'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache,
644
-            ),
645
-            'EventEspresso\core\services\orm\ModelFieldFactory'                                                           => array(
646
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
647
-            ),
648
-            'LEGACY_MODELS'                                                                                               => array(
649
-                null,
650
-                'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache,
651
-            ),
652
-            'EE_Module_Request_Router'                                                                                    => array(
653
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
654
-            ),
655
-            'EE_Registration_Processor'                                                                                   => array(
656
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
657
-            ),
658
-            'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'                                      => array(
659
-                null,
660
-                'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
661
-                'EventEspresso\core\services\request\Request'                         => EE_Dependency_Map::load_from_cache,
662
-            ),
663
-            'EventEspresso\core\services\licensing\LicenseService'                                                        => array(
664
-                'EventEspresso\core\domain\services\pue\Stats'  => EE_Dependency_Map::load_from_cache,
665
-                'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache,
666
-            ),
667
-            'EE_Admin_Transactions_List_Table'                                                                            => array(
668
-                null,
669
-                'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
670
-            ),
671
-            'EventEspresso\core\domain\services\pue\Stats'                                                                => array(
672
-                'EventEspresso\core\domain\services\pue\Config'        => EE_Dependency_Map::load_from_cache,
673
-                'EE_Maintenance_Mode'                                  => EE_Dependency_Map::load_from_cache,
674
-                'EventEspresso\core\domain\services\pue\StatsGatherer' => EE_Dependency_Map::load_from_cache,
675
-            ),
676
-            'EventEspresso\core\domain\services\pue\Config'                                                               => array(
677
-                'EE_Network_Config' => EE_Dependency_Map::load_from_cache,
678
-                'EE_Config'         => EE_Dependency_Map::load_from_cache,
679
-            ),
680
-            'EventEspresso\core\domain\services\pue\StatsGatherer'                                                        => array(
681
-                'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
682
-                'EEM_Event'          => EE_Dependency_Map::load_from_cache,
683
-                'EEM_Datetime'       => EE_Dependency_Map::load_from_cache,
684
-                'EEM_Ticket'         => EE_Dependency_Map::load_from_cache,
685
-                'EEM_Registration'   => EE_Dependency_Map::load_from_cache,
686
-                'EEM_Transaction'    => EE_Dependency_Map::load_from_cache,
687
-                'EE_Config'          => EE_Dependency_Map::load_from_cache,
688
-            ),
689
-            'EventEspresso\core\domain\services\admin\ExitModal'                                                          => array(
690
-                'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache,
691
-            ),
692
-            'EventEspresso\core\domain\services\admin\PluginUpsells'                                                      => array(
693
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
694
-            ),
695
-            'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha'                                    => array(
696
-                'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
697
-                'EE_Session'             => EE_Dependency_Map::load_from_cache,
698
-            ),
699
-            'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings'                                => array(
700
-                'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
701
-            ),
702
-            'EventEspresso\modules\ticket_selector\ProcessTicketSelector'                                                 => array(
703
-                'EE_Core_Config'                                                          => EE_Dependency_Map::load_from_cache,
704
-                'EventEspresso\core\services\request\Request'                             => EE_Dependency_Map::load_from_cache,
705
-                'EE_Session'                                                              => EE_Dependency_Map::load_from_cache,
706
-                'EEM_Ticket'                                                              => EE_Dependency_Map::load_from_cache,
707
-                'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache,
708
-            ),
709
-            'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker'                                     => array(
710
-                'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
711
-            ),
712
-            'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'                              => array(
713
-                'EE_Core_Config'                             => EE_Dependency_Map::load_from_cache,
714
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
715
-            ),
716
-            'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes'                                => array(
717
-                'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
718
-            ),
719
-            'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies'                               => array(
720
-                'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
721
-            ),
722
-            'EE_CPT_Strategy'                                                                                             => array(
723
-                'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
724
-                'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
725
-            ),
726
-            'EventEspresso\core\services\loaders\ObjectIdentifier'                                                        => array(
727
-                'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
728
-            ),
729
-            'EventEspresso\core\domain\services\assets\CoreAssetManager'                                                  => array(
730
-                'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
731
-                'EE_Currency_Config'                                 => EE_Dependency_Map::load_from_cache,
732
-                'EE_Template_Config'                                 => EE_Dependency_Map::load_from_cache,
733
-                'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
734
-                'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
735
-            ),
736
-            'EventEspresso\core\domain\services\admin\privacy\policy\PrivacyPolicy' => array(
737
-                'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
738
-                'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache
739
-            ),
740
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendee' => array(
741
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
742
-            ),
743
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendeeBillingData' => array(
744
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
745
-                'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache
746
-            ),
747
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportCheckins' => array(
748
-                'EEM_Checkin' => EE_Dependency_Map::load_from_cache,
749
-            ),
750
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportRegistration' => array(
751
-                'EEM_Registration' => EE_Dependency_Map::load_from_cache,
752
-            ),
753
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportTransaction' => array(
754
-                'EEM_Transaction' => EE_Dependency_Map::load_from_cache,
755
-            ),
756
-            'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAttendeeData' => array(
757
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
758
-            ),
759
-            'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAnswers' => array(
760
-                'EEM_Answer' => EE_Dependency_Map::load_from_cache,
761
-                'EEM_Question' => EE_Dependency_Map::load_from_cache,
762
-            ),
763
-            'EventEspresso\core\CPTs\CptQueryModifier' => array(
764
-                null,
765
-                null,
766
-                null,
767
-                'EE_Request_Handler'                          => EE_Dependency_Map::load_from_cache,
768
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
769
-                'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
770
-            ),
771
-            'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler' => array(
772
-                'EE_Registry' => EE_Dependency_Map::load_from_cache,
773
-                'EE_Config' => EE_Dependency_Map::load_from_cache
774
-            ),
775
-        );
776
-    }
777
-
778
-
779
-    /**
780
-     * Registers how core classes are loaded.
781
-     * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
782
-     *        'EE_Request_Handler' => 'load_core'
783
-     *        'EE_Messages_Queue'  => 'load_lib'
784
-     *        'EEH_Debug_Tools'    => 'load_helper'
785
-     * or, if greater control is required, by providing a custom closure. For example:
786
-     *        'Some_Class' => function () {
787
-     *            return new Some_Class();
788
-     *        },
789
-     * This is required for instantiating dependencies
790
-     * where an interface has been type hinted in a class constructor. For example:
791
-     *        'Required_Interface' => function () {
792
-     *            return new A_Class_That_Implements_Required_Interface();
793
-     *        },
794
-     */
795
-    protected function _register_core_class_loaders()
796
-    {
797
-        // for PHP5.3 compat, we need to register any properties called here in a variable because `$this` cannot
798
-        // be used in a closure.
799
-        $request = &$this->request;
800
-        $response = &$this->response;
801
-        $legacy_request = &$this->legacy_request;
802
-        // $loader = &$this->loader;
803
-        $this->_class_loaders = array(
804
-            // load_core
805
-            'EE_Capabilities'                              => 'load_core',
806
-            'EE_Encryption'                                => 'load_core',
807
-            'EE_Front_Controller'                          => 'load_core',
808
-            'EE_Module_Request_Router'                     => 'load_core',
809
-            'EE_Registry'                                  => 'load_core',
810
-            'EE_Request'                                   => function () use (&$legacy_request) {
811
-                return $legacy_request;
812
-            },
813
-            'EventEspresso\core\services\request\Request'  => function () use (&$request) {
814
-                return $request;
815
-            },
816
-            'EventEspresso\core\services\request\Response' => function () use (&$response) {
817
-                return $response;
818
-            },
819
-            'EE_Base'                                      => 'load_core',
820
-            'EE_Request_Handler'                           => 'load_core',
821
-            'EE_Session'                                   => 'load_core',
822
-            'EE_Cron_Tasks'                                => 'load_core',
823
-            'EE_System'                                    => 'load_core',
824
-            'EE_Maintenance_Mode'                          => 'load_core',
825
-            'EE_Register_CPTs'                             => 'load_core',
826
-            'EE_Admin'                                     => 'load_core',
827
-            'EE_CPT_Strategy'                              => 'load_core',
828
-            // load_lib
829
-            'EE_Message_Resource_Manager'                  => 'load_lib',
830
-            'EE_Message_Type_Collection'                   => 'load_lib',
831
-            'EE_Message_Type_Collection_Loader'            => 'load_lib',
832
-            'EE_Messenger_Collection'                      => 'load_lib',
833
-            'EE_Messenger_Collection_Loader'               => 'load_lib',
834
-            'EE_Messages_Processor'                        => 'load_lib',
835
-            'EE_Message_Repository'                        => 'load_lib',
836
-            'EE_Messages_Queue'                            => 'load_lib',
837
-            'EE_Messages_Data_Handler_Collection'          => 'load_lib',
838
-            'EE_Message_Template_Group_Collection'         => 'load_lib',
839
-            'EE_Payment_Method_Manager'                    => 'load_lib',
840
-            'EE_Messages_Generator'                        => function () {
841
-                return EE_Registry::instance()->load_lib(
842
-                    'Messages_Generator',
843
-                    array(),
844
-                    false,
845
-                    false
846
-                );
847
-            },
848
-            'EE_Messages_Template_Defaults'                => function ($arguments = array()) {
849
-                return EE_Registry::instance()->load_lib(
850
-                    'Messages_Template_Defaults',
851
-                    $arguments,
852
-                    false,
853
-                    false
854
-                );
855
-            },
856
-            // load_helper
857
-            'EEH_Parse_Shortcodes'                         => function () {
858
-                if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
859
-                    return new EEH_Parse_Shortcodes();
860
-                }
861
-                return null;
862
-            },
863
-            'EE_Template_Config'                           => function () {
864
-                return EE_Config::instance()->template_settings;
865
-            },
866
-            'EE_Currency_Config'                           => function () {
867
-                return EE_Config::instance()->currency;
868
-            },
869
-            'EE_Registration_Config'                       => function () {
870
-                return EE_Config::instance()->registration;
871
-            },
872
-            'EE_Core_Config'                               => function () {
873
-                return EE_Config::instance()->core;
874
-            },
875
-            'EventEspresso\core\services\loaders\Loader'   => function () {
876
-                return LoaderFactory::getLoader();
877
-            },
878
-            'EE_Network_Config'                            => function () {
879
-                return EE_Network_Config::instance();
880
-            },
881
-            'EE_Config'                                    => function () {
882
-                return EE_Config::instance();
883
-            },
884
-            'EventEspresso\core\domain\Domain'             => function () {
885
-                return DomainFactory::getEventEspressoCoreDomain();
886
-            },
887
-            'EE_Admin_Config'                              => function () {
888
-                return EE_Config::instance()->admin;
889
-            },
890
-        );
891
-    }
892
-
893
-
894
-    /**
895
-     * can be used for supplying alternate names for classes,
896
-     * or for connecting interface names to instantiable classes
897
-     */
898
-    protected function _register_core_aliases()
899
-    {
900
-        $aliases = array(
901
-            'CommandBusInterface'                                                          => 'EventEspresso\core\services\commands\CommandBusInterface',
902
-            'EventEspresso\core\services\commands\CommandBusInterface'                     => 'EventEspresso\core\services\commands\CommandBus',
903
-            'CommandHandlerManagerInterface'                                               => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
904
-            'EventEspresso\core\services\commands\CommandHandlerManagerInterface'          => 'EventEspresso\core\services\commands\CommandHandlerManager',
905
-            'CapChecker'                                                                   => 'EventEspresso\core\services\commands\middleware\CapChecker',
906
-            'AddActionHook'                                                                => 'EventEspresso\core\services\commands\middleware\AddActionHook',
907
-            'CapabilitiesChecker'                                                          => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
908
-            'CapabilitiesCheckerInterface'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface',
909
-            'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
910
-            'CreateRegistrationService'                                                    => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
911
-            'CreateRegistrationCommandHandler'                                             => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
912
-            'CopyRegistrationDetailsCommandHandler'                                        => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
913
-            'CopyRegistrationPaymentsCommandHandler'                                       => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
914
-            'CancelRegistrationAndTicketLineItemCommandHandler'                            => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
915
-            'UpdateRegistrationAndTransactionAfterChangeCommandHandler'                    => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
916
-            'CreateTicketLineItemCommandHandler'                                           => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
917
-            'CreateTransactionCommandHandler'                                              => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler',
918
-            'CreateAttendeeCommandHandler'                                                 => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler',
919
-            'TableManager'                                                                 => 'EventEspresso\core\services\database\TableManager',
920
-            'TableAnalysis'                                                                => 'EventEspresso\core\services\database\TableAnalysis',
921
-            'EspressoShortcode'                                                            => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
922
-            'ShortcodeInterface'                                                           => 'EventEspresso\core\services\shortcodes\ShortcodeInterface',
923
-            'EventEspresso\core\services\shortcodes\ShortcodeInterface'                    => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
924
-            'EventEspresso\core\services\cache\CacheStorageInterface'                      => 'EventEspresso\core\services\cache\TransientCacheStorage',
925
-            'LoaderInterface'                                                              => 'EventEspresso\core\services\loaders\LoaderInterface',
926
-            'EventEspresso\core\services\loaders\LoaderInterface'                          => 'EventEspresso\core\services\loaders\Loader',
927
-            'CommandFactoryInterface'                                                      => 'EventEspresso\core\services\commands\CommandFactoryInterface',
928
-            'EventEspresso\core\services\commands\CommandFactoryInterface'                 => 'EventEspresso\core\services\commands\CommandFactory',
929
-            'EventEspresso\core\domain\services\session\SessionIdentifierInterface'        => 'EE_Session',
930
-            'EmailValidatorInterface'                                                      => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface',
931
-            'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface'  => 'EventEspresso\core\domain\services\validation\email\EmailValidationService',
932
-            'NoticeConverterInterface'                                                     => 'EventEspresso\core\services\notices\NoticeConverterInterface',
933
-            'EventEspresso\core\services\notices\NoticeConverterInterface'                 => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors',
934
-            'NoticesContainerInterface'                                                    => 'EventEspresso\core\services\notices\NoticesContainerInterface',
935
-            'EventEspresso\core\services\notices\NoticesContainerInterface'                => 'EventEspresso\core\services\notices\NoticesContainer',
936
-            'EventEspresso\core\services\request\RequestInterface'                         => 'EventEspresso\core\services\request\Request',
937
-            'EventEspresso\core\services\request\ResponseInterface'                        => 'EventEspresso\core\services\request\Response',
938
-            'EventEspresso\core\domain\DomainInterface'                                    => 'EventEspresso\core\domain\Domain',
939
-        );
940
-        foreach ($aliases as $alias => $fqn) {
941
-            if (is_array($fqn)) {
942
-                foreach ($fqn as $class => $for_class) {
943
-                    $this->class_cache->addAlias($class, $alias, $for_class);
944
-                }
945
-                continue;
946
-            }
947
-            $this->class_cache->addAlias($fqn, $alias);
948
-        }
949
-        if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
950
-            $this->class_cache->addAlias(
951
-                'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices',
952
-                'EventEspresso\core\services\notices\NoticeConverterInterface'
953
-            );
954
-        }
955
-    }
956
-
957
-
958
-    /**
959
-     * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
960
-     * request Primarily used by unit tests.
961
-     */
962
-    public function reset()
963
-    {
964
-        $this->_register_core_class_loaders();
965
-        $this->_register_core_dependencies();
966
-    }
967
-
968
-
969
-    /**
970
-     * PLZ NOTE: a better name for this method would be is_alias()
971
-     * because it returns TRUE if the provided fully qualified name IS an alias
972
-     * WHY?
973
-     * Because if a class is type hinting for a concretion,
974
-     * then why would we need to find another class to supply it?
975
-     * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
976
-     * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
977
-     * Don't go looking for some substitute.
978
-     * Whereas if a class is type hinting for an interface...
979
-     * then we need to find an actual class to use.
980
-     * So the interface IS the alias for some other FQN,
981
-     * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
982
-     * represents some other class.
983
-     *
984
-     * @deprecated 4.9.62.p
985
-     * @param string $fqn
986
-     * @param string $for_class
987
-     * @return bool
988
-     */
989
-    public function has_alias($fqn = '', $for_class = '')
990
-    {
991
-        return $this->isAlias($fqn, $for_class);
992
-    }
993
-
994
-
995
-    /**
996
-     * PLZ NOTE: a better name for this method would be get_fqn_for_alias()
997
-     * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias
998
-     * functions recursively, so that multiple aliases can be used to drill down to a FQN
999
-     *  for example:
1000
-     *      if the following two entries were added to the _aliases array:
1001
-     *          array(
1002
-     *              'interface_alias'           => 'some\namespace\interface'
1003
-     *              'some\namespace\interface'  => 'some\namespace\classname'
1004
-     *          )
1005
-     *      then one could use EE_Registry::instance()->create( 'interface_alias' )
1006
-     *      to load an instance of 'some\namespace\classname'
1007
-     *
1008
-     * @deprecated 4.9.62.p
1009
-     * @param string $alias
1010
-     * @param string $for_class
1011
-     * @return string
1012
-     */
1013
-    public function get_alias($alias = '', $for_class = '')
1014
-    {
1015
-        return $this->getFqnForAlias($alias, $for_class);
1016
-    }
23
+	/**
24
+	 * This means that the requested class dependency is not present in the dependency map
25
+	 */
26
+	const not_registered = 0;
27
+
28
+	/**
29
+	 * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class.
30
+	 */
31
+	const load_new_object = 1;
32
+
33
+	/**
34
+	 * This instructs class loaders to return a previously instantiated and cached object for the requested class.
35
+	 * IF a previously instantiated object does not exist, a new one will be created and added to the cache.
36
+	 */
37
+	const load_from_cache = 2;
38
+
39
+	/**
40
+	 * When registering a dependency,
41
+	 * this indicates to keep any existing dependencies that already exist,
42
+	 * and simply discard any new dependencies declared in the incoming data
43
+	 */
44
+	const KEEP_EXISTING_DEPENDENCIES = 0;
45
+
46
+	/**
47
+	 * When registering a dependency,
48
+	 * this indicates to overwrite any existing dependencies that already exist using the incoming data
49
+	 */
50
+	const OVERWRITE_DEPENDENCIES = 1;
51
+
52
+
53
+	/**
54
+	 * @type EE_Dependency_Map $_instance
55
+	 */
56
+	protected static $_instance;
57
+
58
+	/**
59
+	 * @var ClassInterfaceCache $class_cache
60
+	 */
61
+	private $class_cache;
62
+
63
+	/**
64
+	 * @type RequestInterface $request
65
+	 */
66
+	protected $request;
67
+
68
+	/**
69
+	 * @type LegacyRequestInterface $legacy_request
70
+	 */
71
+	protected $legacy_request;
72
+
73
+	/**
74
+	 * @type ResponseInterface $response
75
+	 */
76
+	protected $response;
77
+
78
+	/**
79
+	 * @type LoaderInterface $loader
80
+	 */
81
+	protected $loader;
82
+
83
+	/**
84
+	 * @type array $_dependency_map
85
+	 */
86
+	protected $_dependency_map = array();
87
+
88
+	/**
89
+	 * @type array $_class_loaders
90
+	 */
91
+	protected $_class_loaders = array();
92
+
93
+
94
+	/**
95
+	 * EE_Dependency_Map constructor.
96
+	 *
97
+	 * @param ClassInterfaceCache $class_cache
98
+	 */
99
+	protected function __construct(ClassInterfaceCache $class_cache)
100
+	{
101
+		$this->class_cache = $class_cache;
102
+		do_action('EE_Dependency_Map____construct', $this);
103
+	}
104
+
105
+
106
+	/**
107
+	 * @return void
108
+	 */
109
+	public function initialize()
110
+	{
111
+		$this->_register_core_dependencies();
112
+		$this->_register_core_class_loaders();
113
+		$this->_register_core_aliases();
114
+	}
115
+
116
+
117
+	/**
118
+	 * @singleton method used to instantiate class object
119
+	 * @param ClassInterfaceCache|null $class_cache
120
+	 * @return EE_Dependency_Map
121
+	 */
122
+	public static function instance(ClassInterfaceCache $class_cache = null)
123
+	{
124
+		// check if class object is instantiated, and instantiated properly
125
+		if (! self::$_instance instanceof EE_Dependency_Map
126
+			&& $class_cache instanceof ClassInterfaceCache
127
+		) {
128
+			self::$_instance = new EE_Dependency_Map($class_cache);
129
+		}
130
+		return self::$_instance;
131
+	}
132
+
133
+
134
+	/**
135
+	 * @param RequestInterface $request
136
+	 */
137
+	public function setRequest(RequestInterface $request)
138
+	{
139
+		$this->request = $request;
140
+	}
141
+
142
+
143
+	/**
144
+	 * @param LegacyRequestInterface $legacy_request
145
+	 */
146
+	public function setLegacyRequest(LegacyRequestInterface $legacy_request)
147
+	{
148
+		$this->legacy_request = $legacy_request;
149
+	}
150
+
151
+
152
+	/**
153
+	 * @param ResponseInterface $response
154
+	 */
155
+	public function setResponse(ResponseInterface $response)
156
+	{
157
+		$this->response = $response;
158
+	}
159
+
160
+
161
+	/**
162
+	 * @param LoaderInterface $loader
163
+	 */
164
+	public function setLoader(LoaderInterface $loader)
165
+	{
166
+		$this->loader = $loader;
167
+	}
168
+
169
+
170
+	/**
171
+	 * @param string $class
172
+	 * @param array  $dependencies
173
+	 * @param int    $overwrite
174
+	 * @return bool
175
+	 */
176
+	public static function register_dependencies(
177
+		$class,
178
+		array $dependencies,
179
+		$overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
180
+	) {
181
+		return self::$_instance->registerDependencies($class, $dependencies, $overwrite);
182
+	}
183
+
184
+
185
+	/**
186
+	 * Assigns an array of class names and corresponding load sources (new or cached)
187
+	 * to the class specified by the first parameter.
188
+	 * IMPORTANT !!!
189
+	 * The order of elements in the incoming $dependencies array MUST match
190
+	 * the order of the constructor parameters for the class in question.
191
+	 * This is especially important when overriding any existing dependencies that are registered.
192
+	 * the third parameter controls whether any duplicate dependencies are overwritten or not.
193
+	 *
194
+	 * @param string $class
195
+	 * @param array  $dependencies
196
+	 * @param int    $overwrite
197
+	 * @return bool
198
+	 */
199
+	public function registerDependencies(
200
+		$class,
201
+		array $dependencies,
202
+		$overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
203
+	) {
204
+		$class = trim($class, '\\');
205
+		$registered = false;
206
+		if (empty(self::$_instance->_dependency_map[ $class ])) {
207
+			self::$_instance->_dependency_map[ $class ] = array();
208
+		}
209
+		// we need to make sure that any aliases used when registering a dependency
210
+		// get resolved to the correct class name
211
+		foreach ($dependencies as $dependency => $load_source) {
212
+			$alias = self::$_instance->getFqnForAlias($dependency);
213
+			if ($overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
214
+				|| ! isset(self::$_instance->_dependency_map[ $class ][ $alias ])
215
+			) {
216
+				unset($dependencies[ $dependency ]);
217
+				$dependencies[ $alias ] = $load_source;
218
+				$registered = true;
219
+			}
220
+		}
221
+		// now add our two lists of dependencies together.
222
+		// using Union (+=) favours the arrays in precedence from left to right,
223
+		// so $dependencies is NOT overwritten because it is listed first
224
+		// ie: with A = B + C, entries in B take precedence over duplicate entries in C
225
+		// Union is way faster than array_merge() but should be used with caution...
226
+		// especially with numerically indexed arrays
227
+		$dependencies += self::$_instance->_dependency_map[ $class ];
228
+		// now we need to ensure that the resulting dependencies
229
+		// array only has the entries that are required for the class
230
+		// so first count how many dependencies were originally registered for the class
231
+		$dependency_count = count(self::$_instance->_dependency_map[ $class ]);
232
+		// if that count is non-zero (meaning dependencies were already registered)
233
+		self::$_instance->_dependency_map[ $class ] = $dependency_count
234
+			// then truncate the  final array to match that count
235
+			? array_slice($dependencies, 0, $dependency_count)
236
+			// otherwise just take the incoming array because nothing previously existed
237
+			: $dependencies;
238
+		return $registered;
239
+	}
240
+
241
+
242
+	/**
243
+	 * @param string $class_name
244
+	 * @param string $loader
245
+	 * @return bool
246
+	 * @throws DomainException
247
+	 */
248
+	public static function register_class_loader($class_name, $loader = 'load_core')
249
+	{
250
+		if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
251
+			throw new DomainException(
252
+				esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
253
+			);
254
+		}
255
+		// check that loader is callable or method starts with "load_" and exists in EE_Registry
256
+		if (! is_callable($loader)
257
+			&& (
258
+				strpos($loader, 'load_') !== 0
259
+				|| ! method_exists('EE_Registry', $loader)
260
+			)
261
+		) {
262
+			throw new DomainException(
263
+				sprintf(
264
+					esc_html__(
265
+						'"%1$s" is not a valid loader method on EE_Registry.',
266
+						'event_espresso'
267
+					),
268
+					$loader
269
+				)
270
+			);
271
+		}
272
+		$class_name = self::$_instance->getFqnForAlias($class_name);
273
+		if (! isset(self::$_instance->_class_loaders[ $class_name ])) {
274
+			self::$_instance->_class_loaders[ $class_name ] = $loader;
275
+			return true;
276
+		}
277
+		return false;
278
+	}
279
+
280
+
281
+	/**
282
+	 * @return array
283
+	 */
284
+	public function dependency_map()
285
+	{
286
+		return $this->_dependency_map;
287
+	}
288
+
289
+
290
+	/**
291
+	 * returns TRUE if dependency map contains a listing for the provided class name
292
+	 *
293
+	 * @param string $class_name
294
+	 * @return boolean
295
+	 */
296
+	public function has($class_name = '')
297
+	{
298
+		// all legacy models have the same dependencies
299
+		if (strpos($class_name, 'EEM_') === 0) {
300
+			$class_name = 'LEGACY_MODELS';
301
+		}
302
+		return isset($this->_dependency_map[ $class_name ]) ? true : false;
303
+	}
304
+
305
+
306
+	/**
307
+	 * returns TRUE if dependency map contains a listing for the provided class name AND dependency
308
+	 *
309
+	 * @param string $class_name
310
+	 * @param string $dependency
311
+	 * @return bool
312
+	 */
313
+	public function has_dependency_for_class($class_name = '', $dependency = '')
314
+	{
315
+		// all legacy models have the same dependencies
316
+		if (strpos($class_name, 'EEM_') === 0) {
317
+			$class_name = 'LEGACY_MODELS';
318
+		}
319
+		$dependency = $this->getFqnForAlias($dependency, $class_name);
320
+		return isset($this->_dependency_map[ $class_name ][ $dependency ])
321
+			? true
322
+			: false;
323
+	}
324
+
325
+
326
+	/**
327
+	 * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned
328
+	 *
329
+	 * @param string $class_name
330
+	 * @param string $dependency
331
+	 * @return int
332
+	 */
333
+	public function loading_strategy_for_class_dependency($class_name = '', $dependency = '')
334
+	{
335
+		// all legacy models have the same dependencies
336
+		if (strpos($class_name, 'EEM_') === 0) {
337
+			$class_name = 'LEGACY_MODELS';
338
+		}
339
+		$dependency = $this->getFqnForAlias($dependency);
340
+		return $this->has_dependency_for_class($class_name, $dependency)
341
+			? $this->_dependency_map[ $class_name ][ $dependency ]
342
+			: EE_Dependency_Map::not_registered;
343
+	}
344
+
345
+
346
+	/**
347
+	 * @param string $class_name
348
+	 * @return string | Closure
349
+	 */
350
+	public function class_loader($class_name)
351
+	{
352
+		// all legacy models use load_model()
353
+		if (strpos($class_name, 'EEM_') === 0) {
354
+			return 'load_model';
355
+		}
356
+		// EE_CPT_*_Strategy classes like EE_CPT_Event_Strategy, EE_CPT_Venue_Strategy, etc
357
+		// perform strpos() first to avoid loading regex every time we load a class
358
+		if (strpos($class_name, 'EE_CPT_') === 0
359
+			&& preg_match('/^EE_CPT_([a-zA-Z]+)_Strategy$/', $class_name)
360
+		) {
361
+			return 'load_core';
362
+		}
363
+		$class_name = $this->getFqnForAlias($class_name);
364
+		return isset($this->_class_loaders[ $class_name ]) ? $this->_class_loaders[ $class_name ] : '';
365
+	}
366
+
367
+
368
+	/**
369
+	 * @return array
370
+	 */
371
+	public function class_loaders()
372
+	{
373
+		return $this->_class_loaders;
374
+	}
375
+
376
+
377
+	/**
378
+	 * adds an alias for a classname
379
+	 *
380
+	 * @param string $fqcn      the class name that should be used (concrete class to replace interface)
381
+	 * @param string $alias     the class name that would be type hinted for (abstract parent or interface)
382
+	 * @param string $for_class the class that has the dependency (is type hinting for the interface)
383
+	 */
384
+	public function add_alias($fqcn, $alias, $for_class = '')
385
+	{
386
+		$this->class_cache->addAlias($fqcn, $alias, $for_class);
387
+	}
388
+
389
+
390
+	/**
391
+	 * Returns TRUE if the provided fully qualified name IS an alias
392
+	 * WHY?
393
+	 * Because if a class is type hinting for a concretion,
394
+	 * then why would we need to find another class to supply it?
395
+	 * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
396
+	 * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
397
+	 * Don't go looking for some substitute.
398
+	 * Whereas if a class is type hinting for an interface...
399
+	 * then we need to find an actual class to use.
400
+	 * So the interface IS the alias for some other FQN,
401
+	 * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
402
+	 * represents some other class.
403
+	 *
404
+	 * @param string $fqn
405
+	 * @param string $for_class
406
+	 * @return bool
407
+	 */
408
+	public function isAlias($fqn = '', $for_class = '')
409
+	{
410
+		return $this->class_cache->isAlias($fqn, $for_class);
411
+	}
412
+
413
+
414
+	/**
415
+	 * Returns a FQN for provided alias if one exists, otherwise returns the original $alias
416
+	 * functions recursively, so that multiple aliases can be used to drill down to a FQN
417
+	 *  for example:
418
+	 *      if the following two entries were added to the _aliases array:
419
+	 *          array(
420
+	 *              'interface_alias'           => 'some\namespace\interface'
421
+	 *              'some\namespace\interface'  => 'some\namespace\classname'
422
+	 *          )
423
+	 *      then one could use EE_Registry::instance()->create( 'interface_alias' )
424
+	 *      to load an instance of 'some\namespace\classname'
425
+	 *
426
+	 * @param string $alias
427
+	 * @param string $for_class
428
+	 * @return string
429
+	 */
430
+	public function getFqnForAlias($alias = '', $for_class = '')
431
+	{
432
+		return (string) $this->class_cache->getFqnForAlias($alias, $for_class);
433
+	}
434
+
435
+
436
+	/**
437
+	 * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache,
438
+	 * if one exists, or whether a new object should be generated every time the requested class is loaded.
439
+	 * This is done by using the following class constants:
440
+	 *        EE_Dependency_Map::load_from_cache - loads previously instantiated object
441
+	 *        EE_Dependency_Map::load_new_object - generates a new object every time
442
+	 */
443
+	protected function _register_core_dependencies()
444
+	{
445
+		$this->_dependency_map = array(
446
+			'EE_Request_Handler'                                                                                          => array(
447
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
448
+			),
449
+			'EE_System'                                                                                                   => array(
450
+				'EE_Registry'                                 => EE_Dependency_Map::load_from_cache,
451
+				'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
452
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
453
+				'EE_Maintenance_Mode'                         => EE_Dependency_Map::load_from_cache,
454
+			),
455
+			'EE_Session'                                                                                                  => array(
456
+				'EventEspresso\core\services\cache\TransientCacheStorage'  => EE_Dependency_Map::load_from_cache,
457
+				'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
458
+				'EventEspresso\core\services\request\Request'              => EE_Dependency_Map::load_from_cache,
459
+				'EE_Encryption'                                            => EE_Dependency_Map::load_from_cache,
460
+			),
461
+			'EE_Cart'                                                                                                     => array(
462
+				'EE_Session' => EE_Dependency_Map::load_from_cache,
463
+			),
464
+			'EE_Front_Controller'                                                                                         => array(
465
+				'EE_Registry'              => EE_Dependency_Map::load_from_cache,
466
+				'EE_Request_Handler'       => EE_Dependency_Map::load_from_cache,
467
+				'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache,
468
+			),
469
+			'EE_Messenger_Collection_Loader'                                                                              => array(
470
+				'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object,
471
+			),
472
+			'EE_Message_Type_Collection_Loader'                                                                           => array(
473
+				'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object,
474
+			),
475
+			'EE_Message_Resource_Manager'                                                                                 => array(
476
+				'EE_Messenger_Collection_Loader'    => EE_Dependency_Map::load_new_object,
477
+				'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object,
478
+				'EEM_Message_Template_Group'        => EE_Dependency_Map::load_from_cache,
479
+			),
480
+			'EE_Message_Factory'                                                                                          => array(
481
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
482
+			),
483
+			'EE_messages'                                                                                                 => array(
484
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
485
+			),
486
+			'EE_Messages_Generator'                                                                                       => array(
487
+				'EE_Messages_Queue'                    => EE_Dependency_Map::load_new_object,
488
+				'EE_Messages_Data_Handler_Collection'  => EE_Dependency_Map::load_new_object,
489
+				'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object,
490
+				'EEH_Parse_Shortcodes'                 => EE_Dependency_Map::load_from_cache,
491
+			),
492
+			'EE_Messages_Processor'                                                                                       => array(
493
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
494
+			),
495
+			'EE_Messages_Queue'                                                                                           => array(
496
+				'EE_Message_Repository' => EE_Dependency_Map::load_new_object,
497
+			),
498
+			'EE_Messages_Template_Defaults'                                                                               => array(
499
+				'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache,
500
+				'EEM_Message_Template'       => EE_Dependency_Map::load_from_cache,
501
+			),
502
+			'EE_Message_To_Generate_From_Request'                                                                         => array(
503
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
504
+				'EE_Request_Handler'          => EE_Dependency_Map::load_from_cache,
505
+			),
506
+			'EventEspresso\core\services\commands\CommandBus'                                                             => array(
507
+				'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache,
508
+			),
509
+			'EventEspresso\services\commands\CommandHandler'                                                              => array(
510
+				'EE_Registry'         => EE_Dependency_Map::load_from_cache,
511
+				'CommandBusInterface' => EE_Dependency_Map::load_from_cache,
512
+			),
513
+			'EventEspresso\core\services\commands\CommandHandlerManager'                                                  => array(
514
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
515
+			),
516
+			'EventEspresso\core\services\commands\CompositeCommandHandler'                                                => array(
517
+				'EventEspresso\core\services\commands\CommandBus'     => EE_Dependency_Map::load_from_cache,
518
+				'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache,
519
+			),
520
+			'EventEspresso\core\services\commands\CommandFactory'                                                         => array(
521
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
522
+			),
523
+			'EventEspresso\core\services\commands\middleware\CapChecker'                                                  => array(
524
+				'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
525
+			),
526
+			'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker'                                         => array(
527
+				'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
528
+			),
529
+			'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker'                                     => array(
530
+				'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
531
+			),
532
+			'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler'                          => array(
533
+				'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache,
534
+			),
535
+			'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler'                     => array(
536
+				'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
537
+			),
538
+			'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler'                    => array(
539
+				'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
540
+			),
541
+			'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler'         => array(
542
+				'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
543
+			),
544
+			'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array(
545
+				'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache,
546
+			),
547
+			'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler'                              => array(
548
+				'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache,
549
+			),
550
+			'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler'                              => array(
551
+				'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
552
+			),
553
+			'EventEspresso\core\domain\services\registration\CancelRegistrationService'                                   => array(
554
+				'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
555
+			),
556
+			'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler'                                  => array(
557
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
558
+			),
559
+			'EventEspresso\core\services\database\TableManager'                                                           => array(
560
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
561
+			),
562
+			'EE_Data_Migration_Class_Base'                                                                                => array(
563
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
564
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
565
+			),
566
+			'EE_DMS_Core_4_1_0'                                                                                           => array(
567
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
568
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
569
+			),
570
+			'EE_DMS_Core_4_2_0'                                                                                           => array(
571
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
572
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
573
+			),
574
+			'EE_DMS_Core_4_3_0'                                                                                           => array(
575
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
576
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
577
+			),
578
+			'EE_DMS_Core_4_4_0'                                                                                           => array(
579
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
580
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
581
+			),
582
+			'EE_DMS_Core_4_5_0'                                                                                           => array(
583
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
584
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
585
+			),
586
+			'EE_DMS_Core_4_6_0'                                                                                           => array(
587
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
588
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
589
+			),
590
+			'EE_DMS_Core_4_7_0'                                                                                           => array(
591
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
592
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
593
+			),
594
+			'EE_DMS_Core_4_8_0'                                                                                           => array(
595
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
596
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
597
+			),
598
+			'EE_DMS_Core_4_9_0'                                                                                           => array(
599
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
600
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
601
+			),
602
+			'EventEspresso\core\services\assets\I18nRegistry'                                                             => array(
603
+				array(),
604
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
605
+			),
606
+			'EventEspresso\core\services\assets\Registry'                                                                 => array(
607
+				'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
608
+				'EventEspresso\core\services\assets\I18nRegistry'    => EE_Dependency_Map::load_from_cache,
609
+			),
610
+			'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled'                                             => array(
611
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
612
+			),
613
+			'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout'                                              => array(
614
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
615
+			),
616
+			'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees'                                        => array(
617
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
618
+			),
619
+			'EventEspresso\core\domain\entities\shortcodes\EspressoEvents'                                                => array(
620
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
621
+			),
622
+			'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou'                                              => array(
623
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
624
+			),
625
+			'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector'                                        => array(
626
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
627
+			),
628
+			'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage'                                               => array(
629
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
630
+			),
631
+			'EventEspresso\core\services\cache\BasicCacheManager'                                                         => array(
632
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
633
+			),
634
+			'EventEspresso\core\services\cache\PostRelatedCacheManager'                                                   => array(
635
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
636
+			),
637
+			'EventEspresso\core\domain\services\validation\email\EmailValidationService'                                  => array(
638
+				'EE_Registration_Config'                     => EE_Dependency_Map::load_from_cache,
639
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
640
+			),
641
+			'EventEspresso\core\domain\values\EmailAddress'                                                               => array(
642
+				null,
643
+				'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache,
644
+			),
645
+			'EventEspresso\core\services\orm\ModelFieldFactory'                                                           => array(
646
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
647
+			),
648
+			'LEGACY_MODELS'                                                                                               => array(
649
+				null,
650
+				'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache,
651
+			),
652
+			'EE_Module_Request_Router'                                                                                    => array(
653
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
654
+			),
655
+			'EE_Registration_Processor'                                                                                   => array(
656
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
657
+			),
658
+			'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'                                      => array(
659
+				null,
660
+				'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
661
+				'EventEspresso\core\services\request\Request'                         => EE_Dependency_Map::load_from_cache,
662
+			),
663
+			'EventEspresso\core\services\licensing\LicenseService'                                                        => array(
664
+				'EventEspresso\core\domain\services\pue\Stats'  => EE_Dependency_Map::load_from_cache,
665
+				'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache,
666
+			),
667
+			'EE_Admin_Transactions_List_Table'                                                                            => array(
668
+				null,
669
+				'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
670
+			),
671
+			'EventEspresso\core\domain\services\pue\Stats'                                                                => array(
672
+				'EventEspresso\core\domain\services\pue\Config'        => EE_Dependency_Map::load_from_cache,
673
+				'EE_Maintenance_Mode'                                  => EE_Dependency_Map::load_from_cache,
674
+				'EventEspresso\core\domain\services\pue\StatsGatherer' => EE_Dependency_Map::load_from_cache,
675
+			),
676
+			'EventEspresso\core\domain\services\pue\Config'                                                               => array(
677
+				'EE_Network_Config' => EE_Dependency_Map::load_from_cache,
678
+				'EE_Config'         => EE_Dependency_Map::load_from_cache,
679
+			),
680
+			'EventEspresso\core\domain\services\pue\StatsGatherer'                                                        => array(
681
+				'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
682
+				'EEM_Event'          => EE_Dependency_Map::load_from_cache,
683
+				'EEM_Datetime'       => EE_Dependency_Map::load_from_cache,
684
+				'EEM_Ticket'         => EE_Dependency_Map::load_from_cache,
685
+				'EEM_Registration'   => EE_Dependency_Map::load_from_cache,
686
+				'EEM_Transaction'    => EE_Dependency_Map::load_from_cache,
687
+				'EE_Config'          => EE_Dependency_Map::load_from_cache,
688
+			),
689
+			'EventEspresso\core\domain\services\admin\ExitModal'                                                          => array(
690
+				'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache,
691
+			),
692
+			'EventEspresso\core\domain\services\admin\PluginUpsells'                                                      => array(
693
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
694
+			),
695
+			'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha'                                    => array(
696
+				'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
697
+				'EE_Session'             => EE_Dependency_Map::load_from_cache,
698
+			),
699
+			'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings'                                => array(
700
+				'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
701
+			),
702
+			'EventEspresso\modules\ticket_selector\ProcessTicketSelector'                                                 => array(
703
+				'EE_Core_Config'                                                          => EE_Dependency_Map::load_from_cache,
704
+				'EventEspresso\core\services\request\Request'                             => EE_Dependency_Map::load_from_cache,
705
+				'EE_Session'                                                              => EE_Dependency_Map::load_from_cache,
706
+				'EEM_Ticket'                                                              => EE_Dependency_Map::load_from_cache,
707
+				'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache,
708
+			),
709
+			'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker'                                     => array(
710
+				'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
711
+			),
712
+			'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'                              => array(
713
+				'EE_Core_Config'                             => EE_Dependency_Map::load_from_cache,
714
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
715
+			),
716
+			'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes'                                => array(
717
+				'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
718
+			),
719
+			'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies'                               => array(
720
+				'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
721
+			),
722
+			'EE_CPT_Strategy'                                                                                             => array(
723
+				'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
724
+				'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
725
+			),
726
+			'EventEspresso\core\services\loaders\ObjectIdentifier'                                                        => array(
727
+				'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
728
+			),
729
+			'EventEspresso\core\domain\services\assets\CoreAssetManager'                                                  => array(
730
+				'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
731
+				'EE_Currency_Config'                                 => EE_Dependency_Map::load_from_cache,
732
+				'EE_Template_Config'                                 => EE_Dependency_Map::load_from_cache,
733
+				'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
734
+				'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
735
+			),
736
+			'EventEspresso\core\domain\services\admin\privacy\policy\PrivacyPolicy' => array(
737
+				'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
738
+				'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache
739
+			),
740
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendee' => array(
741
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
742
+			),
743
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendeeBillingData' => array(
744
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
745
+				'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache
746
+			),
747
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportCheckins' => array(
748
+				'EEM_Checkin' => EE_Dependency_Map::load_from_cache,
749
+			),
750
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportRegistration' => array(
751
+				'EEM_Registration' => EE_Dependency_Map::load_from_cache,
752
+			),
753
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportTransaction' => array(
754
+				'EEM_Transaction' => EE_Dependency_Map::load_from_cache,
755
+			),
756
+			'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAttendeeData' => array(
757
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
758
+			),
759
+			'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAnswers' => array(
760
+				'EEM_Answer' => EE_Dependency_Map::load_from_cache,
761
+				'EEM_Question' => EE_Dependency_Map::load_from_cache,
762
+			),
763
+			'EventEspresso\core\CPTs\CptQueryModifier' => array(
764
+				null,
765
+				null,
766
+				null,
767
+				'EE_Request_Handler'                          => EE_Dependency_Map::load_from_cache,
768
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
769
+				'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
770
+			),
771
+			'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler' => array(
772
+				'EE_Registry' => EE_Dependency_Map::load_from_cache,
773
+				'EE_Config' => EE_Dependency_Map::load_from_cache
774
+			),
775
+		);
776
+	}
777
+
778
+
779
+	/**
780
+	 * Registers how core classes are loaded.
781
+	 * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
782
+	 *        'EE_Request_Handler' => 'load_core'
783
+	 *        'EE_Messages_Queue'  => 'load_lib'
784
+	 *        'EEH_Debug_Tools'    => 'load_helper'
785
+	 * or, if greater control is required, by providing a custom closure. For example:
786
+	 *        'Some_Class' => function () {
787
+	 *            return new Some_Class();
788
+	 *        },
789
+	 * This is required for instantiating dependencies
790
+	 * where an interface has been type hinted in a class constructor. For example:
791
+	 *        'Required_Interface' => function () {
792
+	 *            return new A_Class_That_Implements_Required_Interface();
793
+	 *        },
794
+	 */
795
+	protected function _register_core_class_loaders()
796
+	{
797
+		// for PHP5.3 compat, we need to register any properties called here in a variable because `$this` cannot
798
+		// be used in a closure.
799
+		$request = &$this->request;
800
+		$response = &$this->response;
801
+		$legacy_request = &$this->legacy_request;
802
+		// $loader = &$this->loader;
803
+		$this->_class_loaders = array(
804
+			// load_core
805
+			'EE_Capabilities'                              => 'load_core',
806
+			'EE_Encryption'                                => 'load_core',
807
+			'EE_Front_Controller'                          => 'load_core',
808
+			'EE_Module_Request_Router'                     => 'load_core',
809
+			'EE_Registry'                                  => 'load_core',
810
+			'EE_Request'                                   => function () use (&$legacy_request) {
811
+				return $legacy_request;
812
+			},
813
+			'EventEspresso\core\services\request\Request'  => function () use (&$request) {
814
+				return $request;
815
+			},
816
+			'EventEspresso\core\services\request\Response' => function () use (&$response) {
817
+				return $response;
818
+			},
819
+			'EE_Base'                                      => 'load_core',
820
+			'EE_Request_Handler'                           => 'load_core',
821
+			'EE_Session'                                   => 'load_core',
822
+			'EE_Cron_Tasks'                                => 'load_core',
823
+			'EE_System'                                    => 'load_core',
824
+			'EE_Maintenance_Mode'                          => 'load_core',
825
+			'EE_Register_CPTs'                             => 'load_core',
826
+			'EE_Admin'                                     => 'load_core',
827
+			'EE_CPT_Strategy'                              => 'load_core',
828
+			// load_lib
829
+			'EE_Message_Resource_Manager'                  => 'load_lib',
830
+			'EE_Message_Type_Collection'                   => 'load_lib',
831
+			'EE_Message_Type_Collection_Loader'            => 'load_lib',
832
+			'EE_Messenger_Collection'                      => 'load_lib',
833
+			'EE_Messenger_Collection_Loader'               => 'load_lib',
834
+			'EE_Messages_Processor'                        => 'load_lib',
835
+			'EE_Message_Repository'                        => 'load_lib',
836
+			'EE_Messages_Queue'                            => 'load_lib',
837
+			'EE_Messages_Data_Handler_Collection'          => 'load_lib',
838
+			'EE_Message_Template_Group_Collection'         => 'load_lib',
839
+			'EE_Payment_Method_Manager'                    => 'load_lib',
840
+			'EE_Messages_Generator'                        => function () {
841
+				return EE_Registry::instance()->load_lib(
842
+					'Messages_Generator',
843
+					array(),
844
+					false,
845
+					false
846
+				);
847
+			},
848
+			'EE_Messages_Template_Defaults'                => function ($arguments = array()) {
849
+				return EE_Registry::instance()->load_lib(
850
+					'Messages_Template_Defaults',
851
+					$arguments,
852
+					false,
853
+					false
854
+				);
855
+			},
856
+			// load_helper
857
+			'EEH_Parse_Shortcodes'                         => function () {
858
+				if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
859
+					return new EEH_Parse_Shortcodes();
860
+				}
861
+				return null;
862
+			},
863
+			'EE_Template_Config'                           => function () {
864
+				return EE_Config::instance()->template_settings;
865
+			},
866
+			'EE_Currency_Config'                           => function () {
867
+				return EE_Config::instance()->currency;
868
+			},
869
+			'EE_Registration_Config'                       => function () {
870
+				return EE_Config::instance()->registration;
871
+			},
872
+			'EE_Core_Config'                               => function () {
873
+				return EE_Config::instance()->core;
874
+			},
875
+			'EventEspresso\core\services\loaders\Loader'   => function () {
876
+				return LoaderFactory::getLoader();
877
+			},
878
+			'EE_Network_Config'                            => function () {
879
+				return EE_Network_Config::instance();
880
+			},
881
+			'EE_Config'                                    => function () {
882
+				return EE_Config::instance();
883
+			},
884
+			'EventEspresso\core\domain\Domain'             => function () {
885
+				return DomainFactory::getEventEspressoCoreDomain();
886
+			},
887
+			'EE_Admin_Config'                              => function () {
888
+				return EE_Config::instance()->admin;
889
+			},
890
+		);
891
+	}
892
+
893
+
894
+	/**
895
+	 * can be used for supplying alternate names for classes,
896
+	 * or for connecting interface names to instantiable classes
897
+	 */
898
+	protected function _register_core_aliases()
899
+	{
900
+		$aliases = array(
901
+			'CommandBusInterface'                                                          => 'EventEspresso\core\services\commands\CommandBusInterface',
902
+			'EventEspresso\core\services\commands\CommandBusInterface'                     => 'EventEspresso\core\services\commands\CommandBus',
903
+			'CommandHandlerManagerInterface'                                               => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
904
+			'EventEspresso\core\services\commands\CommandHandlerManagerInterface'          => 'EventEspresso\core\services\commands\CommandHandlerManager',
905
+			'CapChecker'                                                                   => 'EventEspresso\core\services\commands\middleware\CapChecker',
906
+			'AddActionHook'                                                                => 'EventEspresso\core\services\commands\middleware\AddActionHook',
907
+			'CapabilitiesChecker'                                                          => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
908
+			'CapabilitiesCheckerInterface'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface',
909
+			'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
910
+			'CreateRegistrationService'                                                    => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
911
+			'CreateRegistrationCommandHandler'                                             => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
912
+			'CopyRegistrationDetailsCommandHandler'                                        => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
913
+			'CopyRegistrationPaymentsCommandHandler'                                       => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
914
+			'CancelRegistrationAndTicketLineItemCommandHandler'                            => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
915
+			'UpdateRegistrationAndTransactionAfterChangeCommandHandler'                    => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
916
+			'CreateTicketLineItemCommandHandler'                                           => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
917
+			'CreateTransactionCommandHandler'                                              => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler',
918
+			'CreateAttendeeCommandHandler'                                                 => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler',
919
+			'TableManager'                                                                 => 'EventEspresso\core\services\database\TableManager',
920
+			'TableAnalysis'                                                                => 'EventEspresso\core\services\database\TableAnalysis',
921
+			'EspressoShortcode'                                                            => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
922
+			'ShortcodeInterface'                                                           => 'EventEspresso\core\services\shortcodes\ShortcodeInterface',
923
+			'EventEspresso\core\services\shortcodes\ShortcodeInterface'                    => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
924
+			'EventEspresso\core\services\cache\CacheStorageInterface'                      => 'EventEspresso\core\services\cache\TransientCacheStorage',
925
+			'LoaderInterface'                                                              => 'EventEspresso\core\services\loaders\LoaderInterface',
926
+			'EventEspresso\core\services\loaders\LoaderInterface'                          => 'EventEspresso\core\services\loaders\Loader',
927
+			'CommandFactoryInterface'                                                      => 'EventEspresso\core\services\commands\CommandFactoryInterface',
928
+			'EventEspresso\core\services\commands\CommandFactoryInterface'                 => 'EventEspresso\core\services\commands\CommandFactory',
929
+			'EventEspresso\core\domain\services\session\SessionIdentifierInterface'        => 'EE_Session',
930
+			'EmailValidatorInterface'                                                      => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface',
931
+			'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface'  => 'EventEspresso\core\domain\services\validation\email\EmailValidationService',
932
+			'NoticeConverterInterface'                                                     => 'EventEspresso\core\services\notices\NoticeConverterInterface',
933
+			'EventEspresso\core\services\notices\NoticeConverterInterface'                 => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors',
934
+			'NoticesContainerInterface'                                                    => 'EventEspresso\core\services\notices\NoticesContainerInterface',
935
+			'EventEspresso\core\services\notices\NoticesContainerInterface'                => 'EventEspresso\core\services\notices\NoticesContainer',
936
+			'EventEspresso\core\services\request\RequestInterface'                         => 'EventEspresso\core\services\request\Request',
937
+			'EventEspresso\core\services\request\ResponseInterface'                        => 'EventEspresso\core\services\request\Response',
938
+			'EventEspresso\core\domain\DomainInterface'                                    => 'EventEspresso\core\domain\Domain',
939
+		);
940
+		foreach ($aliases as $alias => $fqn) {
941
+			if (is_array($fqn)) {
942
+				foreach ($fqn as $class => $for_class) {
943
+					$this->class_cache->addAlias($class, $alias, $for_class);
944
+				}
945
+				continue;
946
+			}
947
+			$this->class_cache->addAlias($fqn, $alias);
948
+		}
949
+		if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
950
+			$this->class_cache->addAlias(
951
+				'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices',
952
+				'EventEspresso\core\services\notices\NoticeConverterInterface'
953
+			);
954
+		}
955
+	}
956
+
957
+
958
+	/**
959
+	 * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
960
+	 * request Primarily used by unit tests.
961
+	 */
962
+	public function reset()
963
+	{
964
+		$this->_register_core_class_loaders();
965
+		$this->_register_core_dependencies();
966
+	}
967
+
968
+
969
+	/**
970
+	 * PLZ NOTE: a better name for this method would be is_alias()
971
+	 * because it returns TRUE if the provided fully qualified name IS an alias
972
+	 * WHY?
973
+	 * Because if a class is type hinting for a concretion,
974
+	 * then why would we need to find another class to supply it?
975
+	 * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
976
+	 * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
977
+	 * Don't go looking for some substitute.
978
+	 * Whereas if a class is type hinting for an interface...
979
+	 * then we need to find an actual class to use.
980
+	 * So the interface IS the alias for some other FQN,
981
+	 * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
982
+	 * represents some other class.
983
+	 *
984
+	 * @deprecated 4.9.62.p
985
+	 * @param string $fqn
986
+	 * @param string $for_class
987
+	 * @return bool
988
+	 */
989
+	public function has_alias($fqn = '', $for_class = '')
990
+	{
991
+		return $this->isAlias($fqn, $for_class);
992
+	}
993
+
994
+
995
+	/**
996
+	 * PLZ NOTE: a better name for this method would be get_fqn_for_alias()
997
+	 * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias
998
+	 * functions recursively, so that multiple aliases can be used to drill down to a FQN
999
+	 *  for example:
1000
+	 *      if the following two entries were added to the _aliases array:
1001
+	 *          array(
1002
+	 *              'interface_alias'           => 'some\namespace\interface'
1003
+	 *              'some\namespace\interface'  => 'some\namespace\classname'
1004
+	 *          )
1005
+	 *      then one could use EE_Registry::instance()->create( 'interface_alias' )
1006
+	 *      to load an instance of 'some\namespace\classname'
1007
+	 *
1008
+	 * @deprecated 4.9.62.p
1009
+	 * @param string $alias
1010
+	 * @param string $for_class
1011
+	 * @return string
1012
+	 */
1013
+	public function get_alias($alias = '', $for_class = '')
1014
+	{
1015
+		return $this->getFqnForAlias($alias, $for_class);
1016
+	}
1017 1017
 }
Please login to merge, or discard this patch.
core/domain/entities/notifications/PersistentAdminNotice.php 1 patch
Indentation   +312 added lines, -312 removed lines patch added patch discarded remove patch
@@ -25,316 +25,316 @@
 block discarded – undo
25 25
 class PersistentAdminNotice implements RequiresCapCheckInterface
26 26
 {
27 27
 
28
-    /**
29
-     * @var string $name
30
-     */
31
-    protected $name = '';
32
-
33
-    /**
34
-     * @var string $message
35
-     */
36
-    protected $message = '';
37
-
38
-    /**
39
-     * @var boolean $force_update
40
-     */
41
-    protected $force_update = false;
42
-
43
-    /**
44
-     * @var string $capability
45
-     */
46
-    protected $capability = 'manage_options';
47
-
48
-    /**
49
-     * @var string $cap_context
50
-     */
51
-    protected $cap_context = 'view persistent admin notice';
52
-
53
-    /**
54
-     * @var boolean $dismissed
55
-     */
56
-    protected $dismissed = false;
57
-
58
-    /**
59
-     * @var CapCheckInterface $cap_check
60
-     */
61
-    protected $cap_check;
62
-
63
-    /**
64
-     * if true, then this notice will be deleted from the database
65
-     *
66
-     * @var boolean $purge
67
-     */
68
-    protected $purge = false;
69
-
70
-    /**
71
-     * gets set to true if notice is successfully registered with the PersistentAdminNoticeManager
72
-     * if false, and WP_DEBUG is on, then an exception will be thrown in the admin footer
73
-     *
74
-     * @var boolean $registered
75
-     */
76
-    private $registered = false;
77
-
78
-
79
-    /**
80
-     * PersistentAdminNotice constructor
81
-     *
82
-     * @param string $name         [required] the name, or key of the Persistent Admin Notice to be stored
83
-     * @param string $message      [required] the message to be stored persistently until dismissed
84
-     * @param bool   $force_update enforce the reappearance of a persistent message
85
-     * @param string $capability   user capability required to view this notice
86
-     * @param string $cap_context  description for why the cap check is being performed
87
-     * @param bool   $dismissed    whether or not the user has already dismissed/viewed this notice
88
-     * @throws InvalidDataTypeException
89
-     */
90
-    public function __construct(
91
-        $name,
92
-        $message,
93
-        $force_update = false,
94
-        $capability = 'manage_options',
95
-        $cap_context = 'view persistent admin notice',
96
-        $dismissed = false
97
-    ) {
98
-        $this->setName($name);
99
-        $this->setMessage($message);
100
-        $this->setForceUpdate($force_update);
101
-        $this->setCapability($capability);
102
-        $this->setCapContext($cap_context);
103
-        $this->setDismissed($dismissed);
104
-        add_action(
105
-            'AHEE__EventEspresso_core_services_notifications_PersistentAdminNoticeManager__registerNotices',
106
-            array($this, 'registerPersistentAdminNotice')
107
-        );
108
-        add_action('shutdown', array($this, 'confirmRegistered'), 999);
109
-    }
110
-
111
-
112
-    /**
113
-     * @return string
114
-     */
115
-    public function getName()
116
-    {
117
-        return $this->name;
118
-    }
119
-
120
-
121
-    /**
122
-     * @param string $name
123
-     * @throws InvalidDataTypeException
124
-     */
125
-    private function setName($name)
126
-    {
127
-        if (! is_string($name)) {
128
-            throw new InvalidDataTypeException('$name', $name, 'string');
129
-        }
130
-        $this->name = sanitize_key($name);
131
-    }
132
-
133
-
134
-    /**
135
-     * @return string
136
-     */
137
-    public function getMessage()
138
-    {
139
-        return $this->message;
140
-    }
141
-
142
-
143
-    /**
144
-     * @param string $message
145
-     * @throws InvalidDataTypeException
146
-     */
147
-    private function setMessage($message)
148
-    {
149
-        if (! is_string($message)) {
150
-            throw new InvalidDataTypeException('$message', $message, 'string');
151
-        }
152
-        global $allowedtags;
153
-        $allowedtags['br'] = array();
154
-        $this->message = wp_kses($message, $allowedtags);
155
-    }
156
-
157
-
158
-    /**
159
-     * @return bool
160
-     */
161
-    public function getForceUpdate()
162
-    {
163
-        return $this->force_update;
164
-    }
165
-
166
-
167
-    /**
168
-     * @param bool $force_update
169
-     */
170
-    private function setForceUpdate($force_update)
171
-    {
172
-        $this->force_update = filter_var($force_update, FILTER_VALIDATE_BOOLEAN);
173
-    }
174
-
175
-
176
-    /**
177
-     * @return string
178
-     */
179
-    public function getCapability()
180
-    {
181
-        return $this->capability;
182
-    }
183
-
184
-
185
-    /**
186
-     * @param string $capability
187
-     * @throws InvalidDataTypeException
188
-     */
189
-    private function setCapability($capability)
190
-    {
191
-        if (! is_string($capability)) {
192
-            throw new InvalidDataTypeException('$capability', $capability, 'string');
193
-        }
194
-        $this->capability = ! empty($capability) ? $capability : 'manage_options';
195
-    }
196
-
197
-
198
-    /**
199
-     * @return string
200
-     */
201
-    public function getCapContext()
202
-    {
203
-        return $this->cap_context;
204
-    }
205
-
206
-
207
-    /**
208
-     * @param string $cap_context
209
-     * @throws InvalidDataTypeException
210
-     */
211
-    private function setCapContext($cap_context)
212
-    {
213
-        if (! is_string($cap_context)) {
214
-            throw new InvalidDataTypeException('$cap_context', $cap_context, 'string');
215
-        }
216
-        $this->cap_context = ! empty($cap_context) ? $cap_context : 'view persistent admin notice';
217
-    }
218
-
219
-
220
-    /**
221
-     * @return bool
222
-     */
223
-    public function getDismissed()
224
-    {
225
-        return $this->dismissed;
226
-    }
227
-
228
-
229
-    /**
230
-     * @param bool $dismissed
231
-     */
232
-    public function setDismissed($dismissed)
233
-    {
234
-        $this->dismissed = filter_var($dismissed, FILTER_VALIDATE_BOOLEAN);
235
-    }
236
-
237
-
238
-    /**
239
-     * @return CapCheckInterface
240
-     * @throws InvalidDataTypeException
241
-     */
242
-    public function getCapCheck()
243
-    {
244
-        if (! $this->cap_check instanceof CapCheckInterface) {
245
-            $this->setCapCheck(
246
-                new CapCheck(
247
-                    $this->capability,
248
-                    $this->cap_context
249
-                )
250
-            );
251
-        }
252
-        return $this->cap_check;
253
-    }
254
-
255
-
256
-    /**
257
-     * @param CapCheckInterface $cap_check
258
-     */
259
-    private function setCapCheck(CapCheckInterface $cap_check)
260
-    {
261
-        $this->cap_check = $cap_check;
262
-    }
263
-
264
-
265
-    /**
266
-     * @return bool
267
-     */
268
-    public function getPurge()
269
-    {
270
-        return $this->purge;
271
-    }
272
-
273
-
274
-    /**
275
-     * @param bool $purge
276
-     */
277
-    public function setPurge($purge)
278
-    {
279
-        $this->purge = filter_var($purge, FILTER_VALIDATE_BOOLEAN);
280
-    }
281
-
282
-
283
-    /**
284
-     * given a valid PersistentAdminNotice Collection,
285
-     * this notice will be added if it is not already found in the collection (using its name as the identifier)
286
-     * if an existing notice is found that has already been dismissed,
287
-     * but we are overriding with a forced update, then we will toggle its dismissed state,
288
-     * so that the notice is displayed again
289
-     *
290
-     * @param Collection $persistent_admin_notice_collection
291
-     * @throws InvalidEntityException
292
-     * @throws InvalidDataTypeException
293
-     * @throws DuplicateCollectionIdentifierException
294
-     */
295
-    public function registerPersistentAdminNotice(Collection $persistent_admin_notice_collection)
296
-    {
297
-        if ($this->registered) {
298
-            return;
299
-        }
300
-        // first check if this notice has already been added to the collection
301
-        if ($persistent_admin_notice_collection->has($this->name)) {
302
-            /** @var PersistentAdminNotice $existing */
303
-            $existing = $persistent_admin_notice_collection->get($this->name);
304
-            // we don't need to add it again (we can't actually)
305
-            // but if it has already been dismissed, and we are overriding with a forced update
306
-            if ($existing->getDismissed() && $this->getForceUpdate()) {
307
-                // then toggle the notice's dismissed state to true
308
-                // so that it gets displayed again
309
-                $existing->setDismissed(false);
310
-                // and make sure the message is set
311
-                $existing->setMessage($this->message);
312
-            }
313
-        } else {
314
-            $persistent_admin_notice_collection->add($this, $this->name);
315
-        }
316
-        $this->registered = true;
317
-    }
318
-
319
-
320
-    /**
321
-     * @throws Exception
322
-     */
323
-    public function confirmRegistered()
324
-    {
325
-        if (! apply_filters('PersistentAdminNoticeManager__registerAndSaveNotices__complete', false)) {
326
-            PersistentAdminNoticeManager::loadRegisterAndSaveNotices();
327
-        }
328
-        if (! $this->registered && WP_DEBUG) {
329
-            throw new DomainException(
330
-                sprintf(
331
-                    esc_html__(
332
-                        'The "%1$s" PersistentAdminNotice was not successfully registered. Please ensure that it is being created prior to either the "admin_notices" or "network_admin_notices" hooks being triggered.',
333
-                        'event_espresso'
334
-                    ),
335
-                    $this->name
336
-                )
337
-            );
338
-        }
339
-    }
28
+	/**
29
+	 * @var string $name
30
+	 */
31
+	protected $name = '';
32
+
33
+	/**
34
+	 * @var string $message
35
+	 */
36
+	protected $message = '';
37
+
38
+	/**
39
+	 * @var boolean $force_update
40
+	 */
41
+	protected $force_update = false;
42
+
43
+	/**
44
+	 * @var string $capability
45
+	 */
46
+	protected $capability = 'manage_options';
47
+
48
+	/**
49
+	 * @var string $cap_context
50
+	 */
51
+	protected $cap_context = 'view persistent admin notice';
52
+
53
+	/**
54
+	 * @var boolean $dismissed
55
+	 */
56
+	protected $dismissed = false;
57
+
58
+	/**
59
+	 * @var CapCheckInterface $cap_check
60
+	 */
61
+	protected $cap_check;
62
+
63
+	/**
64
+	 * if true, then this notice will be deleted from the database
65
+	 *
66
+	 * @var boolean $purge
67
+	 */
68
+	protected $purge = false;
69
+
70
+	/**
71
+	 * gets set to true if notice is successfully registered with the PersistentAdminNoticeManager
72
+	 * if false, and WP_DEBUG is on, then an exception will be thrown in the admin footer
73
+	 *
74
+	 * @var boolean $registered
75
+	 */
76
+	private $registered = false;
77
+
78
+
79
+	/**
80
+	 * PersistentAdminNotice constructor
81
+	 *
82
+	 * @param string $name         [required] the name, or key of the Persistent Admin Notice to be stored
83
+	 * @param string $message      [required] the message to be stored persistently until dismissed
84
+	 * @param bool   $force_update enforce the reappearance of a persistent message
85
+	 * @param string $capability   user capability required to view this notice
86
+	 * @param string $cap_context  description for why the cap check is being performed
87
+	 * @param bool   $dismissed    whether or not the user has already dismissed/viewed this notice
88
+	 * @throws InvalidDataTypeException
89
+	 */
90
+	public function __construct(
91
+		$name,
92
+		$message,
93
+		$force_update = false,
94
+		$capability = 'manage_options',
95
+		$cap_context = 'view persistent admin notice',
96
+		$dismissed = false
97
+	) {
98
+		$this->setName($name);
99
+		$this->setMessage($message);
100
+		$this->setForceUpdate($force_update);
101
+		$this->setCapability($capability);
102
+		$this->setCapContext($cap_context);
103
+		$this->setDismissed($dismissed);
104
+		add_action(
105
+			'AHEE__EventEspresso_core_services_notifications_PersistentAdminNoticeManager__registerNotices',
106
+			array($this, 'registerPersistentAdminNotice')
107
+		);
108
+		add_action('shutdown', array($this, 'confirmRegistered'), 999);
109
+	}
110
+
111
+
112
+	/**
113
+	 * @return string
114
+	 */
115
+	public function getName()
116
+	{
117
+		return $this->name;
118
+	}
119
+
120
+
121
+	/**
122
+	 * @param string $name
123
+	 * @throws InvalidDataTypeException
124
+	 */
125
+	private function setName($name)
126
+	{
127
+		if (! is_string($name)) {
128
+			throw new InvalidDataTypeException('$name', $name, 'string');
129
+		}
130
+		$this->name = sanitize_key($name);
131
+	}
132
+
133
+
134
+	/**
135
+	 * @return string
136
+	 */
137
+	public function getMessage()
138
+	{
139
+		return $this->message;
140
+	}
141
+
142
+
143
+	/**
144
+	 * @param string $message
145
+	 * @throws InvalidDataTypeException
146
+	 */
147
+	private function setMessage($message)
148
+	{
149
+		if (! is_string($message)) {
150
+			throw new InvalidDataTypeException('$message', $message, 'string');
151
+		}
152
+		global $allowedtags;
153
+		$allowedtags['br'] = array();
154
+		$this->message = wp_kses($message, $allowedtags);
155
+	}
156
+
157
+
158
+	/**
159
+	 * @return bool
160
+	 */
161
+	public function getForceUpdate()
162
+	{
163
+		return $this->force_update;
164
+	}
165
+
166
+
167
+	/**
168
+	 * @param bool $force_update
169
+	 */
170
+	private function setForceUpdate($force_update)
171
+	{
172
+		$this->force_update = filter_var($force_update, FILTER_VALIDATE_BOOLEAN);
173
+	}
174
+
175
+
176
+	/**
177
+	 * @return string
178
+	 */
179
+	public function getCapability()
180
+	{
181
+		return $this->capability;
182
+	}
183
+
184
+
185
+	/**
186
+	 * @param string $capability
187
+	 * @throws InvalidDataTypeException
188
+	 */
189
+	private function setCapability($capability)
190
+	{
191
+		if (! is_string($capability)) {
192
+			throw new InvalidDataTypeException('$capability', $capability, 'string');
193
+		}
194
+		$this->capability = ! empty($capability) ? $capability : 'manage_options';
195
+	}
196
+
197
+
198
+	/**
199
+	 * @return string
200
+	 */
201
+	public function getCapContext()
202
+	{
203
+		return $this->cap_context;
204
+	}
205
+
206
+
207
+	/**
208
+	 * @param string $cap_context
209
+	 * @throws InvalidDataTypeException
210
+	 */
211
+	private function setCapContext($cap_context)
212
+	{
213
+		if (! is_string($cap_context)) {
214
+			throw new InvalidDataTypeException('$cap_context', $cap_context, 'string');
215
+		}
216
+		$this->cap_context = ! empty($cap_context) ? $cap_context : 'view persistent admin notice';
217
+	}
218
+
219
+
220
+	/**
221
+	 * @return bool
222
+	 */
223
+	public function getDismissed()
224
+	{
225
+		return $this->dismissed;
226
+	}
227
+
228
+
229
+	/**
230
+	 * @param bool $dismissed
231
+	 */
232
+	public function setDismissed($dismissed)
233
+	{
234
+		$this->dismissed = filter_var($dismissed, FILTER_VALIDATE_BOOLEAN);
235
+	}
236
+
237
+
238
+	/**
239
+	 * @return CapCheckInterface
240
+	 * @throws InvalidDataTypeException
241
+	 */
242
+	public function getCapCheck()
243
+	{
244
+		if (! $this->cap_check instanceof CapCheckInterface) {
245
+			$this->setCapCheck(
246
+				new CapCheck(
247
+					$this->capability,
248
+					$this->cap_context
249
+				)
250
+			);
251
+		}
252
+		return $this->cap_check;
253
+	}
254
+
255
+
256
+	/**
257
+	 * @param CapCheckInterface $cap_check
258
+	 */
259
+	private function setCapCheck(CapCheckInterface $cap_check)
260
+	{
261
+		$this->cap_check = $cap_check;
262
+	}
263
+
264
+
265
+	/**
266
+	 * @return bool
267
+	 */
268
+	public function getPurge()
269
+	{
270
+		return $this->purge;
271
+	}
272
+
273
+
274
+	/**
275
+	 * @param bool $purge
276
+	 */
277
+	public function setPurge($purge)
278
+	{
279
+		$this->purge = filter_var($purge, FILTER_VALIDATE_BOOLEAN);
280
+	}
281
+
282
+
283
+	/**
284
+	 * given a valid PersistentAdminNotice Collection,
285
+	 * this notice will be added if it is not already found in the collection (using its name as the identifier)
286
+	 * if an existing notice is found that has already been dismissed,
287
+	 * but we are overriding with a forced update, then we will toggle its dismissed state,
288
+	 * so that the notice is displayed again
289
+	 *
290
+	 * @param Collection $persistent_admin_notice_collection
291
+	 * @throws InvalidEntityException
292
+	 * @throws InvalidDataTypeException
293
+	 * @throws DuplicateCollectionIdentifierException
294
+	 */
295
+	public function registerPersistentAdminNotice(Collection $persistent_admin_notice_collection)
296
+	{
297
+		if ($this->registered) {
298
+			return;
299
+		}
300
+		// first check if this notice has already been added to the collection
301
+		if ($persistent_admin_notice_collection->has($this->name)) {
302
+			/** @var PersistentAdminNotice $existing */
303
+			$existing = $persistent_admin_notice_collection->get($this->name);
304
+			// we don't need to add it again (we can't actually)
305
+			// but if it has already been dismissed, and we are overriding with a forced update
306
+			if ($existing->getDismissed() && $this->getForceUpdate()) {
307
+				// then toggle the notice's dismissed state to true
308
+				// so that it gets displayed again
309
+				$existing->setDismissed(false);
310
+				// and make sure the message is set
311
+				$existing->setMessage($this->message);
312
+			}
313
+		} else {
314
+			$persistent_admin_notice_collection->add($this, $this->name);
315
+		}
316
+		$this->registered = true;
317
+	}
318
+
319
+
320
+	/**
321
+	 * @throws Exception
322
+	 */
323
+	public function confirmRegistered()
324
+	{
325
+		if (! apply_filters('PersistentAdminNoticeManager__registerAndSaveNotices__complete', false)) {
326
+			PersistentAdminNoticeManager::loadRegisterAndSaveNotices();
327
+		}
328
+		if (! $this->registered && WP_DEBUG) {
329
+			throw new DomainException(
330
+				sprintf(
331
+					esc_html__(
332
+						'The "%1$s" PersistentAdminNotice was not successfully registered. Please ensure that it is being created prior to either the "admin_notices" or "network_admin_notices" hooks being triggered.',
333
+						'event_espresso'
334
+					),
335
+					$this->name
336
+				)
337
+			);
338
+		}
339
+	}
340 340
 }
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -38,103 +38,103 @@
 block discarded – undo
38 38
  * @since           4.0
39 39
  */
40 40
 if (function_exists('espresso_version')) {
41
-    if (! function_exists('espresso_duplicate_plugin_error')) {
42
-        /**
43
-         *    espresso_duplicate_plugin_error
44
-         *    displays if more than one version of EE is activated at the same time
45
-         */
46
-        function espresso_duplicate_plugin_error()
47
-        {
48
-            ?>
41
+	if (! function_exists('espresso_duplicate_plugin_error')) {
42
+		/**
43
+		 *    espresso_duplicate_plugin_error
44
+		 *    displays if more than one version of EE is activated at the same time
45
+		 */
46
+		function espresso_duplicate_plugin_error()
47
+		{
48
+			?>
49 49
             <div class="error">
50 50
                 <p>
51 51
                     <?php
52
-                    echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                    ); ?>
52
+					echo esc_html__(
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+					); ?>
56 56
                 </p>
57 57
             </div>
58 58
             <?php
59
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-        }
61
-    }
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
59
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+		}
61
+	}
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 } else {
64
-    define('EE_MIN_PHP_VER_REQUIRED', '5.4.0');
65
-    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
-        /**
67
-         * espresso_minimum_php_version_error
68
-         *
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
64
+	define('EE_MIN_PHP_VER_REQUIRED', '5.4.0');
65
+	if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
+		/**
67
+		 * espresso_minimum_php_version_error
68
+		 *
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                        esc_html__(
79
-                            'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
-                            'event_espresso'
81
-                        ),
82
-                        EE_MIN_PHP_VER_REQUIRED,
83
-                        PHP_VERSION,
84
-                        '<br/>',
85
-                        '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+						esc_html__(
79
+							'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
+							'event_espresso'
81
+						),
82
+						EE_MIN_PHP_VER_REQUIRED,
83
+						PHP_VERSION,
84
+						'<br/>',
85
+						'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
-        /**
98
-         * espresso_version
99
-         * Returns the plugin version
100
-         *
101
-         * @return string
102
-         */
103
-        function espresso_version()
104
-        {
105
-            return apply_filters('FHEE__espresso__espresso_version', '4.9.66.rc.022');
106
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
+		/**
98
+		 * espresso_version
99
+		 * Returns the plugin version
100
+		 *
101
+		 * @return string
102
+		 */
103
+		function espresso_version()
104
+		{
105
+			return apply_filters('FHEE__espresso__espresso_version', '4.9.66.rc.022');
106
+		}
107 107
 
108
-        /**
109
-         * espresso_plugin_activation
110
-         * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
-         */
112
-        function espresso_plugin_activation()
113
-        {
114
-            update_option('ee_espresso_activation', true);
115
-        }
108
+		/**
109
+		 * espresso_plugin_activation
110
+		 * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
+		 */
112
+		function espresso_plugin_activation()
113
+		{
114
+			update_option('ee_espresso_activation', true);
115
+		}
116 116
 
117
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
117
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
118 118
 
119
-        require_once __DIR__ . '/core/bootstrap_espresso.php';
120
-        bootstrap_espresso();
121
-    }
119
+		require_once __DIR__ . '/core/bootstrap_espresso.php';
120
+		bootstrap_espresso();
121
+	}
122 122
 }
123 123
 if (! function_exists('espresso_deactivate_plugin')) {
124
-    /**
125
-     *    deactivate_plugin
126
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
-     *
128
-     * @access public
129
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
-     * @return    void
131
-     */
132
-    function espresso_deactivate_plugin($plugin_basename = '')
133
-    {
134
-        if (! function_exists('deactivate_plugins')) {
135
-            require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
-        }
137
-        unset($_GET['activate'], $_REQUEST['activate']);
138
-        deactivate_plugins($plugin_basename);
139
-    }
124
+	/**
125
+	 *    deactivate_plugin
126
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
+	 *
128
+	 * @access public
129
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
+	 * @return    void
131
+	 */
132
+	function espresso_deactivate_plugin($plugin_basename = '')
133
+	{
134
+		if (! function_exists('deactivate_plugins')) {
135
+			require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
+		}
137
+		unset($_GET['activate'], $_REQUEST['activate']);
138
+		deactivate_plugins($plugin_basename);
139
+	}
140 140
 }
Please login to merge, or discard this patch.