Completed
Branch FET-10785-ee-system-loader (d67185)
by
unknown
106:46 queued 95:31
created
caffeinated/brewing_regular.php 1 patch
Indentation   +269 added lines, -269 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 use EventEspresso\core\services\database\TableAnalysis;
5 5
 
6 6
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
7
-    exit('No direct script access allowed');
7
+	exit('No direct script access allowed');
8 8
 }
9 9
 /**
10 10
  * the purpose of this file is to simply contain any action/filter hook callbacks etc for specific aspects of EE
@@ -29,277 +29,277 @@  discard block
 block discarded – undo
29 29
 class EE_Brewing_Regular extends EE_BASE implements InterminableInterface
30 30
 {
31 31
 
32
-    /**
33
-     * @var \EventEspresso\core\services\database\TableAnalysis $table_analysis
34
-     */
35
-    protected $_table_analysis;
36
-
37
-
38
-
39
-    /**
40
-     * EE_Brewing_Regular constructor.
41
-     */
42
-    public function __construct(TableAnalysis $table_analysis)
43
-    {
44
-        $this->_table_analysis = $table_analysis;
45
-        if (defined('EE_CAFF_PATH')) {
46
-            // activation
47
-            add_action('AHEE__EEH_Activation__initialize_db_content', array($this, 'initialize_caf_db_content'));
48
-            // load caff init
49
-            add_action('AHEE__EE_System__set_hooks_for_core', array($this, 'caffeinated_init'));
50
-            // remove the "powered by" credit link from receipts and invoices
51
-            add_filter('FHEE_EE_Html_messenger__add_powered_by_credit_link_to_receipt_and_invoice', '__return_false');
52
-            // add caffeinated modules
53
-            add_filter(
54
-                'FHEE__EE_Config__register_modules__modules_to_register',
55
-                array($this, 'caffeinated_modules_to_register')
56
-            );
57
-            // load caff scripts
58
-            add_action('wp_enqueue_scripts', array($this, 'enqueue_caffeinated_scripts'), 10);
59
-            add_filter('FHEE__EE_Registry__load_helper__helper_paths', array($this, 'caf_helper_paths'), 10);
60
-            add_filter(
61
-                'FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register',
62
-                array($this, 'caf_payment_methods')
63
-            );
64
-            // caffeinated constructed
65
-            do_action('AHEE__EE_Brewing_Regular__construct__complete');
66
-            //seeing how this is caf, which isn't put on WordPress.org, we can have affiliate links without a disclaimer
67
-            add_filter('FHEE__ee_show_affiliate_links', '__return_false');
68
-        }
69
-    }
70
-
71
-
72
-
73
-    /**
74
-     * callback for the FHEE__EE_Registry__load_helper__helper_paths filter to add the caffeinated paths
75
-     *
76
-     * @param array $paths original helper paths array
77
-     * @return array             new array of paths
78
-     */
79
-    public function caf_helper_paths($paths)
80
-    {
81
-        $paths[] = EE_CAF_CORE . 'helpers' . DS;
82
-        return $paths;
83
-    }
84
-
85
-
86
-
87
-    /**
88
-     * Upon brand-new activation, if this is a new activation of CAF, we want to add
89
-     * some global prices that will show off EE4's capabilities. However, if they're upgrading
90
-     * from 3.1, or simply EE4.x decaf, we assume they don't want us to suddenly introduce these extra prices.
91
-     * This action should only be called when EE 4.x.0.P is initially activated.
92
-     * Right now the only CAF content are these global prices. If there's more in the future, then
93
-     * we should probably create a caf file to contain it all instead just a function like this.
94
-     * Right now, we ASSUME the only price types in the system are default ones
95
-     *
96
-     * @global wpdb $wpdb
97
-     */
98
-    public function initialize_caf_db_content()
99
-    {
100
-        global $wpdb;
101
-        //use same method of getting creator id as the version introducing the change
102
-        $default_creator_id = apply_filters('FHEE__EE_DMS_Core_4_5_0__get_default_creator_id', get_current_user_id());
103
-        $price_type_table = $wpdb->prefix . "esp_price_type";
104
-        $price_table = $wpdb->prefix . "esp_price";
105
-        if ($this->_get_table_analysis()->tableExists($price_type_table)) {
106
-            $SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table . ' WHERE PBT_ID=4';//include trashed price types
107
-            $tax_price_type_count = $wpdb->get_var($SQL);
108
-            if ($tax_price_type_count <= 1) {
109
-                $wpdb->insert(
110
-                    $price_type_table,
111
-                    array(
112
-                        'PRT_name'       => __("Regional Tax", "event_espresso"),
113
-                        'PBT_ID'         => 4,
114
-                        'PRT_is_percent' => true,
115
-                        'PRT_order'      => 60,
116
-                        'PRT_deleted'    => false,
117
-                        'PRT_wp_user'    => $default_creator_id,
118
-                    ),
119
-                    array(
120
-                        '%s',//PRT_name
121
-                        '%d',//PBT_id
122
-                        '%d',//PRT_is_percent
123
-                        '%d',//PRT_order
124
-                        '%d',//PRT_deleted
125
-                        '%d', //PRT_wp_user
126
-                    )
127
-                );
128
-                //federal tax
129
-                $result = $wpdb->insert(
130
-                    $price_type_table,
131
-                    array(
132
-                        'PRT_name'       => __("Federal Tax", "event_espresso"),
133
-                        'PBT_ID'         => 4,
134
-                        'PRT_is_percent' => true,
135
-                        'PRT_order'      => 70,
136
-                        'PRT_deleted'    => false,
137
-                        'PRT_wp_user'    => $default_creator_id,
138
-                    ),
139
-                    array(
140
-                        '%s',//PRT_name
141
-                        '%d',//PBT_id
142
-                        '%d',//PRT_is_percent
143
-                        '%d',//PRT_order
144
-                        '%d',//PRT_deleted
145
-                        '%d' //PRT_wp_user
146
-                    )
147
-                );
148
-                if ($result) {
149
-                    $wpdb->insert(
150
-                        $price_table,
151
-                        array(
152
-                            'PRT_ID'         => $wpdb->insert_id,
153
-                            'PRC_amount'     => 15.00,
154
-                            'PRC_name'       => __("Sales Tax", "event_espresso"),
155
-                            'PRC_desc'       => '',
156
-                            'PRC_is_default' => true,
157
-                            'PRC_overrides'  => null,
158
-                            'PRC_deleted'    => false,
159
-                            'PRC_order'      => 50,
160
-                            'PRC_parent'     => null,
161
-                            'PRC_wp_user'    => $default_creator_id,
162
-                        ),
163
-                        array(
164
-                            '%d',//PRT_id
165
-                            '%f',//PRC_amount
166
-                            '%s',//PRC_name
167
-                            '%s',//PRC_desc
168
-                            '%d',//PRC_is_default
169
-                            '%d',//PRC_overrides
170
-                            '%d',//PRC_deleted
171
-                            '%d',//PRC_order
172
-                            '%d',//PRC_parent
173
-                            '%d' //PRC_wp_user
174
-                        )
175
-                    );
176
-                }
177
-            }
178
-        }
179
-    }
180
-
181
-
182
-
183
-    /**
184
-     *    caffeinated_modules_to_register
185
-     *
186
-     * @access public
187
-     * @param array $modules_to_register
188
-     * @return array
189
-     */
190
-    public function caffeinated_modules_to_register($modules_to_register = array())
191
-    {
192
-        if (is_readable(EE_CAFF_PATH . 'modules')) {
193
-            $caffeinated_modules_to_register = glob(EE_CAFF_PATH . 'modules' . DS . '*', GLOB_ONLYDIR);
194
-            if (is_array($caffeinated_modules_to_register) && ! empty($caffeinated_modules_to_register)) {
195
-                $modules_to_register = array_merge($modules_to_register, $caffeinated_modules_to_register);
196
-            }
197
-        }
198
-        return $modules_to_register;
199
-    }
200
-
201
-
202
-
203
-    public function caffeinated_init()
204
-    {
205
-        // EE_Register_CPTs hooks
206
-        add_filter('FHEE__EE_Register_CPTs__get_taxonomies__taxonomies', array($this, 'filter_taxonomies'), 10);
207
-        add_filter('FHEE__EE_Register_CPTs__get_CPTs__cpts', array($this, 'filter_cpts'), 10);
208
-        add_filter('FHEE__EE_Admin__get_extra_nav_menu_pages_items', array($this, 'nav_metabox_items'), 10);
209
-        EE_Registry::instance()->load_file(EE_CAFF_PATH, 'EE_Caf_Messages', 'class', array(), false);
210
-        // caffeinated_init__complete hook
211
-        do_action('AHEE__EE_Brewing_Regular__caffeinated_init__complete');
212
-    }
213
-
214
-
215
-
216
-    public function enqueue_caffeinated_scripts()
217
-    {
218
-        // sound of crickets...
219
-    }
220
-
221
-
222
-
223
-    /**
224
-     * callbacks below here
225
-     *
226
-     * @param array $taxonomy_array
227
-     * @return array
228
-     */
229
-    public function filter_taxonomies(array $taxonomy_array)
230
-    {
231
-        $taxonomy_array['espresso_venue_categories']['args']['show_in_nav_menus'] = true;
232
-        return $taxonomy_array;
233
-    }
234
-
235
-
236
-
237
-    /**
238
-     * @param array $cpt_array
239
-     * @return mixed
240
-     */
241
-    public function filter_cpts(array $cpt_array)
242
-    {
243
-        $cpt_array['espresso_venues']['args']['show_in_nav_menus'] = true;
244
-        return $cpt_array;
245
-    }
246
-
247
-
248
-
249
-    /**
250
-     * @param array $menuitems
251
-     * @return array
252
-     */
253
-    public function nav_metabox_items(array $menuitems)
254
-    {
255
-        $menuitems[] = array(
256
-            'title'       => __('Venue List', 'event_espresso'),
257
-            'url'         => get_post_type_archive_link('espresso_venues'),
258
-            'description' => __('Archive page for all venues.', 'event_espresso'),
259
-        );
260
-        return $menuitems;
261
-    }
262
-
263
-
264
-
265
-    /**
266
-     * Adds the payment methods in {event-espresso-core}/caffeinated/payment_methods
267
-     *
268
-     * @param array $payment_method_paths
269
-     * @return array values are folder paths to payment method folders
270
-     */
271
-    public function caf_payment_methods($payment_method_paths)
272
-    {
273
-        $caf_payment_methods_paths = glob(EE_CAF_PAYMENT_METHODS . '*', GLOB_ONLYDIR);
274
-        $payment_method_paths = array_merge($payment_method_paths, $caf_payment_methods_paths);
275
-        return $payment_method_paths;
276
-    }
277
-
278
-
279
-
280
-    /**
281
-     * Gets the injected table analyzer, or throws an exception
282
-     *
283
-     * @return TableAnalysis
284
-     * @throws \EE_Error
285
-     */
286
-    protected function _get_table_analysis()
287
-    {
288
-        if ($this->_table_analysis instanceof TableAnalysis) {
289
-            return $this->_table_analysis;
290
-        } else {
291
-            throw new \EE_Error(
292
-                sprintf(
293
-                    __('Table analysis class on class %1$s is not set properly.', 'event_espresso'),
294
-                    get_class($this)
295
-                )
296
-            );
297
-        }
298
-    }
32
+	/**
33
+	 * @var \EventEspresso\core\services\database\TableAnalysis $table_analysis
34
+	 */
35
+	protected $_table_analysis;
36
+
37
+
38
+
39
+	/**
40
+	 * EE_Brewing_Regular constructor.
41
+	 */
42
+	public function __construct(TableAnalysis $table_analysis)
43
+	{
44
+		$this->_table_analysis = $table_analysis;
45
+		if (defined('EE_CAFF_PATH')) {
46
+			// activation
47
+			add_action('AHEE__EEH_Activation__initialize_db_content', array($this, 'initialize_caf_db_content'));
48
+			// load caff init
49
+			add_action('AHEE__EE_System__set_hooks_for_core', array($this, 'caffeinated_init'));
50
+			// remove the "powered by" credit link from receipts and invoices
51
+			add_filter('FHEE_EE_Html_messenger__add_powered_by_credit_link_to_receipt_and_invoice', '__return_false');
52
+			// add caffeinated modules
53
+			add_filter(
54
+				'FHEE__EE_Config__register_modules__modules_to_register',
55
+				array($this, 'caffeinated_modules_to_register')
56
+			);
57
+			// load caff scripts
58
+			add_action('wp_enqueue_scripts', array($this, 'enqueue_caffeinated_scripts'), 10);
59
+			add_filter('FHEE__EE_Registry__load_helper__helper_paths', array($this, 'caf_helper_paths'), 10);
60
+			add_filter(
61
+				'FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register',
62
+				array($this, 'caf_payment_methods')
63
+			);
64
+			// caffeinated constructed
65
+			do_action('AHEE__EE_Brewing_Regular__construct__complete');
66
+			//seeing how this is caf, which isn't put on WordPress.org, we can have affiliate links without a disclaimer
67
+			add_filter('FHEE__ee_show_affiliate_links', '__return_false');
68
+		}
69
+	}
70
+
71
+
72
+
73
+	/**
74
+	 * callback for the FHEE__EE_Registry__load_helper__helper_paths filter to add the caffeinated paths
75
+	 *
76
+	 * @param array $paths original helper paths array
77
+	 * @return array             new array of paths
78
+	 */
79
+	public function caf_helper_paths($paths)
80
+	{
81
+		$paths[] = EE_CAF_CORE . 'helpers' . DS;
82
+		return $paths;
83
+	}
84
+
85
+
86
+
87
+	/**
88
+	 * Upon brand-new activation, if this is a new activation of CAF, we want to add
89
+	 * some global prices that will show off EE4's capabilities. However, if they're upgrading
90
+	 * from 3.1, or simply EE4.x decaf, we assume they don't want us to suddenly introduce these extra prices.
91
+	 * This action should only be called when EE 4.x.0.P is initially activated.
92
+	 * Right now the only CAF content are these global prices. If there's more in the future, then
93
+	 * we should probably create a caf file to contain it all instead just a function like this.
94
+	 * Right now, we ASSUME the only price types in the system are default ones
95
+	 *
96
+	 * @global wpdb $wpdb
97
+	 */
98
+	public function initialize_caf_db_content()
99
+	{
100
+		global $wpdb;
101
+		//use same method of getting creator id as the version introducing the change
102
+		$default_creator_id = apply_filters('FHEE__EE_DMS_Core_4_5_0__get_default_creator_id', get_current_user_id());
103
+		$price_type_table = $wpdb->prefix . "esp_price_type";
104
+		$price_table = $wpdb->prefix . "esp_price";
105
+		if ($this->_get_table_analysis()->tableExists($price_type_table)) {
106
+			$SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table . ' WHERE PBT_ID=4';//include trashed price types
107
+			$tax_price_type_count = $wpdb->get_var($SQL);
108
+			if ($tax_price_type_count <= 1) {
109
+				$wpdb->insert(
110
+					$price_type_table,
111
+					array(
112
+						'PRT_name'       => __("Regional Tax", "event_espresso"),
113
+						'PBT_ID'         => 4,
114
+						'PRT_is_percent' => true,
115
+						'PRT_order'      => 60,
116
+						'PRT_deleted'    => false,
117
+						'PRT_wp_user'    => $default_creator_id,
118
+					),
119
+					array(
120
+						'%s',//PRT_name
121
+						'%d',//PBT_id
122
+						'%d',//PRT_is_percent
123
+						'%d',//PRT_order
124
+						'%d',//PRT_deleted
125
+						'%d', //PRT_wp_user
126
+					)
127
+				);
128
+				//federal tax
129
+				$result = $wpdb->insert(
130
+					$price_type_table,
131
+					array(
132
+						'PRT_name'       => __("Federal Tax", "event_espresso"),
133
+						'PBT_ID'         => 4,
134
+						'PRT_is_percent' => true,
135
+						'PRT_order'      => 70,
136
+						'PRT_deleted'    => false,
137
+						'PRT_wp_user'    => $default_creator_id,
138
+					),
139
+					array(
140
+						'%s',//PRT_name
141
+						'%d',//PBT_id
142
+						'%d',//PRT_is_percent
143
+						'%d',//PRT_order
144
+						'%d',//PRT_deleted
145
+						'%d' //PRT_wp_user
146
+					)
147
+				);
148
+				if ($result) {
149
+					$wpdb->insert(
150
+						$price_table,
151
+						array(
152
+							'PRT_ID'         => $wpdb->insert_id,
153
+							'PRC_amount'     => 15.00,
154
+							'PRC_name'       => __("Sales Tax", "event_espresso"),
155
+							'PRC_desc'       => '',
156
+							'PRC_is_default' => true,
157
+							'PRC_overrides'  => null,
158
+							'PRC_deleted'    => false,
159
+							'PRC_order'      => 50,
160
+							'PRC_parent'     => null,
161
+							'PRC_wp_user'    => $default_creator_id,
162
+						),
163
+						array(
164
+							'%d',//PRT_id
165
+							'%f',//PRC_amount
166
+							'%s',//PRC_name
167
+							'%s',//PRC_desc
168
+							'%d',//PRC_is_default
169
+							'%d',//PRC_overrides
170
+							'%d',//PRC_deleted
171
+							'%d',//PRC_order
172
+							'%d',//PRC_parent
173
+							'%d' //PRC_wp_user
174
+						)
175
+					);
176
+				}
177
+			}
178
+		}
179
+	}
180
+
181
+
182
+
183
+	/**
184
+	 *    caffeinated_modules_to_register
185
+	 *
186
+	 * @access public
187
+	 * @param array $modules_to_register
188
+	 * @return array
189
+	 */
190
+	public function caffeinated_modules_to_register($modules_to_register = array())
191
+	{
192
+		if (is_readable(EE_CAFF_PATH . 'modules')) {
193
+			$caffeinated_modules_to_register = glob(EE_CAFF_PATH . 'modules' . DS . '*', GLOB_ONLYDIR);
194
+			if (is_array($caffeinated_modules_to_register) && ! empty($caffeinated_modules_to_register)) {
195
+				$modules_to_register = array_merge($modules_to_register, $caffeinated_modules_to_register);
196
+			}
197
+		}
198
+		return $modules_to_register;
199
+	}
200
+
201
+
202
+
203
+	public function caffeinated_init()
204
+	{
205
+		// EE_Register_CPTs hooks
206
+		add_filter('FHEE__EE_Register_CPTs__get_taxonomies__taxonomies', array($this, 'filter_taxonomies'), 10);
207
+		add_filter('FHEE__EE_Register_CPTs__get_CPTs__cpts', array($this, 'filter_cpts'), 10);
208
+		add_filter('FHEE__EE_Admin__get_extra_nav_menu_pages_items', array($this, 'nav_metabox_items'), 10);
209
+		EE_Registry::instance()->load_file(EE_CAFF_PATH, 'EE_Caf_Messages', 'class', array(), false);
210
+		// caffeinated_init__complete hook
211
+		do_action('AHEE__EE_Brewing_Regular__caffeinated_init__complete');
212
+	}
213
+
214
+
215
+
216
+	public function enqueue_caffeinated_scripts()
217
+	{
218
+		// sound of crickets...
219
+	}
220
+
221
+
222
+
223
+	/**
224
+	 * callbacks below here
225
+	 *
226
+	 * @param array $taxonomy_array
227
+	 * @return array
228
+	 */
229
+	public function filter_taxonomies(array $taxonomy_array)
230
+	{
231
+		$taxonomy_array['espresso_venue_categories']['args']['show_in_nav_menus'] = true;
232
+		return $taxonomy_array;
233
+	}
234
+
235
+
236
+
237
+	/**
238
+	 * @param array $cpt_array
239
+	 * @return mixed
240
+	 */
241
+	public function filter_cpts(array $cpt_array)
242
+	{
243
+		$cpt_array['espresso_venues']['args']['show_in_nav_menus'] = true;
244
+		return $cpt_array;
245
+	}
246
+
247
+
248
+
249
+	/**
250
+	 * @param array $menuitems
251
+	 * @return array
252
+	 */
253
+	public function nav_metabox_items(array $menuitems)
254
+	{
255
+		$menuitems[] = array(
256
+			'title'       => __('Venue List', 'event_espresso'),
257
+			'url'         => get_post_type_archive_link('espresso_venues'),
258
+			'description' => __('Archive page for all venues.', 'event_espresso'),
259
+		);
260
+		return $menuitems;
261
+	}
262
+
263
+
264
+
265
+	/**
266
+	 * Adds the payment methods in {event-espresso-core}/caffeinated/payment_methods
267
+	 *
268
+	 * @param array $payment_method_paths
269
+	 * @return array values are folder paths to payment method folders
270
+	 */
271
+	public function caf_payment_methods($payment_method_paths)
272
+	{
273
+		$caf_payment_methods_paths = glob(EE_CAF_PAYMENT_METHODS . '*', GLOB_ONLYDIR);
274
+		$payment_method_paths = array_merge($payment_method_paths, $caf_payment_methods_paths);
275
+		return $payment_method_paths;
276
+	}
277
+
278
+
279
+
280
+	/**
281
+	 * Gets the injected table analyzer, or throws an exception
282
+	 *
283
+	 * @return TableAnalysis
284
+	 * @throws \EE_Error
285
+	 */
286
+	protected function _get_table_analysis()
287
+	{
288
+		if ($this->_table_analysis instanceof TableAnalysis) {
289
+			return $this->_table_analysis;
290
+		} else {
291
+			throw new \EE_Error(
292
+				sprintf(
293
+					__('Table analysis class on class %1$s is not set properly.', 'event_espresso'),
294
+					get_class($this)
295
+				)
296
+			);
297
+		}
298
+	}
299 299
 }
300 300
 
301 301
 
302 302
 
303 303
 $brewing = new EE_Brewing_Regular(
304
-    EE_Registry::instance()->create('TableAnalysis', array(), true)
304
+	EE_Registry::instance()->create('TableAnalysis', array(), true)
305 305
 );
306 306
\ No newline at end of file
Please login to merge, or discard this patch.
core/EE_Request_Handler.core.php 1 patch
Spacing   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php use EventEspresso\core\interfaces\InterminableInterface;
2 2
 
3
-if ( ! defined( 'EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');}
3
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); }
4 4
 /**
5 5
  * class EE_Request_Handler
6 6
  *
@@ -51,13 +51,13 @@  discard block
 block discarded – undo
51 51
 	 * @access public
52 52
 	 * @param  EE_Request $request
53 53
 	 */
54
-	public function __construct( EE_Request $request ) {
54
+	public function __construct(EE_Request $request) {
55 55
 		// grab request vars
56 56
 		$this->_params = $request->params();
57 57
 		// AJAX ???
58
-		$this->ajax = defined( 'DOING_AJAX' ) && DOING_AJAX ? true : false;
59
-		$this->front_ajax = defined( 'EE_FRONT_AJAX' ) && EE_FRONT_AJAX ? true : false;
60
-		do_action( 'AHEE__EE_Request_Handler__construct__complete' );
58
+		$this->ajax = defined('DOING_AJAX') && DOING_AJAX ? true : false;
59
+		$this->front_ajax = defined('EE_FRONT_AJAX') && EE_FRONT_AJAX ? true : false;
60
+		do_action('AHEE__EE_Request_Handler__construct__complete');
61 61
 	}
62 62
 
63 63
 
@@ -69,12 +69,12 @@  discard block
 block discarded – undo
69 69
 	 * @param WP $wp
70 70
 	 * @return void
71 71
 	 */
72
-	public function parse_request( $wp = null ) {
72
+	public function parse_request($wp = null) {
73 73
 		//if somebody forgot to provide us with WP, that's ok because its global
74
-		if ( ! $wp instanceof WP ) {
74
+		if ( ! $wp instanceof WP) {
75 75
 			global $wp;
76 76
 		}
77
-		$this->set_request_vars( $wp );
77
+		$this->set_request_vars($wp);
78 78
 	}
79 79
 
80 80
 
@@ -86,14 +86,14 @@  discard block
 block discarded – undo
86 86
 	 * @param WP $wp
87 87
 	 * @return void
88 88
 	 */
89
-	public function set_request_vars( $wp = null ) {
90
-		if ( ! is_admin() ) {
89
+	public function set_request_vars($wp = null) {
90
+		if ( ! is_admin()) {
91 91
 			// set request post_id
92
-			$this->set( 'post_id', $this->get_post_id_from_request( $wp ));
92
+			$this->set('post_id', $this->get_post_id_from_request($wp));
93 93
 			// set request post name
94
-			$this->set( 'post_name', $this->get_post_name_from_request( $wp ));
94
+			$this->set('post_name', $this->get_post_name_from_request($wp));
95 95
 			// set request post_type
96
-			$this->set( 'post_type', $this->get_post_type_from_request( $wp ));
96
+			$this->set('post_type', $this->get_post_type_from_request($wp));
97 97
 			// true or false ? is this page being used by EE ?
98 98
 			$this->set_espresso_page();
99 99
 		}
@@ -108,19 +108,19 @@  discard block
 block discarded – undo
108 108
 	 * @param WP $wp
109 109
 	 * @return int
110 110
 	 */
111
-	public function get_post_id_from_request( $wp = null ) {
112
-		if ( ! $wp instanceof WP ){
111
+	public function get_post_id_from_request($wp = null) {
112
+		if ( ! $wp instanceof WP) {
113 113
 			global $wp;
114 114
 		}
115 115
 		$post_id = null;
116
-		if ( isset( $wp->query_vars['p'] )) {
116
+		if (isset($wp->query_vars['p'])) {
117 117
 			$post_id = $wp->query_vars['p'];
118 118
 		}
119
-		if ( ! $post_id && isset( $wp->query_vars['page_id'] )) {
119
+		if ( ! $post_id && isset($wp->query_vars['page_id'])) {
120 120
 			$post_id = $wp->query_vars['page_id'];
121 121
 		}
122
-		if ( ! $post_id && isset( $wp->request ) && is_numeric( basename( $wp->request ))) {
123
-			$post_id = basename( $wp->request );
122
+		if ( ! $post_id && isset($wp->request) && is_numeric(basename($wp->request))) {
123
+			$post_id = basename($wp->request);
124 124
 		}
125 125
 		return $post_id;
126 126
 	}
@@ -134,35 +134,35 @@  discard block
 block discarded – undo
134 134
 	 * @param WP $wp
135 135
 	 * @return string
136 136
 	 */
137
-	public function get_post_name_from_request( $wp = null ) {
138
-		if ( ! $wp instanceof WP ){
137
+	public function get_post_name_from_request($wp = null) {
138
+		if ( ! $wp instanceof WP) {
139 139
 			global $wp;
140 140
 		}
141 141
 		$post_name = null;
142
-		if ( isset( $wp->query_vars['name'] ) && ! empty( $wp->query_vars['name'] )) {
142
+		if (isset($wp->query_vars['name']) && ! empty($wp->query_vars['name'])) {
143 143
 			$post_name = $wp->query_vars['name'];
144 144
 		}
145
-		if ( ! $post_name && isset( $wp->query_vars['pagename'] ) && ! empty( $wp->query_vars['pagename'] )) {
145
+		if ( ! $post_name && isset($wp->query_vars['pagename']) && ! empty($wp->query_vars['pagename'])) {
146 146
 			$post_name = $wp->query_vars['pagename'];
147 147
 		}
148
-		if ( ! $post_name && isset( $wp->request ) && ! empty( $wp->request )) {
149
-			$possible_post_name = basename( $wp->request );
150
-			if ( ! is_numeric( $possible_post_name )) {
148
+		if ( ! $post_name && isset($wp->request) && ! empty($wp->request)) {
149
+			$possible_post_name = basename($wp->request);
150
+			if ( ! is_numeric($possible_post_name)) {
151 151
 				/** @type WPDB $wpdb */
152 152
 				global $wpdb;
153 153
 				$SQL = "SELECT ID from {$wpdb->posts} WHERE post_status='publish' AND post_name=%s";
154
-				$possible_post_name = $wpdb->get_var( $wpdb->prepare( $SQL, $possible_post_name ));
155
-				if ( $possible_post_name ) {
154
+				$possible_post_name = $wpdb->get_var($wpdb->prepare($SQL, $possible_post_name));
155
+				if ($possible_post_name) {
156 156
 					$post_name = $possible_post_name;
157 157
 				}
158 158
 			}
159 159
 		}
160
-		if ( ! $post_name && $this->get( 'post_id' )) {
160
+		if ( ! $post_name && $this->get('post_id')) {
161 161
 			/** @type WPDB $wpdb */
162 162
 			global $wpdb;
163 163
 			$SQL = "SELECT post_name from {$wpdb->posts} WHERE post_status='publish' AND ID=%d";
164
-			$possible_post_name = $wpdb->get_var( $wpdb->prepare( $SQL, $this->get( 'post_id' )));
165
-			if( $possible_post_name ) {
164
+			$possible_post_name = $wpdb->get_var($wpdb->prepare($SQL, $this->get('post_id')));
165
+			if ($possible_post_name) {
166 166
 				$post_name = $possible_post_name;
167 167
 			}
168 168
 		}
@@ -178,11 +178,11 @@  discard block
 block discarded – undo
178 178
 	 * @param WP $wp
179 179
 	 * @return mixed
180 180
 	 */
181
-	public function get_post_type_from_request( $wp = null ) {
182
-		if ( ! $wp instanceof WP ){
181
+	public function get_post_type_from_request($wp = null) {
182
+		if ( ! $wp instanceof WP) {
183 183
 			global $wp;
184 184
 		}
185
-		return isset( $wp->query_vars['post_type'] ) ? $wp->query_vars['post_type'] : null;
185
+		return isset($wp->query_vars['post_type']) ? $wp->query_vars['post_type'] : null;
186 186
 	}
187 187
 
188 188
 
@@ -192,18 +192,18 @@  discard block
 block discarded – undo
192 192
 	 * @param  WP $wp
193 193
 	 * @return string
194 194
 	 */
195
-	public function get_current_page_permalink( $wp = null ) {
196
-		$post_id = $this->get_post_id_from_request( $wp );
197
-		if ( $post_id ) {
198
-			$current_page_permalink = get_permalink( $post_id );
195
+	public function get_current_page_permalink($wp = null) {
196
+		$post_id = $this->get_post_id_from_request($wp);
197
+		if ($post_id) {
198
+			$current_page_permalink = get_permalink($post_id);
199 199
 		} else {
200
-			if ( ! $wp instanceof WP ) {
200
+			if ( ! $wp instanceof WP) {
201 201
 				global $wp;
202 202
 			}
203
-			if ( $wp->request ) {
204
-				$current_page_permalink = site_url( $wp->request );
203
+			if ($wp->request) {
204
+				$current_page_permalink = site_url($wp->request);
205 205
 			} else {
206
-				$current_page_permalink = esc_url( site_url( $_SERVER[ 'REQUEST_URI' ] ) );
206
+				$current_page_permalink = esc_url(site_url($_SERVER['REQUEST_URI']));
207 207
 			}
208 208
 		}
209 209
 		return $current_page_permalink;
@@ -220,31 +220,31 @@  discard block
 block discarded – undo
220 220
 	public function test_for_espresso_page() {
221 221
 		global $wp;
222 222
 		/** @type EE_CPT_Strategy $EE_CPT_Strategy */
223
-		$EE_CPT_Strategy = EE_Registry::instance()->load_core( 'CPT_Strategy' );
223
+		$EE_CPT_Strategy = EE_Registry::instance()->load_core('CPT_Strategy');
224 224
 		$espresso_CPT_taxonomies = $EE_CPT_Strategy->get_CPT_taxonomies();
225
-		if ( is_array( $espresso_CPT_taxonomies ) ) {
226
-			foreach ( $espresso_CPT_taxonomies as $espresso_CPT_taxonomy =>$details ) {
227
-				if ( isset( $wp->query_vars, $wp->query_vars[ $espresso_CPT_taxonomy ] ) ) {
225
+		if (is_array($espresso_CPT_taxonomies)) {
226
+			foreach ($espresso_CPT_taxonomies as $espresso_CPT_taxonomy =>$details) {
227
+				if (isset($wp->query_vars, $wp->query_vars[$espresso_CPT_taxonomy])) {
228 228
 					return true;
229 229
 				}
230 230
 			}
231 231
 		}
232 232
 		// load espresso CPT endpoints
233 233
 		$espresso_CPT_endpoints = $EE_CPT_Strategy->get_CPT_endpoints();
234
-		$post_type_CPT_endpoints = array_flip( $espresso_CPT_endpoints );
235
-		$post_types = (array)$this->get( 'post_type' );
236
-		foreach ( $post_types as $post_type ) {
234
+		$post_type_CPT_endpoints = array_flip($espresso_CPT_endpoints);
235
+		$post_types = (array) $this->get('post_type');
236
+		foreach ($post_types as $post_type) {
237 237
 			// was a post name passed ?
238
-			if ( isset( $post_type_CPT_endpoints[ $post_type ] ) ) {
238
+			if (isset($post_type_CPT_endpoints[$post_type])) {
239 239
 				// kk we know this is an espresso page, but is it a specific post ?
240
-				if ( ! $this->get( 'post_name' ) ) {
240
+				if ( ! $this->get('post_name')) {
241 241
 					// there's no specific post name set, so maybe it's one of our endpoints like www.domain.com/events
242
-					$post_name = isset( $post_type_CPT_endpoints[ $this->get( 'post_type' ) ] )
243
-                        ? $post_type_CPT_endpoints[ $this->get( 'post_type' ) ]
242
+					$post_name = isset($post_type_CPT_endpoints[$this->get('post_type')])
243
+                        ? $post_type_CPT_endpoints[$this->get('post_type')]
244 244
                         : '';
245 245
 					// if the post type matches on of our then set the endpoint
246
-					if ( $post_name ) {
247
-						$this->set( 'post_name', $post_name );
246
+					if ($post_name) {
247
+						$this->set('post_name', $post_name);
248 248
 					}
249 249
 				}
250 250
 				return true;
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 	 * @param null|bool $value
263 263
 	 * @return    void
264 264
 	 */
265
-	public function set_espresso_page( $value = null ) {
265
+	public function set_espresso_page($value = null) {
266 266
         $this->_params['is_espresso_page'] = ! empty($value) ? $value : $this->test_for_espresso_page();
267 267
 	}
268 268
 
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 	 *  @return 	mixed
276 276
 	 */
277 277
 	public function is_espresso_page() {
278
-		return isset( $this->_params['is_espresso_page'] ) ? $this->_params['is_espresso_page'] : false;
278
+		return isset($this->_params['is_espresso_page']) ? $this->_params['is_espresso_page'] : false;
279 279
 	}
280 280
 
281 281
 
@@ -299,14 +299,14 @@  discard block
 block discarded – undo
299 299
 	 * @param bool $override_ee
300 300
 	 * @return    void
301 301
 	 */
302
-	public function set( $key, $value, $override_ee = false ) {
302
+	public function set($key, $value, $override_ee = false) {
303 303
 		// don't allow "ee" to be overwritten unless explicitly instructed to do so
304 304
 		if (
305 305
 			$key !== 'ee' ||
306
-			( $key === 'ee' && empty( $this->_params['ee'] ))
307
-			|| ( $key === 'ee' && ! empty( $this->_params['ee'] ) && $override_ee )
306
+			($key === 'ee' && empty($this->_params['ee']))
307
+			|| ($key === 'ee' && ! empty($this->_params['ee']) && $override_ee)
308 308
 		) {
309
-			$this->_params[ $key ] = $value;
309
+			$this->_params[$key] = $value;
310 310
 		}
311 311
 	}
312 312
 
@@ -320,8 +320,8 @@  discard block
 block discarded – undo
320 320
 	 * @param null $default
321 321
 	 * @return    mixed
322 322
 	 */
323
-	public function get( $key, $default = null ) {
324
-		return isset( $this->_params[ $key ] ) ? $this->_params[ $key ] : $default;
323
+	public function get($key, $default = null) {
324
+		return isset($this->_params[$key]) ? $this->_params[$key] : $default;
325 325
 	}
326 326
 
327 327
 
@@ -333,8 +333,8 @@  discard block
 block discarded – undo
333 333
 	 * @param $key
334 334
 	 * @return    boolean
335 335
 	 */
336
-	public function is_set( $key ) {
337
-		return isset( $this->_params[ $key ] ) ? true : false;
336
+	public function is_set($key) {
337
+		return isset($this->_params[$key]) ? true : false;
338 338
 	}
339 339
 
340 340
 
@@ -346,8 +346,8 @@  discard block
 block discarded – undo
346 346
 	 * @param $key
347 347
 	 * @return    void
348 348
 	 */
349
-	public function un_set( $key ) {
350
-		unset( $this->_params[ $key ] );
349
+	public function un_set($key) {
350
+		unset($this->_params[$key]);
351 351
 	}
352 352
 
353 353
 
@@ -360,8 +360,8 @@  discard block
 block discarded – undo
360 360
 	 * @param $value
361 361
 	 * @return    void
362 362
 	 */
363
-	public function set_notice( $key, $value ) {
364
-		$this->_notice[ $key ] = $value;
363
+	public function set_notice($key, $value) {
364
+		$this->_notice[$key] = $value;
365 365
 	}
366 366
 
367 367
 
@@ -373,8 +373,8 @@  discard block
 block discarded – undo
373 373
 	 * @param $key
374 374
 	 * @return    mixed
375 375
 	 */
376
-	public function get_notice( $key ) {
377
-		return isset( $this->_notice[ $key ] ) ? $this->_notice[ $key ] : null;
376
+	public function get_notice($key) {
377
+		return isset($this->_notice[$key]) ? $this->_notice[$key] : null;
378 378
 	}
379 379
 
380 380
 
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
 	 * @param $string
387 387
 	 * @return    void
388 388
 	 */
389
-	public function add_output( $string ) {
389
+	public function add_output($string) {
390 390
 		$this->_output .= $string;
391 391
 	}
392 392
 
@@ -408,8 +408,8 @@  discard block
 block discarded – undo
408 408
 	 * @param $item
409 409
 	 * @param $key
410 410
 	 */
411
-	public function sanitize_text_field_for_array_walk( &$item, &$key ) {
412
-		$item = strpos( $item, 'email' ) !== false ? sanitize_email( $item ) : sanitize_text_field( $item );
411
+	public function sanitize_text_field_for_array_walk(&$item, &$key) {
412
+		$item = strpos($item, 'email') !== false ? sanitize_email($item) : sanitize_text_field($item);
413 413
 	}
414 414
 
415 415
 
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
 	 * @param $b
420 420
 	 * @return bool
421 421
 	 */
422
-	public function __set($a,$b) { return false; }
422
+	public function __set($a, $b) { return false; }
423 423
 
424 424
 
425 425
 
Please login to merge, or discard this patch.
core/EE_Config.core.php 1 patch
Indentation   +3061 added lines, -3061 removed lines patch added patch discarded remove patch
@@ -17,2443 +17,2443 @@  discard block
 block discarded – undo
17 17
 final class EE_Config implements ResettableInterface
18 18
 {
19 19
 
20
-    const OPTION_NAME        = 'ee_config';
20
+	const OPTION_NAME        = 'ee_config';
21
+
22
+	const LOG_NAME           = 'ee_config_log';
23
+
24
+	const LOG_LENGTH         = 100;
25
+
26
+	const ADDON_OPTION_NAMES = 'ee_config_option_names';
27
+
28
+
29
+	/**
30
+	 *    instance of the EE_Config object
31
+	 *
32
+	 * @var    EE_Config $_instance
33
+	 * @access    private
34
+	 */
35
+	private static $_instance;
36
+
37
+	/**
38
+	 * @var boolean $_logging_enabled
39
+	 */
40
+	private static $_logging_enabled = false;
41
+
42
+	/**
43
+	 * @var LegacyShortcodesManager $legacy_shortcodes_manager
44
+	 */
45
+	private $legacy_shortcodes_manager;
46
+
47
+	/**
48
+	 * An StdClass whose property names are addon slugs,
49
+	 * and values are their config classes
50
+	 *
51
+	 * @var StdClass
52
+	 */
53
+	public $addons;
54
+
55
+	/**
56
+	 * @var EE_Admin_Config
57
+	 */
58
+	public $admin;
59
+
60
+	/**
61
+	 * @var EE_Core_Config
62
+	 */
63
+	public $core;
64
+
65
+	/**
66
+	 * @var EE_Currency_Config
67
+	 */
68
+	public $currency;
69
+
70
+	/**
71
+	 * @var EE_Organization_Config
72
+	 */
73
+	public $organization;
74
+
75
+	/**
76
+	 * @var EE_Registration_Config
77
+	 */
78
+	public $registration;
79
+
80
+	/**
81
+	 * @var EE_Template_Config
82
+	 */
83
+	public $template_settings;
84
+
85
+	/**
86
+	 * Holds EE environment values.
87
+	 *
88
+	 * @var EE_Environment_Config
89
+	 */
90
+	public $environment;
91
+
92
+	/**
93
+	 * settings pertaining to Google maps
94
+	 *
95
+	 * @var EE_Map_Config
96
+	 */
97
+	public $map_settings;
98
+
99
+	/**
100
+	 * settings pertaining to Taxes
101
+	 *
102
+	 * @var EE_Tax_Config
103
+	 */
104
+	public $tax_settings;
105
+
106
+
107
+	/**
108
+	 * Settings pertaining to global messages settings.
109
+	 *
110
+	 * @var EE_Messages_Config
111
+	 */
112
+	public $messages;
113
+
114
+	/**
115
+	 * @deprecated
116
+	 * @var EE_Gateway_Config
117
+	 */
118
+	public $gateway;
119
+
120
+	/**
121
+	 * @var    array $_addon_option_names
122
+	 * @access    private
123
+	 */
124
+	private $_addon_option_names = array();
125
+
126
+	/**
127
+	 * @var    array $_module_route_map
128
+	 * @access    private
129
+	 */
130
+	private static $_module_route_map = array();
131
+
132
+	/**
133
+	 * @var    array $_module_forward_map
134
+	 * @access    private
135
+	 */
136
+	private static $_module_forward_map = array();
137
+
138
+	/**
139
+	 * @var    array $_module_view_map
140
+	 * @access    private
141
+	 */
142
+	private static $_module_view_map = array();
143
+
144
+
145
+
146
+	/**
147
+	 * @singleton method used to instantiate class object
148
+	 * @access    public
149
+	 * @return EE_Config instance
150
+	 */
151
+	public static function instance()
152
+	{
153
+		// check if class object is instantiated, and instantiated properly
154
+		if (! self::$_instance instanceof EE_Config) {
155
+			self::$_instance = new self();
156
+		}
157
+		return self::$_instance;
158
+	}
159
+
160
+
161
+
162
+	/**
163
+	 * Resets the config
164
+	 *
165
+	 * @param bool    $hard_reset    if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE
166
+	 *                               (default) leaves the database alone, and merely resets the EE_Config object to
167
+	 *                               reflect its state in the database
168
+	 * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave
169
+	 *                               $_instance as NULL. Useful in case you want to forget about the old instance on
170
+	 *                               EE_Config, but might not be ready to instantiate EE_Config currently (eg if the
171
+	 *                               site was put into maintenance mode)
172
+	 * @return EE_Config
173
+	 */
174
+	public static function reset($hard_reset = false, $reinstantiate = true)
175
+	{
176
+		if (self::$_instance instanceof EE_Config) {
177
+			if ($hard_reset) {
178
+				self::$_instance->legacy_shortcodes_manager = null;
179
+				self::$_instance->_addon_option_names = array();
180
+				self::$_instance->_initialize_config();
181
+				self::$_instance->update_espresso_config();
182
+			}
183
+			self::$_instance->update_addon_option_names();
184
+		}
185
+		self::$_instance = null;
186
+		//we don't need to reset the static properties imo because those should
187
+		//only change when a module is added or removed. Currently we don't
188
+		//support removing a module during a request when it previously existed
189
+		if ($reinstantiate) {
190
+			return self::instance();
191
+		} else {
192
+			return null;
193
+		}
194
+	}
195
+
196
+
197
+
198
+	/**
199
+	 *    class constructor
200
+	 *
201
+	 * @access    private
202
+	 */
203
+	private function __construct()
204
+	{
205
+		do_action('AHEE__EE_Config__construct__begin', $this);
206
+		EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false);
207
+		// setup empty config classes
208
+		$this->_initialize_config();
209
+		// load existing EE site settings
210
+		$this->_load_core_config();
211
+		// confirm everything loaded correctly and set filtered defaults if not
212
+		$this->_verify_config();
213
+		//  register shortcodes and modules
214
+		add_action(
215
+			'AHEE__EE_System__register_shortcodes_modules_and_widgets',
216
+			array($this, 'register_shortcodes_and_modules'),
217
+			999
218
+		);
219
+		//  initialize shortcodes and modules
220
+		add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules'));
221
+		// register widgets
222
+		add_action('widgets_init', array($this, 'widgets_init'), 10);
223
+		// shutdown
224
+		add_action('shutdown', array($this, 'shutdown'), 10);
225
+		// construct__end hook
226
+		do_action('AHEE__EE_Config__construct__end', $this);
227
+		// hardcoded hack
228
+		$this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014';
229
+	}
230
+
231
+
232
+
233
+	/**
234
+	 * @return boolean
235
+	 */
236
+	public static function logging_enabled()
237
+	{
238
+		return self::$_logging_enabled;
239
+	}
240
+
241
+
242
+
243
+	/**
244
+	 * use to get the current theme if needed from static context
245
+	 *
246
+	 * @return string current theme set.
247
+	 */
248
+	public static function get_current_theme()
249
+	{
250
+		return isset(self::$_instance->template_settings->current_espresso_theme)
251
+			? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014';
252
+	}
253
+
254
+
255
+
256
+	/**
257
+	 *        _initialize_config
258
+	 *
259
+	 * @access private
260
+	 * @return void
261
+	 */
262
+	private function _initialize_config()
263
+	{
264
+		EE_Config::trim_log();
265
+		//set defaults
266
+		$this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array());
267
+		$this->addons = new stdClass();
268
+		// set _module_route_map
269
+		EE_Config::$_module_route_map = array();
270
+		// set _module_forward_map
271
+		EE_Config::$_module_forward_map = array();
272
+		// set _module_view_map
273
+		EE_Config::$_module_view_map = array();
274
+	}
275
+
276
+
277
+
278
+	/**
279
+	 *        load core plugin configuration
280
+	 *
281
+	 * @access private
282
+	 * @return void
283
+	 */
284
+	private function _load_core_config()
285
+	{
286
+		// load_core_config__start hook
287
+		do_action('AHEE__EE_Config___load_core_config__start', $this);
288
+		$espresso_config = $this->get_espresso_config();
289
+		foreach ($espresso_config as $config => $settings) {
290
+			// load_core_config__start hook
291
+			$settings = apply_filters(
292
+				'FHEE__EE_Config___load_core_config__config_settings',
293
+				$settings,
294
+				$config,
295
+				$this
296
+			);
297
+			if (is_object($settings) && property_exists($this, $config)) {
298
+				$this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings);
299
+				//call configs populate method to ensure any defaults are set for empty values.
300
+				if (method_exists($settings, 'populate')) {
301
+					$this->{$config}->populate();
302
+				}
303
+				if (method_exists($settings, 'do_hooks')) {
304
+					$this->{$config}->do_hooks();
305
+				}
306
+			}
307
+		}
308
+		if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) {
309
+			$this->update_espresso_config();
310
+		}
311
+		// load_core_config__end hook
312
+		do_action('AHEE__EE_Config___load_core_config__end', $this);
313
+	}
314
+
315
+
316
+
317
+	/**
318
+	 *    _verify_config
319
+	 *
320
+	 * @access    protected
321
+	 * @return    void
322
+	 */
323
+	protected function _verify_config()
324
+	{
325
+		$this->core = $this->core instanceof EE_Core_Config
326
+			? $this->core
327
+			: new EE_Core_Config();
328
+		$this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core);
329
+		$this->organization = $this->organization instanceof EE_Organization_Config
330
+			? $this->organization
331
+			: new EE_Organization_Config();
332
+		$this->organization = apply_filters(
333
+			'FHEE__EE_Config___initialize_config__organization',
334
+			$this->organization
335
+		);
336
+		$this->currency = $this->currency instanceof EE_Currency_Config
337
+			? $this->currency
338
+			: new EE_Currency_Config();
339
+		$this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency);
340
+		$this->registration = $this->registration instanceof EE_Registration_Config
341
+			? $this->registration
342
+			: new EE_Registration_Config();
343
+		$this->registration = apply_filters(
344
+			'FHEE__EE_Config___initialize_config__registration',
345
+			$this->registration
346
+		);
347
+		$this->admin = $this->admin instanceof EE_Admin_Config
348
+			? $this->admin
349
+			: new EE_Admin_Config();
350
+		$this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin);
351
+		$this->template_settings = $this->template_settings instanceof EE_Template_Config
352
+			? $this->template_settings
353
+			: new EE_Template_Config();
354
+		$this->template_settings = apply_filters(
355
+			'FHEE__EE_Config___initialize_config__template_settings',
356
+			$this->template_settings
357
+		);
358
+		$this->map_settings = $this->map_settings instanceof EE_Map_Config
359
+			? $this->map_settings
360
+			: new EE_Map_Config();
361
+		$this->map_settings = apply_filters('FHEE__EE_Config___initialize_config__map_settings',
362
+			$this->map_settings);
363
+		$this->environment = $this->environment instanceof EE_Environment_Config
364
+			? $this->environment
365
+			: new EE_Environment_Config();
366
+		$this->environment = apply_filters('FHEE__EE_Config___initialize_config__environment',
367
+			$this->environment);
368
+		$this->tax_settings = $this->tax_settings instanceof EE_Tax_Config
369
+			? $this->tax_settings
370
+			: new EE_Tax_Config();
371
+		$this->tax_settings = apply_filters('FHEE__EE_Config___initialize_config__tax_settings',
372
+			$this->tax_settings);
373
+		$this->messages = apply_filters('FHEE__EE_Config__initialize_config__messages', $this->messages);
374
+		$this->messages = $this->messages instanceof EE_Messages_Config
375
+			? $this->messages
376
+			: new EE_Messages_Config();
377
+		$this->gateway = $this->gateway instanceof EE_Gateway_Config
378
+			? $this->gateway
379
+			: new EE_Gateway_Config();
380
+		$this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway);
381
+		$this->legacy_shortcodes_manager = null;
382
+	}
383
+
384
+
385
+	/**
386
+	 *    get_espresso_config
387
+	 *
388
+	 * @access    public
389
+	 * @return    array of espresso config stuff
390
+	 */
391
+	public function get_espresso_config()
392
+	{
393
+		// grab espresso configuration
394
+		return apply_filters(
395
+			'FHEE__EE_Config__get_espresso_config__CFG',
396
+			get_option(EE_Config::OPTION_NAME, array())
397
+		);
398
+	}
399
+
400
+
401
+
402
+	/**
403
+	 *    double_check_config_comparison
404
+	 *
405
+	 * @access    public
406
+	 * @param string $option
407
+	 * @param        $old_value
408
+	 * @param        $value
409
+	 */
410
+	public function double_check_config_comparison($option = '', $old_value, $value)
411
+	{
412
+		// make sure we're checking the ee config
413
+		if ($option === EE_Config::OPTION_NAME) {
414
+			// run a loose comparison of the old value against the new value for type and properties,
415
+			// but NOT exact instance like WP update_option does (ie: NOT type safe comparison)
416
+			if ($value != $old_value) {
417
+				// if they are NOT the same, then remove the hook,
418
+				// which means the subsequent update results will be based solely on the update query results
419
+				// the reason we do this is because, as stated above,
420
+				// WP update_option performs an exact instance comparison (===) on any update values passed to it
421
+				// this happens PRIOR to serialization and any subsequent update.
422
+				// If values are found to match their previous old value,
423
+				// then WP bails before performing any update.
424
+				// Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version
425
+				// it just pulled from the db, with the one being passed to it (which will not match).
426
+				// HOWEVER, once the object is serialized and passed off to MySQL to update,
427
+				// MySQL MAY ALSO NOT perform the update because
428
+				// the string it sees in the db looks the same as the new one it has been passed!!!
429
+				// This results in the query returning an "affected rows" value of ZERO,
430
+				// which gets returned immediately by WP update_option and looks like an error.
431
+				remove_action('update_option', array($this, 'check_config_updated'));
432
+			}
433
+		}
434
+	}
435
+
436
+
437
+
438
+	/**
439
+	 *    update_espresso_config
440
+	 *
441
+	 * @access   public
442
+	 */
443
+	protected function _reset_espresso_addon_config()
444
+	{
445
+		$this->_addon_option_names = array();
446
+		foreach ($this->addons as $addon_name => $addon_config_obj) {
447
+			$addon_config_obj = maybe_unserialize($addon_config_obj);
448
+			$config_class = get_class($addon_config_obj);
449
+			if ($addon_config_obj instanceof $config_class && ! $addon_config_obj instanceof __PHP_Incomplete_Class) {
450
+				$this->update_config('addons', $addon_name, $addon_config_obj, false);
451
+			}
452
+			$this->addons->{$addon_name} = null;
453
+		}
454
+	}
455
+
456
+
457
+
458
+	/**
459
+	 *    update_espresso_config
460
+	 *
461
+	 * @access   public
462
+	 * @param   bool $add_success
463
+	 * @param   bool $add_error
464
+	 * @return   bool
465
+	 */
466
+	public function update_espresso_config($add_success = false, $add_error = true)
467
+	{
468
+		// don't allow config updates during WP heartbeats
469
+		if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
470
+			return false;
471
+		}
472
+		// commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197
473
+		//$clone = clone( self::$_instance );
474
+		//self::$_instance = NULL;
475
+		do_action('AHEE__EE_Config__update_espresso_config__begin', $this);
476
+		$this->_reset_espresso_addon_config();
477
+		// hook into update_option because that happens AFTER the ( $value === $old_value ) conditional
478
+		// but BEFORE the actual update occurs
479
+		add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3);
480
+		// don't want to persist legacy_shortcodes_manager, but don't want to lose it either
481
+		$legacy_shortcodes_manager = $this->legacy_shortcodes_manager;
482
+		$this->legacy_shortcodes_manager = null;
483
+		// now update "ee_config"
484
+		$saved = update_option(EE_Config::OPTION_NAME, $this);
485
+		$this->legacy_shortcodes_manager = $legacy_shortcodes_manager;
486
+		EE_Config::log(EE_Config::OPTION_NAME);
487
+		// if not saved... check if the hook we just added still exists;
488
+		// if it does, it means one of two things:
489
+		// 		that update_option bailed at the ( $value === $old_value ) conditional,
490
+		//		 or...
491
+		// 		the db update query returned 0 rows affected
492
+		// 		(probably because the data  value was the same from it's perspective)
493
+		// so the existence of the hook means that a negative result from update_option is NOT an error,
494
+		// but just means no update occurred, so don't display an error to the user.
495
+		// BUT... if update_option returns FALSE, AND the hook is missing,
496
+		// then it means that something truly went wrong
497
+		$saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved;
498
+		// remove our action since we don't want it in the system anymore
499
+		remove_action('update_option', array($this, 'double_check_config_comparison'), 1);
500
+		do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved);
501
+		//self::$_instance = $clone;
502
+		//unset( $clone );
503
+		// if config remains the same or was updated successfully
504
+		if ($saved) {
505
+			if ($add_success) {
506
+				EE_Error::add_success(
507
+					__('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'),
508
+					__FILE__,
509
+					__FUNCTION__,
510
+					__LINE__
511
+				);
512
+			}
513
+			return true;
514
+		} else {
515
+			if ($add_error) {
516
+				EE_Error::add_error(
517
+					__('The Event Espresso Configuration Settings were not updated.', 'event_espresso'),
518
+					__FILE__,
519
+					__FUNCTION__,
520
+					__LINE__
521
+				);
522
+			}
523
+			return false;
524
+		}
525
+	}
526
+
527
+
528
+
529
+	/**
530
+	 *    _verify_config_params
531
+	 *
532
+	 * @access    private
533
+	 * @param    string         $section
534
+	 * @param    string         $name
535
+	 * @param    string         $config_class
536
+	 * @param    EE_Config_Base $config_obj
537
+	 * @param    array          $tests_to_run
538
+	 * @param    bool           $display_errors
539
+	 * @return    bool    TRUE on success, FALSE on fail
540
+	 */
541
+	private function _verify_config_params(
542
+		$section = '',
543
+		$name = '',
544
+		$config_class = '',
545
+		$config_obj = null,
546
+		$tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8),
547
+		$display_errors = true
548
+	) {
549
+		try {
550
+			foreach ($tests_to_run as $test) {
551
+				switch ($test) {
552
+					// TEST #1 : check that section was set
553
+					case 1 :
554
+						if (empty($section)) {
555
+							if ($display_errors) {
556
+								throw new EE_Error(
557
+									sprintf(
558
+										__(
559
+											'No configuration section has been provided while attempting to save "%s".',
560
+											'event_espresso'
561
+										),
562
+										$config_class
563
+									)
564
+								);
565
+							}
566
+							return false;
567
+						}
568
+						break;
569
+					// TEST #2 : check that settings section exists
570
+					case 2 :
571
+						if (! isset($this->{$section})) {
572
+							if ($display_errors) {
573
+								throw new EE_Error(
574
+									sprintf(
575
+										__('The "%s" configuration section does not exist.', 'event_espresso'),
576
+										$section
577
+									)
578
+								);
579
+							}
580
+							return false;
581
+						}
582
+						break;
583
+					// TEST #3 : check that section is the proper format
584
+					case 3 :
585
+						if (
586
+						! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass)
587
+						) {
588
+							if ($display_errors) {
589
+								throw new EE_Error(
590
+									sprintf(
591
+										__(
592
+											'The "%s" configuration settings have not been formatted correctly.',
593
+											'event_espresso'
594
+										),
595
+										$section
596
+									)
597
+								);
598
+							}
599
+							return false;
600
+						}
601
+						break;
602
+					// TEST #4 : check that config section name has been set
603
+					case 4 :
604
+						if (empty($name)) {
605
+							if ($display_errors) {
606
+								throw new EE_Error(
607
+									__(
608
+										'No name has been provided for the specific configuration section.',
609
+										'event_espresso'
610
+									)
611
+								);
612
+							}
613
+							return false;
614
+						}
615
+						break;
616
+					// TEST #5 : check that a config class name has been set
617
+					case 5 :
618
+						if (empty($config_class)) {
619
+							if ($display_errors) {
620
+								throw new EE_Error(
621
+									__(
622
+										'No class name has been provided for the specific configuration section.',
623
+										'event_espresso'
624
+									)
625
+								);
626
+							}
627
+							return false;
628
+						}
629
+						break;
630
+					// TEST #6 : verify config class is accessible
631
+					case 6 :
632
+						if (! class_exists($config_class)) {
633
+							if ($display_errors) {
634
+								throw new EE_Error(
635
+									sprintf(
636
+										__(
637
+											'The "%s" class does not exist. Please ensure that an autoloader has been set for it.',
638
+											'event_espresso'
639
+										),
640
+										$config_class
641
+									)
642
+								);
643
+							}
644
+							return false;
645
+						}
646
+						break;
647
+					// TEST #7 : check that config has even been set
648
+					case 7 :
649
+						if (! isset($this->{$section}->{$name})) {
650
+							if ($display_errors) {
651
+								throw new EE_Error(
652
+									sprintf(
653
+										__('No configuration has been set for "%1$s->%2$s".', 'event_espresso'),
654
+										$section,
655
+										$name
656
+									)
657
+								);
658
+							}
659
+							return false;
660
+						} else {
661
+							// and make sure it's not serialized
662
+							$this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name});
663
+						}
664
+						break;
665
+					// TEST #8 : check that config is the requested type
666
+					case 8 :
667
+						if (! $this->{$section}->{$name} instanceof $config_class) {
668
+							if ($display_errors) {
669
+								throw new EE_Error(
670
+									sprintf(
671
+										__(
672
+											'The configuration for "%1$s->%2$s" is not of the "%3$s" class.',
673
+											'event_espresso'
674
+										),
675
+										$section,
676
+										$name,
677
+										$config_class
678
+									)
679
+								);
680
+							}
681
+							return false;
682
+						}
683
+						break;
684
+					// TEST #9 : verify config object
685
+					case 9 :
686
+						if (! $config_obj instanceof EE_Config_Base) {
687
+							if ($display_errors) {
688
+								throw new EE_Error(
689
+									sprintf(
690
+										__('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'),
691
+										print_r($config_obj, true)
692
+									)
693
+								);
694
+							}
695
+							return false;
696
+						}
697
+						break;
698
+				}
699
+			}
700
+		} catch (EE_Error $e) {
701
+			$e->get_error();
702
+		}
703
+		// you have successfully run the gauntlet
704
+		return true;
705
+	}
706
+
707
+
708
+
709
+	/**
710
+	 *    _generate_config_option_name
711
+	 *
712
+	 * @access        protected
713
+	 * @param        string $section
714
+	 * @param        string $name
715
+	 * @return        string
716
+	 */
717
+	private function _generate_config_option_name($section = '', $name = '')
718
+	{
719
+		return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name));
720
+	}
721
+
722
+
723
+
724
+	/**
725
+	 *    _set_config_class
726
+	 * ensures that a config class is set, either from a passed config class or one generated from the config name
727
+	 *
728
+	 * @access    private
729
+	 * @param    string $config_class
730
+	 * @param    string $name
731
+	 * @return    string
732
+	 */
733
+	private function _set_config_class($config_class = '', $name = '')
734
+	{
735
+		return ! empty($config_class)
736
+			? $config_class
737
+			: str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config';
738
+	}
739
+
740
+
741
+
742
+	/**
743
+	 *    set_config
744
+	 *
745
+	 * @access    protected
746
+	 * @param    string         $section
747
+	 * @param    string         $name
748
+	 * @param    string         $config_class
749
+	 * @param    EE_Config_Base $config_obj
750
+	 * @return    EE_Config_Base
751
+	 */
752
+	public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null)
753
+	{
754
+		// ensure config class is set to something
755
+		$config_class = $this->_set_config_class($config_class, $name);
756
+		// run tests 1-4, 6, and 7 to verify all config params are set and valid
757
+		if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
758
+			return null;
759
+		}
760
+		$config_option_name = $this->_generate_config_option_name($section, $name);
761
+		// if the config option name hasn't been added yet to the list of option names we're tracking, then do so now
762
+		if (! isset($this->_addon_option_names[$config_option_name])) {
763
+			$this->_addon_option_names[$config_option_name] = $config_class;
764
+			$this->update_addon_option_names();
765
+		}
766
+		// verify the incoming config object but suppress errors
767
+		if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
768
+			$config_obj = new $config_class();
769
+		}
770
+		if (get_option($config_option_name)) {
771
+			EE_Config::log($config_option_name);
772
+			update_option($config_option_name, $config_obj);
773
+			$this->{$section}->{$name} = $config_obj;
774
+			return $this->{$section}->{$name};
775
+		} else {
776
+			// create a wp-option for this config
777
+			if (add_option($config_option_name, $config_obj, '', 'no')) {
778
+				$this->{$section}->{$name} = maybe_unserialize($config_obj);
779
+				return $this->{$section}->{$name};
780
+			} else {
781
+				EE_Error::add_error(
782
+					sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class),
783
+					__FILE__,
784
+					__FUNCTION__,
785
+					__LINE__
786
+				);
787
+				return null;
788
+			}
789
+		}
790
+	}
791
+
792
+
793
+
794
+	/**
795
+	 *    update_config
796
+	 * Important: the config object must ALREADY be set, otherwise this will produce an error.
797
+	 *
798
+	 * @access    public
799
+	 * @param    string                $section
800
+	 * @param    string                $name
801
+	 * @param    EE_Config_Base|string $config_obj
802
+	 * @param    bool                  $throw_errors
803
+	 * @return    bool
804
+	 */
805
+	public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true)
806
+	{
807
+		// don't allow config updates during WP heartbeats
808
+		if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
809
+			return false;
810
+		}
811
+		$config_obj = maybe_unserialize($config_obj);
812
+		// get class name of the incoming object
813
+		$config_class = get_class($config_obj);
814
+		// run tests 1-5 and 9 to verify config
815
+		if (! $this->_verify_config_params(
816
+			$section,
817
+			$name,
818
+			$config_class,
819
+			$config_obj,
820
+			array(1, 2, 3, 4, 7, 9)
821
+		)
822
+		) {
823
+			return false;
824
+		}
825
+		$config_option_name = $this->_generate_config_option_name($section, $name);
826
+		// check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
827
+		if (! isset($this->_addon_option_names[$config_option_name])) {
828
+			// save new config to db
829
+			if ($this->set_config($section, $name, $config_class, $config_obj)) {
830
+				return true;
831
+			}
832
+		} else {
833
+			// first check if the record already exists
834
+			$existing_config = get_option($config_option_name);
835
+			$config_obj = serialize($config_obj);
836
+			// just return if db record is already up to date (NOT type safe comparison)
837
+			if ($existing_config == $config_obj) {
838
+				$this->{$section}->{$name} = $config_obj;
839
+				return true;
840
+			} else if (update_option($config_option_name, $config_obj)) {
841
+				EE_Config::log($config_option_name);
842
+				// update wp-option for this config class
843
+				$this->{$section}->{$name} = $config_obj;
844
+				return true;
845
+			} elseif ($throw_errors) {
846
+				EE_Error::add_error(
847
+					sprintf(
848
+						__(
849
+							'The "%1$s" object stored at"%2$s" was not successfully updated in the database.',
850
+							'event_espresso'
851
+						),
852
+						$config_class,
853
+						'EE_Config->' . $section . '->' . $name
854
+					),
855
+					__FILE__,
856
+					__FUNCTION__,
857
+					__LINE__
858
+				);
859
+			}
860
+		}
861
+		return false;
862
+	}
863
+
864
+
865
+
866
+	/**
867
+	 *    get_config
868
+	 *
869
+	 * @access    public
870
+	 * @param    string $section
871
+	 * @param    string $name
872
+	 * @param    string $config_class
873
+	 * @return    mixed EE_Config_Base | NULL
874
+	 */
875
+	public function get_config($section = '', $name = '', $config_class = '')
876
+	{
877
+		// ensure config class is set to something
878
+		$config_class = $this->_set_config_class($config_class, $name);
879
+		// run tests 1-4, 6 and 7 to verify that all params have been set
880
+		if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
881
+			return null;
882
+		}
883
+		// now test if the requested config object exists, but suppress errors
884
+		if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) {
885
+			// config already exists, so pass it back
886
+			return $this->{$section}->{$name};
887
+		}
888
+		// load config option from db if it exists
889
+		$config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name));
890
+		// verify the newly retrieved config object, but suppress errors
891
+		if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
892
+			// config is good, so set it and pass it back
893
+			$this->{$section}->{$name} = $config_obj;
894
+			return $this->{$section}->{$name};
895
+		}
896
+		// oops! $config_obj is not already set and does not exist in the db, so create a new one
897
+		$config_obj = $this->set_config($section, $name, $config_class);
898
+		// verify the newly created config object
899
+		if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) {
900
+			return $this->{$section}->{$name};
901
+		} else {
902
+			EE_Error::add_error(
903
+				sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class),
904
+				__FILE__,
905
+				__FUNCTION__,
906
+				__LINE__
907
+			);
908
+		}
909
+		return null;
910
+	}
911
+
912
+
913
+
914
+	/**
915
+	 *    get_config_option
916
+	 *
917
+	 * @access    public
918
+	 * @param    string $config_option_name
919
+	 * @return    mixed EE_Config_Base | FALSE
920
+	 */
921
+	public function get_config_option($config_option_name = '')
922
+	{
923
+		// retrieve the wp-option for this config class.
924
+		$config_option = maybe_unserialize(get_option($config_option_name, array()));
925
+		if (empty($config_option)) {
926
+			EE_Config::log($config_option_name . '-NOT-FOUND');
927
+		}
928
+		return $config_option;
929
+	}
930
+
931
+
932
+
933
+	/**
934
+	 * log
935
+	 *
936
+	 * @param string $config_option_name
937
+	 */
938
+	public static function log($config_option_name = '')
939
+	{
940
+		if (EE_Config::logging_enabled() && ! empty($config_option_name)) {
941
+			$config_log = get_option(EE_Config::LOG_NAME, array());
942
+			//copy incoming $_REQUEST and sanitize it so we can save it
943
+			$_request = $_REQUEST;
944
+			array_walk_recursive($_request, 'sanitize_text_field');
945
+			$config_log[(string)microtime(true)] = array(
946
+				'config_name' => $config_option_name,
947
+				'request'     => $_request,
948
+			);
949
+			update_option(EE_Config::LOG_NAME, $config_log);
950
+		}
951
+	}
952
+
953
+
954
+
955
+	/**
956
+	 * trim_log
957
+	 * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH
958
+	 */
959
+	public static function trim_log()
960
+	{
961
+		if (! EE_Config::logging_enabled()) {
962
+			return;
963
+		}
964
+		$config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
965
+		$log_length = count($config_log);
966
+		if ($log_length > EE_Config::LOG_LENGTH) {
967
+			ksort($config_log);
968
+			$config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true);
969
+			update_option(EE_Config::LOG_NAME, $config_log);
970
+		}
971
+	}
972
+
973
+
974
+
975
+	/**
976
+	 *    get_page_for_posts
977
+	 *    if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the
978
+	 *    wp-option "page_for_posts", or "posts" if no page is selected
979
+	 *
980
+	 * @access    public
981
+	 * @return    string
982
+	 */
983
+	public static function get_page_for_posts()
984
+	{
985
+		$page_for_posts = get_option('page_for_posts');
986
+		if (! $page_for_posts) {
987
+			return 'posts';
988
+		}
989
+		/** @type WPDB $wpdb */
990
+		global $wpdb;
991
+		$SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d";
992
+		return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts));
993
+	}
994
+
995
+
996
+
997
+	/**
998
+	 *    register_shortcodes_and_modules.
999
+	 *    At this point, it's too early to tell if we're maintenance mode or not.
1000
+	 *    In fact, this is where we give modules a chance to let core know they exist
1001
+	 *    so they can help trigger maintenance mode if it's needed
1002
+	 *
1003
+	 * @access    public
1004
+	 * @return    void
1005
+	 */
1006
+	public function register_shortcodes_and_modules()
1007
+	{
1008
+		// allow modules to set hooks for the rest of the system
1009
+		EE_Registry::instance()->modules = $this->_register_modules();
1010
+	}
1011
+
1012
+
1013
+
1014
+	/**
1015
+	 *    initialize_shortcodes_and_modules
1016
+	 *    meaning they can start adding their hooks to get stuff done
1017
+	 *
1018
+	 * @access    public
1019
+	 * @return    void
1020
+	 */
1021
+	public function initialize_shortcodes_and_modules()
1022
+	{
1023
+		// allow modules to set hooks for the rest of the system
1024
+		$this->_initialize_modules();
1025
+	}
1026
+
1027
+
1028
+
1029
+	/**
1030
+	 *    widgets_init
1031
+	 *
1032
+	 * @access private
1033
+	 * @return void
1034
+	 */
1035
+	public function widgets_init()
1036
+	{
1037
+		//only init widgets on admin pages when not in complete maintenance, and
1038
+		//on frontend when not in any maintenance mode
1039
+		if (
1040
+			! EE_Maintenance_Mode::instance()->level()
1041
+			|| (
1042
+				is_admin()
1043
+				&& EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance
1044
+			)
1045
+		) {
1046
+			// grab list of installed widgets
1047
+			$widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
1048
+			// filter list of modules to register
1049
+			$widgets_to_register = apply_filters(
1050
+				'FHEE__EE_Config__register_widgets__widgets_to_register',
1051
+				$widgets_to_register
1052
+			);
1053
+			if (! empty($widgets_to_register)) {
1054
+				// cycle thru widget folders
1055
+				foreach ($widgets_to_register as $widget_path) {
1056
+					// add to list of installed widget modules
1057
+					EE_Config::register_ee_widget($widget_path);
1058
+				}
1059
+			}
1060
+			// filter list of installed modules
1061
+			EE_Registry::instance()->widgets = apply_filters(
1062
+				'FHEE__EE_Config__register_widgets__installed_widgets',
1063
+				EE_Registry::instance()->widgets
1064
+			);
1065
+		}
1066
+	}
1067
+
1068
+
1069
+
1070
+	/**
1071
+	 *    register_ee_widget - makes core aware of this widget
1072
+	 *
1073
+	 * @access    public
1074
+	 * @param    string $widget_path - full path up to and including widget folder
1075
+	 * @return    void
1076
+	 */
1077
+	public static function register_ee_widget($widget_path = null)
1078
+	{
1079
+		do_action('AHEE__EE_Config__register_widget__begin', $widget_path);
1080
+		$widget_ext = '.widget.php';
1081
+		// make all separators match
1082
+		$widget_path = rtrim(str_replace('/\\', DS, $widget_path), DS);
1083
+		// does the file path INCLUDE the actual file name as part of the path ?
1084
+		if (strpos($widget_path, $widget_ext) !== false) {
1085
+			// grab and shortcode file name from directory name and break apart at dots
1086
+			$file_name = explode('.', basename($widget_path));
1087
+			// take first segment from file name pieces and remove class prefix if it exists
1088
+			$widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0];
1089
+			// sanitize shortcode directory name
1090
+			$widget = sanitize_key($widget);
1091
+			// now we need to rebuild the shortcode path
1092
+			$widget_path = explode(DS, $widget_path);
1093
+			// remove last segment
1094
+			array_pop($widget_path);
1095
+			// glue it back together
1096
+			$widget_path = implode(DS, $widget_path);
1097
+		} else {
1098
+			// grab and sanitize widget directory name
1099
+			$widget = sanitize_key(basename($widget_path));
1100
+		}
1101
+		// create classname from widget directory name
1102
+		$widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1103
+		// add class prefix
1104
+		$widget_class = 'EEW_' . $widget;
1105
+		// does the widget exist ?
1106
+		if (! is_readable($widget_path . DS . $widget_class . $widget_ext)) {
1107
+			$msg = sprintf(
1108
+				__(
1109
+					'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s',
1110
+					'event_espresso'
1111
+				),
1112
+				$widget_class,
1113
+				$widget_path . DS . $widget_class . $widget_ext
1114
+			);
1115
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1116
+			return;
1117
+		}
1118
+		// load the widget class file
1119
+		require_once($widget_path . DS . $widget_class . $widget_ext);
1120
+		// verify that class exists
1121
+		if (! class_exists($widget_class)) {
1122
+			$msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1123
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1124
+			return;
1125
+		}
1126
+		register_widget($widget_class);
1127
+		// add to array of registered widgets
1128
+		EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext;
1129
+	}
1130
+
1131
+
1132
+
1133
+	/**
1134
+	 *        _register_modules
1135
+	 *
1136
+	 * @access private
1137
+	 * @return array
1138
+	 */
1139
+	private function _register_modules()
1140
+	{
1141
+		// grab list of installed modules
1142
+		$modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1143
+		// filter list of modules to register
1144
+		$modules_to_register = apply_filters(
1145
+			'FHEE__EE_Config__register_modules__modules_to_register',
1146
+			$modules_to_register
1147
+		);
1148
+		if (! empty($modules_to_register)) {
1149
+			// loop through folders
1150
+			foreach ($modules_to_register as $module_path) {
1151
+				/**TEMPORARILY EXCLUDE gateways from modules for time being**/
1152
+				if (
1153
+					$module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1154
+					&& $module_path !== EE_MODULES . 'gateways'
1155
+				) {
1156
+					// add to list of installed modules
1157
+					EE_Config::register_module($module_path);
1158
+				}
1159
+			}
1160
+		}
1161
+		// filter list of installed modules
1162
+		return apply_filters(
1163
+			'FHEE__EE_Config___register_modules__installed_modules',
1164
+			EE_Registry::instance()->modules
1165
+		);
1166
+	}
1167
+
1168
+
1169
+
1170
+	/**
1171
+	 *    register_module - makes core aware of this module
1172
+	 *
1173
+	 * @access    public
1174
+	 * @param    string $module_path - full path up to and including module folder
1175
+	 * @return    bool
1176
+	 */
1177
+	public static function register_module($module_path = null)
1178
+	{
1179
+		do_action('AHEE__EE_Config__register_module__begin', $module_path);
1180
+		$module_ext = '.module.php';
1181
+		// make all separators match
1182
+		$module_path = str_replace(array('\\', '/'), DS, $module_path);
1183
+		// does the file path INCLUDE the actual file name as part of the path ?
1184
+		if (strpos($module_path, $module_ext) !== false) {
1185
+			// grab and shortcode file name from directory name and break apart at dots
1186
+			$module_file = explode('.', basename($module_path));
1187
+			// now we need to rebuild the shortcode path
1188
+			$module_path = explode(DS, $module_path);
1189
+			// remove last segment
1190
+			array_pop($module_path);
1191
+			// glue it back together
1192
+			$module_path = implode(DS, $module_path) . DS;
1193
+			// take first segment from file name pieces and sanitize it
1194
+			$module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1195
+			// ensure class prefix is added
1196
+			$module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1197
+		} else {
1198
+			// we need to generate the filename based off of the folder name
1199
+			// grab and sanitize module name
1200
+			$module = strtolower(basename($module_path));
1201
+			$module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1202
+			// like trailingslashit()
1203
+			$module_path = rtrim($module_path, DS) . DS;
1204
+			// create classname from module directory name
1205
+			$module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1206
+			// add class prefix
1207
+			$module_class = 'EED_' . $module;
1208
+		}
1209
+		// does the module exist ?
1210
+		if (! is_readable($module_path . DS . $module_class . $module_ext)) {
1211
+			$msg = sprintf(
1212
+				__(
1213
+					'The requested %s module file could not be found or is not readable due to file permissions.',
1214
+					'event_espresso'
1215
+				),
1216
+				$module
1217
+			);
1218
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1219
+			return false;
1220
+		}
1221
+		// load the module class file
1222
+		require_once($module_path . $module_class . $module_ext);
1223
+		// verify that class exists
1224
+		if (! class_exists($module_class)) {
1225
+			$msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1226
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1227
+			return false;
1228
+		}
1229
+		// add to array of registered modules
1230
+		EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1231
+		do_action(
1232
+			'AHEE__EE_Config__register_module__complete',
1233
+			$module_class,
1234
+			EE_Registry::instance()->modules->{$module_class}
1235
+		);
1236
+		return true;
1237
+	}
1238
+
1239
+
1240
+
1241
+	/**
1242
+	 *    _initialize_modules
1243
+	 *    allow modules to set hooks for the rest of the system
1244
+	 *
1245
+	 * @access private
1246
+	 * @return void
1247
+	 */
1248
+	private function _initialize_modules()
1249
+	{
1250
+		// cycle thru shortcode folders
1251
+		foreach (EE_Registry::instance()->modules as $module_class => $module_path) {
1252
+			// fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1253
+			// which set hooks ?
1254
+			if (is_admin()) {
1255
+				// fire immediately
1256
+				call_user_func(array($module_class, 'set_hooks_admin'));
1257
+			} else {
1258
+				// delay until other systems are online
1259
+				add_action(
1260
+					'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
1261
+					array($module_class, 'set_hooks')
1262
+				);
1263
+			}
1264
+		}
1265
+	}
1266
+
1267
+
1268
+
1269
+	/**
1270
+	 *    register_route - adds module method routes to route_map
1271
+	 *
1272
+	 * @access    public
1273
+	 * @param    string $route       - "pretty" public alias for module method
1274
+	 * @param    string $module      - module name (classname without EED_ prefix)
1275
+	 * @param    string $method_name - the actual module method to be routed to
1276
+	 * @param    string $key         - url param key indicating a route is being called
1277
+	 * @return    bool
1278
+	 */
1279
+	public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee')
1280
+	{
1281
+		do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1282
+		$module = str_replace('EED_', '', $module);
1283
+		$module_class = 'EED_' . $module;
1284
+		if (! isset(EE_Registry::instance()->modules->{$module_class})) {
1285
+			$msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module);
1286
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1287
+			return false;
1288
+		}
1289
+		if (empty($route)) {
1290
+			$msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route);
1291
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1292
+			return false;
1293
+		}
1294
+		if (! method_exists('EED_' . $module, $method_name)) {
1295
+			$msg = sprintf(
1296
+				__('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1297
+				$route
1298
+			);
1299
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1300
+			return false;
1301
+		}
1302
+		EE_Config::$_module_route_map[$key][$route] = array('EED_' . $module, $method_name);
1303
+		return true;
1304
+	}
1305
+
1306
+
1307
+
1308
+	/**
1309
+	 *    get_route - get module method route
1310
+	 *
1311
+	 * @access    public
1312
+	 * @param    string $route - "pretty" public alias for module method
1313
+	 * @param    string $key   - url param key indicating a route is being called
1314
+	 * @return    string
1315
+	 */
1316
+	public static function get_route($route = null, $key = 'ee')
1317
+	{
1318
+		do_action('AHEE__EE_Config__get_route__begin', $route);
1319
+		$route = (string)apply_filters('FHEE__EE_Config__get_route', $route);
1320
+		if (isset(EE_Config::$_module_route_map[$key][$route])) {
1321
+			return EE_Config::$_module_route_map[$key][$route];
1322
+		}
1323
+		return null;
1324
+	}
1325
+
1326
+
1327
+
1328
+	/**
1329
+	 *    get_routes - get ALL module method routes
1330
+	 *
1331
+	 * @access    public
1332
+	 * @return    array
1333
+	 */
1334
+	public static function get_routes()
1335
+	{
1336
+		return EE_Config::$_module_route_map;
1337
+	}
1338
+
1339
+
1340
+
1341
+	/**
1342
+	 *    register_forward - allows modules to forward request to another module for further processing
1343
+	 *
1344
+	 * @access    public
1345
+	 * @param    string       $route   - "pretty" public alias for module method
1346
+	 * @param    integer      $status  - integer value corresponding  to status constant strings set in module parent
1347
+	 *                                 class, allows different forwards to be served based on status
1348
+	 * @param    array|string $forward - function name or array( class, method )
1349
+	 * @param    string       $key     - url param key indicating a route is being called
1350
+	 * @return    bool
1351
+	 */
1352
+	public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee')
1353
+	{
1354
+		do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1355
+		if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1356
+			$msg = sprintf(
1357
+				__('The module route %s for this forward has not been registered.', 'event_espresso'),
1358
+				$route
1359
+			);
1360
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1361
+			return false;
1362
+		}
1363
+		if (empty($forward)) {
1364
+			$msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route);
1365
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1366
+			return false;
1367
+		}
1368
+		if (is_array($forward)) {
1369
+			if (! isset($forward[1])) {
1370
+				$msg = sprintf(
1371
+					__('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1372
+					$route
1373
+				);
1374
+				EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1375
+				return false;
1376
+			}
1377
+			if (! method_exists($forward[0], $forward[1])) {
1378
+				$msg = sprintf(
1379
+					__('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1380
+					$forward[1],
1381
+					$route
1382
+				);
1383
+				EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1384
+				return false;
1385
+			}
1386
+		} else if (! function_exists($forward)) {
1387
+			$msg = sprintf(
1388
+				__('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1389
+				$forward,
1390
+				$route
1391
+			);
1392
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1393
+			return false;
1394
+		}
1395
+		EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward;
1396
+		return true;
1397
+	}
1398
+
1399
+
1400
+
1401
+	/**
1402
+	 *    get_forward - get forwarding route
1403
+	 *
1404
+	 * @access    public
1405
+	 * @param    string  $route  - "pretty" public alias for module method
1406
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1407
+	 *                           allows different forwards to be served based on status
1408
+	 * @param    string  $key    - url param key indicating a route is being called
1409
+	 * @return    string
1410
+	 */
1411
+	public static function get_forward($route = null, $status = 0, $key = 'ee')
1412
+	{
1413
+		do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1414
+		if (isset(EE_Config::$_module_forward_map[$key][$route][$status])) {
1415
+			return apply_filters(
1416
+				'FHEE__EE_Config__get_forward',
1417
+				EE_Config::$_module_forward_map[$key][$route][$status],
1418
+				$route,
1419
+				$status
1420
+			);
1421
+		}
1422
+		return null;
1423
+	}
1424
+
1425
+
1426
+
1427
+	/**
1428
+	 *    register_forward - allows modules to specify different view templates for different method routes and status
1429
+	 *    results
1430
+	 *
1431
+	 * @access    public
1432
+	 * @param    string  $route  - "pretty" public alias for module method
1433
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1434
+	 *                           allows different views to be served based on status
1435
+	 * @param    string  $view
1436
+	 * @param    string  $key    - url param key indicating a route is being called
1437
+	 * @return    bool
1438
+	 */
1439
+	public static function register_view($route = null, $status = 0, $view = null, $key = 'ee')
1440
+	{
1441
+		do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1442
+		if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1443
+			$msg = sprintf(
1444
+				__('The module route %s for this view has not been registered.', 'event_espresso'),
1445
+				$route
1446
+			);
1447
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1448
+			return false;
1449
+		}
1450
+		if (! is_readable($view)) {
1451
+			$msg = sprintf(
1452
+				__(
1453
+					'The %s view file could not be found or is not readable due to file permissions.',
1454
+					'event_espresso'
1455
+				),
1456
+				$view
1457
+			);
1458
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1459
+			return false;
1460
+		}
1461
+		EE_Config::$_module_view_map[$key][$route][absint($status)] = $view;
1462
+		return true;
1463
+	}
1464
+
1465
+
1466
+
1467
+	/**
1468
+	 *    get_view - get view for route and status
1469
+	 *
1470
+	 * @access    public
1471
+	 * @param    string  $route  - "pretty" public alias for module method
1472
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1473
+	 *                           allows different views to be served based on status
1474
+	 * @param    string  $key    - url param key indicating a route is being called
1475
+	 * @return    string
1476
+	 */
1477
+	public static function get_view($route = null, $status = 0, $key = 'ee')
1478
+	{
1479
+		do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1480
+		if (isset(EE_Config::$_module_view_map[$key][$route][$status])) {
1481
+			return apply_filters(
1482
+				'FHEE__EE_Config__get_view',
1483
+				EE_Config::$_module_view_map[$key][$route][$status],
1484
+				$route,
1485
+				$status
1486
+			);
1487
+		}
1488
+		return null;
1489
+	}
1490
+
1491
+
1492
+
1493
+	public function update_addon_option_names()
1494
+	{
1495
+		update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names);
1496
+	}
1497
+
1498
+
1499
+
1500
+	public function shutdown()
1501
+	{
1502
+		$this->update_addon_option_names();
1503
+	}
1504
+
1505
+
1506
+
1507
+	/**
1508
+	 * @return LegacyShortcodesManager
1509
+	 */
1510
+	public static function getLegacyShortcodesManager()
1511
+	{
1512
+
1513
+		if ( ! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) {
1514
+			EE_Config::instance()->legacy_shortcodes_manager = new LegacyShortcodesManager(
1515
+				EE_Registry::instance()
1516
+			);
1517
+		}
1518
+		return EE_Config::instance()->legacy_shortcodes_manager;
1519
+	}
1520
+
1521
+
1522
+
1523
+	/**
1524
+	 * register_shortcode - makes core aware of this shortcode
1525
+	 *
1526
+	 * @deprecated 4.9.26
1527
+	 * @param    string $shortcode_path - full path up to and including shortcode folder
1528
+	 * @return    bool
1529
+	 */
1530
+	public static function register_shortcode($shortcode_path = null)
1531
+	{
1532
+		EE_Error::doing_it_wrong(
1533
+			__METHOD__,
1534
+			__(
1535
+				'Usage is deprecated. Use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::registerShortcode() as direct replacement, or better yet, please see the new \EventEspresso\core\services\shortcodes\ShortcodesManager class.',
1536
+				'event_espresso'
1537
+			),
1538
+			'4.9.26'
1539
+		);
1540
+		return EE_Config::instance()->getLegacyShortcodesManager()->registerShortcode($shortcode_path);
1541
+	}
21 1542
 
22
-    const LOG_NAME           = 'ee_config_log';
23 1543
 
24
-    const LOG_LENGTH         = 100;
25 1544
 
26
-    const ADDON_OPTION_NAMES = 'ee_config_option_names';
27
-
28
-
29
-    /**
30
-     *    instance of the EE_Config object
31
-     *
32
-     * @var    EE_Config $_instance
33
-     * @access    private
34
-     */
35
-    private static $_instance;
36
-
37
-    /**
38
-     * @var boolean $_logging_enabled
39
-     */
40
-    private static $_logging_enabled = false;
41
-
42
-    /**
43
-     * @var LegacyShortcodesManager $legacy_shortcodes_manager
44
-     */
45
-    private $legacy_shortcodes_manager;
46
-
47
-    /**
48
-     * An StdClass whose property names are addon slugs,
49
-     * and values are their config classes
50
-     *
51
-     * @var StdClass
52
-     */
53
-    public $addons;
54
-
55
-    /**
56
-     * @var EE_Admin_Config
57
-     */
58
-    public $admin;
59
-
60
-    /**
61
-     * @var EE_Core_Config
62
-     */
63
-    public $core;
64
-
65
-    /**
66
-     * @var EE_Currency_Config
67
-     */
68
-    public $currency;
69
-
70
-    /**
71
-     * @var EE_Organization_Config
72
-     */
73
-    public $organization;
74
-
75
-    /**
76
-     * @var EE_Registration_Config
77
-     */
78
-    public $registration;
79
-
80
-    /**
81
-     * @var EE_Template_Config
82
-     */
83
-    public $template_settings;
84
-
85
-    /**
86
-     * Holds EE environment values.
87
-     *
88
-     * @var EE_Environment_Config
89
-     */
90
-    public $environment;
91
-
92
-    /**
93
-     * settings pertaining to Google maps
94
-     *
95
-     * @var EE_Map_Config
96
-     */
97
-    public $map_settings;
98
-
99
-    /**
100
-     * settings pertaining to Taxes
101
-     *
102
-     * @var EE_Tax_Config
103
-     */
104
-    public $tax_settings;
105
-
106
-
107
-    /**
108
-     * Settings pertaining to global messages settings.
109
-     *
110
-     * @var EE_Messages_Config
111
-     */
112
-    public $messages;
113
-
114
-    /**
115
-     * @deprecated
116
-     * @var EE_Gateway_Config
117
-     */
118
-    public $gateway;
119
-
120
-    /**
121
-     * @var    array $_addon_option_names
122
-     * @access    private
123
-     */
124
-    private $_addon_option_names = array();
125
-
126
-    /**
127
-     * @var    array $_module_route_map
128
-     * @access    private
129
-     */
130
-    private static $_module_route_map = array();
131
-
132
-    /**
133
-     * @var    array $_module_forward_map
134
-     * @access    private
135
-     */
136
-    private static $_module_forward_map = array();
137
-
138
-    /**
139
-     * @var    array $_module_view_map
140
-     * @access    private
141
-     */
142
-    private static $_module_view_map = array();
143
-
144
-
145
-
146
-    /**
147
-     * @singleton method used to instantiate class object
148
-     * @access    public
149
-     * @return EE_Config instance
150
-     */
151
-    public static function instance()
152
-    {
153
-        // check if class object is instantiated, and instantiated properly
154
-        if (! self::$_instance instanceof EE_Config) {
155
-            self::$_instance = new self();
156
-        }
157
-        return self::$_instance;
158
-    }
159
-
160
-
161
-
162
-    /**
163
-     * Resets the config
164
-     *
165
-     * @param bool    $hard_reset    if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE
166
-     *                               (default) leaves the database alone, and merely resets the EE_Config object to
167
-     *                               reflect its state in the database
168
-     * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave
169
-     *                               $_instance as NULL. Useful in case you want to forget about the old instance on
170
-     *                               EE_Config, but might not be ready to instantiate EE_Config currently (eg if the
171
-     *                               site was put into maintenance mode)
172
-     * @return EE_Config
173
-     */
174
-    public static function reset($hard_reset = false, $reinstantiate = true)
175
-    {
176
-        if (self::$_instance instanceof EE_Config) {
177
-            if ($hard_reset) {
178
-                self::$_instance->legacy_shortcodes_manager = null;
179
-                self::$_instance->_addon_option_names = array();
180
-                self::$_instance->_initialize_config();
181
-                self::$_instance->update_espresso_config();
182
-            }
183
-            self::$_instance->update_addon_option_names();
184
-        }
185
-        self::$_instance = null;
186
-        //we don't need to reset the static properties imo because those should
187
-        //only change when a module is added or removed. Currently we don't
188
-        //support removing a module during a request when it previously existed
189
-        if ($reinstantiate) {
190
-            return self::instance();
191
-        } else {
192
-            return null;
193
-        }
194
-    }
195
-
196
-
197
-
198
-    /**
199
-     *    class constructor
200
-     *
201
-     * @access    private
202
-     */
203
-    private function __construct()
204
-    {
205
-        do_action('AHEE__EE_Config__construct__begin', $this);
206
-        EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false);
207
-        // setup empty config classes
208
-        $this->_initialize_config();
209
-        // load existing EE site settings
210
-        $this->_load_core_config();
211
-        // confirm everything loaded correctly and set filtered defaults if not
212
-        $this->_verify_config();
213
-        //  register shortcodes and modules
214
-        add_action(
215
-            'AHEE__EE_System__register_shortcodes_modules_and_widgets',
216
-            array($this, 'register_shortcodes_and_modules'),
217
-            999
218
-        );
219
-        //  initialize shortcodes and modules
220
-        add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules'));
221
-        // register widgets
222
-        add_action('widgets_init', array($this, 'widgets_init'), 10);
223
-        // shutdown
224
-        add_action('shutdown', array($this, 'shutdown'), 10);
225
-        // construct__end hook
226
-        do_action('AHEE__EE_Config__construct__end', $this);
227
-        // hardcoded hack
228
-        $this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014';
229
-    }
230
-
231
-
232
-
233
-    /**
234
-     * @return boolean
235
-     */
236
-    public static function logging_enabled()
237
-    {
238
-        return self::$_logging_enabled;
239
-    }
240
-
241
-
242
-
243
-    /**
244
-     * use to get the current theme if needed from static context
245
-     *
246
-     * @return string current theme set.
247
-     */
248
-    public static function get_current_theme()
249
-    {
250
-        return isset(self::$_instance->template_settings->current_espresso_theme)
251
-            ? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014';
252
-    }
253
-
254
-
255
-
256
-    /**
257
-     *        _initialize_config
258
-     *
259
-     * @access private
260
-     * @return void
261
-     */
262
-    private function _initialize_config()
263
-    {
264
-        EE_Config::trim_log();
265
-        //set defaults
266
-        $this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array());
267
-        $this->addons = new stdClass();
268
-        // set _module_route_map
269
-        EE_Config::$_module_route_map = array();
270
-        // set _module_forward_map
271
-        EE_Config::$_module_forward_map = array();
272
-        // set _module_view_map
273
-        EE_Config::$_module_view_map = array();
274
-    }
275
-
276
-
277
-
278
-    /**
279
-     *        load core plugin configuration
280
-     *
281
-     * @access private
282
-     * @return void
283
-     */
284
-    private function _load_core_config()
285
-    {
286
-        // load_core_config__start hook
287
-        do_action('AHEE__EE_Config___load_core_config__start', $this);
288
-        $espresso_config = $this->get_espresso_config();
289
-        foreach ($espresso_config as $config => $settings) {
290
-            // load_core_config__start hook
291
-            $settings = apply_filters(
292
-                'FHEE__EE_Config___load_core_config__config_settings',
293
-                $settings,
294
-                $config,
295
-                $this
296
-            );
297
-            if (is_object($settings) && property_exists($this, $config)) {
298
-                $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings);
299
-                //call configs populate method to ensure any defaults are set for empty values.
300
-                if (method_exists($settings, 'populate')) {
301
-                    $this->{$config}->populate();
302
-                }
303
-                if (method_exists($settings, 'do_hooks')) {
304
-                    $this->{$config}->do_hooks();
305
-                }
306
-            }
307
-        }
308
-        if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) {
309
-            $this->update_espresso_config();
310
-        }
311
-        // load_core_config__end hook
312
-        do_action('AHEE__EE_Config___load_core_config__end', $this);
313
-    }
314
-
315
-
316
-
317
-    /**
318
-     *    _verify_config
319
-     *
320
-     * @access    protected
321
-     * @return    void
322
-     */
323
-    protected function _verify_config()
324
-    {
325
-        $this->core = $this->core instanceof EE_Core_Config
326
-            ? $this->core
327
-            : new EE_Core_Config();
328
-        $this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core);
329
-        $this->organization = $this->organization instanceof EE_Organization_Config
330
-            ? $this->organization
331
-            : new EE_Organization_Config();
332
-        $this->organization = apply_filters(
333
-            'FHEE__EE_Config___initialize_config__organization',
334
-            $this->organization
335
-        );
336
-        $this->currency = $this->currency instanceof EE_Currency_Config
337
-            ? $this->currency
338
-            : new EE_Currency_Config();
339
-        $this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency);
340
-        $this->registration = $this->registration instanceof EE_Registration_Config
341
-            ? $this->registration
342
-            : new EE_Registration_Config();
343
-        $this->registration = apply_filters(
344
-            'FHEE__EE_Config___initialize_config__registration',
345
-            $this->registration
346
-        );
347
-        $this->admin = $this->admin instanceof EE_Admin_Config
348
-            ? $this->admin
349
-            : new EE_Admin_Config();
350
-        $this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin);
351
-        $this->template_settings = $this->template_settings instanceof EE_Template_Config
352
-            ? $this->template_settings
353
-            : new EE_Template_Config();
354
-        $this->template_settings = apply_filters(
355
-            'FHEE__EE_Config___initialize_config__template_settings',
356
-            $this->template_settings
357
-        );
358
-        $this->map_settings = $this->map_settings instanceof EE_Map_Config
359
-            ? $this->map_settings
360
-            : new EE_Map_Config();
361
-        $this->map_settings = apply_filters('FHEE__EE_Config___initialize_config__map_settings',
362
-            $this->map_settings);
363
-        $this->environment = $this->environment instanceof EE_Environment_Config
364
-            ? $this->environment
365
-            : new EE_Environment_Config();
366
-        $this->environment = apply_filters('FHEE__EE_Config___initialize_config__environment',
367
-            $this->environment);
368
-        $this->tax_settings = $this->tax_settings instanceof EE_Tax_Config
369
-            ? $this->tax_settings
370
-            : new EE_Tax_Config();
371
-        $this->tax_settings = apply_filters('FHEE__EE_Config___initialize_config__tax_settings',
372
-            $this->tax_settings);
373
-        $this->messages = apply_filters('FHEE__EE_Config__initialize_config__messages', $this->messages);
374
-        $this->messages = $this->messages instanceof EE_Messages_Config
375
-            ? $this->messages
376
-            : new EE_Messages_Config();
377
-        $this->gateway = $this->gateway instanceof EE_Gateway_Config
378
-            ? $this->gateway
379
-            : new EE_Gateway_Config();
380
-        $this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway);
381
-        $this->legacy_shortcodes_manager = null;
382
-    }
383
-
384
-
385
-    /**
386
-     *    get_espresso_config
387
-     *
388
-     * @access    public
389
-     * @return    array of espresso config stuff
390
-     */
391
-    public function get_espresso_config()
392
-    {
393
-        // grab espresso configuration
394
-        return apply_filters(
395
-            'FHEE__EE_Config__get_espresso_config__CFG',
396
-            get_option(EE_Config::OPTION_NAME, array())
397
-        );
398
-    }
399
-
400
-
401
-
402
-    /**
403
-     *    double_check_config_comparison
404
-     *
405
-     * @access    public
406
-     * @param string $option
407
-     * @param        $old_value
408
-     * @param        $value
409
-     */
410
-    public function double_check_config_comparison($option = '', $old_value, $value)
411
-    {
412
-        // make sure we're checking the ee config
413
-        if ($option === EE_Config::OPTION_NAME) {
414
-            // run a loose comparison of the old value against the new value for type and properties,
415
-            // but NOT exact instance like WP update_option does (ie: NOT type safe comparison)
416
-            if ($value != $old_value) {
417
-                // if they are NOT the same, then remove the hook,
418
-                // which means the subsequent update results will be based solely on the update query results
419
-                // the reason we do this is because, as stated above,
420
-                // WP update_option performs an exact instance comparison (===) on any update values passed to it
421
-                // this happens PRIOR to serialization and any subsequent update.
422
-                // If values are found to match their previous old value,
423
-                // then WP bails before performing any update.
424
-                // Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version
425
-                // it just pulled from the db, with the one being passed to it (which will not match).
426
-                // HOWEVER, once the object is serialized and passed off to MySQL to update,
427
-                // MySQL MAY ALSO NOT perform the update because
428
-                // the string it sees in the db looks the same as the new one it has been passed!!!
429
-                // This results in the query returning an "affected rows" value of ZERO,
430
-                // which gets returned immediately by WP update_option and looks like an error.
431
-                remove_action('update_option', array($this, 'check_config_updated'));
432
-            }
433
-        }
434
-    }
435
-
436
-
437
-
438
-    /**
439
-     *    update_espresso_config
440
-     *
441
-     * @access   public
442
-     */
443
-    protected function _reset_espresso_addon_config()
444
-    {
445
-        $this->_addon_option_names = array();
446
-        foreach ($this->addons as $addon_name => $addon_config_obj) {
447
-            $addon_config_obj = maybe_unserialize($addon_config_obj);
448
-            $config_class = get_class($addon_config_obj);
449
-            if ($addon_config_obj instanceof $config_class && ! $addon_config_obj instanceof __PHP_Incomplete_Class) {
450
-                $this->update_config('addons', $addon_name, $addon_config_obj, false);
451
-            }
452
-            $this->addons->{$addon_name} = null;
453
-        }
454
-    }
455
-
456
-
457
-
458
-    /**
459
-     *    update_espresso_config
460
-     *
461
-     * @access   public
462
-     * @param   bool $add_success
463
-     * @param   bool $add_error
464
-     * @return   bool
465
-     */
466
-    public function update_espresso_config($add_success = false, $add_error = true)
467
-    {
468
-        // don't allow config updates during WP heartbeats
469
-        if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
470
-            return false;
471
-        }
472
-        // commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197
473
-        //$clone = clone( self::$_instance );
474
-        //self::$_instance = NULL;
475
-        do_action('AHEE__EE_Config__update_espresso_config__begin', $this);
476
-        $this->_reset_espresso_addon_config();
477
-        // hook into update_option because that happens AFTER the ( $value === $old_value ) conditional
478
-        // but BEFORE the actual update occurs
479
-        add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3);
480
-        // don't want to persist legacy_shortcodes_manager, but don't want to lose it either
481
-        $legacy_shortcodes_manager = $this->legacy_shortcodes_manager;
482
-        $this->legacy_shortcodes_manager = null;
483
-        // now update "ee_config"
484
-        $saved = update_option(EE_Config::OPTION_NAME, $this);
485
-        $this->legacy_shortcodes_manager = $legacy_shortcodes_manager;
486
-        EE_Config::log(EE_Config::OPTION_NAME);
487
-        // if not saved... check if the hook we just added still exists;
488
-        // if it does, it means one of two things:
489
-        // 		that update_option bailed at the ( $value === $old_value ) conditional,
490
-        //		 or...
491
-        // 		the db update query returned 0 rows affected
492
-        // 		(probably because the data  value was the same from it's perspective)
493
-        // so the existence of the hook means that a negative result from update_option is NOT an error,
494
-        // but just means no update occurred, so don't display an error to the user.
495
-        // BUT... if update_option returns FALSE, AND the hook is missing,
496
-        // then it means that something truly went wrong
497
-        $saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved;
498
-        // remove our action since we don't want it in the system anymore
499
-        remove_action('update_option', array($this, 'double_check_config_comparison'), 1);
500
-        do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved);
501
-        //self::$_instance = $clone;
502
-        //unset( $clone );
503
-        // if config remains the same or was updated successfully
504
-        if ($saved) {
505
-            if ($add_success) {
506
-                EE_Error::add_success(
507
-                    __('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'),
508
-                    __FILE__,
509
-                    __FUNCTION__,
510
-                    __LINE__
511
-                );
512
-            }
513
-            return true;
514
-        } else {
515
-            if ($add_error) {
516
-                EE_Error::add_error(
517
-                    __('The Event Espresso Configuration Settings were not updated.', 'event_espresso'),
518
-                    __FILE__,
519
-                    __FUNCTION__,
520
-                    __LINE__
521
-                );
522
-            }
523
-            return false;
524
-        }
525
-    }
526
-
527
-
528
-
529
-    /**
530
-     *    _verify_config_params
531
-     *
532
-     * @access    private
533
-     * @param    string         $section
534
-     * @param    string         $name
535
-     * @param    string         $config_class
536
-     * @param    EE_Config_Base $config_obj
537
-     * @param    array          $tests_to_run
538
-     * @param    bool           $display_errors
539
-     * @return    bool    TRUE on success, FALSE on fail
540
-     */
541
-    private function _verify_config_params(
542
-        $section = '',
543
-        $name = '',
544
-        $config_class = '',
545
-        $config_obj = null,
546
-        $tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8),
547
-        $display_errors = true
548
-    ) {
549
-        try {
550
-            foreach ($tests_to_run as $test) {
551
-                switch ($test) {
552
-                    // TEST #1 : check that section was set
553
-                    case 1 :
554
-                        if (empty($section)) {
555
-                            if ($display_errors) {
556
-                                throw new EE_Error(
557
-                                    sprintf(
558
-                                        __(
559
-                                            'No configuration section has been provided while attempting to save "%s".',
560
-                                            'event_espresso'
561
-                                        ),
562
-                                        $config_class
563
-                                    )
564
-                                );
565
-                            }
566
-                            return false;
567
-                        }
568
-                        break;
569
-                    // TEST #2 : check that settings section exists
570
-                    case 2 :
571
-                        if (! isset($this->{$section})) {
572
-                            if ($display_errors) {
573
-                                throw new EE_Error(
574
-                                    sprintf(
575
-                                        __('The "%s" configuration section does not exist.', 'event_espresso'),
576
-                                        $section
577
-                                    )
578
-                                );
579
-                            }
580
-                            return false;
581
-                        }
582
-                        break;
583
-                    // TEST #3 : check that section is the proper format
584
-                    case 3 :
585
-                        if (
586
-                        ! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass)
587
-                        ) {
588
-                            if ($display_errors) {
589
-                                throw new EE_Error(
590
-                                    sprintf(
591
-                                        __(
592
-                                            'The "%s" configuration settings have not been formatted correctly.',
593
-                                            'event_espresso'
594
-                                        ),
595
-                                        $section
596
-                                    )
597
-                                );
598
-                            }
599
-                            return false;
600
-                        }
601
-                        break;
602
-                    // TEST #4 : check that config section name has been set
603
-                    case 4 :
604
-                        if (empty($name)) {
605
-                            if ($display_errors) {
606
-                                throw new EE_Error(
607
-                                    __(
608
-                                        'No name has been provided for the specific configuration section.',
609
-                                        'event_espresso'
610
-                                    )
611
-                                );
612
-                            }
613
-                            return false;
614
-                        }
615
-                        break;
616
-                    // TEST #5 : check that a config class name has been set
617
-                    case 5 :
618
-                        if (empty($config_class)) {
619
-                            if ($display_errors) {
620
-                                throw new EE_Error(
621
-                                    __(
622
-                                        'No class name has been provided for the specific configuration section.',
623
-                                        'event_espresso'
624
-                                    )
625
-                                );
626
-                            }
627
-                            return false;
628
-                        }
629
-                        break;
630
-                    // TEST #6 : verify config class is accessible
631
-                    case 6 :
632
-                        if (! class_exists($config_class)) {
633
-                            if ($display_errors) {
634
-                                throw new EE_Error(
635
-                                    sprintf(
636
-                                        __(
637
-                                            'The "%s" class does not exist. Please ensure that an autoloader has been set for it.',
638
-                                            'event_espresso'
639
-                                        ),
640
-                                        $config_class
641
-                                    )
642
-                                );
643
-                            }
644
-                            return false;
645
-                        }
646
-                        break;
647
-                    // TEST #7 : check that config has even been set
648
-                    case 7 :
649
-                        if (! isset($this->{$section}->{$name})) {
650
-                            if ($display_errors) {
651
-                                throw new EE_Error(
652
-                                    sprintf(
653
-                                        __('No configuration has been set for "%1$s->%2$s".', 'event_espresso'),
654
-                                        $section,
655
-                                        $name
656
-                                    )
657
-                                );
658
-                            }
659
-                            return false;
660
-                        } else {
661
-                            // and make sure it's not serialized
662
-                            $this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name});
663
-                        }
664
-                        break;
665
-                    // TEST #8 : check that config is the requested type
666
-                    case 8 :
667
-                        if (! $this->{$section}->{$name} instanceof $config_class) {
668
-                            if ($display_errors) {
669
-                                throw new EE_Error(
670
-                                    sprintf(
671
-                                        __(
672
-                                            'The configuration for "%1$s->%2$s" is not of the "%3$s" class.',
673
-                                            'event_espresso'
674
-                                        ),
675
-                                        $section,
676
-                                        $name,
677
-                                        $config_class
678
-                                    )
679
-                                );
680
-                            }
681
-                            return false;
682
-                        }
683
-                        break;
684
-                    // TEST #9 : verify config object
685
-                    case 9 :
686
-                        if (! $config_obj instanceof EE_Config_Base) {
687
-                            if ($display_errors) {
688
-                                throw new EE_Error(
689
-                                    sprintf(
690
-                                        __('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'),
691
-                                        print_r($config_obj, true)
692
-                                    )
693
-                                );
694
-                            }
695
-                            return false;
696
-                        }
697
-                        break;
698
-                }
699
-            }
700
-        } catch (EE_Error $e) {
701
-            $e->get_error();
702
-        }
703
-        // you have successfully run the gauntlet
704
-        return true;
705
-    }
706
-
707
-
708
-
709
-    /**
710
-     *    _generate_config_option_name
711
-     *
712
-     * @access        protected
713
-     * @param        string $section
714
-     * @param        string $name
715
-     * @return        string
716
-     */
717
-    private function _generate_config_option_name($section = '', $name = '')
718
-    {
719
-        return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name));
720
-    }
721
-
722
-
723
-
724
-    /**
725
-     *    _set_config_class
726
-     * ensures that a config class is set, either from a passed config class or one generated from the config name
727
-     *
728
-     * @access    private
729
-     * @param    string $config_class
730
-     * @param    string $name
731
-     * @return    string
732
-     */
733
-    private function _set_config_class($config_class = '', $name = '')
734
-    {
735
-        return ! empty($config_class)
736
-            ? $config_class
737
-            : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config';
738
-    }
739
-
740
-
741
-
742
-    /**
743
-     *    set_config
744
-     *
745
-     * @access    protected
746
-     * @param    string         $section
747
-     * @param    string         $name
748
-     * @param    string         $config_class
749
-     * @param    EE_Config_Base $config_obj
750
-     * @return    EE_Config_Base
751
-     */
752
-    public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null)
753
-    {
754
-        // ensure config class is set to something
755
-        $config_class = $this->_set_config_class($config_class, $name);
756
-        // run tests 1-4, 6, and 7 to verify all config params are set and valid
757
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
758
-            return null;
759
-        }
760
-        $config_option_name = $this->_generate_config_option_name($section, $name);
761
-        // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now
762
-        if (! isset($this->_addon_option_names[$config_option_name])) {
763
-            $this->_addon_option_names[$config_option_name] = $config_class;
764
-            $this->update_addon_option_names();
765
-        }
766
-        // verify the incoming config object but suppress errors
767
-        if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
768
-            $config_obj = new $config_class();
769
-        }
770
-        if (get_option($config_option_name)) {
771
-            EE_Config::log($config_option_name);
772
-            update_option($config_option_name, $config_obj);
773
-            $this->{$section}->{$name} = $config_obj;
774
-            return $this->{$section}->{$name};
775
-        } else {
776
-            // create a wp-option for this config
777
-            if (add_option($config_option_name, $config_obj, '', 'no')) {
778
-                $this->{$section}->{$name} = maybe_unserialize($config_obj);
779
-                return $this->{$section}->{$name};
780
-            } else {
781
-                EE_Error::add_error(
782
-                    sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class),
783
-                    __FILE__,
784
-                    __FUNCTION__,
785
-                    __LINE__
786
-                );
787
-                return null;
788
-            }
789
-        }
790
-    }
791
-
792
-
793
-
794
-    /**
795
-     *    update_config
796
-     * Important: the config object must ALREADY be set, otherwise this will produce an error.
797
-     *
798
-     * @access    public
799
-     * @param    string                $section
800
-     * @param    string                $name
801
-     * @param    EE_Config_Base|string $config_obj
802
-     * @param    bool                  $throw_errors
803
-     * @return    bool
804
-     */
805
-    public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true)
806
-    {
807
-        // don't allow config updates during WP heartbeats
808
-        if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
809
-            return false;
810
-        }
811
-        $config_obj = maybe_unserialize($config_obj);
812
-        // get class name of the incoming object
813
-        $config_class = get_class($config_obj);
814
-        // run tests 1-5 and 9 to verify config
815
-        if (! $this->_verify_config_params(
816
-            $section,
817
-            $name,
818
-            $config_class,
819
-            $config_obj,
820
-            array(1, 2, 3, 4, 7, 9)
821
-        )
822
-        ) {
823
-            return false;
824
-        }
825
-        $config_option_name = $this->_generate_config_option_name($section, $name);
826
-        // check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
827
-        if (! isset($this->_addon_option_names[$config_option_name])) {
828
-            // save new config to db
829
-            if ($this->set_config($section, $name, $config_class, $config_obj)) {
830
-                return true;
831
-            }
832
-        } else {
833
-            // first check if the record already exists
834
-            $existing_config = get_option($config_option_name);
835
-            $config_obj = serialize($config_obj);
836
-            // just return if db record is already up to date (NOT type safe comparison)
837
-            if ($existing_config == $config_obj) {
838
-                $this->{$section}->{$name} = $config_obj;
839
-                return true;
840
-            } else if (update_option($config_option_name, $config_obj)) {
841
-                EE_Config::log($config_option_name);
842
-                // update wp-option for this config class
843
-                $this->{$section}->{$name} = $config_obj;
844
-                return true;
845
-            } elseif ($throw_errors) {
846
-                EE_Error::add_error(
847
-                    sprintf(
848
-                        __(
849
-                            'The "%1$s" object stored at"%2$s" was not successfully updated in the database.',
850
-                            'event_espresso'
851
-                        ),
852
-                        $config_class,
853
-                        'EE_Config->' . $section . '->' . $name
854
-                    ),
855
-                    __FILE__,
856
-                    __FUNCTION__,
857
-                    __LINE__
858
-                );
859
-            }
860
-        }
861
-        return false;
862
-    }
863
-
864
-
865
-
866
-    /**
867
-     *    get_config
868
-     *
869
-     * @access    public
870
-     * @param    string $section
871
-     * @param    string $name
872
-     * @param    string $config_class
873
-     * @return    mixed EE_Config_Base | NULL
874
-     */
875
-    public function get_config($section = '', $name = '', $config_class = '')
876
-    {
877
-        // ensure config class is set to something
878
-        $config_class = $this->_set_config_class($config_class, $name);
879
-        // run tests 1-4, 6 and 7 to verify that all params have been set
880
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
881
-            return null;
882
-        }
883
-        // now test if the requested config object exists, but suppress errors
884
-        if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) {
885
-            // config already exists, so pass it back
886
-            return $this->{$section}->{$name};
887
-        }
888
-        // load config option from db if it exists
889
-        $config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name));
890
-        // verify the newly retrieved config object, but suppress errors
891
-        if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
892
-            // config is good, so set it and pass it back
893
-            $this->{$section}->{$name} = $config_obj;
894
-            return $this->{$section}->{$name};
895
-        }
896
-        // oops! $config_obj is not already set and does not exist in the db, so create a new one
897
-        $config_obj = $this->set_config($section, $name, $config_class);
898
-        // verify the newly created config object
899
-        if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) {
900
-            return $this->{$section}->{$name};
901
-        } else {
902
-            EE_Error::add_error(
903
-                sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class),
904
-                __FILE__,
905
-                __FUNCTION__,
906
-                __LINE__
907
-            );
908
-        }
909
-        return null;
910
-    }
911
-
912
-
913
-
914
-    /**
915
-     *    get_config_option
916
-     *
917
-     * @access    public
918
-     * @param    string $config_option_name
919
-     * @return    mixed EE_Config_Base | FALSE
920
-     */
921
-    public function get_config_option($config_option_name = '')
922
-    {
923
-        // retrieve the wp-option for this config class.
924
-        $config_option = maybe_unserialize(get_option($config_option_name, array()));
925
-        if (empty($config_option)) {
926
-            EE_Config::log($config_option_name . '-NOT-FOUND');
927
-        }
928
-        return $config_option;
929
-    }
930
-
931
-
932
-
933
-    /**
934
-     * log
935
-     *
936
-     * @param string $config_option_name
937
-     */
938
-    public static function log($config_option_name = '')
939
-    {
940
-        if (EE_Config::logging_enabled() && ! empty($config_option_name)) {
941
-            $config_log = get_option(EE_Config::LOG_NAME, array());
942
-            //copy incoming $_REQUEST and sanitize it so we can save it
943
-            $_request = $_REQUEST;
944
-            array_walk_recursive($_request, 'sanitize_text_field');
945
-            $config_log[(string)microtime(true)] = array(
946
-                'config_name' => $config_option_name,
947
-                'request'     => $_request,
948
-            );
949
-            update_option(EE_Config::LOG_NAME, $config_log);
950
-        }
951
-    }
952
-
953
-
954
-
955
-    /**
956
-     * trim_log
957
-     * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH
958
-     */
959
-    public static function trim_log()
960
-    {
961
-        if (! EE_Config::logging_enabled()) {
962
-            return;
963
-        }
964
-        $config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
965
-        $log_length = count($config_log);
966
-        if ($log_length > EE_Config::LOG_LENGTH) {
967
-            ksort($config_log);
968
-            $config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true);
969
-            update_option(EE_Config::LOG_NAME, $config_log);
970
-        }
971
-    }
972
-
973
-
974
-
975
-    /**
976
-     *    get_page_for_posts
977
-     *    if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the
978
-     *    wp-option "page_for_posts", or "posts" if no page is selected
979
-     *
980
-     * @access    public
981
-     * @return    string
982
-     */
983
-    public static function get_page_for_posts()
984
-    {
985
-        $page_for_posts = get_option('page_for_posts');
986
-        if (! $page_for_posts) {
987
-            return 'posts';
988
-        }
989
-        /** @type WPDB $wpdb */
990
-        global $wpdb;
991
-        $SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d";
992
-        return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts));
993
-    }
994
-
995
-
996
-
997
-    /**
998
-     *    register_shortcodes_and_modules.
999
-     *    At this point, it's too early to tell if we're maintenance mode or not.
1000
-     *    In fact, this is where we give modules a chance to let core know they exist
1001
-     *    so they can help trigger maintenance mode if it's needed
1002
-     *
1003
-     * @access    public
1004
-     * @return    void
1005
-     */
1006
-    public function register_shortcodes_and_modules()
1007
-    {
1008
-        // allow modules to set hooks for the rest of the system
1009
-        EE_Registry::instance()->modules = $this->_register_modules();
1010
-    }
1011
-
1012
-
1013
-
1014
-    /**
1015
-     *    initialize_shortcodes_and_modules
1016
-     *    meaning they can start adding their hooks to get stuff done
1017
-     *
1018
-     * @access    public
1019
-     * @return    void
1020
-     */
1021
-    public function initialize_shortcodes_and_modules()
1022
-    {
1023
-        // allow modules to set hooks for the rest of the system
1024
-        $this->_initialize_modules();
1025
-    }
1026
-
1027
-
1028
-
1029
-    /**
1030
-     *    widgets_init
1031
-     *
1032
-     * @access private
1033
-     * @return void
1034
-     */
1035
-    public function widgets_init()
1036
-    {
1037
-        //only init widgets on admin pages when not in complete maintenance, and
1038
-        //on frontend when not in any maintenance mode
1039
-        if (
1040
-            ! EE_Maintenance_Mode::instance()->level()
1041
-            || (
1042
-                is_admin()
1043
-                && EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance
1044
-            )
1045
-        ) {
1046
-            // grab list of installed widgets
1047
-            $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
1048
-            // filter list of modules to register
1049
-            $widgets_to_register = apply_filters(
1050
-                'FHEE__EE_Config__register_widgets__widgets_to_register',
1051
-                $widgets_to_register
1052
-            );
1053
-            if (! empty($widgets_to_register)) {
1054
-                // cycle thru widget folders
1055
-                foreach ($widgets_to_register as $widget_path) {
1056
-                    // add to list of installed widget modules
1057
-                    EE_Config::register_ee_widget($widget_path);
1058
-                }
1059
-            }
1060
-            // filter list of installed modules
1061
-            EE_Registry::instance()->widgets = apply_filters(
1062
-                'FHEE__EE_Config__register_widgets__installed_widgets',
1063
-                EE_Registry::instance()->widgets
1064
-            );
1065
-        }
1066
-    }
1067
-
1068
-
1069
-
1070
-    /**
1071
-     *    register_ee_widget - makes core aware of this widget
1072
-     *
1073
-     * @access    public
1074
-     * @param    string $widget_path - full path up to and including widget folder
1075
-     * @return    void
1076
-     */
1077
-    public static function register_ee_widget($widget_path = null)
1078
-    {
1079
-        do_action('AHEE__EE_Config__register_widget__begin', $widget_path);
1080
-        $widget_ext = '.widget.php';
1081
-        // make all separators match
1082
-        $widget_path = rtrim(str_replace('/\\', DS, $widget_path), DS);
1083
-        // does the file path INCLUDE the actual file name as part of the path ?
1084
-        if (strpos($widget_path, $widget_ext) !== false) {
1085
-            // grab and shortcode file name from directory name and break apart at dots
1086
-            $file_name = explode('.', basename($widget_path));
1087
-            // take first segment from file name pieces and remove class prefix if it exists
1088
-            $widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0];
1089
-            // sanitize shortcode directory name
1090
-            $widget = sanitize_key($widget);
1091
-            // now we need to rebuild the shortcode path
1092
-            $widget_path = explode(DS, $widget_path);
1093
-            // remove last segment
1094
-            array_pop($widget_path);
1095
-            // glue it back together
1096
-            $widget_path = implode(DS, $widget_path);
1097
-        } else {
1098
-            // grab and sanitize widget directory name
1099
-            $widget = sanitize_key(basename($widget_path));
1100
-        }
1101
-        // create classname from widget directory name
1102
-        $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1103
-        // add class prefix
1104
-        $widget_class = 'EEW_' . $widget;
1105
-        // does the widget exist ?
1106
-        if (! is_readable($widget_path . DS . $widget_class . $widget_ext)) {
1107
-            $msg = sprintf(
1108
-                __(
1109
-                    'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s',
1110
-                    'event_espresso'
1111
-                ),
1112
-                $widget_class,
1113
-                $widget_path . DS . $widget_class . $widget_ext
1114
-            );
1115
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1116
-            return;
1117
-        }
1118
-        // load the widget class file
1119
-        require_once($widget_path . DS . $widget_class . $widget_ext);
1120
-        // verify that class exists
1121
-        if (! class_exists($widget_class)) {
1122
-            $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1123
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1124
-            return;
1125
-        }
1126
-        register_widget($widget_class);
1127
-        // add to array of registered widgets
1128
-        EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext;
1129
-    }
1130
-
1131
-
1132
-
1133
-    /**
1134
-     *        _register_modules
1135
-     *
1136
-     * @access private
1137
-     * @return array
1138
-     */
1139
-    private function _register_modules()
1140
-    {
1141
-        // grab list of installed modules
1142
-        $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1143
-        // filter list of modules to register
1144
-        $modules_to_register = apply_filters(
1145
-            'FHEE__EE_Config__register_modules__modules_to_register',
1146
-            $modules_to_register
1147
-        );
1148
-        if (! empty($modules_to_register)) {
1149
-            // loop through folders
1150
-            foreach ($modules_to_register as $module_path) {
1151
-                /**TEMPORARILY EXCLUDE gateways from modules for time being**/
1152
-                if (
1153
-                    $module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1154
-                    && $module_path !== EE_MODULES . 'gateways'
1155
-                ) {
1156
-                    // add to list of installed modules
1157
-                    EE_Config::register_module($module_path);
1158
-                }
1159
-            }
1160
-        }
1161
-        // filter list of installed modules
1162
-        return apply_filters(
1163
-            'FHEE__EE_Config___register_modules__installed_modules',
1164
-            EE_Registry::instance()->modules
1165
-        );
1166
-    }
1167
-
1168
-
1169
-
1170
-    /**
1171
-     *    register_module - makes core aware of this module
1172
-     *
1173
-     * @access    public
1174
-     * @param    string $module_path - full path up to and including module folder
1175
-     * @return    bool
1176
-     */
1177
-    public static function register_module($module_path = null)
1178
-    {
1179
-        do_action('AHEE__EE_Config__register_module__begin', $module_path);
1180
-        $module_ext = '.module.php';
1181
-        // make all separators match
1182
-        $module_path = str_replace(array('\\', '/'), DS, $module_path);
1183
-        // does the file path INCLUDE the actual file name as part of the path ?
1184
-        if (strpos($module_path, $module_ext) !== false) {
1185
-            // grab and shortcode file name from directory name and break apart at dots
1186
-            $module_file = explode('.', basename($module_path));
1187
-            // now we need to rebuild the shortcode path
1188
-            $module_path = explode(DS, $module_path);
1189
-            // remove last segment
1190
-            array_pop($module_path);
1191
-            // glue it back together
1192
-            $module_path = implode(DS, $module_path) . DS;
1193
-            // take first segment from file name pieces and sanitize it
1194
-            $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1195
-            // ensure class prefix is added
1196
-            $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1197
-        } else {
1198
-            // we need to generate the filename based off of the folder name
1199
-            // grab and sanitize module name
1200
-            $module = strtolower(basename($module_path));
1201
-            $module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1202
-            // like trailingslashit()
1203
-            $module_path = rtrim($module_path, DS) . DS;
1204
-            // create classname from module directory name
1205
-            $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1206
-            // add class prefix
1207
-            $module_class = 'EED_' . $module;
1208
-        }
1209
-        // does the module exist ?
1210
-        if (! is_readable($module_path . DS . $module_class . $module_ext)) {
1211
-            $msg = sprintf(
1212
-                __(
1213
-                    'The requested %s module file could not be found or is not readable due to file permissions.',
1214
-                    'event_espresso'
1215
-                ),
1216
-                $module
1217
-            );
1218
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1219
-            return false;
1220
-        }
1221
-        // load the module class file
1222
-        require_once($module_path . $module_class . $module_ext);
1223
-        // verify that class exists
1224
-        if (! class_exists($module_class)) {
1225
-            $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1226
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1227
-            return false;
1228
-        }
1229
-        // add to array of registered modules
1230
-        EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1231
-        do_action(
1232
-            'AHEE__EE_Config__register_module__complete',
1233
-            $module_class,
1234
-            EE_Registry::instance()->modules->{$module_class}
1235
-        );
1236
-        return true;
1237
-    }
1238
-
1239
-
1240
-
1241
-    /**
1242
-     *    _initialize_modules
1243
-     *    allow modules to set hooks for the rest of the system
1244
-     *
1245
-     * @access private
1246
-     * @return void
1247
-     */
1248
-    private function _initialize_modules()
1249
-    {
1250
-        // cycle thru shortcode folders
1251
-        foreach (EE_Registry::instance()->modules as $module_class => $module_path) {
1252
-            // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1253
-            // which set hooks ?
1254
-            if (is_admin()) {
1255
-                // fire immediately
1256
-                call_user_func(array($module_class, 'set_hooks_admin'));
1257
-            } else {
1258
-                // delay until other systems are online
1259
-                add_action(
1260
-                    'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
1261
-                    array($module_class, 'set_hooks')
1262
-                );
1263
-            }
1264
-        }
1265
-    }
1266
-
1267
-
1268
-
1269
-    /**
1270
-     *    register_route - adds module method routes to route_map
1271
-     *
1272
-     * @access    public
1273
-     * @param    string $route       - "pretty" public alias for module method
1274
-     * @param    string $module      - module name (classname without EED_ prefix)
1275
-     * @param    string $method_name - the actual module method to be routed to
1276
-     * @param    string $key         - url param key indicating a route is being called
1277
-     * @return    bool
1278
-     */
1279
-    public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee')
1280
-    {
1281
-        do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1282
-        $module = str_replace('EED_', '', $module);
1283
-        $module_class = 'EED_' . $module;
1284
-        if (! isset(EE_Registry::instance()->modules->{$module_class})) {
1285
-            $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module);
1286
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1287
-            return false;
1288
-        }
1289
-        if (empty($route)) {
1290
-            $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route);
1291
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1292
-            return false;
1293
-        }
1294
-        if (! method_exists('EED_' . $module, $method_name)) {
1295
-            $msg = sprintf(
1296
-                __('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1297
-                $route
1298
-            );
1299
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1300
-            return false;
1301
-        }
1302
-        EE_Config::$_module_route_map[$key][$route] = array('EED_' . $module, $method_name);
1303
-        return true;
1304
-    }
1305
-
1306
-
1307
-
1308
-    /**
1309
-     *    get_route - get module method route
1310
-     *
1311
-     * @access    public
1312
-     * @param    string $route - "pretty" public alias for module method
1313
-     * @param    string $key   - url param key indicating a route is being called
1314
-     * @return    string
1315
-     */
1316
-    public static function get_route($route = null, $key = 'ee')
1317
-    {
1318
-        do_action('AHEE__EE_Config__get_route__begin', $route);
1319
-        $route = (string)apply_filters('FHEE__EE_Config__get_route', $route);
1320
-        if (isset(EE_Config::$_module_route_map[$key][$route])) {
1321
-            return EE_Config::$_module_route_map[$key][$route];
1322
-        }
1323
-        return null;
1324
-    }
1325
-
1326
-
1327
-
1328
-    /**
1329
-     *    get_routes - get ALL module method routes
1330
-     *
1331
-     * @access    public
1332
-     * @return    array
1333
-     */
1334
-    public static function get_routes()
1335
-    {
1336
-        return EE_Config::$_module_route_map;
1337
-    }
1338
-
1339
-
1340
-
1341
-    /**
1342
-     *    register_forward - allows modules to forward request to another module for further processing
1343
-     *
1344
-     * @access    public
1345
-     * @param    string       $route   - "pretty" public alias for module method
1346
-     * @param    integer      $status  - integer value corresponding  to status constant strings set in module parent
1347
-     *                                 class, allows different forwards to be served based on status
1348
-     * @param    array|string $forward - function name or array( class, method )
1349
-     * @param    string       $key     - url param key indicating a route is being called
1350
-     * @return    bool
1351
-     */
1352
-    public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee')
1353
-    {
1354
-        do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1355
-        if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1356
-            $msg = sprintf(
1357
-                __('The module route %s for this forward has not been registered.', 'event_espresso'),
1358
-                $route
1359
-            );
1360
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1361
-            return false;
1362
-        }
1363
-        if (empty($forward)) {
1364
-            $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route);
1365
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1366
-            return false;
1367
-        }
1368
-        if (is_array($forward)) {
1369
-            if (! isset($forward[1])) {
1370
-                $msg = sprintf(
1371
-                    __('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1372
-                    $route
1373
-                );
1374
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1375
-                return false;
1376
-            }
1377
-            if (! method_exists($forward[0], $forward[1])) {
1378
-                $msg = sprintf(
1379
-                    __('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1380
-                    $forward[1],
1381
-                    $route
1382
-                );
1383
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1384
-                return false;
1385
-            }
1386
-        } else if (! function_exists($forward)) {
1387
-            $msg = sprintf(
1388
-                __('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1389
-                $forward,
1390
-                $route
1391
-            );
1392
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1393
-            return false;
1394
-        }
1395
-        EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward;
1396
-        return true;
1397
-    }
1398
-
1399
-
1400
-
1401
-    /**
1402
-     *    get_forward - get forwarding route
1403
-     *
1404
-     * @access    public
1405
-     * @param    string  $route  - "pretty" public alias for module method
1406
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1407
-     *                           allows different forwards to be served based on status
1408
-     * @param    string  $key    - url param key indicating a route is being called
1409
-     * @return    string
1410
-     */
1411
-    public static function get_forward($route = null, $status = 0, $key = 'ee')
1412
-    {
1413
-        do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1414
-        if (isset(EE_Config::$_module_forward_map[$key][$route][$status])) {
1415
-            return apply_filters(
1416
-                'FHEE__EE_Config__get_forward',
1417
-                EE_Config::$_module_forward_map[$key][$route][$status],
1418
-                $route,
1419
-                $status
1420
-            );
1421
-        }
1422
-        return null;
1423
-    }
1424
-
1425
-
1426
-
1427
-    /**
1428
-     *    register_forward - allows modules to specify different view templates for different method routes and status
1429
-     *    results
1430
-     *
1431
-     * @access    public
1432
-     * @param    string  $route  - "pretty" public alias for module method
1433
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1434
-     *                           allows different views to be served based on status
1435
-     * @param    string  $view
1436
-     * @param    string  $key    - url param key indicating a route is being called
1437
-     * @return    bool
1438
-     */
1439
-    public static function register_view($route = null, $status = 0, $view = null, $key = 'ee')
1440
-    {
1441
-        do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1442
-        if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1443
-            $msg = sprintf(
1444
-                __('The module route %s for this view has not been registered.', 'event_espresso'),
1445
-                $route
1446
-            );
1447
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1448
-            return false;
1449
-        }
1450
-        if (! is_readable($view)) {
1451
-            $msg = sprintf(
1452
-                __(
1453
-                    'The %s view file could not be found or is not readable due to file permissions.',
1454
-                    'event_espresso'
1455
-                ),
1456
-                $view
1457
-            );
1458
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1459
-            return false;
1460
-        }
1461
-        EE_Config::$_module_view_map[$key][$route][absint($status)] = $view;
1462
-        return true;
1463
-    }
1464
-
1465
-
1466
-
1467
-    /**
1468
-     *    get_view - get view for route and status
1469
-     *
1470
-     * @access    public
1471
-     * @param    string  $route  - "pretty" public alias for module method
1472
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1473
-     *                           allows different views to be served based on status
1474
-     * @param    string  $key    - url param key indicating a route is being called
1475
-     * @return    string
1476
-     */
1477
-    public static function get_view($route = null, $status = 0, $key = 'ee')
1478
-    {
1479
-        do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1480
-        if (isset(EE_Config::$_module_view_map[$key][$route][$status])) {
1481
-            return apply_filters(
1482
-                'FHEE__EE_Config__get_view',
1483
-                EE_Config::$_module_view_map[$key][$route][$status],
1484
-                $route,
1485
-                $status
1486
-            );
1487
-        }
1488
-        return null;
1489
-    }
1490
-
1491
-
1492
-
1493
-    public function update_addon_option_names()
1494
-    {
1495
-        update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names);
1496
-    }
1497
-
1498
-
1499
-
1500
-    public function shutdown()
1501
-    {
1502
-        $this->update_addon_option_names();
1503
-    }
1504
-
1505
-
1506
-
1507
-    /**
1508
-     * @return LegacyShortcodesManager
1509
-     */
1510
-    public static function getLegacyShortcodesManager()
1511
-    {
1512
-
1513
-        if ( ! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) {
1514
-            EE_Config::instance()->legacy_shortcodes_manager = new LegacyShortcodesManager(
1515
-                EE_Registry::instance()
1516
-            );
1517
-        }
1518
-        return EE_Config::instance()->legacy_shortcodes_manager;
1519
-    }
1520
-
1521
-
1522
-
1523
-    /**
1524
-     * register_shortcode - makes core aware of this shortcode
1525
-     *
1526
-     * @deprecated 4.9.26
1527
-     * @param    string $shortcode_path - full path up to and including shortcode folder
1528
-     * @return    bool
1529
-     */
1530
-    public static function register_shortcode($shortcode_path = null)
1531
-    {
1532
-        EE_Error::doing_it_wrong(
1533
-            __METHOD__,
1534
-            __(
1535
-                'Usage is deprecated. Use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::registerShortcode() as direct replacement, or better yet, please see the new \EventEspresso\core\services\shortcodes\ShortcodesManager class.',
1536
-                'event_espresso'
1537
-            ),
1538
-            '4.9.26'
1539
-        );
1540
-        return EE_Config::instance()->getLegacyShortcodesManager()->registerShortcode($shortcode_path);
1541
-    }
1542
-
1543
-
1544
-
1545
-}
1546
-
1547
-
1548
-
1549
-/**
1550
- * Base class used for config classes. These classes should generally not have
1551
- * magic functions in use, except we'll allow them to magically set and get stuff...
1552
- * basically, they should just be well-defined stdClasses
1553
- */
1554
-class EE_Config_Base
1555
-{
1556
-
1557
-    /**
1558
-     * Utility function for escaping the value of a property and returning.
1559
-     *
1560
-     * @param string $property property name (checks to see if exists).
1561
-     * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1562
-     * @throws \EE_Error
1563
-     */
1564
-    public function get_pretty($property)
1565
-    {
1566
-        if (! property_exists($this, $property)) {
1567
-            throw new EE_Error(
1568
-                sprintf(
1569
-                    __(
1570
-                        '%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.',
1571
-                        'event_espresso'
1572
-                    ),
1573
-                    get_class($this),
1574
-                    $property
1575
-                )
1576
-            );
1577
-        }
1578
-        //just handling escaping of strings for now.
1579
-        if (is_string($this->{$property})) {
1580
-            return stripslashes($this->{$property});
1581
-        }
1582
-        return $this->{$property};
1583
-    }
1584
-
1585
-
1586
-
1587
-    public function populate()
1588
-    {
1589
-        //grab defaults via a new instance of this class.
1590
-        $class_name = get_class($this);
1591
-        $defaults = new $class_name;
1592
-        //loop through the properties for this class and see if they are set.  If they are NOT, then grab the
1593
-        //default from our $defaults object.
1594
-        foreach (get_object_vars($defaults) as $property => $value) {
1595
-            if ($this->{$property} === null) {
1596
-                $this->{$property} = $value;
1597
-            }
1598
-        }
1599
-        //cleanup
1600
-        unset($defaults);
1601
-    }
1602
-
1603
-
1604
-
1605
-    /**
1606
-     *        __isset
1607
-     *
1608
-     * @param $a
1609
-     * @return bool
1610
-     */
1611
-    public function __isset($a)
1612
-    {
1613
-        return false;
1614
-    }
1615
-
1616
-
1617
-
1618
-    /**
1619
-     *        __unset
1620
-     *
1621
-     * @param $a
1622
-     * @return bool
1623
-     */
1624
-    public function __unset($a)
1625
-    {
1626
-        return false;
1627
-    }
1628
-
1629
-
1630
-
1631
-    /**
1632
-     *        __clone
1633
-     */
1634
-    public function __clone()
1635
-    {
1636
-    }
1637
-
1638
-
1639
-
1640
-    /**
1641
-     *        __wakeup
1642
-     */
1643
-    public function __wakeup()
1644
-    {
1645
-    }
1646
-
1647
-
1648
-
1649
-    /**
1650
-     *        __destruct
1651
-     */
1652
-    public function __destruct()
1653
-    {
1654
-    }
1655
-}
1656
-
1657
-
1658
-
1659
-/**
1660
- * Class for defining what's in the EE_Config relating to registration settings
1661
- */
1662
-class EE_Core_Config extends EE_Config_Base
1663
-{
1664
-
1665
-    public $current_blog_id;
1666
-
1667
-    public $ee_ueip_optin;
1668
-
1669
-    public $ee_ueip_has_notified;
1670
-
1671
-    /**
1672
-     * Not to be confused with the 4 critical page variables (See
1673
-     * get_critical_pages_array()), this is just an array of wp posts that have EE
1674
-     * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode
1675
-     * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array.
1676
-     *
1677
-     * @var array
1678
-     */
1679
-    public $post_shortcodes;
1680
-
1681
-    public $module_route_map;
1682
-
1683
-    public $module_forward_map;
1684
-
1685
-    public $module_view_map;
1686
-
1687
-    /**
1688
-     * The next 4 vars are the IDs of critical EE pages.
1689
-     *
1690
-     * @var int
1691
-     */
1692
-    public $reg_page_id;
1693
-
1694
-    public $txn_page_id;
1695
-
1696
-    public $thank_you_page_id;
1697
-
1698
-    public $cancel_page_id;
1699
-
1700
-    /**
1701
-     * The next 4 vars are the URLs of critical EE pages.
1702
-     *
1703
-     * @var int
1704
-     */
1705
-    public $reg_page_url;
1706
-
1707
-    public $txn_page_url;
1708
-
1709
-    public $thank_you_page_url;
1710
-
1711
-    public $cancel_page_url;
1712
-
1713
-    /**
1714
-     * The next vars relate to the custom slugs for EE CPT routes
1715
-     */
1716
-    public $event_cpt_slug;
1717
-
1718
-
1719
-    /**
1720
-     * This caches the _ee_ueip_option in case this config is reset in the same
1721
-     * request across blog switches in a multisite context.
1722
-     * Avoids extra queries to the db for this option.
1723
-     *
1724
-     * @var bool
1725
-     */
1726
-    public static $ee_ueip_option;
1727
-
1728
-
1729
-
1730
-    /**
1731
-     *    class constructor
1732
-     *
1733
-     * @access    public
1734
-     */
1735
-    public function __construct()
1736
-    {
1737
-        // set default organization settings
1738
-        $this->current_blog_id = get_current_blog_id();
1739
-        $this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id;
1740
-        $this->ee_ueip_optin = $this->_get_main_ee_ueip_optin();
1741
-        $this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true;
1742
-        $this->post_shortcodes = array();
1743
-        $this->module_route_map = array();
1744
-        $this->module_forward_map = array();
1745
-        $this->module_view_map = array();
1746
-        // critical EE page IDs
1747
-        $this->reg_page_id = 0;
1748
-        $this->txn_page_id = 0;
1749
-        $this->thank_you_page_id = 0;
1750
-        $this->cancel_page_id = 0;
1751
-        // critical EE page URLs
1752
-        $this->reg_page_url = '';
1753
-        $this->txn_page_url = '';
1754
-        $this->thank_you_page_url = '';
1755
-        $this->cancel_page_url = '';
1756
-        //cpt slugs
1757
-        $this->event_cpt_slug = __('events', 'event_espresso');
1758
-        //ueip constant check
1759
-        if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) {
1760
-            $this->ee_ueip_optin = false;
1761
-            $this->ee_ueip_has_notified = true;
1762
-        }
1763
-    }
1764
-
1765
-
1766
-
1767
-    /**
1768
-     * @return array
1769
-     */
1770
-    public function get_critical_pages_array()
1771
-    {
1772
-        return array(
1773
-            $this->reg_page_id,
1774
-            $this->txn_page_id,
1775
-            $this->thank_you_page_id,
1776
-            $this->cancel_page_id,
1777
-        );
1778
-    }
1779
-
1780
-
1781
-
1782
-    /**
1783
-     * @return array
1784
-     */
1785
-    public function get_critical_pages_shortcodes_array()
1786
-    {
1787
-        return array(
1788
-            $this->reg_page_id       => 'ESPRESSO_CHECKOUT',
1789
-            $this->txn_page_id       => 'ESPRESSO_TXN_PAGE',
1790
-            $this->thank_you_page_id => 'ESPRESSO_THANK_YOU',
1791
-            $this->cancel_page_id    => 'ESPRESSO_CANCELLED',
1792
-        );
1793
-    }
1794
-
1795
-
1796
-
1797
-    /**
1798
-     *  gets/returns URL for EE reg_page
1799
-     *
1800
-     * @access    public
1801
-     * @return    string
1802
-     */
1803
-    public function reg_page_url()
1804
-    {
1805
-        if (! $this->reg_page_url) {
1806
-            $this->reg_page_url = add_query_arg(
1807
-                                      array('uts' => time()),
1808
-                                      get_permalink($this->reg_page_id)
1809
-                                  ) . '#checkout';
1810
-        }
1811
-        return $this->reg_page_url;
1812
-    }
1813
-
1814
-
1815
-
1816
-    /**
1817
-     *  gets/returns URL for EE txn_page
1818
-     *
1819
-     * @param array $query_args like what gets passed to
1820
-     *                          add_query_arg() as the first argument
1821
-     * @access    public
1822
-     * @return    string
1823
-     */
1824
-    public function txn_page_url($query_args = array())
1825
-    {
1826
-        if (! $this->txn_page_url) {
1827
-            $this->txn_page_url = get_permalink($this->txn_page_id);
1828
-        }
1829
-        if ($query_args) {
1830
-            return add_query_arg($query_args, $this->txn_page_url);
1831
-        } else {
1832
-            return $this->txn_page_url;
1833
-        }
1834
-    }
1835
-
1836
-
1837
-
1838
-    /**
1839
-     *  gets/returns URL for EE thank_you_page
1840
-     *
1841
-     * @param array $query_args like what gets passed to
1842
-     *                          add_query_arg() as the first argument
1843
-     * @access    public
1844
-     * @return    string
1845
-     */
1846
-    public function thank_you_page_url($query_args = array())
1847
-    {
1848
-        if (! $this->thank_you_page_url) {
1849
-            $this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1850
-        }
1851
-        if ($query_args) {
1852
-            return add_query_arg($query_args, $this->thank_you_page_url);
1853
-        } else {
1854
-            return $this->thank_you_page_url;
1855
-        }
1856
-    }
1857
-
1858
-
1859
-
1860
-    /**
1861
-     *  gets/returns URL for EE cancel_page
1862
-     *
1863
-     * @access    public
1864
-     * @return    string
1865
-     */
1866
-    public function cancel_page_url()
1867
-    {
1868
-        if (! $this->cancel_page_url) {
1869
-            $this->cancel_page_url = get_permalink($this->cancel_page_id);
1870
-        }
1871
-        return $this->cancel_page_url;
1872
-    }
1873
-
1874
-
1875
-
1876
-    /**
1877
-     * Resets all critical page urls to their original state.  Used primarily by the __sleep() magic method currently.
1878
-     *
1879
-     * @since 4.7.5
1880
-     */
1881
-    protected function _reset_urls()
1882
-    {
1883
-        $this->reg_page_url = '';
1884
-        $this->txn_page_url = '';
1885
-        $this->cancel_page_url = '';
1886
-        $this->thank_you_page_url = '';
1887
-    }
1888
-
1889
-
1890
-
1891
-    /**
1892
-     * Used to return what the optin value is set for the EE User Experience Program.
1893
-     * This accounts for multisite and this value being requested for a subsite.  In multisite, the value is set
1894
-     * on the main site only.
1895
-     *
1896
-     * @return mixed|void
1897
-     */
1898
-    protected function _get_main_ee_ueip_optin()
1899
-    {
1900
-        //if this is the main site then we can just bypass our direct query.
1901
-        if (is_main_site()) {
1902
-            return get_option('ee_ueip_optin', false);
1903
-        }
1904
-        //is this already cached for this request?  If so use it.
1905
-        if ( ! empty(EE_Core_Config::$ee_ueip_option)) {
1906
-            return EE_Core_Config::$ee_ueip_option;
1907
-        }
1908
-        global $wpdb;
1909
-        $current_network_main_site = is_multisite() ? get_current_site() : null;
1910
-        $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1911
-        $option = 'ee_ueip_optin';
1912
-        //set correct table for query
1913
-        $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1914
-        //rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
1915
-        //get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be
1916
-        //re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1917
-        //this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1918
-        //for the purpose of caching.
1919
-        $pre = apply_filters('pre_option_' . $option, false, $option);
1920
-        if (false !== $pre) {
1921
-            EE_Core_Config::$ee_ueip_option = $pre;
1922
-            return EE_Core_Config::$ee_ueip_option;
1923
-        }
1924
-        $row = $wpdb->get_row($wpdb->prepare("SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1",
1925
-            $option));
1926
-        if (is_object($row)) {
1927
-            $value = $row->option_value;
1928
-        } else { //option does not exist so use default.
1929
-            return apply_filters('default_option_' . $option, false, $option);
1930
-        }
1931
-        EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
1932
-        return EE_Core_Config::$ee_ueip_option;
1933
-    }
1934
-
1935
-
1936
-
1937
-    /**
1938
-     * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values
1939
-     * on the object.
1940
-     *
1941
-     * @return array
1942
-     */
1943
-    public function __sleep()
1944
-    {
1945
-        //reset all url properties
1946
-        $this->_reset_urls();
1947
-        //return what to save to db
1948
-        return array_keys(get_object_vars($this));
1949
-    }
1950
-
1951
-}
1952
-
1953
-
1954
-
1955
-/**
1956
- * Config class for storing info on the Organization
1957
- */
1958
-class EE_Organization_Config extends EE_Config_Base
1959
-{
1960
-
1961
-    /**
1962
-     * @var string $name
1963
-     * eg EE4.1
1964
-     */
1965
-    public $name;
1966
-
1967
-    /**
1968
-     * @var string $address_1
1969
-     * eg 123 Onna Road
1970
-     */
1971
-    public $address_1;
1972
-
1973
-    /**
1974
-     * @var string $address_2
1975
-     * eg PO Box 123
1976
-     */
1977
-    public $address_2;
1978
-
1979
-    /**
1980
-     * @var string $city
1981
-     * eg Inna City
1982
-     */
1983
-    public $city;
1984
-
1985
-    /**
1986
-     * @var int $STA_ID
1987
-     * eg 4
1988
-     */
1989
-    public $STA_ID;
1990
-
1991
-    /**
1992
-     * @var string $CNT_ISO
1993
-     * eg US
1994
-     */
1995
-    public $CNT_ISO;
1996
-
1997
-    /**
1998
-     * @var string $zip
1999
-     * eg 12345  or V1A 2B3
2000
-     */
2001
-    public $zip;
2002
-
2003
-    /**
2004
-     * @var string $email
2005
-     * eg [email protected]
2006
-     */
2007
-    public $email;
2008
-
2009
-
2010
-    /**
2011
-     * @var string $phone
2012
-     * eg. 111-111-1111
2013
-     */
2014
-    public $phone;
2015
-
2016
-
2017
-    /**
2018
-     * @var string $vat
2019
-     * VAT/Tax Number
2020
-     */
2021
-    public $vat;
2022
-
2023
-    /**
2024
-     * @var string $logo_url
2025
-     * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg
2026
-     */
2027
-    public $logo_url;
2028
-
2029
-
2030
-    /**
2031
-     * The below are all various properties for holding links to organization social network profiles
2032
-     *
2033
-     * @var string
2034
-     */
2035
-    /**
2036
-     * facebook (facebook.com/profile.name)
2037
-     *
2038
-     * @var string
2039
-     */
2040
-    public $facebook;
2041
-
2042
-
2043
-    /**
2044
-     * twitter (twitter.com/twitter_handle)
2045
-     *
2046
-     * @var string
2047
-     */
2048
-    public $twitter;
2049
-
2050
-
2051
-    /**
2052
-     * linkedin (linkedin.com/in/profile_name)
2053
-     *
2054
-     * @var string
2055
-     */
2056
-    public $linkedin;
2057
-
2058
-
2059
-    /**
2060
-     * pinterest (www.pinterest.com/profile_name)
2061
-     *
2062
-     * @var string
2063
-     */
2064
-    public $pinterest;
2065
-
2066
-
2067
-    /**
2068
-     * google+ (google.com/+profileName)
2069
-     *
2070
-     * @var string
2071
-     */
2072
-    public $google;
2073
-
2074
-
2075
-    /**
2076
-     * instagram (instagram.com/handle)
2077
-     *
2078
-     * @var string
2079
-     */
2080
-    public $instagram;
2081
-
2082
-
2083
-
2084
-    /**
2085
-     *    class constructor
2086
-     *
2087
-     * @access    public
2088
-     */
2089
-    public function __construct()
2090
-    {
2091
-        // set default organization settings
2092
-        $this->name = get_bloginfo('name');
2093
-        $this->address_1 = '123 Onna Road';
2094
-        $this->address_2 = 'PO Box 123';
2095
-        $this->city = 'Inna City';
2096
-        $this->STA_ID = 4;
2097
-        $this->CNT_ISO = 'US';
2098
-        $this->zip = '12345';
2099
-        $this->email = get_bloginfo('admin_email');
2100
-        $this->phone = '';
2101
-        $this->vat = '123456789';
2102
-        $this->logo_url = '';
2103
-        $this->facebook = '';
2104
-        $this->twitter = '';
2105
-        $this->linkedin = '';
2106
-        $this->pinterest = '';
2107
-        $this->google = '';
2108
-        $this->instagram = '';
2109
-    }
2110
-
2111
-}
2112
-
2113
-
2114
-
2115
-/**
2116
- * Class for defining what's in the EE_Config relating to currency
2117
- */
2118
-class EE_Currency_Config extends EE_Config_Base
2119
-{
2120
-
2121
-    /**
2122
-     * @var string $code
2123
-     * eg 'US'
2124
-     */
2125
-    public $code;
2126
-
2127
-    /**
2128
-     * @var string $name
2129
-     * eg 'Dollar'
2130
-     */
2131
-    public $name;
2132
-
2133
-    /**
2134
-     * plural name
2135
-     *
2136
-     * @var string $plural
2137
-     * eg 'Dollars'
2138
-     */
2139
-    public $plural;
2140
-
2141
-    /**
2142
-     * currency sign
2143
-     *
2144
-     * @var string $sign
2145
-     * eg '$'
2146
-     */
2147
-    public $sign;
2148
-
2149
-    /**
2150
-     * Whether the currency sign should come before the number or not
2151
-     *
2152
-     * @var boolean $sign_b4
2153
-     */
2154
-    public $sign_b4;
2155
-
2156
-    /**
2157
-     * How many digits should come after the decimal place
2158
-     *
2159
-     * @var int $dec_plc
2160
-     */
2161
-    public $dec_plc;
2162
-
2163
-    /**
2164
-     * Symbol to use for decimal mark
2165
-     *
2166
-     * @var string $dec_mrk
2167
-     * eg '.'
2168
-     */
2169
-    public $dec_mrk;
2170
-
2171
-    /**
2172
-     * Symbol to use for thousands
2173
-     *
2174
-     * @var string $thsnds
2175
-     * eg ','
2176
-     */
2177
-    public $thsnds;
2178
-
2179
-
2180
-
2181
-    /**
2182
-     *    class constructor
2183
-     *
2184
-     * @access    public
2185
-     * @param string $CNT_ISO
2186
-     * @throws \EE_Error
2187
-     */
2188
-    public function __construct($CNT_ISO = '')
2189
-    {
2190
-        /** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */
2191
-        $table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
2192
-        // get country code from organization settings or use default
2193
-        $ORG_CNT = isset(EE_Registry::instance()->CFG->organization)
2194
-                   && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config
2195
-            ? EE_Registry::instance()->CFG->organization->CNT_ISO
2196
-            : '';
2197
-        // but override if requested
2198
-        $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT;
2199
-        // so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists
2200
-        if (
2201
-            ! empty($CNT_ISO)
2202
-            && EE_Maintenance_Mode::instance()->models_can_query()
2203
-            && $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table())
2204
-        ) {
2205
-            // retrieve the country settings from the db, just in case they have been customized
2206
-            $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
2207
-            if ($country instanceof EE_Country) {
2208
-                $this->code = $country->currency_code();    // currency code: USD, CAD, EUR
2209
-                $this->name = $country->currency_name_single();    // Dollar
2210
-                $this->plural = $country->currency_name_plural();    // Dollars
2211
-                $this->sign = $country->currency_sign();            // currency sign: $
2212
-                $this->sign_b4 = $country->currency_sign_before();        // currency sign before or after: $TRUE  or  FALSE$
2213
-                $this->dec_plc = $country->currency_decimal_places();    // decimal places: 2 = 0.00  3 = 0.000
2214
-                $this->dec_mrk = $country->currency_decimal_mark();    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2215
-                $this->thsnds = $country->currency_thousands_separator();    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2216
-            }
2217
-        }
2218
-        // fallback to hardcoded defaults, in case the above failed
2219
-        if (empty($this->code)) {
2220
-            // set default currency settings
2221
-            $this->code = 'USD';    // currency code: USD, CAD, EUR
2222
-            $this->name = __('Dollar', 'event_espresso');    // Dollar
2223
-            $this->plural = __('Dollars', 'event_espresso');    // Dollars
2224
-            $this->sign = '$';    // currency sign: $
2225
-            $this->sign_b4 = true;    // currency sign before or after: $TRUE  or  FALSE$
2226
-            $this->dec_plc = 2;    // decimal places: 2 = 0.00  3 = 0.000
2227
-            $this->dec_mrk = '.';    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2228
-            $this->thsnds = ',';    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2229
-        }
2230
-    }
2231
-}
2232
-
2233
-
2234
-
2235
-/**
2236
- * Class for defining what's in the EE_Config relating to registration settings
2237
- */
2238
-class EE_Registration_Config extends EE_Config_Base
2239
-{
2240
-
2241
-    /**
2242
-     * Default registration status
2243
-     *
2244
-     * @var string $default_STS_ID
2245
-     * eg 'RPP'
2246
-     */
2247
-    public $default_STS_ID;
2248
-
2249
-
2250
-    /**
2251
-     * For new events, this will be the default value for the maximum number of tickets (equivalent to maximum number of
2252
-     * registrations)
2253
-     * @var int
2254
-     */
2255
-    public $default_maximum_number_of_tickets;
2256
-
2257
-
2258
-    /**
2259
-     * level of validation to apply to email addresses
2260
-     *
2261
-     * @var string $email_validation_level
2262
-     * options: 'basic', 'wp_default', 'i18n', 'i18n_dns'
2263
-     */
2264
-    public $email_validation_level;
2265
-
2266
-    /**
2267
-     *    whether or not to show alternate payment options during the reg process if payment status is pending
2268
-     *
2269
-     * @var boolean $show_pending_payment_options
2270
-     */
2271
-    public $show_pending_payment_options;
2272
-
2273
-    /**
2274
-     * Whether to skip the registration confirmation page
2275
-     *
2276
-     * @var boolean $skip_reg_confirmation
2277
-     */
2278
-    public $skip_reg_confirmation;
2279
-
2280
-    /**
2281
-     * an array of SPCO reg steps where:
2282
-     *        the keys denotes the reg step order
2283
-     *        each element consists of an array with the following elements:
2284
-     *            "file_path" => the file path to the EE_SPCO_Reg_Step class
2285
-     *            "class_name" => the specific EE_SPCO_Reg_Step child class name
2286
-     *            "slug" => the URL param used to trigger the reg step
2287
-     *
2288
-     * @var array $reg_steps
2289
-     */
2290
-    public $reg_steps;
2291
-
2292
-    /**
2293
-     * Whether registration confirmation should be the last page of SPCO
2294
-     *
2295
-     * @var boolean $reg_confirmation_last
2296
-     */
2297
-    public $reg_confirmation_last;
2298
-
2299
-    /**
2300
-     * Whether or not to enable the EE Bot Trap
2301
-     *
2302
-     * @var boolean $use_bot_trap
2303
-     */
2304
-    public $use_bot_trap;
2305
-
2306
-    /**
2307
-     * Whether or not to encrypt some data sent by the EE Bot Trap
2308
-     *
2309
-     * @var boolean $use_encryption
2310
-     */
2311
-    public $use_encryption;
1545
+}
2312 1546
 
2313
-    /**
2314
-     * Whether or not to use ReCaptcha
2315
-     *
2316
-     * @var boolean $use_captcha
2317
-     */
2318
-    public $use_captcha;
2319 1547
 
2320
-    /**
2321
-     * ReCaptcha Theme
2322
-     *
2323
-     * @var string $recaptcha_theme
2324
-     *    options: 'dark    ', 'light'
2325
-     */
2326
-    public $recaptcha_theme;
2327 1548
 
2328
-    /**
2329
-     * ReCaptcha Type
2330
-     *
2331
-     * @var string $recaptcha_type
2332
-     *    options: 'audio', 'image'
2333
-     */
2334
-    public $recaptcha_type;
1549
+/**
1550
+ * Base class used for config classes. These classes should generally not have
1551
+ * magic functions in use, except we'll allow them to magically set and get stuff...
1552
+ * basically, they should just be well-defined stdClasses
1553
+ */
1554
+class EE_Config_Base
1555
+{
2335 1556
 
2336
-    /**
2337
-     * ReCaptcha language
2338
-     *
2339
-     * @var string $recaptcha_language
2340
-     * eg 'en'
2341
-     */
2342
-    public $recaptcha_language;
1557
+	/**
1558
+	 * Utility function for escaping the value of a property and returning.
1559
+	 *
1560
+	 * @param string $property property name (checks to see if exists).
1561
+	 * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1562
+	 * @throws \EE_Error
1563
+	 */
1564
+	public function get_pretty($property)
1565
+	{
1566
+		if (! property_exists($this, $property)) {
1567
+			throw new EE_Error(
1568
+				sprintf(
1569
+					__(
1570
+						'%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.',
1571
+						'event_espresso'
1572
+					),
1573
+					get_class($this),
1574
+					$property
1575
+				)
1576
+			);
1577
+		}
1578
+		//just handling escaping of strings for now.
1579
+		if (is_string($this->{$property})) {
1580
+			return stripslashes($this->{$property});
1581
+		}
1582
+		return $this->{$property};
1583
+	}
1584
+
1585
+
1586
+
1587
+	public function populate()
1588
+	{
1589
+		//grab defaults via a new instance of this class.
1590
+		$class_name = get_class($this);
1591
+		$defaults = new $class_name;
1592
+		//loop through the properties for this class and see if they are set.  If they are NOT, then grab the
1593
+		//default from our $defaults object.
1594
+		foreach (get_object_vars($defaults) as $property => $value) {
1595
+			if ($this->{$property} === null) {
1596
+				$this->{$property} = $value;
1597
+			}
1598
+		}
1599
+		//cleanup
1600
+		unset($defaults);
1601
+	}
1602
+
1603
+
1604
+
1605
+	/**
1606
+	 *        __isset
1607
+	 *
1608
+	 * @param $a
1609
+	 * @return bool
1610
+	 */
1611
+	public function __isset($a)
1612
+	{
1613
+		return false;
1614
+	}
1615
+
1616
+
1617
+
1618
+	/**
1619
+	 *        __unset
1620
+	 *
1621
+	 * @param $a
1622
+	 * @return bool
1623
+	 */
1624
+	public function __unset($a)
1625
+	{
1626
+		return false;
1627
+	}
1628
+
1629
+
1630
+
1631
+	/**
1632
+	 *        __clone
1633
+	 */
1634
+	public function __clone()
1635
+	{
1636
+	}
1637
+
1638
+
1639
+
1640
+	/**
1641
+	 *        __wakeup
1642
+	 */
1643
+	public function __wakeup()
1644
+	{
1645
+	}
1646
+
1647
+
1648
+
1649
+	/**
1650
+	 *        __destruct
1651
+	 */
1652
+	public function __destruct()
1653
+	{
1654
+	}
1655
+}
2343 1656
 
2344
-    /**
2345
-     * ReCaptcha public key
2346
-     *
2347
-     * @var string $recaptcha_publickey
2348
-     */
2349
-    public $recaptcha_publickey;
2350 1657
 
2351
-    /**
2352
-     * ReCaptcha private key
2353
-     *
2354
-     * @var string $recaptcha_privatekey
2355
-     */
2356
-    public $recaptcha_privatekey;
2357 1658
 
2358
-    /**
2359
-     * ReCaptcha width
2360
-     *
2361
-     * @var int $recaptcha_width
2362
-     * @deprecated
2363
-     */
2364
-    public $recaptcha_width;
1659
+/**
1660
+ * Class for defining what's in the EE_Config relating to registration settings
1661
+ */
1662
+class EE_Core_Config extends EE_Config_Base
1663
+{
2365 1664
 
2366
-    /**
2367
-     * Whether or not invalid attempts to directly access the registration checkout page should be tracked.
2368
-     *
2369
-     * @var boolean $track_invalid_checkout_access
2370
-     */
2371
-    protected $track_invalid_checkout_access = true;
1665
+	public $current_blog_id;
1666
+
1667
+	public $ee_ueip_optin;
1668
+
1669
+	public $ee_ueip_has_notified;
1670
+
1671
+	/**
1672
+	 * Not to be confused with the 4 critical page variables (See
1673
+	 * get_critical_pages_array()), this is just an array of wp posts that have EE
1674
+	 * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode
1675
+	 * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array.
1676
+	 *
1677
+	 * @var array
1678
+	 */
1679
+	public $post_shortcodes;
1680
+
1681
+	public $module_route_map;
1682
+
1683
+	public $module_forward_map;
1684
+
1685
+	public $module_view_map;
1686
+
1687
+	/**
1688
+	 * The next 4 vars are the IDs of critical EE pages.
1689
+	 *
1690
+	 * @var int
1691
+	 */
1692
+	public $reg_page_id;
1693
+
1694
+	public $txn_page_id;
1695
+
1696
+	public $thank_you_page_id;
1697
+
1698
+	public $cancel_page_id;
1699
+
1700
+	/**
1701
+	 * The next 4 vars are the URLs of critical EE pages.
1702
+	 *
1703
+	 * @var int
1704
+	 */
1705
+	public $reg_page_url;
1706
+
1707
+	public $txn_page_url;
1708
+
1709
+	public $thank_you_page_url;
1710
+
1711
+	public $cancel_page_url;
1712
+
1713
+	/**
1714
+	 * The next vars relate to the custom slugs for EE CPT routes
1715
+	 */
1716
+	public $event_cpt_slug;
1717
+
1718
+
1719
+	/**
1720
+	 * This caches the _ee_ueip_option in case this config is reset in the same
1721
+	 * request across blog switches in a multisite context.
1722
+	 * Avoids extra queries to the db for this option.
1723
+	 *
1724
+	 * @var bool
1725
+	 */
1726
+	public static $ee_ueip_option;
1727
+
1728
+
1729
+
1730
+	/**
1731
+	 *    class constructor
1732
+	 *
1733
+	 * @access    public
1734
+	 */
1735
+	public function __construct()
1736
+	{
1737
+		// set default organization settings
1738
+		$this->current_blog_id = get_current_blog_id();
1739
+		$this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id;
1740
+		$this->ee_ueip_optin = $this->_get_main_ee_ueip_optin();
1741
+		$this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true;
1742
+		$this->post_shortcodes = array();
1743
+		$this->module_route_map = array();
1744
+		$this->module_forward_map = array();
1745
+		$this->module_view_map = array();
1746
+		// critical EE page IDs
1747
+		$this->reg_page_id = 0;
1748
+		$this->txn_page_id = 0;
1749
+		$this->thank_you_page_id = 0;
1750
+		$this->cancel_page_id = 0;
1751
+		// critical EE page URLs
1752
+		$this->reg_page_url = '';
1753
+		$this->txn_page_url = '';
1754
+		$this->thank_you_page_url = '';
1755
+		$this->cancel_page_url = '';
1756
+		//cpt slugs
1757
+		$this->event_cpt_slug = __('events', 'event_espresso');
1758
+		//ueip constant check
1759
+		if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) {
1760
+			$this->ee_ueip_optin = false;
1761
+			$this->ee_ueip_has_notified = true;
1762
+		}
1763
+	}
1764
+
1765
+
1766
+
1767
+	/**
1768
+	 * @return array
1769
+	 */
1770
+	public function get_critical_pages_array()
1771
+	{
1772
+		return array(
1773
+			$this->reg_page_id,
1774
+			$this->txn_page_id,
1775
+			$this->thank_you_page_id,
1776
+			$this->cancel_page_id,
1777
+		);
1778
+	}
1779
+
1780
+
1781
+
1782
+	/**
1783
+	 * @return array
1784
+	 */
1785
+	public function get_critical_pages_shortcodes_array()
1786
+	{
1787
+		return array(
1788
+			$this->reg_page_id       => 'ESPRESSO_CHECKOUT',
1789
+			$this->txn_page_id       => 'ESPRESSO_TXN_PAGE',
1790
+			$this->thank_you_page_id => 'ESPRESSO_THANK_YOU',
1791
+			$this->cancel_page_id    => 'ESPRESSO_CANCELLED',
1792
+		);
1793
+	}
1794
+
1795
+
1796
+
1797
+	/**
1798
+	 *  gets/returns URL for EE reg_page
1799
+	 *
1800
+	 * @access    public
1801
+	 * @return    string
1802
+	 */
1803
+	public function reg_page_url()
1804
+	{
1805
+		if (! $this->reg_page_url) {
1806
+			$this->reg_page_url = add_query_arg(
1807
+									  array('uts' => time()),
1808
+									  get_permalink($this->reg_page_id)
1809
+								  ) . '#checkout';
1810
+		}
1811
+		return $this->reg_page_url;
1812
+	}
1813
+
1814
+
1815
+
1816
+	/**
1817
+	 *  gets/returns URL for EE txn_page
1818
+	 *
1819
+	 * @param array $query_args like what gets passed to
1820
+	 *                          add_query_arg() as the first argument
1821
+	 * @access    public
1822
+	 * @return    string
1823
+	 */
1824
+	public function txn_page_url($query_args = array())
1825
+	{
1826
+		if (! $this->txn_page_url) {
1827
+			$this->txn_page_url = get_permalink($this->txn_page_id);
1828
+		}
1829
+		if ($query_args) {
1830
+			return add_query_arg($query_args, $this->txn_page_url);
1831
+		} else {
1832
+			return $this->txn_page_url;
1833
+		}
1834
+	}
1835
+
1836
+
1837
+
1838
+	/**
1839
+	 *  gets/returns URL for EE thank_you_page
1840
+	 *
1841
+	 * @param array $query_args like what gets passed to
1842
+	 *                          add_query_arg() as the first argument
1843
+	 * @access    public
1844
+	 * @return    string
1845
+	 */
1846
+	public function thank_you_page_url($query_args = array())
1847
+	{
1848
+		if (! $this->thank_you_page_url) {
1849
+			$this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1850
+		}
1851
+		if ($query_args) {
1852
+			return add_query_arg($query_args, $this->thank_you_page_url);
1853
+		} else {
1854
+			return $this->thank_you_page_url;
1855
+		}
1856
+	}
1857
+
1858
+
1859
+
1860
+	/**
1861
+	 *  gets/returns URL for EE cancel_page
1862
+	 *
1863
+	 * @access    public
1864
+	 * @return    string
1865
+	 */
1866
+	public function cancel_page_url()
1867
+	{
1868
+		if (! $this->cancel_page_url) {
1869
+			$this->cancel_page_url = get_permalink($this->cancel_page_id);
1870
+		}
1871
+		return $this->cancel_page_url;
1872
+	}
1873
+
1874
+
1875
+
1876
+	/**
1877
+	 * Resets all critical page urls to their original state.  Used primarily by the __sleep() magic method currently.
1878
+	 *
1879
+	 * @since 4.7.5
1880
+	 */
1881
+	protected function _reset_urls()
1882
+	{
1883
+		$this->reg_page_url = '';
1884
+		$this->txn_page_url = '';
1885
+		$this->cancel_page_url = '';
1886
+		$this->thank_you_page_url = '';
1887
+	}
1888
+
1889
+
1890
+
1891
+	/**
1892
+	 * Used to return what the optin value is set for the EE User Experience Program.
1893
+	 * This accounts for multisite and this value being requested for a subsite.  In multisite, the value is set
1894
+	 * on the main site only.
1895
+	 *
1896
+	 * @return mixed|void
1897
+	 */
1898
+	protected function _get_main_ee_ueip_optin()
1899
+	{
1900
+		//if this is the main site then we can just bypass our direct query.
1901
+		if (is_main_site()) {
1902
+			return get_option('ee_ueip_optin', false);
1903
+		}
1904
+		//is this already cached for this request?  If so use it.
1905
+		if ( ! empty(EE_Core_Config::$ee_ueip_option)) {
1906
+			return EE_Core_Config::$ee_ueip_option;
1907
+		}
1908
+		global $wpdb;
1909
+		$current_network_main_site = is_multisite() ? get_current_site() : null;
1910
+		$current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1911
+		$option = 'ee_ueip_optin';
1912
+		//set correct table for query
1913
+		$table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1914
+		//rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
1915
+		//get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be
1916
+		//re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1917
+		//this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1918
+		//for the purpose of caching.
1919
+		$pre = apply_filters('pre_option_' . $option, false, $option);
1920
+		if (false !== $pre) {
1921
+			EE_Core_Config::$ee_ueip_option = $pre;
1922
+			return EE_Core_Config::$ee_ueip_option;
1923
+		}
1924
+		$row = $wpdb->get_row($wpdb->prepare("SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1",
1925
+			$option));
1926
+		if (is_object($row)) {
1927
+			$value = $row->option_value;
1928
+		} else { //option does not exist so use default.
1929
+			return apply_filters('default_option_' . $option, false, $option);
1930
+		}
1931
+		EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
1932
+		return EE_Core_Config::$ee_ueip_option;
1933
+	}
1934
+
1935
+
1936
+
1937
+	/**
1938
+	 * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values
1939
+	 * on the object.
1940
+	 *
1941
+	 * @return array
1942
+	 */
1943
+	public function __sleep()
1944
+	{
1945
+		//reset all url properties
1946
+		$this->_reset_urls();
1947
+		//return what to save to db
1948
+		return array_keys(get_object_vars($this));
1949
+	}
2372 1950
 
1951
+}
2373 1952
 
2374 1953
 
2375
-    /**
2376
-     *    class constructor
2377
-     *
2378
-     * @access    public
2379
-     */
2380
-    public function __construct()
2381
-    {
2382
-        // set default registration settings
2383
-        $this->default_STS_ID = EEM_Registration::status_id_pending_payment;
2384
-        $this->email_validation_level = 'wp_default';
2385
-        $this->show_pending_payment_options = true;
2386
-        $this->skip_reg_confirmation = false;
2387
-        $this->reg_steps = array();
2388
-        $this->reg_confirmation_last = false;
2389
-        $this->use_bot_trap = true;
2390
-        $this->use_encryption = true;
2391
-        $this->use_captcha = false;
2392
-        $this->recaptcha_theme = 'light';
2393
-        $this->recaptcha_type = 'image';
2394
-        $this->recaptcha_language = 'en';
2395
-        $this->recaptcha_publickey = null;
2396
-        $this->recaptcha_privatekey = null;
2397
-        $this->recaptcha_width = 500;
2398
-        $this->default_maximum_number_of_tickets = 10;
2399
-    }
2400
-
2401
-
2402
-
2403
-    /**
2404
-     * This is called by the config loader and hooks are initialized AFTER the config has been populated.
2405
-     *
2406
-     * @since 4.8.8.rc.019
2407
-     */
2408
-    public function do_hooks()
2409
-    {
2410
-        add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event'));
2411
-        add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_max_ticket_on_EEM_Event'));
2412
-    }
2413 1954
 
1955
+/**
1956
+ * Config class for storing info on the Organization
1957
+ */
1958
+class EE_Organization_Config extends EE_Config_Base
1959
+{
2414 1960
 
1961
+	/**
1962
+	 * @var string $name
1963
+	 * eg EE4.1
1964
+	 */
1965
+	public $name;
1966
+
1967
+	/**
1968
+	 * @var string $address_1
1969
+	 * eg 123 Onna Road
1970
+	 */
1971
+	public $address_1;
1972
+
1973
+	/**
1974
+	 * @var string $address_2
1975
+	 * eg PO Box 123
1976
+	 */
1977
+	public $address_2;
1978
+
1979
+	/**
1980
+	 * @var string $city
1981
+	 * eg Inna City
1982
+	 */
1983
+	public $city;
1984
+
1985
+	/**
1986
+	 * @var int $STA_ID
1987
+	 * eg 4
1988
+	 */
1989
+	public $STA_ID;
1990
+
1991
+	/**
1992
+	 * @var string $CNT_ISO
1993
+	 * eg US
1994
+	 */
1995
+	public $CNT_ISO;
1996
+
1997
+	/**
1998
+	 * @var string $zip
1999
+	 * eg 12345  or V1A 2B3
2000
+	 */
2001
+	public $zip;
2002
+
2003
+	/**
2004
+	 * @var string $email
2005
+	 * eg [email protected]
2006
+	 */
2007
+	public $email;
2008
+
2009
+
2010
+	/**
2011
+	 * @var string $phone
2012
+	 * eg. 111-111-1111
2013
+	 */
2014
+	public $phone;
2015
+
2016
+
2017
+	/**
2018
+	 * @var string $vat
2019
+	 * VAT/Tax Number
2020
+	 */
2021
+	public $vat;
2022
+
2023
+	/**
2024
+	 * @var string $logo_url
2025
+	 * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg
2026
+	 */
2027
+	public $logo_url;
2028
+
2029
+
2030
+	/**
2031
+	 * The below are all various properties for holding links to organization social network profiles
2032
+	 *
2033
+	 * @var string
2034
+	 */
2035
+	/**
2036
+	 * facebook (facebook.com/profile.name)
2037
+	 *
2038
+	 * @var string
2039
+	 */
2040
+	public $facebook;
2041
+
2042
+
2043
+	/**
2044
+	 * twitter (twitter.com/twitter_handle)
2045
+	 *
2046
+	 * @var string
2047
+	 */
2048
+	public $twitter;
2049
+
2050
+
2051
+	/**
2052
+	 * linkedin (linkedin.com/in/profile_name)
2053
+	 *
2054
+	 * @var string
2055
+	 */
2056
+	public $linkedin;
2057
+
2058
+
2059
+	/**
2060
+	 * pinterest (www.pinterest.com/profile_name)
2061
+	 *
2062
+	 * @var string
2063
+	 */
2064
+	public $pinterest;
2065
+
2066
+
2067
+	/**
2068
+	 * google+ (google.com/+profileName)
2069
+	 *
2070
+	 * @var string
2071
+	 */
2072
+	public $google;
2073
+
2074
+
2075
+	/**
2076
+	 * instagram (instagram.com/handle)
2077
+	 *
2078
+	 * @var string
2079
+	 */
2080
+	public $instagram;
2081
+
2082
+
2083
+
2084
+	/**
2085
+	 *    class constructor
2086
+	 *
2087
+	 * @access    public
2088
+	 */
2089
+	public function __construct()
2090
+	{
2091
+		// set default organization settings
2092
+		$this->name = get_bloginfo('name');
2093
+		$this->address_1 = '123 Onna Road';
2094
+		$this->address_2 = 'PO Box 123';
2095
+		$this->city = 'Inna City';
2096
+		$this->STA_ID = 4;
2097
+		$this->CNT_ISO = 'US';
2098
+		$this->zip = '12345';
2099
+		$this->email = get_bloginfo('admin_email');
2100
+		$this->phone = '';
2101
+		$this->vat = '123456789';
2102
+		$this->logo_url = '';
2103
+		$this->facebook = '';
2104
+		$this->twitter = '';
2105
+		$this->linkedin = '';
2106
+		$this->pinterest = '';
2107
+		$this->google = '';
2108
+		$this->instagram = '';
2109
+	}
2415 2110
 
2416
-    /**
2417
-     * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_default_registration_status
2418
-     * field matches the config setting for default_STS_ID.
2419
-     */
2420
-    public function set_default_reg_status_on_EEM_Event()
2421
-    {
2422
-        EEM_Event::set_default_reg_status($this->default_STS_ID);
2423
-    }
2111
+}
2424 2112
 
2425 2113
 
2426
-    /**
2427
-     * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_additional_limit field
2428
-     * for Events matches the config setting for default_maximum_number_of_tickets
2429
-     */
2430
-    public function set_default_max_ticket_on_EEM_Event()
2431
-    {
2432
-        EEM_Event::set_default_additional_limit($this->default_maximum_number_of_tickets);
2433
-    }
2434 2114
 
2115
+/**
2116
+ * Class for defining what's in the EE_Config relating to currency
2117
+ */
2118
+class EE_Currency_Config extends EE_Config_Base
2119
+{
2435 2120
 
2121
+	/**
2122
+	 * @var string $code
2123
+	 * eg 'US'
2124
+	 */
2125
+	public $code;
2126
+
2127
+	/**
2128
+	 * @var string $name
2129
+	 * eg 'Dollar'
2130
+	 */
2131
+	public $name;
2132
+
2133
+	/**
2134
+	 * plural name
2135
+	 *
2136
+	 * @var string $plural
2137
+	 * eg 'Dollars'
2138
+	 */
2139
+	public $plural;
2140
+
2141
+	/**
2142
+	 * currency sign
2143
+	 *
2144
+	 * @var string $sign
2145
+	 * eg '$'
2146
+	 */
2147
+	public $sign;
2148
+
2149
+	/**
2150
+	 * Whether the currency sign should come before the number or not
2151
+	 *
2152
+	 * @var boolean $sign_b4
2153
+	 */
2154
+	public $sign_b4;
2155
+
2156
+	/**
2157
+	 * How many digits should come after the decimal place
2158
+	 *
2159
+	 * @var int $dec_plc
2160
+	 */
2161
+	public $dec_plc;
2162
+
2163
+	/**
2164
+	 * Symbol to use for decimal mark
2165
+	 *
2166
+	 * @var string $dec_mrk
2167
+	 * eg '.'
2168
+	 */
2169
+	public $dec_mrk;
2170
+
2171
+	/**
2172
+	 * Symbol to use for thousands
2173
+	 *
2174
+	 * @var string $thsnds
2175
+	 * eg ','
2176
+	 */
2177
+	public $thsnds;
2178
+
2179
+
2180
+
2181
+	/**
2182
+	 *    class constructor
2183
+	 *
2184
+	 * @access    public
2185
+	 * @param string $CNT_ISO
2186
+	 * @throws \EE_Error
2187
+	 */
2188
+	public function __construct($CNT_ISO = '')
2189
+	{
2190
+		/** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */
2191
+		$table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
2192
+		// get country code from organization settings or use default
2193
+		$ORG_CNT = isset(EE_Registry::instance()->CFG->organization)
2194
+				   && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config
2195
+			? EE_Registry::instance()->CFG->organization->CNT_ISO
2196
+			: '';
2197
+		// but override if requested
2198
+		$CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT;
2199
+		// so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists
2200
+		if (
2201
+			! empty($CNT_ISO)
2202
+			&& EE_Maintenance_Mode::instance()->models_can_query()
2203
+			&& $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table())
2204
+		) {
2205
+			// retrieve the country settings from the db, just in case they have been customized
2206
+			$country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
2207
+			if ($country instanceof EE_Country) {
2208
+				$this->code = $country->currency_code();    // currency code: USD, CAD, EUR
2209
+				$this->name = $country->currency_name_single();    // Dollar
2210
+				$this->plural = $country->currency_name_plural();    // Dollars
2211
+				$this->sign = $country->currency_sign();            // currency sign: $
2212
+				$this->sign_b4 = $country->currency_sign_before();        // currency sign before or after: $TRUE  or  FALSE$
2213
+				$this->dec_plc = $country->currency_decimal_places();    // decimal places: 2 = 0.00  3 = 0.000
2214
+				$this->dec_mrk = $country->currency_decimal_mark();    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2215
+				$this->thsnds = $country->currency_thousands_separator();    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2216
+			}
2217
+		}
2218
+		// fallback to hardcoded defaults, in case the above failed
2219
+		if (empty($this->code)) {
2220
+			// set default currency settings
2221
+			$this->code = 'USD';    // currency code: USD, CAD, EUR
2222
+			$this->name = __('Dollar', 'event_espresso');    // Dollar
2223
+			$this->plural = __('Dollars', 'event_espresso');    // Dollars
2224
+			$this->sign = '$';    // currency sign: $
2225
+			$this->sign_b4 = true;    // currency sign before or after: $TRUE  or  FALSE$
2226
+			$this->dec_plc = 2;    // decimal places: 2 = 0.00  3 = 0.000
2227
+			$this->dec_mrk = '.';    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2228
+			$this->thsnds = ',';    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2229
+		}
2230
+	}
2231
+}
2436 2232
 
2437
-    /**
2438
-     * @return boolean
2439
-     */
2440
-    public function track_invalid_checkout_access()
2441
-    {
2442
-        return $this->track_invalid_checkout_access;
2443
-    }
2444 2233
 
2445 2234
 
2235
+/**
2236
+ * Class for defining what's in the EE_Config relating to registration settings
2237
+ */
2238
+class EE_Registration_Config extends EE_Config_Base
2239
+{
2446 2240
 
2447
-    /**
2448
-     * @param boolean $track_invalid_checkout_access
2449
-     */
2450
-    public function set_track_invalid_checkout_access($track_invalid_checkout_access)
2451
-    {
2452
-        $this->track_invalid_checkout_access = filter_var(
2453
-            $track_invalid_checkout_access,
2454
-            FILTER_VALIDATE_BOOLEAN
2455
-        );
2456
-    }
2241
+	/**
2242
+	 * Default registration status
2243
+	 *
2244
+	 * @var string $default_STS_ID
2245
+	 * eg 'RPP'
2246
+	 */
2247
+	public $default_STS_ID;
2248
+
2249
+
2250
+	/**
2251
+	 * For new events, this will be the default value for the maximum number of tickets (equivalent to maximum number of
2252
+	 * registrations)
2253
+	 * @var int
2254
+	 */
2255
+	public $default_maximum_number_of_tickets;
2256
+
2257
+
2258
+	/**
2259
+	 * level of validation to apply to email addresses
2260
+	 *
2261
+	 * @var string $email_validation_level
2262
+	 * options: 'basic', 'wp_default', 'i18n', 'i18n_dns'
2263
+	 */
2264
+	public $email_validation_level;
2265
+
2266
+	/**
2267
+	 *    whether or not to show alternate payment options during the reg process if payment status is pending
2268
+	 *
2269
+	 * @var boolean $show_pending_payment_options
2270
+	 */
2271
+	public $show_pending_payment_options;
2272
+
2273
+	/**
2274
+	 * Whether to skip the registration confirmation page
2275
+	 *
2276
+	 * @var boolean $skip_reg_confirmation
2277
+	 */
2278
+	public $skip_reg_confirmation;
2279
+
2280
+	/**
2281
+	 * an array of SPCO reg steps where:
2282
+	 *        the keys denotes the reg step order
2283
+	 *        each element consists of an array with the following elements:
2284
+	 *            "file_path" => the file path to the EE_SPCO_Reg_Step class
2285
+	 *            "class_name" => the specific EE_SPCO_Reg_Step child class name
2286
+	 *            "slug" => the URL param used to trigger the reg step
2287
+	 *
2288
+	 * @var array $reg_steps
2289
+	 */
2290
+	public $reg_steps;
2291
+
2292
+	/**
2293
+	 * Whether registration confirmation should be the last page of SPCO
2294
+	 *
2295
+	 * @var boolean $reg_confirmation_last
2296
+	 */
2297
+	public $reg_confirmation_last;
2298
+
2299
+	/**
2300
+	 * Whether or not to enable the EE Bot Trap
2301
+	 *
2302
+	 * @var boolean $use_bot_trap
2303
+	 */
2304
+	public $use_bot_trap;
2305
+
2306
+	/**
2307
+	 * Whether or not to encrypt some data sent by the EE Bot Trap
2308
+	 *
2309
+	 * @var boolean $use_encryption
2310
+	 */
2311
+	public $use_encryption;
2312
+
2313
+	/**
2314
+	 * Whether or not to use ReCaptcha
2315
+	 *
2316
+	 * @var boolean $use_captcha
2317
+	 */
2318
+	public $use_captcha;
2319
+
2320
+	/**
2321
+	 * ReCaptcha Theme
2322
+	 *
2323
+	 * @var string $recaptcha_theme
2324
+	 *    options: 'dark    ', 'light'
2325
+	 */
2326
+	public $recaptcha_theme;
2327
+
2328
+	/**
2329
+	 * ReCaptcha Type
2330
+	 *
2331
+	 * @var string $recaptcha_type
2332
+	 *    options: 'audio', 'image'
2333
+	 */
2334
+	public $recaptcha_type;
2335
+
2336
+	/**
2337
+	 * ReCaptcha language
2338
+	 *
2339
+	 * @var string $recaptcha_language
2340
+	 * eg 'en'
2341
+	 */
2342
+	public $recaptcha_language;
2343
+
2344
+	/**
2345
+	 * ReCaptcha public key
2346
+	 *
2347
+	 * @var string $recaptcha_publickey
2348
+	 */
2349
+	public $recaptcha_publickey;
2350
+
2351
+	/**
2352
+	 * ReCaptcha private key
2353
+	 *
2354
+	 * @var string $recaptcha_privatekey
2355
+	 */
2356
+	public $recaptcha_privatekey;
2357
+
2358
+	/**
2359
+	 * ReCaptcha width
2360
+	 *
2361
+	 * @var int $recaptcha_width
2362
+	 * @deprecated
2363
+	 */
2364
+	public $recaptcha_width;
2365
+
2366
+	/**
2367
+	 * Whether or not invalid attempts to directly access the registration checkout page should be tracked.
2368
+	 *
2369
+	 * @var boolean $track_invalid_checkout_access
2370
+	 */
2371
+	protected $track_invalid_checkout_access = true;
2372
+
2373
+
2374
+
2375
+	/**
2376
+	 *    class constructor
2377
+	 *
2378
+	 * @access    public
2379
+	 */
2380
+	public function __construct()
2381
+	{
2382
+		// set default registration settings
2383
+		$this->default_STS_ID = EEM_Registration::status_id_pending_payment;
2384
+		$this->email_validation_level = 'wp_default';
2385
+		$this->show_pending_payment_options = true;
2386
+		$this->skip_reg_confirmation = false;
2387
+		$this->reg_steps = array();
2388
+		$this->reg_confirmation_last = false;
2389
+		$this->use_bot_trap = true;
2390
+		$this->use_encryption = true;
2391
+		$this->use_captcha = false;
2392
+		$this->recaptcha_theme = 'light';
2393
+		$this->recaptcha_type = 'image';
2394
+		$this->recaptcha_language = 'en';
2395
+		$this->recaptcha_publickey = null;
2396
+		$this->recaptcha_privatekey = null;
2397
+		$this->recaptcha_width = 500;
2398
+		$this->default_maximum_number_of_tickets = 10;
2399
+	}
2400
+
2401
+
2402
+
2403
+	/**
2404
+	 * This is called by the config loader and hooks are initialized AFTER the config has been populated.
2405
+	 *
2406
+	 * @since 4.8.8.rc.019
2407
+	 */
2408
+	public function do_hooks()
2409
+	{
2410
+		add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event'));
2411
+		add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_max_ticket_on_EEM_Event'));
2412
+	}
2413
+
2414
+
2415
+
2416
+	/**
2417
+	 * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_default_registration_status
2418
+	 * field matches the config setting for default_STS_ID.
2419
+	 */
2420
+	public function set_default_reg_status_on_EEM_Event()
2421
+	{
2422
+		EEM_Event::set_default_reg_status($this->default_STS_ID);
2423
+	}
2424
+
2425
+
2426
+	/**
2427
+	 * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_additional_limit field
2428
+	 * for Events matches the config setting for default_maximum_number_of_tickets
2429
+	 */
2430
+	public function set_default_max_ticket_on_EEM_Event()
2431
+	{
2432
+		EEM_Event::set_default_additional_limit($this->default_maximum_number_of_tickets);
2433
+	}
2434
+
2435
+
2436
+
2437
+	/**
2438
+	 * @return boolean
2439
+	 */
2440
+	public function track_invalid_checkout_access()
2441
+	{
2442
+		return $this->track_invalid_checkout_access;
2443
+	}
2444
+
2445
+
2446
+
2447
+	/**
2448
+	 * @param boolean $track_invalid_checkout_access
2449
+	 */
2450
+	public function set_track_invalid_checkout_access($track_invalid_checkout_access)
2451
+	{
2452
+		$this->track_invalid_checkout_access = filter_var(
2453
+			$track_invalid_checkout_access,
2454
+			FILTER_VALIDATE_BOOLEAN
2455
+		);
2456
+	}
2457 2457
 
2458 2458
 
2459 2459
 
@@ -2467,160 +2467,160 @@  discard block
 block discarded – undo
2467 2467
 class EE_Admin_Config extends EE_Config_Base
2468 2468
 {
2469 2469
 
2470
-    /**
2471
-     * @var boolean $use_personnel_manager
2472
-     */
2473
-    public $use_personnel_manager;
2474
-
2475
-    /**
2476
-     * @var boolean $use_dashboard_widget
2477
-     */
2478
-    public $use_dashboard_widget;
2479
-
2480
-    /**
2481
-     * @var int $events_in_dashboard
2482
-     */
2483
-    public $events_in_dashboard;
2484
-
2485
-    /**
2486
-     * @var boolean $use_event_timezones
2487
-     */
2488
-    public $use_event_timezones;
2489
-
2490
-    /**
2491
-     * @var boolean $use_full_logging
2492
-     */
2493
-    public $use_full_logging;
2494
-
2495
-    /**
2496
-     * @var string $log_file_name
2497
-     */
2498
-    public $log_file_name;
2499
-
2500
-    /**
2501
-     * @var string $debug_file_name
2502
-     */
2503
-    public $debug_file_name;
2504
-
2505
-    /**
2506
-     * @var boolean $use_remote_logging
2507
-     */
2508
-    public $use_remote_logging;
2509
-
2510
-    /**
2511
-     * @var string $remote_logging_url
2512
-     */
2513
-    public $remote_logging_url;
2514
-
2515
-    /**
2516
-     * @var boolean $show_reg_footer
2517
-     */
2518
-    public $show_reg_footer;
2519
-
2520
-    /**
2521
-     * @var string $affiliate_id
2522
-     */
2523
-    public $affiliate_id;
2524
-
2525
-    /**
2526
-     * help tours on or off (global setting)
2527
-     *
2528
-     * @var boolean
2529
-     */
2530
-    public $help_tour_activation;
2531
-
2532
-    /**
2533
-     * adds extra layer of encoding to session data to prevent serialization errors
2534
-     * but is incompatible with some server configuration errors
2535
-     * if you get "500 internal server errors" during registration, try turning this on
2536
-     * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off
2537
-     *
2538
-     * @var boolean $encode_session_data
2539
-     */
2540
-    private $encode_session_data = false;
2541
-
2542
-
2543
-
2544
-    /**
2545
-     *    class constructor
2546
-     *
2547
-     * @access    public
2548
-     */
2549
-    public function __construct()
2550
-    {
2551
-        // set default general admin settings
2552
-        $this->use_personnel_manager = true;
2553
-        $this->use_dashboard_widget = true;
2554
-        $this->events_in_dashboard = 30;
2555
-        $this->use_event_timezones = false;
2556
-        $this->use_full_logging = false;
2557
-        $this->use_remote_logging = false;
2558
-        $this->remote_logging_url = null;
2559
-        $this->show_reg_footer = true;
2560
-        $this->affiliate_id = 'default';
2561
-        $this->help_tour_activation = true;
2562
-        $this->encode_session_data = false;
2563
-    }
2564
-
2565
-
2566
-
2567
-    /**
2568
-     * @param bool $reset
2569
-     * @return string
2570
-     */
2571
-    public function log_file_name($reset = false)
2572
-    {
2573
-        if (empty($this->log_file_name) || $reset) {
2574
-            $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2575
-            EE_Config::instance()->update_espresso_config(false, false);
2576
-        }
2577
-        return $this->log_file_name;
2578
-    }
2579
-
2580
-
2581
-
2582
-    /**
2583
-     * @param bool $reset
2584
-     * @return string
2585
-     */
2586
-    public function debug_file_name($reset = false)
2587
-    {
2588
-        if (empty($this->debug_file_name) || $reset) {
2589
-            $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2590
-            EE_Config::instance()->update_espresso_config(false, false);
2591
-        }
2592
-        return $this->debug_file_name;
2593
-    }
2594
-
2595
-
2596
-
2597
-    /**
2598
-     * @return string
2599
-     */
2600
-    public function affiliate_id()
2601
-    {
2602
-        return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default';
2603
-    }
2604
-
2605
-
2606
-
2607
-    /**
2608
-     * @return boolean
2609
-     */
2610
-    public function encode_session_data()
2611
-    {
2612
-        return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN);
2613
-    }
2614
-
2615
-
2616
-
2617
-    /**
2618
-     * @param boolean $encode_session_data
2619
-     */
2620
-    public function set_encode_session_data($encode_session_data)
2621
-    {
2622
-        $this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN);
2623
-    }
2470
+	/**
2471
+	 * @var boolean $use_personnel_manager
2472
+	 */
2473
+	public $use_personnel_manager;
2474
+
2475
+	/**
2476
+	 * @var boolean $use_dashboard_widget
2477
+	 */
2478
+	public $use_dashboard_widget;
2479
+
2480
+	/**
2481
+	 * @var int $events_in_dashboard
2482
+	 */
2483
+	public $events_in_dashboard;
2484
+
2485
+	/**
2486
+	 * @var boolean $use_event_timezones
2487
+	 */
2488
+	public $use_event_timezones;
2489
+
2490
+	/**
2491
+	 * @var boolean $use_full_logging
2492
+	 */
2493
+	public $use_full_logging;
2494
+
2495
+	/**
2496
+	 * @var string $log_file_name
2497
+	 */
2498
+	public $log_file_name;
2499
+
2500
+	/**
2501
+	 * @var string $debug_file_name
2502
+	 */
2503
+	public $debug_file_name;
2504
+
2505
+	/**
2506
+	 * @var boolean $use_remote_logging
2507
+	 */
2508
+	public $use_remote_logging;
2509
+
2510
+	/**
2511
+	 * @var string $remote_logging_url
2512
+	 */
2513
+	public $remote_logging_url;
2514
+
2515
+	/**
2516
+	 * @var boolean $show_reg_footer
2517
+	 */
2518
+	public $show_reg_footer;
2519
+
2520
+	/**
2521
+	 * @var string $affiliate_id
2522
+	 */
2523
+	public $affiliate_id;
2524
+
2525
+	/**
2526
+	 * help tours on or off (global setting)
2527
+	 *
2528
+	 * @var boolean
2529
+	 */
2530
+	public $help_tour_activation;
2531
+
2532
+	/**
2533
+	 * adds extra layer of encoding to session data to prevent serialization errors
2534
+	 * but is incompatible with some server configuration errors
2535
+	 * if you get "500 internal server errors" during registration, try turning this on
2536
+	 * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off
2537
+	 *
2538
+	 * @var boolean $encode_session_data
2539
+	 */
2540
+	private $encode_session_data = false;
2541
+
2542
+
2543
+
2544
+	/**
2545
+	 *    class constructor
2546
+	 *
2547
+	 * @access    public
2548
+	 */
2549
+	public function __construct()
2550
+	{
2551
+		// set default general admin settings
2552
+		$this->use_personnel_manager = true;
2553
+		$this->use_dashboard_widget = true;
2554
+		$this->events_in_dashboard = 30;
2555
+		$this->use_event_timezones = false;
2556
+		$this->use_full_logging = false;
2557
+		$this->use_remote_logging = false;
2558
+		$this->remote_logging_url = null;
2559
+		$this->show_reg_footer = true;
2560
+		$this->affiliate_id = 'default';
2561
+		$this->help_tour_activation = true;
2562
+		$this->encode_session_data = false;
2563
+	}
2564
+
2565
+
2566
+
2567
+	/**
2568
+	 * @param bool $reset
2569
+	 * @return string
2570
+	 */
2571
+	public function log_file_name($reset = false)
2572
+	{
2573
+		if (empty($this->log_file_name) || $reset) {
2574
+			$this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2575
+			EE_Config::instance()->update_espresso_config(false, false);
2576
+		}
2577
+		return $this->log_file_name;
2578
+	}
2579
+
2580
+
2581
+
2582
+	/**
2583
+	 * @param bool $reset
2584
+	 * @return string
2585
+	 */
2586
+	public function debug_file_name($reset = false)
2587
+	{
2588
+		if (empty($this->debug_file_name) || $reset) {
2589
+			$this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2590
+			EE_Config::instance()->update_espresso_config(false, false);
2591
+		}
2592
+		return $this->debug_file_name;
2593
+	}
2594
+
2595
+
2596
+
2597
+	/**
2598
+	 * @return string
2599
+	 */
2600
+	public function affiliate_id()
2601
+	{
2602
+		return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default';
2603
+	}
2604
+
2605
+
2606
+
2607
+	/**
2608
+	 * @return boolean
2609
+	 */
2610
+	public function encode_session_data()
2611
+	{
2612
+		return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN);
2613
+	}
2614
+
2615
+
2616
+
2617
+	/**
2618
+	 * @param boolean $encode_session_data
2619
+	 */
2620
+	public function set_encode_session_data($encode_session_data)
2621
+	{
2622
+		$this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN);
2623
+	}
2624 2624
 
2625 2625
 
2626 2626
 
@@ -2634,71 +2634,71 @@  discard block
 block discarded – undo
2634 2634
 class EE_Template_Config extends EE_Config_Base
2635 2635
 {
2636 2636
 
2637
-    /**
2638
-     * @var boolean $enable_default_style
2639
-     */
2640
-    public $enable_default_style;
2641
-
2642
-    /**
2643
-     * @var string $custom_style_sheet
2644
-     */
2645
-    public $custom_style_sheet;
2646
-
2647
-    /**
2648
-     * @var boolean $display_address_in_regform
2649
-     */
2650
-    public $display_address_in_regform;
2651
-
2652
-    /**
2653
-     * @var int $display_description_on_multi_reg_page
2654
-     */
2655
-    public $display_description_on_multi_reg_page;
2656
-
2657
-    /**
2658
-     * @var boolean $use_custom_templates
2659
-     */
2660
-    public $use_custom_templates;
2661
-
2662
-    /**
2663
-     * @var string $current_espresso_theme
2664
-     */
2665
-    public $current_espresso_theme;
2666
-
2667
-    /**
2668
-     * @var EE_Ticket_Selector_Config $EED_Ticket_Selector
2669
-     */
2670
-    public $EED_Ticket_Selector;
2671
-
2672
-    /**
2673
-     * @var EE_Event_Single_Config $EED_Event_Single
2674
-     */
2675
-    public $EED_Event_Single;
2676
-
2677
-    /**
2678
-     * @var EE_Events_Archive_Config $EED_Events_Archive
2679
-     */
2680
-    public $EED_Events_Archive;
2681
-
2682
-
2683
-
2684
-    /**
2685
-     *    class constructor
2686
-     *
2687
-     * @access    public
2688
-     */
2689
-    public function __construct()
2690
-    {
2691
-        // set default template settings
2692
-        $this->enable_default_style = true;
2693
-        $this->custom_style_sheet = null;
2694
-        $this->display_address_in_regform = true;
2695
-        $this->display_description_on_multi_reg_page = false;
2696
-        $this->use_custom_templates = false;
2697
-        $this->current_espresso_theme = 'Espresso_Arabica_2014';
2698
-        $this->EED_Event_Single = null;
2699
-        $this->EED_Events_Archive = null;
2700
-        $this->EED_Ticket_Selector = null;
2701
-    }
2637
+	/**
2638
+	 * @var boolean $enable_default_style
2639
+	 */
2640
+	public $enable_default_style;
2641
+
2642
+	/**
2643
+	 * @var string $custom_style_sheet
2644
+	 */
2645
+	public $custom_style_sheet;
2646
+
2647
+	/**
2648
+	 * @var boolean $display_address_in_regform
2649
+	 */
2650
+	public $display_address_in_regform;
2651
+
2652
+	/**
2653
+	 * @var int $display_description_on_multi_reg_page
2654
+	 */
2655
+	public $display_description_on_multi_reg_page;
2656
+
2657
+	/**
2658
+	 * @var boolean $use_custom_templates
2659
+	 */
2660
+	public $use_custom_templates;
2661
+
2662
+	/**
2663
+	 * @var string $current_espresso_theme
2664
+	 */
2665
+	public $current_espresso_theme;
2666
+
2667
+	/**
2668
+	 * @var EE_Ticket_Selector_Config $EED_Ticket_Selector
2669
+	 */
2670
+	public $EED_Ticket_Selector;
2671
+
2672
+	/**
2673
+	 * @var EE_Event_Single_Config $EED_Event_Single
2674
+	 */
2675
+	public $EED_Event_Single;
2676
+
2677
+	/**
2678
+	 * @var EE_Events_Archive_Config $EED_Events_Archive
2679
+	 */
2680
+	public $EED_Events_Archive;
2681
+
2682
+
2683
+
2684
+	/**
2685
+	 *    class constructor
2686
+	 *
2687
+	 * @access    public
2688
+	 */
2689
+	public function __construct()
2690
+	{
2691
+		// set default template settings
2692
+		$this->enable_default_style = true;
2693
+		$this->custom_style_sheet = null;
2694
+		$this->display_address_in_regform = true;
2695
+		$this->display_description_on_multi_reg_page = false;
2696
+		$this->use_custom_templates = false;
2697
+		$this->current_espresso_theme = 'Espresso_Arabica_2014';
2698
+		$this->EED_Event_Single = null;
2699
+		$this->EED_Events_Archive = null;
2700
+		$this->EED_Ticket_Selector = null;
2701
+	}
2702 2702
 
2703 2703
 }
2704 2704
 
@@ -2710,115 +2710,115 @@  discard block
 block discarded – undo
2710 2710
 class EE_Map_Config extends EE_Config_Base
2711 2711
 {
2712 2712
 
2713
-    /**
2714
-     * @var boolean $use_google_maps
2715
-     */
2716
-    public $use_google_maps;
2717
-
2718
-    /**
2719
-     * @var string $api_key
2720
-     */
2721
-    public $google_map_api_key;
2722
-
2723
-    /**
2724
-     * @var int $event_details_map_width
2725
-     */
2726
-    public $event_details_map_width;
2727
-
2728
-    /**
2729
-     * @var int $event_details_map_height
2730
-     */
2731
-    public $event_details_map_height;
2732
-
2733
-    /**
2734
-     * @var int $event_details_map_zoom
2735
-     */
2736
-    public $event_details_map_zoom;
2737
-
2738
-    /**
2739
-     * @var boolean $event_details_display_nav
2740
-     */
2741
-    public $event_details_display_nav;
2742
-
2743
-    /**
2744
-     * @var boolean $event_details_nav_size
2745
-     */
2746
-    public $event_details_nav_size;
2747
-
2748
-    /**
2749
-     * @var string $event_details_control_type
2750
-     */
2751
-    public $event_details_control_type;
2752
-
2753
-    /**
2754
-     * @var string $event_details_map_align
2755
-     */
2756
-    public $event_details_map_align;
2757
-
2758
-    /**
2759
-     * @var int $event_list_map_width
2760
-     */
2761
-    public $event_list_map_width;
2762
-
2763
-    /**
2764
-     * @var int $event_list_map_height
2765
-     */
2766
-    public $event_list_map_height;
2767
-
2768
-    /**
2769
-     * @var int $event_list_map_zoom
2770
-     */
2771
-    public $event_list_map_zoom;
2772
-
2773
-    /**
2774
-     * @var boolean $event_list_display_nav
2775
-     */
2776
-    public $event_list_display_nav;
2777
-
2778
-    /**
2779
-     * @var boolean $event_list_nav_size
2780
-     */
2781
-    public $event_list_nav_size;
2782
-
2783
-    /**
2784
-     * @var string $event_list_control_type
2785
-     */
2786
-    public $event_list_control_type;
2787
-
2788
-    /**
2789
-     * @var string $event_list_map_align
2790
-     */
2791
-    public $event_list_map_align;
2792
-
2793
-
2794
-
2795
-    /**
2796
-     *    class constructor
2797
-     *
2798
-     * @access    public
2799
-     */
2800
-    public function __construct()
2801
-    {
2802
-        // set default map settings
2803
-        $this->use_google_maps = true;
2804
-        $this->google_map_api_key = '';
2805
-        // for event details pages (reg page)
2806
-        $this->event_details_map_width = 585;            // ee_map_width_single
2807
-        $this->event_details_map_height = 362;            // ee_map_height_single
2808
-        $this->event_details_map_zoom = 14;            // ee_map_zoom_single
2809
-        $this->event_details_display_nav = true;            // ee_map_nav_display_single
2810
-        $this->event_details_nav_size = false;            // ee_map_nav_size_single
2811
-        $this->event_details_control_type = 'default';        // ee_map_type_control_single
2812
-        $this->event_details_map_align = 'center';            // ee_map_align_single
2813
-        // for event list pages
2814
-        $this->event_list_map_width = 300;            // ee_map_width
2815
-        $this->event_list_map_height = 185;        // ee_map_height
2816
-        $this->event_list_map_zoom = 12;            // ee_map_zoom
2817
-        $this->event_list_display_nav = false;        // ee_map_nav_display
2818
-        $this->event_list_nav_size = true;            // ee_map_nav_size
2819
-        $this->event_list_control_type = 'dropdown';        // ee_map_type_control
2820
-        $this->event_list_map_align = 'center';            // ee_map_align
2821
-    }
2713
+	/**
2714
+	 * @var boolean $use_google_maps
2715
+	 */
2716
+	public $use_google_maps;
2717
+
2718
+	/**
2719
+	 * @var string $api_key
2720
+	 */
2721
+	public $google_map_api_key;
2722
+
2723
+	/**
2724
+	 * @var int $event_details_map_width
2725
+	 */
2726
+	public $event_details_map_width;
2727
+
2728
+	/**
2729
+	 * @var int $event_details_map_height
2730
+	 */
2731
+	public $event_details_map_height;
2732
+
2733
+	/**
2734
+	 * @var int $event_details_map_zoom
2735
+	 */
2736
+	public $event_details_map_zoom;
2737
+
2738
+	/**
2739
+	 * @var boolean $event_details_display_nav
2740
+	 */
2741
+	public $event_details_display_nav;
2742
+
2743
+	/**
2744
+	 * @var boolean $event_details_nav_size
2745
+	 */
2746
+	public $event_details_nav_size;
2747
+
2748
+	/**
2749
+	 * @var string $event_details_control_type
2750
+	 */
2751
+	public $event_details_control_type;
2752
+
2753
+	/**
2754
+	 * @var string $event_details_map_align
2755
+	 */
2756
+	public $event_details_map_align;
2757
+
2758
+	/**
2759
+	 * @var int $event_list_map_width
2760
+	 */
2761
+	public $event_list_map_width;
2762
+
2763
+	/**
2764
+	 * @var int $event_list_map_height
2765
+	 */
2766
+	public $event_list_map_height;
2767
+
2768
+	/**
2769
+	 * @var int $event_list_map_zoom
2770
+	 */
2771
+	public $event_list_map_zoom;
2772
+
2773
+	/**
2774
+	 * @var boolean $event_list_display_nav
2775
+	 */
2776
+	public $event_list_display_nav;
2777
+
2778
+	/**
2779
+	 * @var boolean $event_list_nav_size
2780
+	 */
2781
+	public $event_list_nav_size;
2782
+
2783
+	/**
2784
+	 * @var string $event_list_control_type
2785
+	 */
2786
+	public $event_list_control_type;
2787
+
2788
+	/**
2789
+	 * @var string $event_list_map_align
2790
+	 */
2791
+	public $event_list_map_align;
2792
+
2793
+
2794
+
2795
+	/**
2796
+	 *    class constructor
2797
+	 *
2798
+	 * @access    public
2799
+	 */
2800
+	public function __construct()
2801
+	{
2802
+		// set default map settings
2803
+		$this->use_google_maps = true;
2804
+		$this->google_map_api_key = '';
2805
+		// for event details pages (reg page)
2806
+		$this->event_details_map_width = 585;            // ee_map_width_single
2807
+		$this->event_details_map_height = 362;            // ee_map_height_single
2808
+		$this->event_details_map_zoom = 14;            // ee_map_zoom_single
2809
+		$this->event_details_display_nav = true;            // ee_map_nav_display_single
2810
+		$this->event_details_nav_size = false;            // ee_map_nav_size_single
2811
+		$this->event_details_control_type = 'default';        // ee_map_type_control_single
2812
+		$this->event_details_map_align = 'center';            // ee_map_align_single
2813
+		// for event list pages
2814
+		$this->event_list_map_width = 300;            // ee_map_width
2815
+		$this->event_list_map_height = 185;        // ee_map_height
2816
+		$this->event_list_map_zoom = 12;            // ee_map_zoom
2817
+		$this->event_list_display_nav = false;        // ee_map_nav_display
2818
+		$this->event_list_nav_size = true;            // ee_map_nav_size
2819
+		$this->event_list_control_type = 'dropdown';        // ee_map_type_control
2820
+		$this->event_list_map_align = 'center';            // ee_map_align
2821
+	}
2822 2822
 
2823 2823
 }
2824 2824
 
@@ -2830,47 +2830,47 @@  discard block
 block discarded – undo
2830 2830
 class EE_Events_Archive_Config extends EE_Config_Base
2831 2831
 {
2832 2832
 
2833
-    public $display_status_banner;
2833
+	public $display_status_banner;
2834 2834
 
2835
-    public $display_description;
2835
+	public $display_description;
2836 2836
 
2837
-    public $display_ticket_selector;
2837
+	public $display_ticket_selector;
2838 2838
 
2839
-    public $display_datetimes;
2839
+	public $display_datetimes;
2840 2840
 
2841
-    public $display_venue;
2841
+	public $display_venue;
2842 2842
 
2843
-    public $display_expired_events;
2843
+	public $display_expired_events;
2844 2844
 
2845
-    public $use_sortable_display_order;
2845
+	public $use_sortable_display_order;
2846 2846
 
2847
-    public $display_order_tickets;
2847
+	public $display_order_tickets;
2848 2848
 
2849
-    public $display_order_datetimes;
2849
+	public $display_order_datetimes;
2850 2850
 
2851
-    public $display_order_event;
2851
+	public $display_order_event;
2852 2852
 
2853
-    public $display_order_venue;
2853
+	public $display_order_venue;
2854 2854
 
2855 2855
 
2856 2856
 
2857
-    /**
2858
-     *    class constructor
2859
-     */
2860
-    public function __construct()
2861
-    {
2862
-        $this->display_status_banner = 0;
2863
-        $this->display_description = 1;
2864
-        $this->display_ticket_selector = 0;
2865
-        $this->display_datetimes = 1;
2866
-        $this->display_venue = 0;
2867
-        $this->display_expired_events = 0;
2868
-        $this->use_sortable_display_order = false;
2869
-        $this->display_order_tickets = 100;
2870
-        $this->display_order_datetimes = 110;
2871
-        $this->display_order_event = 120;
2872
-        $this->display_order_venue = 130;
2873
-    }
2857
+	/**
2858
+	 *    class constructor
2859
+	 */
2860
+	public function __construct()
2861
+	{
2862
+		$this->display_status_banner = 0;
2863
+		$this->display_description = 1;
2864
+		$this->display_ticket_selector = 0;
2865
+		$this->display_datetimes = 1;
2866
+		$this->display_venue = 0;
2867
+		$this->display_expired_events = 0;
2868
+		$this->use_sortable_display_order = false;
2869
+		$this->display_order_tickets = 100;
2870
+		$this->display_order_datetimes = 110;
2871
+		$this->display_order_event = 120;
2872
+		$this->display_order_venue = 130;
2873
+	}
2874 2874
 }
2875 2875
 
2876 2876
 
@@ -2881,35 +2881,35 @@  discard block
 block discarded – undo
2881 2881
 class EE_Event_Single_Config extends EE_Config_Base
2882 2882
 {
2883 2883
 
2884
-    public $display_status_banner_single;
2884
+	public $display_status_banner_single;
2885 2885
 
2886
-    public $display_venue;
2886
+	public $display_venue;
2887 2887
 
2888
-    public $use_sortable_display_order;
2888
+	public $use_sortable_display_order;
2889 2889
 
2890
-    public $display_order_tickets;
2890
+	public $display_order_tickets;
2891 2891
 
2892
-    public $display_order_datetimes;
2892
+	public $display_order_datetimes;
2893 2893
 
2894
-    public $display_order_event;
2894
+	public $display_order_event;
2895 2895
 
2896
-    public $display_order_venue;
2896
+	public $display_order_venue;
2897 2897
 
2898 2898
 
2899 2899
 
2900
-    /**
2901
-     *    class constructor
2902
-     */
2903
-    public function __construct()
2904
-    {
2905
-        $this->display_status_banner_single = 0;
2906
-        $this->display_venue = 1;
2907
-        $this->use_sortable_display_order = false;
2908
-        $this->display_order_tickets = 100;
2909
-        $this->display_order_datetimes = 110;
2910
-        $this->display_order_event = 120;
2911
-        $this->display_order_venue = 130;
2912
-    }
2900
+	/**
2901
+	 *    class constructor
2902
+	 */
2903
+	public function __construct()
2904
+	{
2905
+		$this->display_status_banner_single = 0;
2906
+		$this->display_venue = 1;
2907
+		$this->use_sortable_display_order = false;
2908
+		$this->display_order_tickets = 100;
2909
+		$this->display_order_datetimes = 110;
2910
+		$this->display_order_event = 120;
2911
+		$this->display_order_venue = 130;
2912
+	}
2913 2913
 }
2914 2914
 
2915 2915
 
@@ -2920,152 +2920,152 @@  discard block
 block discarded – undo
2920 2920
 class EE_Ticket_Selector_Config extends EE_Config_Base
2921 2921
 {
2922 2922
 
2923
-    /**
2924
-     * constant to indicate that a datetime selector should NEVER be shown for ticket selectors
2925
-     */
2926
-    const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector';
2927
-
2928
-    /**
2929
-     * constant to indicate that a datetime selector should only be shown for ticket selectors
2930
-     * when the number of datetimes for the event matches the value set for $datetime_selector_threshold
2931
-     */
2932
-    const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector';
2933
-
2934
-    /**
2935
-     * @var boolean $show_ticket_sale_columns
2936
-     */
2937
-    public $show_ticket_sale_columns;
2938
-
2939
-    /**
2940
-     * @var boolean $show_ticket_details
2941
-     */
2942
-    public $show_ticket_details;
2943
-
2944
-    /**
2945
-     * @var boolean $show_expired_tickets
2946
-     */
2947
-    public $show_expired_tickets;
2948
-
2949
-    /**
2950
-     * whether or not to display a dropdown box populated with event datetimes
2951
-     * that toggles which tickets are displayed for a ticket selector.
2952
-     * uses one of the *_DATETIME_SELECTOR constants defined above
2953
-     *
2954
-     * @var string $show_datetime_selector
2955
-     */
2956
-    private $show_datetime_selector = 'no_datetime_selector';
2957
-
2958
-    /**
2959
-     * the number of datetimes an event has to have before conditionally displaying a datetime selector
2960
-     *
2961
-     * @var int $datetime_selector_threshold
2962
-     */
2963
-    private $datetime_selector_threshold = 3;
2964
-
2965
-
2966
-
2967
-    /**
2968
-     *    class constructor
2969
-     */
2970
-    public function __construct()
2971
-    {
2972
-        $this->show_ticket_sale_columns = true;
2973
-        $this->show_ticket_details = true;
2974
-        $this->show_expired_tickets = true;
2975
-        $this->show_datetime_selector = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
2976
-        $this->datetime_selector_threshold = 3;
2977
-    }
2978
-
2979
-
2980
-
2981
-    /**
2982
-     * returns true if a datetime selector should be displayed
2983
-     *
2984
-     * @param array $datetimes
2985
-     * @return bool
2986
-     */
2987
-    public function showDatetimeSelector(array $datetimes)
2988
-    {
2989
-        // if the settings are NOT: don't show OR below threshold, THEN active = true
2990
-        return ! (
2991
-            $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR
2992
-            || (
2993
-                $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR
2994
-                && count($datetimes) < $this->getDatetimeSelectorThreshold()
2995
-            )
2996
-        );
2997
-    }
2998
-
2999
-
3000
-
3001
-    /**
3002
-     * @return string
3003
-     */
3004
-    public function getShowDatetimeSelector()
3005
-    {
3006
-        return $this->show_datetime_selector;
3007
-    }
3008
-
3009
-
3010
-
3011
-    /**
3012
-     * @param bool $keys_only
3013
-     * @return array
3014
-     */
3015
-    public function getShowDatetimeSelectorOptions($keys_only = true)
3016
-    {
3017
-        return $keys_only
3018
-            ? array(
3019
-                \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR,
3020
-                \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR,
3021
-            )
3022
-            : array(
3023
-                \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__(
3024
-                    'Do not show date & time filter', 'event_espresso'
3025
-                ),
3026
-                \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR  => esc_html__(
3027
-                    'Maybe show date & time filter', 'event_espresso'
3028
-                ),
3029
-            );
3030
-    }
3031
-
3032
-
3033
-
3034
-    /**
3035
-     * @param string $show_datetime_selector
3036
-     */
3037
-    public function setShowDatetimeSelector($show_datetime_selector)
3038
-    {
3039
-        $this->show_datetime_selector = in_array(
3040
-            $show_datetime_selector,
3041
-            $this->getShowDatetimeSelectorOptions(),
3042
-            true
3043
-        )
3044
-            ? $show_datetime_selector
3045
-            : \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3046
-    }
3047
-
3048
-
3049
-
3050
-    /**
3051
-     * @return int
3052
-     */
3053
-    public function getDatetimeSelectorThreshold()
3054
-    {
3055
-        return $this->datetime_selector_threshold;
3056
-    }
3057
-
3058
-
3059
-
3060
-
3061
-    /**
3062
-     * @param int $datetime_selector_threshold
3063
-     */
3064
-    public function setDatetimeSelectorThreshold($datetime_selector_threshold)
3065
-    {
3066
-        $datetime_selector_threshold = absint($datetime_selector_threshold);
3067
-        $this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3;
3068
-    }
2923
+	/**
2924
+	 * constant to indicate that a datetime selector should NEVER be shown for ticket selectors
2925
+	 */
2926
+	const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector';
2927
+
2928
+	/**
2929
+	 * constant to indicate that a datetime selector should only be shown for ticket selectors
2930
+	 * when the number of datetimes for the event matches the value set for $datetime_selector_threshold
2931
+	 */
2932
+	const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector';
2933
+
2934
+	/**
2935
+	 * @var boolean $show_ticket_sale_columns
2936
+	 */
2937
+	public $show_ticket_sale_columns;
2938
+
2939
+	/**
2940
+	 * @var boolean $show_ticket_details
2941
+	 */
2942
+	public $show_ticket_details;
2943
+
2944
+	/**
2945
+	 * @var boolean $show_expired_tickets
2946
+	 */
2947
+	public $show_expired_tickets;
2948
+
2949
+	/**
2950
+	 * whether or not to display a dropdown box populated with event datetimes
2951
+	 * that toggles which tickets are displayed for a ticket selector.
2952
+	 * uses one of the *_DATETIME_SELECTOR constants defined above
2953
+	 *
2954
+	 * @var string $show_datetime_selector
2955
+	 */
2956
+	private $show_datetime_selector = 'no_datetime_selector';
2957
+
2958
+	/**
2959
+	 * the number of datetimes an event has to have before conditionally displaying a datetime selector
2960
+	 *
2961
+	 * @var int $datetime_selector_threshold
2962
+	 */
2963
+	private $datetime_selector_threshold = 3;
2964
+
2965
+
2966
+
2967
+	/**
2968
+	 *    class constructor
2969
+	 */
2970
+	public function __construct()
2971
+	{
2972
+		$this->show_ticket_sale_columns = true;
2973
+		$this->show_ticket_details = true;
2974
+		$this->show_expired_tickets = true;
2975
+		$this->show_datetime_selector = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
2976
+		$this->datetime_selector_threshold = 3;
2977
+	}
2978
+
2979
+
2980
+
2981
+	/**
2982
+	 * returns true if a datetime selector should be displayed
2983
+	 *
2984
+	 * @param array $datetimes
2985
+	 * @return bool
2986
+	 */
2987
+	public function showDatetimeSelector(array $datetimes)
2988
+	{
2989
+		// if the settings are NOT: don't show OR below threshold, THEN active = true
2990
+		return ! (
2991
+			$this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR
2992
+			|| (
2993
+				$this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR
2994
+				&& count($datetimes) < $this->getDatetimeSelectorThreshold()
2995
+			)
2996
+		);
2997
+	}
2998
+
2999
+
3000
+
3001
+	/**
3002
+	 * @return string
3003
+	 */
3004
+	public function getShowDatetimeSelector()
3005
+	{
3006
+		return $this->show_datetime_selector;
3007
+	}
3008
+
3009
+
3010
+
3011
+	/**
3012
+	 * @param bool $keys_only
3013
+	 * @return array
3014
+	 */
3015
+	public function getShowDatetimeSelectorOptions($keys_only = true)
3016
+	{
3017
+		return $keys_only
3018
+			? array(
3019
+				\EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR,
3020
+				\EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR,
3021
+			)
3022
+			: array(
3023
+				\EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__(
3024
+					'Do not show date & time filter', 'event_espresso'
3025
+				),
3026
+				\EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR  => esc_html__(
3027
+					'Maybe show date & time filter', 'event_espresso'
3028
+				),
3029
+			);
3030
+	}
3031
+
3032
+
3033
+
3034
+	/**
3035
+	 * @param string $show_datetime_selector
3036
+	 */
3037
+	public function setShowDatetimeSelector($show_datetime_selector)
3038
+	{
3039
+		$this->show_datetime_selector = in_array(
3040
+			$show_datetime_selector,
3041
+			$this->getShowDatetimeSelectorOptions(),
3042
+			true
3043
+		)
3044
+			? $show_datetime_selector
3045
+			: \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3046
+	}
3047
+
3048
+
3049
+
3050
+	/**
3051
+	 * @return int
3052
+	 */
3053
+	public function getDatetimeSelectorThreshold()
3054
+	{
3055
+		return $this->datetime_selector_threshold;
3056
+	}
3057
+
3058
+
3059
+
3060
+
3061
+	/**
3062
+	 * @param int $datetime_selector_threshold
3063
+	 */
3064
+	public function setDatetimeSelectorThreshold($datetime_selector_threshold)
3065
+	{
3066
+		$datetime_selector_threshold = absint($datetime_selector_threshold);
3067
+		$this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3;
3068
+	}
3069 3069
 
3070 3070
 
3071 3071
 
@@ -3083,85 +3083,85 @@  discard block
 block discarded – undo
3083 3083
 class EE_Environment_Config extends EE_Config_Base
3084 3084
 {
3085 3085
 
3086
-    /**
3087
-     * Hold any php environment variables that we want to track.
3088
-     *
3089
-     * @var stdClass;
3090
-     */
3091
-    public $php;
3092
-
3093
-
3094
-
3095
-    /**
3096
-     *    constructor
3097
-     */
3098
-    public function __construct()
3099
-    {
3100
-        $this->php = new stdClass();
3101
-        $this->_set_php_values();
3102
-    }
3103
-
3104
-
3105
-
3106
-    /**
3107
-     * This sets the php environment variables.
3108
-     *
3109
-     * @since 4.4.0
3110
-     * @return void
3111
-     */
3112
-    protected function _set_php_values()
3113
-    {
3114
-        $this->php->max_input_vars = ini_get('max_input_vars');
3115
-        $this->php->version = phpversion();
3116
-    }
3117
-
3118
-
3119
-
3120
-    /**
3121
-     * helper method for determining whether input_count is
3122
-     * reaching the potential maximum the server can handle
3123
-     * according to max_input_vars
3124
-     *
3125
-     * @param int   $input_count the count of input vars.
3126
-     * @return array {
3127
-     *                           An array that represents whether available space and if no available space the error
3128
-     *                           message.
3129
-     * @type bool   $has_space   whether more inputs can be added.
3130
-     * @type string $msg         Any message to be displayed.
3131
-     *                           }
3132
-     */
3133
-    public function max_input_vars_limit_check($input_count = 0)
3134
-    {
3135
-        if (! empty($this->php->max_input_vars)
3136
-            && ($input_count >= $this->php->max_input_vars)
3137
-            && (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9)
3138
-        ) {
3139
-            return sprintf(
3140
-                __(
3141
-                    'The maximum number of inputs on this page has been exceeded.  You cannot add anymore items (i.e. tickets, datetimes, custom fields) on this page because of your servers PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.',
3142
-                    'event_espresso'
3143
-                ),
3144
-                '<br>',
3145
-                $input_count,
3146
-                $this->php->max_input_vars
3147
-            );
3148
-        } else {
3149
-            return '';
3150
-        }
3151
-    }
3152
-
3153
-
3154
-
3155
-    /**
3156
-     * The purpose of this method is just to force rechecking php values so if they've changed, they get updated.
3157
-     *
3158
-     * @since 4.4.1
3159
-     * @return void
3160
-     */
3161
-    public function recheck_values()
3162
-    {
3163
-        $this->_set_php_values();
3164
-    }
3086
+	/**
3087
+	 * Hold any php environment variables that we want to track.
3088
+	 *
3089
+	 * @var stdClass;
3090
+	 */
3091
+	public $php;
3092
+
3093
+
3094
+
3095
+	/**
3096
+	 *    constructor
3097
+	 */
3098
+	public function __construct()
3099
+	{
3100
+		$this->php = new stdClass();
3101
+		$this->_set_php_values();
3102
+	}
3103
+
3104
+
3105
+
3106
+	/**
3107
+	 * This sets the php environment variables.
3108
+	 *
3109
+	 * @since 4.4.0
3110
+	 * @return void
3111
+	 */
3112
+	protected function _set_php_values()
3113
+	{
3114
+		$this->php->max_input_vars = ini_get('max_input_vars');
3115
+		$this->php->version = phpversion();
3116
+	}
3117
+
3118
+
3119
+
3120
+	/**
3121
+	 * helper method for determining whether input_count is
3122
+	 * reaching the potential maximum the server can handle
3123
+	 * according to max_input_vars
3124
+	 *
3125
+	 * @param int   $input_count the count of input vars.
3126
+	 * @return array {
3127
+	 *                           An array that represents whether available space and if no available space the error
3128
+	 *                           message.
3129
+	 * @type bool   $has_space   whether more inputs can be added.
3130
+	 * @type string $msg         Any message to be displayed.
3131
+	 *                           }
3132
+	 */
3133
+	public function max_input_vars_limit_check($input_count = 0)
3134
+	{
3135
+		if (! empty($this->php->max_input_vars)
3136
+			&& ($input_count >= $this->php->max_input_vars)
3137
+			&& (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9)
3138
+		) {
3139
+			return sprintf(
3140
+				__(
3141
+					'The maximum number of inputs on this page has been exceeded.  You cannot add anymore items (i.e. tickets, datetimes, custom fields) on this page because of your servers PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.',
3142
+					'event_espresso'
3143
+				),
3144
+				'<br>',
3145
+				$input_count,
3146
+				$this->php->max_input_vars
3147
+			);
3148
+		} else {
3149
+			return '';
3150
+		}
3151
+	}
3152
+
3153
+
3154
+
3155
+	/**
3156
+	 * The purpose of this method is just to force rechecking php values so if they've changed, they get updated.
3157
+	 *
3158
+	 * @since 4.4.1
3159
+	 * @return void
3160
+	 */
3161
+	public function recheck_values()
3162
+	{
3163
+		$this->_set_php_values();
3164
+	}
3165 3165
 
3166 3166
 
3167 3167
 
@@ -3179,22 +3179,22 @@  discard block
 block discarded – undo
3179 3179
 class EE_Tax_Config extends EE_Config_Base
3180 3180
 {
3181 3181
 
3182
-    /*
3182
+	/*
3183 3183
      * flag to indicate whether or not to display ticket prices with the taxes included
3184 3184
      *
3185 3185
      * @var boolean $prices_displayed_including_taxes
3186 3186
      */
3187
-    public $prices_displayed_including_taxes;
3187
+	public $prices_displayed_including_taxes;
3188 3188
 
3189 3189
 
3190 3190
 
3191
-    /**
3192
-     *    class constructor
3193
-     */
3194
-    public function __construct()
3195
-    {
3196
-        $this->prices_displayed_including_taxes = true;
3197
-    }
3191
+	/**
3192
+	 *    class constructor
3193
+	 */
3194
+	public function __construct()
3195
+	{
3196
+		$this->prices_displayed_including_taxes = true;
3197
+	}
3198 3198
 }
3199 3199
 
3200 3200
 
@@ -3209,17 +3209,17 @@  discard block
 block discarded – undo
3209 3209
 class EE_Messages_Config extends EE_Config_Base
3210 3210
 {
3211 3211
 
3212
-    /**
3213
-     * This is an integer representing the deletion threshold in months for when old messages will get deleted.
3214
-     * A value of 0 represents never deleting.  Default is 0.
3215
-     *
3216
-     * @var integer
3217
-     */
3218
-    public $delete_threshold;
3219
-
3220
-    public function __construct() {
3221
-        $this->delete_threshold = 0;
3222
-    }
3212
+	/**
3213
+	 * This is an integer representing the deletion threshold in months for when old messages will get deleted.
3214
+	 * A value of 0 represents never deleting.  Default is 0.
3215
+	 *
3216
+	 * @var integer
3217
+	 */
3218
+	public $delete_threshold;
3219
+
3220
+	public function __construct() {
3221
+		$this->delete_threshold = 0;
3222
+	}
3223 3223
 }
3224 3224
 
3225 3225
 
@@ -3231,34 +3231,34 @@  discard block
 block discarded – undo
3231 3231
 class EE_Gateway_Config extends EE_Config_Base
3232 3232
 {
3233 3233
 
3234
-    /**
3235
-     * Array with keys that are payment gateways slugs, and values are arrays
3236
-     * with any config info the gateway wants to store
3237
-     *
3238
-     * @var array
3239
-     */
3240
-    public $payment_settings;
3241
-
3242
-    /**
3243
-     * Where keys are gateway slugs, and values are booleans indicating whether or not
3244
-     * the gateway is stored in the uploads directory
3245
-     *
3246
-     * @var array
3247
-     */
3248
-    public $active_gateways;
3249
-
3250
-
3251
-
3252
-    /**
3253
-     *    class constructor
3254
-     *
3255
-     * @deprecated
3256
-     */
3257
-    public function __construct()
3258
-    {
3259
-        $this->payment_settings = array();
3260
-        $this->active_gateways = array('Invoice' => false);
3261
-    }
3234
+	/**
3235
+	 * Array with keys that are payment gateways slugs, and values are arrays
3236
+	 * with any config info the gateway wants to store
3237
+	 *
3238
+	 * @var array
3239
+	 */
3240
+	public $payment_settings;
3241
+
3242
+	/**
3243
+	 * Where keys are gateway slugs, and values are booleans indicating whether or not
3244
+	 * the gateway is stored in the uploads directory
3245
+	 *
3246
+	 * @var array
3247
+	 */
3248
+	public $active_gateways;
3249
+
3250
+
3251
+
3252
+	/**
3253
+	 *    class constructor
3254
+	 *
3255
+	 * @deprecated
3256
+	 */
3257
+	public function __construct()
3258
+	{
3259
+		$this->payment_settings = array();
3260
+		$this->active_gateways = array('Invoice' => false);
3261
+	}
3262 3262
 }
3263 3263
 
3264 3264
 // End of file EE_Config.core.php
Please login to merge, or discard this patch.
core/EE_Cart.core.php 1 patch
Indentation   +413 added lines, -413 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 use EventEspresso\core\interfaces\ResettableInterface;
3 3
 
4 4
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
5
-    exit('No direct script access allowed');
5
+	exit('No direct script access allowed');
6 6
 }
7 7
 do_action('AHEE_log', __FILE__, __FUNCTION__, '');
8 8
 
@@ -23,418 +23,418 @@  discard block
 block discarded – undo
23 23
 class EE_Cart implements ResettableInterface
24 24
 {
25 25
 
26
-    /**
27
-     * instance of the EE_Cart object
28
-     *
29
-     * @access    private
30
-     * @var EE_Cart $_instance
31
-     */
32
-    private static $_instance;
33
-
34
-    /**
35
-     * instance of the EE_Session object
36
-     *
37
-     * @access    protected
38
-     * @var EE_Session $_session
39
-     */
40
-    protected $_session;
41
-
42
-    /**
43
-     * The total Line item which comprises all the children line-item subtotals,
44
-     * which in turn each have their line items.
45
-     * Typically, the line item structure will look like:
46
-     * grand total
47
-     * -tickets-sub-total
48
-     * --ticket1
49
-     * --ticket2
50
-     * --...
51
-     * -taxes-sub-total
52
-     * --tax1
53
-     * --tax2
54
-     *
55
-     * @var EE_Line_Item
56
-     */
57
-    private $_grand_total;
58
-
59
-
60
-
61
-    /**
62
-     * @singleton method used to instantiate class object
63
-     * @access    public
64
-     * @param EE_Line_Item $grand_total
65
-     * @param EE_Session   $session
66
-     * @return \EE_Cart
67
-     * @throws \EE_Error
68
-     */
69
-    public static function instance(EE_Line_Item $grand_total = null, EE_Session $session = null)
70
-    {
71
-        if ( ! empty($grand_total)) {
72
-            self::$_instance = new self($grand_total, $session);
73
-        }
74
-        // or maybe retrieve an existing one ?
75
-        if ( ! self::$_instance instanceof EE_Cart) {
76
-            // try getting the cart out of the session
77
-            $saved_cart = $session instanceof EE_Session ? $session->cart() : null;
78
-            self::$_instance = $saved_cart instanceof EE_Cart ? $saved_cart : new self($grand_total, $session);
79
-            unset($saved_cart);
80
-        }
81
-        // verify that cart is ok and grand total line item exists
82
-        if ( ! self::$_instance instanceof EE_Cart || ! self::$_instance->_grand_total instanceof EE_Line_Item) {
83
-            self::$_instance = new self($grand_total, $session);
84
-        }
85
-        self::$_instance->get_grand_total();
86
-        // once everything is all said and done, save the cart to the EE_Session
87
-        add_action('shutdown', array(self::$_instance, 'save_cart'), 90);
88
-        return self::$_instance;
89
-    }
90
-
91
-
92
-
93
-    /**
94
-     * private constructor to prevent direct creation
95
-     *
96
-     * @Constructor
97
-     * @access private
98
-     * @param EE_Line_Item $grand_total
99
-     * @param EE_Session   $session
100
-     */
101
-    private function __construct(EE_Line_Item $grand_total = null, EE_Session $session = null)
102
-    {
103
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
104
-        $this->set_session($session);
105
-        if ($grand_total instanceof EE_Line_Item) {
106
-            $this->set_grand_total_line_item($grand_total);
107
-        }
108
-    }
109
-
110
-
111
-
112
-    /**
113
-     * Resets the cart completely (whereas empty_cart
114
-     *
115
-     * @param EE_Line_Item $grand_total
116
-     * @param EE_Session   $session
117
-     * @return EE_Cart
118
-     * @throws \EE_Error
119
-     */
120
-    public static function reset(EE_Line_Item $grand_total = null, EE_Session $session = null)
121
-    {
122
-        remove_action('shutdown', array(self::$_instance, 'save_cart'), 90);
123
-        if ($session instanceof EE_Session) {
124
-            $session->reset_cart();
125
-        }
126
-        self::$_instance = null;
127
-        return self::instance($grand_total, $session);
128
-    }
129
-
130
-
131
-
132
-    /**
133
-     * @return \EE_Session
134
-     */
135
-    public function session()
136
-    {
137
-        if ( ! $this->_session instanceof EE_Session) {
138
-            $this->set_session();
139
-        }
140
-        return $this->_session;
141
-    }
142
-
143
-
144
-
145
-    /**
146
-     * @param EE_Session $session
147
-     */
148
-    public function set_session(EE_Session $session = null)
149
-    {
150
-        $this->_session = $session instanceof EE_Session ? $session : EE_Registry::instance()->load_core('Session');
151
-    }
152
-
153
-
154
-
155
-    /**
156
-     * Sets the cart to match the line item. Especially handy for loading an old cart where you
157
-     *  know the grand total line item on it
158
-     *
159
-     * @param EE_Line_Item $line_item
160
-     */
161
-    public function set_grand_total_line_item(EE_Line_Item $line_item)
162
-    {
163
-        $this->_grand_total = $line_item;
164
-    }
165
-
166
-
167
-
168
-    /**
169
-     * get_cart_from_reg_url_link
170
-     *
171
-     * @access public
172
-     * @param EE_Transaction $transaction
173
-     * @param EE_Session     $session
174
-     * @return \EE_Cart
175
-     * @throws \EE_Error
176
-     */
177
-    public static function get_cart_from_txn(EE_Transaction $transaction, EE_Session $session = null)
178
-    {
179
-        $grand_total = $transaction->total_line_item();
180
-        $grand_total->get_items();
181
-        $grand_total->tax_descendants();
182
-        return EE_Cart::instance($grand_total, $session);
183
-    }
184
-
185
-
186
-
187
-    /**
188
-     * Creates the total line item, and ensures it has its 'tickets' and 'taxes' sub-items
189
-     *
190
-     * @return EE_Line_Item
191
-     * @throws \EE_Error
192
-     */
193
-    private function _create_grand_total()
194
-    {
195
-        $this->_grand_total = EEH_Line_Item::create_total_line_item();
196
-        return $this->_grand_total;
197
-    }
198
-
199
-
200
-
201
-    /**
202
-     * Gets all the line items of object type Ticket
203
-     *
204
-     * @access public
205
-     * @return \EE_Line_Item[]
206
-     */
207
-    public function get_tickets()
208
-    {
209
-        if ($this->_grand_total === null ) {
210
-            return array();
211
-        }
212
-        return EEH_Line_Item::get_ticket_line_items($this->_grand_total);
213
-    }
214
-
215
-
216
-
217
-    /**
218
-     * returns the total quantity of tickets in the cart
219
-     *
220
-     * @access public
221
-     * @return int
222
-     * @throws \EE_Error
223
-     */
224
-    public function all_ticket_quantity_count()
225
-    {
226
-        $tickets = $this->get_tickets();
227
-        if (empty($tickets)) {
228
-            return 0;
229
-        }
230
-        $count = 0;
231
-        foreach ($tickets as $ticket) {
232
-            $count += $ticket->get('LIN_quantity');
233
-        }
234
-        return $count;
235
-    }
236
-
237
-
238
-
239
-    /**
240
-     * Gets all the tax line items
241
-     *
242
-     * @return \EE_Line_Item[]
243
-     * @throws \EE_Error
244
-     */
245
-    public function get_taxes()
246
-    {
247
-        return EEH_Line_Item::get_taxes_subtotal($this->_grand_total)->children();
248
-    }
249
-
250
-
251
-
252
-    /**
253
-     * Gets the total line item (which is a parent of all other line items) on this cart
254
-     *
255
-     * @return EE_Line_Item
256
-     * @throws \EE_Error
257
-     */
258
-    public function get_grand_total()
259
-    {
260
-        return $this->_grand_total instanceof EE_Line_Item ? $this->_grand_total : $this->_create_grand_total();
261
-    }
262
-
263
-
264
-
265
-    /**
266
-     * @process items for adding to cart
267
-     * @access  public
268
-     * @param EE_Ticket $ticket
269
-     * @param int       $qty
270
-     * @return TRUE on success, FALSE on fail
271
-     * @throws \EE_Error
272
-     */
273
-    public function add_ticket_to_cart(EE_Ticket $ticket, $qty = 1)
274
-    {
275
-        EEH_Line_Item::add_ticket_purchase($this->get_grand_total(), $ticket, $qty);
276
-        return $this->save_cart() ? true : false;
277
-    }
278
-
279
-
280
-
281
-    /**
282
-     * get_cart_total_before_tax
283
-     *
284
-     * @access public
285
-     * @return float
286
-     * @throws \EE_Error
287
-     */
288
-    public function get_cart_total_before_tax()
289
-    {
290
-        return $this->get_grand_total()->recalculate_pre_tax_total();
291
-    }
292
-
293
-
294
-
295
-    /**
296
-     * gets the total amount of tax paid for items in this cart
297
-     *
298
-     * @access public
299
-     * @return float
300
-     * @throws \EE_Error
301
-     */
302
-    public function get_applied_taxes()
303
-    {
304
-        return EEH_Line_Item::ensure_taxes_applied($this->_grand_total);
305
-    }
306
-
307
-
308
-
309
-    /**
310
-     * Gets the total amount to be paid for the items in the cart, including taxes and other modifiers
311
-     *
312
-     * @access public
313
-     * @return float
314
-     * @throws \EE_Error
315
-     */
316
-    public function get_cart_grand_total()
317
-    {
318
-        EEH_Line_Item::ensure_taxes_applied($this->_grand_total);
319
-        return $this->get_grand_total()->total();
320
-    }
321
-
322
-
323
-
324
-    /**
325
-     * Gets the total amount to be paid for the items in the cart, including taxes and other modifiers
326
-     *
327
-     * @access public
328
-     * @return float
329
-     * @throws \EE_Error
330
-     */
331
-    public function recalculate_all_cart_totals()
332
-    {
333
-        $pre_tax_total = $this->get_cart_total_before_tax();
334
-        $taxes_total = EEH_Line_Item::ensure_taxes_applied($this->_grand_total);
335
-        $this->_grand_total->set_total($pre_tax_total + $taxes_total);
336
-        $this->_grand_total->save_this_and_descendants_to_txn();
337
-        return $this->get_grand_total()->total();
338
-    }
339
-
340
-
341
-
342
-    /**
343
-     * deletes an item from the cart
344
-     *
345
-     * @access public
346
-     * @param array|bool|string $line_item_codes
347
-     * @return int on success, FALSE on fail
348
-     * @throws \EE_Error
349
-     */
350
-    public function delete_items($line_item_codes = false)
351
-    {
352
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
353
-        return EEH_Line_Item::delete_items($this->get_grand_total(), $line_item_codes);
354
-    }
355
-
356
-
357
-
358
-    /**
359
-     * @remove ALL items from cart and zero ALL totals
360
-     * @access public
361
-     * @return bool
362
-     * @throws \EE_Error
363
-     */
364
-    public function empty_cart()
365
-    {
366
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
367
-        $this->_grand_total = $this->_create_grand_total();
368
-        return $this->save_cart(true);
369
-    }
370
-
371
-
372
-
373
-    /**
374
-     * @remove ALL items from cart and delete total as well
375
-     * @access public
376
-     * @return bool
377
-     * @throws \EE_Error
378
-     */
379
-    public function delete_cart()
380
-    {
381
-        $deleted = EEH_Line_Item::delete_all_child_items($this->_grand_total);
382
-        if ($deleted) {
383
-            $deleted += $this->_grand_total->delete();
384
-            $this->_grand_total = null;
385
-        }
386
-        return $deleted;
387
-    }
388
-
389
-
390
-
391
-    /**
392
-     * @save   cart to session
393
-     * @access public
394
-     * @param bool $apply_taxes
395
-     * @return TRUE on success, FALSE on fail
396
-     * @throws \EE_Error
397
-     */
398
-    public function save_cart($apply_taxes = true)
399
-    {
400
-        if ($apply_taxes && $this->_grand_total instanceof EE_Line_Item) {
401
-            EEH_Line_Item::ensure_taxes_applied($this->_grand_total);
402
-            //make sure we don't cache the transaction because it can get stale
403
-            if ($this->_grand_total->get_one_from_cache('Transaction') instanceof EE_Transaction
404
-                && $this->_grand_total->get_one_from_cache('Transaction')->ID()
405
-            ) {
406
-                $this->_grand_total->clear_cache('Transaction', null, true);
407
-            }
408
-        }
409
-        if ($this->session() instanceof EE_Session) {
410
-            return $this->session()->set_cart($this);
411
-        } else {
412
-            return false;
413
-        }
414
-    }
415
-
416
-
417
-
418
-    public function __wakeup()
419
-    {
420
-        if ( ! $this->_grand_total instanceof EE_Line_Item && absint($this->_grand_total) !== 0) {
421
-            // $this->_grand_total is actually just an ID, so use it to get the object from the db
422
-            $this->_grand_total = EEM_Line_Item::instance()->get_one_by_ID($this->_grand_total);
423
-        }
424
-    }
425
-
426
-
427
-
428
-    /**
429
-     * @return array
430
-     */
431
-    public function __sleep()
432
-    {
433
-        if ($this->_grand_total instanceof EE_Line_Item && $this->_grand_total->ID()) {
434
-            $this->_grand_total = $this->_grand_total->ID();
435
-        }
436
-        return array('_grand_total');
437
-    }
26
+	/**
27
+	 * instance of the EE_Cart object
28
+	 *
29
+	 * @access    private
30
+	 * @var EE_Cart $_instance
31
+	 */
32
+	private static $_instance;
33
+
34
+	/**
35
+	 * instance of the EE_Session object
36
+	 *
37
+	 * @access    protected
38
+	 * @var EE_Session $_session
39
+	 */
40
+	protected $_session;
41
+
42
+	/**
43
+	 * The total Line item which comprises all the children line-item subtotals,
44
+	 * which in turn each have their line items.
45
+	 * Typically, the line item structure will look like:
46
+	 * grand total
47
+	 * -tickets-sub-total
48
+	 * --ticket1
49
+	 * --ticket2
50
+	 * --...
51
+	 * -taxes-sub-total
52
+	 * --tax1
53
+	 * --tax2
54
+	 *
55
+	 * @var EE_Line_Item
56
+	 */
57
+	private $_grand_total;
58
+
59
+
60
+
61
+	/**
62
+	 * @singleton method used to instantiate class object
63
+	 * @access    public
64
+	 * @param EE_Line_Item $grand_total
65
+	 * @param EE_Session   $session
66
+	 * @return \EE_Cart
67
+	 * @throws \EE_Error
68
+	 */
69
+	public static function instance(EE_Line_Item $grand_total = null, EE_Session $session = null)
70
+	{
71
+		if ( ! empty($grand_total)) {
72
+			self::$_instance = new self($grand_total, $session);
73
+		}
74
+		// or maybe retrieve an existing one ?
75
+		if ( ! self::$_instance instanceof EE_Cart) {
76
+			// try getting the cart out of the session
77
+			$saved_cart = $session instanceof EE_Session ? $session->cart() : null;
78
+			self::$_instance = $saved_cart instanceof EE_Cart ? $saved_cart : new self($grand_total, $session);
79
+			unset($saved_cart);
80
+		}
81
+		// verify that cart is ok and grand total line item exists
82
+		if ( ! self::$_instance instanceof EE_Cart || ! self::$_instance->_grand_total instanceof EE_Line_Item) {
83
+			self::$_instance = new self($grand_total, $session);
84
+		}
85
+		self::$_instance->get_grand_total();
86
+		// once everything is all said and done, save the cart to the EE_Session
87
+		add_action('shutdown', array(self::$_instance, 'save_cart'), 90);
88
+		return self::$_instance;
89
+	}
90
+
91
+
92
+
93
+	/**
94
+	 * private constructor to prevent direct creation
95
+	 *
96
+	 * @Constructor
97
+	 * @access private
98
+	 * @param EE_Line_Item $grand_total
99
+	 * @param EE_Session   $session
100
+	 */
101
+	private function __construct(EE_Line_Item $grand_total = null, EE_Session $session = null)
102
+	{
103
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
104
+		$this->set_session($session);
105
+		if ($grand_total instanceof EE_Line_Item) {
106
+			$this->set_grand_total_line_item($grand_total);
107
+		}
108
+	}
109
+
110
+
111
+
112
+	/**
113
+	 * Resets the cart completely (whereas empty_cart
114
+	 *
115
+	 * @param EE_Line_Item $grand_total
116
+	 * @param EE_Session   $session
117
+	 * @return EE_Cart
118
+	 * @throws \EE_Error
119
+	 */
120
+	public static function reset(EE_Line_Item $grand_total = null, EE_Session $session = null)
121
+	{
122
+		remove_action('shutdown', array(self::$_instance, 'save_cart'), 90);
123
+		if ($session instanceof EE_Session) {
124
+			$session->reset_cart();
125
+		}
126
+		self::$_instance = null;
127
+		return self::instance($grand_total, $session);
128
+	}
129
+
130
+
131
+
132
+	/**
133
+	 * @return \EE_Session
134
+	 */
135
+	public function session()
136
+	{
137
+		if ( ! $this->_session instanceof EE_Session) {
138
+			$this->set_session();
139
+		}
140
+		return $this->_session;
141
+	}
142
+
143
+
144
+
145
+	/**
146
+	 * @param EE_Session $session
147
+	 */
148
+	public function set_session(EE_Session $session = null)
149
+	{
150
+		$this->_session = $session instanceof EE_Session ? $session : EE_Registry::instance()->load_core('Session');
151
+	}
152
+
153
+
154
+
155
+	/**
156
+	 * Sets the cart to match the line item. Especially handy for loading an old cart where you
157
+	 *  know the grand total line item on it
158
+	 *
159
+	 * @param EE_Line_Item $line_item
160
+	 */
161
+	public function set_grand_total_line_item(EE_Line_Item $line_item)
162
+	{
163
+		$this->_grand_total = $line_item;
164
+	}
165
+
166
+
167
+
168
+	/**
169
+	 * get_cart_from_reg_url_link
170
+	 *
171
+	 * @access public
172
+	 * @param EE_Transaction $transaction
173
+	 * @param EE_Session     $session
174
+	 * @return \EE_Cart
175
+	 * @throws \EE_Error
176
+	 */
177
+	public static function get_cart_from_txn(EE_Transaction $transaction, EE_Session $session = null)
178
+	{
179
+		$grand_total = $transaction->total_line_item();
180
+		$grand_total->get_items();
181
+		$grand_total->tax_descendants();
182
+		return EE_Cart::instance($grand_total, $session);
183
+	}
184
+
185
+
186
+
187
+	/**
188
+	 * Creates the total line item, and ensures it has its 'tickets' and 'taxes' sub-items
189
+	 *
190
+	 * @return EE_Line_Item
191
+	 * @throws \EE_Error
192
+	 */
193
+	private function _create_grand_total()
194
+	{
195
+		$this->_grand_total = EEH_Line_Item::create_total_line_item();
196
+		return $this->_grand_total;
197
+	}
198
+
199
+
200
+
201
+	/**
202
+	 * Gets all the line items of object type Ticket
203
+	 *
204
+	 * @access public
205
+	 * @return \EE_Line_Item[]
206
+	 */
207
+	public function get_tickets()
208
+	{
209
+		if ($this->_grand_total === null ) {
210
+			return array();
211
+		}
212
+		return EEH_Line_Item::get_ticket_line_items($this->_grand_total);
213
+	}
214
+
215
+
216
+
217
+	/**
218
+	 * returns the total quantity of tickets in the cart
219
+	 *
220
+	 * @access public
221
+	 * @return int
222
+	 * @throws \EE_Error
223
+	 */
224
+	public function all_ticket_quantity_count()
225
+	{
226
+		$tickets = $this->get_tickets();
227
+		if (empty($tickets)) {
228
+			return 0;
229
+		}
230
+		$count = 0;
231
+		foreach ($tickets as $ticket) {
232
+			$count += $ticket->get('LIN_quantity');
233
+		}
234
+		return $count;
235
+	}
236
+
237
+
238
+
239
+	/**
240
+	 * Gets all the tax line items
241
+	 *
242
+	 * @return \EE_Line_Item[]
243
+	 * @throws \EE_Error
244
+	 */
245
+	public function get_taxes()
246
+	{
247
+		return EEH_Line_Item::get_taxes_subtotal($this->_grand_total)->children();
248
+	}
249
+
250
+
251
+
252
+	/**
253
+	 * Gets the total line item (which is a parent of all other line items) on this cart
254
+	 *
255
+	 * @return EE_Line_Item
256
+	 * @throws \EE_Error
257
+	 */
258
+	public function get_grand_total()
259
+	{
260
+		return $this->_grand_total instanceof EE_Line_Item ? $this->_grand_total : $this->_create_grand_total();
261
+	}
262
+
263
+
264
+
265
+	/**
266
+	 * @process items for adding to cart
267
+	 * @access  public
268
+	 * @param EE_Ticket $ticket
269
+	 * @param int       $qty
270
+	 * @return TRUE on success, FALSE on fail
271
+	 * @throws \EE_Error
272
+	 */
273
+	public function add_ticket_to_cart(EE_Ticket $ticket, $qty = 1)
274
+	{
275
+		EEH_Line_Item::add_ticket_purchase($this->get_grand_total(), $ticket, $qty);
276
+		return $this->save_cart() ? true : false;
277
+	}
278
+
279
+
280
+
281
+	/**
282
+	 * get_cart_total_before_tax
283
+	 *
284
+	 * @access public
285
+	 * @return float
286
+	 * @throws \EE_Error
287
+	 */
288
+	public function get_cart_total_before_tax()
289
+	{
290
+		return $this->get_grand_total()->recalculate_pre_tax_total();
291
+	}
292
+
293
+
294
+
295
+	/**
296
+	 * gets the total amount of tax paid for items in this cart
297
+	 *
298
+	 * @access public
299
+	 * @return float
300
+	 * @throws \EE_Error
301
+	 */
302
+	public function get_applied_taxes()
303
+	{
304
+		return EEH_Line_Item::ensure_taxes_applied($this->_grand_total);
305
+	}
306
+
307
+
308
+
309
+	/**
310
+	 * Gets the total amount to be paid for the items in the cart, including taxes and other modifiers
311
+	 *
312
+	 * @access public
313
+	 * @return float
314
+	 * @throws \EE_Error
315
+	 */
316
+	public function get_cart_grand_total()
317
+	{
318
+		EEH_Line_Item::ensure_taxes_applied($this->_grand_total);
319
+		return $this->get_grand_total()->total();
320
+	}
321
+
322
+
323
+
324
+	/**
325
+	 * Gets the total amount to be paid for the items in the cart, including taxes and other modifiers
326
+	 *
327
+	 * @access public
328
+	 * @return float
329
+	 * @throws \EE_Error
330
+	 */
331
+	public function recalculate_all_cart_totals()
332
+	{
333
+		$pre_tax_total = $this->get_cart_total_before_tax();
334
+		$taxes_total = EEH_Line_Item::ensure_taxes_applied($this->_grand_total);
335
+		$this->_grand_total->set_total($pre_tax_total + $taxes_total);
336
+		$this->_grand_total->save_this_and_descendants_to_txn();
337
+		return $this->get_grand_total()->total();
338
+	}
339
+
340
+
341
+
342
+	/**
343
+	 * deletes an item from the cart
344
+	 *
345
+	 * @access public
346
+	 * @param array|bool|string $line_item_codes
347
+	 * @return int on success, FALSE on fail
348
+	 * @throws \EE_Error
349
+	 */
350
+	public function delete_items($line_item_codes = false)
351
+	{
352
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
353
+		return EEH_Line_Item::delete_items($this->get_grand_total(), $line_item_codes);
354
+	}
355
+
356
+
357
+
358
+	/**
359
+	 * @remove ALL items from cart and zero ALL totals
360
+	 * @access public
361
+	 * @return bool
362
+	 * @throws \EE_Error
363
+	 */
364
+	public function empty_cart()
365
+	{
366
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
367
+		$this->_grand_total = $this->_create_grand_total();
368
+		return $this->save_cart(true);
369
+	}
370
+
371
+
372
+
373
+	/**
374
+	 * @remove ALL items from cart and delete total as well
375
+	 * @access public
376
+	 * @return bool
377
+	 * @throws \EE_Error
378
+	 */
379
+	public function delete_cart()
380
+	{
381
+		$deleted = EEH_Line_Item::delete_all_child_items($this->_grand_total);
382
+		if ($deleted) {
383
+			$deleted += $this->_grand_total->delete();
384
+			$this->_grand_total = null;
385
+		}
386
+		return $deleted;
387
+	}
388
+
389
+
390
+
391
+	/**
392
+	 * @save   cart to session
393
+	 * @access public
394
+	 * @param bool $apply_taxes
395
+	 * @return TRUE on success, FALSE on fail
396
+	 * @throws \EE_Error
397
+	 */
398
+	public function save_cart($apply_taxes = true)
399
+	{
400
+		if ($apply_taxes && $this->_grand_total instanceof EE_Line_Item) {
401
+			EEH_Line_Item::ensure_taxes_applied($this->_grand_total);
402
+			//make sure we don't cache the transaction because it can get stale
403
+			if ($this->_grand_total->get_one_from_cache('Transaction') instanceof EE_Transaction
404
+				&& $this->_grand_total->get_one_from_cache('Transaction')->ID()
405
+			) {
406
+				$this->_grand_total->clear_cache('Transaction', null, true);
407
+			}
408
+		}
409
+		if ($this->session() instanceof EE_Session) {
410
+			return $this->session()->set_cart($this);
411
+		} else {
412
+			return false;
413
+		}
414
+	}
415
+
416
+
417
+
418
+	public function __wakeup()
419
+	{
420
+		if ( ! $this->_grand_total instanceof EE_Line_Item && absint($this->_grand_total) !== 0) {
421
+			// $this->_grand_total is actually just an ID, so use it to get the object from the db
422
+			$this->_grand_total = EEM_Line_Item::instance()->get_one_by_ID($this->_grand_total);
423
+		}
424
+	}
425
+
426
+
427
+
428
+	/**
429
+	 * @return array
430
+	 */
431
+	public function __sleep()
432
+	{
433
+		if ($this->_grand_total instanceof EE_Line_Item && $this->_grand_total->ID()) {
434
+			$this->_grand_total = $this->_grand_total->ID();
435
+		}
436
+		return array('_grand_total');
437
+	}
438 438
 
439 439
 
440 440
 }
Please login to merge, or discard this patch.
core/EE_Payment_Processor.core.php 1 patch
Indentation   +745 added lines, -745 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php use EventEspresso\core\interfaces\ResettableInterface;
2 2
 
3 3
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
4
-    exit('No direct script access allowed');
4
+	exit('No direct script access allowed');
5 5
 }
6 6
 EE_Registry::instance()->load_class('Processor_Base');
7 7
 
@@ -18,748 +18,748 @@  discard block
 block discarded – undo
18 18
 class EE_Payment_Processor extends EE_Processor_Base implements ResettableInterface
19 19
 {
20 20
 
21
-    /**
22
-     * @var EE_Payment_Processor $_instance
23
-     * @access    private
24
-     */
25
-    private static $_instance;
26
-
27
-
28
-
29
-    /**
30
-     * @singleton method used to instantiate class object
31
-     * @access    public
32
-     * @return EE_Payment_Processor instance
33
-     */
34
-    public static function instance()
35
-    {
36
-        // check if class object is instantiated
37
-        if ( ! self::$_instance instanceof EE_Payment_Processor) {
38
-            self::$_instance = new self();
39
-        }
40
-        return self::$_instance;
41
-    }
42
-
43
-
44
-
45
-    /**
46
-     * @return EE_Payment_Processor
47
-     */
48
-    public static function reset()
49
-    {
50
-        self::$_instance = null;
51
-        return self::instance();
52
-    }
53
-
54
-
55
-
56
-    /**
57
-     *private constructor to prevent direct creation
58
-     *
59
-     * @Constructor
60
-     * @access private
61
-     */
62
-    private function __construct()
63
-    {
64
-        do_action('AHEE__EE_Payment_Processor__construct');
65
-        add_action('http_api_curl', array($this, '_curl_requests_to_paypal_use_tls'), 10, 3);
66
-    }
67
-
68
-
69
-
70
-    /**
71
-     * Using the selected gateway, processes the payment for that transaction, and updates the transaction
72
-     * appropriately. Saves the payment that is generated
73
-     *
74
-     * @param EE_Payment_Method    $payment_method
75
-     * @param EE_Transaction       $transaction
76
-     * @param float                $amount       if only part of the transaction is to be paid for, how much.
77
-     *                                           Leave null if payment is for the full amount owing
78
-     * @param EE_Billing_Info_Form $billing_form (or probably null, if it's an offline or offsite payment method).
79
-     *                                           Receive_form_submission() should have
80
-     *                                           already been called on the billing form
81
-     *                                           (ie, its inputs should have their normalized values set).
82
-     * @param string               $return_url   string used mostly by offsite gateways to specify
83
-     *                                           where to go AFTER the offsite gateway
84
-     * @param string               $method       like 'CART', indicates who the client who called this was
85
-     * @param bool                 $by_admin     TRUE if payment is being attempted from the admin
86
-     * @param boolean              $update_txn   whether or not to call
87
-     *                                           EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()
88
-     * @param string               $cancel_url   URL to return to if off-site payments are cancelled
89
-     * @return \EE_Payment
90
-     * @throws \EE_Error
91
-     */
92
-    public function process_payment(
93
-        EE_Payment_Method $payment_method,
94
-        EE_Transaction $transaction,
95
-        $amount = null,
96
-        $billing_form = null,
97
-        $return_url = null,
98
-        $method = 'CART',
99
-        $by_admin = false,
100
-        $update_txn = true,
101
-        $cancel_url = ''
102
-    ) {
103
-        if ((float)$amount < 0) {
104
-            throw new EE_Error(
105
-                sprintf(
106
-                    __(
107
-                        'Attempting to make a payment for a negative amount of %1$d for transaction %2$d. That should be a refund',
108
-                        'event_espresso'
109
-                    ),
110
-                    $amount,
111
-                    $transaction->ID()
112
-                )
113
-            );
114
-        }
115
-        // verify payment method
116
-        $payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method, true);
117
-        // verify transaction
118
-        EEM_Transaction::instance()->ensure_is_obj($transaction);
119
-        $transaction->set_payment_method_ID($payment_method->ID());
120
-        // verify payment method type
121
-        if ($payment_method->type_obj() instanceof EE_PMT_Base) {
122
-            $payment = $payment_method->type_obj()->process_payment(
123
-                $transaction,
124
-                min($amount, $transaction->remaining()),//make sure we don't overcharge
125
-                $billing_form,
126
-                $return_url,
127
-                add_query_arg(array('ee_cancel_payment' => true), $cancel_url),
128
-                $method,
129
-                $by_admin
130
-            );
131
-            // check if payment method uses an off-site gateway
132
-            if ($payment_method->type_obj()->payment_occurs() !== EE_PMT_Base::offsite) {
133
-                // don't process payments for off-site gateways yet because no payment has occurred yet
134
-                $this->update_txn_based_on_payment($transaction, $payment, $update_txn);
135
-            }
136
-            return $payment;
137
-        } else {
138
-            EE_Error::add_error(
139
-                sprintf(
140
-                    __('A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'),
141
-                    '<br/>',
142
-                    EE_Registry::instance()->CFG->organization->get_pretty('email')
143
-                ), __FILE__, __FUNCTION__, __LINE__
144
-            );
145
-            return null;
146
-        }
147
-    }
148
-
149
-
150
-
151
-    /**
152
-     * @param EE_Transaction|int $transaction
153
-     * @param EE_Payment_Method  $payment_method
154
-     * @throws EE_Error
155
-     * @return string
156
-     */
157
-    public function get_ipn_url_for_payment_method($transaction, $payment_method)
158
-    {
159
-        /** @type \EE_Transaction $transaction */
160
-        $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction);
161
-        $primary_reg = $transaction->primary_registration();
162
-        if ( ! $primary_reg instanceof EE_Registration) {
163
-            throw new EE_Error(
164
-                sprintf(
165
-                    __(
166
-                        "Cannot get IPN URL for transaction with ID %d because it has no primary registration",
167
-                        "event_espresso"
168
-                    ),
169
-                    $transaction->ID()
170
-                )
171
-            );
172
-        }
173
-        $payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method, true);
174
-        $url = add_query_arg(
175
-            array(
176
-                'e_reg_url_link'    => $primary_reg->reg_url_link(),
177
-                'ee_payment_method' => $payment_method->slug(),
178
-            ),
179
-            EE_Registry::instance()->CFG->core->txn_page_url()
180
-        );
181
-        return $url;
182
-    }
183
-
184
-
185
-
186
-    /**
187
-     * Process the IPN. Firstly, we'll hope we put the standard args into the IPN URL so
188
-     * we can easily find what registration the IPN is for and what payment method.
189
-     * However, if not, we'll give all payment methods a chance to claim it and process it.
190
-     * If a payment is found for the IPN info, it is saved.
191
-     *
192
-     * @param array              $_req_data            eg $_REQUEST
193
-     * @param EE_Transaction|int $transaction          optional (or a transactions id)
194
-     * @param EE_Payment_Method  $payment_method       (or a slug or id of one)
195
-     * @param boolean            $update_txn           whether or not to call
196
-     *                                                 EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()
197
-     * @param bool               $separate_IPN_request whether the IPN uses a separate request ( true like PayPal )
198
-     *                                                 or is processed manually ( false like Mijireh )
199
-     * @throws EE_Error
200
-     * @throws Exception
201
-     * @return EE_Payment
202
-     */
203
-    public function process_ipn(
204
-        $_req_data,
205
-        $transaction = null,
206
-        $payment_method = null,
207
-        $update_txn = true,
208
-        $separate_IPN_request = true
209
-    ) {
210
-        EE_Registry::instance()->load_model('Change_Log');
211
-        $_req_data = $this->_remove_unusable_characters_from_array((array)$_req_data);
212
-        EE_Processor_Base::set_IPN($separate_IPN_request);
213
-        $obj_for_log = null;
214
-        if ($transaction instanceof EE_Transaction) {
215
-            $obj_for_log = $transaction;
216
-            if ($payment_method instanceof EE_Payment_Method) {
217
-                $obj_for_log = EEM_Payment::instance()->get_one(
218
-                    array(
219
-                        array('TXN_ID' => $transaction->ID(), 'PMD_ID' => $payment_method->ID()),
220
-                        'order_by' => array('PAY_timestamp' => 'desc'),
221
-                    )
222
-                );
223
-            }
224
-        } else if ($payment_method instanceof EE_Payment) {
225
-            $obj_for_log = $payment_method;
226
-        }
227
-        $log = EEM_Change_Log::instance()->log(
228
-            EEM_Change_Log::type_gateway,
229
-            array('IPN data received' => $_req_data),
230
-            $obj_for_log
231
-        );
232
-        try {
233
-            /**
234
-             * @var EE_Payment $payment
235
-             */
236
-            $payment = null;
237
-            if ($transaction && $payment_method) {
238
-                /** @type EE_Transaction $transaction */
239
-                $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction);
240
-                /** @type EE_Payment_Method $payment_method */
241
-                $payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method);
242
-                if ($payment_method->type_obj() instanceof EE_PMT_Base) {
243
-                    try {
244
-                        $payment = $payment_method->type_obj()->handle_ipn($_req_data, $transaction);
245
-                        $log->set_object($payment);
246
-                    } catch (EventEspresso\core\exceptions\IpnException $e) {
247
-                        EEM_Change_Log::instance()->log(
248
-                            EEM_Change_Log::type_gateway,
249
-                            array(
250
-                                'message'     => 'IPN Exception: ' . $e->getMessage(),
251
-                                'current_url' => EEH_URL::current_url(),
252
-                                'payment'     => $e->getPaymentProperties(),
253
-                                'IPN_data'    => $e->getIpnData(),
254
-                            ),
255
-                            $obj_for_log
256
-                        );
257
-                        return $e->getPayment();
258
-                    }
259
-                } else {
260
-                    // not a payment
261
-                    EE_Error::add_error(
262
-                        sprintf(
263
-                            __('A valid payment method could not be determined due to a technical issue.%sPlease refresh your browser and try again or contact %s for assistance.', 'event_espresso'),
264
-                            '<br/>',
265
-                            EE_Registry::instance()->CFG->organization->get_pretty('email')
266
-                        ),
267
-                        __FILE__, __FUNCTION__, __LINE__
268
-                    );
269
-                }
270
-            } else {
271
-                //that's actually pretty ok. The IPN just wasn't able
272
-                //to identify which transaction or payment method this was for
273
-                // give all active payment methods a chance to claim it
274
-                $active_payment_methods = EEM_Payment_Method::instance()->get_all_active();
275
-                foreach ($active_payment_methods as $active_payment_method) {
276
-                    try {
277
-                        $payment = $active_payment_method->type_obj()->handle_unclaimed_ipn($_req_data);
278
-                        $payment_method = $active_payment_method;
279
-                        EEM_Change_Log::instance()->log(
280
-                            EEM_Change_Log::type_gateway, array('IPN data' => $_req_data), $payment
281
-                        );
282
-                        break;
283
-                    } catch (EventEspresso\core\exceptions\IpnException $e) {
284
-                        EEM_Change_Log::instance()->log(
285
-                            EEM_Change_Log::type_gateway,
286
-                            array(
287
-                                'message'     => 'IPN Exception: ' . $e->getMessage(),
288
-                                'current_url' => EEH_URL::current_url(),
289
-                                'payment'     => $e->getPaymentProperties(),
290
-                                'IPN_data'    => $e->getIpnData(),
291
-                            ),
292
-                            $obj_for_log
293
-                        );
294
-                        return $e->getPayment();
295
-                    } catch (EE_Error $e) {
296
-                        //that's fine- it apparently couldn't handle the IPN
297
-                    }
298
-                }
299
-            }
300
-            // 			EEM_Payment_Log::instance()->log("got to 7",$transaction,$payment_method);
301
-            if ($payment instanceof EE_Payment) {
302
-                $payment->save();
303
-                //  update the TXN
304
-                $this->update_txn_based_on_payment($transaction, $payment, $update_txn, $separate_IPN_request);
305
-            } else {
306
-                //we couldn't find the payment for this IPN... let's try and log at least SOMETHING
307
-                if ($payment_method) {
308
-                    EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data' => $_req_data), $payment_method);
309
-                } elseif ($transaction) {
310
-                    EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data' => $_req_data), $transaction);
311
-                }
312
-            }
313
-            return $payment;
314
-        } catch (EE_Error $e) {
315
-            do_action(
316
-                'AHEE__log', __FILE__, __FUNCTION__, sprintf(
317
-                    __('Error occurred while receiving IPN. Transaction: %1$s, req data: %2$s. The error was "%3$s"', 'event_espresso'),
318
-                    print_r($transaction, true),
319
-                    print_r($_req_data, true),
320
-                    $e->getMessage()
321
-                )
322
-            );
323
-            throw $e;
324
-        }
325
-    }
326
-
327
-
328
-
329
-    /**
330
-     * Removes any non-printable illegal characters from the input,
331
-     * which might cause a raucous when trying to insert into the database
332
-     *
333
-     * @param  array $request_data
334
-     * @return array
335
-     */
336
-    protected function _remove_unusable_characters_from_array(array $request_data)
337
-    {
338
-        $return_data = array();
339
-        foreach ($request_data as $key => $value) {
340
-            $return_data[$this->_remove_unusable_characters($key)] = $this->_remove_unusable_characters($value);
341
-        }
342
-        return $return_data;
343
-    }
344
-
345
-
346
-
347
-    /**
348
-     * Removes any non-printable illegal characters from the input,
349
-     * which might cause a raucous when trying to insert into the database
350
-     *
351
-     * @param string $request_data
352
-     * @return string
353
-     */
354
-    protected function _remove_unusable_characters($request_data)
355
-    {
356
-        return preg_replace('/[^[:print:]]/', '', $request_data);
357
-    }
358
-
359
-
360
-
361
-    /**
362
-     * Should be called just before displaying the payment attempt results to the user,
363
-     * when the payment attempt has finished. Some payment methods may have special
364
-     * logic to perform here. For example, if process_payment() happens on a special request
365
-     * and then the user is redirected to a page that displays the payment's status, this
366
-     * should be called while loading the page that displays the payment's status. If the user is
367
-     * sent to an offsite payment provider, this should be called upon returning from that offsite payment
368
-     * provider.
369
-     *
370
-     * @param EE_Transaction|int $transaction
371
-     * @param bool               $update_txn whether or not to call
372
-     *                                       EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()
373
-     * @throws \EE_Error
374
-     * @return EE_Payment
375
-     * @deprecated 4.6.24 method is no longer used. Instead it is up to client code, like SPCO,
376
-     *                                       to call handle_ipn() for offsite gateways that don't receive separate IPNs
377
-     */
378
-    public function finalize_payment_for($transaction, $update_txn = true)
379
-    {
380
-        /** @var $transaction EE_Transaction */
381
-        $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction);
382
-        $last_payment_method = $transaction->payment_method();
383
-        if ($last_payment_method instanceof EE_Payment_Method) {
384
-            $payment = $last_payment_method->type_obj()->finalize_payment_for($transaction);
385
-            $this->update_txn_based_on_payment($transaction, $payment, $update_txn);
386
-            return $payment;
387
-        } else {
388
-            return null;
389
-        }
390
-    }
391
-
392
-
393
-
394
-    /**
395
-     * Processes a direct refund request, saves the payment, and updates the transaction appropriately.
396
-     *
397
-     * @param EE_Payment_Method $payment_method
398
-     * @param EE_Payment        $payment_to_refund
399
-     * @param array             $refund_info
400
-     * @return EE_Payment
401
-     * @throws \EE_Error
402
-     */
403
-    public function process_refund(
404
-        EE_Payment_Method $payment_method,
405
-        EE_Payment $payment_to_refund,
406
-        $refund_info = array()
407
-    ) {
408
-        if ($payment_method instanceof EE_Payment_Method && $payment_method->type_obj()->supports_sending_refunds()) {
409
-            $payment_method->type_obj()->process_refund($payment_to_refund, $refund_info);
410
-            $this->update_txn_based_on_payment($payment_to_refund->transaction(), $payment_to_refund);
411
-        }
412
-        return $payment_to_refund;
413
-    }
414
-
415
-
416
-
417
-    /**
418
-     * This should be called each time there may have been an update to a
419
-     * payment on a transaction (ie, we asked for a payment to process a
420
-     * payment for a transaction, or we told a payment method about an IPN, or
421
-     * we told a payment method to
422
-     * "finalize_payment_for" (a transaction), or we told a payment method to
423
-     * process a refund. This should handle firing the correct hooks to
424
-     * indicate
425
-     * what exactly happened and updating the transaction appropriately). This
426
-     * could be integrated directly into EE_Transaction upon save, but we want
427
-     * this logic to be separate from 'normal' plain-jane saving and updating
428
-     * of transactions and payments, and to be tied to payment processing.
429
-     * Note: this method DOES NOT save the payment passed into it. It is the responsibility
430
-     * of previous code to decide whether or not to save (because the payment passed into
431
-     * this method might be a temporary, never-to-be-saved payment from an offline gateway,
432
-     * in which case we only want that payment object for some temporary usage during this request,
433
-     * but we don't want it to be saved).
434
-     *
435
-     * @param EE_Transaction|int $transaction
436
-     * @param EE_Payment         $payment
437
-     * @param boolean            $update_txn
438
-     *                        whether or not to call
439
-     *                        EE_Transaction_Processor::
440
-     *                        update_transaction_and_registrations_after_checkout_or_payment()
441
-     *                        (you can save 1 DB query if you know you're going
442
-     *                        to save it later instead)
443
-     * @param bool               $IPN
444
-     *                        if processing IPNs or other similar payment
445
-     *                        related activities that occur in alternate
446
-     *                        requests than the main one that is processing the
447
-     *                        TXN, then set this to true to check whether the
448
-     *                        TXN is locked before updating
449
-     * @throws \EE_Error
450
-     */
451
-    public function update_txn_based_on_payment($transaction, $payment, $update_txn = true, $IPN = false)
452
-    {
453
-        $do_action = 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__not_successful';
454
-        /** @type EE_Transaction $transaction */
455
-        $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction);
456
-        // can we freely update the TXN at this moment?
457
-        if ($IPN && $transaction->is_locked()) {
458
-            // don't update the transaction at this exact moment
459
-            // because the TXN is active in another request
460
-            EE_Cron_Tasks::schedule_update_transaction_with_payment(
461
-                time(),
462
-                $transaction->ID(),
463
-                $payment->ID()
464
-            );
465
-        } else {
466
-            // verify payment and that it has been saved
467
-            if ($payment instanceof EE_Payment && $payment->ID()) {
468
-                if (
469
-                    $payment->payment_method() instanceof EE_Payment_Method
470
-                    && $payment->payment_method()->type_obj() instanceof EE_PMT_Base
471
-                ) {
472
-                    $payment->payment_method()->type_obj()->update_txn_based_on_payment($payment);
473
-                    // update TXN registrations with payment info
474
-                    $this->process_registration_payments($transaction, $payment);
475
-                }
476
-                $do_action = $payment->just_approved()
477
-                    ? 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__successful'
478
-                    : $do_action;
479
-            } else {
480
-                // send out notifications
481
-                add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true');
482
-                $do_action = 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__no_payment_made';
483
-            }
484
-            if ($payment instanceof EE_Payment && $payment->status() !== EEM_Payment::status_id_failed) {
485
-                /** @type EE_Transaction_Payments $transaction_payments */
486
-                $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
487
-                // set new value for total paid
488
-                $transaction_payments->calculate_total_payments_and_update_status($transaction);
489
-                // call EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment() ???
490
-                if ($update_txn) {
491
-                    $this->_post_payment_processing($transaction, $payment, $IPN);
492
-                }
493
-            }
494
-            // granular hook for others to use.
495
-            do_action($do_action, $transaction, $payment);
496
-            do_action('AHEE_log', __CLASS__, __FUNCTION__, $do_action, '$do_action');
497
-            //global hook for others to use.
498
-            do_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', $transaction, $payment);
499
-        }
500
-    }
501
-
502
-
503
-
504
-    /**
505
-     * update registrations REG_paid field after successful payment and link registrations with payment
506
-     *
507
-     * @param EE_Transaction    $transaction
508
-     * @param EE_Payment        $payment
509
-     * @param EE_Registration[] $registrations
510
-     * @throws \EE_Error
511
-     */
512
-    public function process_registration_payments(
513
-        EE_Transaction $transaction,
514
-        EE_Payment $payment,
515
-        $registrations = array()
516
-    ) {
517
-        // only process if payment was successful
518
-        if ($payment->status() !== EEM_Payment::status_id_approved) {
519
-            return;
520
-        }
521
-        //EEM_Registration::instance()->show_next_x_db_queries();
522
-        if (empty($registrations)) {
523
-            // find registrations with monies owing that can receive a payment
524
-            $registrations = $transaction->registrations(
525
-                array(
526
-                    array(
527
-                        // only these reg statuses can receive payments
528
-                        'STS_ID'           => array('IN', EEM_Registration::reg_statuses_that_allow_payment()),
529
-                        'REG_final_price'  => array('!=', 0),
530
-                        'REG_final_price*' => array('!=', 'REG_paid', true),
531
-                    ),
532
-                )
533
-            );
534
-        }
535
-        // still nothing ??!??
536
-        if (empty($registrations)) {
537
-            return;
538
-        }
539
-        // todo: break out the following logic into a separate strategy class
540
-        // todo: named something like "Sequential_Reg_Payment_Strategy"
541
-        // todo: which would apply payments using the capitalist "first come first paid" approach
542
-        // todo: then have another strategy class like "Distributed_Reg_Payment_Strategy"
543
-        // todo: which would be the socialist "everybody gets a piece of pie" approach,
544
-        // todo: which would be better for deposits, where you want a bit of the payment applied to each registration
545
-        $refund = $payment->is_a_refund();
546
-        // how much is available to apply to registrations?
547
-        $available_payment_amount = abs($payment->amount());
548
-        foreach ($registrations as $registration) {
549
-            if ($registration instanceof EE_Registration) {
550
-                // nothing left?
551
-                if ($available_payment_amount <= 0) {
552
-                    break;
553
-                }
554
-                if ($refund) {
555
-                    $available_payment_amount = $this->process_registration_refund($registration, $payment, $available_payment_amount);
556
-                } else {
557
-                    $available_payment_amount = $this->process_registration_payment($registration, $payment, $available_payment_amount);
558
-                }
559
-            }
560
-        }
561
-        if ($available_payment_amount > 0 && apply_filters('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', false)) {
562
-            EE_Error::add_attention(
563
-                sprintf(
564
-                    __('A remainder of %1$s exists after applying this payment to Registration(s) %2$s.%3$sPlease verify that the original payment amount of %4$s is correct. If so, you should edit this payment and select at least one additional registration in the "Registrations to Apply Payment to" section, so that the remainder of this payment can be applied to the additional registration(s).',
565
-                        'event_espresso'),
566
-                    EEH_Template::format_currency($available_payment_amount),
567
-                    implode(', ', array_keys($registrations)),
568
-                    '<br/>',
569
-                    EEH_Template::format_currency($payment->amount())
570
-                ),
571
-                __FILE__, __FUNCTION__, __LINE__
572
-            );
573
-        }
574
-    }
575
-
576
-
577
-
578
-    /**
579
-     * update registration REG_paid field after successful payment and link registration with payment
580
-     *
581
-     * @param EE_Registration $registration
582
-     * @param EE_Payment      $payment
583
-     * @param float           $available_payment_amount
584
-     * @return float
585
-     * @throws \EE_Error
586
-     */
587
-    public function process_registration_payment(
588
-        EE_Registration $registration,
589
-        EE_Payment $payment,
590
-        $available_payment_amount = 0.00
591
-    ) {
592
-        $owing = $registration->final_price() - $registration->paid();
593
-        if ($owing > 0) {
594
-            // don't allow payment amount to exceed the available payment amount, OR the amount owing
595
-            $payment_amount = min($available_payment_amount, $owing);
596
-            // update $available_payment_amount
597
-            $available_payment_amount -= $payment_amount;
598
-            //calculate and set new REG_paid
599
-            $registration->set_paid($registration->paid() + $payment_amount);
600
-            // now save it
601
-            $this->_apply_registration_payment($registration, $payment, $payment_amount);
602
-        }
603
-        return $available_payment_amount;
604
-    }
605
-
606
-
607
-
608
-    /**
609
-     * update registration REG_paid field after successful payment and link registration with payment
610
-     *
611
-     * @param EE_Registration $registration
612
-     * @param EE_Payment      $payment
613
-     * @param float           $payment_amount
614
-     * @return void
615
-     * @throws \EE_Error
616
-     */
617
-    protected function _apply_registration_payment(
618
-        EE_Registration $registration,
619
-        EE_Payment $payment,
620
-        $payment_amount = 0.00
621
-    ) {
622
-        // find any existing reg payment records for this registration and payment
623
-        $existing_reg_payment = EEM_Registration_Payment::instance()->get_one(
624
-            array(array('REG_ID' => $registration->ID(), 'PAY_ID' => $payment->ID()))
625
-        );
626
-        // if existing registration payment exists
627
-        if ($existing_reg_payment instanceof EE_Registration_Payment) {
628
-            // then update that record
629
-            $existing_reg_payment->set_amount($payment_amount);
630
-            $existing_reg_payment->save();
631
-        } else {
632
-            // or add new relation between registration and payment and set amount
633
-            $registration->_add_relation_to($payment, 'Payment', array('RPY_amount' => $payment_amount));
634
-            // make it stick
635
-            $registration->save();
636
-        }
637
-    }
638
-
639
-
640
-
641
-    /**
642
-     * update registration REG_paid field after refund and link registration with payment
643
-     *
644
-     * @param EE_Registration $registration
645
-     * @param EE_Payment      $payment
646
-     * @param float           $available_refund_amount - IMPORTANT !!! SEND AVAILABLE REFUND AMOUNT AS A POSITIVE NUMBER
647
-     * @return float
648
-     * @throws \EE_Error
649
-     */
650
-    public function process_registration_refund(
651
-        EE_Registration $registration,
652
-        EE_Payment $payment,
653
-        $available_refund_amount = 0.00
654
-    ) {
655
-        //EEH_Debug_Tools::printr( $payment->amount(), '$payment->amount()', __FILE__, __LINE__ );
656
-        if ($registration->paid() > 0) {
657
-            // ensure $available_refund_amount is NOT negative
658
-            $available_refund_amount = (float)abs($available_refund_amount);
659
-            // don't allow refund amount to exceed the available payment amount, OR the amount paid
660
-            $refund_amount = min($available_refund_amount, (float)$registration->paid());
661
-            // update $available_payment_amount
662
-            $available_refund_amount -= $refund_amount;
663
-            //calculate and set new REG_paid
664
-            $registration->set_paid($registration->paid() - $refund_amount);
665
-            // convert payment amount back to a negative value for storage in the db
666
-            $refund_amount = (float)abs($refund_amount) * -1;
667
-            // now save it
668
-            $this->_apply_registration_payment($registration, $payment, $refund_amount);
669
-        }
670
-        return $available_refund_amount;
671
-    }
672
-
673
-
674
-
675
-    /**
676
-     * Process payments and transaction after payment process completed.
677
-     * ultimately this will send the TXN and payment details off so that notifications can be sent out.
678
-     * if this request happens to be processing an IPN,
679
-     * then we will also set the Payment Options Reg Step to completed,
680
-     * and attempt to completely finalize the TXN if all of the other Reg Steps are completed as well.
681
-     *
682
-     * @param EE_Transaction $transaction
683
-     * @param EE_Payment     $payment
684
-     * @param bool           $IPN
685
-     * @throws \EE_Error
686
-     */
687
-    protected function _post_payment_processing(EE_Transaction $transaction, EE_Payment $payment, $IPN = false)
688
-    {
689
-        /** @type EE_Transaction_Processor $transaction_processor */
690
-        $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
691
-        // is the Payment Options Reg Step completed ?
692
-        $payment_options_step_completed = $transaction->reg_step_completed('payment_options');
693
-        // if the Payment Options Reg Step is completed...
694
-        $revisit = $payment_options_step_completed === true ? true : false;
695
-        // then this is kinda sorta a revisit with regards to payments at least
696
-        $transaction_processor->set_revisit($revisit);
697
-        // if this is an IPN, let's consider the Payment Options Reg Step completed if not already
698
-        if (
699
-            $IPN
700
-            && $payment_options_step_completed !== true
701
-            && ($payment->is_approved() || $payment->is_pending())
702
-        ) {
703
-            $payment_options_step_completed = $transaction->set_reg_step_completed(
704
-                'payment_options'
705
-            );
706
-        }
707
-        // maybe update status, but don't save transaction just yet
708
-        $transaction->update_status_based_on_total_paid(false);
709
-        // check if 'finalize_registration' step has been completed...
710
-        $finalized = $transaction->reg_step_completed('finalize_registration');
711
-        //  if this is an IPN and the final step has not been initiated
712
-        if ($IPN && $payment_options_step_completed && $finalized === false) {
713
-            // and if it hasn't already been set as being started...
714
-            $finalized = $transaction->set_reg_step_initiated('finalize_registration');
715
-        }
716
-        $transaction->save();
717
-        // because the above will return false if the final step was not fully completed, we need to check again...
718
-        if ($IPN && $finalized !== false) {
719
-            // and if we are all good to go, then send out notifications
720
-            add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true');
721
-            //ok, now process the transaction according to the payment
722
-            $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment($transaction, $payment);
723
-        }
724
-        // DEBUG LOG
725
-        $payment_method = $payment->payment_method();
726
-        if ($payment_method instanceof EE_Payment_Method) {
727
-            $payment_method_type_obj = $payment_method->type_obj();
728
-            if ($payment_method_type_obj instanceof EE_PMT_Base) {
729
-                $gateway = $payment_method_type_obj->get_gateway();
730
-                if ($gateway instanceof EE_Gateway) {
731
-                    $gateway->log(
732
-                        array(
733
-                            'message'               => __('Post Payment Transaction Details', 'event_espresso'),
734
-                            'transaction'           => $transaction->model_field_array(),
735
-                            'finalized'             => $finalized,
736
-                            'IPN'                   => $IPN,
737
-                            'deliver_notifications' => has_filter(
738
-                                'FHEE__EED_Messages___maybe_registration__deliver_notifications'
739
-                            ),
740
-                        ),
741
-                        $payment
742
-                    );
743
-                }
744
-            }
745
-        }
746
-    }
747
-
748
-
749
-
750
-    /**
751
-     * Force posts to PayPal to use TLS v1.2. See:
752
-     * https://core.trac.wordpress.org/ticket/36320
753
-     * https://core.trac.wordpress.org/ticket/34924#comment:15
754
-     * https://www.paypal-knowledge.com/infocenter/index?page=content&widgetview=true&id=FAQ1914&viewlocale=en_US
755
-     * This will affect paypal standard, pro, express, and payflow.
756
-     */
757
-    public static function _curl_requests_to_paypal_use_tls($handle, $r, $url)
758
-    {
759
-        if (strstr($url, 'https://') && strstr($url, '.paypal.com')) {
760
-            //Use the value of the constant CURL_SSLVERSION_TLSv1 = 1
761
-            //instead of the constant because it might not be defined
762
-            curl_setopt($handle, CURLOPT_SSLVERSION, 1);
763
-        }
764
-    }
21
+	/**
22
+	 * @var EE_Payment_Processor $_instance
23
+	 * @access    private
24
+	 */
25
+	private static $_instance;
26
+
27
+
28
+
29
+	/**
30
+	 * @singleton method used to instantiate class object
31
+	 * @access    public
32
+	 * @return EE_Payment_Processor instance
33
+	 */
34
+	public static function instance()
35
+	{
36
+		// check if class object is instantiated
37
+		if ( ! self::$_instance instanceof EE_Payment_Processor) {
38
+			self::$_instance = new self();
39
+		}
40
+		return self::$_instance;
41
+	}
42
+
43
+
44
+
45
+	/**
46
+	 * @return EE_Payment_Processor
47
+	 */
48
+	public static function reset()
49
+	{
50
+		self::$_instance = null;
51
+		return self::instance();
52
+	}
53
+
54
+
55
+
56
+	/**
57
+	 *private constructor to prevent direct creation
58
+	 *
59
+	 * @Constructor
60
+	 * @access private
61
+	 */
62
+	private function __construct()
63
+	{
64
+		do_action('AHEE__EE_Payment_Processor__construct');
65
+		add_action('http_api_curl', array($this, '_curl_requests_to_paypal_use_tls'), 10, 3);
66
+	}
67
+
68
+
69
+
70
+	/**
71
+	 * Using the selected gateway, processes the payment for that transaction, and updates the transaction
72
+	 * appropriately. Saves the payment that is generated
73
+	 *
74
+	 * @param EE_Payment_Method    $payment_method
75
+	 * @param EE_Transaction       $transaction
76
+	 * @param float                $amount       if only part of the transaction is to be paid for, how much.
77
+	 *                                           Leave null if payment is for the full amount owing
78
+	 * @param EE_Billing_Info_Form $billing_form (or probably null, if it's an offline or offsite payment method).
79
+	 *                                           Receive_form_submission() should have
80
+	 *                                           already been called on the billing form
81
+	 *                                           (ie, its inputs should have their normalized values set).
82
+	 * @param string               $return_url   string used mostly by offsite gateways to specify
83
+	 *                                           where to go AFTER the offsite gateway
84
+	 * @param string               $method       like 'CART', indicates who the client who called this was
85
+	 * @param bool                 $by_admin     TRUE if payment is being attempted from the admin
86
+	 * @param boolean              $update_txn   whether or not to call
87
+	 *                                           EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()
88
+	 * @param string               $cancel_url   URL to return to if off-site payments are cancelled
89
+	 * @return \EE_Payment
90
+	 * @throws \EE_Error
91
+	 */
92
+	public function process_payment(
93
+		EE_Payment_Method $payment_method,
94
+		EE_Transaction $transaction,
95
+		$amount = null,
96
+		$billing_form = null,
97
+		$return_url = null,
98
+		$method = 'CART',
99
+		$by_admin = false,
100
+		$update_txn = true,
101
+		$cancel_url = ''
102
+	) {
103
+		if ((float)$amount < 0) {
104
+			throw new EE_Error(
105
+				sprintf(
106
+					__(
107
+						'Attempting to make a payment for a negative amount of %1$d for transaction %2$d. That should be a refund',
108
+						'event_espresso'
109
+					),
110
+					$amount,
111
+					$transaction->ID()
112
+				)
113
+			);
114
+		}
115
+		// verify payment method
116
+		$payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method, true);
117
+		// verify transaction
118
+		EEM_Transaction::instance()->ensure_is_obj($transaction);
119
+		$transaction->set_payment_method_ID($payment_method->ID());
120
+		// verify payment method type
121
+		if ($payment_method->type_obj() instanceof EE_PMT_Base) {
122
+			$payment = $payment_method->type_obj()->process_payment(
123
+				$transaction,
124
+				min($amount, $transaction->remaining()),//make sure we don't overcharge
125
+				$billing_form,
126
+				$return_url,
127
+				add_query_arg(array('ee_cancel_payment' => true), $cancel_url),
128
+				$method,
129
+				$by_admin
130
+			);
131
+			// check if payment method uses an off-site gateway
132
+			if ($payment_method->type_obj()->payment_occurs() !== EE_PMT_Base::offsite) {
133
+				// don't process payments for off-site gateways yet because no payment has occurred yet
134
+				$this->update_txn_based_on_payment($transaction, $payment, $update_txn);
135
+			}
136
+			return $payment;
137
+		} else {
138
+			EE_Error::add_error(
139
+				sprintf(
140
+					__('A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'),
141
+					'<br/>',
142
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
143
+				), __FILE__, __FUNCTION__, __LINE__
144
+			);
145
+			return null;
146
+		}
147
+	}
148
+
149
+
150
+
151
+	/**
152
+	 * @param EE_Transaction|int $transaction
153
+	 * @param EE_Payment_Method  $payment_method
154
+	 * @throws EE_Error
155
+	 * @return string
156
+	 */
157
+	public function get_ipn_url_for_payment_method($transaction, $payment_method)
158
+	{
159
+		/** @type \EE_Transaction $transaction */
160
+		$transaction = EEM_Transaction::instance()->ensure_is_obj($transaction);
161
+		$primary_reg = $transaction->primary_registration();
162
+		if ( ! $primary_reg instanceof EE_Registration) {
163
+			throw new EE_Error(
164
+				sprintf(
165
+					__(
166
+						"Cannot get IPN URL for transaction with ID %d because it has no primary registration",
167
+						"event_espresso"
168
+					),
169
+					$transaction->ID()
170
+				)
171
+			);
172
+		}
173
+		$payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method, true);
174
+		$url = add_query_arg(
175
+			array(
176
+				'e_reg_url_link'    => $primary_reg->reg_url_link(),
177
+				'ee_payment_method' => $payment_method->slug(),
178
+			),
179
+			EE_Registry::instance()->CFG->core->txn_page_url()
180
+		);
181
+		return $url;
182
+	}
183
+
184
+
185
+
186
+	/**
187
+	 * Process the IPN. Firstly, we'll hope we put the standard args into the IPN URL so
188
+	 * we can easily find what registration the IPN is for and what payment method.
189
+	 * However, if not, we'll give all payment methods a chance to claim it and process it.
190
+	 * If a payment is found for the IPN info, it is saved.
191
+	 *
192
+	 * @param array              $_req_data            eg $_REQUEST
193
+	 * @param EE_Transaction|int $transaction          optional (or a transactions id)
194
+	 * @param EE_Payment_Method  $payment_method       (or a slug or id of one)
195
+	 * @param boolean            $update_txn           whether or not to call
196
+	 *                                                 EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()
197
+	 * @param bool               $separate_IPN_request whether the IPN uses a separate request ( true like PayPal )
198
+	 *                                                 or is processed manually ( false like Mijireh )
199
+	 * @throws EE_Error
200
+	 * @throws Exception
201
+	 * @return EE_Payment
202
+	 */
203
+	public function process_ipn(
204
+		$_req_data,
205
+		$transaction = null,
206
+		$payment_method = null,
207
+		$update_txn = true,
208
+		$separate_IPN_request = true
209
+	) {
210
+		EE_Registry::instance()->load_model('Change_Log');
211
+		$_req_data = $this->_remove_unusable_characters_from_array((array)$_req_data);
212
+		EE_Processor_Base::set_IPN($separate_IPN_request);
213
+		$obj_for_log = null;
214
+		if ($transaction instanceof EE_Transaction) {
215
+			$obj_for_log = $transaction;
216
+			if ($payment_method instanceof EE_Payment_Method) {
217
+				$obj_for_log = EEM_Payment::instance()->get_one(
218
+					array(
219
+						array('TXN_ID' => $transaction->ID(), 'PMD_ID' => $payment_method->ID()),
220
+						'order_by' => array('PAY_timestamp' => 'desc'),
221
+					)
222
+				);
223
+			}
224
+		} else if ($payment_method instanceof EE_Payment) {
225
+			$obj_for_log = $payment_method;
226
+		}
227
+		$log = EEM_Change_Log::instance()->log(
228
+			EEM_Change_Log::type_gateway,
229
+			array('IPN data received' => $_req_data),
230
+			$obj_for_log
231
+		);
232
+		try {
233
+			/**
234
+			 * @var EE_Payment $payment
235
+			 */
236
+			$payment = null;
237
+			if ($transaction && $payment_method) {
238
+				/** @type EE_Transaction $transaction */
239
+				$transaction = EEM_Transaction::instance()->ensure_is_obj($transaction);
240
+				/** @type EE_Payment_Method $payment_method */
241
+				$payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method);
242
+				if ($payment_method->type_obj() instanceof EE_PMT_Base) {
243
+					try {
244
+						$payment = $payment_method->type_obj()->handle_ipn($_req_data, $transaction);
245
+						$log->set_object($payment);
246
+					} catch (EventEspresso\core\exceptions\IpnException $e) {
247
+						EEM_Change_Log::instance()->log(
248
+							EEM_Change_Log::type_gateway,
249
+							array(
250
+								'message'     => 'IPN Exception: ' . $e->getMessage(),
251
+								'current_url' => EEH_URL::current_url(),
252
+								'payment'     => $e->getPaymentProperties(),
253
+								'IPN_data'    => $e->getIpnData(),
254
+							),
255
+							$obj_for_log
256
+						);
257
+						return $e->getPayment();
258
+					}
259
+				} else {
260
+					// not a payment
261
+					EE_Error::add_error(
262
+						sprintf(
263
+							__('A valid payment method could not be determined due to a technical issue.%sPlease refresh your browser and try again or contact %s for assistance.', 'event_espresso'),
264
+							'<br/>',
265
+							EE_Registry::instance()->CFG->organization->get_pretty('email')
266
+						),
267
+						__FILE__, __FUNCTION__, __LINE__
268
+					);
269
+				}
270
+			} else {
271
+				//that's actually pretty ok. The IPN just wasn't able
272
+				//to identify which transaction or payment method this was for
273
+				// give all active payment methods a chance to claim it
274
+				$active_payment_methods = EEM_Payment_Method::instance()->get_all_active();
275
+				foreach ($active_payment_methods as $active_payment_method) {
276
+					try {
277
+						$payment = $active_payment_method->type_obj()->handle_unclaimed_ipn($_req_data);
278
+						$payment_method = $active_payment_method;
279
+						EEM_Change_Log::instance()->log(
280
+							EEM_Change_Log::type_gateway, array('IPN data' => $_req_data), $payment
281
+						);
282
+						break;
283
+					} catch (EventEspresso\core\exceptions\IpnException $e) {
284
+						EEM_Change_Log::instance()->log(
285
+							EEM_Change_Log::type_gateway,
286
+							array(
287
+								'message'     => 'IPN Exception: ' . $e->getMessage(),
288
+								'current_url' => EEH_URL::current_url(),
289
+								'payment'     => $e->getPaymentProperties(),
290
+								'IPN_data'    => $e->getIpnData(),
291
+							),
292
+							$obj_for_log
293
+						);
294
+						return $e->getPayment();
295
+					} catch (EE_Error $e) {
296
+						//that's fine- it apparently couldn't handle the IPN
297
+					}
298
+				}
299
+			}
300
+			// 			EEM_Payment_Log::instance()->log("got to 7",$transaction,$payment_method);
301
+			if ($payment instanceof EE_Payment) {
302
+				$payment->save();
303
+				//  update the TXN
304
+				$this->update_txn_based_on_payment($transaction, $payment, $update_txn, $separate_IPN_request);
305
+			} else {
306
+				//we couldn't find the payment for this IPN... let's try and log at least SOMETHING
307
+				if ($payment_method) {
308
+					EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data' => $_req_data), $payment_method);
309
+				} elseif ($transaction) {
310
+					EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data' => $_req_data), $transaction);
311
+				}
312
+			}
313
+			return $payment;
314
+		} catch (EE_Error $e) {
315
+			do_action(
316
+				'AHEE__log', __FILE__, __FUNCTION__, sprintf(
317
+					__('Error occurred while receiving IPN. Transaction: %1$s, req data: %2$s. The error was "%3$s"', 'event_espresso'),
318
+					print_r($transaction, true),
319
+					print_r($_req_data, true),
320
+					$e->getMessage()
321
+				)
322
+			);
323
+			throw $e;
324
+		}
325
+	}
326
+
327
+
328
+
329
+	/**
330
+	 * Removes any non-printable illegal characters from the input,
331
+	 * which might cause a raucous when trying to insert into the database
332
+	 *
333
+	 * @param  array $request_data
334
+	 * @return array
335
+	 */
336
+	protected function _remove_unusable_characters_from_array(array $request_data)
337
+	{
338
+		$return_data = array();
339
+		foreach ($request_data as $key => $value) {
340
+			$return_data[$this->_remove_unusable_characters($key)] = $this->_remove_unusable_characters($value);
341
+		}
342
+		return $return_data;
343
+	}
344
+
345
+
346
+
347
+	/**
348
+	 * Removes any non-printable illegal characters from the input,
349
+	 * which might cause a raucous when trying to insert into the database
350
+	 *
351
+	 * @param string $request_data
352
+	 * @return string
353
+	 */
354
+	protected function _remove_unusable_characters($request_data)
355
+	{
356
+		return preg_replace('/[^[:print:]]/', '', $request_data);
357
+	}
358
+
359
+
360
+
361
+	/**
362
+	 * Should be called just before displaying the payment attempt results to the user,
363
+	 * when the payment attempt has finished. Some payment methods may have special
364
+	 * logic to perform here. For example, if process_payment() happens on a special request
365
+	 * and then the user is redirected to a page that displays the payment's status, this
366
+	 * should be called while loading the page that displays the payment's status. If the user is
367
+	 * sent to an offsite payment provider, this should be called upon returning from that offsite payment
368
+	 * provider.
369
+	 *
370
+	 * @param EE_Transaction|int $transaction
371
+	 * @param bool               $update_txn whether or not to call
372
+	 *                                       EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()
373
+	 * @throws \EE_Error
374
+	 * @return EE_Payment
375
+	 * @deprecated 4.6.24 method is no longer used. Instead it is up to client code, like SPCO,
376
+	 *                                       to call handle_ipn() for offsite gateways that don't receive separate IPNs
377
+	 */
378
+	public function finalize_payment_for($transaction, $update_txn = true)
379
+	{
380
+		/** @var $transaction EE_Transaction */
381
+		$transaction = EEM_Transaction::instance()->ensure_is_obj($transaction);
382
+		$last_payment_method = $transaction->payment_method();
383
+		if ($last_payment_method instanceof EE_Payment_Method) {
384
+			$payment = $last_payment_method->type_obj()->finalize_payment_for($transaction);
385
+			$this->update_txn_based_on_payment($transaction, $payment, $update_txn);
386
+			return $payment;
387
+		} else {
388
+			return null;
389
+		}
390
+	}
391
+
392
+
393
+
394
+	/**
395
+	 * Processes a direct refund request, saves the payment, and updates the transaction appropriately.
396
+	 *
397
+	 * @param EE_Payment_Method $payment_method
398
+	 * @param EE_Payment        $payment_to_refund
399
+	 * @param array             $refund_info
400
+	 * @return EE_Payment
401
+	 * @throws \EE_Error
402
+	 */
403
+	public function process_refund(
404
+		EE_Payment_Method $payment_method,
405
+		EE_Payment $payment_to_refund,
406
+		$refund_info = array()
407
+	) {
408
+		if ($payment_method instanceof EE_Payment_Method && $payment_method->type_obj()->supports_sending_refunds()) {
409
+			$payment_method->type_obj()->process_refund($payment_to_refund, $refund_info);
410
+			$this->update_txn_based_on_payment($payment_to_refund->transaction(), $payment_to_refund);
411
+		}
412
+		return $payment_to_refund;
413
+	}
414
+
415
+
416
+
417
+	/**
418
+	 * This should be called each time there may have been an update to a
419
+	 * payment on a transaction (ie, we asked for a payment to process a
420
+	 * payment for a transaction, or we told a payment method about an IPN, or
421
+	 * we told a payment method to
422
+	 * "finalize_payment_for" (a transaction), or we told a payment method to
423
+	 * process a refund. This should handle firing the correct hooks to
424
+	 * indicate
425
+	 * what exactly happened and updating the transaction appropriately). This
426
+	 * could be integrated directly into EE_Transaction upon save, but we want
427
+	 * this logic to be separate from 'normal' plain-jane saving and updating
428
+	 * of transactions and payments, and to be tied to payment processing.
429
+	 * Note: this method DOES NOT save the payment passed into it. It is the responsibility
430
+	 * of previous code to decide whether or not to save (because the payment passed into
431
+	 * this method might be a temporary, never-to-be-saved payment from an offline gateway,
432
+	 * in which case we only want that payment object for some temporary usage during this request,
433
+	 * but we don't want it to be saved).
434
+	 *
435
+	 * @param EE_Transaction|int $transaction
436
+	 * @param EE_Payment         $payment
437
+	 * @param boolean            $update_txn
438
+	 *                        whether or not to call
439
+	 *                        EE_Transaction_Processor::
440
+	 *                        update_transaction_and_registrations_after_checkout_or_payment()
441
+	 *                        (you can save 1 DB query if you know you're going
442
+	 *                        to save it later instead)
443
+	 * @param bool               $IPN
444
+	 *                        if processing IPNs or other similar payment
445
+	 *                        related activities that occur in alternate
446
+	 *                        requests than the main one that is processing the
447
+	 *                        TXN, then set this to true to check whether the
448
+	 *                        TXN is locked before updating
449
+	 * @throws \EE_Error
450
+	 */
451
+	public function update_txn_based_on_payment($transaction, $payment, $update_txn = true, $IPN = false)
452
+	{
453
+		$do_action = 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__not_successful';
454
+		/** @type EE_Transaction $transaction */
455
+		$transaction = EEM_Transaction::instance()->ensure_is_obj($transaction);
456
+		// can we freely update the TXN at this moment?
457
+		if ($IPN && $transaction->is_locked()) {
458
+			// don't update the transaction at this exact moment
459
+			// because the TXN is active in another request
460
+			EE_Cron_Tasks::schedule_update_transaction_with_payment(
461
+				time(),
462
+				$transaction->ID(),
463
+				$payment->ID()
464
+			);
465
+		} else {
466
+			// verify payment and that it has been saved
467
+			if ($payment instanceof EE_Payment && $payment->ID()) {
468
+				if (
469
+					$payment->payment_method() instanceof EE_Payment_Method
470
+					&& $payment->payment_method()->type_obj() instanceof EE_PMT_Base
471
+				) {
472
+					$payment->payment_method()->type_obj()->update_txn_based_on_payment($payment);
473
+					// update TXN registrations with payment info
474
+					$this->process_registration_payments($transaction, $payment);
475
+				}
476
+				$do_action = $payment->just_approved()
477
+					? 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__successful'
478
+					: $do_action;
479
+			} else {
480
+				// send out notifications
481
+				add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true');
482
+				$do_action = 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__no_payment_made';
483
+			}
484
+			if ($payment instanceof EE_Payment && $payment->status() !== EEM_Payment::status_id_failed) {
485
+				/** @type EE_Transaction_Payments $transaction_payments */
486
+				$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
487
+				// set new value for total paid
488
+				$transaction_payments->calculate_total_payments_and_update_status($transaction);
489
+				// call EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment() ???
490
+				if ($update_txn) {
491
+					$this->_post_payment_processing($transaction, $payment, $IPN);
492
+				}
493
+			}
494
+			// granular hook for others to use.
495
+			do_action($do_action, $transaction, $payment);
496
+			do_action('AHEE_log', __CLASS__, __FUNCTION__, $do_action, '$do_action');
497
+			//global hook for others to use.
498
+			do_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', $transaction, $payment);
499
+		}
500
+	}
501
+
502
+
503
+
504
+	/**
505
+	 * update registrations REG_paid field after successful payment and link registrations with payment
506
+	 *
507
+	 * @param EE_Transaction    $transaction
508
+	 * @param EE_Payment        $payment
509
+	 * @param EE_Registration[] $registrations
510
+	 * @throws \EE_Error
511
+	 */
512
+	public function process_registration_payments(
513
+		EE_Transaction $transaction,
514
+		EE_Payment $payment,
515
+		$registrations = array()
516
+	) {
517
+		// only process if payment was successful
518
+		if ($payment->status() !== EEM_Payment::status_id_approved) {
519
+			return;
520
+		}
521
+		//EEM_Registration::instance()->show_next_x_db_queries();
522
+		if (empty($registrations)) {
523
+			// find registrations with monies owing that can receive a payment
524
+			$registrations = $transaction->registrations(
525
+				array(
526
+					array(
527
+						// only these reg statuses can receive payments
528
+						'STS_ID'           => array('IN', EEM_Registration::reg_statuses_that_allow_payment()),
529
+						'REG_final_price'  => array('!=', 0),
530
+						'REG_final_price*' => array('!=', 'REG_paid', true),
531
+					),
532
+				)
533
+			);
534
+		}
535
+		// still nothing ??!??
536
+		if (empty($registrations)) {
537
+			return;
538
+		}
539
+		// todo: break out the following logic into a separate strategy class
540
+		// todo: named something like "Sequential_Reg_Payment_Strategy"
541
+		// todo: which would apply payments using the capitalist "first come first paid" approach
542
+		// todo: then have another strategy class like "Distributed_Reg_Payment_Strategy"
543
+		// todo: which would be the socialist "everybody gets a piece of pie" approach,
544
+		// todo: which would be better for deposits, where you want a bit of the payment applied to each registration
545
+		$refund = $payment->is_a_refund();
546
+		// how much is available to apply to registrations?
547
+		$available_payment_amount = abs($payment->amount());
548
+		foreach ($registrations as $registration) {
549
+			if ($registration instanceof EE_Registration) {
550
+				// nothing left?
551
+				if ($available_payment_amount <= 0) {
552
+					break;
553
+				}
554
+				if ($refund) {
555
+					$available_payment_amount = $this->process_registration_refund($registration, $payment, $available_payment_amount);
556
+				} else {
557
+					$available_payment_amount = $this->process_registration_payment($registration, $payment, $available_payment_amount);
558
+				}
559
+			}
560
+		}
561
+		if ($available_payment_amount > 0 && apply_filters('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', false)) {
562
+			EE_Error::add_attention(
563
+				sprintf(
564
+					__('A remainder of %1$s exists after applying this payment to Registration(s) %2$s.%3$sPlease verify that the original payment amount of %4$s is correct. If so, you should edit this payment and select at least one additional registration in the "Registrations to Apply Payment to" section, so that the remainder of this payment can be applied to the additional registration(s).',
565
+						'event_espresso'),
566
+					EEH_Template::format_currency($available_payment_amount),
567
+					implode(', ', array_keys($registrations)),
568
+					'<br/>',
569
+					EEH_Template::format_currency($payment->amount())
570
+				),
571
+				__FILE__, __FUNCTION__, __LINE__
572
+			);
573
+		}
574
+	}
575
+
576
+
577
+
578
+	/**
579
+	 * update registration REG_paid field after successful payment and link registration with payment
580
+	 *
581
+	 * @param EE_Registration $registration
582
+	 * @param EE_Payment      $payment
583
+	 * @param float           $available_payment_amount
584
+	 * @return float
585
+	 * @throws \EE_Error
586
+	 */
587
+	public function process_registration_payment(
588
+		EE_Registration $registration,
589
+		EE_Payment $payment,
590
+		$available_payment_amount = 0.00
591
+	) {
592
+		$owing = $registration->final_price() - $registration->paid();
593
+		if ($owing > 0) {
594
+			// don't allow payment amount to exceed the available payment amount, OR the amount owing
595
+			$payment_amount = min($available_payment_amount, $owing);
596
+			// update $available_payment_amount
597
+			$available_payment_amount -= $payment_amount;
598
+			//calculate and set new REG_paid
599
+			$registration->set_paid($registration->paid() + $payment_amount);
600
+			// now save it
601
+			$this->_apply_registration_payment($registration, $payment, $payment_amount);
602
+		}
603
+		return $available_payment_amount;
604
+	}
605
+
606
+
607
+
608
+	/**
609
+	 * update registration REG_paid field after successful payment and link registration with payment
610
+	 *
611
+	 * @param EE_Registration $registration
612
+	 * @param EE_Payment      $payment
613
+	 * @param float           $payment_amount
614
+	 * @return void
615
+	 * @throws \EE_Error
616
+	 */
617
+	protected function _apply_registration_payment(
618
+		EE_Registration $registration,
619
+		EE_Payment $payment,
620
+		$payment_amount = 0.00
621
+	) {
622
+		// find any existing reg payment records for this registration and payment
623
+		$existing_reg_payment = EEM_Registration_Payment::instance()->get_one(
624
+			array(array('REG_ID' => $registration->ID(), 'PAY_ID' => $payment->ID()))
625
+		);
626
+		// if existing registration payment exists
627
+		if ($existing_reg_payment instanceof EE_Registration_Payment) {
628
+			// then update that record
629
+			$existing_reg_payment->set_amount($payment_amount);
630
+			$existing_reg_payment->save();
631
+		} else {
632
+			// or add new relation between registration and payment and set amount
633
+			$registration->_add_relation_to($payment, 'Payment', array('RPY_amount' => $payment_amount));
634
+			// make it stick
635
+			$registration->save();
636
+		}
637
+	}
638
+
639
+
640
+
641
+	/**
642
+	 * update registration REG_paid field after refund and link registration with payment
643
+	 *
644
+	 * @param EE_Registration $registration
645
+	 * @param EE_Payment      $payment
646
+	 * @param float           $available_refund_amount - IMPORTANT !!! SEND AVAILABLE REFUND AMOUNT AS A POSITIVE NUMBER
647
+	 * @return float
648
+	 * @throws \EE_Error
649
+	 */
650
+	public function process_registration_refund(
651
+		EE_Registration $registration,
652
+		EE_Payment $payment,
653
+		$available_refund_amount = 0.00
654
+	) {
655
+		//EEH_Debug_Tools::printr( $payment->amount(), '$payment->amount()', __FILE__, __LINE__ );
656
+		if ($registration->paid() > 0) {
657
+			// ensure $available_refund_amount is NOT negative
658
+			$available_refund_amount = (float)abs($available_refund_amount);
659
+			// don't allow refund amount to exceed the available payment amount, OR the amount paid
660
+			$refund_amount = min($available_refund_amount, (float)$registration->paid());
661
+			// update $available_payment_amount
662
+			$available_refund_amount -= $refund_amount;
663
+			//calculate and set new REG_paid
664
+			$registration->set_paid($registration->paid() - $refund_amount);
665
+			// convert payment amount back to a negative value for storage in the db
666
+			$refund_amount = (float)abs($refund_amount) * -1;
667
+			// now save it
668
+			$this->_apply_registration_payment($registration, $payment, $refund_amount);
669
+		}
670
+		return $available_refund_amount;
671
+	}
672
+
673
+
674
+
675
+	/**
676
+	 * Process payments and transaction after payment process completed.
677
+	 * ultimately this will send the TXN and payment details off so that notifications can be sent out.
678
+	 * if this request happens to be processing an IPN,
679
+	 * then we will also set the Payment Options Reg Step to completed,
680
+	 * and attempt to completely finalize the TXN if all of the other Reg Steps are completed as well.
681
+	 *
682
+	 * @param EE_Transaction $transaction
683
+	 * @param EE_Payment     $payment
684
+	 * @param bool           $IPN
685
+	 * @throws \EE_Error
686
+	 */
687
+	protected function _post_payment_processing(EE_Transaction $transaction, EE_Payment $payment, $IPN = false)
688
+	{
689
+		/** @type EE_Transaction_Processor $transaction_processor */
690
+		$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
691
+		// is the Payment Options Reg Step completed ?
692
+		$payment_options_step_completed = $transaction->reg_step_completed('payment_options');
693
+		// if the Payment Options Reg Step is completed...
694
+		$revisit = $payment_options_step_completed === true ? true : false;
695
+		// then this is kinda sorta a revisit with regards to payments at least
696
+		$transaction_processor->set_revisit($revisit);
697
+		// if this is an IPN, let's consider the Payment Options Reg Step completed if not already
698
+		if (
699
+			$IPN
700
+			&& $payment_options_step_completed !== true
701
+			&& ($payment->is_approved() || $payment->is_pending())
702
+		) {
703
+			$payment_options_step_completed = $transaction->set_reg_step_completed(
704
+				'payment_options'
705
+			);
706
+		}
707
+		// maybe update status, but don't save transaction just yet
708
+		$transaction->update_status_based_on_total_paid(false);
709
+		// check if 'finalize_registration' step has been completed...
710
+		$finalized = $transaction->reg_step_completed('finalize_registration');
711
+		//  if this is an IPN and the final step has not been initiated
712
+		if ($IPN && $payment_options_step_completed && $finalized === false) {
713
+			// and if it hasn't already been set as being started...
714
+			$finalized = $transaction->set_reg_step_initiated('finalize_registration');
715
+		}
716
+		$transaction->save();
717
+		// because the above will return false if the final step was not fully completed, we need to check again...
718
+		if ($IPN && $finalized !== false) {
719
+			// and if we are all good to go, then send out notifications
720
+			add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true');
721
+			//ok, now process the transaction according to the payment
722
+			$transaction_processor->update_transaction_and_registrations_after_checkout_or_payment($transaction, $payment);
723
+		}
724
+		// DEBUG LOG
725
+		$payment_method = $payment->payment_method();
726
+		if ($payment_method instanceof EE_Payment_Method) {
727
+			$payment_method_type_obj = $payment_method->type_obj();
728
+			if ($payment_method_type_obj instanceof EE_PMT_Base) {
729
+				$gateway = $payment_method_type_obj->get_gateway();
730
+				if ($gateway instanceof EE_Gateway) {
731
+					$gateway->log(
732
+						array(
733
+							'message'               => __('Post Payment Transaction Details', 'event_espresso'),
734
+							'transaction'           => $transaction->model_field_array(),
735
+							'finalized'             => $finalized,
736
+							'IPN'                   => $IPN,
737
+							'deliver_notifications' => has_filter(
738
+								'FHEE__EED_Messages___maybe_registration__deliver_notifications'
739
+							),
740
+						),
741
+						$payment
742
+					);
743
+				}
744
+			}
745
+		}
746
+	}
747
+
748
+
749
+
750
+	/**
751
+	 * Force posts to PayPal to use TLS v1.2. See:
752
+	 * https://core.trac.wordpress.org/ticket/36320
753
+	 * https://core.trac.wordpress.org/ticket/34924#comment:15
754
+	 * https://www.paypal-knowledge.com/infocenter/index?page=content&widgetview=true&id=FAQ1914&viewlocale=en_US
755
+	 * This will affect paypal standard, pro, express, and payflow.
756
+	 */
757
+	public static function _curl_requests_to_paypal_use_tls($handle, $r, $url)
758
+	{
759
+		if (strstr($url, 'https://') && strstr($url, '.paypal.com')) {
760
+			//Use the value of the constant CURL_SSLVERSION_TLSv1 = 1
761
+			//instead of the constant because it might not be defined
762
+			curl_setopt($handle, CURLOPT_SSLVERSION, 1);
763
+		}
764
+	}
765 765
 }
Please login to merge, or discard this patch.
core/EE_Bootstrap.core.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -42,13 +42,13 @@  discard block
 block discarded – undo
42 42
 
43 43
 	public function __construct() {
44 44
 		// construct request stack and run middleware apps as soon as all WP plugins are loaded
45
-		add_action( 'plugins_loaded', array( $this, 'run_request_stack' ), 0 );
45
+		add_action('plugins_loaded', array($this, 'run_request_stack'), 0);
46 46
 		// set framework for the rest of EE to hook into when loading
47
-		add_action( 'plugins_loaded', array( 'EE_Bootstrap', 'load_espresso_addons' ), 1 );
48
-		add_action( 'plugins_loaded', array( 'EE_Bootstrap', 'detect_activations_or_upgrades' ), 3 );
49
-		add_action( 'plugins_loaded', array( 'EE_Bootstrap', 'load_core_configuration' ), 5 );
50
-		add_action( 'plugins_loaded', array( 'EE_Bootstrap', 'register_shortcodes_modules_and_widgets' ), 7 );
51
-		add_action( 'plugins_loaded', array( 'EE_Bootstrap', 'brew_espresso' ), 9 );
47
+		add_action('plugins_loaded', array('EE_Bootstrap', 'load_espresso_addons'), 1);
48
+		add_action('plugins_loaded', array('EE_Bootstrap', 'detect_activations_or_upgrades'), 3);
49
+		add_action('plugins_loaded', array('EE_Bootstrap', 'load_core_configuration'), 5);
50
+		add_action('plugins_loaded', array('EE_Bootstrap', 'register_shortcodes_modules_and_widgets'), 7);
51
+		add_action('plugins_loaded', array('EE_Bootstrap', 'brew_espresso'), 9);
52 52
 	}
53 53
 
54 54
 
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 			new EE_Load_Espresso_Core()
66 66
 		);
67 67
 		$this->_request_stack->handle_request(
68
-			new EE_Request( $_GET, $_POST, $_COOKIE ),
68
+			new EE_Request($_GET, $_POST, $_COOKIE),
69 69
 			new EE_Response()
70 70
 		);
71 71
 		$this->_request_stack->handle_response();
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 */
79 79
 	protected function load_autoloader() {
80 80
 		// load interfaces
81
-		espresso_load_required( 'EEH_Autoloader', EE_CORE . 'helpers' . DS . 'EEH_Autoloader.helper.php' );
81
+		espresso_load_required('EEH_Autoloader', EE_CORE.'helpers'.DS.'EEH_Autoloader.helper.php');
82 82
 		EEH_Autoloader::instance();
83 83
 	}
84 84
 
@@ -89,15 +89,15 @@  discard block
 block discarded – undo
89 89
 	 */
90 90
 	protected function set_autoloaders_for_required_files() {
91 91
 		// load interfaces
92
-		espresso_load_required( 'EEI_Interfaces', EE_CORE . 'interfaces' . DS . 'EEI_Interfaces.php' );
93
-		espresso_load_required( 'InterminableInterface', EE_CORE . 'interfaces' . DS . 'InterminableInterface.php' );
94
-		espresso_load_required( 'ResettableInterface', EE_CORE . 'interfaces' . DS . 'ResettableInterface.php' );
92
+		espresso_load_required('EEI_Interfaces', EE_CORE.'interfaces'.DS.'EEI_Interfaces.php');
93
+		espresso_load_required('InterminableInterface', EE_CORE.'interfaces'.DS.'InterminableInterface.php');
94
+		espresso_load_required('ResettableInterface', EE_CORE.'interfaces'.DS.'ResettableInterface.php');
95 95
 		// load helpers
96
-		EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_HELPERS );
96
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_HELPERS);
97 97
 		// load request stack
98
-		EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_CORE . 'request_stack' . DS );
98
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE.'request_stack'.DS);
99 99
 		// load middleware
100
-		EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_CORE . 'middleware' . DS );
100
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE.'middleware'.DS);
101 101
 	}
102 102
 
103 103
 
@@ -118,9 +118,9 @@  discard block
 block discarded – undo
118 118
 			)
119 119
 		);
120 120
 		// load middleware onto stack : FILO (First In Last Out)
121
-		foreach ( (array)$stack_apps as $stack_app ) {
121
+		foreach ((array) $stack_apps as $stack_app) {
122 122
 			//$request_stack_builder->push( $stack_app );
123
-			$request_stack_builder->unshift( $stack_app );
123
+			$request_stack_builder->unshift($stack_app);
124 124
 		}
125 125
 		return apply_filters(
126 126
 			'FHEE__EE_Bootstrap__build_request_stack__request_stack_builder',
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 	 * no other logic should be performed at this point
138 138
 	 */
139 139
 	public static function load_espresso_addons() {
140
-		do_action( 'AHEE__EE_Bootstrap__load_espresso_addons' );
140
+		do_action('AHEE__EE_Bootstrap__load_espresso_addons');
141 141
 	}
142 142
 
143 143
 
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 	 * we can determine if anything needs activating or upgrading
150 150
 	 */
151 151
 	public static function detect_activations_or_upgrades() {
152
-		do_action( 'AHEE__EE_Bootstrap__detect_activations_or_upgrades' );
152
+		do_action('AHEE__EE_Bootstrap__detect_activations_or_upgrades');
153 153
 	}
154 154
 
155 155
 
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 	 * we can load and set all of the system configurations
162 162
 	 */
163 163
 	public static function load_core_configuration() {
164
-		do_action( 'AHEE__EE_Bootstrap__load_core_configuration' );
164
+		do_action('AHEE__EE_Bootstrap__load_core_configuration');
165 165
 	}
166 166
 
167 167
 
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 	 * so that they are ready to be used throughout the system
174 174
 	 */
175 175
 	public static function register_shortcodes_modules_and_widgets() {
176
-		do_action( 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets' );
176
+		do_action('AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets');
177 177
 	}
178 178
 
179 179
 
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 	 * so let the fun begin...
186 186
 	 */
187 187
 	public static function brew_espresso() {
188
-		do_action( 'AHEE__EE_Bootstrap__brew_espresso' );
188
+		do_action('AHEE__EE_Bootstrap__brew_espresso');
189 189
 	}
190 190
 
191 191
 
Please login to merge, or discard this patch.
core/EE_Encryption.core.php 1 patch
Unused Use Statements   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@
 block discarded – undo
1
-<?php use EventEspresso\core\interfaces\InterminableInterface;
1
+<?php 
2 2
 
3 3
 defined('EVENT_ESPRESSO_VERSION') || exit('No direct script access allowed');
4 4
 
Please login to merge, or discard this patch.
admin/extend/registrations/EE_Event_Registrations_List_Table.class.php 1 patch
Spacing   +119 added lines, -119 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
2
-	exit( 'No direct script access allowed' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 
5 5
 
@@ -42,51 +42,51 @@  discard block
 block discarded – undo
42 42
 	 *
43 43
 	 * @param \Registrations_Admin_Page $admin_page
44 44
 	 */
45
-	public function __construct( $admin_page ) {
46
-		parent::__construct( $admin_page );
45
+	public function __construct($admin_page) {
46
+		parent::__construct($admin_page);
47 47
 		$this->_status = $this->_admin_page->get_registration_status_array();
48 48
 	}
49 49
 
50 50
 
51 51
 
52 52
 	protected function _setup_data() {
53
-		$this->_data = $this->_view !== 'trash' ? $this->_admin_page->get_event_attendees( $this->_per_page )
54
-			: $this->_admin_page->get_event_attendees( $this->_per_page, false, true );
53
+		$this->_data = $this->_view !== 'trash' ? $this->_admin_page->get_event_attendees($this->_per_page)
54
+			: $this->_admin_page->get_event_attendees($this->_per_page, false, true);
55 55
 		$this->_all_data_count = $this->_view !== 'trash' ? $this->_admin_page->get_event_attendees(
56 56
 			$this->_per_page,
57 57
 			true
58
-		) : $this->_admin_page->get_event_attendees( $this->_per_page, true, true );
58
+		) : $this->_admin_page->get_event_attendees($this->_per_page, true, true);
59 59
 	}
60 60
 
61 61
 
62 62
 
63 63
 	protected function _set_properties() {
64
-		$evt_id = isset( $this->_req_data['event_id'] ) ? $this->_req_data['event_id'] : null;
64
+		$evt_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null;
65 65
 		$this->_wp_list_args = array(
66
-			'singular' => __( 'registrant', 'event_espresso' ),
67
-			'plural'   => __( 'registrants', 'event_espresso' ),
66
+			'singular' => __('registrant', 'event_espresso'),
67
+			'plural'   => __('registrants', 'event_espresso'),
68 68
 			'ajax'     => true,
69 69
 			'screen'   => $this->_admin_page->get_current_screen()->id,
70 70
 		);
71 71
 		$columns = array();
72 72
 		//$columns['_Reg_Status'] = '';
73
-		if ( ! empty( $evt_id ) ) {
73
+		if ( ! empty($evt_id)) {
74 74
 			$columns['cb'] = '<input type="checkbox" />'; //Render a checkbox instead of text
75 75
 			$this->_has_checkbox_column = true;
76 76
 		}
77 77
 		$this->_columns = array(
78 78
 			'_REG_att_checked_in' => '<span class="dashicons dashicons-yes ee-icon-size-18"></span>',
79
-			'ATT_name'            => __( 'Registrant', 'event_espresso' ),
80
-			'ATT_email'           => __( 'Email Address', 'event_espresso' ),
81
-			'Event'               => __( 'Event', 'event_espresso' ),
82
-			'PRC_name'            => __( 'TKT Option', 'event_espresso' ),
83
-			'_REG_final_price'    => __( 'Price', 'event_espresso' ),
84
-			'TXN_paid'            => __( 'Paid', 'event_espresso' ),
85
-			'TXN_total'           => __( 'Total', 'event_espresso' ),
79
+			'ATT_name'            => __('Registrant', 'event_espresso'),
80
+			'ATT_email'           => __('Email Address', 'event_espresso'),
81
+			'Event'               => __('Event', 'event_espresso'),
82
+			'PRC_name'            => __('TKT Option', 'event_espresso'),
83
+			'_REG_final_price'    => __('Price', 'event_espresso'),
84
+			'TXN_paid'            => __('Paid', 'event_espresso'),
85
+			'TXN_total'           => __('Total', 'event_espresso'),
86 86
 		);
87
-		$this->_columns = array_merge( $columns, $this->_columns );
87
+		$this->_columns = array_merge($columns, $this->_columns);
88 88
 		$this->_primary_column = '_REG_att_checked_in';
89
-		if ( ! empty( $evt_id )
89
+		if ( ! empty($evt_id)
90 90
 		     && EE_Registry::instance()->CAP->current_user_can(
91 91
 				'ee_read_registrations',
92 92
 				'espresso_registrations_registrations_reports',
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 					'extra_request' =>
100 100
 						array(
101 101
 							'EVT_ID'     => $evt_id,
102
-							'return_url' => urlencode( "//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}" ),
102
+							'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"),
103 103
 						),
104 104
 				),
105 105
 			);
@@ -140,12 +140,12 @@  discard block
 block discarded – undo
140 140
                     true,
141 141
                     $this
142 142
                 )
143
-                ? array( 'ATT_lname' => true )
144
-                : array( 'ATT_fname' => true ),
145
-			'Event'    => array( 'Event.EVT.Name' => false ),
143
+                ? array('ATT_lname' => true)
144
+                : array('ATT_fname' => true),
145
+			'Event'    => array('Event.EVT.Name' => false),
146 146
 		);
147 147
 		$this->_hidden_columns = array();
148
-		$this->_evt = EEM_Event::instance()->get_one_by_ID( $evt_id );
148
+		$this->_evt = EEM_Event::instance()->get_one_by_ID($evt_id);
149 149
 		$this->_dtts_for_event = $this->_evt instanceof EE_Event ? $this->_evt->datetimes_ordered() : array();
150 150
 	}
151 151
 
@@ -155,11 +155,11 @@  discard block
 block discarded – undo
155 155
 	 * @param \EE_Registration $item
156 156
 	 * @return string
157 157
 	 */
158
-	protected function _get_row_class( $item ) {
159
-		$class = parent::_get_row_class( $item );
158
+	protected function _get_row_class($item) {
159
+		$class = parent::_get_row_class($item);
160 160
 		//add status class
161
-		$class .= ' ee-status-strip reg-status-' . $item->status_ID();
162
-		if ( $this->_has_checkbox_column ) {
161
+		$class .= ' ee-status-strip reg-status-'.$item->status_ID();
162
+		if ($this->_has_checkbox_column) {
163 163
 			$class .= ' has-checkbox-column';
164 164
 		}
165 165
 		return $class;
@@ -173,61 +173,61 @@  discard block
 block discarded – undo
173 173
 	 */
174 174
 	protected function _get_table_filters() {
175 175
 		$filters = $where = array();
176
-		$current_EVT_ID = isset( $this->_req_data['event_id'] ) ? (int) $this->_req_data['event_id'] : 0;
177
-		if ( empty( $this->_dtts_for_event ) || count( $this->_dtts_for_event ) === 1 ) {
176
+		$current_EVT_ID = isset($this->_req_data['event_id']) ? (int) $this->_req_data['event_id'] : 0;
177
+		if (empty($this->_dtts_for_event) || count($this->_dtts_for_event) === 1) {
178 178
 			//this means we don't have an event so let's setup a filter dropdown for all the events to select
179 179
 			//note possible capability restrictions
180
-			if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_private_events', 'get_events' ) ) {
181
-				$where['status**'] = array( '!=', 'private' );
180
+			if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) {
181
+				$where['status**'] = array('!=', 'private');
182 182
 			}
183
-			if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_events', 'get_events' ) ) {
183
+			if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) {
184 184
 				$where['EVT_wp_user'] = get_current_user_id();
185 185
 			}
186 186
 			$events = EEM_Event::instance()->get_all(
187 187
 				array(
188 188
 					$where,
189
-					'order_by' => array( 'Datetime.DTT_EVT_start' => 'DESC' ),
189
+					'order_by' => array('Datetime.DTT_EVT_start' => 'DESC'),
190 190
 				)
191 191
 			);
192 192
 			$evts[] = array(
193 193
 				'id'   => 0,
194
-				'text' => __( 'To toggle Check-in status, select an event', 'event_espresso' ),
194
+				'text' => __('To toggle Check-in status, select an event', 'event_espresso'),
195 195
 			);
196 196
 			$checked = 'checked';
197 197
 			/** @var EE_Event $evt */
198
-			foreach ( $events as $evt ) {
198
+			foreach ($events as $evt) {
199 199
 				//any registrations for this event?
200
-				if ( ! $evt->get_count_of_all_registrations() ) {
200
+				if ( ! $evt->get_count_of_all_registrations()) {
201 201
 					continue;
202 202
 				}
203 203
                                 $evts[] = array(
204 204
 					'id'    => $evt->ID(),
205
-					'text'  => apply_filters('FHEE__EE_Event_Registrations___get_table_filters__event_name', $evt->get( 'EVT_name' ), $evt),
205
+					'text'  => apply_filters('FHEE__EE_Event_Registrations___get_table_filters__event_name', $evt->get('EVT_name'), $evt),
206 206
 					'class' => $evt->is_expired() ? 'ee-expired-event' : '',
207 207
 				);
208
-				if ( $evt->ID() === $current_EVT_ID && $evt->is_expired() ) {
208
+				if ($evt->ID() === $current_EVT_ID && $evt->is_expired()) {
209 209
 					$checked = '';
210 210
 				}
211 211
 			}
212 212
 			$event_filter = '<div class="ee-event-filter">';
213
-			$event_filter .= EEH_Form_Fields::select_input( 'event_id', $evts, $current_EVT_ID );
213
+			$event_filter .= EEH_Form_Fields::select_input('event_id', $evts, $current_EVT_ID);
214 214
 			$event_filter .= '<span class="ee-event-filter-toggle">';
215
-			$event_filter .= '<input type="checkbox" id="js-ee-hide-expired-events" ' . $checked . '> ';
216
-			$event_filter .= __( 'Hide Expired Events', 'event_espresso' );
215
+			$event_filter .= '<input type="checkbox" id="js-ee-hide-expired-events" '.$checked.'> ';
216
+			$event_filter .= __('Hide Expired Events', 'event_espresso');
217 217
 			$event_filter .= '</span>';
218 218
 			$event_filter .= '</div>';
219 219
 			$filters[] = $event_filter;
220 220
 		}
221
-		if ( ! empty( $this->_dtts_for_event ) ) {
221
+		if ( ! empty($this->_dtts_for_event)) {
222 222
 			//DTT datetimes filter
223
-			$this->_cur_dtt_id = isset( $this->_req_data['DTT_ID'] ) ? $this->_req_data['DTT_ID'] : 0;
224
-			if ( count( $this->_dtts_for_event ) > 1 ) {
225
-				$dtts[0] = __( 'To toggle check-in status, select a datetime.', 'event_espresso' );
226
-				foreach ( $this->_dtts_for_event as $dtt ) {
223
+			$this->_cur_dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0;
224
+			if (count($this->_dtts_for_event) > 1) {
225
+				$dtts[0] = __('To toggle check-in status, select a datetime.', 'event_espresso');
226
+				foreach ($this->_dtts_for_event as $dtt) {
227 227
                     $datetime_string = $dtt->name();
228
-                    $datetime_string = ! empty($datetime_string ) ? ' (' . $datetime_string . ')' : '';
229
-					$datetime_string = $dtt->start_date_and_time() . ' - ' . $dtt->end_date_and_time() . $datetime_string;
230
-					$dtts[ $dtt->ID() ] = $datetime_string;
228
+                    $datetime_string = ! empty($datetime_string) ? ' ('.$datetime_string.')' : '';
229
+					$datetime_string = $dtt->start_date_and_time().' - '.$dtt->end_date_and_time().$datetime_string;
230
+					$dtts[$dtt->ID()] = $datetime_string;
231 231
 				}
232 232
 				$input = new EE_Select_Input(
233 233
 					$dtts,
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 					)
239 239
 				);
240 240
 				$filters[] = $input->get_html_for_input();
241
-				$filters[] = '<input type="hidden" name="event_id" value="' . $current_EVT_ID . '">';
241
+				$filters[] = '<input type="hidden" name="event_id" value="'.$current_EVT_ID.'">';
242 242
 			}
243 243
 		}
244 244
 		return $filters;
@@ -257,22 +257,22 @@  discard block
 block discarded – undo
257 257
 	 * @throws \EE_Error
258 258
 	 */
259 259
 	protected function _get_total_event_attendees() {
260
-		$EVT_ID = isset( $this->_req_data['event_id'] ) ? absint( $this->_req_data['event_id'] ) : false;
260
+		$EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false;
261 261
 		$DTT_ID = $this->_cur_dtt_id;
262 262
 		$query_params = array();
263
-		if ( $EVT_ID ) {
263
+		if ($EVT_ID) {
264 264
 			$query_params[0]['EVT_ID'] = $EVT_ID;
265 265
 		}
266 266
 		//if DTT is included we only show for that datetime.  Otherwise we're showing for all datetimes (the event).
267
-		if ( $DTT_ID ) {
267
+		if ($DTT_ID) {
268 268
 			$query_params[0]['Ticket.Datetime.DTT_ID'] = $DTT_ID;
269 269
 		}
270 270
 		$status_ids_array = apply_filters(
271 271
 			'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array',
272
-			array( EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved )
272
+			array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved)
273 273
 		);
274
-		$query_params[0]['STS_ID'] = array( 'IN', $status_ids_array );
275
-		return EEM_Registration::instance()->count( $query_params );
274
+		$query_params[0]['STS_ID'] = array('IN', $status_ids_array);
275
+		return EEM_Registration::instance()->count($query_params);
276 276
 	}
277 277
 
278 278
 
@@ -281,8 +281,8 @@  discard block
 block discarded – undo
281 281
 	 * @param \EE_Registration $item
282 282
 	 * @return string
283 283
 	 */
284
-	public function column__Reg_Status( EE_Registration $item ) {
285
-		return '<span class="ee-status-strip ee-status-strip-td reg-status-' . $item->status_ID() . '"></span>';
284
+	public function column__Reg_Status(EE_Registration $item) {
285
+		return '<span class="ee-status-strip ee-status-strip-td reg-status-'.$item->status_ID().'"></span>';
286 286
 	}
287 287
 
288 288
 
@@ -292,8 +292,8 @@  discard block
 block discarded – undo
292 292
 	 * @return string
293 293
 	 * @throws \EE_Error
294 294
 	 */
295
-	public function column_cb( $item ) {
296
-		return sprintf( '<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', $item->ID() );
295
+	public function column_cb($item) {
296
+		return sprintf('<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', $item->ID());
297 297
 	}
298 298
 
299 299
 
@@ -305,20 +305,20 @@  discard block
 block discarded – undo
305 305
 	 * @return string
306 306
 	 * @throws \EE_Error
307 307
 	 */
308
-	public function column__REG_att_checked_in( EE_Registration $item ) {
308
+	public function column__REG_att_checked_in(EE_Registration $item) {
309 309
 		$attendee = $item->attendee();
310 310
 		$attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
311 311
 
312
-		if ( $this->_cur_dtt_id === 0 && count( $this->_dtts_for_event ) === 1 ) {
312
+		if ($this->_cur_dtt_id === 0 && count($this->_dtts_for_event) === 1) {
313 313
 			$latest_related_datetime = $item->get_latest_related_datetime();
314
-			if ( $latest_related_datetime instanceof EE_Datetime ) {
314
+			if ($latest_related_datetime instanceof EE_Datetime) {
315 315
 				$this->_cur_dtt_id = $latest_related_datetime->ID();
316 316
 			}
317 317
 		}
318 318
 
319
-		$checkinstatus = $item->check_in_status_for_datetime( $this->_cur_dtt_id );
320
-		$nonce = wp_create_nonce( 'checkin_nonce' );
321
-		$toggle_active = ! empty ( $this->_cur_dtt_id )
319
+		$checkinstatus = $item->check_in_status_for_datetime($this->_cur_dtt_id);
320
+		$nonce = wp_create_nonce('checkin_nonce');
321
+		$toggle_active = ! empty ($this->_cur_dtt_id)
322 322
 		                 && EE_Registry::instance()->CAP->current_user_can(
323 323
 			'ee_edit_checkin',
324 324
 			'espresso_registrations_toggle_checkin_status',
@@ -326,11 +326,11 @@  discard block
 block discarded – undo
326 326
 		)
327 327
 			? ' clickable trigger-checkin'
328 328
 			: '';
329
-		$mobile_view_content = ' <span class="show-on-mobile-view-only">' . $attendee_name . '</span>';
330
-		return '<span class="checkin-icons checkedin-status-' . $checkinstatus . $toggle_active . '"'
331
-		       . ' data-_regid="' . $item->ID() . '"'
332
-		       . ' data-dttid="' . $this->_cur_dtt_id . '"'
333
-		       . ' data-nonce="' . $nonce . '">'
329
+		$mobile_view_content = ' <span class="show-on-mobile-view-only">'.$attendee_name.'</span>';
330
+		return '<span class="checkin-icons checkedin-status-'.$checkinstatus.$toggle_active.'"'
331
+		       . ' data-_regid="'.$item->ID().'"'
332
+		       . ' data-dttid="'.$this->_cur_dtt_id.'"'
333
+		       . ' data-nonce="'.$nonce.'">'
334 334
 		       . '</span>'
335 335
 		       . $mobile_view_content;
336 336
 	}
@@ -342,21 +342,21 @@  discard block
 block discarded – undo
342 342
 	 * @return mixed|string|void
343 343
 	 * @throws \EE_Error
344 344
 	 */
345
-	public function column_ATT_name( EE_Registration $item ) {
345
+	public function column_ATT_name(EE_Registration $item) {
346 346
 		$attendee = $item->attendee();
347
-		if ( ! $attendee instanceof EE_Attendee ) {
348
-			return __( 'No contact record for this registration.', 'event_espresso' );
347
+		if ( ! $attendee instanceof EE_Attendee) {
348
+			return __('No contact record for this registration.', 'event_espresso');
349 349
 		}
350 350
 		// edit attendee link
351 351
 		$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
352
-			array( 'action' => 'view_registration', '_REG_ID' => $item->ID() ),
352
+			array('action' => 'view_registration', '_REG_ID' => $item->ID()),
353 353
 			REG_ADMIN_URL
354 354
 		);
355 355
 		$name_link = EE_Registry::instance()->CAP->current_user_can(
356 356
 			'ee_edit_contacts',
357 357
 			'espresso_registrations_edit_attendee'
358 358
 		)
359
-			? '<a href="' . $edit_lnk_url . '" title="' . esc_attr__( 'View Registration Details', 'event_espresso' ) . '">'
359
+			? '<a href="'.$edit_lnk_url.'" title="'.esc_attr__('View Registration Details', 'event_espresso').'">'
360 360
 			    . $item->attendee()->full_name()
361 361
 			    . '</a>'
362 362
 			: $item->attendee()->full_name();
@@ -364,10 +364,10 @@  discard block
 block discarded – undo
364 364
 			? '&nbsp;<sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup>	'
365 365
 			: '';
366 366
 		//add group details
367
-		$name_link .= '&nbsp;' . sprintf( __( '(%s of %s)', 'event_espresso' ), $item->count(), $item->group_size() );
367
+		$name_link .= '&nbsp;'.sprintf(__('(%s of %s)', 'event_espresso'), $item->count(), $item->group_size());
368 368
 		//add regcode
369 369
 		$link = EE_Admin_Page::add_query_args_and_nonce(
370
-			array( 'action' => 'view_registration', '_REG_ID' => $item->ID() ),
370
+			array('action' => 'view_registration', '_REG_ID' => $item->ID()),
371 371
 			REG_ADMIN_URL
372 372
 		);
373 373
 		$name_link .= '<br>';
@@ -376,50 +376,50 @@  discard block
 block discarded – undo
376 376
 			'view_registration',
377 377
 			$item->ID()
378 378
 		)
379
-			? '<a href="' . $link . '" title="' . esc_attr__( 'View Registration Details', 'event_espresso' ) . '">'
379
+			? '<a href="'.$link.'" title="'.esc_attr__('View Registration Details', 'event_espresso').'">'
380 380
 			  . $item->reg_code()
381 381
 			  . '</a>'
382 382
 			: $item->reg_code();
383 383
 		//status
384 384
 		$name_link .= '<br><span class="ee-status-text-small">';
385
-		$name_link .= EEH_Template::pretty_status( $item->status_ID(), false, 'sentence' );
385
+		$name_link .= EEH_Template::pretty_status($item->status_ID(), false, 'sentence');
386 386
 		$name_link .= '</span>';
387 387
 		$actions = array();
388 388
 		$DTT_ID = $this->_cur_dtt_id;
389
-		$latest_related_datetime = empty( $DTT_ID ) && ! empty( $this->_req_data['event_id'] ) && $item instanceof EE_Registration
389
+		$latest_related_datetime = empty($DTT_ID) && ! empty($this->_req_data['event_id']) && $item instanceof EE_Registration
390 390
 			? $item->get_latest_related_datetime()
391 391
 			: null;
392 392
 		$DTT_ID = $latest_related_datetime instanceof EE_Datetime
393 393
 			? $latest_related_datetime->ID()
394 394
 			: $DTT_ID;
395
-		if ( ! empty( $DTT_ID )
395
+		if ( ! empty($DTT_ID)
396 396
 		     && EE_Registry::instance()->CAP->current_user_can(
397 397
 				'ee_read_checkins',
398 398
 				'espresso_registrations_registration_checkins'
399 399
 			)
400 400
 		) {
401 401
 			$checkin_list_url = EE_Admin_Page::add_query_args_and_nonce(
402
-				array( 'action' => 'registration_checkins', '_REGID' => $item->ID(), 'DTT_ID' => $DTT_ID )
402
+				array('action' => 'registration_checkins', '_REGID' => $item->ID(), 'DTT_ID' => $DTT_ID)
403 403
 			);
404 404
 			// get the timestamps for this registration's checkins, related to the selected datetime
405
-			$timestamps = $item->get_many_related( 'Checkin', array( array( 'DTT_ID' => $DTT_ID ) ) );
406
-			if( ! empty( $timestamps ) ) {
405
+			$timestamps = $item->get_many_related('Checkin', array(array('DTT_ID' => $DTT_ID)));
406
+			if ( ! empty($timestamps)) {
407 407
 				// get the last timestamp
408
-				$last_timestamp = end( $timestamps );
408
+				$last_timestamp = end($timestamps);
409 409
 				// checked in or checked out?
410
-				$checkin_status = $last_timestamp->get( 'CHK_in' ) 
411
-					? esc_html__( 'Checked In', 'event_espresso' )
412
-					: esc_html__( 'Checked Out', 'event_espresso' );
410
+				$checkin_status = $last_timestamp->get('CHK_in') 
411
+					? esc_html__('Checked In', 'event_espresso')
412
+					: esc_html__('Checked Out', 'event_espresso');
413 413
 				// get timestamp string
414
-				$timestamp_string = $last_timestamp->get_datetime( 'CHK_timestamp' );
415
-				$actions['checkin'] = '<a href="' . $checkin_list_url . '" title="' . esc_attr__(
414
+				$timestamp_string = $last_timestamp->get_datetime('CHK_timestamp');
415
+				$actions['checkin'] = '<a href="'.$checkin_list_url.'" title="'.esc_attr__(
416 416
 						'View this registrant\'s check-ins/checkouts for the datetime',
417 417
 						'event_espresso'
418
-					) . '">' . $checkin_status . ': ' . $timestamp_string . '</a>';
418
+					).'">'.$checkin_status.': '.$timestamp_string.'</a>';
419 419
 			}
420 420
 		} 
421
-		return ( ! empty( $DTT_ID ) && ! empty( $timestamps ) ) 
422
-			? sprintf( '%1$s %2$s', $name_link, $this->row_actions( $actions, true ) ) 
421
+		return ( ! empty($DTT_ID) && ! empty($timestamps)) 
422
+			? sprintf('%1$s %2$s', $name_link, $this->row_actions($actions, true)) 
423 423
 			: $name_link;
424 424
 	}
425 425
 
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 	 * @param \EE_Registration $item
430 430
 	 * @return string
431 431
 	 */
432
-	public function column_ATT_email( EE_Registration $item ) {
432
+	public function column_ATT_email(EE_Registration $item) {
433 433
 		$attendee = $item->attendee();
434 434
 		return $attendee instanceof EE_Attendee ? $attendee->email() : '';
435 435
 	}
@@ -441,22 +441,22 @@  discard block
 block discarded – undo
441 441
 	 * @return bool|string
442 442
 	 * @throws \EE_Error
443 443
 	 */
444
-	public function column_Event( EE_Registration $item ) {
444
+	public function column_Event(EE_Registration $item) {
445 445
 		try {
446 446
 			$event = $this->_evt instanceof EE_Event ? $this->_evt : $item->event();
447 447
 			$chkin_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
448
-				array( 'action' => 'event_registrations', 'event_id' => $event->ID() ),
448
+				array('action' => 'event_registrations', 'event_id' => $event->ID()),
449 449
 				REG_ADMIN_URL
450 450
 			);
451 451
 			$event_label = EE_Registry::instance()->CAP->current_user_can(
452 452
 				'ee_read_checkins',
453 453
 				'espresso_registrations_registration_checkins'
454
-			) ? '<a href="' . $chkin_lnk_url . '" title="' . esc_attr__(
454
+			) ? '<a href="'.$chkin_lnk_url.'" title="'.esc_attr__(
455 455
 					'View Checkins for this Event',
456 456
 					'event_espresso'
457
-				) . '">' . $event->name() . '</a>' : $event->name();
458
-		} catch ( \EventEspresso\core\exceptions\EntityNotFoundException $e ) {
459
-			$event_label = esc_html__( 'Unknown', 'event_espresso' );
457
+				).'">'.$event->name().'</a>' : $event->name();
458
+		} catch (\EventEspresso\core\exceptions\EntityNotFoundException $e) {
459
+			$event_label = esc_html__('Unknown', 'event_espresso');
460 460
 		}
461 461
 		return $event_label;
462 462
 	}
@@ -467,8 +467,8 @@  discard block
 block discarded – undo
467 467
 	 * @param \EE_Registration $item
468 468
 	 * @return mixed|string|void
469 469
 	 */
470
-	public function column_PRC_name( EE_Registration $item ) {
471
-		return $item->ticket() instanceof EE_Ticket ? $item->ticket()->name() : __( "Unknown", "event_espresso" );
470
+	public function column_PRC_name(EE_Registration $item) {
471
+		return $item->ticket() instanceof EE_Ticket ? $item->ticket()->name() : __("Unknown", "event_espresso");
472 472
 	}
473 473
 
474 474
 
@@ -479,8 +479,8 @@  discard block
 block discarded – undo
479 479
 	 * @param \EE_Registration $item
480 480
 	 * @return string
481 481
 	 */
482
-	public function column__REG_final_price( EE_Registration $item ) {
483
-		return '<span class="reg-pad-rght">' . ' ' . $item->pretty_final_price() . '</span>';
482
+	public function column__REG_final_price(EE_Registration $item) {
483
+		return '<span class="reg-pad-rght">'.' '.$item->pretty_final_price().'</span>';
484 484
 	}
485 485
 
486 486
 
@@ -492,13 +492,13 @@  discard block
 block discarded – undo
492 492
 	 * @return string
493 493
 	 * @throws \EE_Error
494 494
 	 */
495
-	public function column_TXN_paid( EE_Registration $item ) {
496
-		if ( $item->count() === 1 ) {
497
-			if ( $item->transaction()->paid() >= $item->transaction()->total() ) {
495
+	public function column_TXN_paid(EE_Registration $item) {
496
+		if ($item->count() === 1) {
497
+			if ($item->transaction()->paid() >= $item->transaction()->total()) {
498 498
 				return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>';
499 499
 			} else {
500 500
 				$view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
501
-					array( 'action' => 'view_transaction', 'TXN_ID' => $item->transaction_ID() ),
501
+					array('action' => 'view_transaction', 'TXN_ID' => $item->transaction_ID()),
502 502
 					TXN_ADMIN_URL
503 503
 				);
504 504
 				return EE_Registry::instance()->CAP->current_user_can(
@@ -511,13 +511,13 @@  discard block
 block discarded – undo
511 511
 				    . '" href="'
512 512
 				    . $view_txn_lnk_url
513 513
 				    . '"  title="'
514
-				    . esc_attr__( 'View Transaction', 'event_espresso' )
514
+				    . esc_attr__('View Transaction', 'event_espresso')
515 515
 				    . '">
516 516
 						'
517 517
 				    . $item->transaction()->pretty_paid()
518 518
 				    . '
519 519
 					</a>
520
-				<span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>';
520
+				<span>' : '<span class="reg-pad-rght">'.$item->transaction()->pretty_paid().'</span>';
521 521
 			}
522 522
 		} else {
523 523
 			return '<span class="reg-pad-rght"></span>';
@@ -533,13 +533,13 @@  discard block
 block discarded – undo
533 533
 	 * @return string
534 534
 	 * @throws \EE_Error
535 535
 	 */
536
-	public function column_TXN_total( EE_Registration $item ) {
536
+	public function column_TXN_total(EE_Registration $item) {
537 537
 		$txn = $item->transaction();
538
-		$view_txn_url = add_query_arg( array( 'action' => 'view_transaction', 'TXN_ID' => $txn->ID() ), TXN_ADMIN_URL );
539
-		if ( $item->get( 'REG_count' ) === 1 ) {
538
+		$view_txn_url = add_query_arg(array('action' => 'view_transaction', 'TXN_ID' => $txn->ID()), TXN_ADMIN_URL);
539
+		if ($item->get('REG_count') === 1) {
540 540
 			$line_total_obj = $txn->total_line_item();
541 541
 			$txn_total = $line_total_obj instanceof EE_Line_Item
542
-				? $line_total_obj->get_pretty( 'LIN_total' )
542
+				? $line_total_obj->get_pretty('LIN_total')
543 543
 				: __(
544 544
 					'View Transaction',
545 545
 					'event_espresso'
@@ -550,10 +550,10 @@  discard block
 block discarded – undo
550 550
 			) ? '<a href="'
551 551
 			    . $view_txn_url
552 552
 			    . '" title="'
553
-			    . esc_attr__( 'View Transaction', 'event_espresso' )
553
+			    . esc_attr__('View Transaction', 'event_espresso')
554 554
 			    . '"><span class="reg-pad-rght">'
555 555
 			    . $txn_total
556
-			    . '</span></a>' : '<span class="reg-pad-rght">' . $txn_total . '</span>';
556
+			    . '</span></a>' : '<span class="reg-pad-rght">'.$txn_total.'</span>';
557 557
 		} else {
558 558
 			return '<span class="reg-pad-rght"></span>';
559 559
 		}
Please login to merge, or discard this patch.
core/exceptions/ExceptionStackTraceDisplay.php 2 patches
Indentation   +275 added lines, -275 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 use ReflectionException;
8 8
 
9 9
 if (! defined('EVENT_ESPRESSO_VERSION')) {
10
-    exit('No direct script access allowed');
10
+	exit('No direct script access allowed');
11 11
 }
12 12
 
13 13
 
@@ -25,53 +25,53 @@  discard block
 block discarded – undo
25 25
 
26 26
 
27 27
 
28
-    /**
29
-     * @param Exception $exception
30
-     * @throws Exception
31
-     */
32
-    public function __construct(Exception $exception)
33
-    {
34
-        if (WP_DEBUG && ! defined('EE_TESTS_DIR')) {
35
-            $this->displayException($exception);
36
-        } else {
37
-            throw $exception;
38
-        }
39
-    }
28
+	/**
29
+	 * @param Exception $exception
30
+	 * @throws Exception
31
+	 */
32
+	public function __construct(Exception $exception)
33
+	{
34
+		if (WP_DEBUG && ! defined('EE_TESTS_DIR')) {
35
+			$this->displayException($exception);
36
+		} else {
37
+			throw $exception;
38
+		}
39
+	}
40 40
 
41 41
 
42 42
 
43
-    /**
44
-     * @access protected
45
-     * @param Exception $exception
46
-     * @throws ReflectionException
47
-     */
48
-    protected function displayException(Exception $exception)
49
-    {
50
-        $error_code = '';
51
-        $trace_details = '';
52
-        $time = time();
53
-        $trace = $exception->getTrace();
54
-        // get separate user and developer messages if they exist
55
-        $msg = explode('||', $exception->getMessage());
56
-        $user_msg = $msg[0];
57
-        $dev_msg = isset($msg[1]) ? $msg[1] : $msg[0];
58
-        $msg = WP_DEBUG ? $dev_msg : $user_msg;
59
-        // start gathering output
60
-        $output = $this->exceptionStyles();
61
-        $output .= '
43
+	/**
44
+	 * @access protected
45
+	 * @param Exception $exception
46
+	 * @throws ReflectionException
47
+	 */
48
+	protected function displayException(Exception $exception)
49
+	{
50
+		$error_code = '';
51
+		$trace_details = '';
52
+		$time = time();
53
+		$trace = $exception->getTrace();
54
+		// get separate user and developer messages if they exist
55
+		$msg = explode('||', $exception->getMessage());
56
+		$user_msg = $msg[0];
57
+		$dev_msg = isset($msg[1]) ? $msg[1] : $msg[0];
58
+		$msg = WP_DEBUG ? $dev_msg : $user_msg;
59
+		// start gathering output
60
+		$output = $this->exceptionStyles();
61
+		$output .= '
62 62
 <div id="ee-error-message" class="error">';
63
-        if (! WP_DEBUG) {
64
-            $output .= '
63
+		if (! WP_DEBUG) {
64
+			$output .= '
65 65
 	<p>';
66
-        }
67
-        // process trace info
68
-        if (empty($trace)) {
69
-            $trace_details .= __(
70
-                'Sorry, but no trace information was available for this exception.',
71
-                'event_espresso'
72
-            );
73
-        } else {
74
-            $trace_details .= '
66
+		}
67
+		// process trace info
68
+		if (empty($trace)) {
69
+			$trace_details .= __(
70
+				'Sorry, but no trace information was available for this exception.',
71
+				'event_espresso'
72
+			);
73
+		} else {
74
+			$trace_details .= '
75 75
 			<div id="ee-trace-details">
76 76
 			<table width="100%" border="0" cellpadding="5" cellspacing="0">
77 77
 				<tr>
@@ -79,255 +79,255 @@  discard block
 block discarded – undo
79 79
 					<th scope="col" align="right" style="width:3.5%;">Line</th>
80 80
 					<th scope="col" align="left" style="width:40%;">File</th>
81 81
 					<th scope="col" align="left">' . __('Class', 'event_espresso') . '->' . __('Method( arguments )',
82
-                    'event_espresso') . '</th>
82
+					'event_espresso') . '</th>
83 83
 				</tr>';
84
-            $last_on_stack = count($trace) - 1;
85
-            // reverse array so that stack is in proper chronological order
86
-            $sorted_trace = array_reverse($trace);
87
-            foreach ($sorted_trace as $nmbr => $trace) {
88
-                $file = isset($trace['file']) ? $trace['file'] : '';
89
-                $class = isset($trace['class']) ? $trace['class'] : '';
90
-                $type = isset($trace['type']) ? $trace['type'] : '';
91
-                $function = isset($trace['function']) ? $trace['function'] : '';
92
-                $args = isset($trace['args']) ? $this->_convert_args_to_string($trace['args']) : '';
93
-                $args = isset($trace['args']) && count($trace['args']) > 4 ? ' <br />' . $args . '<br />' : $args;
94
-                $line = isset($trace['line']) ? $trace['line'] : '';
95
-                $zebra = $nmbr % 2 !== 0 ? ' odd' : '';
96
-                if (empty($file) && ! empty($class)) {
97
-                    $a = new ReflectionClass($class);
98
-                    $file = $a->getFileName();
99
-                    if (empty($line) && ! empty($function)) {
100
-                        $b = new \ReflectionMethod($class, $function);
101
-                        $line = $b->getStartLine();
102
-                    }
103
-                }
104
-                if ($nmbr === $last_on_stack) {
105
-                    $file = $exception->getFile() !== '' ? $exception->getFile() : $file;
106
-                    $line = $exception->getLine() !== '' ? $exception->getLine() : $line;
107
-                    $error_code = $this->generate_error_code($file, $trace['function'], $line);
108
-                }
109
-                $file = \EEH_File::standardise_directory_separators($file);
110
-                $nmbr = ! empty($nmbr) ? $nmbr : '&nbsp;';
111
-                $line = ! empty($line) ? $line : '&nbsp;';
112
-                $file = ! empty($file) ? $file : '&nbsp;';
113
-                $class_display = ! empty($class) ? $class : '';
114
-                $type = ! empty($type) ? $type : '';
115
-                $function = ! empty($function) ? $function : '';
116
-                $args = ! empty($args) ? '( ' . $args . ' )' : '()';
117
-                $trace_details .= '
84
+			$last_on_stack = count($trace) - 1;
85
+			// reverse array so that stack is in proper chronological order
86
+			$sorted_trace = array_reverse($trace);
87
+			foreach ($sorted_trace as $nmbr => $trace) {
88
+				$file = isset($trace['file']) ? $trace['file'] : '';
89
+				$class = isset($trace['class']) ? $trace['class'] : '';
90
+				$type = isset($trace['type']) ? $trace['type'] : '';
91
+				$function = isset($trace['function']) ? $trace['function'] : '';
92
+				$args = isset($trace['args']) ? $this->_convert_args_to_string($trace['args']) : '';
93
+				$args = isset($trace['args']) && count($trace['args']) > 4 ? ' <br />' . $args . '<br />' : $args;
94
+				$line = isset($trace['line']) ? $trace['line'] : '';
95
+				$zebra = $nmbr % 2 !== 0 ? ' odd' : '';
96
+				if (empty($file) && ! empty($class)) {
97
+					$a = new ReflectionClass($class);
98
+					$file = $a->getFileName();
99
+					if (empty($line) && ! empty($function)) {
100
+						$b = new \ReflectionMethod($class, $function);
101
+						$line = $b->getStartLine();
102
+					}
103
+				}
104
+				if ($nmbr === $last_on_stack) {
105
+					$file = $exception->getFile() !== '' ? $exception->getFile() : $file;
106
+					$line = $exception->getLine() !== '' ? $exception->getLine() : $line;
107
+					$error_code = $this->generate_error_code($file, $trace['function'], $line);
108
+				}
109
+				$file = \EEH_File::standardise_directory_separators($file);
110
+				$nmbr = ! empty($nmbr) ? $nmbr : '&nbsp;';
111
+				$line = ! empty($line) ? $line : '&nbsp;';
112
+				$file = ! empty($file) ? $file : '&nbsp;';
113
+				$class_display = ! empty($class) ? $class : '';
114
+				$type = ! empty($type) ? $type : '';
115
+				$function = ! empty($function) ? $function : '';
116
+				$args = ! empty($args) ? '( ' . $args . ' )' : '()';
117
+				$trace_details .= '
118 118
 					<tr>
119 119
 						<td align="right" valign="top" class="'
120
-                                  . $zebra
121
-                                  . '">'
122
-                                  . $nmbr
123
-                                  . '</td>
120
+								  . $zebra
121
+								  . '">'
122
+								  . $nmbr
123
+								  . '</td>
124 124
 						<td align="right" valign="top" class="'
125
-                                  . $zebra
126
-                                  . '">'
127
-                                  . $line
128
-                                  . '</td>
125
+								  . $zebra
126
+								  . '">'
127
+								  . $line
128
+								  . '</td>
129 129
 						<td align="left" valign="top" class="'
130
-                                  . $zebra
131
-                                  . '">'
132
-                                  . $file
133
-                                  . '</td>
130
+								  . $zebra
131
+								  . '">'
132
+								  . $file
133
+								  . '</td>
134 134
 						<td align="left" valign="top" class="'
135
-                                  . $zebra
136
-                                  . '">'
137
-                                  . $class_display
138
-                                  . $type
139
-                                  . $function
140
-                                  . $args
141
-                                  . '</td>
135
+								  . $zebra
136
+								  . '">'
137
+								  . $class_display
138
+								  . $type
139
+								  . $function
140
+								  . $args
141
+								  . '</td>
142 142
 					</tr>';
143
-            }
144
-            $trace_details .= '
143
+			}
144
+			$trace_details .= '
145 145
 			 </table>
146 146
 			</div>';
147
-        }
148
-        $code = $exception->getCode() ? $exception->getCode() : $error_code;
149
-        // add generic non-identifying messages for non-privileged users
150
-        if (! WP_DEBUG) {
151
-            $output .= '<span class="ee-error-user-msg-spn">'
152
-                       . trim($msg)
153
-                       . '</span> &nbsp; <sup>'
154
-                       . $code
155
-                       . '</sup><br />';
156
-        } else {
157
-            // or helpful developer messages if debugging is on
158
-            $output .= '
147
+		}
148
+		$code = $exception->getCode() ? $exception->getCode() : $error_code;
149
+		// add generic non-identifying messages for non-privileged users
150
+		if (! WP_DEBUG) {
151
+			$output .= '<span class="ee-error-user-msg-spn">'
152
+					   . trim($msg)
153
+					   . '</span> &nbsp; <sup>'
154
+					   . $code
155
+					   . '</sup><br />';
156
+		} else {
157
+			// or helpful developer messages if debugging is on
158
+			$output .= '
159 159
 		<div class="ee-error-dev-msg-dv">
160 160
 			<p class="ee-error-dev-msg-pg">
161 161
 				'
162
-                       . sprintf(
163
-                           __('%1$sAn %2$s was thrown!%3$s code: %4$s', 'event_espresso'),
164
-                           '<strong class="ee-error-dev-msg-str">',
165
-                           get_class($exception),
166
-                           '</strong>  &nbsp; <span>',
167
-                           $code . '</span>'
168
-                       )
169
-                       . '<br />
162
+					   . sprintf(
163
+						   __('%1$sAn %2$s was thrown!%3$s code: %4$s', 'event_espresso'),
164
+						   '<strong class="ee-error-dev-msg-str">',
165
+						   get_class($exception),
166
+						   '</strong>  &nbsp; <span>',
167
+						   $code . '</span>'
168
+					   )
169
+					   . '<br />
170 170
 				<span class="big-text">"'
171
-                       . trim($msg)
172
-                       . '"</span><br/>
171
+					   . trim($msg)
172
+					   . '"</span><br/>
173 173
 				<a id="display-ee-error-trace-1'
174
-                       . $time
175
-                       . '" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-1'
176
-                       . $time
177
-                       . '">
174
+					   . $time
175
+					   . '" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-1'
176
+					   . $time
177
+					   . '">
178 178
 					'
179
-                       . __('click to view backtrace and class/method details', 'event_espresso')
180
-                       . '
179
+					   . __('click to view backtrace and class/method details', 'event_espresso')
180
+					   . '
181 181
 				</a><br />
182 182
 				'
183
-                       . $exception->getFile()
184
-                       . sprintf(
185
-                           __('%1$s( line no: %2$s )%3$s', 'event_espresso'),
186
-                           ' &nbsp; <span class="small-text lt-grey-text">',
187
-                           $exception->getLine(),
188
-                           '</span>'
189
-                       )
190
-                       . '
183
+					   . $exception->getFile()
184
+					   . sprintf(
185
+						   __('%1$s( line no: %2$s )%3$s', 'event_espresso'),
186
+						   ' &nbsp; <span class="small-text lt-grey-text">',
187
+						   $exception->getLine(),
188
+						   '</span>'
189
+					   )
190
+					   . '
191 191
 			</p>
192 192
 			<div id="ee-error-trace-1'
193
-                       . $time
194
-                       . '-dv" class="ee-error-trace-dv" style="display: none;">
193
+					   . $time
194
+					   . '-dv" class="ee-error-trace-dv" style="display: none;">
195 195
 				'
196
-                       . $trace_details;
197
-            if (! empty($class)) {
198
-                $output .= '
196
+					   . $trace_details;
197
+			if (! empty($class)) {
198
+				$output .= '
199 199
 				<div style="padding:3px; margin:0 0 1em; border:1px solid #999; background:#fff; border-radius:3px;">
200 200
 					<div style="padding:1em 2em; border:1px solid #999; background:#fcfcfc;">
201 201
 						<h3>' . __('Class Details', 'event_espresso') . '</h3>';
202
-                $a = new ReflectionClass($class);
203
-                $output .= '
202
+				$a = new ReflectionClass($class);
203
+				$output .= '
204 204
 						<pre>' . $a . '</pre>
205 205
 					</div>
206 206
 				</div>';
207
-            }
208
-            $output .= '
207
+			}
208
+			$output .= '
209 209
 			</div>
210 210
 		</div>
211 211
 		<br />';
212
-        }
213
-        // remove last linebreak
214
-        $output = substr($output, 0, -6);
215
-        if (! WP_DEBUG) {
216
-            $output .= '
212
+		}
213
+		// remove last linebreak
214
+		$output = substr($output, 0, -6);
215
+		if (! WP_DEBUG) {
216
+			$output .= '
217 217
 	</p>';
218
-        }
219
-        $output .= '
218
+		}
219
+		$output .= '
220 220
 </div>';
221
-        $output .= $this->printScripts(true);
222
-        if (defined('DOING_AJAX')) {
223
-            echo wp_json_encode(array('error' => $output));
224
-            exit();
225
-        }
226
-        echo $output;
227
-    }
221
+		$output .= $this->printScripts(true);
222
+		if (defined('DOING_AJAX')) {
223
+			echo wp_json_encode(array('error' => $output));
224
+			exit();
225
+		}
226
+		echo $output;
227
+	}
228 228
 
229 229
 
230 230
 
231
-    /**
232
-     * generate string from exception trace args
233
-     *
234
-     * @param array $arguments
235
-     * @param int   $indent
236
-     * @param bool  $array
237
-     * @return string
238
-     */
239
-    private function _convert_args_to_string($arguments = array(), $indent = 0, $array = false)
240
-    {
241
-        $args = array();
242
-        $args_count = count($arguments);
243
-        if ($args_count > 2) {
244
-            $indent++;
245
-            $args[] = '<br />';
246
-        }
247
-        $x = 0;
248
-        foreach ($arguments as $arg) {
249
-            $x++;
250
-            for ($i = 0; $i < $indent; $i++) {
251
-                $args[] = ' &nbsp;&nbsp; ';
252
-            }
253
-            if (is_string($arg)) {
254
-                if (! $array && strlen($arg) > 75) {
255
-                    $args[] = '<br />';
256
-                    for ($i = 0; $i <= $indent; $i++) {
257
-                        $args[] = ' &nbsp;&nbsp; ';
258
-                    }
259
-                    $args[] = "'" . $arg . "'<br />";
260
-                } else {
261
-                    $args[] = " '" . $arg . "'";
262
-                }
263
-            } elseif (is_array($arg)) {
264
-                $arg_count = count($arg);
265
-                if ($arg_count > 2) {
266
-                    $indent++;
267
-                    $args[] = ' array(' . $this->_convert_args_to_string($arg, $indent, true) . ')';
268
-                    $indent--;
269
-                } else if ($arg_count === 0) {
270
-                    $args[] = ' array()';
271
-                } else {
272
-                    $args[] = ' array( ' . $this->_convert_args_to_string($arg) . ' )';
273
-                }
274
-            } elseif ($arg === null) {
275
-                $args[] = ' null';
276
-            } elseif (is_bool($arg)) {
277
-                $args[] = $arg ? ' true' : ' false';
278
-            } elseif (is_object($arg)) {
279
-                $args[] = get_class($arg);
280
-            } elseif (is_resource($arg)) {
281
-                $args[] = get_resource_type($arg);
282
-            } else {
283
-                $args[] = $arg;
284
-            }
285
-            if ($x === $args_count) {
286
-                if ($args_count > 2) {
287
-                    $args[] = '<br />';
288
-                    $indent--;
289
-                    for ($i = 1; $i < $indent; $i++) {
290
-                        $args[] = ' &nbsp;&nbsp; ';
291
-                    }
292
-                }
293
-            } else {
294
-                $args[] = $args_count > 2 ? ',<br />' : ', ';
295
-            }
296
-        }
297
-        return implode('', $args);
298
-    }
231
+	/**
232
+	 * generate string from exception trace args
233
+	 *
234
+	 * @param array $arguments
235
+	 * @param int   $indent
236
+	 * @param bool  $array
237
+	 * @return string
238
+	 */
239
+	private function _convert_args_to_string($arguments = array(), $indent = 0, $array = false)
240
+	{
241
+		$args = array();
242
+		$args_count = count($arguments);
243
+		if ($args_count > 2) {
244
+			$indent++;
245
+			$args[] = '<br />';
246
+		}
247
+		$x = 0;
248
+		foreach ($arguments as $arg) {
249
+			$x++;
250
+			for ($i = 0; $i < $indent; $i++) {
251
+				$args[] = ' &nbsp;&nbsp; ';
252
+			}
253
+			if (is_string($arg)) {
254
+				if (! $array && strlen($arg) > 75) {
255
+					$args[] = '<br />';
256
+					for ($i = 0; $i <= $indent; $i++) {
257
+						$args[] = ' &nbsp;&nbsp; ';
258
+					}
259
+					$args[] = "'" . $arg . "'<br />";
260
+				} else {
261
+					$args[] = " '" . $arg . "'";
262
+				}
263
+			} elseif (is_array($arg)) {
264
+				$arg_count = count($arg);
265
+				if ($arg_count > 2) {
266
+					$indent++;
267
+					$args[] = ' array(' . $this->_convert_args_to_string($arg, $indent, true) . ')';
268
+					$indent--;
269
+				} else if ($arg_count === 0) {
270
+					$args[] = ' array()';
271
+				} else {
272
+					$args[] = ' array( ' . $this->_convert_args_to_string($arg) . ' )';
273
+				}
274
+			} elseif ($arg === null) {
275
+				$args[] = ' null';
276
+			} elseif (is_bool($arg)) {
277
+				$args[] = $arg ? ' true' : ' false';
278
+			} elseif (is_object($arg)) {
279
+				$args[] = get_class($arg);
280
+			} elseif (is_resource($arg)) {
281
+				$args[] = get_resource_type($arg);
282
+			} else {
283
+				$args[] = $arg;
284
+			}
285
+			if ($x === $args_count) {
286
+				if ($args_count > 2) {
287
+					$args[] = '<br />';
288
+					$indent--;
289
+					for ($i = 1; $i < $indent; $i++) {
290
+						$args[] = ' &nbsp;&nbsp; ';
291
+					}
292
+				}
293
+			} else {
294
+				$args[] = $args_count > 2 ? ',<br />' : ', ';
295
+			}
296
+		}
297
+		return implode('', $args);
298
+	}
299 299
 
300 300
 
301 301
 
302
-    /**
303
-     * create error code from filepath, function name,
304
-     * and line number where exception or error was thrown
305
-     *
306
-     * @access protected
307
-     * @param string $file
308
-     * @param string $func
309
-     * @param string $line
310
-     * @return string
311
-     */
312
-    protected function generate_error_code($file = '', $func = '', $line = '')
313
-    {
314
-        $file_bits = explode('.', basename($file));
315
-        $error_code = ! empty($file_bits[0]) ? $file_bits[0] : '';
316
-        $error_code .= ! empty($func) ? ' - ' . $func : '';
317
-        $error_code .= ! empty($line) ? ' - ' . $line : '';
318
-        return $error_code;
319
-    }
302
+	/**
303
+	 * create error code from filepath, function name,
304
+	 * and line number where exception or error was thrown
305
+	 *
306
+	 * @access protected
307
+	 * @param string $file
308
+	 * @param string $func
309
+	 * @param string $line
310
+	 * @return string
311
+	 */
312
+	protected function generate_error_code($file = '', $func = '', $line = '')
313
+	{
314
+		$file_bits = explode('.', basename($file));
315
+		$error_code = ! empty($file_bits[0]) ? $file_bits[0] : '';
316
+		$error_code .= ! empty($func) ? ' - ' . $func : '';
317
+		$error_code .= ! empty($line) ? ' - ' . $line : '';
318
+		return $error_code;
319
+	}
320 320
 
321 321
 
322 322
 
323
-    /**
324
-     * _exception_styles
325
-     *
326
-     * @return string
327
-     */
328
-    private function exceptionStyles()
329
-    {
330
-        return '
323
+	/**
324
+	 * _exception_styles
325
+	 *
326
+	 * @return string
327
+	 */
328
+	private function exceptionStyles()
329
+	{
330
+		return '
331 331
 <style type="text/css">
332 332
 	#ee-error-message {
333 333
 		max-width:90% !important;
@@ -384,30 +384,30 @@  discard block
 block discarded – undo
384 384
 		color: #999;
385 385
 	}
386 386
 </style>';
387
-    }
387
+	}
388 388
 
389 389
 
390 390
 
391
-    /**
392
-     * _print_scripts
393
-     *
394
-     * @param bool $force_print
395
-     * @return string
396
-     */
397
-    private function printScripts($force_print = false)
398
-    {
399
-        if (! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) {
400
-            if (wp_script_is('ee_error_js', 'enqueued')) {
401
-                return '';
402
-            }
403
-            if (wp_script_is('ee_error_js', 'registered')) {
404
-                wp_enqueue_style('espresso_default');
405
-                wp_enqueue_style('espresso_custom_css');
406
-                wp_enqueue_script( 'ee_error_js' );
391
+	/**
392
+	 * _print_scripts
393
+	 *
394
+	 * @param bool $force_print
395
+	 * @return string
396
+	 */
397
+	private function printScripts($force_print = false)
398
+	{
399
+		if (! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) {
400
+			if (wp_script_is('ee_error_js', 'enqueued')) {
401
+				return '';
402
+			}
403
+			if (wp_script_is('ee_error_js', 'registered')) {
404
+				wp_enqueue_style('espresso_default');
405
+				wp_enqueue_style('espresso_custom_css');
406
+				wp_enqueue_script( 'ee_error_js' );
407 407
 				wp_localize_script( 'ee_error_js', 'ee_settings', array( 'wp_debug' => WP_DEBUG ) );
408
-            }
409
-        } else {
410
-            return '
408
+			}
409
+		} else {
410
+			return '
411 411
 <script>
412 412
 /* <![CDATA[ */
413 413
 var ee_settings = {"wp_debug":"' . WP_DEBUG . '"};
@@ -417,9 +417,9 @@  discard block
 block discarded – undo
417 417
 <script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script>
418 418
 <script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script>
419 419
 ';
420
-        }
421
-        return '';
422
-    }
420
+		}
421
+		return '';
422
+	}
423 423
 
424 424
 
425 425
 
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
 use ReflectionClass;
7 7
 use ReflectionException;
8 8
 
9
-if (! defined('EVENT_ESPRESSO_VERSION')) {
9
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
10 10
     exit('No direct script access allowed');
11 11
 }
12 12
 
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
         $output = $this->exceptionStyles();
61 61
         $output .= '
62 62
 <div id="ee-error-message" class="error">';
63
-        if (! WP_DEBUG) {
63
+        if ( ! WP_DEBUG) {
64 64
             $output .= '
65 65
 	<p>';
66 66
         }
@@ -78,8 +78,8 @@  discard block
 block discarded – undo
78 78
 					<th scope="col" align="right" style="width:2.5%;">#</th>
79 79
 					<th scope="col" align="right" style="width:3.5%;">Line</th>
80 80
 					<th scope="col" align="left" style="width:40%;">File</th>
81
-					<th scope="col" align="left">' . __('Class', 'event_espresso') . '->' . __('Method( arguments )',
82
-                    'event_espresso') . '</th>
81
+					<th scope="col" align="left">' . __('Class', 'event_espresso').'->'.__('Method( arguments )',
82
+                    'event_espresso').'</th>
83 83
 				</tr>';
84 84
             $last_on_stack = count($trace) - 1;
85 85
             // reverse array so that stack is in proper chronological order
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
                 $type = isset($trace['type']) ? $trace['type'] : '';
91 91
                 $function = isset($trace['function']) ? $trace['function'] : '';
92 92
                 $args = isset($trace['args']) ? $this->_convert_args_to_string($trace['args']) : '';
93
-                $args = isset($trace['args']) && count($trace['args']) > 4 ? ' <br />' . $args . '<br />' : $args;
93
+                $args = isset($trace['args']) && count($trace['args']) > 4 ? ' <br />'.$args.'<br />' : $args;
94 94
                 $line = isset($trace['line']) ? $trace['line'] : '';
95 95
                 $zebra = $nmbr % 2 !== 0 ? ' odd' : '';
96 96
                 if (empty($file) && ! empty($class)) {
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
                 $class_display = ! empty($class) ? $class : '';
114 114
                 $type = ! empty($type) ? $type : '';
115 115
                 $function = ! empty($function) ? $function : '';
116
-                $args = ! empty($args) ? '( ' . $args . ' )' : '()';
116
+                $args = ! empty($args) ? '( '.$args.' )' : '()';
117 117
                 $trace_details .= '
118 118
 					<tr>
119 119
 						<td align="right" valign="top" class="'
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
         }
148 148
         $code = $exception->getCode() ? $exception->getCode() : $error_code;
149 149
         // add generic non-identifying messages for non-privileged users
150
-        if (! WP_DEBUG) {
150
+        if ( ! WP_DEBUG) {
151 151
             $output .= '<span class="ee-error-user-msg-spn">'
152 152
                        . trim($msg)
153 153
                        . '</span> &nbsp; <sup>'
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
                            '<strong class="ee-error-dev-msg-str">',
165 165
                            get_class($exception),
166 166
                            '</strong>  &nbsp; <span>',
167
-                           $code . '</span>'
167
+                           $code.'</span>'
168 168
                        )
169 169
                        . '<br />
170 170
 				<span class="big-text">"'
@@ -194,14 +194,14 @@  discard block
 block discarded – undo
194 194
                        . '-dv" class="ee-error-trace-dv" style="display: none;">
195 195
 				'
196 196
                        . $trace_details;
197
-            if (! empty($class)) {
197
+            if ( ! empty($class)) {
198 198
                 $output .= '
199 199
 				<div style="padding:3px; margin:0 0 1em; border:1px solid #999; background:#fff; border-radius:3px;">
200 200
 					<div style="padding:1em 2em; border:1px solid #999; background:#fcfcfc;">
201
-						<h3>' . __('Class Details', 'event_espresso') . '</h3>';
201
+						<h3>' . __('Class Details', 'event_espresso').'</h3>';
202 202
                 $a = new ReflectionClass($class);
203 203
                 $output .= '
204
-						<pre>' . $a . '</pre>
204
+						<pre>' . $a.'</pre>
205 205
 					</div>
206 206
 				</div>';
207 207
             }
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
         }
213 213
         // remove last linebreak
214 214
         $output = substr($output, 0, -6);
215
-        if (! WP_DEBUG) {
215
+        if ( ! WP_DEBUG) {
216 216
             $output .= '
217 217
 	</p>';
218 218
         }
@@ -251,25 +251,25 @@  discard block
 block discarded – undo
251 251
                 $args[] = ' &nbsp;&nbsp; ';
252 252
             }
253 253
             if (is_string($arg)) {
254
-                if (! $array && strlen($arg) > 75) {
254
+                if ( ! $array && strlen($arg) > 75) {
255 255
                     $args[] = '<br />';
256 256
                     for ($i = 0; $i <= $indent; $i++) {
257 257
                         $args[] = ' &nbsp;&nbsp; ';
258 258
                     }
259
-                    $args[] = "'" . $arg . "'<br />";
259
+                    $args[] = "'".$arg."'<br />";
260 260
                 } else {
261
-                    $args[] = " '" . $arg . "'";
261
+                    $args[] = " '".$arg."'";
262 262
                 }
263 263
             } elseif (is_array($arg)) {
264 264
                 $arg_count = count($arg);
265 265
                 if ($arg_count > 2) {
266 266
                     $indent++;
267
-                    $args[] = ' array(' . $this->_convert_args_to_string($arg, $indent, true) . ')';
267
+                    $args[] = ' array('.$this->_convert_args_to_string($arg, $indent, true).')';
268 268
                     $indent--;
269 269
                 } else if ($arg_count === 0) {
270 270
                     $args[] = ' array()';
271 271
                 } else {
272
-                    $args[] = ' array( ' . $this->_convert_args_to_string($arg) . ' )';
272
+                    $args[] = ' array( '.$this->_convert_args_to_string($arg).' )';
273 273
                 }
274 274
             } elseif ($arg === null) {
275 275
                 $args[] = ' null';
@@ -313,8 +313,8 @@  discard block
 block discarded – undo
313 313
     {
314 314
         $file_bits = explode('.', basename($file));
315 315
         $error_code = ! empty($file_bits[0]) ? $file_bits[0] : '';
316
-        $error_code .= ! empty($func) ? ' - ' . $func : '';
317
-        $error_code .= ! empty($line) ? ' - ' . $line : '';
316
+        $error_code .= ! empty($func) ? ' - '.$func : '';
317
+        $error_code .= ! empty($line) ? ' - '.$line : '';
318 318
         return $error_code;
319 319
     }
320 320
 
@@ -396,26 +396,26 @@  discard block
 block discarded – undo
396 396
      */
397 397
     private function printScripts($force_print = false)
398 398
     {
399
-        if (! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) {
399
+        if ( ! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) {
400 400
             if (wp_script_is('ee_error_js', 'enqueued')) {
401 401
                 return '';
402 402
             }
403 403
             if (wp_script_is('ee_error_js', 'registered')) {
404 404
                 wp_enqueue_style('espresso_default');
405 405
                 wp_enqueue_style('espresso_custom_css');
406
-                wp_enqueue_script( 'ee_error_js' );
407
-				wp_localize_script( 'ee_error_js', 'ee_settings', array( 'wp_debug' => WP_DEBUG ) );
406
+                wp_enqueue_script('ee_error_js');
407
+				wp_localize_script('ee_error_js', 'ee_settings', array('wp_debug' => WP_DEBUG));
408 408
             }
409 409
         } else {
410 410
             return '
411 411
 <script>
412 412
 /* <![CDATA[ */
413
-var ee_settings = {"wp_debug":"' . WP_DEBUG . '"};
413
+var ee_settings = {"wp_debug":"' . WP_DEBUG.'"};
414 414
 /* ]]> */
415 415
 </script>
416
-<script src="' . includes_url() . 'js/jquery/jquery.js" type="text/javascript"></script>
417
-<script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script>
418
-<script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script>
416
+<script src="' . includes_url().'js/jquery/jquery.js" type="text/javascript"></script>
417
+<script src="' . EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js'.'?ver='.espresso_version().'" type="text/javascript"></script>
418
+<script src="' . EE_GLOBAL_ASSETS_URL.'scripts/EE_Error.js'.'?ver='.espresso_version().'" type="text/javascript"></script>
419 419
 ';
420 420
         }
421 421
         return '';
Please login to merge, or discard this patch.