Completed
Branch FET/Gutenberg/11467/espresso-c... (b0019e)
by
unknown
49:48 queued 35:26
created
core/domain/services/custom_post_types/RegisterCustomTaxonomies.php 2 patches
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -21,72 +21,72 @@
 block discarded – undo
21 21
 class RegisterCustomTaxonomies
22 22
 {
23 23
 
24
-    /**
25
-     * @var CustomTaxonomyDefinitions $custom_taxonomies
26
-     */
27
-    public $custom_taxonomies;
24
+	/**
25
+	 * @var CustomTaxonomyDefinitions $custom_taxonomies
26
+	 */
27
+	public $custom_taxonomies;
28 28
 
29 29
 
30
-    /**
31
-     * RegisterCustomTaxonomies constructor.
32
-     *
33
-     * @param CustomTaxonomyDefinitions $custom_taxonomies
34
-     */
35
-    public function __construct(CustomTaxonomyDefinitions $custom_taxonomies)
36
-    {
37
-        $this->custom_taxonomies = $custom_taxonomies;
38
-    }
30
+	/**
31
+	 * RegisterCustomTaxonomies constructor.
32
+	 *
33
+	 * @param CustomTaxonomyDefinitions $custom_taxonomies
34
+	 */
35
+	public function __construct(CustomTaxonomyDefinitions $custom_taxonomies)
36
+	{
37
+		$this->custom_taxonomies = $custom_taxonomies;
38
+	}
39 39
 
40 40
 
41
-    /**
42
-     * @return void
43
-     * @throws DomainException
44
-     */
45
-    public function registerCustomTaxonomies()
46
-    {
47
-        $custom_taxonomies = $this->custom_taxonomies->getCustomTaxonomyDefinitions();
48
-        foreach ($custom_taxonomies as $taxonomy => $tax) {
49
-            $this->registerCustomTaxonomy(
50
-                $taxonomy,
51
-                $tax['singular_name'],
52
-                $tax['plural_name'],
53
-                $tax['args']
54
-            );
55
-        }
56
-    }
41
+	/**
42
+	 * @return void
43
+	 * @throws DomainException
44
+	 */
45
+	public function registerCustomTaxonomies()
46
+	{
47
+		$custom_taxonomies = $this->custom_taxonomies->getCustomTaxonomyDefinitions();
48
+		foreach ($custom_taxonomies as $taxonomy => $tax) {
49
+			$this->registerCustomTaxonomy(
50
+				$taxonomy,
51
+				$tax['singular_name'],
52
+				$tax['plural_name'],
53
+				$tax['args']
54
+			);
55
+		}
56
+	}
57 57
 
58 58
 
59
-    /**
60
-     * Registers a custom taxonomy. Should be called before registering custom post types,
61
-     * otherwise you should link the taxonomy to the custom post type using 'register_taxonomy_for_object_type'.
62
-     *
63
-     * @param string $taxonomy_name , eg 'books'
64
-     * @param string $singular_name internationalized singular name
65
-     * @param string $plural_name   internationalized plural name
66
-     * @param array  $override_args like $args on http://codex.wordpress.org/Function_Reference/register_taxonomy
67
-     * @throws DomainException
68
-     */
69
-    public function registerCustomTaxonomy($taxonomy_name, $singular_name, $plural_name, array $override_args)
70
-    {
71
-        $args = array(
72
-            'hierarchical'      => true,
73
-            'labels'            => array(
74
-                'name'          => $plural_name,
75
-                'singular_name' => $singular_name,
76
-            ),
77
-            'show_ui'           => true,
78
-            'show_ee_ui'        => true,
79
-            'show_admin_column' => true,
80
-            'query_var'         => true,
81
-            'show_in_nav_menus' => false,
82
-            'map_meta_cap'      => true
83
-        );
84
-        if (! empty($override_args)) {
85
-            $args = array_merge_recursive($args, $override_args);
86
-        }
87
-        $result = register_taxonomy($taxonomy_name, null, $args);
88
-        if ($result instanceof WP_Error) {
89
-            throw new DomainException($result->get_error_message());
90
-        }
91
-    }
59
+	/**
60
+	 * Registers a custom taxonomy. Should be called before registering custom post types,
61
+	 * otherwise you should link the taxonomy to the custom post type using 'register_taxonomy_for_object_type'.
62
+	 *
63
+	 * @param string $taxonomy_name , eg 'books'
64
+	 * @param string $singular_name internationalized singular name
65
+	 * @param string $plural_name   internationalized plural name
66
+	 * @param array  $override_args like $args on http://codex.wordpress.org/Function_Reference/register_taxonomy
67
+	 * @throws DomainException
68
+	 */
69
+	public function registerCustomTaxonomy($taxonomy_name, $singular_name, $plural_name, array $override_args)
70
+	{
71
+		$args = array(
72
+			'hierarchical'      => true,
73
+			'labels'            => array(
74
+				'name'          => $plural_name,
75
+				'singular_name' => $singular_name,
76
+			),
77
+			'show_ui'           => true,
78
+			'show_ee_ui'        => true,
79
+			'show_admin_column' => true,
80
+			'query_var'         => true,
81
+			'show_in_nav_menus' => false,
82
+			'map_meta_cap'      => true
83
+		);
84
+		if (! empty($override_args)) {
85
+			$args = array_merge_recursive($args, $override_args);
86
+		}
87
+		$result = register_taxonomy($taxonomy_name, null, $args);
88
+		if ($result instanceof WP_Error) {
89
+			throw new DomainException($result->get_error_message());
90
+		}
91
+	}
92 92
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -81,7 +81,7 @@
 block discarded – undo
81 81
             'show_in_nav_menus' => false,
82 82
             'map_meta_cap'      => true
83 83
         );
84
-        if (! empty($override_args)) {
84
+        if ( ! empty($override_args)) {
85 85
             $args = array_merge_recursive($args, $override_args);
86 86
         }
87 87
         $result = register_taxonomy($taxonomy_name, null, $args);
Please login to merge, or discard this patch.
core/domain/entities/custom_post_types/CustomPostTypeDefinitions.php 2 patches
Indentation   +267 added lines, -267 removed lines patch added patch discarded remove patch
@@ -21,291 +21,291 @@
 block discarded – undo
21 21
 class CustomPostTypeDefinitions
22 22
 {
23 23
 
24
-    /**
25
-     * @var EE_Core_Config
26
-     */
27
-    public $core_config;
24
+	/**
25
+	 * @var EE_Core_Config
26
+	 */
27
+	public $core_config;
28 28
 
29
-    /**
30
-     * @var array $custom_post_types
31
-     */
32
-    private $custom_post_types;
29
+	/**
30
+	 * @var array $custom_post_types
31
+	 */
32
+	private $custom_post_types;
33 33
 
34
-    /**
35
-     * @var LoaderInterface $loader
36
-     */
37
-    private $loader;
34
+	/**
35
+	 * @var LoaderInterface $loader
36
+	 */
37
+	private $loader;
38 38
 
39 39
 
40
-    /**
41
-     * EspressoCustomPostTypeDefinitions constructor.
42
-     *
43
-     * @param EE_Core_Config  $core_config
44
-     * @param LoaderInterface $loader
45
-     */
46
-    public function __construct(EE_Core_Config $core_config, LoaderInterface $loader)
47
-    {
48
-        $this->core_config = $core_config;
49
-        $this->loader      = $loader;
50
-        $this->setDefinitions();
51
-    }
40
+	/**
41
+	 * EspressoCustomPostTypeDefinitions constructor.
42
+	 *
43
+	 * @param EE_Core_Config  $core_config
44
+	 * @param LoaderInterface $loader
45
+	 */
46
+	public function __construct(EE_Core_Config $core_config, LoaderInterface $loader)
47
+	{
48
+		$this->core_config = $core_config;
49
+		$this->loader      = $loader;
50
+		$this->setDefinitions();
51
+	}
52 52
 
53 53
 
54
-    /**
55
-     * defines Espresso Custom Post Types
56
-     * NOTE the ['args']['page_templates'] array index is something specific to our CPTs
57
-     * and not part of the WP custom post type api.
58
-     *
59
-     * @return void
60
-     */
61
-    private function setDefinitions()
62
-    {
63
-        $this->custom_post_types = array(
64
-            'espresso_events'    => array(
65
-                'singular_name' => esc_html__('Event', 'event_espresso'),
66
-                'plural_name'   => esc_html__('Events', 'event_espresso'),
67
-                'singular_slug' => esc_html__('event', 'event_espresso'),
68
-                'plural_slug'   => $this->core_config->event_cpt_slug,
69
-                'class_name'    => 'EE_Event',
70
-                'model_name'    => 'EEM_Event',
71
-                'args'          => array(
72
-                    'public'            => true,
73
-                    'show_in_nav_menus' => true,
74
-                    'capability_type'   => 'event',
75
-                    'capabilities'      => array(
76
-                        'edit_post'              => 'ee_edit_event',
77
-                        'read_post'              => 'ee_read_event',
78
-                        'delete_post'            => 'ee_delete_event',
79
-                        'edit_posts'             => 'ee_edit_events',
80
-                        'edit_others_posts'      => 'ee_edit_others_events',
81
-                        'publish_posts'          => 'ee_publish_events',
82
-                        'read_private_posts'     => 'ee_read_private_events',
83
-                        'delete_posts'           => 'ee_delete_events',
84
-                        'delete_private_posts'   => 'ee_delete_private_events',
85
-                        'delete_published_posts' => 'ee_delete_published_events',
86
-                        'delete_others_posts'    => 'ee_delete_others_events',
87
-                        'edit_private_posts'     => 'ee_edit_private_events',
88
-                        'edit_published_posts'   => 'ee_edit_published_events',
89
-                    ),
90
-                    'taxonomies'        => array(
91
-                        'espresso_event_categories',
92
-                        'espresso_event_type',
93
-                        'post_tag',
94
-                    ),
95
-                    'page_templates'    => true,
96
-                ),
97
-            ),
98
-            'espresso_venues'    => array(
99
-                'singular_name' => esc_html__('Venue', 'event_espresso'),
100
-                'plural_name'   => esc_html__('Venues', 'event_espresso'),
101
-                'singular_slug' => esc_html__('venue', 'event_espresso'),
102
-                'plural_slug'   => esc_html__('venues', 'event_espresso'),
103
-                'class_name'    => 'EE_Venue',
104
-                'model_name'    => 'EEM_Venue',
105
-                'args'          => array(
106
-                    'public'            => true,
107
-                    'show_in_nav_menus' => false, //by default this doesn't show for decaf,
108
-                    'capability_type'   => 'venue',
109
-                    'capabilities'      => array(
110
-                        'edit_post'              => 'ee_edit_venue',
111
-                        'read_post'              => 'ee_read_venue',
112
-                        'delete_post'            => 'ee_delete_venue',
113
-                        'edit_posts'             => 'ee_edit_venues',
114
-                        'edit_others_posts'      => 'ee_edit_others_venues',
115
-                        'publish_posts'          => 'ee_publish_venues',
116
-                        'read_private_posts'     => 'ee_read_private_venues',
117
-                        'delete_posts'           => 'ee_delete_venues',
118
-                        'delete_private_posts'   => 'ee_delete_private_venues',
119
-                        'delete_published_posts' => 'ee_delete_published_venues',
120
-                        'delete_others_posts'    => 'ee_edit_others_venues',
121
-                        'edit_private_posts'     => 'ee_edit_private_venues',
122
-                        'edit_published_posts'   => 'ee_edit_published_venues',
123
-                    ),
124
-                    'taxonomies'        => array(
125
-                        'espresso_venue_categories',
126
-                        'post_tag',
127
-                    ),
128
-                    'page_templates'    => true,
129
-                ),
130
-            ),
131
-            'espresso_attendees' => array(
132
-                'singular_name' => esc_html__('Contact', 'event_espresso'),
133
-                'plural_name'   => esc_html__('Contacts', 'event_espresso'),
134
-                'singular_slug' => esc_html__('contact', 'event_espresso'),
135
-                'plural_slug'   => esc_html__('contacts', 'event_espresso'),
136
-                'class_name'    => 'EE_Attendee',
137
-                'model_name'    => 'EEM_Attendee',
138
-                'args'          => array(
139
-                    'public'             => false,
140
-                    'publicly_queryable' => false,
141
-                    'hierarchical'       => false,
142
-                    'has_archive'        => false,
143
-                    'supports'           => array(
144
-                        'editor',
145
-                        'thumbnail',
146
-                        'excerpt',
147
-                        'custom-fields',
148
-                        'comments',
149
-                    ),
150
-                    'taxonomies'         => array('post_tag'),
151
-                    'capability_type'    => 'contact',
152
-                    'capabilities'       => array(
153
-                        'edit_post'              => 'ee_edit_contact',
154
-                        'read_post'              => 'ee_read_contact',
155
-                        'delete_post'            => 'ee_delete_contact',
156
-                        'edit_posts'             => 'ee_edit_contacts',
157
-                        'edit_others_posts'      => 'ee_edit_contacts',
158
-                        'publish_posts'          => 'ee_edit_contacts',
159
-                        'read_private_posts'     => 'ee_edit_contacts',
160
-                        'delete_posts'           => 'ee_delete_contacts',
161
-                        'delete_private_posts'   => 'ee_delete_contacts',
162
-                        'delete_published_posts' => 'ee_delete_contacts',
163
-                        'delete_others_posts'    => 'ee_delete_contacts',
164
-                        'edit_private_posts'     => 'ee_edit_contacts',
165
-                        'edit_published_posts'   => 'ee_edit_contacts',
166
-                    ),
167
-                ),
168
-            ),
169
-        );
170
-    }
54
+	/**
55
+	 * defines Espresso Custom Post Types
56
+	 * NOTE the ['args']['page_templates'] array index is something specific to our CPTs
57
+	 * and not part of the WP custom post type api.
58
+	 *
59
+	 * @return void
60
+	 */
61
+	private function setDefinitions()
62
+	{
63
+		$this->custom_post_types = array(
64
+			'espresso_events'    => array(
65
+				'singular_name' => esc_html__('Event', 'event_espresso'),
66
+				'plural_name'   => esc_html__('Events', 'event_espresso'),
67
+				'singular_slug' => esc_html__('event', 'event_espresso'),
68
+				'plural_slug'   => $this->core_config->event_cpt_slug,
69
+				'class_name'    => 'EE_Event',
70
+				'model_name'    => 'EEM_Event',
71
+				'args'          => array(
72
+					'public'            => true,
73
+					'show_in_nav_menus' => true,
74
+					'capability_type'   => 'event',
75
+					'capabilities'      => array(
76
+						'edit_post'              => 'ee_edit_event',
77
+						'read_post'              => 'ee_read_event',
78
+						'delete_post'            => 'ee_delete_event',
79
+						'edit_posts'             => 'ee_edit_events',
80
+						'edit_others_posts'      => 'ee_edit_others_events',
81
+						'publish_posts'          => 'ee_publish_events',
82
+						'read_private_posts'     => 'ee_read_private_events',
83
+						'delete_posts'           => 'ee_delete_events',
84
+						'delete_private_posts'   => 'ee_delete_private_events',
85
+						'delete_published_posts' => 'ee_delete_published_events',
86
+						'delete_others_posts'    => 'ee_delete_others_events',
87
+						'edit_private_posts'     => 'ee_edit_private_events',
88
+						'edit_published_posts'   => 'ee_edit_published_events',
89
+					),
90
+					'taxonomies'        => array(
91
+						'espresso_event_categories',
92
+						'espresso_event_type',
93
+						'post_tag',
94
+					),
95
+					'page_templates'    => true,
96
+				),
97
+			),
98
+			'espresso_venues'    => array(
99
+				'singular_name' => esc_html__('Venue', 'event_espresso'),
100
+				'plural_name'   => esc_html__('Venues', 'event_espresso'),
101
+				'singular_slug' => esc_html__('venue', 'event_espresso'),
102
+				'plural_slug'   => esc_html__('venues', 'event_espresso'),
103
+				'class_name'    => 'EE_Venue',
104
+				'model_name'    => 'EEM_Venue',
105
+				'args'          => array(
106
+					'public'            => true,
107
+					'show_in_nav_menus' => false, //by default this doesn't show for decaf,
108
+					'capability_type'   => 'venue',
109
+					'capabilities'      => array(
110
+						'edit_post'              => 'ee_edit_venue',
111
+						'read_post'              => 'ee_read_venue',
112
+						'delete_post'            => 'ee_delete_venue',
113
+						'edit_posts'             => 'ee_edit_venues',
114
+						'edit_others_posts'      => 'ee_edit_others_venues',
115
+						'publish_posts'          => 'ee_publish_venues',
116
+						'read_private_posts'     => 'ee_read_private_venues',
117
+						'delete_posts'           => 'ee_delete_venues',
118
+						'delete_private_posts'   => 'ee_delete_private_venues',
119
+						'delete_published_posts' => 'ee_delete_published_venues',
120
+						'delete_others_posts'    => 'ee_edit_others_venues',
121
+						'edit_private_posts'     => 'ee_edit_private_venues',
122
+						'edit_published_posts'   => 'ee_edit_published_venues',
123
+					),
124
+					'taxonomies'        => array(
125
+						'espresso_venue_categories',
126
+						'post_tag',
127
+					),
128
+					'page_templates'    => true,
129
+				),
130
+			),
131
+			'espresso_attendees' => array(
132
+				'singular_name' => esc_html__('Contact', 'event_espresso'),
133
+				'plural_name'   => esc_html__('Contacts', 'event_espresso'),
134
+				'singular_slug' => esc_html__('contact', 'event_espresso'),
135
+				'plural_slug'   => esc_html__('contacts', 'event_espresso'),
136
+				'class_name'    => 'EE_Attendee',
137
+				'model_name'    => 'EEM_Attendee',
138
+				'args'          => array(
139
+					'public'             => false,
140
+					'publicly_queryable' => false,
141
+					'hierarchical'       => false,
142
+					'has_archive'        => false,
143
+					'supports'           => array(
144
+						'editor',
145
+						'thumbnail',
146
+						'excerpt',
147
+						'custom-fields',
148
+						'comments',
149
+					),
150
+					'taxonomies'         => array('post_tag'),
151
+					'capability_type'    => 'contact',
152
+					'capabilities'       => array(
153
+						'edit_post'              => 'ee_edit_contact',
154
+						'read_post'              => 'ee_read_contact',
155
+						'delete_post'            => 'ee_delete_contact',
156
+						'edit_posts'             => 'ee_edit_contacts',
157
+						'edit_others_posts'      => 'ee_edit_contacts',
158
+						'publish_posts'          => 'ee_edit_contacts',
159
+						'read_private_posts'     => 'ee_edit_contacts',
160
+						'delete_posts'           => 'ee_delete_contacts',
161
+						'delete_private_posts'   => 'ee_delete_contacts',
162
+						'delete_published_posts' => 'ee_delete_contacts',
163
+						'delete_others_posts'    => 'ee_delete_contacts',
164
+						'edit_private_posts'     => 'ee_edit_contacts',
165
+						'edit_published_posts'   => 'ee_edit_contacts',
166
+					),
167
+				),
168
+			),
169
+		);
170
+	}
171 171
 
172 172
 
173
-    /**
174
-     * @return array
175
-     */
176
-    public function getDefinitions()
177
-    {
178
-        return (array) apply_filters(
179
-            'FHEE__EventEspresso_core_domain_entities_custom_post_types_CustomPostTypeDefinitions__getCustomPostTypes',
180
-            // legacy filter applied for now,
181
-            // later on we'll run a has_filter($tag) check and throw a doing_it_wrong() notice
182
-            apply_filters(
183
-                'FHEE__EE_Register_CPTs__get_CPTs__cpts',
184
-                $this->custom_post_types
185
-            )
186
-        );
187
-    }
173
+	/**
174
+	 * @return array
175
+	 */
176
+	public function getDefinitions()
177
+	{
178
+		return (array) apply_filters(
179
+			'FHEE__EventEspresso_core_domain_entities_custom_post_types_CustomPostTypeDefinitions__getCustomPostTypes',
180
+			// legacy filter applied for now,
181
+			// later on we'll run a has_filter($tag) check and throw a doing_it_wrong() notice
182
+			apply_filters(
183
+				'FHEE__EE_Register_CPTs__get_CPTs__cpts',
184
+				$this->custom_post_types
185
+			)
186
+		);
187
+	}
188 188
 
189 189
 
190
-    /**
191
-     * @return array
192
-     */
193
-    public function getCustomPostTypeSlugs()
194
-    {
195
-        return array_keys($this->getDefinitions());
196
-    }
190
+	/**
191
+	 * @return array
192
+	 */
193
+	public function getCustomPostTypeSlugs()
194
+	{
195
+		return array_keys($this->getDefinitions());
196
+	}
197 197
 
198 198
 
199
-    /**
200
-     * This basically goes through the CPT array and returns only CPT's
201
-     * that have the ['args']['public'] option set as false
202
-     *
203
-     * @return array
204
-     */
205
-    public function getPrivateCustomPostTypes()
206
-    {
207
-        $private_CPTs = array();
208
-        foreach ($this->getDefinitions() as $CPT => $details) {
209
-            if (empty($details['args']['public'])) {
210
-                $private_CPTs[ $CPT ] = $details;
211
-            }
212
-        }
213
-        return $private_CPTs;
214
-    }
199
+	/**
200
+	 * This basically goes through the CPT array and returns only CPT's
201
+	 * that have the ['args']['public'] option set as false
202
+	 *
203
+	 * @return array
204
+	 */
205
+	public function getPrivateCustomPostTypes()
206
+	{
207
+		$private_CPTs = array();
208
+		foreach ($this->getDefinitions() as $CPT => $details) {
209
+			if (empty($details['args']['public'])) {
210
+				$private_CPTs[ $CPT ] = $details;
211
+			}
212
+		}
213
+		return $private_CPTs;
214
+	}
215 215
 
216 216
 
217
-    /**
218
-     * This returns the corresponding model name for cpts registered by EE.
219
-     *
220
-     * @param string $post_type_slug    If a slug is included, then attempt to retrieve
221
-     *                                  the model name for the given cpt slug.
222
-     *                                  Otherwise if empty, then we'll return
223
-     *                                  all cpt model names for cpts registered in EE.
224
-     * @return array                    Empty array if no matching model names for the given slug
225
-     *                                  or an array of model names indexed by post type slug.
226
-     */
227
-    public function getCustomPostTypeModelNames($post_type_slug = '')
228
-    {
229
-        $cpts = $this->getDefinitions();
230
-        //first if slug passed in...
231
-        if (! empty($post_type_slug)) {
232
-            //match?
233
-            if (
234
-                ! isset($cpts[ $post_type_slug ])
235
-                || (
236
-                    isset($cpts[ $post_type_slug ])
237
-                    && (
238
-                        empty($cpts[ $post_type_slug ]['class_name'])
239
-                        && empty($cpts[ $post_type_slug ]['model_name'])
240
-                    )
241
-                )
242
-            ) {
243
-                return array();
244
-            }
245
-            // k let's get the model name for this cpt.
246
-            return $this->getCustomPostTypeModelName($post_type_slug, $cpts[ $post_type_slug ]);
247
-        }
248
-        //if we made it here then we're returning an array of cpt model names indexed by post_type_slug.
249
-        $cpt_models = array();
250
-        foreach ($cpts as $slug => $args) {
251
-            $model = $this->getCustomPostTypeModelName($post_type_slug, $cpts[ $post_type_slug ]);
252
-            if (! empty($model)) {
253
-                $cpt_models[ $slug ] = $model;
254
-            }
255
-        }
256
-        return $cpt_models;
257
-    }
217
+	/**
218
+	 * This returns the corresponding model name for cpts registered by EE.
219
+	 *
220
+	 * @param string $post_type_slug    If a slug is included, then attempt to retrieve
221
+	 *                                  the model name for the given cpt slug.
222
+	 *                                  Otherwise if empty, then we'll return
223
+	 *                                  all cpt model names for cpts registered in EE.
224
+	 * @return array                    Empty array if no matching model names for the given slug
225
+	 *                                  or an array of model names indexed by post type slug.
226
+	 */
227
+	public function getCustomPostTypeModelNames($post_type_slug = '')
228
+	{
229
+		$cpts = $this->getDefinitions();
230
+		//first if slug passed in...
231
+		if (! empty($post_type_slug)) {
232
+			//match?
233
+			if (
234
+				! isset($cpts[ $post_type_slug ])
235
+				|| (
236
+					isset($cpts[ $post_type_slug ])
237
+					&& (
238
+						empty($cpts[ $post_type_slug ]['class_name'])
239
+						&& empty($cpts[ $post_type_slug ]['model_name'])
240
+					)
241
+				)
242
+			) {
243
+				return array();
244
+			}
245
+			// k let's get the model name for this cpt.
246
+			return $this->getCustomPostTypeModelName($post_type_slug, $cpts[ $post_type_slug ]);
247
+		}
248
+		//if we made it here then we're returning an array of cpt model names indexed by post_type_slug.
249
+		$cpt_models = array();
250
+		foreach ($cpts as $slug => $args) {
251
+			$model = $this->getCustomPostTypeModelName($post_type_slug, $cpts[ $post_type_slug ]);
252
+			if (! empty($model)) {
253
+				$cpt_models[ $slug ] = $model;
254
+			}
255
+		}
256
+		return $cpt_models;
257
+	}
258 258
 
259 259
 
260
-    /**
261
-     * @param       $post_type_slug
262
-     * @param array $cpt
263
-     * @return array
264
-     */
265
-    private function getCustomPostTypeModelName($post_type_slug, array $cpt)
266
-    {
267
-        if(! empty($cpt['model_name'])) {
268
-            return array($post_type_slug => $cpt['model_name']);
269
-        }
270
-        if (! empty($cpt['class_name'])) {
271
-            return array(
272
-                $post_type_slug => $this->deriveCptModelNameFromClassName($cpt['class_name'])
273
-            );
274
-        }
275
-        return array();
276
-    }
260
+	/**
261
+	 * @param       $post_type_slug
262
+	 * @param array $cpt
263
+	 * @return array
264
+	 */
265
+	private function getCustomPostTypeModelName($post_type_slug, array $cpt)
266
+	{
267
+		if(! empty($cpt['model_name'])) {
268
+			return array($post_type_slug => $cpt['model_name']);
269
+		}
270
+		if (! empty($cpt['class_name'])) {
271
+			return array(
272
+				$post_type_slug => $this->deriveCptModelNameFromClassName($cpt['class_name'])
273
+			);
274
+		}
275
+		return array();
276
+	}
277 277
 
278 278
 
279
-    /**
280
-     * @param string $class_name
281
-     * @return string
282
-     */
283
-    private function deriveCptModelNameFromClassName($class_name)
284
-    {
285
-        return str_replace('EE', 'EEM', $class_name);
286
-    }
279
+	/**
280
+	 * @param string $class_name
281
+	 * @return string
282
+	 */
283
+	private function deriveCptModelNameFromClassName($class_name)
284
+	{
285
+		return str_replace('EE', 'EEM', $class_name);
286
+	}
287 287
 
288 288
 
289
-    /**
290
-     * This instantiates cpt models related to the cpts registered via EE.
291
-     *
292
-     * @since 4.6.16.rc.000
293
-     * @param string $post_type_slug If valid slug is provided, then will instantiate the model only for
294
-     *                               the cpt matching the given slug.  Otherwise all cpt models will be
295
-     *                               instantiated (if possible).
296
-     * @return EEM_CPT_Base[]        successful instantiation will return an array of successfully instantiated
297
-     *                               EEM models indexed by post slug.
298
-     */
299
-    public function getCustomPostTypeModels($post_type_slug = '')
300
-    {
301
-        $cpt_model_names = $this->getCustomPostTypeModelNames($post_type_slug);
302
-        $instantiated    = array();
303
-        foreach ($cpt_model_names as $slug => $model_name) {
304
-            $model = $this->loader->getShared($model_name);
305
-            if ($model instanceof EEM_CPT_Base) {
306
-                $instantiated[ $slug ] = $model;
307
-            }
308
-        }
309
-        return $instantiated;
310
-    }
289
+	/**
290
+	 * This instantiates cpt models related to the cpts registered via EE.
291
+	 *
292
+	 * @since 4.6.16.rc.000
293
+	 * @param string $post_type_slug If valid slug is provided, then will instantiate the model only for
294
+	 *                               the cpt matching the given slug.  Otherwise all cpt models will be
295
+	 *                               instantiated (if possible).
296
+	 * @return EEM_CPT_Base[]        successful instantiation will return an array of successfully instantiated
297
+	 *                               EEM models indexed by post slug.
298
+	 */
299
+	public function getCustomPostTypeModels($post_type_slug = '')
300
+	{
301
+		$cpt_model_names = $this->getCustomPostTypeModelNames($post_type_slug);
302
+		$instantiated    = array();
303
+		foreach ($cpt_model_names as $slug => $model_name) {
304
+			$model = $this->loader->getShared($model_name);
305
+			if ($model instanceof EEM_CPT_Base) {
306
+				$instantiated[ $slug ] = $model;
307
+			}
308
+		}
309
+		return $instantiated;
310
+	}
311 311
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
         $private_CPTs = array();
208 208
         foreach ($this->getDefinitions() as $CPT => $details) {
209 209
             if (empty($details['args']['public'])) {
210
-                $private_CPTs[ $CPT ] = $details;
210
+                $private_CPTs[$CPT] = $details;
211 211
             }
212 212
         }
213 213
         return $private_CPTs;
@@ -228,29 +228,29 @@  discard block
 block discarded – undo
228 228
     {
229 229
         $cpts = $this->getDefinitions();
230 230
         //first if slug passed in...
231
-        if (! empty($post_type_slug)) {
231
+        if ( ! empty($post_type_slug)) {
232 232
             //match?
233 233
             if (
234
-                ! isset($cpts[ $post_type_slug ])
234
+                ! isset($cpts[$post_type_slug])
235 235
                 || (
236
-                    isset($cpts[ $post_type_slug ])
236
+                    isset($cpts[$post_type_slug])
237 237
                     && (
238
-                        empty($cpts[ $post_type_slug ]['class_name'])
239
-                        && empty($cpts[ $post_type_slug ]['model_name'])
238
+                        empty($cpts[$post_type_slug]['class_name'])
239
+                        && empty($cpts[$post_type_slug]['model_name'])
240 240
                     )
241 241
                 )
242 242
             ) {
243 243
                 return array();
244 244
             }
245 245
             // k let's get the model name for this cpt.
246
-            return $this->getCustomPostTypeModelName($post_type_slug, $cpts[ $post_type_slug ]);
246
+            return $this->getCustomPostTypeModelName($post_type_slug, $cpts[$post_type_slug]);
247 247
         }
248 248
         //if we made it here then we're returning an array of cpt model names indexed by post_type_slug.
249 249
         $cpt_models = array();
250 250
         foreach ($cpts as $slug => $args) {
251
-            $model = $this->getCustomPostTypeModelName($post_type_slug, $cpts[ $post_type_slug ]);
252
-            if (! empty($model)) {
253
-                $cpt_models[ $slug ] = $model;
251
+            $model = $this->getCustomPostTypeModelName($post_type_slug, $cpts[$post_type_slug]);
252
+            if ( ! empty($model)) {
253
+                $cpt_models[$slug] = $model;
254 254
             }
255 255
         }
256 256
         return $cpt_models;
@@ -264,10 +264,10 @@  discard block
 block discarded – undo
264 264
      */
265 265
     private function getCustomPostTypeModelName($post_type_slug, array $cpt)
266 266
     {
267
-        if(! empty($cpt['model_name'])) {
267
+        if ( ! empty($cpt['model_name'])) {
268 268
             return array($post_type_slug => $cpt['model_name']);
269 269
         }
270
-        if (! empty($cpt['class_name'])) {
270
+        if ( ! empty($cpt['class_name'])) {
271 271
             return array(
272 272
                 $post_type_slug => $this->deriveCptModelNameFromClassName($cpt['class_name'])
273 273
             );
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
         foreach ($cpt_model_names as $slug => $model_name) {
304 304
             $model = $this->loader->getShared($model_name);
305 305
             if ($model instanceof EEM_CPT_Base) {
306
-                $instantiated[ $slug ] = $model;
306
+                $instantiated[$slug] = $model;
307 307
             }
308 308
         }
309 309
         return $instantiated;
Please login to merge, or discard this patch.
core/domain/entities/custom_post_types/CustomTaxonomyTerm.php 1 patch
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -17,60 +17,60 @@
 block discarded – undo
17 17
 class CustomTaxonomyTerm
18 18
 {
19 19
 
20
-    /**
21
-     * @var string $taxonomy_slug
22
-     */
23
-    public $taxonomy_slug;
24
-
25
-    /**
26
-     * @var string $term_slug
27
-     */
28
-    public $term_slug;
29
-
30
-    /**
31
-     * @var array $custom_post_type_slugs
32
-     */
33
-    public $custom_post_type_slugs;
34
-
35
-
36
-    /**
37
-     * CustomTaxonomyTerm constructor.
38
-     *
39
-     * @param string $taxonomy_slug
40
-     * @param string $term_slug
41
-     * @param array  $custom_post_type_slugs
42
-     */
43
-    public function __construct($taxonomy_slug, $term_slug, array $custom_post_type_slugs = array())
44
-    {
45
-        $this->taxonomy_slug          = $taxonomy_slug;
46
-        $this->term_slug              = $term_slug;
47
-        $this->custom_post_type_slugs = $custom_post_type_slugs;
48
-    }
49
-
50
-
51
-    /**
52
-     * @return string
53
-     */
54
-    public function taxonomySlug()
55
-    {
56
-        return $this->taxonomy_slug;
57
-    }
58
-
59
-
60
-    /**
61
-     * @return string
62
-     */
63
-    public function termSlug()
64
-    {
65
-        return $this->term_slug;
66
-    }
67
-
68
-
69
-    /**
70
-     * @return array
71
-     */
72
-    public function customPostTypeSlugs()
73
-    {
74
-        return $this->custom_post_type_slugs;
75
-    }
20
+	/**
21
+	 * @var string $taxonomy_slug
22
+	 */
23
+	public $taxonomy_slug;
24
+
25
+	/**
26
+	 * @var string $term_slug
27
+	 */
28
+	public $term_slug;
29
+
30
+	/**
31
+	 * @var array $custom_post_type_slugs
32
+	 */
33
+	public $custom_post_type_slugs;
34
+
35
+
36
+	/**
37
+	 * CustomTaxonomyTerm constructor.
38
+	 *
39
+	 * @param string $taxonomy_slug
40
+	 * @param string $term_slug
41
+	 * @param array  $custom_post_type_slugs
42
+	 */
43
+	public function __construct($taxonomy_slug, $term_slug, array $custom_post_type_slugs = array())
44
+	{
45
+		$this->taxonomy_slug          = $taxonomy_slug;
46
+		$this->term_slug              = $term_slug;
47
+		$this->custom_post_type_slugs = $custom_post_type_slugs;
48
+	}
49
+
50
+
51
+	/**
52
+	 * @return string
53
+	 */
54
+	public function taxonomySlug()
55
+	{
56
+		return $this->taxonomy_slug;
57
+	}
58
+
59
+
60
+	/**
61
+	 * @return string
62
+	 */
63
+	public function termSlug()
64
+	{
65
+		return $this->term_slug;
66
+	}
67
+
68
+
69
+	/**
70
+	 * @return array
71
+	 */
72
+	public function customPostTypeSlugs()
73
+	{
74
+		return $this->custom_post_type_slugs;
75
+	}
76 76
 }
Please login to merge, or discard this patch.
core/domain/entities/custom_post_types/CustomTaxonomyDefinitions.php 1 patch
Indentation   +126 added lines, -126 removed lines patch added patch discarded remove patch
@@ -17,130 +17,130 @@
 block discarded – undo
17 17
 class CustomTaxonomyDefinitions
18 18
 {
19 19
 
20
-    /**
21
-     * @var array $taxonomies
22
-     */
23
-    private $taxonomies;
24
-
25
-
26
-    /**
27
-     * EspressoCustomPostTypeDefinitions constructor.
28
-     */
29
-    public function __construct()
30
-    {
31
-        $this->setTaxonomies();
32
-        add_filter('pre_term_description', array($this, 'filterCustomTermDescription'), 1, 2);
33
-    }
34
-
35
-
36
-    private function setTaxonomies()
37
-    {
38
-        $this->taxonomies = array(
39
-            'espresso_event_categories' => array(
40
-                'singular_name' => esc_html__('Event Category', 'event_espresso'),
41
-                'plural_name'   => esc_html__('Event Categories', 'event_espresso'),
42
-                'args'          => array(
43
-                    'public'            => true,
44
-                    'show_in_nav_menus' => true,
45
-                    'show_in_rest'      => true,
46
-                    'capabilities'      => array(
47
-                        'manage_terms' => 'ee_manage_event_categories',
48
-                        'edit_terms'   => 'ee_edit_event_category',
49
-                        'delete_terms' => 'ee_delete_event_category',
50
-                        'assign_terms' => 'ee_assign_event_category',
51
-                    ),
52
-                    'rewrite'           => array('slug' => esc_html__('event-category', 'event_espresso')),
53
-                ),
54
-            ),
55
-            'espresso_venue_categories' => array(
56
-                'singular_name' => esc_html__('Venue Category', 'event_espresso'),
57
-                'plural_name'   => esc_html__('Venue Categories', 'event_espresso'),
58
-                'args'          => array(
59
-                    'public'            => true,
60
-                    'show_in_nav_menus' => false, //by default this doesn't show for decaf
61
-                    'show_in_rest'      => true,
62
-                    'capabilities'      => array(
63
-                        'manage_terms' => 'ee_manage_venue_categories',
64
-                        'edit_terms'   => 'ee_edit_venue_category',
65
-                        'delete_terms' => 'ee_delete_venue_category',
66
-                        'assign_terms' => 'ee_assign_venue_category',
67
-                    ),
68
-                    'rewrite'           => array('slug' => esc_html__('venue-category', 'event_espresso')),
69
-                ),
70
-            ),
71
-            'espresso_event_type'       => array(
72
-                'singular_name' => esc_html__('Event Type', 'event_espresso'),
73
-                'plural_name'   => esc_html__('Event Types', 'event_espresso'),
74
-                'args'          => array(
75
-                    'public'       => true,
76
-                    'show_ui'      => false,
77
-                    'show_in_rest' => true,
78
-                    'capabilities' => array(
79
-                        'manage_terms' => 'ee_read_event_type',
80
-                        'edit_terms'   => 'ee_edit_event_type',
81
-                        'delete_terms' => 'ee_delete_event_type',
82
-                        'assign_terms' => 'ee_assign_event_type',
83
-                    ),
84
-                    'rewrite'      => array('slug' => esc_html__('event-type', 'event_espresso')),
85
-                    'hierarchical' => true,
86
-                ),
87
-            ),
88
-        );
89
-    }
90
-
91
-
92
-    /**
93
-     * @return array
94
-     */
95
-    public function getCustomTaxonomyDefinitions()
96
-    {
97
-        return (array) apply_filters(
98
-            'FHEE__EventEspresso_core_domain_entities_custom_post_types_TaxonomyDefinitions__getTaxonomies',
99
-            // legacy filter applied for now,
100
-            // later on we'll run a has_filter($tag) check and throw a doing_it_wrong() notice
101
-            apply_filters(
102
-                'FHEE__EE_Register_CPTs__get_taxonomies__taxonomies',
103
-                $this->taxonomies
104
-            )
105
-        );
106
-    }
107
-
108
-
109
-    /**
110
-     * @return array
111
-     */
112
-    public function getCustomTaxonomySlugs()
113
-    {
114
-        return array_keys($this->getCustomTaxonomyDefinitions());
115
-    }
116
-
117
-
118
-    /**
119
-     * By default, WordPress strips all html from term taxonomy description content.
120
-     * The purpose of this method is to remove that restriction
121
-     * and ensure that we still run ee term taxonomy descriptions
122
-     * through some full html sanitization equivalent to the post content field.
123
-     * So first we remove default filter for term description
124
-     * but we have to do this earlier before wp sets their own filter
125
-     * because they just set a global filter on all term descriptions
126
-     * before the custom term description filter.
127
-     * Really sux.
128
-     *
129
-     * @param string $description The description content.
130
-     * @param string $taxonomy    The taxonomy name for the taxonomy being filtered.
131
-     * @return string
132
-     */
133
-    public function filterCustomTermDescription($description, $taxonomy)
134
-    {
135
-        //get a list of EE taxonomies
136
-        $custom_taxonomies = $this->getCustomTaxonomySlugs();
137
-        //only do our own thing if the taxonomy listed is an ee taxonomy.
138
-        if (in_array($taxonomy, $custom_taxonomies, true)) {
139
-            //remove default wp filter
140
-            remove_filter('pre_term_description', 'wp_filter_kses');
141
-            //sanitize THIS content.
142
-            $description = wp_kses($description, wp_kses_allowed_html('post'));
143
-        }
144
-        return $description;
145
-    }
20
+	/**
21
+	 * @var array $taxonomies
22
+	 */
23
+	private $taxonomies;
24
+
25
+
26
+	/**
27
+	 * EspressoCustomPostTypeDefinitions constructor.
28
+	 */
29
+	public function __construct()
30
+	{
31
+		$this->setTaxonomies();
32
+		add_filter('pre_term_description', array($this, 'filterCustomTermDescription'), 1, 2);
33
+	}
34
+
35
+
36
+	private function setTaxonomies()
37
+	{
38
+		$this->taxonomies = array(
39
+			'espresso_event_categories' => array(
40
+				'singular_name' => esc_html__('Event Category', 'event_espresso'),
41
+				'plural_name'   => esc_html__('Event Categories', 'event_espresso'),
42
+				'args'          => array(
43
+					'public'            => true,
44
+					'show_in_nav_menus' => true,
45
+					'show_in_rest'      => true,
46
+					'capabilities'      => array(
47
+						'manage_terms' => 'ee_manage_event_categories',
48
+						'edit_terms'   => 'ee_edit_event_category',
49
+						'delete_terms' => 'ee_delete_event_category',
50
+						'assign_terms' => 'ee_assign_event_category',
51
+					),
52
+					'rewrite'           => array('slug' => esc_html__('event-category', 'event_espresso')),
53
+				),
54
+			),
55
+			'espresso_venue_categories' => array(
56
+				'singular_name' => esc_html__('Venue Category', 'event_espresso'),
57
+				'plural_name'   => esc_html__('Venue Categories', 'event_espresso'),
58
+				'args'          => array(
59
+					'public'            => true,
60
+					'show_in_nav_menus' => false, //by default this doesn't show for decaf
61
+					'show_in_rest'      => true,
62
+					'capabilities'      => array(
63
+						'manage_terms' => 'ee_manage_venue_categories',
64
+						'edit_terms'   => 'ee_edit_venue_category',
65
+						'delete_terms' => 'ee_delete_venue_category',
66
+						'assign_terms' => 'ee_assign_venue_category',
67
+					),
68
+					'rewrite'           => array('slug' => esc_html__('venue-category', 'event_espresso')),
69
+				),
70
+			),
71
+			'espresso_event_type'       => array(
72
+				'singular_name' => esc_html__('Event Type', 'event_espresso'),
73
+				'plural_name'   => esc_html__('Event Types', 'event_espresso'),
74
+				'args'          => array(
75
+					'public'       => true,
76
+					'show_ui'      => false,
77
+					'show_in_rest' => true,
78
+					'capabilities' => array(
79
+						'manage_terms' => 'ee_read_event_type',
80
+						'edit_terms'   => 'ee_edit_event_type',
81
+						'delete_terms' => 'ee_delete_event_type',
82
+						'assign_terms' => 'ee_assign_event_type',
83
+					),
84
+					'rewrite'      => array('slug' => esc_html__('event-type', 'event_espresso')),
85
+					'hierarchical' => true,
86
+				),
87
+			),
88
+		);
89
+	}
90
+
91
+
92
+	/**
93
+	 * @return array
94
+	 */
95
+	public function getCustomTaxonomyDefinitions()
96
+	{
97
+		return (array) apply_filters(
98
+			'FHEE__EventEspresso_core_domain_entities_custom_post_types_TaxonomyDefinitions__getTaxonomies',
99
+			// legacy filter applied for now,
100
+			// later on we'll run a has_filter($tag) check and throw a doing_it_wrong() notice
101
+			apply_filters(
102
+				'FHEE__EE_Register_CPTs__get_taxonomies__taxonomies',
103
+				$this->taxonomies
104
+			)
105
+		);
106
+	}
107
+
108
+
109
+	/**
110
+	 * @return array
111
+	 */
112
+	public function getCustomTaxonomySlugs()
113
+	{
114
+		return array_keys($this->getCustomTaxonomyDefinitions());
115
+	}
116
+
117
+
118
+	/**
119
+	 * By default, WordPress strips all html from term taxonomy description content.
120
+	 * The purpose of this method is to remove that restriction
121
+	 * and ensure that we still run ee term taxonomy descriptions
122
+	 * through some full html sanitization equivalent to the post content field.
123
+	 * So first we remove default filter for term description
124
+	 * but we have to do this earlier before wp sets their own filter
125
+	 * because they just set a global filter on all term descriptions
126
+	 * before the custom term description filter.
127
+	 * Really sux.
128
+	 *
129
+	 * @param string $description The description content.
130
+	 * @param string $taxonomy    The taxonomy name for the taxonomy being filtered.
131
+	 * @return string
132
+	 */
133
+	public function filterCustomTermDescription($description, $taxonomy)
134
+	{
135
+		//get a list of EE taxonomies
136
+		$custom_taxonomies = $this->getCustomTaxonomySlugs();
137
+		//only do our own thing if the taxonomy listed is an ee taxonomy.
138
+		if (in_array($taxonomy, $custom_taxonomies, true)) {
139
+			//remove default wp filter
140
+			remove_filter('pre_term_description', 'wp_filter_kses');
141
+			//sanitize THIS content.
142
+			$description = wp_kses($description, wp_kses_allowed_html('post'));
143
+		}
144
+		return $description;
145
+	}
146 146
 }
Please login to merge, or discard this patch.
caffeinated/admin/extend/events/Extend_Events_Admin_Page.core.php 2 patches
Indentation   +1268 added lines, -1268 removed lines patch added patch discarded remove patch
@@ -19,1272 +19,1272 @@
 block discarded – undo
19 19
 {
20 20
 
21 21
 
22
-    /**
23
-     * Extend_Events_Admin_Page constructor.
24
-     *
25
-     * @param bool $routing
26
-     */
27
-    public function __construct($routing = true)
28
-    {
29
-        parent::__construct($routing);
30
-        if (! defined('EVENTS_CAF_TEMPLATE_PATH')) {
31
-            define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/');
32
-            define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/');
33
-            define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/');
34
-        }
35
-    }
36
-
37
-
38
-    /**
39
-     * Sets routes.
40
-     */
41
-    protected function _extend_page_config()
42
-    {
43
-        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events';
44
-        //is there a evt_id in the request?
45
-        $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID'])
46
-            ? $this->_req_data['EVT_ID']
47
-            : 0;
48
-        $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id;
49
-        //tkt_id?
50
-        $tkt_id             = ! empty($this->_req_data['TKT_ID']) && ! is_array($this->_req_data['TKT_ID'])
51
-            ? $this->_req_data['TKT_ID']
52
-            : 0;
53
-        $new_page_routes    = array(
54
-            'duplicate_event'          => array(
55
-                'func'       => '_duplicate_event',
56
-                'capability' => 'ee_edit_event',
57
-                'obj_id'     => $evt_id,
58
-                'noheader'   => true,
59
-            ),
60
-            'ticket_list_table'        => array(
61
-                'func'       => '_tickets_overview_list_table',
62
-                'capability' => 'ee_read_default_tickets',
63
-            ),
64
-            'trash_ticket'             => array(
65
-                'func'       => '_trash_or_restore_ticket',
66
-                'capability' => 'ee_delete_default_ticket',
67
-                'obj_id'     => $tkt_id,
68
-                'noheader'   => true,
69
-                'args'       => array('trash' => true),
70
-            ),
71
-            'trash_tickets'            => array(
72
-                'func'       => '_trash_or_restore_ticket',
73
-                'capability' => 'ee_delete_default_tickets',
74
-                'noheader'   => true,
75
-                'args'       => array('trash' => true),
76
-            ),
77
-            'restore_ticket'           => array(
78
-                'func'       => '_trash_or_restore_ticket',
79
-                'capability' => 'ee_delete_default_ticket',
80
-                'obj_id'     => $tkt_id,
81
-                'noheader'   => true,
82
-            ),
83
-            'restore_tickets'          => array(
84
-                'func'       => '_trash_or_restore_ticket',
85
-                'capability' => 'ee_delete_default_tickets',
86
-                'noheader'   => true,
87
-            ),
88
-            'delete_ticket'            => array(
89
-                'func'       => '_delete_ticket',
90
-                'capability' => 'ee_delete_default_ticket',
91
-                'obj_id'     => $tkt_id,
92
-                'noheader'   => true,
93
-            ),
94
-            'delete_tickets'           => array(
95
-                'func'       => '_delete_ticket',
96
-                'capability' => 'ee_delete_default_tickets',
97
-                'noheader'   => true,
98
-            ),
99
-            'import_page'              => array(
100
-                'func'       => '_import_page',
101
-                'capability' => 'import',
102
-            ),
103
-            'import'                   => array(
104
-                'func'       => '_import_events',
105
-                'capability' => 'import',
106
-                'noheader'   => true,
107
-            ),
108
-            'import_events'            => array(
109
-                'func'       => '_import_events',
110
-                'capability' => 'import',
111
-                'noheader'   => true,
112
-            ),
113
-            'export_events'            => array(
114
-                'func'       => '_events_export',
115
-                'capability' => 'export',
116
-                'noheader'   => true,
117
-            ),
118
-            'export_categories'        => array(
119
-                'func'       => '_categories_export',
120
-                'capability' => 'export',
121
-                'noheader'   => true,
122
-            ),
123
-            'sample_export_file'       => array(
124
-                'func'       => '_sample_export_file',
125
-                'capability' => 'export',
126
-                'noheader'   => true,
127
-            ),
128
-            'update_template_settings' => array(
129
-                'func'       => '_update_template_settings',
130
-                'capability' => 'manage_options',
131
-                'noheader'   => true,
132
-            ),
133
-        );
134
-        $this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
135
-        //partial route/config override
136
-        $this->_page_config['import_events']['metaboxes'] = $this->_default_espresso_metaboxes;
137
-        $this->_page_config['create_new']['metaboxes'][]  = '_premium_event_editor_meta_boxes';
138
-        $this->_page_config['create_new']['qtips'][]      = 'EE_Event_Editor_Tips';
139
-        $this->_page_config['edit']['qtips'][]            = 'EE_Event_Editor_Tips';
140
-        $this->_page_config['edit']['metaboxes'][]        = '_premium_event_editor_meta_boxes';
141
-        $this->_page_config['default']['list_table']      = 'Extend_Events_Admin_List_Table';
142
-        //add tickets tab but only if there are more than one default ticket!
143
-        $tkt_count = EEM_Ticket::instance()->count_deleted_and_undeleted(
144
-            array(array('TKT_is_default' => 1)),
145
-            'TKT_ID',
146
-            true
147
-        );
148
-        if ($tkt_count > 1) {
149
-            $new_page_config = array(
150
-                'ticket_list_table' => array(
151
-                    'nav'           => array(
152
-                        'label' => esc_html__('Default Tickets', 'event_espresso'),
153
-                        'order' => 60,
154
-                    ),
155
-                    'list_table'    => 'Tickets_List_Table',
156
-                    'require_nonce' => false,
157
-                ),
158
-            );
159
-        }
160
-        //template settings
161
-        $new_page_config['template_settings'] = array(
162
-            'nav'           => array(
163
-                'label' => esc_html__('Templates', 'event_espresso'),
164
-                'order' => 30,
165
-            ),
166
-            'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
167
-            'help_tabs'     => array(
168
-                'general_settings_templates_help_tab' => array(
169
-                    'title'    => esc_html__('Templates', 'event_espresso'),
170
-                    'filename' => 'general_settings_templates',
171
-                ),
172
-            ),
173
-            'help_tour'     => array('Templates_Help_Tour'),
174
-            'require_nonce' => false,
175
-        );
176
-        $this->_page_config                   = array_merge($this->_page_config, $new_page_config);
177
-        //add filters and actions
178
-        //modifying _views
179
-        add_filter(
180
-            'FHEE_event_datetime_metabox_add_additional_date_time_template',
181
-            array($this, 'add_additional_datetime_button'),
182
-            10,
183
-            2
184
-        );
185
-        add_filter(
186
-            'FHEE_event_datetime_metabox_clone_button_template',
187
-            array($this, 'add_datetime_clone_button'),
188
-            10,
189
-            2
190
-        );
191
-        add_filter(
192
-            'FHEE_event_datetime_metabox_timezones_template',
193
-            array($this, 'datetime_timezones_template'),
194
-            10,
195
-            2
196
-        );
197
-        //filters for event list table
198
-        add_filter('FHEE__Extend_Events_Admin_List_Table__filters', array($this, 'list_table_filters'), 10, 2);
199
-        add_filter(
200
-            'FHEE__Events_Admin_List_Table__column_actions__action_links',
201
-            array($this, 'extra_list_table_actions'),
202
-            10,
203
-            2
204
-        );
205
-        //legend item
206
-        add_filter('FHEE__Events_Admin_Page___event_legend_items__items', array($this, 'additional_legend_items'));
207
-        add_action('admin_init', array($this, 'admin_init'));
208
-        //heartbeat stuff
209
-        add_filter('heartbeat_received', array($this, 'heartbeat_response'), 10, 2);
210
-    }
211
-
212
-
213
-    /**
214
-     * admin_init
215
-     */
216
-    public function admin_init()
217
-    {
218
-        EE_Registry::$i18n_js_strings = array_merge(
219
-            EE_Registry::$i18n_js_strings,
220
-            array(
221
-                'image_confirm'          => esc_html__(
222
-                    'Do you really want to delete this image? Please remember to update your event to complete the removal.',
223
-                    'event_espresso'
224
-                ),
225
-                'event_starts_on'        => esc_html__('Event Starts on', 'event_espresso'),
226
-                'event_ends_on'          => esc_html__('Event Ends on', 'event_espresso'),
227
-                'event_datetime_actions' => esc_html__('Actions', 'event_espresso'),
228
-                'event_clone_dt_msg'     => esc_html__('Clone this Event Date and Time', 'event_espresso'),
229
-                'remove_event_dt_msg'    => esc_html__('Remove this Event Time', 'event_espresso'),
230
-            )
231
-        );
232
-    }
233
-
234
-
235
-    /**
236
-     * This will be used to listen for any heartbeat data packages coming via the WordPress heartbeat API and handle
237
-     * accordingly.
238
-     *
239
-     * @param array $response The existing heartbeat response array.
240
-     * @param array $data     The incoming data package.
241
-     * @return array  possibly appended response.
242
-     */
243
-    public function heartbeat_response($response, $data)
244
-    {
245
-        /**
246
-         * check whether count of tickets is approaching the potential
247
-         * limits for the server.
248
-         */
249
-        if (! empty($data['input_count'])) {
250
-            $response['max_input_vars_check'] = EE_Registry::instance()->CFG->environment->max_input_vars_limit_check(
251
-                $data['input_count']
252
-            );
253
-        }
254
-        return $response;
255
-    }
256
-
257
-
258
-    /**
259
-     * Add per page screen options to the default ticket list table view.
260
-     */
261
-    protected function _add_screen_options_ticket_list_table()
262
-    {
263
-        $this->_per_page_screen_option();
264
-    }
265
-
266
-
267
-    /**
268
-     * @param string $return
269
-     * @param int    $id
270
-     * @param string $new_title
271
-     * @param string $new_slug
272
-     * @return string
273
-     */
274
-    public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug)
275
-    {
276
-        $return = parent::extra_permalink_field_buttons($return, $id, $new_title, $new_slug);
277
-        //make sure this is only when editing
278
-        if (! empty($id)) {
279
-            $href   = EE_Admin_Page::add_query_args_and_nonce(
280
-                array('action' => 'duplicate_event', 'EVT_ID' => $id),
281
-                $this->_admin_base_url
282
-            );
283
-            $title  = esc_attr__('Duplicate Event', 'event_espresso');
284
-            $return .= '<a href="'
285
-                       . $href
286
-                       . '" title="'
287
-                       . $title
288
-                       . '" id="ee-duplicate-event-button" class="button button-small"  value="duplicate_event">'
289
-                       . $title
290
-                       . '</a>';
291
-        }
292
-        return $return;
293
-    }
294
-
295
-
296
-    /**
297
-     * Set the list table views for the default ticket list table view.
298
-     */
299
-    public function _set_list_table_views_ticket_list_table()
300
-    {
301
-        $this->_views = array(
302
-            'all'     => array(
303
-                'slug'        => 'all',
304
-                'label'       => esc_html__('All', 'event_espresso'),
305
-                'count'       => 0,
306
-                'bulk_action' => array(
307
-                    'trash_tickets' => esc_html__('Move to Trash', 'event_espresso'),
308
-                ),
309
-            ),
310
-            'trashed' => array(
311
-                'slug'        => 'trashed',
312
-                'label'       => esc_html__('Trash', 'event_espresso'),
313
-                'count'       => 0,
314
-                'bulk_action' => array(
315
-                    'restore_tickets' => esc_html__('Restore from Trash', 'event_espresso'),
316
-                    'delete_tickets'  => esc_html__('Delete Permanently', 'event_espresso'),
317
-                ),
318
-            ),
319
-        );
320
-    }
321
-
322
-
323
-    /**
324
-     * Enqueue scripts and styles for the event editor.
325
-     */
326
-    public function load_scripts_styles_edit()
327
-    {
328
-        wp_register_script(
329
-            'ee-event-editor-heartbeat',
330
-            EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js',
331
-            array('ee_admin_js', 'heartbeat'),
332
-            EVENT_ESPRESSO_VERSION,
333
-            true
334
-        );
335
-        wp_enqueue_script('ee-accounting');
336
-        //styles
337
-        wp_enqueue_style('espresso-ui-theme');
338
-        wp_enqueue_script('event_editor_js');
339
-        wp_enqueue_script('ee-event-editor-heartbeat');
340
-    }
341
-
342
-
343
-    /**
344
-     * Returns template for the additional datetime.
345
-     * @param $template
346
-     * @param $template_args
347
-     * @return mixed
348
-     * @throws DomainException
349
-     */
350
-    public function add_additional_datetime_button($template, $template_args)
351
-    {
352
-        return EEH_Template::display_template(
353
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_add_additional_time.template.php',
354
-            $template_args,
355
-            true
356
-        );
357
-    }
358
-
359
-
360
-    /**
361
-     * Returns the template for cloning a datetime.
362
-     * @param $template
363
-     * @param $template_args
364
-     * @return mixed
365
-     * @throws DomainException
366
-     */
367
-    public function add_datetime_clone_button($template, $template_args)
368
-    {
369
-        return EEH_Template::display_template(
370
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_metabox_clone_button.template.php',
371
-            $template_args,
372
-            true
373
-        );
374
-    }
375
-
376
-
377
-    /**
378
-     * Returns the template for datetime timezones.
379
-     * @param $template
380
-     * @param $template_args
381
-     * @return mixed
382
-     * @throws DomainException
383
-     */
384
-    public function datetime_timezones_template($template, $template_args)
385
-    {
386
-        return EEH_Template::display_template(
387
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_timezones.template.php',
388
-            $template_args,
389
-            true
390
-        );
391
-    }
392
-
393
-
394
-    /**
395
-     * Sets the views for the default list table view.
396
-     */
397
-    protected function _set_list_table_views_default()
398
-    {
399
-        parent::_set_list_table_views_default();
400
-        $new_views    = array(
401
-            'today' => array(
402
-                'slug'        => 'today',
403
-                'label'       => esc_html__('Today', 'event_espresso'),
404
-                'count'       => $this->total_events_today(),
405
-                'bulk_action' => array(
406
-                    'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
407
-                ),
408
-            ),
409
-            'month' => array(
410
-                'slug'        => 'month',
411
-                'label'       => esc_html__('This Month', 'event_espresso'),
412
-                'count'       => $this->total_events_this_month(),
413
-                'bulk_action' => array(
414
-                    'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
415
-                ),
416
-            ),
417
-        );
418
-        $this->_views = array_merge($this->_views, $new_views);
419
-    }
420
-
421
-
422
-    /**
423
-     * Returns the extra action links for the default list table view.
424
-     * @param array     $action_links
425
-     * @param \EE_Event $event
426
-     * @return array
427
-     * @throws EE_Error
428
-     */
429
-    public function extra_list_table_actions(array $action_links, \EE_Event $event)
430
-    {
431
-        if (EE_Registry::instance()->CAP->current_user_can(
432
-            'ee_read_registrations',
433
-            'espresso_registrations_reports',
434
-            $event->ID()
435
-        )
436
-        ) {
437
-            $reports_query_args = array(
438
-                'action' => 'reports',
439
-                'EVT_ID' => $event->ID(),
440
-            );
441
-            $reports_link       = EE_Admin_Page::add_query_args_and_nonce($reports_query_args, REG_ADMIN_URL);
442
-            $action_links[]     = '<a href="'
443
-                                  . $reports_link
444
-                                  . '" title="'
445
-                                  . esc_attr__('View Report', 'event_espresso')
446
-                                  . '"><div class="dashicons dashicons-chart-bar"></div></a>'
447
-                                  . "\n\t";
448
-        }
449
-        if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
450
-            EE_Registry::instance()->load_helper('MSG_Template');
451
-            $action_links[] = EEH_MSG_Template::get_message_action_link(
452
-                'see_notifications_for',
453
-                null,
454
-                array('EVT_ID' => $event->ID())
455
-            );
456
-        }
457
-        return $action_links;
458
-    }
459
-
460
-
461
-    /**
462
-     * @param $items
463
-     * @return mixed
464
-     */
465
-    public function additional_legend_items($items)
466
-    {
467
-        if (EE_Registry::instance()->CAP->current_user_can(
468
-            'ee_read_registrations',
469
-            'espresso_registrations_reports'
470
-        )
471
-        ) {
472
-            $items['reports'] = array(
473
-                'class' => 'dashicons dashicons-chart-bar',
474
-                'desc'  => esc_html__('Event Reports', 'event_espresso'),
475
-            );
476
-        }
477
-        if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
478
-            $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
479
-            if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) {
480
-                $items['view_related_messages'] = array(
481
-                    'class' => $related_for_icon['css_class'],
482
-                    'desc'  => $related_for_icon['label'],
483
-                );
484
-            }
485
-        }
486
-        return $items;
487
-    }
488
-
489
-
490
-    /**
491
-     * This is the callback method for the duplicate event route
492
-     * Method looks for 'EVT_ID' in the request and retrieves that event and its details and duplicates them
493
-     * into a new event.  We add a hook so that any plugins that add extra event details can hook into this
494
-     * action.  Note that the dupe will have **DUPLICATE** as its title and slug.
495
-     * After duplication the redirect is to the new event edit page.
496
-     *
497
-     * @return void
498
-     * @access protected
499
-     * @throws EE_Error If EE_Event is not available with given ID
500
-     */
501
-    protected function _duplicate_event()
502
-    {
503
-        // first make sure the ID for the event is in the request.
504
-        //  If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?)
505
-        if (! isset($this->_req_data['EVT_ID'])) {
506
-            EE_Error::add_error(
507
-                esc_html__(
508
-                    'In order to duplicate an event an Event ID is required.  None was given.',
509
-                    'event_espresso'
510
-                ),
511
-                __FILE__,
512
-                __FUNCTION__,
513
-                __LINE__
514
-            );
515
-            $this->_redirect_after_action(false, '', '', array(), true);
516
-            return;
517
-        }
518
-        //k we've got EVT_ID so let's use that to get the event we'll duplicate
519
-        $orig_event = EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']);
520
-        if (! $orig_event instanceof EE_Event) {
521
-            throw new EE_Error(
522
-                sprintf(
523
-                    esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'),
524
-                    $this->_req_data['EVT_ID']
525
-                )
526
-            );
527
-        }
528
-        //k now let's clone the $orig_event before getting relations
529
-        $new_event = clone $orig_event;
530
-        //original datetimes
531
-        $orig_datetimes = $orig_event->get_many_related('Datetime');
532
-        //other original relations
533
-        $orig_ven = $orig_event->get_many_related('Venue');
534
-        //reset the ID and modify other details to make it clear this is a dupe
535
-        $new_event->set('EVT_ID', 0);
536
-        $new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso');
537
-        $new_event->set('EVT_name', $new_name);
538
-        $new_event->set(
539
-            'EVT_slug',
540
-            wp_unique_post_slug(
541
-                sanitize_title($orig_event->name()),
542
-                0,
543
-                'publish',
544
-                'espresso_events',
545
-                0
546
-            )
547
-        );
548
-        $new_event->set('status', 'draft');
549
-        //duplicate discussion settings
550
-        $new_event->set('comment_status', $orig_event->get('comment_status'));
551
-        $new_event->set('ping_status', $orig_event->get('ping_status'));
552
-        //save the new event
553
-        $new_event->save();
554
-        //venues
555
-        foreach ($orig_ven as $ven) {
556
-            $new_event->_add_relation_to($ven, 'Venue');
557
-        }
558
-        $new_event->save();
559
-        //now we need to get the question group relations and handle that
560
-        //first primary question groups
561
-        $orig_primary_qgs = $orig_event->get_many_related(
562
-            'Question_Group',
563
-            array(array('Event_Question_Group.EQG_primary' => 1))
564
-        );
565
-        if (! empty($orig_primary_qgs)) {
566
-            foreach ($orig_primary_qgs as $id => $obj) {
567
-                if ($obj instanceof EE_Question_Group) {
568
-                    $new_event->_add_relation_to($obj, 'Question_Group', array('EQG_primary' => 1));
569
-                }
570
-            }
571
-        }
572
-        //next additional attendee question groups
573
-        $orig_additional_qgs = $orig_event->get_many_related(
574
-            'Question_Group',
575
-            array(array('Event_Question_Group.EQG_primary' => 0))
576
-        );
577
-        if (! empty($orig_additional_qgs)) {
578
-            foreach ($orig_additional_qgs as $id => $obj) {
579
-                if ($obj instanceof EE_Question_Group) {
580
-                    $new_event->_add_relation_to($obj, 'Question_Group', array('EQG_primary' => 0));
581
-                }
582
-            }
583
-        }
584
-
585
-        $new_event->save();
586
-
587
-        //k now that we have the new event saved we can loop through the datetimes and start adding relations.
588
-        $cloned_tickets = array();
589
-        foreach ($orig_datetimes as $orig_dtt) {
590
-            if (! $orig_dtt instanceof EE_Datetime) {
591
-                continue;
592
-            }
593
-            $new_dtt   = clone $orig_dtt;
594
-            $orig_tkts = $orig_dtt->tickets();
595
-            //save new dtt then add to event
596
-            $new_dtt->set('DTT_ID', 0);
597
-            $new_dtt->set('DTT_sold', 0);
598
-            $new_dtt->set_reserved(0);
599
-            $new_dtt->save();
600
-            $new_event->_add_relation_to($new_dtt, 'Datetime');
601
-            $new_event->save();
602
-            //now let's get the ticket relations setup.
603
-            foreach ((array)$orig_tkts as $orig_tkt) {
604
-                //it's possible a datetime will have no tickets so let's verify we HAVE a ticket first.
605
-                if (! $orig_tkt instanceof EE_Ticket) {
606
-                    continue;
607
-                }
608
-                //is this ticket archived?  If it is then let's skip
609
-                if ($orig_tkt->get('TKT_deleted')) {
610
-                    continue;
611
-                }
612
-                // does this original ticket already exist in the clone_tickets cache?
613
-                //  If so we'll just use the new ticket from it.
614
-                if (isset($cloned_tickets[$orig_tkt->ID()])) {
615
-                    $new_tkt = $cloned_tickets[$orig_tkt->ID()];
616
-                } else {
617
-                    $new_tkt = clone $orig_tkt;
618
-                    //get relations on the $orig_tkt that we need to setup.
619
-                    $orig_prices = $orig_tkt->prices();
620
-                    $new_tkt->set('TKT_ID', 0);
621
-                    $new_tkt->set('TKT_sold', 0);
622
-                    $new_tkt->set('TKT_reserved', 0);
623
-                    $new_tkt->save(); //make sure new ticket has ID.
624
-                    //price relations on new ticket need to be setup.
625
-                    foreach ($orig_prices as $orig_price) {
626
-                        $new_price = clone $orig_price;
627
-                        $new_price->set('PRC_ID', 0);
628
-                        $new_price->save();
629
-                        $new_tkt->_add_relation_to($new_price, 'Price');
630
-                        $new_tkt->save();
631
-                    }
632
-
633
-                    do_action(
634
-                        'AHEE__Extend_Events_Admin_Page___duplicate_event__duplicate_ticket__after',
635
-                        $orig_tkt,
636
-                        $new_tkt,
637
-                        $orig_prices,
638
-                        $orig_event,
639
-                        $orig_dtt,
640
-                        $new_dtt
641
-                    );
642
-                }
643
-                // k now we can add the new ticket as a relation to the new datetime
644
-                // and make sure its added to our cached $cloned_tickets array
645
-                // for use with later datetimes that have the same ticket.
646
-                $new_dtt->_add_relation_to($new_tkt, 'Ticket');
647
-                $new_dtt->save();
648
-                $cloned_tickets[$orig_tkt->ID()] = $new_tkt;
649
-            }
650
-        }
651
-        //clone taxonomy information
652
-        $taxonomies_to_clone_with = apply_filters(
653
-            'FHEE__Extend_Events_Admin_Page___duplicate_event__taxonomies_to_clone',
654
-            array('espresso_event_categories', 'espresso_event_type', 'post_tag')
655
-        );
656
-        //get terms for original event (notice)
657
-        $orig_terms = wp_get_object_terms($orig_event->ID(), $taxonomies_to_clone_with);
658
-        //loop through terms and add them to new event.
659
-        foreach ($orig_terms as $term) {
660
-            wp_set_object_terms($new_event->ID(), $term->term_id, $term->taxonomy, true);
661
-        }
662
-
663
-        //duplicate other core WP_Post items for this event.
664
-        //post thumbnail (feature image).
665
-        $feature_image_id = get_post_thumbnail_id($orig_event->ID());
666
-        if ($feature_image_id) {
667
-            update_post_meta($new_event->ID(), '_thumbnail_id', $feature_image_id);
668
-        }
669
-
670
-        //duplicate page_template setting
671
-        $page_template = get_post_meta($orig_event->ID(), '_wp_page_template', true);
672
-        if ($page_template) {
673
-            update_post_meta($new_event->ID(), '_wp_page_template', $page_template);
674
-        }
675
-
676
-        do_action('AHEE__Extend_Events_Admin_Page___duplicate_event__after', $new_event, $orig_event);
677
-        //now let's redirect to the edit page for this duplicated event if we have a new event id.
678
-        if ($new_event->ID()) {
679
-            $redirect_args = array(
680
-                'post'   => $new_event->ID(),
681
-                'action' => 'edit',
682
-            );
683
-            EE_Error::add_success(
684
-                esc_html__(
685
-                    'Event successfully duplicated.  Please review the details below and make any necessary edits',
686
-                    'event_espresso'
687
-                )
688
-            );
689
-        } else {
690
-            $redirect_args = array(
691
-                'action' => 'default',
692
-            );
693
-            EE_Error::add_error(
694
-                esc_html__('Not able to duplicate event.  Something went wrong.', 'event_espresso'),
695
-                __FILE__,
696
-                __FUNCTION__,
697
-                __LINE__
698
-            );
699
-        }
700
-        $this->_redirect_after_action(false, '', '', $redirect_args, true);
701
-    }
702
-
703
-
704
-    /**
705
-     * Generates output for the import page.
706
-     * @throws DomainException
707
-     */
708
-    protected function _import_page()
709
-    {
710
-        $title                                      = esc_html__('Import', 'event_espresso');
711
-        $intro                                      = esc_html__(
712
-            'If you have a previously exported Event Espresso 4 information in a Comma Separated Value (CSV) file format, you can upload the file here: ',
713
-            'event_espresso'
714
-        );
715
-        $form_url                                   = EVENTS_ADMIN_URL;
716
-        $action                                     = 'import_events';
717
-        $type                                       = 'csv';
718
-        $this->_template_args['form']               = EE_Import::instance()->upload_form(
719
-            $title, $intro, $form_url, $action, $type
720
-        );
721
-        $this->_template_args['sample_file_link']   = EE_Admin_Page::add_query_args_and_nonce(
722
-            array('action' => 'sample_export_file'),
723
-            $this->_admin_base_url
724
-        );
725
-        $content                                    = EEH_Template::display_template(
726
-            EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php',
727
-            $this->_template_args,
728
-            true
729
-        );
730
-        $this->_template_args['admin_page_content'] = $content;
731
-        $this->display_admin_page_with_sidebar();
732
-    }
733
-
734
-
735
-    /**
736
-     * _import_events
737
-     * This handles displaying the screen and running imports for importing events.
738
-     *
739
-     * @return void
740
-     */
741
-    protected function _import_events()
742
-    {
743
-        require_once(EE_CLASSES . 'EE_Import.class.php');
744
-        $success = EE_Import::instance()->import();
745
-        $this->_redirect_after_action($success, 'Import File', 'ran', array('action' => 'import_page'), true);
746
-    }
747
-
748
-
749
-    /**
750
-     * _events_export
751
-     * Will export all (or just the given event) to a Excel compatible file.
752
-     *
753
-     * @access protected
754
-     * @return void
755
-     */
756
-    protected function _events_export()
757
-    {
758
-        if (isset($this->_req_data['EVT_ID'])) {
759
-            $event_ids = $this->_req_data['EVT_ID'];
760
-        } elseif (isset($this->_req_data['EVT_IDs'])) {
761
-            $event_ids = $this->_req_data['EVT_IDs'];
762
-        } else {
763
-            $event_ids = null;
764
-        }
765
-        //todo: I don't like doing this but it'll do until we modify EE_Export Class.
766
-        $new_request_args = array(
767
-            'export' => 'report',
768
-            'action' => 'all_event_data',
769
-            'EVT_ID' => $event_ids,
770
-        );
771
-        $this->_req_data  = array_merge($this->_req_data, $new_request_args);
772
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
773
-            require_once(EE_CLASSES . 'EE_Export.class.php');
774
-            $EE_Export = EE_Export::instance($this->_req_data);
775
-            $EE_Export->export();
776
-        }
777
-    }
778
-
779
-
780
-    /**
781
-     * handle category exports()
782
-     *
783
-     * @return void
784
-     */
785
-    protected function _categories_export()
786
-    {
787
-        //todo: I don't like doing this but it'll do until we modify EE_Export Class.
788
-        $new_request_args = array(
789
-            'export'       => 'report',
790
-            'action'       => 'categories',
791
-            'category_ids' => $this->_req_data['EVT_CAT_ID'],
792
-        );
793
-        $this->_req_data  = array_merge($this->_req_data, $new_request_args);
794
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
795
-            require_once(EE_CLASSES . 'EE_Export.class.php');
796
-            $EE_Export = EE_Export::instance($this->_req_data);
797
-            $EE_Export->export();
798
-        }
799
-    }
800
-
801
-
802
-    /**
803
-     * Creates a sample CSV file for importing
804
-     */
805
-    protected function _sample_export_file()
806
-    {
807
-        //		require_once(EE_CLASSES . 'EE_Export.class.php');
808
-        EE_Export::instance()->export_sample();
809
-    }
810
-
811
-
812
-    /*************        Template Settings        *************/
813
-    /**
814
-     * Generates template settings page output
815
-     * @throws DomainException
816
-     * @throws EE_Error
817
-     */
818
-    protected function _template_settings()
819
-    {
820
-        $this->_template_args['values'] = $this->_yes_no_values;
821
-        /**
822
-         * Note leaving this filter in for backward compatibility this was moved in 4.6.x
823
-         * from General_Settings_Admin_Page to here.
824
-         */
825
-        $this->_template_args = apply_filters(
826
-            'FHEE__General_Settings_Admin_Page__template_settings__template_args',
827
-            $this->_template_args
828
-        );
829
-        $this->_set_add_edit_form_tags('update_template_settings');
830
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
831
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
832
-            EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php',
833
-            $this->_template_args,
834
-            true
835
-        );
836
-        $this->display_admin_page_with_sidebar();
837
-    }
838
-
839
-
840
-    /**
841
-     * Handler for updating template settings.
842
-     *
843
-     * @throws InvalidInterfaceException
844
-     * @throws InvalidDataTypeException
845
-     * @throws InvalidArgumentException
846
-     */
847
-    protected function _update_template_settings()
848
-    {
849
-        /**
850
-         * Note leaving this filter in for backward compatibility this was moved in 4.6.x
851
-         * from General_Settings_Admin_Page to here.
852
-         */
853
-        EE_Registry::instance()->CFG->template_settings = apply_filters(
854
-            'FHEE__General_Settings_Admin_Page__update_template_settings__data',
855
-            EE_Registry::instance()->CFG->template_settings,
856
-            $this->_req_data
857
-        );
858
-        //update custom post type slugs and detect if we need to flush rewrite rules
859
-        $old_slug                                          = EE_Registry::instance()->CFG->core->event_cpt_slug;
860
-        EE_Registry::instance()->CFG->core->event_cpt_slug = empty($this->_req_data['event_cpt_slug'])
861
-            ? EE_Registry::instance()->CFG->core->event_cpt_slug
862
-            : sanitize_title_with_dashes($this->_req_data['event_cpt_slug']);
863
-        $what                                              = 'Template Settings';
864
-        $success                                           = $this->_update_espresso_configuration(
865
-            $what,
866
-            EE_Registry::instance()->CFG->template_settings,
867
-            __FILE__,
868
-            __FUNCTION__,
869
-            __LINE__
870
-        );
871
-        if (EE_Registry::instance()->CFG->core->event_cpt_slug != $old_slug) {
872
-            /** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */
873
-            $rewrite_rules =  LoaderFactory::getLoader()->getShared(
874
-                'EventEspresso\core\domain\services\custom_post_types\RewriteRules'
875
-            );
876
-            $rewrite_rules->flush();
877
-        }
878
-        $this->_redirect_after_action($success, $what, 'updated', array('action' => 'template_settings'));
879
-    }
880
-
881
-
882
-    /**
883
-     * _premium_event_editor_meta_boxes
884
-     * add all metaboxes related to the event_editor
885
-     *
886
-     * @access protected
887
-     * @return void
888
-     * @throws EE_Error
889
-     */
890
-    protected function _premium_event_editor_meta_boxes()
891
-    {
892
-        $this->verify_cpt_object();
893
-        add_meta_box(
894
-            'espresso_event_editor_event_options',
895
-            esc_html__('Event Registration Options', 'event_espresso'),
896
-            array($this, 'registration_options_meta_box'),
897
-            $this->page_slug,
898
-            'side',
899
-            'core'
900
-        );
901
-    }
902
-
903
-
904
-    /**
905
-     * override caf metabox
906
-     *
907
-     * @return void
908
-     * @throws DomainException
909
-     */
910
-    public function registration_options_meta_box()
911
-    {
912
-        $yes_no_values                                    = array(
913
-            array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')),
914
-            array('id' => false, 'text' => esc_html__('No', 'event_espresso')),
915
-        );
916
-        $default_reg_status_values                        = EEM_Registration::reg_status_array(
917
-            array(
918
-                EEM_Registration::status_id_cancelled,
919
-                EEM_Registration::status_id_declined,
920
-                EEM_Registration::status_id_incomplete,
921
-                EEM_Registration::status_id_wait_list,
922
-            ),
923
-            true
924
-        );
925
-        $template_args['active_status']                   = $this->_cpt_model_obj->pretty_active_status(false);
926
-        $template_args['_event']                          = $this->_cpt_model_obj;
927
-        $template_args['additional_limit']                = $this->_cpt_model_obj->additional_limit();
928
-        $template_args['default_registration_status']     = EEH_Form_Fields::select_input(
929
-            'default_reg_status',
930
-            $default_reg_status_values,
931
-            $this->_cpt_model_obj->default_registration_status()
932
-        );
933
-        $template_args['display_description']             = EEH_Form_Fields::select_input(
934
-            'display_desc',
935
-            $yes_no_values,
936
-            $this->_cpt_model_obj->display_description()
937
-        );
938
-        $template_args['display_ticket_selector']         = EEH_Form_Fields::select_input(
939
-            'display_ticket_selector',
940
-            $yes_no_values,
941
-            $this->_cpt_model_obj->display_ticket_selector(),
942
-            '',
943
-            '',
944
-            false
945
-        );
946
-        $template_args['EVT_default_registration_status'] = EEH_Form_Fields::select_input(
947
-            'EVT_default_registration_status',
948
-            $default_reg_status_values,
949
-            $this->_cpt_model_obj->default_registration_status()
950
-        );
951
-        $template_args['additional_registration_options'] = apply_filters(
952
-            'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options',
953
-            '',
954
-            $template_args,
955
-            $yes_no_values,
956
-            $default_reg_status_values
957
-        );
958
-        EEH_Template::display_template(
959
-            EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php',
960
-            $template_args
961
-        );
962
-    }
963
-
964
-
965
-
966
-    /**
967
-     * wp_list_table_mods for caf
968
-     * ============================
969
-     */
970
-    /**
971
-     * hook into list table filters and provide filters for caffeinated list table
972
-     *
973
-     * @param  array $old_filters    any existing filters present
974
-     * @param  array $list_table_obj the list table object
975
-     * @return array                  new filters
976
-     */
977
-    public function list_table_filters($old_filters, $list_table_obj)
978
-    {
979
-        $filters = array();
980
-        //first month/year filters
981
-        $filters[] = $this->espresso_event_months_dropdown();
982
-        $status    = isset($this->_req_data['status']) ? $this->_req_data['status'] : null;
983
-        //active status dropdown
984
-        if ($status !== 'draft') {
985
-            $filters[] = $this->active_status_dropdown(
986
-                isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : ''
987
-            );
988
-        }
989
-        //category filter
990
-        $filters[] = $this->category_dropdown();
991
-        return array_merge($old_filters, $filters);
992
-    }
993
-
994
-
995
-    /**
996
-     * espresso_event_months_dropdown
997
-     *
998
-     * @access public
999
-     * @return string                dropdown listing month/year selections for events.
1000
-     */
1001
-    public function espresso_event_months_dropdown()
1002
-    {
1003
-        // what we need to do is get all PRIMARY datetimes for all events to filter on.
1004
-        // Note we need to include any other filters that are set!
1005
-        $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null;
1006
-        //categories?
1007
-        $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0
1008
-            ? $this->_req_data['EVT_CAT']
1009
-            : null;
1010
-        //active status?
1011
-        $active_status = isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : null;
1012
-        $cur_date      = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : '';
1013
-        return EEH_Form_Fields::generate_event_months_dropdown($cur_date, $status, $category, $active_status);
1014
-    }
1015
-
1016
-
1017
-    /**
1018
-     * returns a list of "active" statuses on the event
1019
-     *
1020
-     * @param  string $current_value whatever the current active status is
1021
-     * @return string
1022
-     */
1023
-    public function active_status_dropdown($current_value = '')
1024
-    {
1025
-        $select_name = 'active_status';
1026
-        $values      = array(
1027
-            'none'     => esc_html__('Show Active/Inactive', 'event_espresso'),
1028
-            'active'   => esc_html__('Active', 'event_espresso'),
1029
-            'upcoming' => esc_html__('Upcoming', 'event_espresso'),
1030
-            'expired'  => esc_html__('Expired', 'event_espresso'),
1031
-            'inactive' => esc_html__('Inactive', 'event_espresso'),
1032
-        );
1033
-        $id          = 'id="espresso-active-status-dropdown-filter"';
1034
-        $class       = 'wide';
1035
-        return EEH_Form_Fields::select_input($select_name, $values, $current_value, $id, $class);
1036
-    }
1037
-
1038
-
1039
-    /**
1040
-     * output a dropdown of the categories for the category filter on the event admin list table
1041
-     *
1042
-     * @access  public
1043
-     * @return string html
1044
-     */
1045
-    public function category_dropdown()
1046
-    {
1047
-        $cur_cat = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1;
1048
-        return EEH_Form_Fields::generate_event_category_dropdown($cur_cat);
1049
-    }
1050
-
1051
-
1052
-    /**
1053
-     * get total number of events today
1054
-     *
1055
-     * @access public
1056
-     * @return int
1057
-     * @throws EE_Error
1058
-     */
1059
-    public function total_events_today()
1060
-    {
1061
-        $start = EEM_Datetime::instance()->convert_datetime_for_query(
1062
-            'DTT_EVT_start',
1063
-            date('Y-m-d') . ' 00:00:00',
1064
-            'Y-m-d H:i:s',
1065
-            'UTC'
1066
-        );
1067
-        $end   = EEM_Datetime::instance()->convert_datetime_for_query(
1068
-            'DTT_EVT_start',
1069
-            date('Y-m-d') . ' 23:59:59',
1070
-            'Y-m-d H:i:s',
1071
-            'UTC'
1072
-        );
1073
-        $where = array(
1074
-            'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)),
1075
-        );
1076
-        $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
1077
-        return $count;
1078
-    }
1079
-
1080
-
1081
-    /**
1082
-     * get total number of events this month
1083
-     *
1084
-     * @access public
1085
-     * @return int
1086
-     * @throws EE_Error
1087
-     */
1088
-    public function total_events_this_month()
1089
-    {
1090
-        //Dates
1091
-        $this_year_r     = date('Y');
1092
-        $this_month_r    = date('m');
1093
-        $days_this_month = date('t');
1094
-        $start           = EEM_Datetime::instance()->convert_datetime_for_query(
1095
-            'DTT_EVT_start',
1096
-            $this_year_r . '-' . $this_month_r . '-01 00:00:00',
1097
-            'Y-m-d H:i:s',
1098
-            'UTC'
1099
-        );
1100
-        $end             = EEM_Datetime::instance()->convert_datetime_for_query(
1101
-            'DTT_EVT_start',
1102
-            $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59',
1103
-            'Y-m-d H:i:s',
1104
-            'UTC'
1105
-        );
1106
-        $where           = array(
1107
-            'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)),
1108
-        );
1109
-        $count           = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
1110
-        return $count;
1111
-    }
1112
-
1113
-
1114
-    /** DEFAULT TICKETS STUFF **/
1115
-
1116
-    /**
1117
-     * Output default tickets list table view.
1118
-     */
1119
-    public function _tickets_overview_list_table()
1120
-    {
1121
-        $this->_search_btn_label = esc_html__('Tickets', 'event_espresso');
1122
-        $this->display_admin_list_table_page_with_no_sidebar();
1123
-    }
1124
-
1125
-
1126
-    /**
1127
-     * @param int  $per_page
1128
-     * @param bool $count
1129
-     * @param bool $trashed
1130
-     * @return \EE_Soft_Delete_Base_Class[]|int
1131
-     */
1132
-    public function get_default_tickets($per_page = 10, $count = false, $trashed = false)
1133
-    {
1134
-        $orderby = empty($this->_req_data['orderby']) ? 'TKT_name' : $this->_req_data['orderby'];
1135
-        $order   = empty($this->_req_data['order']) ? 'ASC' : $this->_req_data['order'];
1136
-        switch ($orderby) {
1137
-            case 'TKT_name':
1138
-                $orderby = array('TKT_name' => $order);
1139
-                break;
1140
-            case 'TKT_price':
1141
-                $orderby = array('TKT_price' => $order);
1142
-                break;
1143
-            case 'TKT_uses':
1144
-                $orderby = array('TKT_uses' => $order);
1145
-                break;
1146
-            case 'TKT_min':
1147
-                $orderby = array('TKT_min' => $order);
1148
-                break;
1149
-            case 'TKT_max':
1150
-                $orderby = array('TKT_max' => $order);
1151
-                break;
1152
-            case 'TKT_qty':
1153
-                $orderby = array('TKT_qty' => $order);
1154
-                break;
1155
-        }
1156
-        $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged'])
1157
-            ? $this->_req_data['paged']
1158
-            : 1;
1159
-        $per_page     = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage'])
1160
-            ? $this->_req_data['perpage']
1161
-            : $per_page;
1162
-        $_where       = array(
1163
-            'TKT_is_default' => 1,
1164
-            'TKT_deleted'    => $trashed,
1165
-        );
1166
-        $offset       = ($current_page - 1) * $per_page;
1167
-        $limit        = array($offset, $per_page);
1168
-        if (isset($this->_req_data['s'])) {
1169
-            $sstr         = '%' . $this->_req_data['s'] . '%';
1170
-            $_where['OR'] = array(
1171
-                'TKT_name'        => array('LIKE', $sstr),
1172
-                'TKT_description' => array('LIKE', $sstr),
1173
-            );
1174
-        }
1175
-        $query_params = array(
1176
-            $_where,
1177
-            'order_by' => $orderby,
1178
-            'limit'    => $limit,
1179
-            'group_by' => 'TKT_ID',
1180
-        );
1181
-        if ($count) {
1182
-            return EEM_Ticket::instance()->count_deleted_and_undeleted(array($_where));
1183
-        } else {
1184
-            return EEM_Ticket::instance()->get_all_deleted_and_undeleted($query_params);
1185
-        }
1186
-    }
1187
-
1188
-
1189
-    /**
1190
-     * @param bool $trash
1191
-     * @throws EE_Error
1192
-     */
1193
-    protected function _trash_or_restore_ticket($trash = false)
1194
-    {
1195
-        $success = 1;
1196
-        $TKT     = EEM_Ticket::instance();
1197
-        //checkboxes?
1198
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1199
-            //if array has more than one element then success message should be plural
1200
-            $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1201
-            //cycle thru the boxes
1202
-            while (list($TKT_ID, $value) = each($this->_req_data['checkbox'])) {
1203
-                if ($trash) {
1204
-                    if (! $TKT->delete_by_ID($TKT_ID)) {
1205
-                        $success = 0;
1206
-                    }
1207
-                } else {
1208
-                    if (! $TKT->restore_by_ID($TKT_ID)) {
1209
-                        $success = 0;
1210
-                    }
1211
-                }
1212
-            }
1213
-        } else {
1214
-            //grab single id and trash
1215
-            $TKT_ID = absint($this->_req_data['TKT_ID']);
1216
-            if ($trash) {
1217
-                if (! $TKT->delete_by_ID($TKT_ID)) {
1218
-                    $success = 0;
1219
-                }
1220
-            } else {
1221
-                if (! $TKT->restore_by_ID($TKT_ID)) {
1222
-                    $success = 0;
1223
-                }
1224
-            }
1225
-        }
1226
-        $action_desc = $trash ? 'moved to the trash' : 'restored';
1227
-        $query_args  = array(
1228
-            'action' => 'ticket_list_table',
1229
-            'status' => $trash ? '' : 'trashed',
1230
-        );
1231
-        $this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args);
1232
-    }
1233
-
1234
-
1235
-    /**
1236
-     * Handles trashing default ticket.
1237
-     */
1238
-    protected function _delete_ticket()
1239
-    {
1240
-        $success = 1;
1241
-        //checkboxes?
1242
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1243
-            //if array has more than one element then success message should be plural
1244
-            $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1245
-            //cycle thru the boxes
1246
-            while (list($TKT_ID, $value) = each($this->_req_data['checkbox'])) {
1247
-                //delete
1248
-                if (! $this->_delete_the_ticket($TKT_ID)) {
1249
-                    $success = 0;
1250
-                }
1251
-            }
1252
-        } else {
1253
-            //grab single id and trash
1254
-            $TKT_ID = absint($this->_req_data['TKT_ID']);
1255
-            if (! $this->_delete_the_ticket($TKT_ID)) {
1256
-                $success = 0;
1257
-            }
1258
-        }
1259
-        $action_desc = 'deleted';
1260
-        $query_args  = array(
1261
-            'action' => 'ticket_list_table',
1262
-            'status' => 'trashed',
1263
-        );
1264
-        //fail safe.  If the default ticket count === 1 then we need to redirect to event overview.
1265
-        if (EEM_Ticket::instance()->count_deleted_and_undeleted(
1266
-            array(array('TKT_is_default' => 1)),
1267
-            'TKT_ID',
1268
-            true
1269
-        )
1270
-        ) {
1271
-            $query_args = array();
1272
-        }
1273
-        $this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args);
1274
-    }
1275
-
1276
-
1277
-    /**
1278
-     * @param int $TKT_ID
1279
-     * @return bool|int
1280
-     * @throws EE_Error
1281
-     */
1282
-    protected function _delete_the_ticket($TKT_ID)
1283
-    {
1284
-        $tkt = EEM_Ticket::instance()->get_one_by_ID($TKT_ID);
1285
-        $tkt->_remove_relations('Datetime');
1286
-        //delete all related prices first
1287
-        $tkt->delete_related_permanently('Price');
1288
-        return $tkt->delete_permanently();
1289
-    }
22
+	/**
23
+	 * Extend_Events_Admin_Page constructor.
24
+	 *
25
+	 * @param bool $routing
26
+	 */
27
+	public function __construct($routing = true)
28
+	{
29
+		parent::__construct($routing);
30
+		if (! defined('EVENTS_CAF_TEMPLATE_PATH')) {
31
+			define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/');
32
+			define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/');
33
+			define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/');
34
+		}
35
+	}
36
+
37
+
38
+	/**
39
+	 * Sets routes.
40
+	 */
41
+	protected function _extend_page_config()
42
+	{
43
+		$this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events';
44
+		//is there a evt_id in the request?
45
+		$evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID'])
46
+			? $this->_req_data['EVT_ID']
47
+			: 0;
48
+		$evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id;
49
+		//tkt_id?
50
+		$tkt_id             = ! empty($this->_req_data['TKT_ID']) && ! is_array($this->_req_data['TKT_ID'])
51
+			? $this->_req_data['TKT_ID']
52
+			: 0;
53
+		$new_page_routes    = array(
54
+			'duplicate_event'          => array(
55
+				'func'       => '_duplicate_event',
56
+				'capability' => 'ee_edit_event',
57
+				'obj_id'     => $evt_id,
58
+				'noheader'   => true,
59
+			),
60
+			'ticket_list_table'        => array(
61
+				'func'       => '_tickets_overview_list_table',
62
+				'capability' => 'ee_read_default_tickets',
63
+			),
64
+			'trash_ticket'             => array(
65
+				'func'       => '_trash_or_restore_ticket',
66
+				'capability' => 'ee_delete_default_ticket',
67
+				'obj_id'     => $tkt_id,
68
+				'noheader'   => true,
69
+				'args'       => array('trash' => true),
70
+			),
71
+			'trash_tickets'            => array(
72
+				'func'       => '_trash_or_restore_ticket',
73
+				'capability' => 'ee_delete_default_tickets',
74
+				'noheader'   => true,
75
+				'args'       => array('trash' => true),
76
+			),
77
+			'restore_ticket'           => array(
78
+				'func'       => '_trash_or_restore_ticket',
79
+				'capability' => 'ee_delete_default_ticket',
80
+				'obj_id'     => $tkt_id,
81
+				'noheader'   => true,
82
+			),
83
+			'restore_tickets'          => array(
84
+				'func'       => '_trash_or_restore_ticket',
85
+				'capability' => 'ee_delete_default_tickets',
86
+				'noheader'   => true,
87
+			),
88
+			'delete_ticket'            => array(
89
+				'func'       => '_delete_ticket',
90
+				'capability' => 'ee_delete_default_ticket',
91
+				'obj_id'     => $tkt_id,
92
+				'noheader'   => true,
93
+			),
94
+			'delete_tickets'           => array(
95
+				'func'       => '_delete_ticket',
96
+				'capability' => 'ee_delete_default_tickets',
97
+				'noheader'   => true,
98
+			),
99
+			'import_page'              => array(
100
+				'func'       => '_import_page',
101
+				'capability' => 'import',
102
+			),
103
+			'import'                   => array(
104
+				'func'       => '_import_events',
105
+				'capability' => 'import',
106
+				'noheader'   => true,
107
+			),
108
+			'import_events'            => array(
109
+				'func'       => '_import_events',
110
+				'capability' => 'import',
111
+				'noheader'   => true,
112
+			),
113
+			'export_events'            => array(
114
+				'func'       => '_events_export',
115
+				'capability' => 'export',
116
+				'noheader'   => true,
117
+			),
118
+			'export_categories'        => array(
119
+				'func'       => '_categories_export',
120
+				'capability' => 'export',
121
+				'noheader'   => true,
122
+			),
123
+			'sample_export_file'       => array(
124
+				'func'       => '_sample_export_file',
125
+				'capability' => 'export',
126
+				'noheader'   => true,
127
+			),
128
+			'update_template_settings' => array(
129
+				'func'       => '_update_template_settings',
130
+				'capability' => 'manage_options',
131
+				'noheader'   => true,
132
+			),
133
+		);
134
+		$this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
135
+		//partial route/config override
136
+		$this->_page_config['import_events']['metaboxes'] = $this->_default_espresso_metaboxes;
137
+		$this->_page_config['create_new']['metaboxes'][]  = '_premium_event_editor_meta_boxes';
138
+		$this->_page_config['create_new']['qtips'][]      = 'EE_Event_Editor_Tips';
139
+		$this->_page_config['edit']['qtips'][]            = 'EE_Event_Editor_Tips';
140
+		$this->_page_config['edit']['metaboxes'][]        = '_premium_event_editor_meta_boxes';
141
+		$this->_page_config['default']['list_table']      = 'Extend_Events_Admin_List_Table';
142
+		//add tickets tab but only if there are more than one default ticket!
143
+		$tkt_count = EEM_Ticket::instance()->count_deleted_and_undeleted(
144
+			array(array('TKT_is_default' => 1)),
145
+			'TKT_ID',
146
+			true
147
+		);
148
+		if ($tkt_count > 1) {
149
+			$new_page_config = array(
150
+				'ticket_list_table' => array(
151
+					'nav'           => array(
152
+						'label' => esc_html__('Default Tickets', 'event_espresso'),
153
+						'order' => 60,
154
+					),
155
+					'list_table'    => 'Tickets_List_Table',
156
+					'require_nonce' => false,
157
+				),
158
+			);
159
+		}
160
+		//template settings
161
+		$new_page_config['template_settings'] = array(
162
+			'nav'           => array(
163
+				'label' => esc_html__('Templates', 'event_espresso'),
164
+				'order' => 30,
165
+			),
166
+			'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
167
+			'help_tabs'     => array(
168
+				'general_settings_templates_help_tab' => array(
169
+					'title'    => esc_html__('Templates', 'event_espresso'),
170
+					'filename' => 'general_settings_templates',
171
+				),
172
+			),
173
+			'help_tour'     => array('Templates_Help_Tour'),
174
+			'require_nonce' => false,
175
+		);
176
+		$this->_page_config                   = array_merge($this->_page_config, $new_page_config);
177
+		//add filters and actions
178
+		//modifying _views
179
+		add_filter(
180
+			'FHEE_event_datetime_metabox_add_additional_date_time_template',
181
+			array($this, 'add_additional_datetime_button'),
182
+			10,
183
+			2
184
+		);
185
+		add_filter(
186
+			'FHEE_event_datetime_metabox_clone_button_template',
187
+			array($this, 'add_datetime_clone_button'),
188
+			10,
189
+			2
190
+		);
191
+		add_filter(
192
+			'FHEE_event_datetime_metabox_timezones_template',
193
+			array($this, 'datetime_timezones_template'),
194
+			10,
195
+			2
196
+		);
197
+		//filters for event list table
198
+		add_filter('FHEE__Extend_Events_Admin_List_Table__filters', array($this, 'list_table_filters'), 10, 2);
199
+		add_filter(
200
+			'FHEE__Events_Admin_List_Table__column_actions__action_links',
201
+			array($this, 'extra_list_table_actions'),
202
+			10,
203
+			2
204
+		);
205
+		//legend item
206
+		add_filter('FHEE__Events_Admin_Page___event_legend_items__items', array($this, 'additional_legend_items'));
207
+		add_action('admin_init', array($this, 'admin_init'));
208
+		//heartbeat stuff
209
+		add_filter('heartbeat_received', array($this, 'heartbeat_response'), 10, 2);
210
+	}
211
+
212
+
213
+	/**
214
+	 * admin_init
215
+	 */
216
+	public function admin_init()
217
+	{
218
+		EE_Registry::$i18n_js_strings = array_merge(
219
+			EE_Registry::$i18n_js_strings,
220
+			array(
221
+				'image_confirm'          => esc_html__(
222
+					'Do you really want to delete this image? Please remember to update your event to complete the removal.',
223
+					'event_espresso'
224
+				),
225
+				'event_starts_on'        => esc_html__('Event Starts on', 'event_espresso'),
226
+				'event_ends_on'          => esc_html__('Event Ends on', 'event_espresso'),
227
+				'event_datetime_actions' => esc_html__('Actions', 'event_espresso'),
228
+				'event_clone_dt_msg'     => esc_html__('Clone this Event Date and Time', 'event_espresso'),
229
+				'remove_event_dt_msg'    => esc_html__('Remove this Event Time', 'event_espresso'),
230
+			)
231
+		);
232
+	}
233
+
234
+
235
+	/**
236
+	 * This will be used to listen for any heartbeat data packages coming via the WordPress heartbeat API and handle
237
+	 * accordingly.
238
+	 *
239
+	 * @param array $response The existing heartbeat response array.
240
+	 * @param array $data     The incoming data package.
241
+	 * @return array  possibly appended response.
242
+	 */
243
+	public function heartbeat_response($response, $data)
244
+	{
245
+		/**
246
+		 * check whether count of tickets is approaching the potential
247
+		 * limits for the server.
248
+		 */
249
+		if (! empty($data['input_count'])) {
250
+			$response['max_input_vars_check'] = EE_Registry::instance()->CFG->environment->max_input_vars_limit_check(
251
+				$data['input_count']
252
+			);
253
+		}
254
+		return $response;
255
+	}
256
+
257
+
258
+	/**
259
+	 * Add per page screen options to the default ticket list table view.
260
+	 */
261
+	protected function _add_screen_options_ticket_list_table()
262
+	{
263
+		$this->_per_page_screen_option();
264
+	}
265
+
266
+
267
+	/**
268
+	 * @param string $return
269
+	 * @param int    $id
270
+	 * @param string $new_title
271
+	 * @param string $new_slug
272
+	 * @return string
273
+	 */
274
+	public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug)
275
+	{
276
+		$return = parent::extra_permalink_field_buttons($return, $id, $new_title, $new_slug);
277
+		//make sure this is only when editing
278
+		if (! empty($id)) {
279
+			$href   = EE_Admin_Page::add_query_args_and_nonce(
280
+				array('action' => 'duplicate_event', 'EVT_ID' => $id),
281
+				$this->_admin_base_url
282
+			);
283
+			$title  = esc_attr__('Duplicate Event', 'event_espresso');
284
+			$return .= '<a href="'
285
+					   . $href
286
+					   . '" title="'
287
+					   . $title
288
+					   . '" id="ee-duplicate-event-button" class="button button-small"  value="duplicate_event">'
289
+					   . $title
290
+					   . '</a>';
291
+		}
292
+		return $return;
293
+	}
294
+
295
+
296
+	/**
297
+	 * Set the list table views for the default ticket list table view.
298
+	 */
299
+	public function _set_list_table_views_ticket_list_table()
300
+	{
301
+		$this->_views = array(
302
+			'all'     => array(
303
+				'slug'        => 'all',
304
+				'label'       => esc_html__('All', 'event_espresso'),
305
+				'count'       => 0,
306
+				'bulk_action' => array(
307
+					'trash_tickets' => esc_html__('Move to Trash', 'event_espresso'),
308
+				),
309
+			),
310
+			'trashed' => array(
311
+				'slug'        => 'trashed',
312
+				'label'       => esc_html__('Trash', 'event_espresso'),
313
+				'count'       => 0,
314
+				'bulk_action' => array(
315
+					'restore_tickets' => esc_html__('Restore from Trash', 'event_espresso'),
316
+					'delete_tickets'  => esc_html__('Delete Permanently', 'event_espresso'),
317
+				),
318
+			),
319
+		);
320
+	}
321
+
322
+
323
+	/**
324
+	 * Enqueue scripts and styles for the event editor.
325
+	 */
326
+	public function load_scripts_styles_edit()
327
+	{
328
+		wp_register_script(
329
+			'ee-event-editor-heartbeat',
330
+			EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js',
331
+			array('ee_admin_js', 'heartbeat'),
332
+			EVENT_ESPRESSO_VERSION,
333
+			true
334
+		);
335
+		wp_enqueue_script('ee-accounting');
336
+		//styles
337
+		wp_enqueue_style('espresso-ui-theme');
338
+		wp_enqueue_script('event_editor_js');
339
+		wp_enqueue_script('ee-event-editor-heartbeat');
340
+	}
341
+
342
+
343
+	/**
344
+	 * Returns template for the additional datetime.
345
+	 * @param $template
346
+	 * @param $template_args
347
+	 * @return mixed
348
+	 * @throws DomainException
349
+	 */
350
+	public function add_additional_datetime_button($template, $template_args)
351
+	{
352
+		return EEH_Template::display_template(
353
+			EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_add_additional_time.template.php',
354
+			$template_args,
355
+			true
356
+		);
357
+	}
358
+
359
+
360
+	/**
361
+	 * Returns the template for cloning a datetime.
362
+	 * @param $template
363
+	 * @param $template_args
364
+	 * @return mixed
365
+	 * @throws DomainException
366
+	 */
367
+	public function add_datetime_clone_button($template, $template_args)
368
+	{
369
+		return EEH_Template::display_template(
370
+			EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_metabox_clone_button.template.php',
371
+			$template_args,
372
+			true
373
+		);
374
+	}
375
+
376
+
377
+	/**
378
+	 * Returns the template for datetime timezones.
379
+	 * @param $template
380
+	 * @param $template_args
381
+	 * @return mixed
382
+	 * @throws DomainException
383
+	 */
384
+	public function datetime_timezones_template($template, $template_args)
385
+	{
386
+		return EEH_Template::display_template(
387
+			EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_timezones.template.php',
388
+			$template_args,
389
+			true
390
+		);
391
+	}
392
+
393
+
394
+	/**
395
+	 * Sets the views for the default list table view.
396
+	 */
397
+	protected function _set_list_table_views_default()
398
+	{
399
+		parent::_set_list_table_views_default();
400
+		$new_views    = array(
401
+			'today' => array(
402
+				'slug'        => 'today',
403
+				'label'       => esc_html__('Today', 'event_espresso'),
404
+				'count'       => $this->total_events_today(),
405
+				'bulk_action' => array(
406
+					'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
407
+				),
408
+			),
409
+			'month' => array(
410
+				'slug'        => 'month',
411
+				'label'       => esc_html__('This Month', 'event_espresso'),
412
+				'count'       => $this->total_events_this_month(),
413
+				'bulk_action' => array(
414
+					'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
415
+				),
416
+			),
417
+		);
418
+		$this->_views = array_merge($this->_views, $new_views);
419
+	}
420
+
421
+
422
+	/**
423
+	 * Returns the extra action links for the default list table view.
424
+	 * @param array     $action_links
425
+	 * @param \EE_Event $event
426
+	 * @return array
427
+	 * @throws EE_Error
428
+	 */
429
+	public function extra_list_table_actions(array $action_links, \EE_Event $event)
430
+	{
431
+		if (EE_Registry::instance()->CAP->current_user_can(
432
+			'ee_read_registrations',
433
+			'espresso_registrations_reports',
434
+			$event->ID()
435
+		)
436
+		) {
437
+			$reports_query_args = array(
438
+				'action' => 'reports',
439
+				'EVT_ID' => $event->ID(),
440
+			);
441
+			$reports_link       = EE_Admin_Page::add_query_args_and_nonce($reports_query_args, REG_ADMIN_URL);
442
+			$action_links[]     = '<a href="'
443
+								  . $reports_link
444
+								  . '" title="'
445
+								  . esc_attr__('View Report', 'event_espresso')
446
+								  . '"><div class="dashicons dashicons-chart-bar"></div></a>'
447
+								  . "\n\t";
448
+		}
449
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
450
+			EE_Registry::instance()->load_helper('MSG_Template');
451
+			$action_links[] = EEH_MSG_Template::get_message_action_link(
452
+				'see_notifications_for',
453
+				null,
454
+				array('EVT_ID' => $event->ID())
455
+			);
456
+		}
457
+		return $action_links;
458
+	}
459
+
460
+
461
+	/**
462
+	 * @param $items
463
+	 * @return mixed
464
+	 */
465
+	public function additional_legend_items($items)
466
+	{
467
+		if (EE_Registry::instance()->CAP->current_user_can(
468
+			'ee_read_registrations',
469
+			'espresso_registrations_reports'
470
+		)
471
+		) {
472
+			$items['reports'] = array(
473
+				'class' => 'dashicons dashicons-chart-bar',
474
+				'desc'  => esc_html__('Event Reports', 'event_espresso'),
475
+			);
476
+		}
477
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
478
+			$related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
479
+			if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) {
480
+				$items['view_related_messages'] = array(
481
+					'class' => $related_for_icon['css_class'],
482
+					'desc'  => $related_for_icon['label'],
483
+				);
484
+			}
485
+		}
486
+		return $items;
487
+	}
488
+
489
+
490
+	/**
491
+	 * This is the callback method for the duplicate event route
492
+	 * Method looks for 'EVT_ID' in the request and retrieves that event and its details and duplicates them
493
+	 * into a new event.  We add a hook so that any plugins that add extra event details can hook into this
494
+	 * action.  Note that the dupe will have **DUPLICATE** as its title and slug.
495
+	 * After duplication the redirect is to the new event edit page.
496
+	 *
497
+	 * @return void
498
+	 * @access protected
499
+	 * @throws EE_Error If EE_Event is not available with given ID
500
+	 */
501
+	protected function _duplicate_event()
502
+	{
503
+		// first make sure the ID for the event is in the request.
504
+		//  If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?)
505
+		if (! isset($this->_req_data['EVT_ID'])) {
506
+			EE_Error::add_error(
507
+				esc_html__(
508
+					'In order to duplicate an event an Event ID is required.  None was given.',
509
+					'event_espresso'
510
+				),
511
+				__FILE__,
512
+				__FUNCTION__,
513
+				__LINE__
514
+			);
515
+			$this->_redirect_after_action(false, '', '', array(), true);
516
+			return;
517
+		}
518
+		//k we've got EVT_ID so let's use that to get the event we'll duplicate
519
+		$orig_event = EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']);
520
+		if (! $orig_event instanceof EE_Event) {
521
+			throw new EE_Error(
522
+				sprintf(
523
+					esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'),
524
+					$this->_req_data['EVT_ID']
525
+				)
526
+			);
527
+		}
528
+		//k now let's clone the $orig_event before getting relations
529
+		$new_event = clone $orig_event;
530
+		//original datetimes
531
+		$orig_datetimes = $orig_event->get_many_related('Datetime');
532
+		//other original relations
533
+		$orig_ven = $orig_event->get_many_related('Venue');
534
+		//reset the ID and modify other details to make it clear this is a dupe
535
+		$new_event->set('EVT_ID', 0);
536
+		$new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso');
537
+		$new_event->set('EVT_name', $new_name);
538
+		$new_event->set(
539
+			'EVT_slug',
540
+			wp_unique_post_slug(
541
+				sanitize_title($orig_event->name()),
542
+				0,
543
+				'publish',
544
+				'espresso_events',
545
+				0
546
+			)
547
+		);
548
+		$new_event->set('status', 'draft');
549
+		//duplicate discussion settings
550
+		$new_event->set('comment_status', $orig_event->get('comment_status'));
551
+		$new_event->set('ping_status', $orig_event->get('ping_status'));
552
+		//save the new event
553
+		$new_event->save();
554
+		//venues
555
+		foreach ($orig_ven as $ven) {
556
+			$new_event->_add_relation_to($ven, 'Venue');
557
+		}
558
+		$new_event->save();
559
+		//now we need to get the question group relations and handle that
560
+		//first primary question groups
561
+		$orig_primary_qgs = $orig_event->get_many_related(
562
+			'Question_Group',
563
+			array(array('Event_Question_Group.EQG_primary' => 1))
564
+		);
565
+		if (! empty($orig_primary_qgs)) {
566
+			foreach ($orig_primary_qgs as $id => $obj) {
567
+				if ($obj instanceof EE_Question_Group) {
568
+					$new_event->_add_relation_to($obj, 'Question_Group', array('EQG_primary' => 1));
569
+				}
570
+			}
571
+		}
572
+		//next additional attendee question groups
573
+		$orig_additional_qgs = $orig_event->get_many_related(
574
+			'Question_Group',
575
+			array(array('Event_Question_Group.EQG_primary' => 0))
576
+		);
577
+		if (! empty($orig_additional_qgs)) {
578
+			foreach ($orig_additional_qgs as $id => $obj) {
579
+				if ($obj instanceof EE_Question_Group) {
580
+					$new_event->_add_relation_to($obj, 'Question_Group', array('EQG_primary' => 0));
581
+				}
582
+			}
583
+		}
584
+
585
+		$new_event->save();
586
+
587
+		//k now that we have the new event saved we can loop through the datetimes and start adding relations.
588
+		$cloned_tickets = array();
589
+		foreach ($orig_datetimes as $orig_dtt) {
590
+			if (! $orig_dtt instanceof EE_Datetime) {
591
+				continue;
592
+			}
593
+			$new_dtt   = clone $orig_dtt;
594
+			$orig_tkts = $orig_dtt->tickets();
595
+			//save new dtt then add to event
596
+			$new_dtt->set('DTT_ID', 0);
597
+			$new_dtt->set('DTT_sold', 0);
598
+			$new_dtt->set_reserved(0);
599
+			$new_dtt->save();
600
+			$new_event->_add_relation_to($new_dtt, 'Datetime');
601
+			$new_event->save();
602
+			//now let's get the ticket relations setup.
603
+			foreach ((array)$orig_tkts as $orig_tkt) {
604
+				//it's possible a datetime will have no tickets so let's verify we HAVE a ticket first.
605
+				if (! $orig_tkt instanceof EE_Ticket) {
606
+					continue;
607
+				}
608
+				//is this ticket archived?  If it is then let's skip
609
+				if ($orig_tkt->get('TKT_deleted')) {
610
+					continue;
611
+				}
612
+				// does this original ticket already exist in the clone_tickets cache?
613
+				//  If so we'll just use the new ticket from it.
614
+				if (isset($cloned_tickets[$orig_tkt->ID()])) {
615
+					$new_tkt = $cloned_tickets[$orig_tkt->ID()];
616
+				} else {
617
+					$new_tkt = clone $orig_tkt;
618
+					//get relations on the $orig_tkt that we need to setup.
619
+					$orig_prices = $orig_tkt->prices();
620
+					$new_tkt->set('TKT_ID', 0);
621
+					$new_tkt->set('TKT_sold', 0);
622
+					$new_tkt->set('TKT_reserved', 0);
623
+					$new_tkt->save(); //make sure new ticket has ID.
624
+					//price relations on new ticket need to be setup.
625
+					foreach ($orig_prices as $orig_price) {
626
+						$new_price = clone $orig_price;
627
+						$new_price->set('PRC_ID', 0);
628
+						$new_price->save();
629
+						$new_tkt->_add_relation_to($new_price, 'Price');
630
+						$new_tkt->save();
631
+					}
632
+
633
+					do_action(
634
+						'AHEE__Extend_Events_Admin_Page___duplicate_event__duplicate_ticket__after',
635
+						$orig_tkt,
636
+						$new_tkt,
637
+						$orig_prices,
638
+						$orig_event,
639
+						$orig_dtt,
640
+						$new_dtt
641
+					);
642
+				}
643
+				// k now we can add the new ticket as a relation to the new datetime
644
+				// and make sure its added to our cached $cloned_tickets array
645
+				// for use with later datetimes that have the same ticket.
646
+				$new_dtt->_add_relation_to($new_tkt, 'Ticket');
647
+				$new_dtt->save();
648
+				$cloned_tickets[$orig_tkt->ID()] = $new_tkt;
649
+			}
650
+		}
651
+		//clone taxonomy information
652
+		$taxonomies_to_clone_with = apply_filters(
653
+			'FHEE__Extend_Events_Admin_Page___duplicate_event__taxonomies_to_clone',
654
+			array('espresso_event_categories', 'espresso_event_type', 'post_tag')
655
+		);
656
+		//get terms for original event (notice)
657
+		$orig_terms = wp_get_object_terms($orig_event->ID(), $taxonomies_to_clone_with);
658
+		//loop through terms and add them to new event.
659
+		foreach ($orig_terms as $term) {
660
+			wp_set_object_terms($new_event->ID(), $term->term_id, $term->taxonomy, true);
661
+		}
662
+
663
+		//duplicate other core WP_Post items for this event.
664
+		//post thumbnail (feature image).
665
+		$feature_image_id = get_post_thumbnail_id($orig_event->ID());
666
+		if ($feature_image_id) {
667
+			update_post_meta($new_event->ID(), '_thumbnail_id', $feature_image_id);
668
+		}
669
+
670
+		//duplicate page_template setting
671
+		$page_template = get_post_meta($orig_event->ID(), '_wp_page_template', true);
672
+		if ($page_template) {
673
+			update_post_meta($new_event->ID(), '_wp_page_template', $page_template);
674
+		}
675
+
676
+		do_action('AHEE__Extend_Events_Admin_Page___duplicate_event__after', $new_event, $orig_event);
677
+		//now let's redirect to the edit page for this duplicated event if we have a new event id.
678
+		if ($new_event->ID()) {
679
+			$redirect_args = array(
680
+				'post'   => $new_event->ID(),
681
+				'action' => 'edit',
682
+			);
683
+			EE_Error::add_success(
684
+				esc_html__(
685
+					'Event successfully duplicated.  Please review the details below and make any necessary edits',
686
+					'event_espresso'
687
+				)
688
+			);
689
+		} else {
690
+			$redirect_args = array(
691
+				'action' => 'default',
692
+			);
693
+			EE_Error::add_error(
694
+				esc_html__('Not able to duplicate event.  Something went wrong.', 'event_espresso'),
695
+				__FILE__,
696
+				__FUNCTION__,
697
+				__LINE__
698
+			);
699
+		}
700
+		$this->_redirect_after_action(false, '', '', $redirect_args, true);
701
+	}
702
+
703
+
704
+	/**
705
+	 * Generates output for the import page.
706
+	 * @throws DomainException
707
+	 */
708
+	protected function _import_page()
709
+	{
710
+		$title                                      = esc_html__('Import', 'event_espresso');
711
+		$intro                                      = esc_html__(
712
+			'If you have a previously exported Event Espresso 4 information in a Comma Separated Value (CSV) file format, you can upload the file here: ',
713
+			'event_espresso'
714
+		);
715
+		$form_url                                   = EVENTS_ADMIN_URL;
716
+		$action                                     = 'import_events';
717
+		$type                                       = 'csv';
718
+		$this->_template_args['form']               = EE_Import::instance()->upload_form(
719
+			$title, $intro, $form_url, $action, $type
720
+		);
721
+		$this->_template_args['sample_file_link']   = EE_Admin_Page::add_query_args_and_nonce(
722
+			array('action' => 'sample_export_file'),
723
+			$this->_admin_base_url
724
+		);
725
+		$content                                    = EEH_Template::display_template(
726
+			EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php',
727
+			$this->_template_args,
728
+			true
729
+		);
730
+		$this->_template_args['admin_page_content'] = $content;
731
+		$this->display_admin_page_with_sidebar();
732
+	}
733
+
734
+
735
+	/**
736
+	 * _import_events
737
+	 * This handles displaying the screen and running imports for importing events.
738
+	 *
739
+	 * @return void
740
+	 */
741
+	protected function _import_events()
742
+	{
743
+		require_once(EE_CLASSES . 'EE_Import.class.php');
744
+		$success = EE_Import::instance()->import();
745
+		$this->_redirect_after_action($success, 'Import File', 'ran', array('action' => 'import_page'), true);
746
+	}
747
+
748
+
749
+	/**
750
+	 * _events_export
751
+	 * Will export all (or just the given event) to a Excel compatible file.
752
+	 *
753
+	 * @access protected
754
+	 * @return void
755
+	 */
756
+	protected function _events_export()
757
+	{
758
+		if (isset($this->_req_data['EVT_ID'])) {
759
+			$event_ids = $this->_req_data['EVT_ID'];
760
+		} elseif (isset($this->_req_data['EVT_IDs'])) {
761
+			$event_ids = $this->_req_data['EVT_IDs'];
762
+		} else {
763
+			$event_ids = null;
764
+		}
765
+		//todo: I don't like doing this but it'll do until we modify EE_Export Class.
766
+		$new_request_args = array(
767
+			'export' => 'report',
768
+			'action' => 'all_event_data',
769
+			'EVT_ID' => $event_ids,
770
+		);
771
+		$this->_req_data  = array_merge($this->_req_data, $new_request_args);
772
+		if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
773
+			require_once(EE_CLASSES . 'EE_Export.class.php');
774
+			$EE_Export = EE_Export::instance($this->_req_data);
775
+			$EE_Export->export();
776
+		}
777
+	}
778
+
779
+
780
+	/**
781
+	 * handle category exports()
782
+	 *
783
+	 * @return void
784
+	 */
785
+	protected function _categories_export()
786
+	{
787
+		//todo: I don't like doing this but it'll do until we modify EE_Export Class.
788
+		$new_request_args = array(
789
+			'export'       => 'report',
790
+			'action'       => 'categories',
791
+			'category_ids' => $this->_req_data['EVT_CAT_ID'],
792
+		);
793
+		$this->_req_data  = array_merge($this->_req_data, $new_request_args);
794
+		if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
795
+			require_once(EE_CLASSES . 'EE_Export.class.php');
796
+			$EE_Export = EE_Export::instance($this->_req_data);
797
+			$EE_Export->export();
798
+		}
799
+	}
800
+
801
+
802
+	/**
803
+	 * Creates a sample CSV file for importing
804
+	 */
805
+	protected function _sample_export_file()
806
+	{
807
+		//		require_once(EE_CLASSES . 'EE_Export.class.php');
808
+		EE_Export::instance()->export_sample();
809
+	}
810
+
811
+
812
+	/*************        Template Settings        *************/
813
+	/**
814
+	 * Generates template settings page output
815
+	 * @throws DomainException
816
+	 * @throws EE_Error
817
+	 */
818
+	protected function _template_settings()
819
+	{
820
+		$this->_template_args['values'] = $this->_yes_no_values;
821
+		/**
822
+		 * Note leaving this filter in for backward compatibility this was moved in 4.6.x
823
+		 * from General_Settings_Admin_Page to here.
824
+		 */
825
+		$this->_template_args = apply_filters(
826
+			'FHEE__General_Settings_Admin_Page__template_settings__template_args',
827
+			$this->_template_args
828
+		);
829
+		$this->_set_add_edit_form_tags('update_template_settings');
830
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
831
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
832
+			EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php',
833
+			$this->_template_args,
834
+			true
835
+		);
836
+		$this->display_admin_page_with_sidebar();
837
+	}
838
+
839
+
840
+	/**
841
+	 * Handler for updating template settings.
842
+	 *
843
+	 * @throws InvalidInterfaceException
844
+	 * @throws InvalidDataTypeException
845
+	 * @throws InvalidArgumentException
846
+	 */
847
+	protected function _update_template_settings()
848
+	{
849
+		/**
850
+		 * Note leaving this filter in for backward compatibility this was moved in 4.6.x
851
+		 * from General_Settings_Admin_Page to here.
852
+		 */
853
+		EE_Registry::instance()->CFG->template_settings = apply_filters(
854
+			'FHEE__General_Settings_Admin_Page__update_template_settings__data',
855
+			EE_Registry::instance()->CFG->template_settings,
856
+			$this->_req_data
857
+		);
858
+		//update custom post type slugs and detect if we need to flush rewrite rules
859
+		$old_slug                                          = EE_Registry::instance()->CFG->core->event_cpt_slug;
860
+		EE_Registry::instance()->CFG->core->event_cpt_slug = empty($this->_req_data['event_cpt_slug'])
861
+			? EE_Registry::instance()->CFG->core->event_cpt_slug
862
+			: sanitize_title_with_dashes($this->_req_data['event_cpt_slug']);
863
+		$what                                              = 'Template Settings';
864
+		$success                                           = $this->_update_espresso_configuration(
865
+			$what,
866
+			EE_Registry::instance()->CFG->template_settings,
867
+			__FILE__,
868
+			__FUNCTION__,
869
+			__LINE__
870
+		);
871
+		if (EE_Registry::instance()->CFG->core->event_cpt_slug != $old_slug) {
872
+			/** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */
873
+			$rewrite_rules =  LoaderFactory::getLoader()->getShared(
874
+				'EventEspresso\core\domain\services\custom_post_types\RewriteRules'
875
+			);
876
+			$rewrite_rules->flush();
877
+		}
878
+		$this->_redirect_after_action($success, $what, 'updated', array('action' => 'template_settings'));
879
+	}
880
+
881
+
882
+	/**
883
+	 * _premium_event_editor_meta_boxes
884
+	 * add all metaboxes related to the event_editor
885
+	 *
886
+	 * @access protected
887
+	 * @return void
888
+	 * @throws EE_Error
889
+	 */
890
+	protected function _premium_event_editor_meta_boxes()
891
+	{
892
+		$this->verify_cpt_object();
893
+		add_meta_box(
894
+			'espresso_event_editor_event_options',
895
+			esc_html__('Event Registration Options', 'event_espresso'),
896
+			array($this, 'registration_options_meta_box'),
897
+			$this->page_slug,
898
+			'side',
899
+			'core'
900
+		);
901
+	}
902
+
903
+
904
+	/**
905
+	 * override caf metabox
906
+	 *
907
+	 * @return void
908
+	 * @throws DomainException
909
+	 */
910
+	public function registration_options_meta_box()
911
+	{
912
+		$yes_no_values                                    = array(
913
+			array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')),
914
+			array('id' => false, 'text' => esc_html__('No', 'event_espresso')),
915
+		);
916
+		$default_reg_status_values                        = EEM_Registration::reg_status_array(
917
+			array(
918
+				EEM_Registration::status_id_cancelled,
919
+				EEM_Registration::status_id_declined,
920
+				EEM_Registration::status_id_incomplete,
921
+				EEM_Registration::status_id_wait_list,
922
+			),
923
+			true
924
+		);
925
+		$template_args['active_status']                   = $this->_cpt_model_obj->pretty_active_status(false);
926
+		$template_args['_event']                          = $this->_cpt_model_obj;
927
+		$template_args['additional_limit']                = $this->_cpt_model_obj->additional_limit();
928
+		$template_args['default_registration_status']     = EEH_Form_Fields::select_input(
929
+			'default_reg_status',
930
+			$default_reg_status_values,
931
+			$this->_cpt_model_obj->default_registration_status()
932
+		);
933
+		$template_args['display_description']             = EEH_Form_Fields::select_input(
934
+			'display_desc',
935
+			$yes_no_values,
936
+			$this->_cpt_model_obj->display_description()
937
+		);
938
+		$template_args['display_ticket_selector']         = EEH_Form_Fields::select_input(
939
+			'display_ticket_selector',
940
+			$yes_no_values,
941
+			$this->_cpt_model_obj->display_ticket_selector(),
942
+			'',
943
+			'',
944
+			false
945
+		);
946
+		$template_args['EVT_default_registration_status'] = EEH_Form_Fields::select_input(
947
+			'EVT_default_registration_status',
948
+			$default_reg_status_values,
949
+			$this->_cpt_model_obj->default_registration_status()
950
+		);
951
+		$template_args['additional_registration_options'] = apply_filters(
952
+			'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options',
953
+			'',
954
+			$template_args,
955
+			$yes_no_values,
956
+			$default_reg_status_values
957
+		);
958
+		EEH_Template::display_template(
959
+			EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php',
960
+			$template_args
961
+		);
962
+	}
963
+
964
+
965
+
966
+	/**
967
+	 * wp_list_table_mods for caf
968
+	 * ============================
969
+	 */
970
+	/**
971
+	 * hook into list table filters and provide filters for caffeinated list table
972
+	 *
973
+	 * @param  array $old_filters    any existing filters present
974
+	 * @param  array $list_table_obj the list table object
975
+	 * @return array                  new filters
976
+	 */
977
+	public function list_table_filters($old_filters, $list_table_obj)
978
+	{
979
+		$filters = array();
980
+		//first month/year filters
981
+		$filters[] = $this->espresso_event_months_dropdown();
982
+		$status    = isset($this->_req_data['status']) ? $this->_req_data['status'] : null;
983
+		//active status dropdown
984
+		if ($status !== 'draft') {
985
+			$filters[] = $this->active_status_dropdown(
986
+				isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : ''
987
+			);
988
+		}
989
+		//category filter
990
+		$filters[] = $this->category_dropdown();
991
+		return array_merge($old_filters, $filters);
992
+	}
993
+
994
+
995
+	/**
996
+	 * espresso_event_months_dropdown
997
+	 *
998
+	 * @access public
999
+	 * @return string                dropdown listing month/year selections for events.
1000
+	 */
1001
+	public function espresso_event_months_dropdown()
1002
+	{
1003
+		// what we need to do is get all PRIMARY datetimes for all events to filter on.
1004
+		// Note we need to include any other filters that are set!
1005
+		$status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null;
1006
+		//categories?
1007
+		$category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0
1008
+			? $this->_req_data['EVT_CAT']
1009
+			: null;
1010
+		//active status?
1011
+		$active_status = isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : null;
1012
+		$cur_date      = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : '';
1013
+		return EEH_Form_Fields::generate_event_months_dropdown($cur_date, $status, $category, $active_status);
1014
+	}
1015
+
1016
+
1017
+	/**
1018
+	 * returns a list of "active" statuses on the event
1019
+	 *
1020
+	 * @param  string $current_value whatever the current active status is
1021
+	 * @return string
1022
+	 */
1023
+	public function active_status_dropdown($current_value = '')
1024
+	{
1025
+		$select_name = 'active_status';
1026
+		$values      = array(
1027
+			'none'     => esc_html__('Show Active/Inactive', 'event_espresso'),
1028
+			'active'   => esc_html__('Active', 'event_espresso'),
1029
+			'upcoming' => esc_html__('Upcoming', 'event_espresso'),
1030
+			'expired'  => esc_html__('Expired', 'event_espresso'),
1031
+			'inactive' => esc_html__('Inactive', 'event_espresso'),
1032
+		);
1033
+		$id          = 'id="espresso-active-status-dropdown-filter"';
1034
+		$class       = 'wide';
1035
+		return EEH_Form_Fields::select_input($select_name, $values, $current_value, $id, $class);
1036
+	}
1037
+
1038
+
1039
+	/**
1040
+	 * output a dropdown of the categories for the category filter on the event admin list table
1041
+	 *
1042
+	 * @access  public
1043
+	 * @return string html
1044
+	 */
1045
+	public function category_dropdown()
1046
+	{
1047
+		$cur_cat = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1;
1048
+		return EEH_Form_Fields::generate_event_category_dropdown($cur_cat);
1049
+	}
1050
+
1051
+
1052
+	/**
1053
+	 * get total number of events today
1054
+	 *
1055
+	 * @access public
1056
+	 * @return int
1057
+	 * @throws EE_Error
1058
+	 */
1059
+	public function total_events_today()
1060
+	{
1061
+		$start = EEM_Datetime::instance()->convert_datetime_for_query(
1062
+			'DTT_EVT_start',
1063
+			date('Y-m-d') . ' 00:00:00',
1064
+			'Y-m-d H:i:s',
1065
+			'UTC'
1066
+		);
1067
+		$end   = EEM_Datetime::instance()->convert_datetime_for_query(
1068
+			'DTT_EVT_start',
1069
+			date('Y-m-d') . ' 23:59:59',
1070
+			'Y-m-d H:i:s',
1071
+			'UTC'
1072
+		);
1073
+		$where = array(
1074
+			'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)),
1075
+		);
1076
+		$count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
1077
+		return $count;
1078
+	}
1079
+
1080
+
1081
+	/**
1082
+	 * get total number of events this month
1083
+	 *
1084
+	 * @access public
1085
+	 * @return int
1086
+	 * @throws EE_Error
1087
+	 */
1088
+	public function total_events_this_month()
1089
+	{
1090
+		//Dates
1091
+		$this_year_r     = date('Y');
1092
+		$this_month_r    = date('m');
1093
+		$days_this_month = date('t');
1094
+		$start           = EEM_Datetime::instance()->convert_datetime_for_query(
1095
+			'DTT_EVT_start',
1096
+			$this_year_r . '-' . $this_month_r . '-01 00:00:00',
1097
+			'Y-m-d H:i:s',
1098
+			'UTC'
1099
+		);
1100
+		$end             = EEM_Datetime::instance()->convert_datetime_for_query(
1101
+			'DTT_EVT_start',
1102
+			$this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59',
1103
+			'Y-m-d H:i:s',
1104
+			'UTC'
1105
+		);
1106
+		$where           = array(
1107
+			'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)),
1108
+		);
1109
+		$count           = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
1110
+		return $count;
1111
+	}
1112
+
1113
+
1114
+	/** DEFAULT TICKETS STUFF **/
1115
+
1116
+	/**
1117
+	 * Output default tickets list table view.
1118
+	 */
1119
+	public function _tickets_overview_list_table()
1120
+	{
1121
+		$this->_search_btn_label = esc_html__('Tickets', 'event_espresso');
1122
+		$this->display_admin_list_table_page_with_no_sidebar();
1123
+	}
1124
+
1125
+
1126
+	/**
1127
+	 * @param int  $per_page
1128
+	 * @param bool $count
1129
+	 * @param bool $trashed
1130
+	 * @return \EE_Soft_Delete_Base_Class[]|int
1131
+	 */
1132
+	public function get_default_tickets($per_page = 10, $count = false, $trashed = false)
1133
+	{
1134
+		$orderby = empty($this->_req_data['orderby']) ? 'TKT_name' : $this->_req_data['orderby'];
1135
+		$order   = empty($this->_req_data['order']) ? 'ASC' : $this->_req_data['order'];
1136
+		switch ($orderby) {
1137
+			case 'TKT_name':
1138
+				$orderby = array('TKT_name' => $order);
1139
+				break;
1140
+			case 'TKT_price':
1141
+				$orderby = array('TKT_price' => $order);
1142
+				break;
1143
+			case 'TKT_uses':
1144
+				$orderby = array('TKT_uses' => $order);
1145
+				break;
1146
+			case 'TKT_min':
1147
+				$orderby = array('TKT_min' => $order);
1148
+				break;
1149
+			case 'TKT_max':
1150
+				$orderby = array('TKT_max' => $order);
1151
+				break;
1152
+			case 'TKT_qty':
1153
+				$orderby = array('TKT_qty' => $order);
1154
+				break;
1155
+		}
1156
+		$current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged'])
1157
+			? $this->_req_data['paged']
1158
+			: 1;
1159
+		$per_page     = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage'])
1160
+			? $this->_req_data['perpage']
1161
+			: $per_page;
1162
+		$_where       = array(
1163
+			'TKT_is_default' => 1,
1164
+			'TKT_deleted'    => $trashed,
1165
+		);
1166
+		$offset       = ($current_page - 1) * $per_page;
1167
+		$limit        = array($offset, $per_page);
1168
+		if (isset($this->_req_data['s'])) {
1169
+			$sstr         = '%' . $this->_req_data['s'] . '%';
1170
+			$_where['OR'] = array(
1171
+				'TKT_name'        => array('LIKE', $sstr),
1172
+				'TKT_description' => array('LIKE', $sstr),
1173
+			);
1174
+		}
1175
+		$query_params = array(
1176
+			$_where,
1177
+			'order_by' => $orderby,
1178
+			'limit'    => $limit,
1179
+			'group_by' => 'TKT_ID',
1180
+		);
1181
+		if ($count) {
1182
+			return EEM_Ticket::instance()->count_deleted_and_undeleted(array($_where));
1183
+		} else {
1184
+			return EEM_Ticket::instance()->get_all_deleted_and_undeleted($query_params);
1185
+		}
1186
+	}
1187
+
1188
+
1189
+	/**
1190
+	 * @param bool $trash
1191
+	 * @throws EE_Error
1192
+	 */
1193
+	protected function _trash_or_restore_ticket($trash = false)
1194
+	{
1195
+		$success = 1;
1196
+		$TKT     = EEM_Ticket::instance();
1197
+		//checkboxes?
1198
+		if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1199
+			//if array has more than one element then success message should be plural
1200
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1201
+			//cycle thru the boxes
1202
+			while (list($TKT_ID, $value) = each($this->_req_data['checkbox'])) {
1203
+				if ($trash) {
1204
+					if (! $TKT->delete_by_ID($TKT_ID)) {
1205
+						$success = 0;
1206
+					}
1207
+				} else {
1208
+					if (! $TKT->restore_by_ID($TKT_ID)) {
1209
+						$success = 0;
1210
+					}
1211
+				}
1212
+			}
1213
+		} else {
1214
+			//grab single id and trash
1215
+			$TKT_ID = absint($this->_req_data['TKT_ID']);
1216
+			if ($trash) {
1217
+				if (! $TKT->delete_by_ID($TKT_ID)) {
1218
+					$success = 0;
1219
+				}
1220
+			} else {
1221
+				if (! $TKT->restore_by_ID($TKT_ID)) {
1222
+					$success = 0;
1223
+				}
1224
+			}
1225
+		}
1226
+		$action_desc = $trash ? 'moved to the trash' : 'restored';
1227
+		$query_args  = array(
1228
+			'action' => 'ticket_list_table',
1229
+			'status' => $trash ? '' : 'trashed',
1230
+		);
1231
+		$this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args);
1232
+	}
1233
+
1234
+
1235
+	/**
1236
+	 * Handles trashing default ticket.
1237
+	 */
1238
+	protected function _delete_ticket()
1239
+	{
1240
+		$success = 1;
1241
+		//checkboxes?
1242
+		if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1243
+			//if array has more than one element then success message should be plural
1244
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1245
+			//cycle thru the boxes
1246
+			while (list($TKT_ID, $value) = each($this->_req_data['checkbox'])) {
1247
+				//delete
1248
+				if (! $this->_delete_the_ticket($TKT_ID)) {
1249
+					$success = 0;
1250
+				}
1251
+			}
1252
+		} else {
1253
+			//grab single id and trash
1254
+			$TKT_ID = absint($this->_req_data['TKT_ID']);
1255
+			if (! $this->_delete_the_ticket($TKT_ID)) {
1256
+				$success = 0;
1257
+			}
1258
+		}
1259
+		$action_desc = 'deleted';
1260
+		$query_args  = array(
1261
+			'action' => 'ticket_list_table',
1262
+			'status' => 'trashed',
1263
+		);
1264
+		//fail safe.  If the default ticket count === 1 then we need to redirect to event overview.
1265
+		if (EEM_Ticket::instance()->count_deleted_and_undeleted(
1266
+			array(array('TKT_is_default' => 1)),
1267
+			'TKT_ID',
1268
+			true
1269
+		)
1270
+		) {
1271
+			$query_args = array();
1272
+		}
1273
+		$this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args);
1274
+	}
1275
+
1276
+
1277
+	/**
1278
+	 * @param int $TKT_ID
1279
+	 * @return bool|int
1280
+	 * @throws EE_Error
1281
+	 */
1282
+	protected function _delete_the_ticket($TKT_ID)
1283
+	{
1284
+		$tkt = EEM_Ticket::instance()->get_one_by_ID($TKT_ID);
1285
+		$tkt->_remove_relations('Datetime');
1286
+		//delete all related prices first
1287
+		$tkt->delete_related_permanently('Price');
1288
+		return $tkt->delete_permanently();
1289
+	}
1290 1290
 }
Please login to merge, or discard this patch.
Spacing   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -27,10 +27,10 @@  discard block
 block discarded – undo
27 27
     public function __construct($routing = true)
28 28
     {
29 29
         parent::__construct($routing);
30
-        if (! defined('EVENTS_CAF_TEMPLATE_PATH')) {
31
-            define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/');
32
-            define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/');
33
-            define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/');
30
+        if ( ! defined('EVENTS_CAF_TEMPLATE_PATH')) {
31
+            define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'events/templates/');
32
+            define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND.'events/assets/');
33
+            define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'events/assets/');
34 34
         }
35 35
     }
36 36
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
      */
41 41
     protected function _extend_page_config()
42 42
     {
43
-        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events';
43
+        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'events';
44 44
         //is there a evt_id in the request?
45 45
         $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID'])
46 46
             ? $this->_req_data['EVT_ID']
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
             'help_tour'     => array('Templates_Help_Tour'),
174 174
             'require_nonce' => false,
175 175
         );
176
-        $this->_page_config                   = array_merge($this->_page_config, $new_page_config);
176
+        $this->_page_config = array_merge($this->_page_config, $new_page_config);
177 177
         //add filters and actions
178 178
         //modifying _views
179 179
         add_filter(
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
          * check whether count of tickets is approaching the potential
247 247
          * limits for the server.
248 248
          */
249
-        if (! empty($data['input_count'])) {
249
+        if ( ! empty($data['input_count'])) {
250 250
             $response['max_input_vars_check'] = EE_Registry::instance()->CFG->environment->max_input_vars_limit_check(
251 251
                 $data['input_count']
252 252
             );
@@ -275,12 +275,12 @@  discard block
 block discarded – undo
275 275
     {
276 276
         $return = parent::extra_permalink_field_buttons($return, $id, $new_title, $new_slug);
277 277
         //make sure this is only when editing
278
-        if (! empty($id)) {
279
-            $href   = EE_Admin_Page::add_query_args_and_nonce(
278
+        if ( ! empty($id)) {
279
+            $href = EE_Admin_Page::add_query_args_and_nonce(
280 280
                 array('action' => 'duplicate_event', 'EVT_ID' => $id),
281 281
                 $this->_admin_base_url
282 282
             );
283
-            $title  = esc_attr__('Duplicate Event', 'event_espresso');
283
+            $title = esc_attr__('Duplicate Event', 'event_espresso');
284 284
             $return .= '<a href="'
285 285
                        . $href
286 286
                        . '" title="'
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
     {
328 328
         wp_register_script(
329 329
             'ee-event-editor-heartbeat',
330
-            EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js',
330
+            EVENTS_CAF_ASSETS_URL.'event-editor-heartbeat.js',
331 331
             array('ee_admin_js', 'heartbeat'),
332 332
             EVENT_ESPRESSO_VERSION,
333 333
             true
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
     public function add_additional_datetime_button($template, $template_args)
351 351
     {
352 352
         return EEH_Template::display_template(
353
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_add_additional_time.template.php',
353
+            EVENTS_CAF_TEMPLATE_PATH.'event_datetime_add_additional_time.template.php',
354 354
             $template_args,
355 355
             true
356 356
         );
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
     public function add_datetime_clone_button($template, $template_args)
368 368
     {
369 369
         return EEH_Template::display_template(
370
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_metabox_clone_button.template.php',
370
+            EVENTS_CAF_TEMPLATE_PATH.'event_datetime_metabox_clone_button.template.php',
371 371
             $template_args,
372 372
             true
373 373
         );
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
     public function datetime_timezones_template($template, $template_args)
385 385
     {
386 386
         return EEH_Template::display_template(
387
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_timezones.template.php',
387
+            EVENTS_CAF_TEMPLATE_PATH.'event_datetime_timezones.template.php',
388 388
             $template_args,
389 389
             true
390 390
         );
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
     protected function _set_list_table_views_default()
398 398
     {
399 399
         parent::_set_list_table_views_default();
400
-        $new_views    = array(
400
+        $new_views = array(
401 401
             'today' => array(
402 402
                 'slug'        => 'today',
403 403
                 'label'       => esc_html__('Today', 'event_espresso'),
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
     {
503 503
         // first make sure the ID for the event is in the request.
504 504
         //  If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?)
505
-        if (! isset($this->_req_data['EVT_ID'])) {
505
+        if ( ! isset($this->_req_data['EVT_ID'])) {
506 506
             EE_Error::add_error(
507 507
                 esc_html__(
508 508
                     'In order to duplicate an event an Event ID is required.  None was given.',
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
         }
518 518
         //k we've got EVT_ID so let's use that to get the event we'll duplicate
519 519
         $orig_event = EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']);
520
-        if (! $orig_event instanceof EE_Event) {
520
+        if ( ! $orig_event instanceof EE_Event) {
521 521
             throw new EE_Error(
522 522
                 sprintf(
523 523
                     esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'),
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
         $orig_ven = $orig_event->get_many_related('Venue');
534 534
         //reset the ID and modify other details to make it clear this is a dupe
535 535
         $new_event->set('EVT_ID', 0);
536
-        $new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso');
536
+        $new_name = $new_event->name().' '.esc_html__('**DUPLICATE**', 'event_espresso');
537 537
         $new_event->set('EVT_name', $new_name);
538 538
         $new_event->set(
539 539
             'EVT_slug',
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
             'Question_Group',
563 563
             array(array('Event_Question_Group.EQG_primary' => 1))
564 564
         );
565
-        if (! empty($orig_primary_qgs)) {
565
+        if ( ! empty($orig_primary_qgs)) {
566 566
             foreach ($orig_primary_qgs as $id => $obj) {
567 567
                 if ($obj instanceof EE_Question_Group) {
568 568
                     $new_event->_add_relation_to($obj, 'Question_Group', array('EQG_primary' => 1));
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
             'Question_Group',
575 575
             array(array('Event_Question_Group.EQG_primary' => 0))
576 576
         );
577
-        if (! empty($orig_additional_qgs)) {
577
+        if ( ! empty($orig_additional_qgs)) {
578 578
             foreach ($orig_additional_qgs as $id => $obj) {
579 579
                 if ($obj instanceof EE_Question_Group) {
580 580
                     $new_event->_add_relation_to($obj, 'Question_Group', array('EQG_primary' => 0));
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
         //k now that we have the new event saved we can loop through the datetimes and start adding relations.
588 588
         $cloned_tickets = array();
589 589
         foreach ($orig_datetimes as $orig_dtt) {
590
-            if (! $orig_dtt instanceof EE_Datetime) {
590
+            if ( ! $orig_dtt instanceof EE_Datetime) {
591 591
                 continue;
592 592
             }
593 593
             $new_dtt   = clone $orig_dtt;
@@ -600,9 +600,9 @@  discard block
 block discarded – undo
600 600
             $new_event->_add_relation_to($new_dtt, 'Datetime');
601 601
             $new_event->save();
602 602
             //now let's get the ticket relations setup.
603
-            foreach ((array)$orig_tkts as $orig_tkt) {
603
+            foreach ((array) $orig_tkts as $orig_tkt) {
604 604
                 //it's possible a datetime will have no tickets so let's verify we HAVE a ticket first.
605
-                if (! $orig_tkt instanceof EE_Ticket) {
605
+                if ( ! $orig_tkt instanceof EE_Ticket) {
606 606
                     continue;
607 607
                 }
608 608
                 //is this ticket archived?  If it is then let's skip
@@ -722,8 +722,8 @@  discard block
 block discarded – undo
722 722
             array('action' => 'sample_export_file'),
723 723
             $this->_admin_base_url
724 724
         );
725
-        $content                                    = EEH_Template::display_template(
726
-            EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php',
725
+        $content = EEH_Template::display_template(
726
+            EVENTS_CAF_TEMPLATE_PATH.'import_page.template.php',
727 727
             $this->_template_args,
728 728
             true
729 729
         );
@@ -740,7 +740,7 @@  discard block
 block discarded – undo
740 740
      */
741 741
     protected function _import_events()
742 742
     {
743
-        require_once(EE_CLASSES . 'EE_Import.class.php');
743
+        require_once(EE_CLASSES.'EE_Import.class.php');
744 744
         $success = EE_Import::instance()->import();
745 745
         $this->_redirect_after_action($success, 'Import File', 'ran', array('action' => 'import_page'), true);
746 746
     }
@@ -768,9 +768,9 @@  discard block
 block discarded – undo
768 768
             'action' => 'all_event_data',
769 769
             'EVT_ID' => $event_ids,
770 770
         );
771
-        $this->_req_data  = array_merge($this->_req_data, $new_request_args);
772
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
773
-            require_once(EE_CLASSES . 'EE_Export.class.php');
771
+        $this->_req_data = array_merge($this->_req_data, $new_request_args);
772
+        if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
773
+            require_once(EE_CLASSES.'EE_Export.class.php');
774 774
             $EE_Export = EE_Export::instance($this->_req_data);
775 775
             $EE_Export->export();
776 776
         }
@@ -790,9 +790,9 @@  discard block
 block discarded – undo
790 790
             'action'       => 'categories',
791 791
             'category_ids' => $this->_req_data['EVT_CAT_ID'],
792 792
         );
793
-        $this->_req_data  = array_merge($this->_req_data, $new_request_args);
794
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
795
-            require_once(EE_CLASSES . 'EE_Export.class.php');
793
+        $this->_req_data = array_merge($this->_req_data, $new_request_args);
794
+        if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
795
+            require_once(EE_CLASSES.'EE_Export.class.php');
796 796
             $EE_Export = EE_Export::instance($this->_req_data);
797 797
             $EE_Export->export();
798 798
         }
@@ -829,7 +829,7 @@  discard block
 block discarded – undo
829 829
         $this->_set_add_edit_form_tags('update_template_settings');
830 830
         $this->_set_publish_post_box_vars(null, false, false, null, false);
831 831
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
832
-            EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php',
832
+            EVENTS_CAF_TEMPLATE_PATH.'template_settings.template.php',
833 833
             $this->_template_args,
834 834
             true
835 835
         );
@@ -870,7 +870,7 @@  discard block
 block discarded – undo
870 870
         );
871 871
         if (EE_Registry::instance()->CFG->core->event_cpt_slug != $old_slug) {
872 872
             /** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */
873
-            $rewrite_rules =  LoaderFactory::getLoader()->getShared(
873
+            $rewrite_rules = LoaderFactory::getLoader()->getShared(
874 874
                 'EventEspresso\core\domain\services\custom_post_types\RewriteRules'
875 875
             );
876 876
             $rewrite_rules->flush();
@@ -909,11 +909,11 @@  discard block
 block discarded – undo
909 909
      */
910 910
     public function registration_options_meta_box()
911 911
     {
912
-        $yes_no_values                                    = array(
912
+        $yes_no_values = array(
913 913
             array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')),
914 914
             array('id' => false, 'text' => esc_html__('No', 'event_espresso')),
915 915
         );
916
-        $default_reg_status_values                        = EEM_Registration::reg_status_array(
916
+        $default_reg_status_values = EEM_Registration::reg_status_array(
917 917
             array(
918 918
                 EEM_Registration::status_id_cancelled,
919 919
                 EEM_Registration::status_id_declined,
@@ -930,12 +930,12 @@  discard block
 block discarded – undo
930 930
             $default_reg_status_values,
931 931
             $this->_cpt_model_obj->default_registration_status()
932 932
         );
933
-        $template_args['display_description']             = EEH_Form_Fields::select_input(
933
+        $template_args['display_description'] = EEH_Form_Fields::select_input(
934 934
             'display_desc',
935 935
             $yes_no_values,
936 936
             $this->_cpt_model_obj->display_description()
937 937
         );
938
-        $template_args['display_ticket_selector']         = EEH_Form_Fields::select_input(
938
+        $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input(
939 939
             'display_ticket_selector',
940 940
             $yes_no_values,
941 941
             $this->_cpt_model_obj->display_ticket_selector(),
@@ -956,7 +956,7 @@  discard block
 block discarded – undo
956 956
             $default_reg_status_values
957 957
         );
958 958
         EEH_Template::display_template(
959
-            EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php',
959
+            EVENTS_CAF_TEMPLATE_PATH.'event_registration_options.template.php',
960 960
             $template_args
961 961
         );
962 962
     }
@@ -1060,13 +1060,13 @@  discard block
 block discarded – undo
1060 1060
     {
1061 1061
         $start = EEM_Datetime::instance()->convert_datetime_for_query(
1062 1062
             'DTT_EVT_start',
1063
-            date('Y-m-d') . ' 00:00:00',
1063
+            date('Y-m-d').' 00:00:00',
1064 1064
             'Y-m-d H:i:s',
1065 1065
             'UTC'
1066 1066
         );
1067
-        $end   = EEM_Datetime::instance()->convert_datetime_for_query(
1067
+        $end = EEM_Datetime::instance()->convert_datetime_for_query(
1068 1068
             'DTT_EVT_start',
1069
-            date('Y-m-d') . ' 23:59:59',
1069
+            date('Y-m-d').' 23:59:59',
1070 1070
             'Y-m-d H:i:s',
1071 1071
             'UTC'
1072 1072
         );
@@ -1093,13 +1093,13 @@  discard block
 block discarded – undo
1093 1093
         $days_this_month = date('t');
1094 1094
         $start           = EEM_Datetime::instance()->convert_datetime_for_query(
1095 1095
             'DTT_EVT_start',
1096
-            $this_year_r . '-' . $this_month_r . '-01 00:00:00',
1096
+            $this_year_r.'-'.$this_month_r.'-01 00:00:00',
1097 1097
             'Y-m-d H:i:s',
1098 1098
             'UTC'
1099 1099
         );
1100
-        $end             = EEM_Datetime::instance()->convert_datetime_for_query(
1100
+        $end = EEM_Datetime::instance()->convert_datetime_for_query(
1101 1101
             'DTT_EVT_start',
1102
-            $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59',
1102
+            $this_year_r.'-'.$this_month_r.'-'.$days_this_month.' 23:59:59',
1103 1103
             'Y-m-d H:i:s',
1104 1104
             'UTC'
1105 1105
         );
@@ -1166,7 +1166,7 @@  discard block
 block discarded – undo
1166 1166
         $offset       = ($current_page - 1) * $per_page;
1167 1167
         $limit        = array($offset, $per_page);
1168 1168
         if (isset($this->_req_data['s'])) {
1169
-            $sstr         = '%' . $this->_req_data['s'] . '%';
1169
+            $sstr         = '%'.$this->_req_data['s'].'%';
1170 1170
             $_where['OR'] = array(
1171 1171
                 'TKT_name'        => array('LIKE', $sstr),
1172 1172
                 'TKT_description' => array('LIKE', $sstr),
@@ -1195,17 +1195,17 @@  discard block
 block discarded – undo
1195 1195
         $success = 1;
1196 1196
         $TKT     = EEM_Ticket::instance();
1197 1197
         //checkboxes?
1198
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1198
+        if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1199 1199
             //if array has more than one element then success message should be plural
1200 1200
             $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1201 1201
             //cycle thru the boxes
1202 1202
             while (list($TKT_ID, $value) = each($this->_req_data['checkbox'])) {
1203 1203
                 if ($trash) {
1204
-                    if (! $TKT->delete_by_ID($TKT_ID)) {
1204
+                    if ( ! $TKT->delete_by_ID($TKT_ID)) {
1205 1205
                         $success = 0;
1206 1206
                     }
1207 1207
                 } else {
1208
-                    if (! $TKT->restore_by_ID($TKT_ID)) {
1208
+                    if ( ! $TKT->restore_by_ID($TKT_ID)) {
1209 1209
                         $success = 0;
1210 1210
                     }
1211 1211
                 }
@@ -1214,11 +1214,11 @@  discard block
 block discarded – undo
1214 1214
             //grab single id and trash
1215 1215
             $TKT_ID = absint($this->_req_data['TKT_ID']);
1216 1216
             if ($trash) {
1217
-                if (! $TKT->delete_by_ID($TKT_ID)) {
1217
+                if ( ! $TKT->delete_by_ID($TKT_ID)) {
1218 1218
                     $success = 0;
1219 1219
                 }
1220 1220
             } else {
1221
-                if (! $TKT->restore_by_ID($TKT_ID)) {
1221
+                if ( ! $TKT->restore_by_ID($TKT_ID)) {
1222 1222
                     $success = 0;
1223 1223
                 }
1224 1224
             }
@@ -1239,20 +1239,20 @@  discard block
 block discarded – undo
1239 1239
     {
1240 1240
         $success = 1;
1241 1241
         //checkboxes?
1242
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1242
+        if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1243 1243
             //if array has more than one element then success message should be plural
1244 1244
             $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1245 1245
             //cycle thru the boxes
1246 1246
             while (list($TKT_ID, $value) = each($this->_req_data['checkbox'])) {
1247 1247
                 //delete
1248
-                if (! $this->_delete_the_ticket($TKT_ID)) {
1248
+                if ( ! $this->_delete_the_ticket($TKT_ID)) {
1249 1249
                     $success = 0;
1250 1250
                 }
1251 1251
             }
1252 1252
         } else {
1253 1253
             //grab single id and trash
1254 1254
             $TKT_ID = absint($this->_req_data['TKT_ID']);
1255
-            if (! $this->_delete_the_ticket($TKT_ID)) {
1255
+            if ( ! $this->_delete_the_ticket($TKT_ID)) {
1256 1256
                 $success = 0;
1257 1257
             }
1258 1258
         }
Please login to merge, or discard this patch.
widgets/upcoming_events/EEW_Upcoming_Events.widget.php 2 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -210,14 +210,14 @@  discard block
 block discarded – undo
210 210
 		        <?php _e('Show on all Pages:', 'event_espresso'); ?>
211 211
 			</label>
212 212
 	 	    <?php
213
-	 	    echo EEH_Form_Fields::select(
214
-	 	        __('Show on all Pages:', 'event_espresso'),
215
-	 	        $instance['show_everywhere'],
216
-	 	        $yes_no_values,
217
-	 	        $this->get_field_name('show_everywhere'),
218
-	 	        $this->get_field_id('show_everywhere')
219
-	 	    );
220
-	 	    ?>
213
+	 		echo EEH_Form_Fields::select(
214
+	 			__('Show on all Pages:', 'event_espresso'),
215
+	 			$instance['show_everywhere'],
216
+	 			$yes_no_values,
217
+	 			$this->get_field_name('show_everywhere'),
218
+	 			$this->get_field_id('show_everywhere')
219
+	 		);
220
+	 		?>
221 221
 	 	</p>
222 222
 		<p>
223 223
 			<label for="<?php echo $this->get_field_id('date_limit'); ?>">
@@ -300,14 +300,14 @@  discard block
 block discarded – undo
300 300
 				extract($args);
301 301
 
302 302
 				// add function to make the title a link
303
-	            add_filter('widget_title', array($this, 'make_the_title_a_link'), 15);
303
+				add_filter('widget_title', array($this, 'make_the_title_a_link'), 15);
304 304
 
305 305
 				$title = isset( $instance['title'] ) && ! empty( $instance['title'] ) ? $instance['title'] : '';
306 306
 				// filter the title
307 307
 				$title = apply_filters('widget_title', $title);
308 308
 
309 309
 				// remove the function from the filter, so it does not affect other widgets
310
-	            remove_filter('widget_title', array($this, 'make_the_title_a_link'), 15);
310
+				remove_filter('widget_title', array($this, 'make_the_title_a_link'), 15);
311 311
 
312 312
 				// Before widget (defined by themes).
313 313
 				echo $before_widget;
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
 	 * @return string
420 420
 	 */
421 421
 	public function make_the_title_a_link($title) {
422
-	    return '<a href="' . EEH_Event_View::event_archive_url() . '">' . $title . '</a>';
422
+		return '<a href="' . EEH_Event_View::event_archive_url() . '">' . $title . '</a>';
423 423
 	}
424 424
 
425 425
 }
Please login to merge, or discard this patch.
Spacing   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -31,8 +31,8 @@  discard block
 block discarded – undo
31 31
 	 */
32 32
 	public function __construct() {
33 33
 		parent::__construct(
34
-			__( 'Event Espresso Upcoming Events', 'event_espresso' ),
35
-			 array( 'description' => __( 'A widget to display your upcoming events.', 'event_espresso' ))
34
+			__('Event Espresso Upcoming Events', 'event_espresso'),
35
+			 array('description' => __('A widget to display your upcoming events.', 'event_espresso'))
36 36
 		);
37 37
 	}
38 38
 
@@ -45,9 +45,9 @@  discard block
 block discarded – undo
45 45
 	 * @param array $instance Previously saved values from database.
46 46
 	 * @return string|void
47 47
 	 */
48
-	public function form( $instance ) {
48
+	public function form($instance) {
49 49
 
50
-		EE_Registry::instance()->load_class( 'Question_Option', array(), FALSE, FALSE, TRUE );
50
+		EE_Registry::instance()->load_class('Question_Option', array(), FALSE, FALSE, TRUE);
51 51
 		// Set up some default widget settings.
52 52
 		$defaults = array(
53 53
 			'title' => __('Upcoming Events', 'event_espresso'),
@@ -63,16 +63,16 @@  discard block
 block discarded – undo
63 63
 			'image_size' => 'medium'
64 64
 		);
65 65
 
66
-		$instance = wp_parse_args( (array) $instance, $defaults );
66
+		$instance = wp_parse_args((array) $instance, $defaults);
67 67
 		// don't add HTML labels for EE_Form_Fields generated inputs
68
-		add_filter( 'FHEE__EEH_Form_Fields__label_html', '__return_empty_string' );
68
+		add_filter('FHEE__EEH_Form_Fields__label_html', '__return_empty_string');
69 69
 		$yes_no_values = array(
70
-			EE_Question_Option::new_instance( array( 'QSO_value' => FALSE, 'QSO_desc' => __('No', 'event_espresso'))),
71
-			EE_Question_Option::new_instance( array( 'QSO_value' => TRUE, 'QSO_desc' => __('Yes', 'event_espresso')))
70
+			EE_Question_Option::new_instance(array('QSO_value' => FALSE, 'QSO_desc' => __('No', 'event_espresso'))),
71
+			EE_Question_Option::new_instance(array('QSO_value' => TRUE, 'QSO_desc' => __('Yes', 'event_espresso')))
72 72
 		);
73 73
 		$sort_values = array(
74
-			EE_Question_Option::new_instance( array( 'QSO_value' => 'ASC', 'QSO_desc' => __('ASC', 'event_espresso'))),
75
-			EE_Question_Option::new_instance( array( 'QSO_value' => 'DESC', 'QSO_desc' => __('DESC', 'event_espresso')))
74
+			EE_Question_Option::new_instance(array('QSO_value' => 'ASC', 'QSO_desc' => __('ASC', 'event_espresso'))),
75
+			EE_Question_Option::new_instance(array('QSO_value' => 'DESC', 'QSO_desc' => __('DESC', 'event_espresso')))
76 76
 		);
77 77
 
78 78
 	?>
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 			<label for="<?php echo $this->get_field_id('title'); ?>">
84 84
 				<?php _e('Title:', 'event_espresso'); ?>
85 85
 			</label>
86
-			<input id="<?php echo $this->get_field_id('title'); ?>" class="widefat" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo esc_attr( $instance['title'] ); ?>" type="text" />
86
+			<input id="<?php echo $this->get_field_id('title'); ?>" class="widefat" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo esc_attr($instance['title']); ?>" type="text" />
87 87
 		</p>
88 88
 		<p>
89 89
 			<label for="<?php echo $this->get_field_id('category_name'); ?>">
@@ -92,16 +92,16 @@  discard block
 block discarded – undo
92 92
 			<?php
93 93
 			$event_categories = array();
94 94
 			/** @type EEM_Term $EEM_Term */
95
-			$EEM_Term = EE_Registry::instance()->load_model( 'Term' );
96
-			$categories = $EEM_Term->get_all_ee_categories( TRUE );
97
-			if ( $categories ) {
98
-				foreach ( $categories as $category ) {
99
-					if ( $category instanceof EE_Term ) {
100
-						$event_categories[] = EE_Question_Option::new_instance( array( 'QSO_value' => $category->get( 'slug' ), 'QSO_desc' => $category->get( 'name' )));
95
+			$EEM_Term = EE_Registry::instance()->load_model('Term');
96
+			$categories = $EEM_Term->get_all_ee_categories(TRUE);
97
+			if ($categories) {
98
+				foreach ($categories as $category) {
99
+					if ($category instanceof EE_Term) {
100
+						$event_categories[] = EE_Question_Option::new_instance(array('QSO_value' => $category->get('slug'), 'QSO_desc' => $category->get('name')));
101 101
 					}
102 102
 				}
103 103
 			}
104
-			array_unshift( $event_categories, EE_Question_Option::new_instance( array( 'QSO_value' => '', 'QSO_desc' => __(' - display all - ', 'event_espresso'))));
104
+			array_unshift($event_categories, EE_Question_Option::new_instance(array('QSO_value' => '', 'QSO_desc' => __(' - display all - ', 'event_espresso'))));
105 105
 			echo EEH_Form_Fields::select(
106 106
 				 __('Event Category:', 'event_espresso'),
107 107
 				$instance['category_name'],
@@ -126,9 +126,9 @@  discard block
 block discarded – undo
126 126
 				 __('Show Expired Events:', 'event_espresso'),
127 127
 				$instance['show_expired'],
128 128
 				array(
129
-					EE_Question_Option::new_instance( array( 'QSO_value' => 0, 'QSO_desc' => __('No', 'event_espresso'))), 
130
-					EE_Question_Option::new_instance( array( 'QSO_value' => 1, 'QSO_desc' => __('Yes', 'event_espresso'))), 
131
-					EE_Question_Option::new_instance( array( 'QSO_value' => 2, 'QSO_desc' => __('Show Only Expired', 'event_espresso'))), 
129
+					EE_Question_Option::new_instance(array('QSO_value' => 0, 'QSO_desc' => __('No', 'event_espresso'))), 
130
+					EE_Question_Option::new_instance(array('QSO_value' => 1, 'QSO_desc' => __('Yes', 'event_espresso'))), 
131
+					EE_Question_Option::new_instance(array('QSO_value' => 2, 'QSO_desc' => __('Show Only Expired', 'event_espresso'))), 
132 132
 				),
133 133
 				$this->get_field_name('show_expired'),
134 134
 				$this->get_field_id('show_expired')
@@ -156,16 +156,16 @@  discard block
 block discarded – undo
156 156
 			<?php
157 157
 			$image_sizes = array();
158 158
 			$sizes = get_intermediate_image_sizes();
159
-			if ( $sizes ) {
159
+			if ($sizes) {
160 160
 				// loop thru images and create option objects out of them
161
-				foreach ( $sizes as $image_size ) {
162
-					$image_size = trim( $image_size );
161
+				foreach ($sizes as $image_size) {
162
+					$image_size = trim($image_size);
163 163
 					// no big images plz
164
-					if ( ! in_array( $image_size, array( 'large', 'post-thumbnail' ))) {
165
-						$image_sizes[] = EE_Question_Option::new_instance( array( 'QSO_value' => $image_size, 'QSO_desc' => $image_size ));
164
+					if ( ! in_array($image_size, array('large', 'post-thumbnail'))) {
165
+						$image_sizes[] = EE_Question_Option::new_instance(array('QSO_value' => $image_size, 'QSO_desc' => $image_size));
166 166
 					}
167 167
 				}
168
-				$image_sizes[] = EE_Question_Option::new_instance( array( 'QSO_value' => 'none', 'QSO_desc' =>  __('don\'t show images', 'event_espresso') ));
168
+				$image_sizes[] = EE_Question_Option::new_instance(array('QSO_value' => 'none', 'QSO_desc' =>  __('don\'t show images', 'event_espresso')));
169 169
 			}
170 170
 			echo EEH_Form_Fields::select(
171 171
 				 __('Image Size:', 'event_espresso'),
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 			<label for="<?php echo $this->get_field_id('date_limit'); ?>">
224 224
 				<?php _e('Number of Dates to Display:', 'event_espresso'); ?>
225 225
 			</label>
226
-			<input id="<?php echo $this->get_field_id('date_limit'); ?>" name="<?php echo $this->get_field_name('date_limit'); ?>" value="<?php echo esc_attr( $instance['date_limit'] ); ?>" size="3" type="text" />
226
+			<input id="<?php echo $this->get_field_id('date_limit'); ?>" name="<?php echo $this->get_field_name('date_limit'); ?>" value="<?php echo esc_attr($instance['date_limit']); ?>" size="3" type="text" />
227 227
 		</p>
228 228
 		<p>
229 229
 			<label for="<?php echo $this->get_field_id('date_range'); ?>">
@@ -255,9 +255,9 @@  discard block
 block discarded – undo
255 255
 	 *
256 256
 	 * @return array Updated safe values to be saved.
257 257
 	 */
258
-	public function update( $new_instance, $old_instance ) {
258
+	public function update($new_instance, $old_instance) {
259 259
 		$instance = $old_instance;
260
-		$instance['title'] = ! empty( $new_instance['title'] ) ? strip_tags( $new_instance['title'] ) : '';
260
+		$instance['title'] = ! empty($new_instance['title']) ? strip_tags($new_instance['title']) : '';
261 261
 		$instance['category_name'] = $new_instance['category_name'];
262 262
 		$instance['show_expired'] = $new_instance['show_expired'];
263 263
 		$instance['limit'] = $new_instance['limit'];
@@ -281,18 +281,18 @@  discard block
 block discarded – undo
281 281
 	 * @param array $args     Widget arguments.
282 282
 	 * @param array $instance Saved values from database.
283 283
 	 */
284
-	public function widget( $args, $instance ) {
284
+	public function widget($args, $instance) {
285 285
 
286 286
 		global $post;
287 287
 		// make sure there is some kinda post object
288
-		if ( $post instanceof WP_Post ) {
288
+		if ($post instanceof WP_Post) {
289 289
 			$before_widget = '';
290 290
 			$before_title = '';
291 291
 			$after_title = '';
292 292
 			$after_widget = '';
293 293
 			// but NOT an events archives page, cuz that would be like two event lists on the same page
294
-			$show_everywhere = isset( $instance['show_everywhere'] ) ? (bool) absint( $instance['show_everywhere'] ) : TRUE;
295
-			if ( $show_everywhere || ! ( $post->post_type == 'espresso_events' && is_archive() )) {
294
+			$show_everywhere = isset($instance['show_everywhere']) ? (bool) absint($instance['show_everywhere']) : TRUE;
295
+			if ($show_everywhere || ! ($post->post_type == 'espresso_events' && is_archive())) {
296 296
 				// let's use some of the event helper functions'
297 297
 				// make separate vars out of attributes
298 298
 
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 				// add function to make the title a link
303 303
 	            add_filter('widget_title', array($this, 'make_the_title_a_link'), 15);
304 304
 
305
-				$title = isset( $instance['title'] ) && ! empty( $instance['title'] ) ? $instance['title'] : '';
305
+				$title = isset($instance['title']) && ! empty($instance['title']) ? $instance['title'] : '';
306 306
 				// filter the title
307 307
 				$title = apply_filters('widget_title', $title);
308 308
 
@@ -312,90 +312,90 @@  discard block
 block discarded – undo
312 312
 				// Before widget (defined by themes).
313 313
 				echo $before_widget;
314 314
 				// Display the widget title if one was input (before and after defined by themes).
315
-				if ( ! empty( $title )) {
316
-					echo $before_title . $title . $after_title;
315
+				if ( ! empty($title)) {
316
+					echo $before_title.$title.$after_title;
317 317
 				}
318 318
 				// grab widget settings
319
-				$category = isset( $instance['category_name'] ) && ! empty( $instance['category_name'] ) ? $instance['category_name'] : FALSE;
320
-				$show_expired = isset( $instance['show_expired'] ) ? absint( $instance['show_expired'] ) : 0;
321
-				$image_size = isset( $instance['image_size'] ) && ! empty( $instance['image_size'] ) ? $instance['image_size'] : 'medium';
322
-				$show_desc = isset( $instance['show_desc'] ) ? (bool) absint( $instance['show_desc'] ) : TRUE;
323
-				$show_dates = isset( $instance['show_dates'] ) ? (bool) absint( $instance['show_dates'] ) : TRUE;
324
-				$date_limit = isset( $instance['date_limit'] ) && ! empty( $instance['date_limit'] ) ? $instance['date_limit'] : NULL;
325
-				$date_range = isset( $instance['date_range'] ) && ! empty( $instance['date_range'] ) ? $instance['date_range'] : FALSE;
319
+				$category = isset($instance['category_name']) && ! empty($instance['category_name']) ? $instance['category_name'] : FALSE;
320
+				$show_expired = isset($instance['show_expired']) ? absint($instance['show_expired']) : 0;
321
+				$image_size = isset($instance['image_size']) && ! empty($instance['image_size']) ? $instance['image_size'] : 'medium';
322
+				$show_desc = isset($instance['show_desc']) ? (bool) absint($instance['show_desc']) : TRUE;
323
+				$show_dates = isset($instance['show_dates']) ? (bool) absint($instance['show_dates']) : TRUE;
324
+				$date_limit = isset($instance['date_limit']) && ! empty($instance['date_limit']) ? $instance['date_limit'] : NULL;
325
+				$date_range = isset($instance['date_range']) && ! empty($instance['date_range']) ? $instance['date_range'] : FALSE;
326 326
 				// start to build our where clause
327 327
 				$where = array(
328 328
 //					'Datetime.DTT_is_primary' => 1,
329
-					'status' => array( 'IN', array( 'publish', 'sold_out' ) )
329
+					'status' => array('IN', array('publish', 'sold_out'))
330 330
 				);
331 331
 				// add category
332
-				if ( $category ) {
332
+				if ($category) {
333 333
 					$where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories';
334 334
 					$where['Term_Taxonomy.Term.slug'] = $category;
335 335
 				}
336 336
 				// if NOT expired then we want events that start today or in the future
337 337
 				// if NOT show expired then we want events that start today or in the future 
338
-				if ( $show_expired == 0 ) { 
339
-				 	$where['Datetime.DTT_EVT_end'] = array( '>=', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_end' ) ); 
338
+				if ($show_expired == 0) { 
339
+				 	$where['Datetime.DTT_EVT_end'] = array('>=', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end')); 
340 340
 				} 
341 341
 				// if show ONLY expired we want events that ended prior to today 
342
-				if ( $show_expired == 2 ) { 
343
-					$where['Datetime.DTT_EVT_end'] = array( '<=', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_start' ) ); 
342
+				if ($show_expired == 2) { 
343
+					$where['Datetime.DTT_EVT_end'] = array('<=', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start')); 
344 344
 				}
345 345
 				// allow $where to be filtered
346
-				$where = apply_filters( 'FHEE__EEW_Upcoming_Events__widget__where', $where, $category, $show_expired );
346
+				$where = apply_filters('FHEE__EEW_Upcoming_Events__widget__where', $where, $category, $show_expired);
347 347
 				// run the query
348
-				$events = EE_Registry::instance()->load_model( 'Event' )->get_all( array(
348
+				$events = EE_Registry::instance()->load_model('Event')->get_all(array(
349 349
 					$where,
350 350
 					'limit' => isset($instance['limit']) && $instance['limit'] > 0 
351
-								? '0,' . $instance['limit'] 
351
+								? '0,'.$instance['limit'] 
352 352
 								: '0,10',
353 353
 					'order_by' => 'Datetime.DTT_EVT_start',
354 354
 					'order' => isset($instance['sort']) ? $instance['sort'] : 'ASC',
355 355
 					'group_by' => 'EVT_ID'
356 356
 				));
357 357
 
358
-				if ( ! empty( $events )) {
358
+				if ( ! empty($events)) {
359 359
 					echo '<ul class="ee-upcoming-events-widget-ul">';
360
-					foreach ( $events as $event ) {
361
-						if ( $event instanceof EE_Event && ( !is_single() || $post->ID != $event->ID() ) ) {
360
+					foreach ($events as $event) {
361
+						if ($event instanceof EE_Event && ( ! is_single() || $post->ID != $event->ID())) {
362 362
 							//printr( $event, '$event  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
363
-							echo '<li id="ee-upcoming-events-widget-li-' . $event->ID() . '" class="ee-upcoming-events-widget-li">';
363
+							echo '<li id="ee-upcoming-events-widget-li-'.$event->ID().'" class="ee-upcoming-events-widget-li">';
364 364
 							// how big is the event name ?
365
-							$name_length = strlen( $event->name() );
366
-							switch( $name_length ) {
365
+							$name_length = strlen($event->name());
366
+							switch ($name_length) {
367 367
 								case $name_length > 70 :
368
-									$len_class =  ' three-line';
368
+									$len_class = ' three-line';
369 369
 									break;
370 370
 								case $name_length > 35 :
371
-									$len_class =  ' two-line';
371
+									$len_class = ' two-line';
372 372
 									break;
373 373
 								default :
374
-									$len_class =  ' one-line';
374
+									$len_class = ' one-line';
375 375
 							}
376
-							$event_url = apply_filters( 'FHEE_EEW_Upcoming_Events__widget__event_url', $event->get_permalink(), $event );
377
-							echo '<h5 class="ee-upcoming-events-widget-title-h5"><a class="ee-widget-event-name-a' . $len_class . '" href="' . $event_url . '">' . $event->name() . '</a></h5>';
378
-							if ( post_password_required( $event->ID() ) ) {
379
-								$pswd_form = apply_filters( 'FHEE_EEW_Upcoming_Events__widget__password_form', get_the_password_form( $event->ID() ), $event );
376
+							$event_url = apply_filters('FHEE_EEW_Upcoming_Events__widget__event_url', $event->get_permalink(), $event);
377
+							echo '<h5 class="ee-upcoming-events-widget-title-h5"><a class="ee-widget-event-name-a'.$len_class.'" href="'.$event_url.'">'.$event->name().'</a></h5>';
378
+							if (post_password_required($event->ID())) {
379
+								$pswd_form = apply_filters('FHEE_EEW_Upcoming_Events__widget__password_form', get_the_password_form($event->ID()), $event);
380 380
 								echo $pswd_form;
381 381
 							} else {
382
-								if ( has_post_thumbnail( $event->ID() ) && $image_size != 'none' ) {
383
-									echo '<div class="ee-upcoming-events-widget-img-dv"><a class="ee-upcoming-events-widget-img" href="' . $event_url . '">' . get_the_post_thumbnail( $event->ID(), $image_size ) . '</a></div>';
382
+								if (has_post_thumbnail($event->ID()) && $image_size != 'none') {
383
+									echo '<div class="ee-upcoming-events-widget-img-dv"><a class="ee-upcoming-events-widget-img" href="'.$event_url.'">'.get_the_post_thumbnail($event->ID(), $image_size).'</a></div>';
384 384
 								}
385
-								$desc = $event->short_description( 25 );
386
-								if ( $show_dates ) {
387
-									$date_format = apply_filters( 'FHEE__espresso_event_date_range__date_format', get_option( 'date_format' ));
388
-									$time_format = apply_filters( 'FHEE__espresso_event_date_range__time_format', get_option( 'time_format' ));
389
-									$single_date_format = apply_filters( 'FHEE__espresso_event_date_range__single_date_format', get_option( 'date_format' ));
390
-									$single_time_format = apply_filters( 'FHEE__espresso_event_date_range__single_time_format', get_option( 'time_format' ));
391
-									if ( $date_range == TRUE ) {
392
-										echo espresso_event_date_range( $date_format, $time_format, $single_date_format, $single_time_format, $event->ID() );
393
-									}else{
394
-										echo espresso_list_of_event_dates( $event->ID(), $date_format, $time_format, FALSE, NULL, TRUE, TRUE, $date_limit );
385
+								$desc = $event->short_description(25);
386
+								if ($show_dates) {
387
+									$date_format = apply_filters('FHEE__espresso_event_date_range__date_format', get_option('date_format'));
388
+									$time_format = apply_filters('FHEE__espresso_event_date_range__time_format', get_option('time_format'));
389
+									$single_date_format = apply_filters('FHEE__espresso_event_date_range__single_date_format', get_option('date_format'));
390
+									$single_time_format = apply_filters('FHEE__espresso_event_date_range__single_time_format', get_option('time_format'));
391
+									if ($date_range == TRUE) {
392
+										echo espresso_event_date_range($date_format, $time_format, $single_date_format, $single_time_format, $event->ID());
393
+									} else {
394
+										echo espresso_list_of_event_dates($event->ID(), $date_format, $time_format, FALSE, NULL, TRUE, TRUE, $date_limit);
395 395
 									}
396 396
 								}
397
-								if ( $show_desc && $desc ) {
398
-									echo '<p style="margin-top: .5em">' . $desc . '</p>';
397
+								if ($show_desc && $desc) {
398
+									echo '<p style="margin-top: .5em">'.$desc.'</p>';
399 399
 								}
400 400
 							}
401 401
 							echo '</li>';
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
 	 * @return string
420 420
 	 */
421 421
 	public function make_the_title_a_link($title) {
422
-	    return '<a href="' . EEH_Event_View::event_archive_url() . '">' . $title . '</a>';
422
+	    return '<a href="'.EEH_Event_View::event_archive_url().'">'.$title.'</a>';
423 423
 	}
424 424
 
425 425
 }
Please login to merge, or discard this patch.
core/EE_Config.core.php 1 patch
Indentation   +3092 added lines, -3092 removed lines patch added patch discarded remove patch
@@ -17,2474 +17,2474 @@  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
+			if ($addon_config_obj instanceof EE_Config_Base) {
449
+				$this->update_config('addons', $addon_name, $addon_config_obj, false);
450
+			}
451
+			$this->addons->{$addon_name} = null;
452
+		}
453
+	}
454
+
455
+
456
+
457
+	/**
458
+	 *    update_espresso_config
459
+	 *
460
+	 * @access   public
461
+	 * @param   bool $add_success
462
+	 * @param   bool $add_error
463
+	 * @return   bool
464
+	 */
465
+	public function update_espresso_config($add_success = false, $add_error = true)
466
+	{
467
+		// don't allow config updates during WP heartbeats
468
+		if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
469
+			return false;
470
+		}
471
+		// commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197
472
+		//$clone = clone( self::$_instance );
473
+		//self::$_instance = NULL;
474
+		do_action('AHEE__EE_Config__update_espresso_config__begin', $this);
475
+		$this->_reset_espresso_addon_config();
476
+		// hook into update_option because that happens AFTER the ( $value === $old_value ) conditional
477
+		// but BEFORE the actual update occurs
478
+		add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3);
479
+		// don't want to persist legacy_shortcodes_manager, but don't want to lose it either
480
+		$legacy_shortcodes_manager = $this->legacy_shortcodes_manager;
481
+		$this->legacy_shortcodes_manager = null;
482
+		// now update "ee_config"
483
+		$saved = update_option(EE_Config::OPTION_NAME, $this);
484
+		$this->legacy_shortcodes_manager = $legacy_shortcodes_manager;
485
+		EE_Config::log(EE_Config::OPTION_NAME);
486
+		// if not saved... check if the hook we just added still exists;
487
+		// if it does, it means one of two things:
488
+		// 		that update_option bailed at the ( $value === $old_value ) conditional,
489
+		//		 or...
490
+		// 		the db update query returned 0 rows affected
491
+		// 		(probably because the data  value was the same from it's perspective)
492
+		// so the existence of the hook means that a negative result from update_option is NOT an error,
493
+		// but just means no update occurred, so don't display an error to the user.
494
+		// BUT... if update_option returns FALSE, AND the hook is missing,
495
+		// then it means that something truly went wrong
496
+		$saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved;
497
+		// remove our action since we don't want it in the system anymore
498
+		remove_action('update_option', array($this, 'double_check_config_comparison'), 1);
499
+		do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved);
500
+		//self::$_instance = $clone;
501
+		//unset( $clone );
502
+		// if config remains the same or was updated successfully
503
+		if ($saved) {
504
+			if ($add_success) {
505
+				EE_Error::add_success(
506
+					__('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'),
507
+					__FILE__,
508
+					__FUNCTION__,
509
+					__LINE__
510
+				);
511
+			}
512
+			return true;
513
+		} else {
514
+			if ($add_error) {
515
+				EE_Error::add_error(
516
+					__('The Event Espresso Configuration Settings were not updated.', 'event_espresso'),
517
+					__FILE__,
518
+					__FUNCTION__,
519
+					__LINE__
520
+				);
521
+			}
522
+			return false;
523
+		}
524
+	}
525
+
526
+
527
+
528
+	/**
529
+	 *    _verify_config_params
530
+	 *
531
+	 * @access    private
532
+	 * @param    string         $section
533
+	 * @param    string         $name
534
+	 * @param    string         $config_class
535
+	 * @param    EE_Config_Base $config_obj
536
+	 * @param    array          $tests_to_run
537
+	 * @param    bool           $display_errors
538
+	 * @return    bool    TRUE on success, FALSE on fail
539
+	 */
540
+	private function _verify_config_params(
541
+		$section = '',
542
+		$name = '',
543
+		$config_class = '',
544
+		$config_obj = null,
545
+		$tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8),
546
+		$display_errors = true
547
+	) {
548
+		try {
549
+			foreach ($tests_to_run as $test) {
550
+				switch ($test) {
551
+					// TEST #1 : check that section was set
552
+					case 1 :
553
+						if (empty($section)) {
554
+							if ($display_errors) {
555
+								throw new EE_Error(
556
+									sprintf(
557
+										__(
558
+											'No configuration section has been provided while attempting to save "%s".',
559
+											'event_espresso'
560
+										),
561
+										$config_class
562
+									)
563
+								);
564
+							}
565
+							return false;
566
+						}
567
+						break;
568
+					// TEST #2 : check that settings section exists
569
+					case 2 :
570
+						if (! isset($this->{$section})) {
571
+							if ($display_errors) {
572
+								throw new EE_Error(
573
+									sprintf(
574
+										__('The "%s" configuration section does not exist.', 'event_espresso'),
575
+										$section
576
+									)
577
+								);
578
+							}
579
+							return false;
580
+						}
581
+						break;
582
+					// TEST #3 : check that section is the proper format
583
+					case 3 :
584
+						if (
585
+						! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass)
586
+						) {
587
+							if ($display_errors) {
588
+								throw new EE_Error(
589
+									sprintf(
590
+										__(
591
+											'The "%s" configuration settings have not been formatted correctly.',
592
+											'event_espresso'
593
+										),
594
+										$section
595
+									)
596
+								);
597
+							}
598
+							return false;
599
+						}
600
+						break;
601
+					// TEST #4 : check that config section name has been set
602
+					case 4 :
603
+						if (empty($name)) {
604
+							if ($display_errors) {
605
+								throw new EE_Error(
606
+									__(
607
+										'No name has been provided for the specific configuration section.',
608
+										'event_espresso'
609
+									)
610
+								);
611
+							}
612
+							return false;
613
+						}
614
+						break;
615
+					// TEST #5 : check that a config class name has been set
616
+					case 5 :
617
+						if (empty($config_class)) {
618
+							if ($display_errors) {
619
+								throw new EE_Error(
620
+									__(
621
+										'No class name has been provided for the specific configuration section.',
622
+										'event_espresso'
623
+									)
624
+								);
625
+							}
626
+							return false;
627
+						}
628
+						break;
629
+					// TEST #6 : verify config class is accessible
630
+					case 6 :
631
+						if (! class_exists($config_class)) {
632
+							if ($display_errors) {
633
+								throw new EE_Error(
634
+									sprintf(
635
+										__(
636
+											'The "%s" class does not exist. Please ensure that an autoloader has been set for it.',
637
+											'event_espresso'
638
+										),
639
+										$config_class
640
+									)
641
+								);
642
+							}
643
+							return false;
644
+						}
645
+						break;
646
+					// TEST #7 : check that config has even been set
647
+					case 7 :
648
+						if (! isset($this->{$section}->{$name})) {
649
+							if ($display_errors) {
650
+								throw new EE_Error(
651
+									sprintf(
652
+										__('No configuration has been set for "%1$s->%2$s".', 'event_espresso'),
653
+										$section,
654
+										$name
655
+									)
656
+								);
657
+							}
658
+							return false;
659
+						} else {
660
+							// and make sure it's not serialized
661
+							$this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name});
662
+						}
663
+						break;
664
+					// TEST #8 : check that config is the requested type
665
+					case 8 :
666
+						if (! $this->{$section}->{$name} instanceof $config_class) {
667
+							if ($display_errors) {
668
+								throw new EE_Error(
669
+									sprintf(
670
+										__(
671
+											'The configuration for "%1$s->%2$s" is not of the "%3$s" class.',
672
+											'event_espresso'
673
+										),
674
+										$section,
675
+										$name,
676
+										$config_class
677
+									)
678
+								);
679
+							}
680
+							return false;
681
+						}
682
+						break;
683
+					// TEST #9 : verify config object
684
+					case 9 :
685
+						if (! $config_obj instanceof EE_Config_Base) {
686
+							if ($display_errors) {
687
+								throw new EE_Error(
688
+									sprintf(
689
+										__('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'),
690
+										print_r($config_obj, true)
691
+									)
692
+								);
693
+							}
694
+							return false;
695
+						}
696
+						break;
697
+				}
698
+			}
699
+		} catch (EE_Error $e) {
700
+			$e->get_error();
701
+		}
702
+		// you have successfully run the gauntlet
703
+		return true;
704
+	}
705
+
706
+
707
+
708
+	/**
709
+	 *    _generate_config_option_name
710
+	 *
711
+	 * @access        protected
712
+	 * @param        string $section
713
+	 * @param        string $name
714
+	 * @return        string
715
+	 */
716
+	private function _generate_config_option_name($section = '', $name = '')
717
+	{
718
+		return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name));
719
+	}
720
+
721
+
722
+
723
+	/**
724
+	 *    _set_config_class
725
+	 * ensures that a config class is set, either from a passed config class or one generated from the config name
726
+	 *
727
+	 * @access    private
728
+	 * @param    string $config_class
729
+	 * @param    string $name
730
+	 * @return    string
731
+	 */
732
+	private function _set_config_class($config_class = '', $name = '')
733
+	{
734
+		return ! empty($config_class)
735
+			? $config_class
736
+			: str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config';
737
+	}
738
+
739
+
740
+
741
+	/**
742
+	 *    set_config
743
+	 *
744
+	 * @access    protected
745
+	 * @param    string         $section
746
+	 * @param    string         $name
747
+	 * @param    string         $config_class
748
+	 * @param    EE_Config_Base $config_obj
749
+	 * @return    EE_Config_Base
750
+	 */
751
+	public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null)
752
+	{
753
+		// ensure config class is set to something
754
+		$config_class = $this->_set_config_class($config_class, $name);
755
+		// run tests 1-4, 6, and 7 to verify all config params are set and valid
756
+		if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
757
+			return null;
758
+		}
759
+		$config_option_name = $this->_generate_config_option_name($section, $name);
760
+		// if the config option name hasn't been added yet to the list of option names we're tracking, then do so now
761
+		if (! isset($this->_addon_option_names[$config_option_name])) {
762
+			$this->_addon_option_names[$config_option_name] = $config_class;
763
+			$this->update_addon_option_names();
764
+		}
765
+		// verify the incoming config object but suppress errors
766
+		if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
767
+			$config_obj = new $config_class();
768
+		}
769
+		if (get_option($config_option_name)) {
770
+			EE_Config::log($config_option_name);
771
+			update_option($config_option_name, $config_obj);
772
+			$this->{$section}->{$name} = $config_obj;
773
+			return $this->{$section}->{$name};
774
+		} else {
775
+			// create a wp-option for this config
776
+			if (add_option($config_option_name, $config_obj, '', 'no')) {
777
+				$this->{$section}->{$name} = maybe_unserialize($config_obj);
778
+				return $this->{$section}->{$name};
779
+			} else {
780
+				EE_Error::add_error(
781
+					sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class),
782
+					__FILE__,
783
+					__FUNCTION__,
784
+					__LINE__
785
+				);
786
+				return null;
787
+			}
788
+		}
789
+	}
790
+
791
+
792
+
793
+	/**
794
+	 *    update_config
795
+	 * Important: the config object must ALREADY be set, otherwise this will produce an error.
796
+	 *
797
+	 * @access    public
798
+	 * @param    string                $section
799
+	 * @param    string                $name
800
+	 * @param    EE_Config_Base|string $config_obj
801
+	 * @param    bool                  $throw_errors
802
+	 * @return    bool
803
+	 */
804
+	public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true)
805
+	{
806
+		// don't allow config updates during WP heartbeats
807
+		if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
808
+			return false;
809
+		}
810
+		$config_obj = maybe_unserialize($config_obj);
811
+		// get class name of the incoming object
812
+		$config_class = get_class($config_obj);
813
+		// run tests 1-5 and 9 to verify config
814
+		if (! $this->_verify_config_params(
815
+			$section,
816
+			$name,
817
+			$config_class,
818
+			$config_obj,
819
+			array(1, 2, 3, 4, 7, 9)
820
+		)
821
+		) {
822
+			return false;
823
+		}
824
+		$config_option_name = $this->_generate_config_option_name($section, $name);
825
+		// check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
826
+		if (! isset($this->_addon_option_names[$config_option_name])) {
827
+			// save new config to db
828
+			if ($this->set_config($section, $name, $config_class, $config_obj)) {
829
+				return true;
830
+			}
831
+		} else {
832
+			// first check if the record already exists
833
+			$existing_config = get_option($config_option_name);
834
+			$config_obj = serialize($config_obj);
835
+			// just return if db record is already up to date (NOT type safe comparison)
836
+			if ($existing_config == $config_obj) {
837
+				$this->{$section}->{$name} = $config_obj;
838
+				return true;
839
+			} else if (update_option($config_option_name, $config_obj)) {
840
+				EE_Config::log($config_option_name);
841
+				// update wp-option for this config class
842
+				$this->{$section}->{$name} = $config_obj;
843
+				return true;
844
+			} elseif ($throw_errors) {
845
+				EE_Error::add_error(
846
+					sprintf(
847
+						__(
848
+							'The "%1$s" object stored at"%2$s" was not successfully updated in the database.',
849
+							'event_espresso'
850
+						),
851
+						$config_class,
852
+						'EE_Config->' . $section . '->' . $name
853
+					),
854
+					__FILE__,
855
+					__FUNCTION__,
856
+					__LINE__
857
+				);
858
+			}
859
+		}
860
+		return false;
861
+	}
862
+
863
+
864
+
865
+	/**
866
+	 *    get_config
867
+	 *
868
+	 * @access    public
869
+	 * @param    string $section
870
+	 * @param    string $name
871
+	 * @param    string $config_class
872
+	 * @return    mixed EE_Config_Base | NULL
873
+	 */
874
+	public function get_config($section = '', $name = '', $config_class = '')
875
+	{
876
+		// ensure config class is set to something
877
+		$config_class = $this->_set_config_class($config_class, $name);
878
+		// run tests 1-4, 6 and 7 to verify that all params have been set
879
+		if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
880
+			return null;
881
+		}
882
+		// now test if the requested config object exists, but suppress errors
883
+		if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) {
884
+			// config already exists, so pass it back
885
+			return $this->{$section}->{$name};
886
+		}
887
+		// load config option from db if it exists
888
+		$config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name));
889
+		// verify the newly retrieved config object, but suppress errors
890
+		if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
891
+			// config is good, so set it and pass it back
892
+			$this->{$section}->{$name} = $config_obj;
893
+			return $this->{$section}->{$name};
894
+		}
895
+		// oops! $config_obj is not already set and does not exist in the db, so create a new one
896
+		$config_obj = $this->set_config($section, $name, $config_class);
897
+		// verify the newly created config object
898
+		if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) {
899
+			return $this->{$section}->{$name};
900
+		} else {
901
+			EE_Error::add_error(
902
+				sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class),
903
+				__FILE__,
904
+				__FUNCTION__,
905
+				__LINE__
906
+			);
907
+		}
908
+		return null;
909
+	}
910
+
911
+
912
+
913
+	/**
914
+	 *    get_config_option
915
+	 *
916
+	 * @access    public
917
+	 * @param    string $config_option_name
918
+	 * @return    mixed EE_Config_Base | FALSE
919
+	 */
920
+	public function get_config_option($config_option_name = '')
921
+	{
922
+		// retrieve the wp-option for this config class.
923
+		$config_option = maybe_unserialize(get_option($config_option_name, array()));
924
+		if (empty($config_option)) {
925
+			EE_Config::log($config_option_name . '-NOT-FOUND');
926
+		}
927
+		return $config_option;
928
+	}
929
+
930
+
931
+
932
+	/**
933
+	 * log
934
+	 *
935
+	 * @param string $config_option_name
936
+	 */
937
+	public static function log($config_option_name = '')
938
+	{
939
+		if (EE_Config::logging_enabled() && ! empty($config_option_name)) {
940
+			$config_log = get_option(EE_Config::LOG_NAME, array());
941
+			//copy incoming $_REQUEST and sanitize it so we can save it
942
+			$_request = $_REQUEST;
943
+			array_walk_recursive($_request, 'sanitize_text_field');
944
+			$config_log[(string)microtime(true)] = array(
945
+				'config_name' => $config_option_name,
946
+				'request'     => $_request,
947
+			);
948
+			update_option(EE_Config::LOG_NAME, $config_log);
949
+		}
950
+	}
951
+
952
+
953
+
954
+	/**
955
+	 * trim_log
956
+	 * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH
957
+	 */
958
+	public static function trim_log()
959
+	{
960
+		if (! EE_Config::logging_enabled()) {
961
+			return;
962
+		}
963
+		$config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
964
+		$log_length = count($config_log);
965
+		if ($log_length > EE_Config::LOG_LENGTH) {
966
+			ksort($config_log);
967
+			$config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true);
968
+			update_option(EE_Config::LOG_NAME, $config_log);
969
+		}
970
+	}
971
+
972
+
973
+
974
+	/**
975
+	 *    get_page_for_posts
976
+	 *    if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the
977
+	 *    wp-option "page_for_posts", or "posts" if no page is selected
978
+	 *
979
+	 * @access    public
980
+	 * @return    string
981
+	 */
982
+	public static function get_page_for_posts()
983
+	{
984
+		$page_for_posts = get_option('page_for_posts');
985
+		if (! $page_for_posts) {
986
+			return 'posts';
987
+		}
988
+		/** @type WPDB $wpdb */
989
+		global $wpdb;
990
+		$SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d";
991
+		return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts));
992
+	}
993
+
994
+
995
+
996
+	/**
997
+	 *    register_shortcodes_and_modules.
998
+	 *    At this point, it's too early to tell if we're maintenance mode or not.
999
+	 *    In fact, this is where we give modules a chance to let core know they exist
1000
+	 *    so they can help trigger maintenance mode if it's needed
1001
+	 *
1002
+	 * @access    public
1003
+	 * @return    void
1004
+	 */
1005
+	public function register_shortcodes_and_modules()
1006
+	{
1007
+		// allow modules to set hooks for the rest of the system
1008
+		EE_Registry::instance()->modules = $this->_register_modules();
1009
+	}
1010
+
1011
+
1012
+
1013
+	/**
1014
+	 *    initialize_shortcodes_and_modules
1015
+	 *    meaning they can start adding their hooks to get stuff done
1016
+	 *
1017
+	 * @access    public
1018
+	 * @return    void
1019
+	 */
1020
+	public function initialize_shortcodes_and_modules()
1021
+	{
1022
+		// allow modules to set hooks for the rest of the system
1023
+		$this->_initialize_modules();
1024
+	}
1025
+
1026
+
1027
+
1028
+	/**
1029
+	 *    widgets_init
1030
+	 *
1031
+	 * @access private
1032
+	 * @return void
1033
+	 */
1034
+	public function widgets_init()
1035
+	{
1036
+		//only init widgets on admin pages when not in complete maintenance, and
1037
+		//on frontend when not in any maintenance mode
1038
+		if (
1039
+			! EE_Maintenance_Mode::instance()->level()
1040
+			|| (
1041
+				is_admin()
1042
+				&& EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance
1043
+			)
1044
+		) {
1045
+			// grab list of installed widgets
1046
+			$widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
1047
+			// filter list of modules to register
1048
+			$widgets_to_register = apply_filters(
1049
+				'FHEE__EE_Config__register_widgets__widgets_to_register',
1050
+				$widgets_to_register
1051
+			);
1052
+			if (! empty($widgets_to_register)) {
1053
+				// cycle thru widget folders
1054
+				foreach ($widgets_to_register as $widget_path) {
1055
+					// add to list of installed widget modules
1056
+					EE_Config::register_ee_widget($widget_path);
1057
+				}
1058
+			}
1059
+			// filter list of installed modules
1060
+			EE_Registry::instance()->widgets = apply_filters(
1061
+				'FHEE__EE_Config__register_widgets__installed_widgets',
1062
+				EE_Registry::instance()->widgets
1063
+			);
1064
+		}
1065
+	}
1066
+
1067
+
1068
+
1069
+	/**
1070
+	 *    register_ee_widget - makes core aware of this widget
1071
+	 *
1072
+	 * @access    public
1073
+	 * @param    string $widget_path - full path up to and including widget folder
1074
+	 * @return    void
1075
+	 */
1076
+	public static function register_ee_widget($widget_path = null)
1077
+	{
1078
+		do_action('AHEE__EE_Config__register_widget__begin', $widget_path);
1079
+		$widget_ext = '.widget.php';
1080
+		// make all separators match
1081
+		$widget_path = rtrim(str_replace('/\\', DS, $widget_path), DS);
1082
+		// does the file path INCLUDE the actual file name as part of the path ?
1083
+		if (strpos($widget_path, $widget_ext) !== false) {
1084
+			// grab and shortcode file name from directory name and break apart at dots
1085
+			$file_name = explode('.', basename($widget_path));
1086
+			// take first segment from file name pieces and remove class prefix if it exists
1087
+			$widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0];
1088
+			// sanitize shortcode directory name
1089
+			$widget = sanitize_key($widget);
1090
+			// now we need to rebuild the shortcode path
1091
+			$widget_path = explode(DS, $widget_path);
1092
+			// remove last segment
1093
+			array_pop($widget_path);
1094
+			// glue it back together
1095
+			$widget_path = implode(DS, $widget_path);
1096
+		} else {
1097
+			// grab and sanitize widget directory name
1098
+			$widget = sanitize_key(basename($widget_path));
1099
+		}
1100
+		// create classname from widget directory name
1101
+		$widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1102
+		// add class prefix
1103
+		$widget_class = 'EEW_' . $widget;
1104
+		// does the widget exist ?
1105
+		if (! is_readable($widget_path . DS . $widget_class . $widget_ext)) {
1106
+			$msg = sprintf(
1107
+				__(
1108
+					'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',
1109
+					'event_espresso'
1110
+				),
1111
+				$widget_class,
1112
+				$widget_path . DS . $widget_class . $widget_ext
1113
+			);
1114
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1115
+			return;
1116
+		}
1117
+		// load the widget class file
1118
+		require_once($widget_path . DS . $widget_class . $widget_ext);
1119
+		// verify that class exists
1120
+		if (! class_exists($widget_class)) {
1121
+			$msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1122
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1123
+			return;
1124
+		}
1125
+		register_widget($widget_class);
1126
+		// add to array of registered widgets
1127
+		EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext;
1128
+	}
1129
+
1130
+
1131
+
1132
+	/**
1133
+	 *        _register_modules
1134
+	 *
1135
+	 * @access private
1136
+	 * @return array
1137
+	 */
1138
+	private function _register_modules()
1139
+	{
1140
+		// grab list of installed modules
1141
+		$modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1142
+		// filter list of modules to register
1143
+		$modules_to_register = apply_filters(
1144
+			'FHEE__EE_Config__register_modules__modules_to_register',
1145
+			$modules_to_register
1146
+		);
1147
+		if (! empty($modules_to_register)) {
1148
+			// loop through folders
1149
+			foreach ($modules_to_register as $module_path) {
1150
+				/**TEMPORARILY EXCLUDE gateways from modules for time being**/
1151
+				if (
1152
+					$module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1153
+					&& $module_path !== EE_MODULES . 'gateways'
1154
+				) {
1155
+					// add to list of installed modules
1156
+					EE_Config::register_module($module_path);
1157
+				}
1158
+			}
1159
+		}
1160
+		// filter list of installed modules
1161
+		return apply_filters(
1162
+			'FHEE__EE_Config___register_modules__installed_modules',
1163
+			EE_Registry::instance()->modules
1164
+		);
1165
+	}
1166
+
1167
+
1168
+
1169
+	/**
1170
+	 *    register_module - makes core aware of this module
1171
+	 *
1172
+	 * @access    public
1173
+	 * @param    string $module_path - full path up to and including module folder
1174
+	 * @return    bool
1175
+	 */
1176
+	public static function register_module($module_path = null)
1177
+	{
1178
+		do_action('AHEE__EE_Config__register_module__begin', $module_path);
1179
+		$module_ext = '.module.php';
1180
+		// make all separators match
1181
+		$module_path = str_replace(array('\\', '/'), DS, $module_path);
1182
+		// does the file path INCLUDE the actual file name as part of the path ?
1183
+		if (strpos($module_path, $module_ext) !== false) {
1184
+			// grab and shortcode file name from directory name and break apart at dots
1185
+			$module_file = explode('.', basename($module_path));
1186
+			// now we need to rebuild the shortcode path
1187
+			$module_path = explode(DS, $module_path);
1188
+			// remove last segment
1189
+			array_pop($module_path);
1190
+			// glue it back together
1191
+			$module_path = implode(DS, $module_path) . DS;
1192
+			// take first segment from file name pieces and sanitize it
1193
+			$module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1194
+			// ensure class prefix is added
1195
+			$module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1196
+		} else {
1197
+			// we need to generate the filename based off of the folder name
1198
+			// grab and sanitize module name
1199
+			$module = strtolower(basename($module_path));
1200
+			$module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1201
+			// like trailingslashit()
1202
+			$module_path = rtrim($module_path, DS) . DS;
1203
+			// create classname from module directory name
1204
+			$module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1205
+			// add class prefix
1206
+			$module_class = 'EED_' . $module;
1207
+		}
1208
+		// does the module exist ?
1209
+		if (! is_readable($module_path . DS . $module_class . $module_ext)) {
1210
+			$msg = sprintf(
1211
+				__(
1212
+					'The requested %s module file could not be found or is not readable due to file permissions.',
1213
+					'event_espresso'
1214
+				),
1215
+				$module
1216
+			);
1217
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1218
+			return false;
1219
+		}
1220
+		// load the module class file
1221
+		require_once($module_path . $module_class . $module_ext);
1222
+		// verify that class exists
1223
+		if (! class_exists($module_class)) {
1224
+			$msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1225
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1226
+			return false;
1227
+		}
1228
+		// add to array of registered modules
1229
+		EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1230
+		do_action(
1231
+			'AHEE__EE_Config__register_module__complete',
1232
+			$module_class,
1233
+			EE_Registry::instance()->modules->{$module_class}
1234
+		);
1235
+		return true;
1236
+	}
1237
+
1238
+
1239
+
1240
+	/**
1241
+	 *    _initialize_modules
1242
+	 *    allow modules to set hooks for the rest of the system
1243
+	 *
1244
+	 * @access private
1245
+	 * @return void
1246
+	 */
1247
+	private function _initialize_modules()
1248
+	{
1249
+		// cycle thru shortcode folders
1250
+		foreach (EE_Registry::instance()->modules as $module_class => $module_path) {
1251
+			// fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1252
+			// which set hooks ?
1253
+			if (is_admin()) {
1254
+				// fire immediately
1255
+				call_user_func(array($module_class, 'set_hooks_admin'));
1256
+			} else {
1257
+				// delay until other systems are online
1258
+				add_action(
1259
+					'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
1260
+					array($module_class, 'set_hooks')
1261
+				);
1262
+			}
1263
+		}
1264
+	}
1265
+
1266
+
1267
+
1268
+	/**
1269
+	 *    register_route - adds module method routes to route_map
1270
+	 *
1271
+	 * @access    public
1272
+	 * @param    string $route       - "pretty" public alias for module method
1273
+	 * @param    string $module      - module name (classname without EED_ prefix)
1274
+	 * @param    string $method_name - the actual module method to be routed to
1275
+	 * @param    string $key         - url param key indicating a route is being called
1276
+	 * @return    bool
1277
+	 */
1278
+	public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee')
1279
+	{
1280
+		do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1281
+		$module = str_replace('EED_', '', $module);
1282
+		$module_class = 'EED_' . $module;
1283
+		if (! isset(EE_Registry::instance()->modules->{$module_class})) {
1284
+			$msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module);
1285
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1286
+			return false;
1287
+		}
1288
+		if (empty($route)) {
1289
+			$msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route);
1290
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1291
+			return false;
1292
+		}
1293
+		if (! method_exists('EED_' . $module, $method_name)) {
1294
+			$msg = sprintf(
1295
+				__('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1296
+				$route
1297
+			);
1298
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1299
+			return false;
1300
+		}
1301
+		EE_Config::$_module_route_map[$key][$route] = array('EED_' . $module, $method_name);
1302
+		return true;
1303
+	}
1304
+
1305
+
1306
+
1307
+	/**
1308
+	 *    get_route - get module method route
1309
+	 *
1310
+	 * @access    public
1311
+	 * @param    string $route - "pretty" public alias for module method
1312
+	 * @param    string $key   - url param key indicating a route is being called
1313
+	 * @return    string
1314
+	 */
1315
+	public static function get_route($route = null, $key = 'ee')
1316
+	{
1317
+		do_action('AHEE__EE_Config__get_route__begin', $route);
1318
+		$route = (string)apply_filters('FHEE__EE_Config__get_route', $route);
1319
+		if (isset(EE_Config::$_module_route_map[$key][$route])) {
1320
+			return EE_Config::$_module_route_map[$key][$route];
1321
+		}
1322
+		return null;
1323
+	}
1324
+
1325
+
1326
+
1327
+	/**
1328
+	 *    get_routes - get ALL module method routes
1329
+	 *
1330
+	 * @access    public
1331
+	 * @return    array
1332
+	 */
1333
+	public static function get_routes()
1334
+	{
1335
+		return EE_Config::$_module_route_map;
1336
+	}
1337
+
1338
+
1339
+
1340
+	/**
1341
+	 *    register_forward - allows modules to forward request to another module for further processing
1342
+	 *
1343
+	 * @access    public
1344
+	 * @param    string       $route   - "pretty" public alias for module method
1345
+	 * @param    integer      $status  - integer value corresponding  to status constant strings set in module parent
1346
+	 *                                 class, allows different forwards to be served based on status
1347
+	 * @param    array|string $forward - function name or array( class, method )
1348
+	 * @param    string       $key     - url param key indicating a route is being called
1349
+	 * @return    bool
1350
+	 */
1351
+	public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee')
1352
+	{
1353
+		do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1354
+		if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1355
+			$msg = sprintf(
1356
+				__('The module route %s for this forward has not been registered.', 'event_espresso'),
1357
+				$route
1358
+			);
1359
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1360
+			return false;
1361
+		}
1362
+		if (empty($forward)) {
1363
+			$msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route);
1364
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1365
+			return false;
1366
+		}
1367
+		if (is_array($forward)) {
1368
+			if (! isset($forward[1])) {
1369
+				$msg = sprintf(
1370
+					__('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1371
+					$route
1372
+				);
1373
+				EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1374
+				return false;
1375
+			}
1376
+			if (! method_exists($forward[0], $forward[1])) {
1377
+				$msg = sprintf(
1378
+					__('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1379
+					$forward[1],
1380
+					$route
1381
+				);
1382
+				EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1383
+				return false;
1384
+			}
1385
+		} else if (! function_exists($forward)) {
1386
+			$msg = sprintf(
1387
+				__('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1388
+				$forward,
1389
+				$route
1390
+			);
1391
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1392
+			return false;
1393
+		}
1394
+		EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward;
1395
+		return true;
1396
+	}
1397
+
1398
+
1399
+
1400
+	/**
1401
+	 *    get_forward - get forwarding route
1402
+	 *
1403
+	 * @access    public
1404
+	 * @param    string  $route  - "pretty" public alias for module method
1405
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1406
+	 *                           allows different forwards to be served based on status
1407
+	 * @param    string  $key    - url param key indicating a route is being called
1408
+	 * @return    string
1409
+	 */
1410
+	public static function get_forward($route = null, $status = 0, $key = 'ee')
1411
+	{
1412
+		do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1413
+		if (isset(EE_Config::$_module_forward_map[$key][$route][$status])) {
1414
+			return apply_filters(
1415
+				'FHEE__EE_Config__get_forward',
1416
+				EE_Config::$_module_forward_map[$key][$route][$status],
1417
+				$route,
1418
+				$status
1419
+			);
1420
+		}
1421
+		return null;
1422
+	}
1423
+
1424
+
1425
+
1426
+	/**
1427
+	 *    register_forward - allows modules to specify different view templates for different method routes and status
1428
+	 *    results
1429
+	 *
1430
+	 * @access    public
1431
+	 * @param    string  $route  - "pretty" public alias for module method
1432
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1433
+	 *                           allows different views to be served based on status
1434
+	 * @param    string  $view
1435
+	 * @param    string  $key    - url param key indicating a route is being called
1436
+	 * @return    bool
1437
+	 */
1438
+	public static function register_view($route = null, $status = 0, $view = null, $key = 'ee')
1439
+	{
1440
+		do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1441
+		if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1442
+			$msg = sprintf(
1443
+				__('The module route %s for this view has not been registered.', 'event_espresso'),
1444
+				$route
1445
+			);
1446
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1447
+			return false;
1448
+		}
1449
+		if (! is_readable($view)) {
1450
+			$msg = sprintf(
1451
+				__(
1452
+					'The %s view file could not be found or is not readable due to file permissions.',
1453
+					'event_espresso'
1454
+				),
1455
+				$view
1456
+			);
1457
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1458
+			return false;
1459
+		}
1460
+		EE_Config::$_module_view_map[$key][$route][absint($status)] = $view;
1461
+		return true;
1462
+	}
1463
+
1464
+
1465
+
1466
+	/**
1467
+	 *    get_view - get view for route and status
1468
+	 *
1469
+	 * @access    public
1470
+	 * @param    string  $route  - "pretty" public alias for module method
1471
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1472
+	 *                           allows different views to be served based on status
1473
+	 * @param    string  $key    - url param key indicating a route is being called
1474
+	 * @return    string
1475
+	 */
1476
+	public static function get_view($route = null, $status = 0, $key = 'ee')
1477
+	{
1478
+		do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1479
+		if (isset(EE_Config::$_module_view_map[$key][$route][$status])) {
1480
+			return apply_filters(
1481
+				'FHEE__EE_Config__get_view',
1482
+				EE_Config::$_module_view_map[$key][$route][$status],
1483
+				$route,
1484
+				$status
1485
+			);
1486
+		}
1487
+		return null;
1488
+	}
1489
+
1490
+
1491
+
1492
+	public function update_addon_option_names()
1493
+	{
1494
+		update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names);
1495
+	}
1496
+
1497
+
1498
+
1499
+	public function shutdown()
1500
+	{
1501
+		$this->update_addon_option_names();
1502
+	}
1503
+
1504
+
1505
+
1506
+	/**
1507
+	 * @return LegacyShortcodesManager
1508
+	 */
1509
+	public static function getLegacyShortcodesManager()
1510
+	{
1511
+
1512
+		if ( ! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) {
1513
+			EE_Config::instance()->legacy_shortcodes_manager = new LegacyShortcodesManager(
1514
+				EE_Registry::instance()
1515
+			);
1516
+		}
1517
+		return EE_Config::instance()->legacy_shortcodes_manager;
1518
+	}
1519
+
1520
+
1521
+
1522
+	/**
1523
+	 * register_shortcode - makes core aware of this shortcode
1524
+	 *
1525
+	 * @deprecated 4.9.26
1526
+	 * @param    string $shortcode_path - full path up to and including shortcode folder
1527
+	 * @return    bool
1528
+	 */
1529
+	public static function register_shortcode($shortcode_path = null)
1530
+	{
1531
+		EE_Error::doing_it_wrong(
1532
+			__METHOD__,
1533
+			__(
1534
+				'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.',
1535
+				'event_espresso'
1536
+			),
1537
+			'4.9.26'
1538
+		);
1539
+		return EE_Config::instance()->getLegacyShortcodesManager()->registerShortcode($shortcode_path);
1540
+	}
21 1541
 
22
-    const LOG_NAME           = 'ee_config_log';
23 1542
 
24
-    const LOG_LENGTH         = 100;
25 1543
 
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
-            if ($addon_config_obj instanceof EE_Config_Base) {
449
-                $this->update_config('addons', $addon_name, $addon_config_obj, false);
450
-            }
451
-            $this->addons->{$addon_name} = null;
452
-        }
453
-    }
454
-
455
-
456
-
457
-    /**
458
-     *    update_espresso_config
459
-     *
460
-     * @access   public
461
-     * @param   bool $add_success
462
-     * @param   bool $add_error
463
-     * @return   bool
464
-     */
465
-    public function update_espresso_config($add_success = false, $add_error = true)
466
-    {
467
-        // don't allow config updates during WP heartbeats
468
-        if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
469
-            return false;
470
-        }
471
-        // commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197
472
-        //$clone = clone( self::$_instance );
473
-        //self::$_instance = NULL;
474
-        do_action('AHEE__EE_Config__update_espresso_config__begin', $this);
475
-        $this->_reset_espresso_addon_config();
476
-        // hook into update_option because that happens AFTER the ( $value === $old_value ) conditional
477
-        // but BEFORE the actual update occurs
478
-        add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3);
479
-        // don't want to persist legacy_shortcodes_manager, but don't want to lose it either
480
-        $legacy_shortcodes_manager = $this->legacy_shortcodes_manager;
481
-        $this->legacy_shortcodes_manager = null;
482
-        // now update "ee_config"
483
-        $saved = update_option(EE_Config::OPTION_NAME, $this);
484
-        $this->legacy_shortcodes_manager = $legacy_shortcodes_manager;
485
-        EE_Config::log(EE_Config::OPTION_NAME);
486
-        // if not saved... check if the hook we just added still exists;
487
-        // if it does, it means one of two things:
488
-        // 		that update_option bailed at the ( $value === $old_value ) conditional,
489
-        //		 or...
490
-        // 		the db update query returned 0 rows affected
491
-        // 		(probably because the data  value was the same from it's perspective)
492
-        // so the existence of the hook means that a negative result from update_option is NOT an error,
493
-        // but just means no update occurred, so don't display an error to the user.
494
-        // BUT... if update_option returns FALSE, AND the hook is missing,
495
-        // then it means that something truly went wrong
496
-        $saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved;
497
-        // remove our action since we don't want it in the system anymore
498
-        remove_action('update_option', array($this, 'double_check_config_comparison'), 1);
499
-        do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved);
500
-        //self::$_instance = $clone;
501
-        //unset( $clone );
502
-        // if config remains the same or was updated successfully
503
-        if ($saved) {
504
-            if ($add_success) {
505
-                EE_Error::add_success(
506
-                    __('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'),
507
-                    __FILE__,
508
-                    __FUNCTION__,
509
-                    __LINE__
510
-                );
511
-            }
512
-            return true;
513
-        } else {
514
-            if ($add_error) {
515
-                EE_Error::add_error(
516
-                    __('The Event Espresso Configuration Settings were not updated.', 'event_espresso'),
517
-                    __FILE__,
518
-                    __FUNCTION__,
519
-                    __LINE__
520
-                );
521
-            }
522
-            return false;
523
-        }
524
-    }
525
-
526
-
527
-
528
-    /**
529
-     *    _verify_config_params
530
-     *
531
-     * @access    private
532
-     * @param    string         $section
533
-     * @param    string         $name
534
-     * @param    string         $config_class
535
-     * @param    EE_Config_Base $config_obj
536
-     * @param    array          $tests_to_run
537
-     * @param    bool           $display_errors
538
-     * @return    bool    TRUE on success, FALSE on fail
539
-     */
540
-    private function _verify_config_params(
541
-        $section = '',
542
-        $name = '',
543
-        $config_class = '',
544
-        $config_obj = null,
545
-        $tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8),
546
-        $display_errors = true
547
-    ) {
548
-        try {
549
-            foreach ($tests_to_run as $test) {
550
-                switch ($test) {
551
-                    // TEST #1 : check that section was set
552
-                    case 1 :
553
-                        if (empty($section)) {
554
-                            if ($display_errors) {
555
-                                throw new EE_Error(
556
-                                    sprintf(
557
-                                        __(
558
-                                            'No configuration section has been provided while attempting to save "%s".',
559
-                                            'event_espresso'
560
-                                        ),
561
-                                        $config_class
562
-                                    )
563
-                                );
564
-                            }
565
-                            return false;
566
-                        }
567
-                        break;
568
-                    // TEST #2 : check that settings section exists
569
-                    case 2 :
570
-                        if (! isset($this->{$section})) {
571
-                            if ($display_errors) {
572
-                                throw new EE_Error(
573
-                                    sprintf(
574
-                                        __('The "%s" configuration section does not exist.', 'event_espresso'),
575
-                                        $section
576
-                                    )
577
-                                );
578
-                            }
579
-                            return false;
580
-                        }
581
-                        break;
582
-                    // TEST #3 : check that section is the proper format
583
-                    case 3 :
584
-                        if (
585
-                        ! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass)
586
-                        ) {
587
-                            if ($display_errors) {
588
-                                throw new EE_Error(
589
-                                    sprintf(
590
-                                        __(
591
-                                            'The "%s" configuration settings have not been formatted correctly.',
592
-                                            'event_espresso'
593
-                                        ),
594
-                                        $section
595
-                                    )
596
-                                );
597
-                            }
598
-                            return false;
599
-                        }
600
-                        break;
601
-                    // TEST #4 : check that config section name has been set
602
-                    case 4 :
603
-                        if (empty($name)) {
604
-                            if ($display_errors) {
605
-                                throw new EE_Error(
606
-                                    __(
607
-                                        'No name has been provided for the specific configuration section.',
608
-                                        'event_espresso'
609
-                                    )
610
-                                );
611
-                            }
612
-                            return false;
613
-                        }
614
-                        break;
615
-                    // TEST #5 : check that a config class name has been set
616
-                    case 5 :
617
-                        if (empty($config_class)) {
618
-                            if ($display_errors) {
619
-                                throw new EE_Error(
620
-                                    __(
621
-                                        'No class name has been provided for the specific configuration section.',
622
-                                        'event_espresso'
623
-                                    )
624
-                                );
625
-                            }
626
-                            return false;
627
-                        }
628
-                        break;
629
-                    // TEST #6 : verify config class is accessible
630
-                    case 6 :
631
-                        if (! class_exists($config_class)) {
632
-                            if ($display_errors) {
633
-                                throw new EE_Error(
634
-                                    sprintf(
635
-                                        __(
636
-                                            'The "%s" class does not exist. Please ensure that an autoloader has been set for it.',
637
-                                            'event_espresso'
638
-                                        ),
639
-                                        $config_class
640
-                                    )
641
-                                );
642
-                            }
643
-                            return false;
644
-                        }
645
-                        break;
646
-                    // TEST #7 : check that config has even been set
647
-                    case 7 :
648
-                        if (! isset($this->{$section}->{$name})) {
649
-                            if ($display_errors) {
650
-                                throw new EE_Error(
651
-                                    sprintf(
652
-                                        __('No configuration has been set for "%1$s->%2$s".', 'event_espresso'),
653
-                                        $section,
654
-                                        $name
655
-                                    )
656
-                                );
657
-                            }
658
-                            return false;
659
-                        } else {
660
-                            // and make sure it's not serialized
661
-                            $this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name});
662
-                        }
663
-                        break;
664
-                    // TEST #8 : check that config is the requested type
665
-                    case 8 :
666
-                        if (! $this->{$section}->{$name} instanceof $config_class) {
667
-                            if ($display_errors) {
668
-                                throw new EE_Error(
669
-                                    sprintf(
670
-                                        __(
671
-                                            'The configuration for "%1$s->%2$s" is not of the "%3$s" class.',
672
-                                            'event_espresso'
673
-                                        ),
674
-                                        $section,
675
-                                        $name,
676
-                                        $config_class
677
-                                    )
678
-                                );
679
-                            }
680
-                            return false;
681
-                        }
682
-                        break;
683
-                    // TEST #9 : verify config object
684
-                    case 9 :
685
-                        if (! $config_obj instanceof EE_Config_Base) {
686
-                            if ($display_errors) {
687
-                                throw new EE_Error(
688
-                                    sprintf(
689
-                                        __('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'),
690
-                                        print_r($config_obj, true)
691
-                                    )
692
-                                );
693
-                            }
694
-                            return false;
695
-                        }
696
-                        break;
697
-                }
698
-            }
699
-        } catch (EE_Error $e) {
700
-            $e->get_error();
701
-        }
702
-        // you have successfully run the gauntlet
703
-        return true;
704
-    }
705
-
706
-
707
-
708
-    /**
709
-     *    _generate_config_option_name
710
-     *
711
-     * @access        protected
712
-     * @param        string $section
713
-     * @param        string $name
714
-     * @return        string
715
-     */
716
-    private function _generate_config_option_name($section = '', $name = '')
717
-    {
718
-        return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name));
719
-    }
720
-
721
-
722
-
723
-    /**
724
-     *    _set_config_class
725
-     * ensures that a config class is set, either from a passed config class or one generated from the config name
726
-     *
727
-     * @access    private
728
-     * @param    string $config_class
729
-     * @param    string $name
730
-     * @return    string
731
-     */
732
-    private function _set_config_class($config_class = '', $name = '')
733
-    {
734
-        return ! empty($config_class)
735
-            ? $config_class
736
-            : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config';
737
-    }
738
-
739
-
740
-
741
-    /**
742
-     *    set_config
743
-     *
744
-     * @access    protected
745
-     * @param    string         $section
746
-     * @param    string         $name
747
-     * @param    string         $config_class
748
-     * @param    EE_Config_Base $config_obj
749
-     * @return    EE_Config_Base
750
-     */
751
-    public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null)
752
-    {
753
-        // ensure config class is set to something
754
-        $config_class = $this->_set_config_class($config_class, $name);
755
-        // run tests 1-4, 6, and 7 to verify all config params are set and valid
756
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
757
-            return null;
758
-        }
759
-        $config_option_name = $this->_generate_config_option_name($section, $name);
760
-        // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now
761
-        if (! isset($this->_addon_option_names[$config_option_name])) {
762
-            $this->_addon_option_names[$config_option_name] = $config_class;
763
-            $this->update_addon_option_names();
764
-        }
765
-        // verify the incoming config object but suppress errors
766
-        if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
767
-            $config_obj = new $config_class();
768
-        }
769
-        if (get_option($config_option_name)) {
770
-            EE_Config::log($config_option_name);
771
-            update_option($config_option_name, $config_obj);
772
-            $this->{$section}->{$name} = $config_obj;
773
-            return $this->{$section}->{$name};
774
-        } else {
775
-            // create a wp-option for this config
776
-            if (add_option($config_option_name, $config_obj, '', 'no')) {
777
-                $this->{$section}->{$name} = maybe_unserialize($config_obj);
778
-                return $this->{$section}->{$name};
779
-            } else {
780
-                EE_Error::add_error(
781
-                    sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class),
782
-                    __FILE__,
783
-                    __FUNCTION__,
784
-                    __LINE__
785
-                );
786
-                return null;
787
-            }
788
-        }
789
-    }
790
-
791
-
792
-
793
-    /**
794
-     *    update_config
795
-     * Important: the config object must ALREADY be set, otherwise this will produce an error.
796
-     *
797
-     * @access    public
798
-     * @param    string                $section
799
-     * @param    string                $name
800
-     * @param    EE_Config_Base|string $config_obj
801
-     * @param    bool                  $throw_errors
802
-     * @return    bool
803
-     */
804
-    public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true)
805
-    {
806
-        // don't allow config updates during WP heartbeats
807
-        if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
808
-            return false;
809
-        }
810
-        $config_obj = maybe_unserialize($config_obj);
811
-        // get class name of the incoming object
812
-        $config_class = get_class($config_obj);
813
-        // run tests 1-5 and 9 to verify config
814
-        if (! $this->_verify_config_params(
815
-            $section,
816
-            $name,
817
-            $config_class,
818
-            $config_obj,
819
-            array(1, 2, 3, 4, 7, 9)
820
-        )
821
-        ) {
822
-            return false;
823
-        }
824
-        $config_option_name = $this->_generate_config_option_name($section, $name);
825
-        // check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
826
-        if (! isset($this->_addon_option_names[$config_option_name])) {
827
-            // save new config to db
828
-            if ($this->set_config($section, $name, $config_class, $config_obj)) {
829
-                return true;
830
-            }
831
-        } else {
832
-            // first check if the record already exists
833
-            $existing_config = get_option($config_option_name);
834
-            $config_obj = serialize($config_obj);
835
-            // just return if db record is already up to date (NOT type safe comparison)
836
-            if ($existing_config == $config_obj) {
837
-                $this->{$section}->{$name} = $config_obj;
838
-                return true;
839
-            } else if (update_option($config_option_name, $config_obj)) {
840
-                EE_Config::log($config_option_name);
841
-                // update wp-option for this config class
842
-                $this->{$section}->{$name} = $config_obj;
843
-                return true;
844
-            } elseif ($throw_errors) {
845
-                EE_Error::add_error(
846
-                    sprintf(
847
-                        __(
848
-                            'The "%1$s" object stored at"%2$s" was not successfully updated in the database.',
849
-                            'event_espresso'
850
-                        ),
851
-                        $config_class,
852
-                        'EE_Config->' . $section . '->' . $name
853
-                    ),
854
-                    __FILE__,
855
-                    __FUNCTION__,
856
-                    __LINE__
857
-                );
858
-            }
859
-        }
860
-        return false;
861
-    }
862
-
863
-
864
-
865
-    /**
866
-     *    get_config
867
-     *
868
-     * @access    public
869
-     * @param    string $section
870
-     * @param    string $name
871
-     * @param    string $config_class
872
-     * @return    mixed EE_Config_Base | NULL
873
-     */
874
-    public function get_config($section = '', $name = '', $config_class = '')
875
-    {
876
-        // ensure config class is set to something
877
-        $config_class = $this->_set_config_class($config_class, $name);
878
-        // run tests 1-4, 6 and 7 to verify that all params have been set
879
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
880
-            return null;
881
-        }
882
-        // now test if the requested config object exists, but suppress errors
883
-        if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) {
884
-            // config already exists, so pass it back
885
-            return $this->{$section}->{$name};
886
-        }
887
-        // load config option from db if it exists
888
-        $config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name));
889
-        // verify the newly retrieved config object, but suppress errors
890
-        if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
891
-            // config is good, so set it and pass it back
892
-            $this->{$section}->{$name} = $config_obj;
893
-            return $this->{$section}->{$name};
894
-        }
895
-        // oops! $config_obj is not already set and does not exist in the db, so create a new one
896
-        $config_obj = $this->set_config($section, $name, $config_class);
897
-        // verify the newly created config object
898
-        if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) {
899
-            return $this->{$section}->{$name};
900
-        } else {
901
-            EE_Error::add_error(
902
-                sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class),
903
-                __FILE__,
904
-                __FUNCTION__,
905
-                __LINE__
906
-            );
907
-        }
908
-        return null;
909
-    }
910
-
911
-
912
-
913
-    /**
914
-     *    get_config_option
915
-     *
916
-     * @access    public
917
-     * @param    string $config_option_name
918
-     * @return    mixed EE_Config_Base | FALSE
919
-     */
920
-    public function get_config_option($config_option_name = '')
921
-    {
922
-        // retrieve the wp-option for this config class.
923
-        $config_option = maybe_unserialize(get_option($config_option_name, array()));
924
-        if (empty($config_option)) {
925
-            EE_Config::log($config_option_name . '-NOT-FOUND');
926
-        }
927
-        return $config_option;
928
-    }
929
-
930
-
931
-
932
-    /**
933
-     * log
934
-     *
935
-     * @param string $config_option_name
936
-     */
937
-    public static function log($config_option_name = '')
938
-    {
939
-        if (EE_Config::logging_enabled() && ! empty($config_option_name)) {
940
-            $config_log = get_option(EE_Config::LOG_NAME, array());
941
-            //copy incoming $_REQUEST and sanitize it so we can save it
942
-            $_request = $_REQUEST;
943
-            array_walk_recursive($_request, 'sanitize_text_field');
944
-            $config_log[(string)microtime(true)] = array(
945
-                'config_name' => $config_option_name,
946
-                'request'     => $_request,
947
-            );
948
-            update_option(EE_Config::LOG_NAME, $config_log);
949
-        }
950
-    }
951
-
952
-
953
-
954
-    /**
955
-     * trim_log
956
-     * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH
957
-     */
958
-    public static function trim_log()
959
-    {
960
-        if (! EE_Config::logging_enabled()) {
961
-            return;
962
-        }
963
-        $config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
964
-        $log_length = count($config_log);
965
-        if ($log_length > EE_Config::LOG_LENGTH) {
966
-            ksort($config_log);
967
-            $config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true);
968
-            update_option(EE_Config::LOG_NAME, $config_log);
969
-        }
970
-    }
971
-
972
-
973
-
974
-    /**
975
-     *    get_page_for_posts
976
-     *    if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the
977
-     *    wp-option "page_for_posts", or "posts" if no page is selected
978
-     *
979
-     * @access    public
980
-     * @return    string
981
-     */
982
-    public static function get_page_for_posts()
983
-    {
984
-        $page_for_posts = get_option('page_for_posts');
985
-        if (! $page_for_posts) {
986
-            return 'posts';
987
-        }
988
-        /** @type WPDB $wpdb */
989
-        global $wpdb;
990
-        $SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d";
991
-        return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts));
992
-    }
993
-
994
-
995
-
996
-    /**
997
-     *    register_shortcodes_and_modules.
998
-     *    At this point, it's too early to tell if we're maintenance mode or not.
999
-     *    In fact, this is where we give modules a chance to let core know they exist
1000
-     *    so they can help trigger maintenance mode if it's needed
1001
-     *
1002
-     * @access    public
1003
-     * @return    void
1004
-     */
1005
-    public function register_shortcodes_and_modules()
1006
-    {
1007
-        // allow modules to set hooks for the rest of the system
1008
-        EE_Registry::instance()->modules = $this->_register_modules();
1009
-    }
1010
-
1011
-
1012
-
1013
-    /**
1014
-     *    initialize_shortcodes_and_modules
1015
-     *    meaning they can start adding their hooks to get stuff done
1016
-     *
1017
-     * @access    public
1018
-     * @return    void
1019
-     */
1020
-    public function initialize_shortcodes_and_modules()
1021
-    {
1022
-        // allow modules to set hooks for the rest of the system
1023
-        $this->_initialize_modules();
1024
-    }
1025
-
1026
-
1027
-
1028
-    /**
1029
-     *    widgets_init
1030
-     *
1031
-     * @access private
1032
-     * @return void
1033
-     */
1034
-    public function widgets_init()
1035
-    {
1036
-        //only init widgets on admin pages when not in complete maintenance, and
1037
-        //on frontend when not in any maintenance mode
1038
-        if (
1039
-            ! EE_Maintenance_Mode::instance()->level()
1040
-            || (
1041
-                is_admin()
1042
-                && EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance
1043
-            )
1044
-        ) {
1045
-            // grab list of installed widgets
1046
-            $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
1047
-            // filter list of modules to register
1048
-            $widgets_to_register = apply_filters(
1049
-                'FHEE__EE_Config__register_widgets__widgets_to_register',
1050
-                $widgets_to_register
1051
-            );
1052
-            if (! empty($widgets_to_register)) {
1053
-                // cycle thru widget folders
1054
-                foreach ($widgets_to_register as $widget_path) {
1055
-                    // add to list of installed widget modules
1056
-                    EE_Config::register_ee_widget($widget_path);
1057
-                }
1058
-            }
1059
-            // filter list of installed modules
1060
-            EE_Registry::instance()->widgets = apply_filters(
1061
-                'FHEE__EE_Config__register_widgets__installed_widgets',
1062
-                EE_Registry::instance()->widgets
1063
-            );
1064
-        }
1065
-    }
1066
-
1067
-
1068
-
1069
-    /**
1070
-     *    register_ee_widget - makes core aware of this widget
1071
-     *
1072
-     * @access    public
1073
-     * @param    string $widget_path - full path up to and including widget folder
1074
-     * @return    void
1075
-     */
1076
-    public static function register_ee_widget($widget_path = null)
1077
-    {
1078
-        do_action('AHEE__EE_Config__register_widget__begin', $widget_path);
1079
-        $widget_ext = '.widget.php';
1080
-        // make all separators match
1081
-        $widget_path = rtrim(str_replace('/\\', DS, $widget_path), DS);
1082
-        // does the file path INCLUDE the actual file name as part of the path ?
1083
-        if (strpos($widget_path, $widget_ext) !== false) {
1084
-            // grab and shortcode file name from directory name and break apart at dots
1085
-            $file_name = explode('.', basename($widget_path));
1086
-            // take first segment from file name pieces and remove class prefix if it exists
1087
-            $widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0];
1088
-            // sanitize shortcode directory name
1089
-            $widget = sanitize_key($widget);
1090
-            // now we need to rebuild the shortcode path
1091
-            $widget_path = explode(DS, $widget_path);
1092
-            // remove last segment
1093
-            array_pop($widget_path);
1094
-            // glue it back together
1095
-            $widget_path = implode(DS, $widget_path);
1096
-        } else {
1097
-            // grab and sanitize widget directory name
1098
-            $widget = sanitize_key(basename($widget_path));
1099
-        }
1100
-        // create classname from widget directory name
1101
-        $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1102
-        // add class prefix
1103
-        $widget_class = 'EEW_' . $widget;
1104
-        // does the widget exist ?
1105
-        if (! is_readable($widget_path . DS . $widget_class . $widget_ext)) {
1106
-            $msg = sprintf(
1107
-                __(
1108
-                    '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',
1109
-                    'event_espresso'
1110
-                ),
1111
-                $widget_class,
1112
-                $widget_path . DS . $widget_class . $widget_ext
1113
-            );
1114
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1115
-            return;
1116
-        }
1117
-        // load the widget class file
1118
-        require_once($widget_path . DS . $widget_class . $widget_ext);
1119
-        // verify that class exists
1120
-        if (! class_exists($widget_class)) {
1121
-            $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1122
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1123
-            return;
1124
-        }
1125
-        register_widget($widget_class);
1126
-        // add to array of registered widgets
1127
-        EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext;
1128
-    }
1129
-
1130
-
1131
-
1132
-    /**
1133
-     *        _register_modules
1134
-     *
1135
-     * @access private
1136
-     * @return array
1137
-     */
1138
-    private function _register_modules()
1139
-    {
1140
-        // grab list of installed modules
1141
-        $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1142
-        // filter list of modules to register
1143
-        $modules_to_register = apply_filters(
1144
-            'FHEE__EE_Config__register_modules__modules_to_register',
1145
-            $modules_to_register
1146
-        );
1147
-        if (! empty($modules_to_register)) {
1148
-            // loop through folders
1149
-            foreach ($modules_to_register as $module_path) {
1150
-                /**TEMPORARILY EXCLUDE gateways from modules for time being**/
1151
-                if (
1152
-                    $module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1153
-                    && $module_path !== EE_MODULES . 'gateways'
1154
-                ) {
1155
-                    // add to list of installed modules
1156
-                    EE_Config::register_module($module_path);
1157
-                }
1158
-            }
1159
-        }
1160
-        // filter list of installed modules
1161
-        return apply_filters(
1162
-            'FHEE__EE_Config___register_modules__installed_modules',
1163
-            EE_Registry::instance()->modules
1164
-        );
1165
-    }
1166
-
1167
-
1168
-
1169
-    /**
1170
-     *    register_module - makes core aware of this module
1171
-     *
1172
-     * @access    public
1173
-     * @param    string $module_path - full path up to and including module folder
1174
-     * @return    bool
1175
-     */
1176
-    public static function register_module($module_path = null)
1177
-    {
1178
-        do_action('AHEE__EE_Config__register_module__begin', $module_path);
1179
-        $module_ext = '.module.php';
1180
-        // make all separators match
1181
-        $module_path = str_replace(array('\\', '/'), DS, $module_path);
1182
-        // does the file path INCLUDE the actual file name as part of the path ?
1183
-        if (strpos($module_path, $module_ext) !== false) {
1184
-            // grab and shortcode file name from directory name and break apart at dots
1185
-            $module_file = explode('.', basename($module_path));
1186
-            // now we need to rebuild the shortcode path
1187
-            $module_path = explode(DS, $module_path);
1188
-            // remove last segment
1189
-            array_pop($module_path);
1190
-            // glue it back together
1191
-            $module_path = implode(DS, $module_path) . DS;
1192
-            // take first segment from file name pieces and sanitize it
1193
-            $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1194
-            // ensure class prefix is added
1195
-            $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1196
-        } else {
1197
-            // we need to generate the filename based off of the folder name
1198
-            // grab and sanitize module name
1199
-            $module = strtolower(basename($module_path));
1200
-            $module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1201
-            // like trailingslashit()
1202
-            $module_path = rtrim($module_path, DS) . DS;
1203
-            // create classname from module directory name
1204
-            $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1205
-            // add class prefix
1206
-            $module_class = 'EED_' . $module;
1207
-        }
1208
-        // does the module exist ?
1209
-        if (! is_readable($module_path . DS . $module_class . $module_ext)) {
1210
-            $msg = sprintf(
1211
-                __(
1212
-                    'The requested %s module file could not be found or is not readable due to file permissions.',
1213
-                    'event_espresso'
1214
-                ),
1215
-                $module
1216
-            );
1217
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1218
-            return false;
1219
-        }
1220
-        // load the module class file
1221
-        require_once($module_path . $module_class . $module_ext);
1222
-        // verify that class exists
1223
-        if (! class_exists($module_class)) {
1224
-            $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1225
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1226
-            return false;
1227
-        }
1228
-        // add to array of registered modules
1229
-        EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1230
-        do_action(
1231
-            'AHEE__EE_Config__register_module__complete',
1232
-            $module_class,
1233
-            EE_Registry::instance()->modules->{$module_class}
1234
-        );
1235
-        return true;
1236
-    }
1237
-
1238
-
1239
-
1240
-    /**
1241
-     *    _initialize_modules
1242
-     *    allow modules to set hooks for the rest of the system
1243
-     *
1244
-     * @access private
1245
-     * @return void
1246
-     */
1247
-    private function _initialize_modules()
1248
-    {
1249
-        // cycle thru shortcode folders
1250
-        foreach (EE_Registry::instance()->modules as $module_class => $module_path) {
1251
-            // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1252
-            // which set hooks ?
1253
-            if (is_admin()) {
1254
-                // fire immediately
1255
-                call_user_func(array($module_class, 'set_hooks_admin'));
1256
-            } else {
1257
-                // delay until other systems are online
1258
-                add_action(
1259
-                    'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
1260
-                    array($module_class, 'set_hooks')
1261
-                );
1262
-            }
1263
-        }
1264
-    }
1265
-
1266
-
1267
-
1268
-    /**
1269
-     *    register_route - adds module method routes to route_map
1270
-     *
1271
-     * @access    public
1272
-     * @param    string $route       - "pretty" public alias for module method
1273
-     * @param    string $module      - module name (classname without EED_ prefix)
1274
-     * @param    string $method_name - the actual module method to be routed to
1275
-     * @param    string $key         - url param key indicating a route is being called
1276
-     * @return    bool
1277
-     */
1278
-    public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee')
1279
-    {
1280
-        do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1281
-        $module = str_replace('EED_', '', $module);
1282
-        $module_class = 'EED_' . $module;
1283
-        if (! isset(EE_Registry::instance()->modules->{$module_class})) {
1284
-            $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module);
1285
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1286
-            return false;
1287
-        }
1288
-        if (empty($route)) {
1289
-            $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route);
1290
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1291
-            return false;
1292
-        }
1293
-        if (! method_exists('EED_' . $module, $method_name)) {
1294
-            $msg = sprintf(
1295
-                __('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1296
-                $route
1297
-            );
1298
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1299
-            return false;
1300
-        }
1301
-        EE_Config::$_module_route_map[$key][$route] = array('EED_' . $module, $method_name);
1302
-        return true;
1303
-    }
1304
-
1305
-
1306
-
1307
-    /**
1308
-     *    get_route - get module method route
1309
-     *
1310
-     * @access    public
1311
-     * @param    string $route - "pretty" public alias for module method
1312
-     * @param    string $key   - url param key indicating a route is being called
1313
-     * @return    string
1314
-     */
1315
-    public static function get_route($route = null, $key = 'ee')
1316
-    {
1317
-        do_action('AHEE__EE_Config__get_route__begin', $route);
1318
-        $route = (string)apply_filters('FHEE__EE_Config__get_route', $route);
1319
-        if (isset(EE_Config::$_module_route_map[$key][$route])) {
1320
-            return EE_Config::$_module_route_map[$key][$route];
1321
-        }
1322
-        return null;
1323
-    }
1324
-
1325
-
1326
-
1327
-    /**
1328
-     *    get_routes - get ALL module method routes
1329
-     *
1330
-     * @access    public
1331
-     * @return    array
1332
-     */
1333
-    public static function get_routes()
1334
-    {
1335
-        return EE_Config::$_module_route_map;
1336
-    }
1337
-
1338
-
1339
-
1340
-    /**
1341
-     *    register_forward - allows modules to forward request to another module for further processing
1342
-     *
1343
-     * @access    public
1344
-     * @param    string       $route   - "pretty" public alias for module method
1345
-     * @param    integer      $status  - integer value corresponding  to status constant strings set in module parent
1346
-     *                                 class, allows different forwards to be served based on status
1347
-     * @param    array|string $forward - function name or array( class, method )
1348
-     * @param    string       $key     - url param key indicating a route is being called
1349
-     * @return    bool
1350
-     */
1351
-    public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee')
1352
-    {
1353
-        do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1354
-        if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1355
-            $msg = sprintf(
1356
-                __('The module route %s for this forward has not been registered.', 'event_espresso'),
1357
-                $route
1358
-            );
1359
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1360
-            return false;
1361
-        }
1362
-        if (empty($forward)) {
1363
-            $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route);
1364
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1365
-            return false;
1366
-        }
1367
-        if (is_array($forward)) {
1368
-            if (! isset($forward[1])) {
1369
-                $msg = sprintf(
1370
-                    __('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1371
-                    $route
1372
-                );
1373
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1374
-                return false;
1375
-            }
1376
-            if (! method_exists($forward[0], $forward[1])) {
1377
-                $msg = sprintf(
1378
-                    __('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1379
-                    $forward[1],
1380
-                    $route
1381
-                );
1382
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1383
-                return false;
1384
-            }
1385
-        } else if (! function_exists($forward)) {
1386
-            $msg = sprintf(
1387
-                __('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1388
-                $forward,
1389
-                $route
1390
-            );
1391
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1392
-            return false;
1393
-        }
1394
-        EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward;
1395
-        return true;
1396
-    }
1397
-
1398
-
1399
-
1400
-    /**
1401
-     *    get_forward - get forwarding route
1402
-     *
1403
-     * @access    public
1404
-     * @param    string  $route  - "pretty" public alias for module method
1405
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1406
-     *                           allows different forwards to be served based on status
1407
-     * @param    string  $key    - url param key indicating a route is being called
1408
-     * @return    string
1409
-     */
1410
-    public static function get_forward($route = null, $status = 0, $key = 'ee')
1411
-    {
1412
-        do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1413
-        if (isset(EE_Config::$_module_forward_map[$key][$route][$status])) {
1414
-            return apply_filters(
1415
-                'FHEE__EE_Config__get_forward',
1416
-                EE_Config::$_module_forward_map[$key][$route][$status],
1417
-                $route,
1418
-                $status
1419
-            );
1420
-        }
1421
-        return null;
1422
-    }
1423
-
1424
-
1425
-
1426
-    /**
1427
-     *    register_forward - allows modules to specify different view templates for different method routes and status
1428
-     *    results
1429
-     *
1430
-     * @access    public
1431
-     * @param    string  $route  - "pretty" public alias for module method
1432
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1433
-     *                           allows different views to be served based on status
1434
-     * @param    string  $view
1435
-     * @param    string  $key    - url param key indicating a route is being called
1436
-     * @return    bool
1437
-     */
1438
-    public static function register_view($route = null, $status = 0, $view = null, $key = 'ee')
1439
-    {
1440
-        do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1441
-        if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1442
-            $msg = sprintf(
1443
-                __('The module route %s for this view has not been registered.', 'event_espresso'),
1444
-                $route
1445
-            );
1446
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1447
-            return false;
1448
-        }
1449
-        if (! is_readable($view)) {
1450
-            $msg = sprintf(
1451
-                __(
1452
-                    'The %s view file could not be found or is not readable due to file permissions.',
1453
-                    'event_espresso'
1454
-                ),
1455
-                $view
1456
-            );
1457
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1458
-            return false;
1459
-        }
1460
-        EE_Config::$_module_view_map[$key][$route][absint($status)] = $view;
1461
-        return true;
1462
-    }
1463
-
1464
-
1465
-
1466
-    /**
1467
-     *    get_view - get view for route and status
1468
-     *
1469
-     * @access    public
1470
-     * @param    string  $route  - "pretty" public alias for module method
1471
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1472
-     *                           allows different views to be served based on status
1473
-     * @param    string  $key    - url param key indicating a route is being called
1474
-     * @return    string
1475
-     */
1476
-    public static function get_view($route = null, $status = 0, $key = 'ee')
1477
-    {
1478
-        do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1479
-        if (isset(EE_Config::$_module_view_map[$key][$route][$status])) {
1480
-            return apply_filters(
1481
-                'FHEE__EE_Config__get_view',
1482
-                EE_Config::$_module_view_map[$key][$route][$status],
1483
-                $route,
1484
-                $status
1485
-            );
1486
-        }
1487
-        return null;
1488
-    }
1489
-
1490
-
1491
-
1492
-    public function update_addon_option_names()
1493
-    {
1494
-        update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names);
1495
-    }
1496
-
1497
-
1498
-
1499
-    public function shutdown()
1500
-    {
1501
-        $this->update_addon_option_names();
1502
-    }
1503
-
1504
-
1505
-
1506
-    /**
1507
-     * @return LegacyShortcodesManager
1508
-     */
1509
-    public static function getLegacyShortcodesManager()
1510
-    {
1511
-
1512
-        if ( ! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) {
1513
-            EE_Config::instance()->legacy_shortcodes_manager = new LegacyShortcodesManager(
1514
-                EE_Registry::instance()
1515
-            );
1516
-        }
1517
-        return EE_Config::instance()->legacy_shortcodes_manager;
1518
-    }
1519
-
1520
-
1521
-
1522
-    /**
1523
-     * register_shortcode - makes core aware of this shortcode
1524
-     *
1525
-     * @deprecated 4.9.26
1526
-     * @param    string $shortcode_path - full path up to and including shortcode folder
1527
-     * @return    bool
1528
-     */
1529
-    public static function register_shortcode($shortcode_path = null)
1530
-    {
1531
-        EE_Error::doing_it_wrong(
1532
-            __METHOD__,
1533
-            __(
1534
-                '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.',
1535
-                'event_espresso'
1536
-            ),
1537
-            '4.9.26'
1538
-        );
1539
-        return EE_Config::instance()->getLegacyShortcodesManager()->registerShortcode($shortcode_path);
1540
-    }
1541
-
1542
-
1543
-
1544
-}
1545
-
1546
-
1547
-
1548
-/**
1549
- * Base class used for config classes. These classes should generally not have
1550
- * magic functions in use, except we'll allow them to magically set and get stuff...
1551
- * basically, they should just be well-defined stdClasses
1552
- */
1553
-class EE_Config_Base
1554
-{
1555
-
1556
-    /**
1557
-     * Utility function for escaping the value of a property and returning.
1558
-     *
1559
-     * @param string $property property name (checks to see if exists).
1560
-     * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1561
-     * @throws \EE_Error
1562
-     */
1563
-    public function get_pretty($property)
1564
-    {
1565
-        if (! property_exists($this, $property)) {
1566
-            throw new EE_Error(
1567
-                sprintf(
1568
-                    __(
1569
-                        '%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.',
1570
-                        'event_espresso'
1571
-                    ),
1572
-                    get_class($this),
1573
-                    $property
1574
-                )
1575
-            );
1576
-        }
1577
-        //just handling escaping of strings for now.
1578
-        if (is_string($this->{$property})) {
1579
-            return stripslashes($this->{$property});
1580
-        }
1581
-        return $this->{$property};
1582
-    }
1583
-
1584
-
1585
-
1586
-    public function populate()
1587
-    {
1588
-        //grab defaults via a new instance of this class.
1589
-        $class_name = get_class($this);
1590
-        $defaults = new $class_name;
1591
-        //loop through the properties for this class and see if they are set.  If they are NOT, then grab the
1592
-        //default from our $defaults object.
1593
-        foreach (get_object_vars($defaults) as $property => $value) {
1594
-            if ($this->{$property} === null) {
1595
-                $this->{$property} = $value;
1596
-            }
1597
-        }
1598
-        //cleanup
1599
-        unset($defaults);
1600
-    }
1601
-
1602
-
1603
-
1604
-    /**
1605
-     *        __isset
1606
-     *
1607
-     * @param $a
1608
-     * @return bool
1609
-     */
1610
-    public function __isset($a)
1611
-    {
1612
-        return false;
1613
-    }
1614
-
1615
-
1616
-
1617
-    /**
1618
-     *        __unset
1619
-     *
1620
-     * @param $a
1621
-     * @return bool
1622
-     */
1623
-    public function __unset($a)
1624
-    {
1625
-        return false;
1626
-    }
1627
-
1628
-
1629
-
1630
-    /**
1631
-     *        __clone
1632
-     */
1633
-    public function __clone()
1634
-    {
1635
-    }
1636
-
1637
-
1638
-
1639
-    /**
1640
-     *        __wakeup
1641
-     */
1642
-    public function __wakeup()
1643
-    {
1644
-    }
1645
-
1646
-
1647
-
1648
-    /**
1649
-     *        __destruct
1650
-     */
1651
-    public function __destruct()
1652
-    {
1653
-    }
1654
-}
1655
-
1656
-
1657
-
1658
-/**
1659
- * Class for defining what's in the EE_Config relating to registration settings
1660
- */
1661
-class EE_Core_Config extends EE_Config_Base
1662
-{
1663
-
1664
-    public $current_blog_id;
1665
-
1666
-    public $ee_ueip_optin;
1667
-
1668
-    public $ee_ueip_has_notified;
1669
-
1670
-    /**
1671
-     * Not to be confused with the 4 critical page variables (See
1672
-     * get_critical_pages_array()), this is just an array of wp posts that have EE
1673
-     * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode
1674
-     * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array.
1675
-     *
1676
-     * @var array
1677
-     */
1678
-    public $post_shortcodes;
1679
-
1680
-    public $module_route_map;
1681
-
1682
-    public $module_forward_map;
1683
-
1684
-    public $module_view_map;
1685
-
1686
-    /**
1687
-     * The next 4 vars are the IDs of critical EE pages.
1688
-     *
1689
-     * @var int
1690
-     */
1691
-    public $reg_page_id;
1692
-
1693
-    public $txn_page_id;
1694
-
1695
-    public $thank_you_page_id;
1696
-
1697
-    public $cancel_page_id;
1698
-
1699
-    /**
1700
-     * The next 4 vars are the URLs of critical EE pages.
1701
-     *
1702
-     * @var int
1703
-     */
1704
-    public $reg_page_url;
1705
-
1706
-    public $txn_page_url;
1707
-
1708
-    public $thank_you_page_url;
1709
-
1710
-    public $cancel_page_url;
1711
-
1712
-    /**
1713
-     * The next vars relate to the custom slugs for EE CPT routes
1714
-     */
1715
-    public $event_cpt_slug;
1716
-
1717
-
1718
-    /**
1719
-     * This caches the _ee_ueip_option in case this config is reset in the same
1720
-     * request across blog switches in a multisite context.
1721
-     * Avoids extra queries to the db for this option.
1722
-     *
1723
-     * @var bool
1724
-     */
1725
-    public static $ee_ueip_option;
1726
-
1727
-
1728
-
1729
-    /**
1730
-     *    class constructor
1731
-     *
1732
-     * @access    public
1733
-     */
1734
-    public function __construct()
1735
-    {
1736
-        // set default organization settings
1737
-        $this->current_blog_id = get_current_blog_id();
1738
-        $this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id;
1739
-        $this->ee_ueip_optin = $this->_get_main_ee_ueip_optin();
1740
-        $this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true;
1741
-        $this->post_shortcodes = array();
1742
-        $this->module_route_map = array();
1743
-        $this->module_forward_map = array();
1744
-        $this->module_view_map = array();
1745
-        // critical EE page IDs
1746
-        $this->reg_page_id = 0;
1747
-        $this->txn_page_id = 0;
1748
-        $this->thank_you_page_id = 0;
1749
-        $this->cancel_page_id = 0;
1750
-        // critical EE page URLs
1751
-        $this->reg_page_url = '';
1752
-        $this->txn_page_url = '';
1753
-        $this->thank_you_page_url = '';
1754
-        $this->cancel_page_url = '';
1755
-        //cpt slugs
1756
-        $this->event_cpt_slug = __('events', 'event_espresso');
1757
-        //ueip constant check
1758
-        if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) {
1759
-            $this->ee_ueip_optin = false;
1760
-            $this->ee_ueip_has_notified = true;
1761
-        }
1762
-    }
1763
-
1764
-
1765
-
1766
-    /**
1767
-     * @return array
1768
-     */
1769
-    public function get_critical_pages_array()
1770
-    {
1771
-        return array(
1772
-            $this->reg_page_id,
1773
-            $this->txn_page_id,
1774
-            $this->thank_you_page_id,
1775
-            $this->cancel_page_id,
1776
-        );
1777
-    }
1778
-
1779
-
1780
-
1781
-    /**
1782
-     * @return array
1783
-     */
1784
-    public function get_critical_pages_shortcodes_array()
1785
-    {
1786
-        return array(
1787
-            $this->reg_page_id       => 'ESPRESSO_CHECKOUT',
1788
-            $this->txn_page_id       => 'ESPRESSO_TXN_PAGE',
1789
-            $this->thank_you_page_id => 'ESPRESSO_THANK_YOU',
1790
-            $this->cancel_page_id    => 'ESPRESSO_CANCELLED',
1791
-        );
1792
-    }
1793
-
1794
-
1795
-
1796
-    /**
1797
-     *  gets/returns URL for EE reg_page
1798
-     *
1799
-     * @access    public
1800
-     * @return    string
1801
-     */
1802
-    public function reg_page_url()
1803
-    {
1804
-        if (! $this->reg_page_url) {
1805
-            $this->reg_page_url = add_query_arg(
1806
-                                      array('uts' => time()),
1807
-                                      get_permalink($this->reg_page_id)
1808
-                                  ) . '#checkout';
1809
-        }
1810
-        return $this->reg_page_url;
1811
-    }
1812
-
1813
-
1814
-
1815
-    /**
1816
-     *  gets/returns URL for EE txn_page
1817
-     *
1818
-     * @param array $query_args like what gets passed to
1819
-     *                          add_query_arg() as the first argument
1820
-     * @access    public
1821
-     * @return    string
1822
-     */
1823
-    public function txn_page_url($query_args = array())
1824
-    {
1825
-        if (! $this->txn_page_url) {
1826
-            $this->txn_page_url = get_permalink($this->txn_page_id);
1827
-        }
1828
-        if ($query_args) {
1829
-            return add_query_arg($query_args, $this->txn_page_url);
1830
-        } else {
1831
-            return $this->txn_page_url;
1832
-        }
1833
-    }
1834
-
1835
-
1836
-
1837
-    /**
1838
-     *  gets/returns URL for EE thank_you_page
1839
-     *
1840
-     * @param array $query_args like what gets passed to
1841
-     *                          add_query_arg() as the first argument
1842
-     * @access    public
1843
-     * @return    string
1844
-     */
1845
-    public function thank_you_page_url($query_args = array())
1846
-    {
1847
-        if (! $this->thank_you_page_url) {
1848
-            $this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1849
-        }
1850
-        if ($query_args) {
1851
-            return add_query_arg($query_args, $this->thank_you_page_url);
1852
-        } else {
1853
-            return $this->thank_you_page_url;
1854
-        }
1855
-    }
1856
-
1857
-
1858
-
1859
-    /**
1860
-     *  gets/returns URL for EE cancel_page
1861
-     *
1862
-     * @access    public
1863
-     * @return    string
1864
-     */
1865
-    public function cancel_page_url()
1866
-    {
1867
-        if (! $this->cancel_page_url) {
1868
-            $this->cancel_page_url = get_permalink($this->cancel_page_id);
1869
-        }
1870
-        return $this->cancel_page_url;
1871
-    }
1872
-
1873
-
1874
-
1875
-    /**
1876
-     * Resets all critical page urls to their original state.  Used primarily by the __sleep() magic method currently.
1877
-     *
1878
-     * @since 4.7.5
1879
-     */
1880
-    protected function _reset_urls()
1881
-    {
1882
-        $this->reg_page_url = '';
1883
-        $this->txn_page_url = '';
1884
-        $this->cancel_page_url = '';
1885
-        $this->thank_you_page_url = '';
1886
-    }
1887
-
1888
-
1889
-
1890
-    /**
1891
-     * Used to return what the optin value is set for the EE User Experience Program.
1892
-     * This accounts for multisite and this value being requested for a subsite.  In multisite, the value is set
1893
-     * on the main site only.
1894
-     *
1895
-     * @return mixed|void
1896
-     */
1897
-    protected function _get_main_ee_ueip_optin()
1898
-    {
1899
-        //if this is the main site then we can just bypass our direct query.
1900
-        if (is_main_site()) {
1901
-            return get_option('ee_ueip_optin', false);
1902
-        }
1903
-        //is this already cached for this request?  If so use it.
1904
-        if ( ! empty(EE_Core_Config::$ee_ueip_option)) {
1905
-            return EE_Core_Config::$ee_ueip_option;
1906
-        }
1907
-        global $wpdb;
1908
-        $current_network_main_site = is_multisite() ? get_current_site() : null;
1909
-        $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1910
-        $option = 'ee_ueip_optin';
1911
-        //set correct table for query
1912
-        $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1913
-        //rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
1914
-        //get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be
1915
-        //re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1916
-        //this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1917
-        //for the purpose of caching.
1918
-        $pre = apply_filters('pre_option_' . $option, false, $option);
1919
-        if (false !== $pre) {
1920
-            EE_Core_Config::$ee_ueip_option = $pre;
1921
-            return EE_Core_Config::$ee_ueip_option;
1922
-        }
1923
-        $row = $wpdb->get_row($wpdb->prepare("SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1",
1924
-            $option));
1925
-        if (is_object($row)) {
1926
-            $value = $row->option_value;
1927
-        } else { //option does not exist so use default.
1928
-            return apply_filters('default_option_' . $option, false, $option);
1929
-        }
1930
-        EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
1931
-        return EE_Core_Config::$ee_ueip_option;
1932
-    }
1933
-
1934
-    /**
1935
-     * Utility function for escaping the value of a property and returning.
1936
-     *
1937
-     * @param string $property property name (checks to see if exists).
1938
-     * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1939
-     * @throws \EE_Error
1940
-     */
1941
-    public function get_pretty($property)
1942
-    {
1943
-        if ($property === 'ee_ueip_optin') {
1944
-            return $this->ee_ueip_optin ? 'yes' : 'no';
1945
-        }
1946
-        return parent::get_pretty($property);
1947
-    }
1948
-
1949
-
1950
-    /**
1951
-     * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values
1952
-     * on the object.
1953
-     *
1954
-     * @return array
1955
-     */
1956
-    public function __sleep()
1957
-    {
1958
-        //reset all url properties
1959
-        $this->_reset_urls();
1960
-        //return what to save to db
1961
-        return array_keys(get_object_vars($this));
1962
-    }
1963
-
1964
-}
1965
-
1966
-
1967
-
1968
-/**
1969
- * Config class for storing info on the Organization
1970
- */
1971
-class EE_Organization_Config extends EE_Config_Base
1972
-{
1973
-
1974
-    /**
1975
-     * @var string $name
1976
-     * eg EE4.1
1977
-     */
1978
-    public $name;
1979
-
1980
-    /**
1981
-     * @var string $address_1
1982
-     * eg 123 Onna Road
1983
-     */
1984
-    public $address_1;
1985
-
1986
-    /**
1987
-     * @var string $address_2
1988
-     * eg PO Box 123
1989
-     */
1990
-    public $address_2;
1991
-
1992
-    /**
1993
-     * @var string $city
1994
-     * eg Inna City
1995
-     */
1996
-    public $city;
1997
-
1998
-    /**
1999
-     * @var int $STA_ID
2000
-     * eg 4
2001
-     */
2002
-    public $STA_ID;
2003
-
2004
-    /**
2005
-     * @var string $CNT_ISO
2006
-     * eg US
2007
-     */
2008
-    public $CNT_ISO;
2009
-
2010
-    /**
2011
-     * @var string $zip
2012
-     * eg 12345  or V1A 2B3
2013
-     */
2014
-    public $zip;
2015
-
2016
-    /**
2017
-     * @var string $email
2018
-     * eg [email protected]
2019
-     */
2020
-    public $email;
2021
-
2022
-
2023
-    /**
2024
-     * @var string $phone
2025
-     * eg. 111-111-1111
2026
-     */
2027
-    public $phone;
2028
-
2029
-
2030
-    /**
2031
-     * @var string $vat
2032
-     * VAT/Tax Number
2033
-     */
2034
-    public $vat;
2035
-
2036
-    /**
2037
-     * @var string $logo_url
2038
-     * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg
2039
-     */
2040
-    public $logo_url;
2041
-
2042
-
2043
-    /**
2044
-     * The below are all various properties for holding links to organization social network profiles
2045
-     *
2046
-     * @var string
2047
-     */
2048
-    /**
2049
-     * facebook (facebook.com/profile.name)
2050
-     *
2051
-     * @var string
2052
-     */
2053
-    public $facebook;
2054
-
2055
-
2056
-    /**
2057
-     * twitter (twitter.com/twitter_handle)
2058
-     *
2059
-     * @var string
2060
-     */
2061
-    public $twitter;
2062
-
2063
-
2064
-    /**
2065
-     * linkedin (linkedin.com/in/profile_name)
2066
-     *
2067
-     * @var string
2068
-     */
2069
-    public $linkedin;
2070
-
2071
-
2072
-    /**
2073
-     * pinterest (www.pinterest.com/profile_name)
2074
-     *
2075
-     * @var string
2076
-     */
2077
-    public $pinterest;
2078
-
2079
-
2080
-    /**
2081
-     * google+ (google.com/+profileName)
2082
-     *
2083
-     * @var string
2084
-     */
2085
-    public $google;
2086
-
2087
-
2088
-    /**
2089
-     * instagram (instagram.com/handle)
2090
-     *
2091
-     * @var string
2092
-     */
2093
-    public $instagram;
2094
-
2095
-
2096
-
2097
-    /**
2098
-     *    class constructor
2099
-     *
2100
-     * @access    public
2101
-     */
2102
-    public function __construct()
2103
-    {
2104
-        // set default organization settings
2105
-        //decode HTML entities from the WP blogname, because it's stored in the DB with HTML entities encoded
2106
-        $this->name = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES);
2107
-        $this->address_1 = '123 Onna Road';
2108
-        $this->address_2 = 'PO Box 123';
2109
-        $this->city = 'Inna City';
2110
-        $this->STA_ID = 4;
2111
-        $this->CNT_ISO = 'US';
2112
-        $this->zip = '12345';
2113
-        $this->email = get_bloginfo('admin_email');
2114
-        $this->phone = '';
2115
-        $this->vat = '123456789';
2116
-        $this->logo_url = '';
2117
-        $this->facebook = '';
2118
-        $this->twitter = '';
2119
-        $this->linkedin = '';
2120
-        $this->pinterest = '';
2121
-        $this->google = '';
2122
-        $this->instagram = '';
2123
-    }
2124
-
2125
-}
2126
-
2127
-
2128
-
2129
-/**
2130
- * Class for defining what's in the EE_Config relating to currency
2131
- */
2132
-class EE_Currency_Config extends EE_Config_Base
2133
-{
2134
-
2135
-    /**
2136
-     * @var string $code
2137
-     * eg 'US'
2138
-     */
2139
-    public $code;
2140
-
2141
-    /**
2142
-     * @var string $name
2143
-     * eg 'Dollar'
2144
-     */
2145
-    public $name;
2146
-
2147
-    /**
2148
-     * plural name
2149
-     *
2150
-     * @var string $plural
2151
-     * eg 'Dollars'
2152
-     */
2153
-    public $plural;
2154
-
2155
-    /**
2156
-     * currency sign
2157
-     *
2158
-     * @var string $sign
2159
-     * eg '$'
2160
-     */
2161
-    public $sign;
2162
-
2163
-    /**
2164
-     * Whether the currency sign should come before the number or not
2165
-     *
2166
-     * @var boolean $sign_b4
2167
-     */
2168
-    public $sign_b4;
2169
-
2170
-    /**
2171
-     * How many digits should come after the decimal place
2172
-     *
2173
-     * @var int $dec_plc
2174
-     */
2175
-    public $dec_plc;
2176
-
2177
-    /**
2178
-     * Symbol to use for decimal mark
2179
-     *
2180
-     * @var string $dec_mrk
2181
-     * eg '.'
2182
-     */
2183
-    public $dec_mrk;
2184
-
2185
-    /**
2186
-     * Symbol to use for thousands
2187
-     *
2188
-     * @var string $thsnds
2189
-     * eg ','
2190
-     */
2191
-    public $thsnds;
2192
-
2193
-
2194
-
2195
-    /**
2196
-     *    class constructor
2197
-     *
2198
-     * @access    public
2199
-     * @param string $CNT_ISO
2200
-     * @throws \EE_Error
2201
-     */
2202
-    public function __construct($CNT_ISO = '')
2203
-    {
2204
-        /** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */
2205
-        $table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
2206
-        // get country code from organization settings or use default
2207
-        $ORG_CNT = isset(EE_Registry::instance()->CFG->organization)
2208
-                   && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config
2209
-            ? EE_Registry::instance()->CFG->organization->CNT_ISO
2210
-            : '';
2211
-        // but override if requested
2212
-        $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT;
2213
-        // 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
2214
-        if (
2215
-            ! empty($CNT_ISO)
2216
-            && EE_Maintenance_Mode::instance()->models_can_query()
2217
-            && $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table())
2218
-        ) {
2219
-            // retrieve the country settings from the db, just in case they have been customized
2220
-            $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
2221
-            if ($country instanceof EE_Country) {
2222
-                $this->code = $country->currency_code();    // currency code: USD, CAD, EUR
2223
-                $this->name = $country->currency_name_single();    // Dollar
2224
-                $this->plural = $country->currency_name_plural();    // Dollars
2225
-                $this->sign = $country->currency_sign();            // currency sign: $
2226
-                $this->sign_b4 = $country->currency_sign_before();        // currency sign before or after: $TRUE  or  FALSE$
2227
-                $this->dec_plc = $country->currency_decimal_places();    // decimal places: 2 = 0.00  3 = 0.000
2228
-                $this->dec_mrk = $country->currency_decimal_mark();    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2229
-                $this->thsnds = $country->currency_thousands_separator();    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2230
-            }
2231
-        }
2232
-        // fallback to hardcoded defaults, in case the above failed
2233
-        if (empty($this->code)) {
2234
-            // set default currency settings
2235
-            $this->code = 'USD';    // currency code: USD, CAD, EUR
2236
-            $this->name = __('Dollar', 'event_espresso');    // Dollar
2237
-            $this->plural = __('Dollars', 'event_espresso');    // Dollars
2238
-            $this->sign = '$';    // currency sign: $
2239
-            $this->sign_b4 = true;    // currency sign before or after: $TRUE  or  FALSE$
2240
-            $this->dec_plc = 2;    // decimal places: 2 = 0.00  3 = 0.000
2241
-            $this->dec_mrk = '.';    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2242
-            $this->thsnds = ',';    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2243
-        }
2244
-    }
2245
-}
2246
-
2247
-
2248
-
2249
-/**
2250
- * Class for defining what's in the EE_Config relating to registration settings
2251
- */
2252
-class EE_Registration_Config extends EE_Config_Base
2253
-{
2254
-
2255
-    /**
2256
-     * Default registration status
2257
-     *
2258
-     * @var string $default_STS_ID
2259
-     * eg 'RPP'
2260
-     */
2261
-    public $default_STS_ID;
2262
-
2263
-
2264
-    /**
2265
-     * For new events, this will be the default value for the maximum number of tickets (equivalent to maximum number of
2266
-     * registrations)
2267
-     * @var int
2268
-     */
2269
-    public $default_maximum_number_of_tickets;
2270
-
2271
-
2272
-    /**
2273
-     * level of validation to apply to email addresses
2274
-     *
2275
-     * @var string $email_validation_level
2276
-     * options: 'basic', 'wp_default', 'i18n', 'i18n_dns'
2277
-     */
2278
-    public $email_validation_level;
2279
-
2280
-    /**
2281
-     *    whether or not to show alternate payment options during the reg process if payment status is pending
2282
-     *
2283
-     * @var boolean $show_pending_payment_options
2284
-     */
2285
-    public $show_pending_payment_options;
2286
-
2287
-    /**
2288
-     * Whether to skip the registration confirmation page
2289
-     *
2290
-     * @var boolean $skip_reg_confirmation
2291
-     */
2292
-    public $skip_reg_confirmation;
2293
-
2294
-    /**
2295
-     * an array of SPCO reg steps where:
2296
-     *        the keys denotes the reg step order
2297
-     *        each element consists of an array with the following elements:
2298
-     *            "file_path" => the file path to the EE_SPCO_Reg_Step class
2299
-     *            "class_name" => the specific EE_SPCO_Reg_Step child class name
2300
-     *            "slug" => the URL param used to trigger the reg step
2301
-     *
2302
-     * @var array $reg_steps
2303
-     */
2304
-    public $reg_steps;
2305
-
2306
-    /**
2307
-     * Whether registration confirmation should be the last page of SPCO
2308
-     *
2309
-     * @var boolean $reg_confirmation_last
2310
-     */
2311
-    public $reg_confirmation_last;
2312
-
2313
-    /**
2314
-     * Whether or not to enable the EE Bot Trap
2315
-     *
2316
-     * @var boolean $use_bot_trap
2317
-     */
2318
-    public $use_bot_trap;
2319
-
2320
-    /**
2321
-     * Whether or not to encrypt some data sent by the EE Bot Trap
2322
-     *
2323
-     * @var boolean $use_encryption
2324
-     */
2325
-    public $use_encryption;
2326
-
2327
-    /**
2328
-     * Whether or not to use ReCaptcha
2329
-     *
2330
-     * @var boolean $use_captcha
2331
-     */
2332
-    public $use_captcha;
2333
-
2334
-    /**
2335
-     * ReCaptcha Theme
2336
-     *
2337
-     * @var string $recaptcha_theme
2338
-     *    options: 'dark', 'light', 'invisible'
2339
-     */
2340
-    public $recaptcha_theme;
1544
+}
2341 1545
 
2342
-    /**
2343
-     * ReCaptcha Badge - determines the position of the reCAPTCHA badge if using Invisible ReCaptcha.
2344
-     *
2345
-     * @var string $recaptcha_badge
2346
-     *    options: 'bottomright', 'bottomleft', 'inline'
2347
-     */
2348
-    public $recaptcha_badge;
2349 1546
 
2350
-    /**
2351
-     * ReCaptcha Type
2352
-     *
2353
-     * @var string $recaptcha_type
2354
-     *    options: 'audio', 'image'
2355
-     */
2356
-    public $recaptcha_type;
2357 1547
 
2358
-    /**
2359
-     * ReCaptcha language
2360
-     *
2361
-     * @var string $recaptcha_language
2362
-     * eg 'en'
2363
-     */
2364
-    public $recaptcha_language;
1548
+/**
1549
+ * Base class used for config classes. These classes should generally not have
1550
+ * magic functions in use, except we'll allow them to magically set and get stuff...
1551
+ * basically, they should just be well-defined stdClasses
1552
+ */
1553
+class EE_Config_Base
1554
+{
2365 1555
 
2366
-    /**
2367
-     * ReCaptcha public key
2368
-     *
2369
-     * @var string $recaptcha_publickey
2370
-     */
2371
-    public $recaptcha_publickey;
1556
+	/**
1557
+	 * Utility function for escaping the value of a property and returning.
1558
+	 *
1559
+	 * @param string $property property name (checks to see if exists).
1560
+	 * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1561
+	 * @throws \EE_Error
1562
+	 */
1563
+	public function get_pretty($property)
1564
+	{
1565
+		if (! property_exists($this, $property)) {
1566
+			throw new EE_Error(
1567
+				sprintf(
1568
+					__(
1569
+						'%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.',
1570
+						'event_espresso'
1571
+					),
1572
+					get_class($this),
1573
+					$property
1574
+				)
1575
+			);
1576
+		}
1577
+		//just handling escaping of strings for now.
1578
+		if (is_string($this->{$property})) {
1579
+			return stripslashes($this->{$property});
1580
+		}
1581
+		return $this->{$property};
1582
+	}
1583
+
1584
+
1585
+
1586
+	public function populate()
1587
+	{
1588
+		//grab defaults via a new instance of this class.
1589
+		$class_name = get_class($this);
1590
+		$defaults = new $class_name;
1591
+		//loop through the properties for this class and see if they are set.  If they are NOT, then grab the
1592
+		//default from our $defaults object.
1593
+		foreach (get_object_vars($defaults) as $property => $value) {
1594
+			if ($this->{$property} === null) {
1595
+				$this->{$property} = $value;
1596
+			}
1597
+		}
1598
+		//cleanup
1599
+		unset($defaults);
1600
+	}
1601
+
1602
+
1603
+
1604
+	/**
1605
+	 *        __isset
1606
+	 *
1607
+	 * @param $a
1608
+	 * @return bool
1609
+	 */
1610
+	public function __isset($a)
1611
+	{
1612
+		return false;
1613
+	}
1614
+
1615
+
1616
+
1617
+	/**
1618
+	 *        __unset
1619
+	 *
1620
+	 * @param $a
1621
+	 * @return bool
1622
+	 */
1623
+	public function __unset($a)
1624
+	{
1625
+		return false;
1626
+	}
1627
+
1628
+
1629
+
1630
+	/**
1631
+	 *        __clone
1632
+	 */
1633
+	public function __clone()
1634
+	{
1635
+	}
1636
+
1637
+
1638
+
1639
+	/**
1640
+	 *        __wakeup
1641
+	 */
1642
+	public function __wakeup()
1643
+	{
1644
+	}
1645
+
1646
+
1647
+
1648
+	/**
1649
+	 *        __destruct
1650
+	 */
1651
+	public function __destruct()
1652
+	{
1653
+	}
1654
+}
2372 1655
 
2373
-    /**
2374
-     * ReCaptcha private key
2375
-     *
2376
-     * @var string $recaptcha_privatekey
2377
-     */
2378
-    public $recaptcha_privatekey;
2379 1656
 
2380
-    /**
2381
-     * array of form names protected by ReCaptcha
2382
-     *
2383
-     * @var array $recaptcha_protected_forms
2384
-     */
2385
-    public $recaptcha_protected_forms;
2386 1657
 
2387
-    /**
2388
-     * ReCaptcha width
2389
-     *
2390
-     * @var int $recaptcha_width
2391
-     * @deprecated
2392
-     */
2393
-    public $recaptcha_width;
1658
+/**
1659
+ * Class for defining what's in the EE_Config relating to registration settings
1660
+ */
1661
+class EE_Core_Config extends EE_Config_Base
1662
+{
2394 1663
 
2395
-    /**
2396
-     * Whether or not invalid attempts to directly access the registration checkout page should be tracked.
2397
-     *
2398
-     * @var boolean $track_invalid_checkout_access
2399
-     */
2400
-    protected $track_invalid_checkout_access = true;
1664
+	public $current_blog_id;
1665
+
1666
+	public $ee_ueip_optin;
1667
+
1668
+	public $ee_ueip_has_notified;
1669
+
1670
+	/**
1671
+	 * Not to be confused with the 4 critical page variables (See
1672
+	 * get_critical_pages_array()), this is just an array of wp posts that have EE
1673
+	 * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode
1674
+	 * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array.
1675
+	 *
1676
+	 * @var array
1677
+	 */
1678
+	public $post_shortcodes;
1679
+
1680
+	public $module_route_map;
1681
+
1682
+	public $module_forward_map;
1683
+
1684
+	public $module_view_map;
1685
+
1686
+	/**
1687
+	 * The next 4 vars are the IDs of critical EE pages.
1688
+	 *
1689
+	 * @var int
1690
+	 */
1691
+	public $reg_page_id;
1692
+
1693
+	public $txn_page_id;
1694
+
1695
+	public $thank_you_page_id;
1696
+
1697
+	public $cancel_page_id;
1698
+
1699
+	/**
1700
+	 * The next 4 vars are the URLs of critical EE pages.
1701
+	 *
1702
+	 * @var int
1703
+	 */
1704
+	public $reg_page_url;
1705
+
1706
+	public $txn_page_url;
1707
+
1708
+	public $thank_you_page_url;
1709
+
1710
+	public $cancel_page_url;
1711
+
1712
+	/**
1713
+	 * The next vars relate to the custom slugs for EE CPT routes
1714
+	 */
1715
+	public $event_cpt_slug;
1716
+
1717
+
1718
+	/**
1719
+	 * This caches the _ee_ueip_option in case this config is reset in the same
1720
+	 * request across blog switches in a multisite context.
1721
+	 * Avoids extra queries to the db for this option.
1722
+	 *
1723
+	 * @var bool
1724
+	 */
1725
+	public static $ee_ueip_option;
1726
+
1727
+
1728
+
1729
+	/**
1730
+	 *    class constructor
1731
+	 *
1732
+	 * @access    public
1733
+	 */
1734
+	public function __construct()
1735
+	{
1736
+		// set default organization settings
1737
+		$this->current_blog_id = get_current_blog_id();
1738
+		$this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id;
1739
+		$this->ee_ueip_optin = $this->_get_main_ee_ueip_optin();
1740
+		$this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true;
1741
+		$this->post_shortcodes = array();
1742
+		$this->module_route_map = array();
1743
+		$this->module_forward_map = array();
1744
+		$this->module_view_map = array();
1745
+		// critical EE page IDs
1746
+		$this->reg_page_id = 0;
1747
+		$this->txn_page_id = 0;
1748
+		$this->thank_you_page_id = 0;
1749
+		$this->cancel_page_id = 0;
1750
+		// critical EE page URLs
1751
+		$this->reg_page_url = '';
1752
+		$this->txn_page_url = '';
1753
+		$this->thank_you_page_url = '';
1754
+		$this->cancel_page_url = '';
1755
+		//cpt slugs
1756
+		$this->event_cpt_slug = __('events', 'event_espresso');
1757
+		//ueip constant check
1758
+		if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) {
1759
+			$this->ee_ueip_optin = false;
1760
+			$this->ee_ueip_has_notified = true;
1761
+		}
1762
+	}
1763
+
1764
+
1765
+
1766
+	/**
1767
+	 * @return array
1768
+	 */
1769
+	public function get_critical_pages_array()
1770
+	{
1771
+		return array(
1772
+			$this->reg_page_id,
1773
+			$this->txn_page_id,
1774
+			$this->thank_you_page_id,
1775
+			$this->cancel_page_id,
1776
+		);
1777
+	}
1778
+
1779
+
1780
+
1781
+	/**
1782
+	 * @return array
1783
+	 */
1784
+	public function get_critical_pages_shortcodes_array()
1785
+	{
1786
+		return array(
1787
+			$this->reg_page_id       => 'ESPRESSO_CHECKOUT',
1788
+			$this->txn_page_id       => 'ESPRESSO_TXN_PAGE',
1789
+			$this->thank_you_page_id => 'ESPRESSO_THANK_YOU',
1790
+			$this->cancel_page_id    => 'ESPRESSO_CANCELLED',
1791
+		);
1792
+	}
1793
+
1794
+
1795
+
1796
+	/**
1797
+	 *  gets/returns URL for EE reg_page
1798
+	 *
1799
+	 * @access    public
1800
+	 * @return    string
1801
+	 */
1802
+	public function reg_page_url()
1803
+	{
1804
+		if (! $this->reg_page_url) {
1805
+			$this->reg_page_url = add_query_arg(
1806
+									  array('uts' => time()),
1807
+									  get_permalink($this->reg_page_id)
1808
+								  ) . '#checkout';
1809
+		}
1810
+		return $this->reg_page_url;
1811
+	}
1812
+
1813
+
1814
+
1815
+	/**
1816
+	 *  gets/returns URL for EE txn_page
1817
+	 *
1818
+	 * @param array $query_args like what gets passed to
1819
+	 *                          add_query_arg() as the first argument
1820
+	 * @access    public
1821
+	 * @return    string
1822
+	 */
1823
+	public function txn_page_url($query_args = array())
1824
+	{
1825
+		if (! $this->txn_page_url) {
1826
+			$this->txn_page_url = get_permalink($this->txn_page_id);
1827
+		}
1828
+		if ($query_args) {
1829
+			return add_query_arg($query_args, $this->txn_page_url);
1830
+		} else {
1831
+			return $this->txn_page_url;
1832
+		}
1833
+	}
1834
+
1835
+
1836
+
1837
+	/**
1838
+	 *  gets/returns URL for EE thank_you_page
1839
+	 *
1840
+	 * @param array $query_args like what gets passed to
1841
+	 *                          add_query_arg() as the first argument
1842
+	 * @access    public
1843
+	 * @return    string
1844
+	 */
1845
+	public function thank_you_page_url($query_args = array())
1846
+	{
1847
+		if (! $this->thank_you_page_url) {
1848
+			$this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1849
+		}
1850
+		if ($query_args) {
1851
+			return add_query_arg($query_args, $this->thank_you_page_url);
1852
+		} else {
1853
+			return $this->thank_you_page_url;
1854
+		}
1855
+	}
1856
+
1857
+
1858
+
1859
+	/**
1860
+	 *  gets/returns URL for EE cancel_page
1861
+	 *
1862
+	 * @access    public
1863
+	 * @return    string
1864
+	 */
1865
+	public function cancel_page_url()
1866
+	{
1867
+		if (! $this->cancel_page_url) {
1868
+			$this->cancel_page_url = get_permalink($this->cancel_page_id);
1869
+		}
1870
+		return $this->cancel_page_url;
1871
+	}
1872
+
1873
+
1874
+
1875
+	/**
1876
+	 * Resets all critical page urls to their original state.  Used primarily by the __sleep() magic method currently.
1877
+	 *
1878
+	 * @since 4.7.5
1879
+	 */
1880
+	protected function _reset_urls()
1881
+	{
1882
+		$this->reg_page_url = '';
1883
+		$this->txn_page_url = '';
1884
+		$this->cancel_page_url = '';
1885
+		$this->thank_you_page_url = '';
1886
+	}
1887
+
1888
+
1889
+
1890
+	/**
1891
+	 * Used to return what the optin value is set for the EE User Experience Program.
1892
+	 * This accounts for multisite and this value being requested for a subsite.  In multisite, the value is set
1893
+	 * on the main site only.
1894
+	 *
1895
+	 * @return mixed|void
1896
+	 */
1897
+	protected function _get_main_ee_ueip_optin()
1898
+	{
1899
+		//if this is the main site then we can just bypass our direct query.
1900
+		if (is_main_site()) {
1901
+			return get_option('ee_ueip_optin', false);
1902
+		}
1903
+		//is this already cached for this request?  If so use it.
1904
+		if ( ! empty(EE_Core_Config::$ee_ueip_option)) {
1905
+			return EE_Core_Config::$ee_ueip_option;
1906
+		}
1907
+		global $wpdb;
1908
+		$current_network_main_site = is_multisite() ? get_current_site() : null;
1909
+		$current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1910
+		$option = 'ee_ueip_optin';
1911
+		//set correct table for query
1912
+		$table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1913
+		//rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
1914
+		//get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be
1915
+		//re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1916
+		//this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1917
+		//for the purpose of caching.
1918
+		$pre = apply_filters('pre_option_' . $option, false, $option);
1919
+		if (false !== $pre) {
1920
+			EE_Core_Config::$ee_ueip_option = $pre;
1921
+			return EE_Core_Config::$ee_ueip_option;
1922
+		}
1923
+		$row = $wpdb->get_row($wpdb->prepare("SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1",
1924
+			$option));
1925
+		if (is_object($row)) {
1926
+			$value = $row->option_value;
1927
+		} else { //option does not exist so use default.
1928
+			return apply_filters('default_option_' . $option, false, $option);
1929
+		}
1930
+		EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
1931
+		return EE_Core_Config::$ee_ueip_option;
1932
+	}
1933
+
1934
+	/**
1935
+	 * Utility function for escaping the value of a property and returning.
1936
+	 *
1937
+	 * @param string $property property name (checks to see if exists).
1938
+	 * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1939
+	 * @throws \EE_Error
1940
+	 */
1941
+	public function get_pretty($property)
1942
+	{
1943
+		if ($property === 'ee_ueip_optin') {
1944
+			return $this->ee_ueip_optin ? 'yes' : 'no';
1945
+		}
1946
+		return parent::get_pretty($property);
1947
+	}
1948
+
1949
+
1950
+	/**
1951
+	 * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values
1952
+	 * on the object.
1953
+	 *
1954
+	 * @return array
1955
+	 */
1956
+	public function __sleep()
1957
+	{
1958
+		//reset all url properties
1959
+		$this->_reset_urls();
1960
+		//return what to save to db
1961
+		return array_keys(get_object_vars($this));
1962
+	}
2401 1963
 
1964
+}
2402 1965
 
2403 1966
 
2404
-    /**
2405
-     *    class constructor
2406
-     *
2407
-     * @access    public
2408
-     */
2409
-    public function __construct()
2410
-    {
2411
-        // set default registration settings
2412
-        $this->default_STS_ID = EEM_Registration::status_id_pending_payment;
2413
-        $this->email_validation_level = 'wp_default';
2414
-        $this->show_pending_payment_options = true;
2415
-        $this->skip_reg_confirmation = false;
2416
-        $this->reg_steps = array();
2417
-        $this->reg_confirmation_last = false;
2418
-        $this->use_bot_trap = true;
2419
-        $this->use_encryption = true;
2420
-        $this->use_captcha = false;
2421
-        $this->recaptcha_theme = 'light';
2422
-        $this->recaptcha_badge = 'bottomleft';
2423
-        $this->recaptcha_type = 'image';
2424
-        $this->recaptcha_language = 'en';
2425
-        $this->recaptcha_publickey = null;
2426
-        $this->recaptcha_privatekey = null;
2427
-        $this->recaptcha_protected_forms = array();
2428
-        $this->recaptcha_width = 500;
2429
-        $this->default_maximum_number_of_tickets = 10;
2430
-    }
2431
-
2432
-
2433
-
2434
-    /**
2435
-     * This is called by the config loader and hooks are initialized AFTER the config has been populated.
2436
-     *
2437
-     * @since 4.8.8.rc.019
2438
-     */
2439
-    public function do_hooks()
2440
-    {
2441
-        add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event'));
2442
-        add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_max_ticket_on_EEM_Event'));
2443
-    }
2444 1967
 
1968
+/**
1969
+ * Config class for storing info on the Organization
1970
+ */
1971
+class EE_Organization_Config extends EE_Config_Base
1972
+{
2445 1973
 
1974
+	/**
1975
+	 * @var string $name
1976
+	 * eg EE4.1
1977
+	 */
1978
+	public $name;
1979
+
1980
+	/**
1981
+	 * @var string $address_1
1982
+	 * eg 123 Onna Road
1983
+	 */
1984
+	public $address_1;
1985
+
1986
+	/**
1987
+	 * @var string $address_2
1988
+	 * eg PO Box 123
1989
+	 */
1990
+	public $address_2;
1991
+
1992
+	/**
1993
+	 * @var string $city
1994
+	 * eg Inna City
1995
+	 */
1996
+	public $city;
1997
+
1998
+	/**
1999
+	 * @var int $STA_ID
2000
+	 * eg 4
2001
+	 */
2002
+	public $STA_ID;
2003
+
2004
+	/**
2005
+	 * @var string $CNT_ISO
2006
+	 * eg US
2007
+	 */
2008
+	public $CNT_ISO;
2009
+
2010
+	/**
2011
+	 * @var string $zip
2012
+	 * eg 12345  or V1A 2B3
2013
+	 */
2014
+	public $zip;
2015
+
2016
+	/**
2017
+	 * @var string $email
2018
+	 * eg [email protected]
2019
+	 */
2020
+	public $email;
2021
+
2022
+
2023
+	/**
2024
+	 * @var string $phone
2025
+	 * eg. 111-111-1111
2026
+	 */
2027
+	public $phone;
2028
+
2029
+
2030
+	/**
2031
+	 * @var string $vat
2032
+	 * VAT/Tax Number
2033
+	 */
2034
+	public $vat;
2035
+
2036
+	/**
2037
+	 * @var string $logo_url
2038
+	 * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg
2039
+	 */
2040
+	public $logo_url;
2041
+
2042
+
2043
+	/**
2044
+	 * The below are all various properties for holding links to organization social network profiles
2045
+	 *
2046
+	 * @var string
2047
+	 */
2048
+	/**
2049
+	 * facebook (facebook.com/profile.name)
2050
+	 *
2051
+	 * @var string
2052
+	 */
2053
+	public $facebook;
2054
+
2055
+
2056
+	/**
2057
+	 * twitter (twitter.com/twitter_handle)
2058
+	 *
2059
+	 * @var string
2060
+	 */
2061
+	public $twitter;
2062
+
2063
+
2064
+	/**
2065
+	 * linkedin (linkedin.com/in/profile_name)
2066
+	 *
2067
+	 * @var string
2068
+	 */
2069
+	public $linkedin;
2070
+
2071
+
2072
+	/**
2073
+	 * pinterest (www.pinterest.com/profile_name)
2074
+	 *
2075
+	 * @var string
2076
+	 */
2077
+	public $pinterest;
2078
+
2079
+
2080
+	/**
2081
+	 * google+ (google.com/+profileName)
2082
+	 *
2083
+	 * @var string
2084
+	 */
2085
+	public $google;
2086
+
2087
+
2088
+	/**
2089
+	 * instagram (instagram.com/handle)
2090
+	 *
2091
+	 * @var string
2092
+	 */
2093
+	public $instagram;
2094
+
2095
+
2096
+
2097
+	/**
2098
+	 *    class constructor
2099
+	 *
2100
+	 * @access    public
2101
+	 */
2102
+	public function __construct()
2103
+	{
2104
+		// set default organization settings
2105
+		//decode HTML entities from the WP blogname, because it's stored in the DB with HTML entities encoded
2106
+		$this->name = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES);
2107
+		$this->address_1 = '123 Onna Road';
2108
+		$this->address_2 = 'PO Box 123';
2109
+		$this->city = 'Inna City';
2110
+		$this->STA_ID = 4;
2111
+		$this->CNT_ISO = 'US';
2112
+		$this->zip = '12345';
2113
+		$this->email = get_bloginfo('admin_email');
2114
+		$this->phone = '';
2115
+		$this->vat = '123456789';
2116
+		$this->logo_url = '';
2117
+		$this->facebook = '';
2118
+		$this->twitter = '';
2119
+		$this->linkedin = '';
2120
+		$this->pinterest = '';
2121
+		$this->google = '';
2122
+		$this->instagram = '';
2123
+	}
2446 2124
 
2447
-    /**
2448
-     * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_default_registration_status
2449
-     * field matches the config setting for default_STS_ID.
2450
-     */
2451
-    public function set_default_reg_status_on_EEM_Event()
2452
-    {
2453
-        EEM_Event::set_default_reg_status($this->default_STS_ID);
2454
-    }
2125
+}
2455 2126
 
2456 2127
 
2457
-    /**
2458
-     * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_additional_limit field
2459
-     * for Events matches the config setting for default_maximum_number_of_tickets
2460
-     */
2461
-    public function set_default_max_ticket_on_EEM_Event()
2462
-    {
2463
-        EEM_Event::set_default_additional_limit($this->default_maximum_number_of_tickets);
2464
-    }
2465 2128
 
2129
+/**
2130
+ * Class for defining what's in the EE_Config relating to currency
2131
+ */
2132
+class EE_Currency_Config extends EE_Config_Base
2133
+{
2466 2134
 
2135
+	/**
2136
+	 * @var string $code
2137
+	 * eg 'US'
2138
+	 */
2139
+	public $code;
2140
+
2141
+	/**
2142
+	 * @var string $name
2143
+	 * eg 'Dollar'
2144
+	 */
2145
+	public $name;
2146
+
2147
+	/**
2148
+	 * plural name
2149
+	 *
2150
+	 * @var string $plural
2151
+	 * eg 'Dollars'
2152
+	 */
2153
+	public $plural;
2154
+
2155
+	/**
2156
+	 * currency sign
2157
+	 *
2158
+	 * @var string $sign
2159
+	 * eg '$'
2160
+	 */
2161
+	public $sign;
2162
+
2163
+	/**
2164
+	 * Whether the currency sign should come before the number or not
2165
+	 *
2166
+	 * @var boolean $sign_b4
2167
+	 */
2168
+	public $sign_b4;
2169
+
2170
+	/**
2171
+	 * How many digits should come after the decimal place
2172
+	 *
2173
+	 * @var int $dec_plc
2174
+	 */
2175
+	public $dec_plc;
2176
+
2177
+	/**
2178
+	 * Symbol to use for decimal mark
2179
+	 *
2180
+	 * @var string $dec_mrk
2181
+	 * eg '.'
2182
+	 */
2183
+	public $dec_mrk;
2184
+
2185
+	/**
2186
+	 * Symbol to use for thousands
2187
+	 *
2188
+	 * @var string $thsnds
2189
+	 * eg ','
2190
+	 */
2191
+	public $thsnds;
2192
+
2193
+
2194
+
2195
+	/**
2196
+	 *    class constructor
2197
+	 *
2198
+	 * @access    public
2199
+	 * @param string $CNT_ISO
2200
+	 * @throws \EE_Error
2201
+	 */
2202
+	public function __construct($CNT_ISO = '')
2203
+	{
2204
+		/** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */
2205
+		$table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
2206
+		// get country code from organization settings or use default
2207
+		$ORG_CNT = isset(EE_Registry::instance()->CFG->organization)
2208
+				   && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config
2209
+			? EE_Registry::instance()->CFG->organization->CNT_ISO
2210
+			: '';
2211
+		// but override if requested
2212
+		$CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT;
2213
+		// 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
2214
+		if (
2215
+			! empty($CNT_ISO)
2216
+			&& EE_Maintenance_Mode::instance()->models_can_query()
2217
+			&& $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table())
2218
+		) {
2219
+			// retrieve the country settings from the db, just in case they have been customized
2220
+			$country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
2221
+			if ($country instanceof EE_Country) {
2222
+				$this->code = $country->currency_code();    // currency code: USD, CAD, EUR
2223
+				$this->name = $country->currency_name_single();    // Dollar
2224
+				$this->plural = $country->currency_name_plural();    // Dollars
2225
+				$this->sign = $country->currency_sign();            // currency sign: $
2226
+				$this->sign_b4 = $country->currency_sign_before();        // currency sign before or after: $TRUE  or  FALSE$
2227
+				$this->dec_plc = $country->currency_decimal_places();    // decimal places: 2 = 0.00  3 = 0.000
2228
+				$this->dec_mrk = $country->currency_decimal_mark();    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2229
+				$this->thsnds = $country->currency_thousands_separator();    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2230
+			}
2231
+		}
2232
+		// fallback to hardcoded defaults, in case the above failed
2233
+		if (empty($this->code)) {
2234
+			// set default currency settings
2235
+			$this->code = 'USD';    // currency code: USD, CAD, EUR
2236
+			$this->name = __('Dollar', 'event_espresso');    // Dollar
2237
+			$this->plural = __('Dollars', 'event_espresso');    // Dollars
2238
+			$this->sign = '$';    // currency sign: $
2239
+			$this->sign_b4 = true;    // currency sign before or after: $TRUE  or  FALSE$
2240
+			$this->dec_plc = 2;    // decimal places: 2 = 0.00  3 = 0.000
2241
+			$this->dec_mrk = '.';    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2242
+			$this->thsnds = ',';    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2243
+		}
2244
+	}
2245
+}
2467 2246
 
2468
-    /**
2469
-     * @return boolean
2470
-     */
2471
-    public function track_invalid_checkout_access()
2472
-    {
2473
-        return $this->track_invalid_checkout_access;
2474
-    }
2475 2247
 
2476 2248
 
2249
+/**
2250
+ * Class for defining what's in the EE_Config relating to registration settings
2251
+ */
2252
+class EE_Registration_Config extends EE_Config_Base
2253
+{
2477 2254
 
2478
-    /**
2479
-     * @param boolean $track_invalid_checkout_access
2480
-     */
2481
-    public function set_track_invalid_checkout_access($track_invalid_checkout_access)
2482
-    {
2483
-        $this->track_invalid_checkout_access = filter_var(
2484
-            $track_invalid_checkout_access,
2485
-            FILTER_VALIDATE_BOOLEAN
2486
-        );
2487
-    }
2255
+	/**
2256
+	 * Default registration status
2257
+	 *
2258
+	 * @var string $default_STS_ID
2259
+	 * eg 'RPP'
2260
+	 */
2261
+	public $default_STS_ID;
2262
+
2263
+
2264
+	/**
2265
+	 * For new events, this will be the default value for the maximum number of tickets (equivalent to maximum number of
2266
+	 * registrations)
2267
+	 * @var int
2268
+	 */
2269
+	public $default_maximum_number_of_tickets;
2270
+
2271
+
2272
+	/**
2273
+	 * level of validation to apply to email addresses
2274
+	 *
2275
+	 * @var string $email_validation_level
2276
+	 * options: 'basic', 'wp_default', 'i18n', 'i18n_dns'
2277
+	 */
2278
+	public $email_validation_level;
2279
+
2280
+	/**
2281
+	 *    whether or not to show alternate payment options during the reg process if payment status is pending
2282
+	 *
2283
+	 * @var boolean $show_pending_payment_options
2284
+	 */
2285
+	public $show_pending_payment_options;
2286
+
2287
+	/**
2288
+	 * Whether to skip the registration confirmation page
2289
+	 *
2290
+	 * @var boolean $skip_reg_confirmation
2291
+	 */
2292
+	public $skip_reg_confirmation;
2293
+
2294
+	/**
2295
+	 * an array of SPCO reg steps where:
2296
+	 *        the keys denotes the reg step order
2297
+	 *        each element consists of an array with the following elements:
2298
+	 *            "file_path" => the file path to the EE_SPCO_Reg_Step class
2299
+	 *            "class_name" => the specific EE_SPCO_Reg_Step child class name
2300
+	 *            "slug" => the URL param used to trigger the reg step
2301
+	 *
2302
+	 * @var array $reg_steps
2303
+	 */
2304
+	public $reg_steps;
2305
+
2306
+	/**
2307
+	 * Whether registration confirmation should be the last page of SPCO
2308
+	 *
2309
+	 * @var boolean $reg_confirmation_last
2310
+	 */
2311
+	public $reg_confirmation_last;
2312
+
2313
+	/**
2314
+	 * Whether or not to enable the EE Bot Trap
2315
+	 *
2316
+	 * @var boolean $use_bot_trap
2317
+	 */
2318
+	public $use_bot_trap;
2319
+
2320
+	/**
2321
+	 * Whether or not to encrypt some data sent by the EE Bot Trap
2322
+	 *
2323
+	 * @var boolean $use_encryption
2324
+	 */
2325
+	public $use_encryption;
2326
+
2327
+	/**
2328
+	 * Whether or not to use ReCaptcha
2329
+	 *
2330
+	 * @var boolean $use_captcha
2331
+	 */
2332
+	public $use_captcha;
2333
+
2334
+	/**
2335
+	 * ReCaptcha Theme
2336
+	 *
2337
+	 * @var string $recaptcha_theme
2338
+	 *    options: 'dark', 'light', 'invisible'
2339
+	 */
2340
+	public $recaptcha_theme;
2341
+
2342
+	/**
2343
+	 * ReCaptcha Badge - determines the position of the reCAPTCHA badge if using Invisible ReCaptcha.
2344
+	 *
2345
+	 * @var string $recaptcha_badge
2346
+	 *    options: 'bottomright', 'bottomleft', 'inline'
2347
+	 */
2348
+	public $recaptcha_badge;
2349
+
2350
+	/**
2351
+	 * ReCaptcha Type
2352
+	 *
2353
+	 * @var string $recaptcha_type
2354
+	 *    options: 'audio', 'image'
2355
+	 */
2356
+	public $recaptcha_type;
2357
+
2358
+	/**
2359
+	 * ReCaptcha language
2360
+	 *
2361
+	 * @var string $recaptcha_language
2362
+	 * eg 'en'
2363
+	 */
2364
+	public $recaptcha_language;
2365
+
2366
+	/**
2367
+	 * ReCaptcha public key
2368
+	 *
2369
+	 * @var string $recaptcha_publickey
2370
+	 */
2371
+	public $recaptcha_publickey;
2372
+
2373
+	/**
2374
+	 * ReCaptcha private key
2375
+	 *
2376
+	 * @var string $recaptcha_privatekey
2377
+	 */
2378
+	public $recaptcha_privatekey;
2379
+
2380
+	/**
2381
+	 * array of form names protected by ReCaptcha
2382
+	 *
2383
+	 * @var array $recaptcha_protected_forms
2384
+	 */
2385
+	public $recaptcha_protected_forms;
2386
+
2387
+	/**
2388
+	 * ReCaptcha width
2389
+	 *
2390
+	 * @var int $recaptcha_width
2391
+	 * @deprecated
2392
+	 */
2393
+	public $recaptcha_width;
2394
+
2395
+	/**
2396
+	 * Whether or not invalid attempts to directly access the registration checkout page should be tracked.
2397
+	 *
2398
+	 * @var boolean $track_invalid_checkout_access
2399
+	 */
2400
+	protected $track_invalid_checkout_access = true;
2401
+
2402
+
2403
+
2404
+	/**
2405
+	 *    class constructor
2406
+	 *
2407
+	 * @access    public
2408
+	 */
2409
+	public function __construct()
2410
+	{
2411
+		// set default registration settings
2412
+		$this->default_STS_ID = EEM_Registration::status_id_pending_payment;
2413
+		$this->email_validation_level = 'wp_default';
2414
+		$this->show_pending_payment_options = true;
2415
+		$this->skip_reg_confirmation = false;
2416
+		$this->reg_steps = array();
2417
+		$this->reg_confirmation_last = false;
2418
+		$this->use_bot_trap = true;
2419
+		$this->use_encryption = true;
2420
+		$this->use_captcha = false;
2421
+		$this->recaptcha_theme = 'light';
2422
+		$this->recaptcha_badge = 'bottomleft';
2423
+		$this->recaptcha_type = 'image';
2424
+		$this->recaptcha_language = 'en';
2425
+		$this->recaptcha_publickey = null;
2426
+		$this->recaptcha_privatekey = null;
2427
+		$this->recaptcha_protected_forms = array();
2428
+		$this->recaptcha_width = 500;
2429
+		$this->default_maximum_number_of_tickets = 10;
2430
+	}
2431
+
2432
+
2433
+
2434
+	/**
2435
+	 * This is called by the config loader and hooks are initialized AFTER the config has been populated.
2436
+	 *
2437
+	 * @since 4.8.8.rc.019
2438
+	 */
2439
+	public function do_hooks()
2440
+	{
2441
+		add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event'));
2442
+		add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_max_ticket_on_EEM_Event'));
2443
+	}
2444
+
2445
+
2446
+
2447
+	/**
2448
+	 * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_default_registration_status
2449
+	 * field matches the config setting for default_STS_ID.
2450
+	 */
2451
+	public function set_default_reg_status_on_EEM_Event()
2452
+	{
2453
+		EEM_Event::set_default_reg_status($this->default_STS_ID);
2454
+	}
2455
+
2456
+
2457
+	/**
2458
+	 * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_additional_limit field
2459
+	 * for Events matches the config setting for default_maximum_number_of_tickets
2460
+	 */
2461
+	public function set_default_max_ticket_on_EEM_Event()
2462
+	{
2463
+		EEM_Event::set_default_additional_limit($this->default_maximum_number_of_tickets);
2464
+	}
2465
+
2466
+
2467
+
2468
+	/**
2469
+	 * @return boolean
2470
+	 */
2471
+	public function track_invalid_checkout_access()
2472
+	{
2473
+		return $this->track_invalid_checkout_access;
2474
+	}
2475
+
2476
+
2477
+
2478
+	/**
2479
+	 * @param boolean $track_invalid_checkout_access
2480
+	 */
2481
+	public function set_track_invalid_checkout_access($track_invalid_checkout_access)
2482
+	{
2483
+		$this->track_invalid_checkout_access = filter_var(
2484
+			$track_invalid_checkout_access,
2485
+			FILTER_VALIDATE_BOOLEAN
2486
+		);
2487
+	}
2488 2488
 
2489 2489
 
2490 2490
 
@@ -2498,160 +2498,160 @@  discard block
 block discarded – undo
2498 2498
 class EE_Admin_Config extends EE_Config_Base
2499 2499
 {
2500 2500
 
2501
-    /**
2502
-     * @var boolean $use_personnel_manager
2503
-     */
2504
-    public $use_personnel_manager;
2505
-
2506
-    /**
2507
-     * @var boolean $use_dashboard_widget
2508
-     */
2509
-    public $use_dashboard_widget;
2510
-
2511
-    /**
2512
-     * @var int $events_in_dashboard
2513
-     */
2514
-    public $events_in_dashboard;
2515
-
2516
-    /**
2517
-     * @var boolean $use_event_timezones
2518
-     */
2519
-    public $use_event_timezones;
2520
-
2521
-    /**
2522
-     * @var boolean $use_full_logging
2523
-     */
2524
-    public $use_full_logging;
2525
-
2526
-    /**
2527
-     * @var string $log_file_name
2528
-     */
2529
-    public $log_file_name;
2530
-
2531
-    /**
2532
-     * @var string $debug_file_name
2533
-     */
2534
-    public $debug_file_name;
2535
-
2536
-    /**
2537
-     * @var boolean $use_remote_logging
2538
-     */
2539
-    public $use_remote_logging;
2540
-
2541
-    /**
2542
-     * @var string $remote_logging_url
2543
-     */
2544
-    public $remote_logging_url;
2545
-
2546
-    /**
2547
-     * @var boolean $show_reg_footer
2548
-     */
2549
-    public $show_reg_footer;
2550
-
2551
-    /**
2552
-     * @var string $affiliate_id
2553
-     */
2554
-    public $affiliate_id;
2555
-
2556
-    /**
2557
-     * help tours on or off (global setting)
2558
-     *
2559
-     * @var boolean
2560
-     */
2561
-    public $help_tour_activation;
2562
-
2563
-    /**
2564
-     * adds extra layer of encoding to session data to prevent serialization errors
2565
-     * but is incompatible with some server configuration errors
2566
-     * if you get "500 internal server errors" during registration, try turning this on
2567
-     * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off
2568
-     *
2569
-     * @var boolean $encode_session_data
2570
-     */
2571
-    private $encode_session_data = false;
2572
-
2573
-
2574
-
2575
-    /**
2576
-     *    class constructor
2577
-     *
2578
-     * @access    public
2579
-     */
2580
-    public function __construct()
2581
-    {
2582
-        // set default general admin settings
2583
-        $this->use_personnel_manager = true;
2584
-        $this->use_dashboard_widget = true;
2585
-        $this->events_in_dashboard = 30;
2586
-        $this->use_event_timezones = false;
2587
-        $this->use_full_logging = false;
2588
-        $this->use_remote_logging = false;
2589
-        $this->remote_logging_url = null;
2590
-        $this->show_reg_footer = true;
2591
-        $this->affiliate_id = 'default';
2592
-        $this->help_tour_activation = true;
2593
-        $this->encode_session_data = false;
2594
-    }
2595
-
2596
-
2597
-
2598
-    /**
2599
-     * @param bool $reset
2600
-     * @return string
2601
-     */
2602
-    public function log_file_name($reset = false)
2603
-    {
2604
-        if (empty($this->log_file_name) || $reset) {
2605
-            $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2606
-            EE_Config::instance()->update_espresso_config(false, false);
2607
-        }
2608
-        return $this->log_file_name;
2609
-    }
2610
-
2611
-
2612
-
2613
-    /**
2614
-     * @param bool $reset
2615
-     * @return string
2616
-     */
2617
-    public function debug_file_name($reset = false)
2618
-    {
2619
-        if (empty($this->debug_file_name) || $reset) {
2620
-            $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2621
-            EE_Config::instance()->update_espresso_config(false, false);
2622
-        }
2623
-        return $this->debug_file_name;
2624
-    }
2625
-
2626
-
2627
-
2628
-    /**
2629
-     * @return string
2630
-     */
2631
-    public function affiliate_id()
2632
-    {
2633
-        return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default';
2634
-    }
2635
-
2636
-
2637
-
2638
-    /**
2639
-     * @return boolean
2640
-     */
2641
-    public function encode_session_data()
2642
-    {
2643
-        return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN);
2644
-    }
2645
-
2646
-
2647
-
2648
-    /**
2649
-     * @param boolean $encode_session_data
2650
-     */
2651
-    public function set_encode_session_data($encode_session_data)
2652
-    {
2653
-        $this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN);
2654
-    }
2501
+	/**
2502
+	 * @var boolean $use_personnel_manager
2503
+	 */
2504
+	public $use_personnel_manager;
2505
+
2506
+	/**
2507
+	 * @var boolean $use_dashboard_widget
2508
+	 */
2509
+	public $use_dashboard_widget;
2510
+
2511
+	/**
2512
+	 * @var int $events_in_dashboard
2513
+	 */
2514
+	public $events_in_dashboard;
2515
+
2516
+	/**
2517
+	 * @var boolean $use_event_timezones
2518
+	 */
2519
+	public $use_event_timezones;
2520
+
2521
+	/**
2522
+	 * @var boolean $use_full_logging
2523
+	 */
2524
+	public $use_full_logging;
2525
+
2526
+	/**
2527
+	 * @var string $log_file_name
2528
+	 */
2529
+	public $log_file_name;
2530
+
2531
+	/**
2532
+	 * @var string $debug_file_name
2533
+	 */
2534
+	public $debug_file_name;
2535
+
2536
+	/**
2537
+	 * @var boolean $use_remote_logging
2538
+	 */
2539
+	public $use_remote_logging;
2540
+
2541
+	/**
2542
+	 * @var string $remote_logging_url
2543
+	 */
2544
+	public $remote_logging_url;
2545
+
2546
+	/**
2547
+	 * @var boolean $show_reg_footer
2548
+	 */
2549
+	public $show_reg_footer;
2550
+
2551
+	/**
2552
+	 * @var string $affiliate_id
2553
+	 */
2554
+	public $affiliate_id;
2555
+
2556
+	/**
2557
+	 * help tours on or off (global setting)
2558
+	 *
2559
+	 * @var boolean
2560
+	 */
2561
+	public $help_tour_activation;
2562
+
2563
+	/**
2564
+	 * adds extra layer of encoding to session data to prevent serialization errors
2565
+	 * but is incompatible with some server configuration errors
2566
+	 * if you get "500 internal server errors" during registration, try turning this on
2567
+	 * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off
2568
+	 *
2569
+	 * @var boolean $encode_session_data
2570
+	 */
2571
+	private $encode_session_data = false;
2572
+
2573
+
2574
+
2575
+	/**
2576
+	 *    class constructor
2577
+	 *
2578
+	 * @access    public
2579
+	 */
2580
+	public function __construct()
2581
+	{
2582
+		// set default general admin settings
2583
+		$this->use_personnel_manager = true;
2584
+		$this->use_dashboard_widget = true;
2585
+		$this->events_in_dashboard = 30;
2586
+		$this->use_event_timezones = false;
2587
+		$this->use_full_logging = false;
2588
+		$this->use_remote_logging = false;
2589
+		$this->remote_logging_url = null;
2590
+		$this->show_reg_footer = true;
2591
+		$this->affiliate_id = 'default';
2592
+		$this->help_tour_activation = true;
2593
+		$this->encode_session_data = false;
2594
+	}
2595
+
2596
+
2597
+
2598
+	/**
2599
+	 * @param bool $reset
2600
+	 * @return string
2601
+	 */
2602
+	public function log_file_name($reset = false)
2603
+	{
2604
+		if (empty($this->log_file_name) || $reset) {
2605
+			$this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2606
+			EE_Config::instance()->update_espresso_config(false, false);
2607
+		}
2608
+		return $this->log_file_name;
2609
+	}
2610
+
2611
+
2612
+
2613
+	/**
2614
+	 * @param bool $reset
2615
+	 * @return string
2616
+	 */
2617
+	public function debug_file_name($reset = false)
2618
+	{
2619
+		if (empty($this->debug_file_name) || $reset) {
2620
+			$this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2621
+			EE_Config::instance()->update_espresso_config(false, false);
2622
+		}
2623
+		return $this->debug_file_name;
2624
+	}
2625
+
2626
+
2627
+
2628
+	/**
2629
+	 * @return string
2630
+	 */
2631
+	public function affiliate_id()
2632
+	{
2633
+		return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default';
2634
+	}
2635
+
2636
+
2637
+
2638
+	/**
2639
+	 * @return boolean
2640
+	 */
2641
+	public function encode_session_data()
2642
+	{
2643
+		return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN);
2644
+	}
2645
+
2646
+
2647
+
2648
+	/**
2649
+	 * @param boolean $encode_session_data
2650
+	 */
2651
+	public function set_encode_session_data($encode_session_data)
2652
+	{
2653
+		$this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN);
2654
+	}
2655 2655
 
2656 2656
 
2657 2657
 
@@ -2665,71 +2665,71 @@  discard block
 block discarded – undo
2665 2665
 class EE_Template_Config extends EE_Config_Base
2666 2666
 {
2667 2667
 
2668
-    /**
2669
-     * @var boolean $enable_default_style
2670
-     */
2671
-    public $enable_default_style;
2672
-
2673
-    /**
2674
-     * @var string $custom_style_sheet
2675
-     */
2676
-    public $custom_style_sheet;
2677
-
2678
-    /**
2679
-     * @var boolean $display_address_in_regform
2680
-     */
2681
-    public $display_address_in_regform;
2682
-
2683
-    /**
2684
-     * @var int $display_description_on_multi_reg_page
2685
-     */
2686
-    public $display_description_on_multi_reg_page;
2687
-
2688
-    /**
2689
-     * @var boolean $use_custom_templates
2690
-     */
2691
-    public $use_custom_templates;
2692
-
2693
-    /**
2694
-     * @var string $current_espresso_theme
2695
-     */
2696
-    public $current_espresso_theme;
2697
-
2698
-    /**
2699
-     * @var EE_Ticket_Selector_Config $EED_Ticket_Selector
2700
-     */
2701
-    public $EED_Ticket_Selector;
2702
-
2703
-    /**
2704
-     * @var EE_Event_Single_Config $EED_Event_Single
2705
-     */
2706
-    public $EED_Event_Single;
2707
-
2708
-    /**
2709
-     * @var EE_Events_Archive_Config $EED_Events_Archive
2710
-     */
2711
-    public $EED_Events_Archive;
2712
-
2713
-
2714
-
2715
-    /**
2716
-     *    class constructor
2717
-     *
2718
-     * @access    public
2719
-     */
2720
-    public function __construct()
2721
-    {
2722
-        // set default template settings
2723
-        $this->enable_default_style = true;
2724
-        $this->custom_style_sheet = null;
2725
-        $this->display_address_in_regform = true;
2726
-        $this->display_description_on_multi_reg_page = false;
2727
-        $this->use_custom_templates = false;
2728
-        $this->current_espresso_theme = 'Espresso_Arabica_2014';
2729
-        $this->EED_Event_Single = null;
2730
-        $this->EED_Events_Archive = null;
2731
-        $this->EED_Ticket_Selector = null;
2732
-    }
2668
+	/**
2669
+	 * @var boolean $enable_default_style
2670
+	 */
2671
+	public $enable_default_style;
2672
+
2673
+	/**
2674
+	 * @var string $custom_style_sheet
2675
+	 */
2676
+	public $custom_style_sheet;
2677
+
2678
+	/**
2679
+	 * @var boolean $display_address_in_regform
2680
+	 */
2681
+	public $display_address_in_regform;
2682
+
2683
+	/**
2684
+	 * @var int $display_description_on_multi_reg_page
2685
+	 */
2686
+	public $display_description_on_multi_reg_page;
2687
+
2688
+	/**
2689
+	 * @var boolean $use_custom_templates
2690
+	 */
2691
+	public $use_custom_templates;
2692
+
2693
+	/**
2694
+	 * @var string $current_espresso_theme
2695
+	 */
2696
+	public $current_espresso_theme;
2697
+
2698
+	/**
2699
+	 * @var EE_Ticket_Selector_Config $EED_Ticket_Selector
2700
+	 */
2701
+	public $EED_Ticket_Selector;
2702
+
2703
+	/**
2704
+	 * @var EE_Event_Single_Config $EED_Event_Single
2705
+	 */
2706
+	public $EED_Event_Single;
2707
+
2708
+	/**
2709
+	 * @var EE_Events_Archive_Config $EED_Events_Archive
2710
+	 */
2711
+	public $EED_Events_Archive;
2712
+
2713
+
2714
+
2715
+	/**
2716
+	 *    class constructor
2717
+	 *
2718
+	 * @access    public
2719
+	 */
2720
+	public function __construct()
2721
+	{
2722
+		// set default template settings
2723
+		$this->enable_default_style = true;
2724
+		$this->custom_style_sheet = null;
2725
+		$this->display_address_in_regform = true;
2726
+		$this->display_description_on_multi_reg_page = false;
2727
+		$this->use_custom_templates = false;
2728
+		$this->current_espresso_theme = 'Espresso_Arabica_2014';
2729
+		$this->EED_Event_Single = null;
2730
+		$this->EED_Events_Archive = null;
2731
+		$this->EED_Ticket_Selector = null;
2732
+	}
2733 2733
 
2734 2734
 }
2735 2735
 
@@ -2741,115 +2741,115 @@  discard block
 block discarded – undo
2741 2741
 class EE_Map_Config extends EE_Config_Base
2742 2742
 {
2743 2743
 
2744
-    /**
2745
-     * @var boolean $use_google_maps
2746
-     */
2747
-    public $use_google_maps;
2748
-
2749
-    /**
2750
-     * @var string $api_key
2751
-     */
2752
-    public $google_map_api_key;
2753
-
2754
-    /**
2755
-     * @var int $event_details_map_width
2756
-     */
2757
-    public $event_details_map_width;
2758
-
2759
-    /**
2760
-     * @var int $event_details_map_height
2761
-     */
2762
-    public $event_details_map_height;
2763
-
2764
-    /**
2765
-     * @var int $event_details_map_zoom
2766
-     */
2767
-    public $event_details_map_zoom;
2768
-
2769
-    /**
2770
-     * @var boolean $event_details_display_nav
2771
-     */
2772
-    public $event_details_display_nav;
2773
-
2774
-    /**
2775
-     * @var boolean $event_details_nav_size
2776
-     */
2777
-    public $event_details_nav_size;
2778
-
2779
-    /**
2780
-     * @var string $event_details_control_type
2781
-     */
2782
-    public $event_details_control_type;
2783
-
2784
-    /**
2785
-     * @var string $event_details_map_align
2786
-     */
2787
-    public $event_details_map_align;
2788
-
2789
-    /**
2790
-     * @var int $event_list_map_width
2791
-     */
2792
-    public $event_list_map_width;
2793
-
2794
-    /**
2795
-     * @var int $event_list_map_height
2796
-     */
2797
-    public $event_list_map_height;
2798
-
2799
-    /**
2800
-     * @var int $event_list_map_zoom
2801
-     */
2802
-    public $event_list_map_zoom;
2803
-
2804
-    /**
2805
-     * @var boolean $event_list_display_nav
2806
-     */
2807
-    public $event_list_display_nav;
2808
-
2809
-    /**
2810
-     * @var boolean $event_list_nav_size
2811
-     */
2812
-    public $event_list_nav_size;
2813
-
2814
-    /**
2815
-     * @var string $event_list_control_type
2816
-     */
2817
-    public $event_list_control_type;
2818
-
2819
-    /**
2820
-     * @var string $event_list_map_align
2821
-     */
2822
-    public $event_list_map_align;
2823
-
2824
-
2825
-
2826
-    /**
2827
-     *    class constructor
2828
-     *
2829
-     * @access    public
2830
-     */
2831
-    public function __construct()
2832
-    {
2833
-        // set default map settings
2834
-        $this->use_google_maps = true;
2835
-        $this->google_map_api_key = '';
2836
-        // for event details pages (reg page)
2837
-        $this->event_details_map_width = 585;            // ee_map_width_single
2838
-        $this->event_details_map_height = 362;            // ee_map_height_single
2839
-        $this->event_details_map_zoom = 14;            // ee_map_zoom_single
2840
-        $this->event_details_display_nav = true;            // ee_map_nav_display_single
2841
-        $this->event_details_nav_size = false;            // ee_map_nav_size_single
2842
-        $this->event_details_control_type = 'default';        // ee_map_type_control_single
2843
-        $this->event_details_map_align = 'center';            // ee_map_align_single
2844
-        // for event list pages
2845
-        $this->event_list_map_width = 300;            // ee_map_width
2846
-        $this->event_list_map_height = 185;        // ee_map_height
2847
-        $this->event_list_map_zoom = 12;            // ee_map_zoom
2848
-        $this->event_list_display_nav = false;        // ee_map_nav_display
2849
-        $this->event_list_nav_size = true;            // ee_map_nav_size
2850
-        $this->event_list_control_type = 'dropdown';        // ee_map_type_control
2851
-        $this->event_list_map_align = 'center';            // ee_map_align
2852
-    }
2744
+	/**
2745
+	 * @var boolean $use_google_maps
2746
+	 */
2747
+	public $use_google_maps;
2748
+
2749
+	/**
2750
+	 * @var string $api_key
2751
+	 */
2752
+	public $google_map_api_key;
2753
+
2754
+	/**
2755
+	 * @var int $event_details_map_width
2756
+	 */
2757
+	public $event_details_map_width;
2758
+
2759
+	/**
2760
+	 * @var int $event_details_map_height
2761
+	 */
2762
+	public $event_details_map_height;
2763
+
2764
+	/**
2765
+	 * @var int $event_details_map_zoom
2766
+	 */
2767
+	public $event_details_map_zoom;
2768
+
2769
+	/**
2770
+	 * @var boolean $event_details_display_nav
2771
+	 */
2772
+	public $event_details_display_nav;
2773
+
2774
+	/**
2775
+	 * @var boolean $event_details_nav_size
2776
+	 */
2777
+	public $event_details_nav_size;
2778
+
2779
+	/**
2780
+	 * @var string $event_details_control_type
2781
+	 */
2782
+	public $event_details_control_type;
2783
+
2784
+	/**
2785
+	 * @var string $event_details_map_align
2786
+	 */
2787
+	public $event_details_map_align;
2788
+
2789
+	/**
2790
+	 * @var int $event_list_map_width
2791
+	 */
2792
+	public $event_list_map_width;
2793
+
2794
+	/**
2795
+	 * @var int $event_list_map_height
2796
+	 */
2797
+	public $event_list_map_height;
2798
+
2799
+	/**
2800
+	 * @var int $event_list_map_zoom
2801
+	 */
2802
+	public $event_list_map_zoom;
2803
+
2804
+	/**
2805
+	 * @var boolean $event_list_display_nav
2806
+	 */
2807
+	public $event_list_display_nav;
2808
+
2809
+	/**
2810
+	 * @var boolean $event_list_nav_size
2811
+	 */
2812
+	public $event_list_nav_size;
2813
+
2814
+	/**
2815
+	 * @var string $event_list_control_type
2816
+	 */
2817
+	public $event_list_control_type;
2818
+
2819
+	/**
2820
+	 * @var string $event_list_map_align
2821
+	 */
2822
+	public $event_list_map_align;
2823
+
2824
+
2825
+
2826
+	/**
2827
+	 *    class constructor
2828
+	 *
2829
+	 * @access    public
2830
+	 */
2831
+	public function __construct()
2832
+	{
2833
+		// set default map settings
2834
+		$this->use_google_maps = true;
2835
+		$this->google_map_api_key = '';
2836
+		// for event details pages (reg page)
2837
+		$this->event_details_map_width = 585;            // ee_map_width_single
2838
+		$this->event_details_map_height = 362;            // ee_map_height_single
2839
+		$this->event_details_map_zoom = 14;            // ee_map_zoom_single
2840
+		$this->event_details_display_nav = true;            // ee_map_nav_display_single
2841
+		$this->event_details_nav_size = false;            // ee_map_nav_size_single
2842
+		$this->event_details_control_type = 'default';        // ee_map_type_control_single
2843
+		$this->event_details_map_align = 'center';            // ee_map_align_single
2844
+		// for event list pages
2845
+		$this->event_list_map_width = 300;            // ee_map_width
2846
+		$this->event_list_map_height = 185;        // ee_map_height
2847
+		$this->event_list_map_zoom = 12;            // ee_map_zoom
2848
+		$this->event_list_display_nav = false;        // ee_map_nav_display
2849
+		$this->event_list_nav_size = true;            // ee_map_nav_size
2850
+		$this->event_list_control_type = 'dropdown';        // ee_map_type_control
2851
+		$this->event_list_map_align = 'center';            // ee_map_align
2852
+	}
2853 2853
 
2854 2854
 }
2855 2855
 
@@ -2861,47 +2861,47 @@  discard block
 block discarded – undo
2861 2861
 class EE_Events_Archive_Config extends EE_Config_Base
2862 2862
 {
2863 2863
 
2864
-    public $display_status_banner;
2864
+	public $display_status_banner;
2865 2865
 
2866
-    public $display_description;
2866
+	public $display_description;
2867 2867
 
2868
-    public $display_ticket_selector;
2868
+	public $display_ticket_selector;
2869 2869
 
2870
-    public $display_datetimes;
2870
+	public $display_datetimes;
2871 2871
 
2872
-    public $display_venue;
2872
+	public $display_venue;
2873 2873
 
2874
-    public $display_expired_events;
2874
+	public $display_expired_events;
2875 2875
 
2876
-    public $use_sortable_display_order;
2876
+	public $use_sortable_display_order;
2877 2877
 
2878
-    public $display_order_tickets;
2878
+	public $display_order_tickets;
2879 2879
 
2880
-    public $display_order_datetimes;
2880
+	public $display_order_datetimes;
2881 2881
 
2882
-    public $display_order_event;
2882
+	public $display_order_event;
2883 2883
 
2884
-    public $display_order_venue;
2884
+	public $display_order_venue;
2885 2885
 
2886 2886
 
2887 2887
 
2888
-    /**
2889
-     *    class constructor
2890
-     */
2891
-    public function __construct()
2892
-    {
2893
-        $this->display_status_banner = 0;
2894
-        $this->display_description = 1;
2895
-        $this->display_ticket_selector = 0;
2896
-        $this->display_datetimes = 1;
2897
-        $this->display_venue = 0;
2898
-        $this->display_expired_events = 0;
2899
-        $this->use_sortable_display_order = false;
2900
-        $this->display_order_tickets = 100;
2901
-        $this->display_order_datetimes = 110;
2902
-        $this->display_order_event = 120;
2903
-        $this->display_order_venue = 130;
2904
-    }
2888
+	/**
2889
+	 *    class constructor
2890
+	 */
2891
+	public function __construct()
2892
+	{
2893
+		$this->display_status_banner = 0;
2894
+		$this->display_description = 1;
2895
+		$this->display_ticket_selector = 0;
2896
+		$this->display_datetimes = 1;
2897
+		$this->display_venue = 0;
2898
+		$this->display_expired_events = 0;
2899
+		$this->use_sortable_display_order = false;
2900
+		$this->display_order_tickets = 100;
2901
+		$this->display_order_datetimes = 110;
2902
+		$this->display_order_event = 120;
2903
+		$this->display_order_venue = 130;
2904
+	}
2905 2905
 }
2906 2906
 
2907 2907
 
@@ -2912,35 +2912,35 @@  discard block
 block discarded – undo
2912 2912
 class EE_Event_Single_Config extends EE_Config_Base
2913 2913
 {
2914 2914
 
2915
-    public $display_status_banner_single;
2915
+	public $display_status_banner_single;
2916 2916
 
2917
-    public $display_venue;
2917
+	public $display_venue;
2918 2918
 
2919
-    public $use_sortable_display_order;
2919
+	public $use_sortable_display_order;
2920 2920
 
2921
-    public $display_order_tickets;
2921
+	public $display_order_tickets;
2922 2922
 
2923
-    public $display_order_datetimes;
2923
+	public $display_order_datetimes;
2924 2924
 
2925
-    public $display_order_event;
2925
+	public $display_order_event;
2926 2926
 
2927
-    public $display_order_venue;
2927
+	public $display_order_venue;
2928 2928
 
2929 2929
 
2930 2930
 
2931
-    /**
2932
-     *    class constructor
2933
-     */
2934
-    public function __construct()
2935
-    {
2936
-        $this->display_status_banner_single = 0;
2937
-        $this->display_venue = 1;
2938
-        $this->use_sortable_display_order = false;
2939
-        $this->display_order_tickets = 100;
2940
-        $this->display_order_datetimes = 110;
2941
-        $this->display_order_event = 120;
2942
-        $this->display_order_venue = 130;
2943
-    }
2931
+	/**
2932
+	 *    class constructor
2933
+	 */
2934
+	public function __construct()
2935
+	{
2936
+		$this->display_status_banner_single = 0;
2937
+		$this->display_venue = 1;
2938
+		$this->use_sortable_display_order = false;
2939
+		$this->display_order_tickets = 100;
2940
+		$this->display_order_datetimes = 110;
2941
+		$this->display_order_event = 120;
2942
+		$this->display_order_venue = 130;
2943
+	}
2944 2944
 }
2945 2945
 
2946 2946
 
@@ -2951,152 +2951,152 @@  discard block
 block discarded – undo
2951 2951
 class EE_Ticket_Selector_Config extends EE_Config_Base
2952 2952
 {
2953 2953
 
2954
-    /**
2955
-     * constant to indicate that a datetime selector should NEVER be shown for ticket selectors
2956
-     */
2957
-    const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector';
2958
-
2959
-    /**
2960
-     * constant to indicate that a datetime selector should only be shown for ticket selectors
2961
-     * when the number of datetimes for the event matches the value set for $datetime_selector_threshold
2962
-     */
2963
-    const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector';
2964
-
2965
-    /**
2966
-     * @var boolean $show_ticket_sale_columns
2967
-     */
2968
-    public $show_ticket_sale_columns;
2969
-
2970
-    /**
2971
-     * @var boolean $show_ticket_details
2972
-     */
2973
-    public $show_ticket_details;
2974
-
2975
-    /**
2976
-     * @var boolean $show_expired_tickets
2977
-     */
2978
-    public $show_expired_tickets;
2979
-
2980
-    /**
2981
-     * whether or not to display a dropdown box populated with event datetimes
2982
-     * that toggles which tickets are displayed for a ticket selector.
2983
-     * uses one of the *_DATETIME_SELECTOR constants defined above
2984
-     *
2985
-     * @var string $show_datetime_selector
2986
-     */
2987
-    private $show_datetime_selector = 'no_datetime_selector';
2988
-
2989
-    /**
2990
-     * the number of datetimes an event has to have before conditionally displaying a datetime selector
2991
-     *
2992
-     * @var int $datetime_selector_threshold
2993
-     */
2994
-    private $datetime_selector_threshold = 3;
2995
-
2996
-
2997
-
2998
-    /**
2999
-     *    class constructor
3000
-     */
3001
-    public function __construct()
3002
-    {
3003
-        $this->show_ticket_sale_columns = true;
3004
-        $this->show_ticket_details = true;
3005
-        $this->show_expired_tickets = true;
3006
-        $this->show_datetime_selector = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3007
-        $this->datetime_selector_threshold = 3;
3008
-    }
3009
-
3010
-
3011
-
3012
-    /**
3013
-     * returns true if a datetime selector should be displayed
3014
-     *
3015
-     * @param array $datetimes
3016
-     * @return bool
3017
-     */
3018
-    public function showDatetimeSelector(array $datetimes)
3019
-    {
3020
-        // if the settings are NOT: don't show OR below threshold, THEN active = true
3021
-        return ! (
3022
-            $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR
3023
-            || (
3024
-                $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR
3025
-                && count($datetimes) < $this->getDatetimeSelectorThreshold()
3026
-            )
3027
-        );
3028
-    }
3029
-
3030
-
3031
-
3032
-    /**
3033
-     * @return string
3034
-     */
3035
-    public function getShowDatetimeSelector()
3036
-    {
3037
-        return $this->show_datetime_selector;
3038
-    }
3039
-
3040
-
3041
-
3042
-    /**
3043
-     * @param bool $keys_only
3044
-     * @return array
3045
-     */
3046
-    public function getShowDatetimeSelectorOptions($keys_only = true)
3047
-    {
3048
-        return $keys_only
3049
-            ? array(
3050
-                \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR,
3051
-                \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR,
3052
-            )
3053
-            : array(
3054
-                \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__(
3055
-                    'Do not show date & time filter', 'event_espresso'
3056
-                ),
3057
-                \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR  => esc_html__(
3058
-                    'Maybe show date & time filter', 'event_espresso'
3059
-                ),
3060
-            );
3061
-    }
3062
-
3063
-
3064
-
3065
-    /**
3066
-     * @param string $show_datetime_selector
3067
-     */
3068
-    public function setShowDatetimeSelector($show_datetime_selector)
3069
-    {
3070
-        $this->show_datetime_selector = in_array(
3071
-            $show_datetime_selector,
3072
-            $this->getShowDatetimeSelectorOptions(),
3073
-            true
3074
-        )
3075
-            ? $show_datetime_selector
3076
-            : \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3077
-    }
3078
-
3079
-
3080
-
3081
-    /**
3082
-     * @return int
3083
-     */
3084
-    public function getDatetimeSelectorThreshold()
3085
-    {
3086
-        return $this->datetime_selector_threshold;
3087
-    }
3088
-
3089
-
3090
-
3091
-
3092
-    /**
3093
-     * @param int $datetime_selector_threshold
3094
-     */
3095
-    public function setDatetimeSelectorThreshold($datetime_selector_threshold)
3096
-    {
3097
-        $datetime_selector_threshold = absint($datetime_selector_threshold);
3098
-        $this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3;
3099
-    }
2954
+	/**
2955
+	 * constant to indicate that a datetime selector should NEVER be shown for ticket selectors
2956
+	 */
2957
+	const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector';
2958
+
2959
+	/**
2960
+	 * constant to indicate that a datetime selector should only be shown for ticket selectors
2961
+	 * when the number of datetimes for the event matches the value set for $datetime_selector_threshold
2962
+	 */
2963
+	const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector';
2964
+
2965
+	/**
2966
+	 * @var boolean $show_ticket_sale_columns
2967
+	 */
2968
+	public $show_ticket_sale_columns;
2969
+
2970
+	/**
2971
+	 * @var boolean $show_ticket_details
2972
+	 */
2973
+	public $show_ticket_details;
2974
+
2975
+	/**
2976
+	 * @var boolean $show_expired_tickets
2977
+	 */
2978
+	public $show_expired_tickets;
2979
+
2980
+	/**
2981
+	 * whether or not to display a dropdown box populated with event datetimes
2982
+	 * that toggles which tickets are displayed for a ticket selector.
2983
+	 * uses one of the *_DATETIME_SELECTOR constants defined above
2984
+	 *
2985
+	 * @var string $show_datetime_selector
2986
+	 */
2987
+	private $show_datetime_selector = 'no_datetime_selector';
2988
+
2989
+	/**
2990
+	 * the number of datetimes an event has to have before conditionally displaying a datetime selector
2991
+	 *
2992
+	 * @var int $datetime_selector_threshold
2993
+	 */
2994
+	private $datetime_selector_threshold = 3;
2995
+
2996
+
2997
+
2998
+	/**
2999
+	 *    class constructor
3000
+	 */
3001
+	public function __construct()
3002
+	{
3003
+		$this->show_ticket_sale_columns = true;
3004
+		$this->show_ticket_details = true;
3005
+		$this->show_expired_tickets = true;
3006
+		$this->show_datetime_selector = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3007
+		$this->datetime_selector_threshold = 3;
3008
+	}
3009
+
3010
+
3011
+
3012
+	/**
3013
+	 * returns true if a datetime selector should be displayed
3014
+	 *
3015
+	 * @param array $datetimes
3016
+	 * @return bool
3017
+	 */
3018
+	public function showDatetimeSelector(array $datetimes)
3019
+	{
3020
+		// if the settings are NOT: don't show OR below threshold, THEN active = true
3021
+		return ! (
3022
+			$this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR
3023
+			|| (
3024
+				$this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR
3025
+				&& count($datetimes) < $this->getDatetimeSelectorThreshold()
3026
+			)
3027
+		);
3028
+	}
3029
+
3030
+
3031
+
3032
+	/**
3033
+	 * @return string
3034
+	 */
3035
+	public function getShowDatetimeSelector()
3036
+	{
3037
+		return $this->show_datetime_selector;
3038
+	}
3039
+
3040
+
3041
+
3042
+	/**
3043
+	 * @param bool $keys_only
3044
+	 * @return array
3045
+	 */
3046
+	public function getShowDatetimeSelectorOptions($keys_only = true)
3047
+	{
3048
+		return $keys_only
3049
+			? array(
3050
+				\EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR,
3051
+				\EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR,
3052
+			)
3053
+			: array(
3054
+				\EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__(
3055
+					'Do not show date & time filter', 'event_espresso'
3056
+				),
3057
+				\EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR  => esc_html__(
3058
+					'Maybe show date & time filter', 'event_espresso'
3059
+				),
3060
+			);
3061
+	}
3062
+
3063
+
3064
+
3065
+	/**
3066
+	 * @param string $show_datetime_selector
3067
+	 */
3068
+	public function setShowDatetimeSelector($show_datetime_selector)
3069
+	{
3070
+		$this->show_datetime_selector = in_array(
3071
+			$show_datetime_selector,
3072
+			$this->getShowDatetimeSelectorOptions(),
3073
+			true
3074
+		)
3075
+			? $show_datetime_selector
3076
+			: \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3077
+	}
3078
+
3079
+
3080
+
3081
+	/**
3082
+	 * @return int
3083
+	 */
3084
+	public function getDatetimeSelectorThreshold()
3085
+	{
3086
+		return $this->datetime_selector_threshold;
3087
+	}
3088
+
3089
+
3090
+
3091
+
3092
+	/**
3093
+	 * @param int $datetime_selector_threshold
3094
+	 */
3095
+	public function setDatetimeSelectorThreshold($datetime_selector_threshold)
3096
+	{
3097
+		$datetime_selector_threshold = absint($datetime_selector_threshold);
3098
+		$this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3;
3099
+	}
3100 3100
 
3101 3101
 
3102 3102
 
@@ -3114,85 +3114,85 @@  discard block
 block discarded – undo
3114 3114
 class EE_Environment_Config extends EE_Config_Base
3115 3115
 {
3116 3116
 
3117
-    /**
3118
-     * Hold any php environment variables that we want to track.
3119
-     *
3120
-     * @var stdClass;
3121
-     */
3122
-    public $php;
3123
-
3124
-
3125
-
3126
-    /**
3127
-     *    constructor
3128
-     */
3129
-    public function __construct()
3130
-    {
3131
-        $this->php = new stdClass();
3132
-        $this->_set_php_values();
3133
-    }
3134
-
3135
-
3136
-
3137
-    /**
3138
-     * This sets the php environment variables.
3139
-     *
3140
-     * @since 4.4.0
3141
-     * @return void
3142
-     */
3143
-    protected function _set_php_values()
3144
-    {
3145
-        $this->php->max_input_vars = ini_get('max_input_vars');
3146
-        $this->php->version = phpversion();
3147
-    }
3148
-
3149
-
3150
-
3151
-    /**
3152
-     * helper method for determining whether input_count is
3153
-     * reaching the potential maximum the server can handle
3154
-     * according to max_input_vars
3155
-     *
3156
-     * @param int   $input_count the count of input vars.
3157
-     * @return array {
3158
-     *                           An array that represents whether available space and if no available space the error
3159
-     *                           message.
3160
-     * @type bool   $has_space   whether more inputs can be added.
3161
-     * @type string $msg         Any message to be displayed.
3162
-     *                           }
3163
-     */
3164
-    public function max_input_vars_limit_check($input_count = 0)
3165
-    {
3166
-        if (! empty($this->php->max_input_vars)
3167
-            && ($input_count >= $this->php->max_input_vars)
3168
-            && (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9)
3169
-        ) {
3170
-            return sprintf(
3171
-                __(
3172
-                    '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.',
3173
-                    'event_espresso'
3174
-                ),
3175
-                '<br>',
3176
-                $input_count,
3177
-                $this->php->max_input_vars
3178
-            );
3179
-        } else {
3180
-            return '';
3181
-        }
3182
-    }
3183
-
3184
-
3185
-
3186
-    /**
3187
-     * The purpose of this method is just to force rechecking php values so if they've changed, they get updated.
3188
-     *
3189
-     * @since 4.4.1
3190
-     * @return void
3191
-     */
3192
-    public function recheck_values()
3193
-    {
3194
-        $this->_set_php_values();
3195
-    }
3117
+	/**
3118
+	 * Hold any php environment variables that we want to track.
3119
+	 *
3120
+	 * @var stdClass;
3121
+	 */
3122
+	public $php;
3123
+
3124
+
3125
+
3126
+	/**
3127
+	 *    constructor
3128
+	 */
3129
+	public function __construct()
3130
+	{
3131
+		$this->php = new stdClass();
3132
+		$this->_set_php_values();
3133
+	}
3134
+
3135
+
3136
+
3137
+	/**
3138
+	 * This sets the php environment variables.
3139
+	 *
3140
+	 * @since 4.4.0
3141
+	 * @return void
3142
+	 */
3143
+	protected function _set_php_values()
3144
+	{
3145
+		$this->php->max_input_vars = ini_get('max_input_vars');
3146
+		$this->php->version = phpversion();
3147
+	}
3148
+
3149
+
3150
+
3151
+	/**
3152
+	 * helper method for determining whether input_count is
3153
+	 * reaching the potential maximum the server can handle
3154
+	 * according to max_input_vars
3155
+	 *
3156
+	 * @param int   $input_count the count of input vars.
3157
+	 * @return array {
3158
+	 *                           An array that represents whether available space and if no available space the error
3159
+	 *                           message.
3160
+	 * @type bool   $has_space   whether more inputs can be added.
3161
+	 * @type string $msg         Any message to be displayed.
3162
+	 *                           }
3163
+	 */
3164
+	public function max_input_vars_limit_check($input_count = 0)
3165
+	{
3166
+		if (! empty($this->php->max_input_vars)
3167
+			&& ($input_count >= $this->php->max_input_vars)
3168
+			&& (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9)
3169
+		) {
3170
+			return sprintf(
3171
+				__(
3172
+					'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.',
3173
+					'event_espresso'
3174
+				),
3175
+				'<br>',
3176
+				$input_count,
3177
+				$this->php->max_input_vars
3178
+			);
3179
+		} else {
3180
+			return '';
3181
+		}
3182
+	}
3183
+
3184
+
3185
+
3186
+	/**
3187
+	 * The purpose of this method is just to force rechecking php values so if they've changed, they get updated.
3188
+	 *
3189
+	 * @since 4.4.1
3190
+	 * @return void
3191
+	 */
3192
+	public function recheck_values()
3193
+	{
3194
+		$this->_set_php_values();
3195
+	}
3196 3196
 
3197 3197
 
3198 3198
 
@@ -3210,22 +3210,22 @@  discard block
 block discarded – undo
3210 3210
 class EE_Tax_Config extends EE_Config_Base
3211 3211
 {
3212 3212
 
3213
-    /*
3213
+	/*
3214 3214
      * flag to indicate whether or not to display ticket prices with the taxes included
3215 3215
      *
3216 3216
      * @var boolean $prices_displayed_including_taxes
3217 3217
      */
3218
-    public $prices_displayed_including_taxes;
3218
+	public $prices_displayed_including_taxes;
3219 3219
 
3220 3220
 
3221 3221
 
3222
-    /**
3223
-     *    class constructor
3224
-     */
3225
-    public function __construct()
3226
-    {
3227
-        $this->prices_displayed_including_taxes = true;
3228
-    }
3222
+	/**
3223
+	 *    class constructor
3224
+	 */
3225
+	public function __construct()
3226
+	{
3227
+		$this->prices_displayed_including_taxes = true;
3228
+	}
3229 3229
 }
3230 3230
 
3231 3231
 
@@ -3240,17 +3240,17 @@  discard block
 block discarded – undo
3240 3240
 class EE_Messages_Config extends EE_Config_Base
3241 3241
 {
3242 3242
 
3243
-    /**
3244
-     * This is an integer representing the deletion threshold in months for when old messages will get deleted.
3245
-     * A value of 0 represents never deleting.  Default is 0.
3246
-     *
3247
-     * @var integer
3248
-     */
3249
-    public $delete_threshold;
3250
-
3251
-    public function __construct() {
3252
-        $this->delete_threshold = 0;
3253
-    }
3243
+	/**
3244
+	 * This is an integer representing the deletion threshold in months for when old messages will get deleted.
3245
+	 * A value of 0 represents never deleting.  Default is 0.
3246
+	 *
3247
+	 * @var integer
3248
+	 */
3249
+	public $delete_threshold;
3250
+
3251
+	public function __construct() {
3252
+		$this->delete_threshold = 0;
3253
+	}
3254 3254
 }
3255 3255
 
3256 3256
 
@@ -3262,34 +3262,34 @@  discard block
 block discarded – undo
3262 3262
 class EE_Gateway_Config extends EE_Config_Base
3263 3263
 {
3264 3264
 
3265
-    /**
3266
-     * Array with keys that are payment gateways slugs, and values are arrays
3267
-     * with any config info the gateway wants to store
3268
-     *
3269
-     * @var array
3270
-     */
3271
-    public $payment_settings;
3272
-
3273
-    /**
3274
-     * Where keys are gateway slugs, and values are booleans indicating whether or not
3275
-     * the gateway is stored in the uploads directory
3276
-     *
3277
-     * @var array
3278
-     */
3279
-    public $active_gateways;
3280
-
3281
-
3282
-
3283
-    /**
3284
-     *    class constructor
3285
-     *
3286
-     * @deprecated
3287
-     */
3288
-    public function __construct()
3289
-    {
3290
-        $this->payment_settings = array();
3291
-        $this->active_gateways = array('Invoice' => false);
3292
-    }
3265
+	/**
3266
+	 * Array with keys that are payment gateways slugs, and values are arrays
3267
+	 * with any config info the gateway wants to store
3268
+	 *
3269
+	 * @var array
3270
+	 */
3271
+	public $payment_settings;
3272
+
3273
+	/**
3274
+	 * Where keys are gateway slugs, and values are booleans indicating whether or not
3275
+	 * the gateway is stored in the uploads directory
3276
+	 *
3277
+	 * @var array
3278
+	 */
3279
+	public $active_gateways;
3280
+
3281
+
3282
+
3283
+	/**
3284
+	 *    class constructor
3285
+	 *
3286
+	 * @deprecated
3287
+	 */
3288
+	public function __construct()
3289
+	{
3290
+		$this->payment_settings = array();
3291
+		$this->active_gateways = array('Invoice' => false);
3292
+	}
3293 3293
 }
3294 3294
 
3295 3295
 // End of file EE_Config.core.php
Please login to merge, or discard this patch.
core/EE_Dependency_Map.core.php 2 patches
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 use EventEspresso\core\services\request\RequestInterface;
8 8
 use EventEspresso\core\services\request\ResponseInterface;
9 9
 
10
-if (! defined('EVENT_ESPRESSO_VERSION')) {
10
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
11 11
     exit('No direct script access allowed');
12 12
 }
13 13
 
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
      */
130 130
     public static function instance() {
131 131
         // check if class object is instantiated, and instantiated properly
132
-        if (! self::$_instance instanceof EE_Dependency_Map) {
132
+        if ( ! self::$_instance instanceof EE_Dependency_Map) {
133 133
             self::$_instance = new EE_Dependency_Map(/*$request, $response, $legacy_request*/);
134 134
         }
135 135
         return self::$_instance;
@@ -211,8 +211,8 @@  discard block
 block discarded – undo
211 211
     ) {
212 212
         $class = trim($class, '\\');
213 213
         $registered = false;
214
-        if (empty(self::$_instance->_dependency_map[ $class ])) {
215
-            self::$_instance->_dependency_map[ $class ] = array();
214
+        if (empty(self::$_instance->_dependency_map[$class])) {
215
+            self::$_instance->_dependency_map[$class] = array();
216 216
         }
217 217
         // we need to make sure that any aliases used when registering a dependency
218 218
         // get resolved to the correct class name
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
             $alias = self::$_instance->get_alias($dependency);
221 221
             if (
222 222
                 $overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
223
-                || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ])
223
+                || ! isset(self::$_instance->_dependency_map[$class][$alias])
224 224
             ) {
225 225
                 unset($dependencies[$dependency]);
226 226
                 $dependencies[$alias] = $load_source;
@@ -233,13 +233,13 @@  discard block
 block discarded – undo
233 233
         // ie: with A = B + C, entries in B take precedence over duplicate entries in C
234 234
         // Union is way faster than array_merge() but should be used with caution...
235 235
         // especially with numerically indexed arrays
236
-        $dependencies += self::$_instance->_dependency_map[ $class ];
236
+        $dependencies += self::$_instance->_dependency_map[$class];
237 237
         // now we need to ensure that the resulting dependencies
238 238
         // array only has the entries that are required for the class
239 239
         // so first count how many dependencies were originally registered for the class
240
-        $dependency_count = count(self::$_instance->_dependency_map[ $class ]);
240
+        $dependency_count = count(self::$_instance->_dependency_map[$class]);
241 241
         // if that count is non-zero (meaning dependencies were already registered)
242
-        self::$_instance->_dependency_map[ $class ] = $dependency_count
242
+        self::$_instance->_dependency_map[$class] = $dependency_count
243 243
             // then truncate the  final array to match that count
244 244
             ? array_slice($dependencies, 0, $dependency_count)
245 245
             // otherwise just take the incoming array because nothing previously existed
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
      */
258 258
     public static function register_class_loader($class_name, $loader = 'load_core')
259 259
     {
260
-        if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
260
+        if ( ! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
261 261
             throw new DomainException(
262 262
                 esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
263 263
             );
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
             );
282 282
         }
283 283
         $class_name = self::$_instance->get_alias($class_name);
284
-        if (! isset(self::$_instance->_class_loaders[$class_name])) {
284
+        if ( ! isset(self::$_instance->_class_loaders[$class_name])) {
285 285
             self::$_instance->_class_loaders[$class_name] = $loader;
286 286
             return true;
287 287
         }
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
     public function class_loader($class_name)
367 367
     {
368 368
         // all legacy models use load_model()
369
-        if(strpos($class_name, 'EEM_') === 0){
369
+        if (strpos($class_name, 'EEM_') === 0) {
370 370
             return 'load_model';
371 371
         }
372 372
         $class_name = $this->get_alias($class_name);
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
     public function add_alias($class_name, $alias, $for_class = '')
396 396
     {
397 397
         if ($for_class !== '') {
398
-            if (! isset($this->_aliases[$for_class])) {
398
+            if ( ! isset($this->_aliases[$for_class])) {
399 399
                 $this->_aliases[$for_class] = array();
400 400
             }
401 401
             $this->_aliases[$for_class][$class_name] = $alias;
@@ -441,10 +441,10 @@  discard block
 block discarded – undo
441 441
      */
442 442
     public function get_alias($class_name = '', $for_class = '')
443 443
     {
444
-        if (! $this->has_alias($class_name, $for_class)) {
444
+        if ( ! $this->has_alias($class_name, $for_class)) {
445 445
             return $class_name;
446 446
         }
447
-        if ($for_class !== '' && isset($this->_aliases[ $for_class ][ $class_name ])) {
447
+        if ($for_class !== '' && isset($this->_aliases[$for_class][$class_name])) {
448 448
             return $this->get_alias($this->_aliases[$for_class][$class_name], $for_class);
449 449
         }
450 450
         return $this->get_alias($this->_aliases[$class_name]);
@@ -765,13 +765,13 @@  discard block
 block discarded – undo
765 765
             'EE_Front_Controller'      => 'load_core',
766 766
             'EE_Module_Request_Router' => 'load_core',
767 767
             'EE_Registry'              => 'load_core',
768
-            'EE_Request'               => function () use (&$legacy_request) {
768
+            'EE_Request'               => function() use (&$legacy_request) {
769 769
                 return $legacy_request;
770 770
             },
771
-            'EventEspresso\core\services\request\Request' => function () use (&$request) {
771
+            'EventEspresso\core\services\request\Request' => function() use (&$request) {
772 772
                 return $request;
773 773
             },
774
-            'EventEspresso\core\services\request\Response' => function () use (&$response) {
774
+            'EventEspresso\core\services\request\Response' => function() use (&$response) {
775 775
                 return $response;
776 776
             },
777 777
             'EE_Request_Handler'       => 'load_core',
@@ -793,7 +793,7 @@  discard block
 block discarded – undo
793 793
             'EE_Messages_Data_Handler_Collection'  => 'load_lib',
794 794
             'EE_Message_Template_Group_Collection' => 'load_lib',
795 795
             'EE_Payment_Method_Manager'            => 'load_lib',
796
-            'EE_Messages_Generator'                => function () {
796
+            'EE_Messages_Generator'                => function() {
797 797
                 return EE_Registry::instance()->load_lib(
798 798
                     'Messages_Generator',
799 799
                     array(),
@@ -801,7 +801,7 @@  discard block
 block discarded – undo
801 801
                     false
802 802
                 );
803 803
             },
804
-            'EE_Messages_Template_Defaults'        => function ($arguments = array()) {
804
+            'EE_Messages_Template_Defaults'        => function($arguments = array()) {
805 805
                 return EE_Registry::instance()->load_lib(
806 806
                     'Messages_Template_Defaults',
807 807
                     $arguments,
@@ -810,31 +810,31 @@  discard block
 block discarded – undo
810 810
                 );
811 811
             },
812 812
             //load_helper
813
-            'EEH_Parse_Shortcodes'                 => function () {
813
+            'EEH_Parse_Shortcodes'                 => function() {
814 814
                 if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
815 815
                     return new EEH_Parse_Shortcodes();
816 816
                 }
817 817
                 return null;
818 818
             },
819
-            'EE_Template_Config'                   => function () {
819
+            'EE_Template_Config'                   => function() {
820 820
                 return EE_Config::instance()->template_settings;
821 821
             },
822
-            'EE_Currency_Config'                   => function () {
822
+            'EE_Currency_Config'                   => function() {
823 823
                 return EE_Config::instance()->currency;
824 824
             },
825
-            'EE_Registration_Config'                   => function () {
825
+            'EE_Registration_Config'                   => function() {
826 826
                 return EE_Config::instance()->registration;
827 827
             },
828
-            'EE_Core_Config'                   => function () {
828
+            'EE_Core_Config'                   => function() {
829 829
                 return EE_Config::instance()->core;
830 830
             },
831
-            'EventEspresso\core\services\loaders\Loader' => function () {
831
+            'EventEspresso\core\services\loaders\Loader' => function() {
832 832
                 return LoaderFactory::getLoader();
833 833
             },
834 834
             'EE_Network_Config' => function() {
835 835
                 return EE_Network_Config::instance();
836 836
             },
837
-            'EE_Config' => function () {
837
+            'EE_Config' => function() {
838 838
                 return EE_Config::instance();
839 839
             }
840 840
         );
@@ -890,7 +890,7 @@  discard block
 block discarded – undo
890 890
             'EventEspresso\core\services\request\ResponseInterface'               => 'EventEspresso\core\services\request\Response',
891 891
             'EventEspresso\core\domain\DomainInterface'                           => 'EventEspresso\core\domain\Domain',
892 892
         );
893
-        if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
893
+        if ( ! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
894 894
             $this->_aliases['EventEspresso\core\services\notices\NoticeConverterInterface'] = 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices';
895 895
         }
896 896
     }
Please login to merge, or discard this patch.
Indentation   +936 added lines, -936 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 use EventEspresso\core\services\request\ResponseInterface;
9 9
 
10 10
 if (! defined('EVENT_ESPRESSO_VERSION')) {
11
-    exit('No direct script access allowed');
11
+	exit('No direct script access allowed');
12 12
 }
13 13
 
14 14
 
@@ -25,941 +25,941 @@  discard block
 block discarded – undo
25 25
 class EE_Dependency_Map
26 26
 {
27 27
 
28
-    /**
29
-     * This means that the requested class dependency is not present in the dependency map
30
-     */
31
-    const not_registered = 0;
32
-
33
-    /**
34
-     * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class.
35
-     */
36
-    const load_new_object = 1;
37
-
38
-    /**
39
-     * This instructs class loaders to return a previously instantiated and cached object for the requested class.
40
-     * IF a previously instantiated object does not exist, a new one will be created and added to the cache.
41
-     */
42
-    const load_from_cache = 2;
43
-
44
-    /**
45
-     * When registering a dependency,
46
-     * this indicates to keep any existing dependencies that already exist,
47
-     * and simply discard any new dependencies declared in the incoming data
48
-     */
49
-    const KEEP_EXISTING_DEPENDENCIES = 0;
50
-
51
-    /**
52
-     * When registering a dependency,
53
-     * this indicates to overwrite any existing dependencies that already exist using the incoming data
54
-     */
55
-    const OVERWRITE_DEPENDENCIES = 1;
56
-
57
-
58
-
59
-    /**
60
-     * @type EE_Dependency_Map $_instance
61
-     */
62
-    protected static $_instance;
63
-
64
-    /**
65
-     * @type RequestInterface $request
66
-     */
67
-    protected $request;
68
-
69
-    /**
70
-     * @type LegacyRequestInterface $legacy_request
71
-     */
72
-    protected $legacy_request;
73
-
74
-    /**
75
-     * @type ResponseInterface $response
76
-     */
77
-    protected $response;
78
-
79
-    /**
80
-     * @type LoaderInterface $loader
81
-     */
82
-    protected $loader;
83
-
84
-    /**
85
-     * @type array $_dependency_map
86
-     */
87
-    protected $_dependency_map = array();
88
-
89
-    /**
90
-     * @type array $_class_loaders
91
-     */
92
-    protected $_class_loaders = array();
93
-
94
-    /**
95
-     * @type array $_aliases
96
-     */
97
-    protected $_aliases = array();
98
-
99
-
100
-
101
-    /**
102
-     * EE_Dependency_Map constructor.
103
-     */
104
-    protected function __construct()
105
-    {
106
-        // add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize'));
107
-        do_action('EE_Dependency_Map____construct');
108
-    }
109
-
110
-
111
-
112
-    /**
113
-     * @throws InvalidDataTypeException
114
-     * @throws InvalidInterfaceException
115
-     * @throws InvalidArgumentException
116
-     */
117
-    public function initialize()
118
-    {
119
-        $this->_register_core_dependencies();
120
-        $this->_register_core_class_loaders();
121
-        $this->_register_core_aliases();
122
-    }
123
-
124
-
125
-
126
-    /**
127
-     * @singleton method used to instantiate class object
128
-     * @return EE_Dependency_Map
129
-     */
130
-    public static function instance() {
131
-        // check if class object is instantiated, and instantiated properly
132
-        if (! self::$_instance instanceof EE_Dependency_Map) {
133
-            self::$_instance = new EE_Dependency_Map(/*$request, $response, $legacy_request*/);
134
-        }
135
-        return self::$_instance;
136
-    }
137
-
138
-
139
-    /**
140
-     * @param RequestInterface $request
141
-     */
142
-    public function setRequest(RequestInterface $request)
143
-    {
144
-        $this->request = $request;
145
-    }
146
-
147
-
148
-    /**
149
-     * @param LegacyRequestInterface $legacy_request
150
-     */
151
-    public function setLegacyRequest(LegacyRequestInterface $legacy_request)
152
-    {
153
-        $this->legacy_request = $legacy_request;
154
-    }
155
-
156
-
157
-    /**
158
-     * @param ResponseInterface $response
159
-     */
160
-    public function setResponse(ResponseInterface $response)
161
-    {
162
-        $this->response = $response;
163
-    }
164
-
165
-
166
-
167
-    /**
168
-     * @param LoaderInterface $loader
169
-     */
170
-    public function setLoader(LoaderInterface $loader)
171
-    {
172
-        $this->loader = $loader;
173
-    }
174
-
175
-
176
-
177
-    /**
178
-     * @param string $class
179
-     * @param array  $dependencies
180
-     * @param int    $overwrite
181
-     * @return bool
182
-     */
183
-    public static function register_dependencies(
184
-        $class,
185
-        array $dependencies,
186
-        $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
187
-    ) {
188
-        return self::$_instance->registerDependencies($class, $dependencies, $overwrite);
189
-    }
190
-
191
-
192
-
193
-    /**
194
-     * Assigns an array of class names and corresponding load sources (new or cached)
195
-     * to the class specified by the first parameter.
196
-     * IMPORTANT !!!
197
-     * The order of elements in the incoming $dependencies array MUST match
198
-     * the order of the constructor parameters for the class in question.
199
-     * This is especially important when overriding any existing dependencies that are registered.
200
-     * the third parameter controls whether any duplicate dependencies are overwritten or not.
201
-     *
202
-     * @param string $class
203
-     * @param array  $dependencies
204
-     * @param int    $overwrite
205
-     * @return bool
206
-     */
207
-    public function registerDependencies(
208
-        $class,
209
-        array $dependencies,
210
-        $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
211
-    ) {
212
-        $class = trim($class, '\\');
213
-        $registered = false;
214
-        if (empty(self::$_instance->_dependency_map[ $class ])) {
215
-            self::$_instance->_dependency_map[ $class ] = array();
216
-        }
217
-        // we need to make sure that any aliases used when registering a dependency
218
-        // get resolved to the correct class name
219
-        foreach ($dependencies as $dependency => $load_source) {
220
-            $alias = self::$_instance->get_alias($dependency);
221
-            if (
222
-                $overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
223
-                || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ])
224
-            ) {
225
-                unset($dependencies[$dependency]);
226
-                $dependencies[$alias] = $load_source;
227
-                $registered = true;
228
-            }
229
-        }
230
-        // now add our two lists of dependencies together.
231
-        // using Union (+=) favours the arrays in precedence from left to right,
232
-        // so $dependencies is NOT overwritten because it is listed first
233
-        // ie: with A = B + C, entries in B take precedence over duplicate entries in C
234
-        // Union is way faster than array_merge() but should be used with caution...
235
-        // especially with numerically indexed arrays
236
-        $dependencies += self::$_instance->_dependency_map[ $class ];
237
-        // now we need to ensure that the resulting dependencies
238
-        // array only has the entries that are required for the class
239
-        // so first count how many dependencies were originally registered for the class
240
-        $dependency_count = count(self::$_instance->_dependency_map[ $class ]);
241
-        // if that count is non-zero (meaning dependencies were already registered)
242
-        self::$_instance->_dependency_map[ $class ] = $dependency_count
243
-            // then truncate the  final array to match that count
244
-            ? array_slice($dependencies, 0, $dependency_count)
245
-            // otherwise just take the incoming array because nothing previously existed
246
-            : $dependencies;
247
-        return $registered;
248
-    }
249
-
250
-
251
-
252
-    /**
253
-     * @param string $class_name
254
-     * @param string $loader
255
-     * @return bool
256
-     * @throws DomainException
257
-     */
258
-    public static function register_class_loader($class_name, $loader = 'load_core')
259
-    {
260
-        if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
261
-            throw new DomainException(
262
-                esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
263
-            );
264
-        }
265
-        // check that loader is callable or method starts with "load_" and exists in EE_Registry
266
-        if (
267
-            ! is_callable($loader)
268
-            && (
269
-                strpos($loader, 'load_') !== 0
270
-                || ! method_exists('EE_Registry', $loader)
271
-            )
272
-        ) {
273
-            throw new DomainException(
274
-                sprintf(
275
-                    esc_html__(
276
-                        '"%1$s" is not a valid loader method on EE_Registry.',
277
-                        'event_espresso'
278
-                    ),
279
-                    $loader
280
-                )
281
-            );
282
-        }
283
-        $class_name = self::$_instance->get_alias($class_name);
284
-        if (! isset(self::$_instance->_class_loaders[$class_name])) {
285
-            self::$_instance->_class_loaders[$class_name] = $loader;
286
-            return true;
287
-        }
288
-        return false;
289
-    }
290
-
291
-
292
-
293
-    /**
294
-     * @return array
295
-     */
296
-    public function dependency_map()
297
-    {
298
-        return $this->_dependency_map;
299
-    }
300
-
301
-
302
-
303
-    /**
304
-     * returns TRUE if dependency map contains a listing for the provided class name
305
-     *
306
-     * @param string $class_name
307
-     * @return boolean
308
-     */
309
-    public function has($class_name = '')
310
-    {
311
-        // all legacy models have the same dependencies
312
-        if (strpos($class_name, 'EEM_') === 0) {
313
-            $class_name = 'LEGACY_MODELS';
314
-        }
315
-        return isset($this->_dependency_map[$class_name]) ? true : false;
316
-    }
317
-
318
-
319
-
320
-    /**
321
-     * returns TRUE if dependency map contains a listing for the provided class name AND dependency
322
-     *
323
-     * @param string $class_name
324
-     * @param string $dependency
325
-     * @return bool
326
-     */
327
-    public function has_dependency_for_class($class_name = '', $dependency = '')
328
-    {
329
-        // all legacy models have the same dependencies
330
-        if (strpos($class_name, 'EEM_') === 0) {
331
-            $class_name = 'LEGACY_MODELS';
332
-        }
333
-        $dependency = $this->get_alias($dependency);
334
-        return isset($this->_dependency_map[$class_name][$dependency])
335
-            ? true
336
-            : false;
337
-    }
338
-
339
-
340
-
341
-    /**
342
-     * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned
343
-     *
344
-     * @param string $class_name
345
-     * @param string $dependency
346
-     * @return int
347
-     */
348
-    public function loading_strategy_for_class_dependency($class_name = '', $dependency = '')
349
-    {
350
-        // all legacy models have the same dependencies
351
-        if (strpos($class_name, 'EEM_') === 0) {
352
-            $class_name = 'LEGACY_MODELS';
353
-        }
354
-        $dependency = $this->get_alias($dependency);
355
-        return $this->has_dependency_for_class($class_name, $dependency)
356
-            ? $this->_dependency_map[$class_name][$dependency]
357
-            : EE_Dependency_Map::not_registered;
358
-    }
359
-
360
-
361
-
362
-    /**
363
-     * @param string $class_name
364
-     * @return string | Closure
365
-     */
366
-    public function class_loader($class_name)
367
-    {
368
-        // all legacy models use load_model()
369
-        if(strpos($class_name, 'EEM_') === 0){
370
-            return 'load_model';
371
-        }
372
-        $class_name = $this->get_alias($class_name);
373
-        return isset($this->_class_loaders[$class_name]) ? $this->_class_loaders[$class_name] : '';
374
-    }
375
-
376
-
377
-
378
-    /**
379
-     * @return array
380
-     */
381
-    public function class_loaders()
382
-    {
383
-        return $this->_class_loaders;
384
-    }
385
-
386
-
387
-
388
-    /**
389
-     * adds an alias for a classname
390
-     *
391
-     * @param string $class_name the class name that should be used (concrete class to replace interface)
392
-     * @param string $alias      the class name that would be type hinted for (abstract parent or interface)
393
-     * @param string $for_class  the class that has the dependency (is type hinting for the interface)
394
-     */
395
-    public function add_alias($class_name, $alias, $for_class = '')
396
-    {
397
-        if ($for_class !== '') {
398
-            if (! isset($this->_aliases[$for_class])) {
399
-                $this->_aliases[$for_class] = array();
400
-            }
401
-            $this->_aliases[$for_class][$class_name] = $alias;
402
-        }
403
-        $this->_aliases[$class_name] = $alias;
404
-    }
405
-
406
-
407
-
408
-    /**
409
-     * returns TRUE if the provided class name has an alias
410
-     *
411
-     * @param string $class_name
412
-     * @param string $for_class
413
-     * @return bool
414
-     */
415
-    public function has_alias($class_name = '', $for_class = '')
416
-    {
417
-        return isset($this->_aliases[$for_class][$class_name])
418
-               || (
419
-                   isset($this->_aliases[$class_name])
420
-                   && ! is_array($this->_aliases[$class_name])
421
-               );
422
-    }
423
-
424
-
425
-
426
-    /**
427
-     * returns alias for class name if one exists, otherwise returns the original classname
428
-     * functions recursively, so that multiple aliases can be used to drill down to a classname
429
-     *  for example:
430
-     *      if the following two entries were added to the _aliases array:
431
-     *          array(
432
-     *              'interface_alias'           => 'some\namespace\interface'
433
-     *              'some\namespace\interface'  => 'some\namespace\classname'
434
-     *          )
435
-     *      then one could use EE_Registry::instance()->create( 'interface_alias' )
436
-     *      to load an instance of 'some\namespace\classname'
437
-     *
438
-     * @param string $class_name
439
-     * @param string $for_class
440
-     * @return string
441
-     */
442
-    public function get_alias($class_name = '', $for_class = '')
443
-    {
444
-        if (! $this->has_alias($class_name, $for_class)) {
445
-            return $class_name;
446
-        }
447
-        if ($for_class !== '' && isset($this->_aliases[ $for_class ][ $class_name ])) {
448
-            return $this->get_alias($this->_aliases[$for_class][$class_name], $for_class);
449
-        }
450
-        return $this->get_alias($this->_aliases[$class_name]);
451
-    }
452
-
453
-
454
-
455
-    /**
456
-     * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache,
457
-     * if one exists, or whether a new object should be generated every time the requested class is loaded.
458
-     * This is done by using the following class constants:
459
-     *        EE_Dependency_Map::load_from_cache - loads previously instantiated object
460
-     *        EE_Dependency_Map::load_new_object - generates a new object every time
461
-     */
462
-    protected function _register_core_dependencies()
463
-    {
464
-        $this->_dependency_map = array(
465
-            'EE_Request_Handler'                                                                                          => array(
466
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
467
-            ),
468
-            'EE_System'                                                                                                   => array(
469
-                'EE_Registry'                                 => EE_Dependency_Map::load_from_cache,
470
-                'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
471
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
472
-                'EE_Maintenance_Mode'                         => EE_Dependency_Map::load_from_cache,
473
-            ),
474
-            'EE_Session'                                                                                                  => array(
475
-                'EventEspresso\core\services\cache\TransientCacheStorage'  => EE_Dependency_Map::load_from_cache,
476
-                'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
477
-                'EventEspresso\core\services\request\Request'              => EE_Dependency_Map::load_from_cache,
478
-                'EE_Encryption'                                            => EE_Dependency_Map::load_from_cache,
479
-            ),
480
-            'EE_Cart'                                                                                                     => array(
481
-                'EE_Session' => EE_Dependency_Map::load_from_cache,
482
-            ),
483
-            'EE_Front_Controller'                                                                                         => array(
484
-                'EE_Registry'              => EE_Dependency_Map::load_from_cache,
485
-                'EE_Request_Handler'       => EE_Dependency_Map::load_from_cache,
486
-                'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache,
487
-            ),
488
-            'EE_Messenger_Collection_Loader'                                                                              => array(
489
-                'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object,
490
-            ),
491
-            'EE_Message_Type_Collection_Loader'                                                                           => array(
492
-                'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object,
493
-            ),
494
-            'EE_Message_Resource_Manager'                                                                                 => array(
495
-                'EE_Messenger_Collection_Loader'    => EE_Dependency_Map::load_new_object,
496
-                'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object,
497
-                'EEM_Message_Template_Group'        => EE_Dependency_Map::load_from_cache,
498
-            ),
499
-            'EE_Message_Factory'                                                                                          => array(
500
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
501
-            ),
502
-            'EE_messages'                                                                                                 => array(
503
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
504
-            ),
505
-            'EE_Messages_Generator'                                                                                       => array(
506
-                'EE_Messages_Queue'                    => EE_Dependency_Map::load_new_object,
507
-                'EE_Messages_Data_Handler_Collection'  => EE_Dependency_Map::load_new_object,
508
-                'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object,
509
-                'EEH_Parse_Shortcodes'                 => EE_Dependency_Map::load_from_cache,
510
-            ),
511
-            'EE_Messages_Processor'                                                                                       => array(
512
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
513
-            ),
514
-            'EE_Messages_Queue'                                                                                           => array(
515
-                'EE_Message_Repository' => EE_Dependency_Map::load_new_object,
516
-            ),
517
-            'EE_Messages_Template_Defaults'                                                                               => array(
518
-                'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache,
519
-                'EEM_Message_Template'       => EE_Dependency_Map::load_from_cache,
520
-            ),
521
-            'EE_Message_To_Generate_From_Request'                                                                         => array(
522
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
523
-                'EE_Request_Handler'          => EE_Dependency_Map::load_from_cache,
524
-            ),
525
-            'EventEspresso\core\services\commands\CommandBus'                                                             => array(
526
-                'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache,
527
-            ),
528
-            'EventEspresso\services\commands\CommandHandler'                                                              => array(
529
-                'EE_Registry'         => EE_Dependency_Map::load_from_cache,
530
-                'CommandBusInterface' => EE_Dependency_Map::load_from_cache,
531
-            ),
532
-            'EventEspresso\core\services\commands\CommandHandlerManager'                                                  => array(
533
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
534
-            ),
535
-            'EventEspresso\core\services\commands\CompositeCommandHandler'                                                => array(
536
-                'EventEspresso\core\services\commands\CommandBus'     => EE_Dependency_Map::load_from_cache,
537
-                'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache,
538
-            ),
539
-            'EventEspresso\core\services\commands\CommandFactory'                                                         => array(
540
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
541
-            ),
542
-            'EventEspresso\core\services\commands\middleware\CapChecker'                                                  => array(
543
-                'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
544
-            ),
545
-            'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker'                                         => array(
546
-                'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
547
-            ),
548
-            'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker'                                     => array(
549
-                'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
550
-            ),
551
-            'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler'                          => array(
552
-                'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache,
553
-            ),
554
-            'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler'                     => array(
555
-                'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
556
-            ),
557
-            'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler'                    => array(
558
-                'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
559
-            ),
560
-            'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler'         => array(
561
-                'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
562
-            ),
563
-            'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array(
564
-                'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache,
565
-            ),
566
-            'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler'                              => array(
567
-                'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache,
568
-            ),
569
-            'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler'                              => array(
570
-                'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
571
-            ),
572
-            'EventEspresso\core\domain\services\registration\CancelRegistrationService'                                   => array(
573
-                'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
574
-            ),
575
-            'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler'                                  => array(
576
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
577
-            ),
578
-            'EventEspresso\core\services\database\TableManager'                                                           => array(
579
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
580
-            ),
581
-            'EE_Data_Migration_Class_Base'                                                                                => array(
582
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
583
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
584
-            ),
585
-            'EE_DMS_Core_4_1_0'                                                                                           => array(
586
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
587
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
588
-            ),
589
-            'EE_DMS_Core_4_2_0'                                                                                           => array(
590
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
591
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
592
-            ),
593
-            'EE_DMS_Core_4_3_0'                                                                                           => array(
594
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
595
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
596
-            ),
597
-            'EE_DMS_Core_4_4_0'                                                                                           => array(
598
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
599
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
600
-            ),
601
-            'EE_DMS_Core_4_5_0'                                                                                           => array(
602
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
603
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
604
-            ),
605
-            'EE_DMS_Core_4_6_0'                                                                                           => array(
606
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
607
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
608
-            ),
609
-            'EE_DMS_Core_4_7_0'                                                                                           => array(
610
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
611
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
612
-            ),
613
-            'EE_DMS_Core_4_8_0'                                                                                           => array(
614
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
615
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
616
-            ),
617
-            'EE_DMS_Core_4_9_0'                                                                                           => array(
618
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
619
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
620
-            ),
621
-            'EventEspresso\core\services\assets\I18nRegistry' => array(
622
-                array(),
623
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache
624
-            ),
625
-            'EventEspresso\core\services\assets\Registry'                                                                 => array(
626
-                'EE_Template_Config' => EE_Dependency_Map::load_from_cache,
627
-                'EE_Currency_Config' => EE_Dependency_Map::load_from_cache,
628
-                'EventEspresso\core\services\assets\I18nRegistry' => EE_Dependency_Map::load_from_cache,
629
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache
630
-            ),
631
-            'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled'                                             => array(
632
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
633
-            ),
634
-            'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout'                                              => array(
635
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
636
-            ),
637
-            'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees'                                        => array(
638
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
639
-            ),
640
-            'EventEspresso\core\domain\entities\shortcodes\EspressoEvents'                                                => array(
641
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
642
-            ),
643
-            'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou'                                              => array(
644
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
645
-            ),
646
-            'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector'                                        => array(
647
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
648
-            ),
649
-            'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage'                                               => array(
650
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
651
-            ),
652
-            'EventEspresso\core\services\cache\BasicCacheManager'                        => array(
653
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
654
-            ),
655
-            'EventEspresso\core\services\cache\PostRelatedCacheManager'                  => array(
656
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
657
-            ),
658
-            'EventEspresso\core\domain\services\validation\email\EmailValidationService' => array(
659
-                'EE_Registration_Config'                                  => EE_Dependency_Map::load_from_cache,
660
-                'EventEspresso\core\services\loaders\Loader'              => EE_Dependency_Map::load_from_cache,
661
-            ),
662
-            'EventEspresso\core\domain\values\EmailAddress'                              => array(
663
-                null,
664
-                'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache,
665
-            ),
666
-            'EventEspresso\core\services\orm\ModelFieldFactory' => array(
667
-                'EventEspresso\core\services\loaders\Loader'              => EE_Dependency_Map::load_from_cache,
668
-            ),
669
-            'LEGACY_MODELS'                                                   => array(
670
-                null,
671
-                'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache,
672
-            ),
673
-            'EE_Module_Request_Router'                                               => array(
674
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
675
-            ),
676
-            'EE_Registration_Processor'                                              => array(
677
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
678
-            ),
679
-            'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' => array(
680
-                null,
681
-                'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
682
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
683
-            ),
684
-            'EE_Admin_Transactions_List_Table' => array(
685
-                null,
686
-                'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
687
-            ),
688
-            'EventEspresso\core\services\licensing\LicenseService' => array(
689
-                'EventEspresso\core\domain\services\pue\Stats' => EE_Dependency_Map::load_from_cache,
690
-                'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache
691
-            ),
692
-            'EventEspresso\core\domain\services\pue\Stats' => array(
693
-                'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache,
694
-                'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache,
695
-                'EventEspresso\core\domain\services\pue\StatsGatherer' => EE_Dependency_Map::load_from_cache
696
-            ),
697
-            'EventEspresso\core\domain\services\pue\Config' => array(
698
-                'EE_Network_Config' => EE_Dependency_Map::load_from_cache,
699
-                'EE_Config' => EE_Dependency_Map::load_from_cache
700
-            ),
701
-            'EventEspresso\core\domain\services\pue\StatsGatherer' => array(
702
-                'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
703
-                'EEM_Event' => EE_Dependency_Map::load_from_cache,
704
-                'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
705
-                'EEM_Ticket' => EE_Dependency_Map::load_from_cache,
706
-                'EEM_Registration' => EE_Dependency_Map::load_from_cache,
707
-                'EEM_Transaction' => EE_Dependency_Map::load_from_cache,
708
-                'EE_Config' => EE_Dependency_Map::load_from_cache
709
-            ),
710
-            'EventEspresso\core\domain\services\admin\ExitModal' => array(
711
-                'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache
712
-            ),
713
-            'EventEspresso\core\domain\services\admin\PluginUpsells' => array(
714
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache
715
-            ),
716
-            'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha' => array(
717
-                'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
718
-                'EE_Session'             => EE_Dependency_Map::load_from_cache,
719
-            ),
720
-            'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings' => array(
721
-                'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
722
-            ),
723
-            'EventEspresso\modules\ticket_selector\ProcessTicketSelector' => array(
724
-                'EE_Core_Config' => EE_Dependency_Map::load_from_cache,
725
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
726
-                'EE_Session' => EE_Dependency_Map::load_from_cache,
727
-                'EEM_Ticket' => EE_Dependency_Map::load_from_cache,
728
-                'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache,
729
-            ),
730
-            'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => array(
731
-                'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
732
-            ),
733
-            'EventEspresso\core\services\editor\BlockRegistrationManager'      => array(
734
-                'EventEspresso\core\services\assets\AssetRegisterCollection'      => EE_Dependency_Map::load_from_cache,
735
-                'EventEspresso\core\domain\entities\editor\BlockCollection' => EE_Dependency_Map::load_from_cache,
736
-                'EventEspresso\core\services\request\Request'                     => EE_Dependency_Map::load_from_cache,
737
-            ),
738
-            'EventEspresso\core\domain\entities\editor\blocks\widgets\EventAttendees' => array(
739
-                'EventEspresso\core\domain\Domain'            => EE_Dependency_Map::load_from_cache,
740
-                'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
741
-                'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache
742
-            ),
743
-            'EventEspresso\core\domain\entities\editor\blocks\CoreBlocksAssetRegister' => array(
744
-                'EventEspresso\core\domain\Domain'            => EE_Dependency_Map::load_from_cache,
745
-                'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache
746
-            ),
747
-            'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => array(
748
-                'EE_Core_Config' => EE_Dependency_Map::load_from_cache,
749
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
750
-            ),
751
-            'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes'   => array(
752
-                'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
753
-            ),
754
-            'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies'   => array(
755
-                'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
756
-            ),
757
-            'EventEspresso\core\services\editor\EspressoGutenbergEditor' => array(
758
-                'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
759
-                'EventEspresso\core\domain\entities\editor\BlockCollection'                      => EE_Dependency_Map::load_from_cache,
760
-                'EventEspresso\core\services\request\Request'                                    => EE_Dependency_Map::load_from_cache,
761
-            ),
762
-            'EventEspresso\core\domain\entities\editor\blocks\shortcodes\EventsList'     => array(
763
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
764
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
765
-            ),
766
-            'EventEspresso\core\domain\entities\editor\blocks\TicketSelector'                   => array(
767
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
768
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
769
-            ),
770
-            'EventEspresso\core\domain\entities\editor\blocks\VenueEditor'                      => array(
771
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
772
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
773
-            ),
774
-            'EventEspresso\core\domain\entities\editor\blocks\common\NextUpcomingEventDatetime' => array(
775
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
776
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
777
-            ),
778
-        );
779
-    }
780
-
781
-
782
-
783
-    /**
784
-     * Registers how core classes are loaded.
785
-     * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
786
-     *        'EE_Request_Handler' => 'load_core'
787
-     *        'EE_Messages_Queue'  => 'load_lib'
788
-     *        'EEH_Debug_Tools'    => 'load_helper'
789
-     * or, if greater control is required, by providing a custom closure. For example:
790
-     *        'Some_Class' => function () {
791
-     *            return new Some_Class();
792
-     *        },
793
-     * This is required for instantiating dependencies
794
-     * where an interface has been type hinted in a class constructor. For example:
795
-     *        'Required_Interface' => function () {
796
-     *            return new A_Class_That_Implements_Required_Interface();
797
-     *        },
798
-     *
799
-     * @throws InvalidInterfaceException
800
-     * @throws InvalidDataTypeException
801
-     * @throws InvalidArgumentException
802
-     */
803
-    protected function _register_core_class_loaders()
804
-    {
805
-        //for PHP5.3 compat, we need to register any properties called here in a variable because `$this` cannot
806
-        //be used in a closure.
807
-        $request = &$this->request;
808
-        $response = &$this->response;
809
-        $legacy_request = &$this->legacy_request;
810
-        // $loader = &$this->loader;
811
-        $this->_class_loaders = array(
812
-            //load_core
813
-            'EE_Capabilities'          => 'load_core',
814
-            'EE_Encryption'            => 'load_core',
815
-            'EE_Front_Controller'      => 'load_core',
816
-            'EE_Module_Request_Router' => 'load_core',
817
-            'EE_Registry'              => 'load_core',
818
-            'EE_Request'               => function () use (&$legacy_request) {
819
-                return $legacy_request;
820
-            },
821
-            'EventEspresso\core\services\request\Request' => function () use (&$request) {
822
-                return $request;
823
-            },
824
-            'EventEspresso\core\services\request\Response' => function () use (&$response) {
825
-                return $response;
826
-            },
827
-            'EE_Request_Handler'       => 'load_core',
828
-            'EE_Session'               => 'load_core',
829
-            'EE_Cron_Tasks'            => 'load_core',
830
-            'EE_System'                => 'load_core',
831
-            'EE_Maintenance_Mode'      => 'load_core',
832
-            'EE_Register_CPTs'         => 'load_core',
833
-            'EE_Admin'                 => 'load_core',
834
-            //load_lib
835
-            'EE_Message_Resource_Manager'          => 'load_lib',
836
-            'EE_Message_Type_Collection'           => 'load_lib',
837
-            'EE_Message_Type_Collection_Loader'    => 'load_lib',
838
-            'EE_Messenger_Collection'              => 'load_lib',
839
-            'EE_Messenger_Collection_Loader'       => 'load_lib',
840
-            'EE_Messages_Processor'                => 'load_lib',
841
-            'EE_Message_Repository'                => 'load_lib',
842
-            'EE_Messages_Queue'                    => 'load_lib',
843
-            'EE_Messages_Data_Handler_Collection'  => 'load_lib',
844
-            'EE_Message_Template_Group_Collection' => 'load_lib',
845
-            'EE_Payment_Method_Manager'            => 'load_lib',
846
-            'EE_Messages_Generator'                => function () {
847
-                return EE_Registry::instance()->load_lib(
848
-                    'Messages_Generator',
849
-                    array(),
850
-                    false,
851
-                    false
852
-                );
853
-            },
854
-            'EE_Messages_Template_Defaults'        => function ($arguments = array()) {
855
-                return EE_Registry::instance()->load_lib(
856
-                    'Messages_Template_Defaults',
857
-                    $arguments,
858
-                    false,
859
-                    false
860
-                );
861
-            },
862
-            //load_helper
863
-            'EEH_Parse_Shortcodes'                 => function () {
864
-                if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
865
-                    return new EEH_Parse_Shortcodes();
866
-                }
867
-                return null;
868
-            },
869
-            'EE_Template_Config'                   => function () {
870
-                return EE_Config::instance()->template_settings;
871
-            },
872
-            'EE_Currency_Config'                   => function () {
873
-                return EE_Config::instance()->currency;
874
-            },
875
-            'EE_Registration_Config'                   => function () {
876
-                return EE_Config::instance()->registration;
877
-            },
878
-            'EE_Core_Config'                   => function () {
879
-                return EE_Config::instance()->core;
880
-            },
881
-            'EventEspresso\core\services\loaders\Loader' => function () {
882
-                return LoaderFactory::getLoader();
883
-            },
884
-            'EE_Network_Config' => function() {
885
-                return EE_Network_Config::instance();
886
-            },
887
-            'EE_Config' => function () {
888
-                return EE_Config::instance();
889
-            }
890
-        );
891
-    }
892
-
893
-
894
-
895
-    /**
896
-     * can be used for supplying alternate names for classes,
897
-     * or for connecting interface names to instantiable classes
898
-     */
899
-    protected function _register_core_aliases()
900
-    {
901
-        $this->_aliases = array(
902
-            'CommandBusInterface'                                                          => 'EventEspresso\core\services\commands\CommandBusInterface',
903
-            'EventEspresso\core\services\commands\CommandBusInterface'                     => 'EventEspresso\core\services\commands\CommandBus',
904
-            'CommandHandlerManagerInterface'                                               => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
905
-            'EventEspresso\core\services\commands\CommandHandlerManagerInterface'          => 'EventEspresso\core\services\commands\CommandHandlerManager',
906
-            'CapChecker'                                                                   => 'EventEspresso\core\services\commands\middleware\CapChecker',
907
-            'AddActionHook'                                                                => 'EventEspresso\core\services\commands\middleware\AddActionHook',
908
-            'CapabilitiesChecker'                                                          => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
909
-            'CapabilitiesCheckerInterface'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface',
910
-            'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
911
-            'CreateRegistrationService'                                                    => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
912
-            'CreateRegCodeCommandHandler'                                                  => 'EventEspresso\core\services\commands\registration\CreateRegCodeCommand',
913
-            'CreateRegUrlLinkCommandHandler'                                               => 'EventEspresso\core\services\commands\registration\CreateRegUrlLinkCommand',
914
-            'CreateRegistrationCommandHandler'                                             => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
915
-            'CopyRegistrationDetailsCommandHandler'                                        => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
916
-            'CopyRegistrationPaymentsCommandHandler'                                       => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
917
-            'CancelRegistrationAndTicketLineItemCommandHandler'                            => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
918
-            'UpdateRegistrationAndTransactionAfterChangeCommandHandler'                    => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
919
-            'CreateTicketLineItemCommandHandler'                                           => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
920
-            'CreateTransactionCommandHandler'                                     => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler',
921
-            'CreateAttendeeCommandHandler'                                        => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler',
922
-            'TableManager'                                                                 => 'EventEspresso\core\services\database\TableManager',
923
-            'TableAnalysis'                                                                => 'EventEspresso\core\services\database\TableAnalysis',
924
-            'EspressoShortcode'                                                            => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
925
-            'ShortcodeInterface'                                                           => 'EventEspresso\core\services\shortcodes\ShortcodeInterface',
926
-            'EventEspresso\core\services\shortcodes\ShortcodeInterface'                    => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
927
-            'EventEspresso\core\services\cache\CacheStorageInterface'                      => 'EventEspresso\core\services\cache\TransientCacheStorage',
928
-            'LoaderInterface'                                                              => 'EventEspresso\core\services\loaders\LoaderInterface',
929
-            'EventEspresso\core\services\loaders\LoaderInterface'                          => 'EventEspresso\core\services\loaders\Loader',
930
-            'CommandFactoryInterface'                                                     => 'EventEspresso\core\services\commands\CommandFactoryInterface',
931
-            'EventEspresso\core\services\commands\CommandFactoryInterface'                => 'EventEspresso\core\services\commands\CommandFactory',
932
-            'EventEspresso\core\domain\services\session\SessionIdentifierInterface'       => 'EE_Session',
933
-            'EmailValidatorInterface'                                                     => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface',
934
-            'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService',
935
-            'NoticeConverterInterface'                                            => 'EventEspresso\core\services\notices\NoticeConverterInterface',
936
-            'EventEspresso\core\services\notices\NoticeConverterInterface'        => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors',
937
-            'NoticesContainerInterface'                                           => 'EventEspresso\core\services\notices\NoticesContainerInterface',
938
-            'EventEspresso\core\services\notices\NoticesContainerInterface'       => 'EventEspresso\core\services\notices\NoticesContainer',
939
-            'EventEspresso\core\services\request\RequestInterface'                => 'EventEspresso\core\services\request\Request',
940
-            'EventEspresso\core\services\request\ResponseInterface'               => 'EventEspresso\core\services\request\Response',
941
-            'EventEspresso\core\domain\DomainInterface'                           => 'EventEspresso\core\domain\Domain',
942
-        );
943
-        if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
944
-            $this->_aliases['EventEspresso\core\services\notices\NoticeConverterInterface'] = 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices';
945
-        }
946
-    }
947
-
948
-
949
-
950
-    /**
951
-     * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
952
-     * request Primarily used by unit tests.
953
-     *
954
-     * @throws InvalidDataTypeException
955
-     * @throws InvalidInterfaceException
956
-     * @throws InvalidArgumentException
957
-     */
958
-    public function reset()
959
-    {
960
-        $this->_register_core_class_loaders();
961
-        $this->_register_core_dependencies();
962
-    }
28
+	/**
29
+	 * This means that the requested class dependency is not present in the dependency map
30
+	 */
31
+	const not_registered = 0;
32
+
33
+	/**
34
+	 * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class.
35
+	 */
36
+	const load_new_object = 1;
37
+
38
+	/**
39
+	 * This instructs class loaders to return a previously instantiated and cached object for the requested class.
40
+	 * IF a previously instantiated object does not exist, a new one will be created and added to the cache.
41
+	 */
42
+	const load_from_cache = 2;
43
+
44
+	/**
45
+	 * When registering a dependency,
46
+	 * this indicates to keep any existing dependencies that already exist,
47
+	 * and simply discard any new dependencies declared in the incoming data
48
+	 */
49
+	const KEEP_EXISTING_DEPENDENCIES = 0;
50
+
51
+	/**
52
+	 * When registering a dependency,
53
+	 * this indicates to overwrite any existing dependencies that already exist using the incoming data
54
+	 */
55
+	const OVERWRITE_DEPENDENCIES = 1;
56
+
57
+
58
+
59
+	/**
60
+	 * @type EE_Dependency_Map $_instance
61
+	 */
62
+	protected static $_instance;
63
+
64
+	/**
65
+	 * @type RequestInterface $request
66
+	 */
67
+	protected $request;
68
+
69
+	/**
70
+	 * @type LegacyRequestInterface $legacy_request
71
+	 */
72
+	protected $legacy_request;
73
+
74
+	/**
75
+	 * @type ResponseInterface $response
76
+	 */
77
+	protected $response;
78
+
79
+	/**
80
+	 * @type LoaderInterface $loader
81
+	 */
82
+	protected $loader;
83
+
84
+	/**
85
+	 * @type array $_dependency_map
86
+	 */
87
+	protected $_dependency_map = array();
88
+
89
+	/**
90
+	 * @type array $_class_loaders
91
+	 */
92
+	protected $_class_loaders = array();
93
+
94
+	/**
95
+	 * @type array $_aliases
96
+	 */
97
+	protected $_aliases = array();
98
+
99
+
100
+
101
+	/**
102
+	 * EE_Dependency_Map constructor.
103
+	 */
104
+	protected function __construct()
105
+	{
106
+		// add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize'));
107
+		do_action('EE_Dependency_Map____construct');
108
+	}
109
+
110
+
111
+
112
+	/**
113
+	 * @throws InvalidDataTypeException
114
+	 * @throws InvalidInterfaceException
115
+	 * @throws InvalidArgumentException
116
+	 */
117
+	public function initialize()
118
+	{
119
+		$this->_register_core_dependencies();
120
+		$this->_register_core_class_loaders();
121
+		$this->_register_core_aliases();
122
+	}
123
+
124
+
125
+
126
+	/**
127
+	 * @singleton method used to instantiate class object
128
+	 * @return EE_Dependency_Map
129
+	 */
130
+	public static function instance() {
131
+		// check if class object is instantiated, and instantiated properly
132
+		if (! self::$_instance instanceof EE_Dependency_Map) {
133
+			self::$_instance = new EE_Dependency_Map(/*$request, $response, $legacy_request*/);
134
+		}
135
+		return self::$_instance;
136
+	}
137
+
138
+
139
+	/**
140
+	 * @param RequestInterface $request
141
+	 */
142
+	public function setRequest(RequestInterface $request)
143
+	{
144
+		$this->request = $request;
145
+	}
146
+
147
+
148
+	/**
149
+	 * @param LegacyRequestInterface $legacy_request
150
+	 */
151
+	public function setLegacyRequest(LegacyRequestInterface $legacy_request)
152
+	{
153
+		$this->legacy_request = $legacy_request;
154
+	}
155
+
156
+
157
+	/**
158
+	 * @param ResponseInterface $response
159
+	 */
160
+	public function setResponse(ResponseInterface $response)
161
+	{
162
+		$this->response = $response;
163
+	}
164
+
165
+
166
+
167
+	/**
168
+	 * @param LoaderInterface $loader
169
+	 */
170
+	public function setLoader(LoaderInterface $loader)
171
+	{
172
+		$this->loader = $loader;
173
+	}
174
+
175
+
176
+
177
+	/**
178
+	 * @param string $class
179
+	 * @param array  $dependencies
180
+	 * @param int    $overwrite
181
+	 * @return bool
182
+	 */
183
+	public static function register_dependencies(
184
+		$class,
185
+		array $dependencies,
186
+		$overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
187
+	) {
188
+		return self::$_instance->registerDependencies($class, $dependencies, $overwrite);
189
+	}
190
+
191
+
192
+
193
+	/**
194
+	 * Assigns an array of class names and corresponding load sources (new or cached)
195
+	 * to the class specified by the first parameter.
196
+	 * IMPORTANT !!!
197
+	 * The order of elements in the incoming $dependencies array MUST match
198
+	 * the order of the constructor parameters for the class in question.
199
+	 * This is especially important when overriding any existing dependencies that are registered.
200
+	 * the third parameter controls whether any duplicate dependencies are overwritten or not.
201
+	 *
202
+	 * @param string $class
203
+	 * @param array  $dependencies
204
+	 * @param int    $overwrite
205
+	 * @return bool
206
+	 */
207
+	public function registerDependencies(
208
+		$class,
209
+		array $dependencies,
210
+		$overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
211
+	) {
212
+		$class = trim($class, '\\');
213
+		$registered = false;
214
+		if (empty(self::$_instance->_dependency_map[ $class ])) {
215
+			self::$_instance->_dependency_map[ $class ] = array();
216
+		}
217
+		// we need to make sure that any aliases used when registering a dependency
218
+		// get resolved to the correct class name
219
+		foreach ($dependencies as $dependency => $load_source) {
220
+			$alias = self::$_instance->get_alias($dependency);
221
+			if (
222
+				$overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
223
+				|| ! isset(self::$_instance->_dependency_map[ $class ][ $alias ])
224
+			) {
225
+				unset($dependencies[$dependency]);
226
+				$dependencies[$alias] = $load_source;
227
+				$registered = true;
228
+			}
229
+		}
230
+		// now add our two lists of dependencies together.
231
+		// using Union (+=) favours the arrays in precedence from left to right,
232
+		// so $dependencies is NOT overwritten because it is listed first
233
+		// ie: with A = B + C, entries in B take precedence over duplicate entries in C
234
+		// Union is way faster than array_merge() but should be used with caution...
235
+		// especially with numerically indexed arrays
236
+		$dependencies += self::$_instance->_dependency_map[ $class ];
237
+		// now we need to ensure that the resulting dependencies
238
+		// array only has the entries that are required for the class
239
+		// so first count how many dependencies were originally registered for the class
240
+		$dependency_count = count(self::$_instance->_dependency_map[ $class ]);
241
+		// if that count is non-zero (meaning dependencies were already registered)
242
+		self::$_instance->_dependency_map[ $class ] = $dependency_count
243
+			// then truncate the  final array to match that count
244
+			? array_slice($dependencies, 0, $dependency_count)
245
+			// otherwise just take the incoming array because nothing previously existed
246
+			: $dependencies;
247
+		return $registered;
248
+	}
249
+
250
+
251
+
252
+	/**
253
+	 * @param string $class_name
254
+	 * @param string $loader
255
+	 * @return bool
256
+	 * @throws DomainException
257
+	 */
258
+	public static function register_class_loader($class_name, $loader = 'load_core')
259
+	{
260
+		if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
261
+			throw new DomainException(
262
+				esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
263
+			);
264
+		}
265
+		// check that loader is callable or method starts with "load_" and exists in EE_Registry
266
+		if (
267
+			! is_callable($loader)
268
+			&& (
269
+				strpos($loader, 'load_') !== 0
270
+				|| ! method_exists('EE_Registry', $loader)
271
+			)
272
+		) {
273
+			throw new DomainException(
274
+				sprintf(
275
+					esc_html__(
276
+						'"%1$s" is not a valid loader method on EE_Registry.',
277
+						'event_espresso'
278
+					),
279
+					$loader
280
+				)
281
+			);
282
+		}
283
+		$class_name = self::$_instance->get_alias($class_name);
284
+		if (! isset(self::$_instance->_class_loaders[$class_name])) {
285
+			self::$_instance->_class_loaders[$class_name] = $loader;
286
+			return true;
287
+		}
288
+		return false;
289
+	}
290
+
291
+
292
+
293
+	/**
294
+	 * @return array
295
+	 */
296
+	public function dependency_map()
297
+	{
298
+		return $this->_dependency_map;
299
+	}
300
+
301
+
302
+
303
+	/**
304
+	 * returns TRUE if dependency map contains a listing for the provided class name
305
+	 *
306
+	 * @param string $class_name
307
+	 * @return boolean
308
+	 */
309
+	public function has($class_name = '')
310
+	{
311
+		// all legacy models have the same dependencies
312
+		if (strpos($class_name, 'EEM_') === 0) {
313
+			$class_name = 'LEGACY_MODELS';
314
+		}
315
+		return isset($this->_dependency_map[$class_name]) ? true : false;
316
+	}
317
+
318
+
319
+
320
+	/**
321
+	 * returns TRUE if dependency map contains a listing for the provided class name AND dependency
322
+	 *
323
+	 * @param string $class_name
324
+	 * @param string $dependency
325
+	 * @return bool
326
+	 */
327
+	public function has_dependency_for_class($class_name = '', $dependency = '')
328
+	{
329
+		// all legacy models have the same dependencies
330
+		if (strpos($class_name, 'EEM_') === 0) {
331
+			$class_name = 'LEGACY_MODELS';
332
+		}
333
+		$dependency = $this->get_alias($dependency);
334
+		return isset($this->_dependency_map[$class_name][$dependency])
335
+			? true
336
+			: false;
337
+	}
338
+
339
+
340
+
341
+	/**
342
+	 * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned
343
+	 *
344
+	 * @param string $class_name
345
+	 * @param string $dependency
346
+	 * @return int
347
+	 */
348
+	public function loading_strategy_for_class_dependency($class_name = '', $dependency = '')
349
+	{
350
+		// all legacy models have the same dependencies
351
+		if (strpos($class_name, 'EEM_') === 0) {
352
+			$class_name = 'LEGACY_MODELS';
353
+		}
354
+		$dependency = $this->get_alias($dependency);
355
+		return $this->has_dependency_for_class($class_name, $dependency)
356
+			? $this->_dependency_map[$class_name][$dependency]
357
+			: EE_Dependency_Map::not_registered;
358
+	}
359
+
360
+
361
+
362
+	/**
363
+	 * @param string $class_name
364
+	 * @return string | Closure
365
+	 */
366
+	public function class_loader($class_name)
367
+	{
368
+		// all legacy models use load_model()
369
+		if(strpos($class_name, 'EEM_') === 0){
370
+			return 'load_model';
371
+		}
372
+		$class_name = $this->get_alias($class_name);
373
+		return isset($this->_class_loaders[$class_name]) ? $this->_class_loaders[$class_name] : '';
374
+	}
375
+
376
+
377
+
378
+	/**
379
+	 * @return array
380
+	 */
381
+	public function class_loaders()
382
+	{
383
+		return $this->_class_loaders;
384
+	}
385
+
386
+
387
+
388
+	/**
389
+	 * adds an alias for a classname
390
+	 *
391
+	 * @param string $class_name the class name that should be used (concrete class to replace interface)
392
+	 * @param string $alias      the class name that would be type hinted for (abstract parent or interface)
393
+	 * @param string $for_class  the class that has the dependency (is type hinting for the interface)
394
+	 */
395
+	public function add_alias($class_name, $alias, $for_class = '')
396
+	{
397
+		if ($for_class !== '') {
398
+			if (! isset($this->_aliases[$for_class])) {
399
+				$this->_aliases[$for_class] = array();
400
+			}
401
+			$this->_aliases[$for_class][$class_name] = $alias;
402
+		}
403
+		$this->_aliases[$class_name] = $alias;
404
+	}
405
+
406
+
407
+
408
+	/**
409
+	 * returns TRUE if the provided class name has an alias
410
+	 *
411
+	 * @param string $class_name
412
+	 * @param string $for_class
413
+	 * @return bool
414
+	 */
415
+	public function has_alias($class_name = '', $for_class = '')
416
+	{
417
+		return isset($this->_aliases[$for_class][$class_name])
418
+			   || (
419
+				   isset($this->_aliases[$class_name])
420
+				   && ! is_array($this->_aliases[$class_name])
421
+			   );
422
+	}
423
+
424
+
425
+
426
+	/**
427
+	 * returns alias for class name if one exists, otherwise returns the original classname
428
+	 * functions recursively, so that multiple aliases can be used to drill down to a classname
429
+	 *  for example:
430
+	 *      if the following two entries were added to the _aliases array:
431
+	 *          array(
432
+	 *              'interface_alias'           => 'some\namespace\interface'
433
+	 *              'some\namespace\interface'  => 'some\namespace\classname'
434
+	 *          )
435
+	 *      then one could use EE_Registry::instance()->create( 'interface_alias' )
436
+	 *      to load an instance of 'some\namespace\classname'
437
+	 *
438
+	 * @param string $class_name
439
+	 * @param string $for_class
440
+	 * @return string
441
+	 */
442
+	public function get_alias($class_name = '', $for_class = '')
443
+	{
444
+		if (! $this->has_alias($class_name, $for_class)) {
445
+			return $class_name;
446
+		}
447
+		if ($for_class !== '' && isset($this->_aliases[ $for_class ][ $class_name ])) {
448
+			return $this->get_alias($this->_aliases[$for_class][$class_name], $for_class);
449
+		}
450
+		return $this->get_alias($this->_aliases[$class_name]);
451
+	}
452
+
453
+
454
+
455
+	/**
456
+	 * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache,
457
+	 * if one exists, or whether a new object should be generated every time the requested class is loaded.
458
+	 * This is done by using the following class constants:
459
+	 *        EE_Dependency_Map::load_from_cache - loads previously instantiated object
460
+	 *        EE_Dependency_Map::load_new_object - generates a new object every time
461
+	 */
462
+	protected function _register_core_dependencies()
463
+	{
464
+		$this->_dependency_map = array(
465
+			'EE_Request_Handler'                                                                                          => array(
466
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
467
+			),
468
+			'EE_System'                                                                                                   => array(
469
+				'EE_Registry'                                 => EE_Dependency_Map::load_from_cache,
470
+				'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
471
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
472
+				'EE_Maintenance_Mode'                         => EE_Dependency_Map::load_from_cache,
473
+			),
474
+			'EE_Session'                                                                                                  => array(
475
+				'EventEspresso\core\services\cache\TransientCacheStorage'  => EE_Dependency_Map::load_from_cache,
476
+				'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
477
+				'EventEspresso\core\services\request\Request'              => EE_Dependency_Map::load_from_cache,
478
+				'EE_Encryption'                                            => EE_Dependency_Map::load_from_cache,
479
+			),
480
+			'EE_Cart'                                                                                                     => array(
481
+				'EE_Session' => EE_Dependency_Map::load_from_cache,
482
+			),
483
+			'EE_Front_Controller'                                                                                         => array(
484
+				'EE_Registry'              => EE_Dependency_Map::load_from_cache,
485
+				'EE_Request_Handler'       => EE_Dependency_Map::load_from_cache,
486
+				'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache,
487
+			),
488
+			'EE_Messenger_Collection_Loader'                                                                              => array(
489
+				'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object,
490
+			),
491
+			'EE_Message_Type_Collection_Loader'                                                                           => array(
492
+				'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object,
493
+			),
494
+			'EE_Message_Resource_Manager'                                                                                 => array(
495
+				'EE_Messenger_Collection_Loader'    => EE_Dependency_Map::load_new_object,
496
+				'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object,
497
+				'EEM_Message_Template_Group'        => EE_Dependency_Map::load_from_cache,
498
+			),
499
+			'EE_Message_Factory'                                                                                          => array(
500
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
501
+			),
502
+			'EE_messages'                                                                                                 => array(
503
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
504
+			),
505
+			'EE_Messages_Generator'                                                                                       => array(
506
+				'EE_Messages_Queue'                    => EE_Dependency_Map::load_new_object,
507
+				'EE_Messages_Data_Handler_Collection'  => EE_Dependency_Map::load_new_object,
508
+				'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object,
509
+				'EEH_Parse_Shortcodes'                 => EE_Dependency_Map::load_from_cache,
510
+			),
511
+			'EE_Messages_Processor'                                                                                       => array(
512
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
513
+			),
514
+			'EE_Messages_Queue'                                                                                           => array(
515
+				'EE_Message_Repository' => EE_Dependency_Map::load_new_object,
516
+			),
517
+			'EE_Messages_Template_Defaults'                                                                               => array(
518
+				'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache,
519
+				'EEM_Message_Template'       => EE_Dependency_Map::load_from_cache,
520
+			),
521
+			'EE_Message_To_Generate_From_Request'                                                                         => array(
522
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
523
+				'EE_Request_Handler'          => EE_Dependency_Map::load_from_cache,
524
+			),
525
+			'EventEspresso\core\services\commands\CommandBus'                                                             => array(
526
+				'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache,
527
+			),
528
+			'EventEspresso\services\commands\CommandHandler'                                                              => array(
529
+				'EE_Registry'         => EE_Dependency_Map::load_from_cache,
530
+				'CommandBusInterface' => EE_Dependency_Map::load_from_cache,
531
+			),
532
+			'EventEspresso\core\services\commands\CommandHandlerManager'                                                  => array(
533
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
534
+			),
535
+			'EventEspresso\core\services\commands\CompositeCommandHandler'                                                => array(
536
+				'EventEspresso\core\services\commands\CommandBus'     => EE_Dependency_Map::load_from_cache,
537
+				'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache,
538
+			),
539
+			'EventEspresso\core\services\commands\CommandFactory'                                                         => array(
540
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
541
+			),
542
+			'EventEspresso\core\services\commands\middleware\CapChecker'                                                  => array(
543
+				'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
544
+			),
545
+			'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker'                                         => array(
546
+				'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
547
+			),
548
+			'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker'                                     => array(
549
+				'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
550
+			),
551
+			'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler'                          => array(
552
+				'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache,
553
+			),
554
+			'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler'                     => array(
555
+				'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
556
+			),
557
+			'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler'                    => array(
558
+				'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
559
+			),
560
+			'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler'         => array(
561
+				'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
562
+			),
563
+			'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array(
564
+				'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache,
565
+			),
566
+			'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler'                              => array(
567
+				'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache,
568
+			),
569
+			'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler'                              => array(
570
+				'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
571
+			),
572
+			'EventEspresso\core\domain\services\registration\CancelRegistrationService'                                   => array(
573
+				'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
574
+			),
575
+			'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler'                                  => array(
576
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
577
+			),
578
+			'EventEspresso\core\services\database\TableManager'                                                           => array(
579
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
580
+			),
581
+			'EE_Data_Migration_Class_Base'                                                                                => array(
582
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
583
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
584
+			),
585
+			'EE_DMS_Core_4_1_0'                                                                                           => array(
586
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
587
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
588
+			),
589
+			'EE_DMS_Core_4_2_0'                                                                                           => array(
590
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
591
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
592
+			),
593
+			'EE_DMS_Core_4_3_0'                                                                                           => array(
594
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
595
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
596
+			),
597
+			'EE_DMS_Core_4_4_0'                                                                                           => array(
598
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
599
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
600
+			),
601
+			'EE_DMS_Core_4_5_0'                                                                                           => array(
602
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
603
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
604
+			),
605
+			'EE_DMS_Core_4_6_0'                                                                                           => array(
606
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
607
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
608
+			),
609
+			'EE_DMS_Core_4_7_0'                                                                                           => array(
610
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
611
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
612
+			),
613
+			'EE_DMS_Core_4_8_0'                                                                                           => array(
614
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
615
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
616
+			),
617
+			'EE_DMS_Core_4_9_0'                                                                                           => array(
618
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
619
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
620
+			),
621
+			'EventEspresso\core\services\assets\I18nRegistry' => array(
622
+				array(),
623
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache
624
+			),
625
+			'EventEspresso\core\services\assets\Registry'                                                                 => array(
626
+				'EE_Template_Config' => EE_Dependency_Map::load_from_cache,
627
+				'EE_Currency_Config' => EE_Dependency_Map::load_from_cache,
628
+				'EventEspresso\core\services\assets\I18nRegistry' => EE_Dependency_Map::load_from_cache,
629
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache
630
+			),
631
+			'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled'                                             => array(
632
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
633
+			),
634
+			'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout'                                              => array(
635
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
636
+			),
637
+			'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees'                                        => array(
638
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
639
+			),
640
+			'EventEspresso\core\domain\entities\shortcodes\EspressoEvents'                                                => array(
641
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
642
+			),
643
+			'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou'                                              => array(
644
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
645
+			),
646
+			'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector'                                        => array(
647
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
648
+			),
649
+			'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage'                                               => array(
650
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
651
+			),
652
+			'EventEspresso\core\services\cache\BasicCacheManager'                        => array(
653
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
654
+			),
655
+			'EventEspresso\core\services\cache\PostRelatedCacheManager'                  => array(
656
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
657
+			),
658
+			'EventEspresso\core\domain\services\validation\email\EmailValidationService' => array(
659
+				'EE_Registration_Config'                                  => EE_Dependency_Map::load_from_cache,
660
+				'EventEspresso\core\services\loaders\Loader'              => EE_Dependency_Map::load_from_cache,
661
+			),
662
+			'EventEspresso\core\domain\values\EmailAddress'                              => array(
663
+				null,
664
+				'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache,
665
+			),
666
+			'EventEspresso\core\services\orm\ModelFieldFactory' => array(
667
+				'EventEspresso\core\services\loaders\Loader'              => EE_Dependency_Map::load_from_cache,
668
+			),
669
+			'LEGACY_MODELS'                                                   => array(
670
+				null,
671
+				'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache,
672
+			),
673
+			'EE_Module_Request_Router'                                               => array(
674
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
675
+			),
676
+			'EE_Registration_Processor'                                              => array(
677
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
678
+			),
679
+			'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' => array(
680
+				null,
681
+				'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
682
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
683
+			),
684
+			'EE_Admin_Transactions_List_Table' => array(
685
+				null,
686
+				'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
687
+			),
688
+			'EventEspresso\core\services\licensing\LicenseService' => array(
689
+				'EventEspresso\core\domain\services\pue\Stats' => EE_Dependency_Map::load_from_cache,
690
+				'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache
691
+			),
692
+			'EventEspresso\core\domain\services\pue\Stats' => array(
693
+				'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache,
694
+				'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache,
695
+				'EventEspresso\core\domain\services\pue\StatsGatherer' => EE_Dependency_Map::load_from_cache
696
+			),
697
+			'EventEspresso\core\domain\services\pue\Config' => array(
698
+				'EE_Network_Config' => EE_Dependency_Map::load_from_cache,
699
+				'EE_Config' => EE_Dependency_Map::load_from_cache
700
+			),
701
+			'EventEspresso\core\domain\services\pue\StatsGatherer' => array(
702
+				'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
703
+				'EEM_Event' => EE_Dependency_Map::load_from_cache,
704
+				'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
705
+				'EEM_Ticket' => EE_Dependency_Map::load_from_cache,
706
+				'EEM_Registration' => EE_Dependency_Map::load_from_cache,
707
+				'EEM_Transaction' => EE_Dependency_Map::load_from_cache,
708
+				'EE_Config' => EE_Dependency_Map::load_from_cache
709
+			),
710
+			'EventEspresso\core\domain\services\admin\ExitModal' => array(
711
+				'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache
712
+			),
713
+			'EventEspresso\core\domain\services\admin\PluginUpsells' => array(
714
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache
715
+			),
716
+			'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha' => array(
717
+				'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
718
+				'EE_Session'             => EE_Dependency_Map::load_from_cache,
719
+			),
720
+			'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings' => array(
721
+				'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
722
+			),
723
+			'EventEspresso\modules\ticket_selector\ProcessTicketSelector' => array(
724
+				'EE_Core_Config' => EE_Dependency_Map::load_from_cache,
725
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
726
+				'EE_Session' => EE_Dependency_Map::load_from_cache,
727
+				'EEM_Ticket' => EE_Dependency_Map::load_from_cache,
728
+				'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache,
729
+			),
730
+			'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => array(
731
+				'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
732
+			),
733
+			'EventEspresso\core\services\editor\BlockRegistrationManager'      => array(
734
+				'EventEspresso\core\services\assets\AssetRegisterCollection'      => EE_Dependency_Map::load_from_cache,
735
+				'EventEspresso\core\domain\entities\editor\BlockCollection' => EE_Dependency_Map::load_from_cache,
736
+				'EventEspresso\core\services\request\Request'                     => EE_Dependency_Map::load_from_cache,
737
+			),
738
+			'EventEspresso\core\domain\entities\editor\blocks\widgets\EventAttendees' => array(
739
+				'EventEspresso\core\domain\Domain'            => EE_Dependency_Map::load_from_cache,
740
+				'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
741
+				'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache
742
+			),
743
+			'EventEspresso\core\domain\entities\editor\blocks\CoreBlocksAssetRegister' => array(
744
+				'EventEspresso\core\domain\Domain'            => EE_Dependency_Map::load_from_cache,
745
+				'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache
746
+			),
747
+			'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => array(
748
+				'EE_Core_Config' => EE_Dependency_Map::load_from_cache,
749
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
750
+			),
751
+			'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes'   => array(
752
+				'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
753
+			),
754
+			'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies'   => array(
755
+				'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
756
+			),
757
+			'EventEspresso\core\services\editor\EspressoGutenbergEditor' => array(
758
+				'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
759
+				'EventEspresso\core\domain\entities\editor\BlockCollection'                      => EE_Dependency_Map::load_from_cache,
760
+				'EventEspresso\core\services\request\Request'                                    => EE_Dependency_Map::load_from_cache,
761
+			),
762
+			'EventEspresso\core\domain\entities\editor\blocks\shortcodes\EventsList'     => array(
763
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
764
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
765
+			),
766
+			'EventEspresso\core\domain\entities\editor\blocks\TicketSelector'                   => array(
767
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
768
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
769
+			),
770
+			'EventEspresso\core\domain\entities\editor\blocks\VenueEditor'                      => array(
771
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
772
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
773
+			),
774
+			'EventEspresso\core\domain\entities\editor\blocks\common\NextUpcomingEventDatetime' => array(
775
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
776
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
777
+			),
778
+		);
779
+	}
780
+
781
+
782
+
783
+	/**
784
+	 * Registers how core classes are loaded.
785
+	 * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
786
+	 *        'EE_Request_Handler' => 'load_core'
787
+	 *        'EE_Messages_Queue'  => 'load_lib'
788
+	 *        'EEH_Debug_Tools'    => 'load_helper'
789
+	 * or, if greater control is required, by providing a custom closure. For example:
790
+	 *        'Some_Class' => function () {
791
+	 *            return new Some_Class();
792
+	 *        },
793
+	 * This is required for instantiating dependencies
794
+	 * where an interface has been type hinted in a class constructor. For example:
795
+	 *        'Required_Interface' => function () {
796
+	 *            return new A_Class_That_Implements_Required_Interface();
797
+	 *        },
798
+	 *
799
+	 * @throws InvalidInterfaceException
800
+	 * @throws InvalidDataTypeException
801
+	 * @throws InvalidArgumentException
802
+	 */
803
+	protected function _register_core_class_loaders()
804
+	{
805
+		//for PHP5.3 compat, we need to register any properties called here in a variable because `$this` cannot
806
+		//be used in a closure.
807
+		$request = &$this->request;
808
+		$response = &$this->response;
809
+		$legacy_request = &$this->legacy_request;
810
+		// $loader = &$this->loader;
811
+		$this->_class_loaders = array(
812
+			//load_core
813
+			'EE_Capabilities'          => 'load_core',
814
+			'EE_Encryption'            => 'load_core',
815
+			'EE_Front_Controller'      => 'load_core',
816
+			'EE_Module_Request_Router' => 'load_core',
817
+			'EE_Registry'              => 'load_core',
818
+			'EE_Request'               => function () use (&$legacy_request) {
819
+				return $legacy_request;
820
+			},
821
+			'EventEspresso\core\services\request\Request' => function () use (&$request) {
822
+				return $request;
823
+			},
824
+			'EventEspresso\core\services\request\Response' => function () use (&$response) {
825
+				return $response;
826
+			},
827
+			'EE_Request_Handler'       => 'load_core',
828
+			'EE_Session'               => 'load_core',
829
+			'EE_Cron_Tasks'            => 'load_core',
830
+			'EE_System'                => 'load_core',
831
+			'EE_Maintenance_Mode'      => 'load_core',
832
+			'EE_Register_CPTs'         => 'load_core',
833
+			'EE_Admin'                 => 'load_core',
834
+			//load_lib
835
+			'EE_Message_Resource_Manager'          => 'load_lib',
836
+			'EE_Message_Type_Collection'           => 'load_lib',
837
+			'EE_Message_Type_Collection_Loader'    => 'load_lib',
838
+			'EE_Messenger_Collection'              => 'load_lib',
839
+			'EE_Messenger_Collection_Loader'       => 'load_lib',
840
+			'EE_Messages_Processor'                => 'load_lib',
841
+			'EE_Message_Repository'                => 'load_lib',
842
+			'EE_Messages_Queue'                    => 'load_lib',
843
+			'EE_Messages_Data_Handler_Collection'  => 'load_lib',
844
+			'EE_Message_Template_Group_Collection' => 'load_lib',
845
+			'EE_Payment_Method_Manager'            => 'load_lib',
846
+			'EE_Messages_Generator'                => function () {
847
+				return EE_Registry::instance()->load_lib(
848
+					'Messages_Generator',
849
+					array(),
850
+					false,
851
+					false
852
+				);
853
+			},
854
+			'EE_Messages_Template_Defaults'        => function ($arguments = array()) {
855
+				return EE_Registry::instance()->load_lib(
856
+					'Messages_Template_Defaults',
857
+					$arguments,
858
+					false,
859
+					false
860
+				);
861
+			},
862
+			//load_helper
863
+			'EEH_Parse_Shortcodes'                 => function () {
864
+				if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
865
+					return new EEH_Parse_Shortcodes();
866
+				}
867
+				return null;
868
+			},
869
+			'EE_Template_Config'                   => function () {
870
+				return EE_Config::instance()->template_settings;
871
+			},
872
+			'EE_Currency_Config'                   => function () {
873
+				return EE_Config::instance()->currency;
874
+			},
875
+			'EE_Registration_Config'                   => function () {
876
+				return EE_Config::instance()->registration;
877
+			},
878
+			'EE_Core_Config'                   => function () {
879
+				return EE_Config::instance()->core;
880
+			},
881
+			'EventEspresso\core\services\loaders\Loader' => function () {
882
+				return LoaderFactory::getLoader();
883
+			},
884
+			'EE_Network_Config' => function() {
885
+				return EE_Network_Config::instance();
886
+			},
887
+			'EE_Config' => function () {
888
+				return EE_Config::instance();
889
+			}
890
+		);
891
+	}
892
+
893
+
894
+
895
+	/**
896
+	 * can be used for supplying alternate names for classes,
897
+	 * or for connecting interface names to instantiable classes
898
+	 */
899
+	protected function _register_core_aliases()
900
+	{
901
+		$this->_aliases = array(
902
+			'CommandBusInterface'                                                          => 'EventEspresso\core\services\commands\CommandBusInterface',
903
+			'EventEspresso\core\services\commands\CommandBusInterface'                     => 'EventEspresso\core\services\commands\CommandBus',
904
+			'CommandHandlerManagerInterface'                                               => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
905
+			'EventEspresso\core\services\commands\CommandHandlerManagerInterface'          => 'EventEspresso\core\services\commands\CommandHandlerManager',
906
+			'CapChecker'                                                                   => 'EventEspresso\core\services\commands\middleware\CapChecker',
907
+			'AddActionHook'                                                                => 'EventEspresso\core\services\commands\middleware\AddActionHook',
908
+			'CapabilitiesChecker'                                                          => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
909
+			'CapabilitiesCheckerInterface'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface',
910
+			'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
911
+			'CreateRegistrationService'                                                    => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
912
+			'CreateRegCodeCommandHandler'                                                  => 'EventEspresso\core\services\commands\registration\CreateRegCodeCommand',
913
+			'CreateRegUrlLinkCommandHandler'                                               => 'EventEspresso\core\services\commands\registration\CreateRegUrlLinkCommand',
914
+			'CreateRegistrationCommandHandler'                                             => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
915
+			'CopyRegistrationDetailsCommandHandler'                                        => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
916
+			'CopyRegistrationPaymentsCommandHandler'                                       => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
917
+			'CancelRegistrationAndTicketLineItemCommandHandler'                            => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
918
+			'UpdateRegistrationAndTransactionAfterChangeCommandHandler'                    => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
919
+			'CreateTicketLineItemCommandHandler'                                           => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
920
+			'CreateTransactionCommandHandler'                                     => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler',
921
+			'CreateAttendeeCommandHandler'                                        => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler',
922
+			'TableManager'                                                                 => 'EventEspresso\core\services\database\TableManager',
923
+			'TableAnalysis'                                                                => 'EventEspresso\core\services\database\TableAnalysis',
924
+			'EspressoShortcode'                                                            => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
925
+			'ShortcodeInterface'                                                           => 'EventEspresso\core\services\shortcodes\ShortcodeInterface',
926
+			'EventEspresso\core\services\shortcodes\ShortcodeInterface'                    => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
927
+			'EventEspresso\core\services\cache\CacheStorageInterface'                      => 'EventEspresso\core\services\cache\TransientCacheStorage',
928
+			'LoaderInterface'                                                              => 'EventEspresso\core\services\loaders\LoaderInterface',
929
+			'EventEspresso\core\services\loaders\LoaderInterface'                          => 'EventEspresso\core\services\loaders\Loader',
930
+			'CommandFactoryInterface'                                                     => 'EventEspresso\core\services\commands\CommandFactoryInterface',
931
+			'EventEspresso\core\services\commands\CommandFactoryInterface'                => 'EventEspresso\core\services\commands\CommandFactory',
932
+			'EventEspresso\core\domain\services\session\SessionIdentifierInterface'       => 'EE_Session',
933
+			'EmailValidatorInterface'                                                     => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface',
934
+			'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService',
935
+			'NoticeConverterInterface'                                            => 'EventEspresso\core\services\notices\NoticeConverterInterface',
936
+			'EventEspresso\core\services\notices\NoticeConverterInterface'        => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors',
937
+			'NoticesContainerInterface'                                           => 'EventEspresso\core\services\notices\NoticesContainerInterface',
938
+			'EventEspresso\core\services\notices\NoticesContainerInterface'       => 'EventEspresso\core\services\notices\NoticesContainer',
939
+			'EventEspresso\core\services\request\RequestInterface'                => 'EventEspresso\core\services\request\Request',
940
+			'EventEspresso\core\services\request\ResponseInterface'               => 'EventEspresso\core\services\request\Response',
941
+			'EventEspresso\core\domain\DomainInterface'                           => 'EventEspresso\core\domain\Domain',
942
+		);
943
+		if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
944
+			$this->_aliases['EventEspresso\core\services\notices\NoticeConverterInterface'] = 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices';
945
+		}
946
+	}
947
+
948
+
949
+
950
+	/**
951
+	 * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
952
+	 * request Primarily used by unit tests.
953
+	 *
954
+	 * @throws InvalidDataTypeException
955
+	 * @throws InvalidInterfaceException
956
+	 * @throws InvalidArgumentException
957
+	 */
958
+	public function reset()
959
+	{
960
+		$this->_register_core_class_loaders();
961
+		$this->_register_core_dependencies();
962
+	}
963 963
 
964 964
 
965 965
 }
Please login to merge, or discard this patch.
modules/single_page_checkout/EED_Single_Page_Checkout.module.php 1 patch
Indentation   +1844 added lines, -1844 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 use EventEspresso\core\exceptions\InvalidEntityException;
6 6
 
7 7
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
8
-    exit('No direct script access allowed');
8
+	exit('No direct script access allowed');
9 9
 }
10 10
 
11 11
 
@@ -20,1849 +20,1849 @@  discard block
 block discarded – undo
20 20
 class EED_Single_Page_Checkout extends EED_Module
21 21
 {
22 22
 
23
-    /**
24
-     * $_initialized - has the SPCO controller already been initialized ?
25
-     *
26
-     * @access private
27
-     * @var bool $_initialized
28
-     */
29
-    private static $_initialized = false;
30
-
31
-
32
-    /**
33
-     * $_checkout_verified - is the EE_Checkout verified as correct for this request ?
34
-     *
35
-     * @access private
36
-     * @var bool $_valid_checkout
37
-     */
38
-    private static $_checkout_verified = true;
39
-
40
-    /**
41
-     *    $_reg_steps_array - holds initial array of reg steps
42
-     *
43
-     * @access private
44
-     * @var array $_reg_steps_array
45
-     */
46
-    private static $_reg_steps_array = array();
47
-
48
-    /**
49
-     *    $checkout - EE_Checkout object for handling the properties of the current checkout process
50
-     *
51
-     * @access public
52
-     * @var EE_Checkout $checkout
53
-     */
54
-    public $checkout;
55
-
56
-
57
-
58
-    /**
59
-     * @return EED_Module|EED_Single_Page_Checkout
60
-     */
61
-    public static function instance()
62
-    {
63
-        add_filter('EED_Single_Page_Checkout__SPCO_active', '__return_true');
64
-        return parent::get_instance(__CLASS__);
65
-    }
66
-
67
-
68
-
69
-    /**
70
-     * @return EE_CART
71
-     */
72
-    public function cart()
73
-    {
74
-        return $this->checkout->cart;
75
-    }
76
-
77
-
78
-
79
-    /**
80
-     * @return EE_Transaction
81
-     */
82
-    public function transaction()
83
-    {
84
-        return $this->checkout->transaction;
85
-    }
86
-
87
-
88
-
89
-    /**
90
-     *    set_hooks - for hooking into EE Core, other modules, etc
91
-     *
92
-     * @access    public
93
-     * @return    void
94
-     * @throws EE_Error
95
-     */
96
-    public static function set_hooks()
97
-    {
98
-        EED_Single_Page_Checkout::set_definitions();
99
-    }
100
-
101
-
102
-
103
-    /**
104
-     *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
105
-     *
106
-     * @access    public
107
-     * @return    void
108
-     * @throws EE_Error
109
-     */
110
-    public static function set_hooks_admin()
111
-    {
112
-        EED_Single_Page_Checkout::set_definitions();
113
-        if ( ! (defined('DOING_AJAX') && DOING_AJAX)) {
114
-            return;
115
-        }
116
-        // going to start an output buffer in case anything gets accidentally output
117
-        // that might disrupt our JSON response
118
-        ob_start();
119
-        EED_Single_Page_Checkout::load_request_handler();
120
-        EED_Single_Page_Checkout::load_reg_steps();
121
-        // set ajax hooks
122
-        add_action('wp_ajax_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step'));
123
-        add_action('wp_ajax_nopriv_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step'));
124
-        add_action('wp_ajax_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step'));
125
-        add_action('wp_ajax_nopriv_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step'));
126
-        add_action('wp_ajax_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step'));
127
-        add_action('wp_ajax_nopriv_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step'));
128
-    }
129
-
130
-
131
-
132
-    /**
133
-     *    process ajax request
134
-     *
135
-     * @param string $ajax_action
136
-     * @throws EE_Error
137
-     */
138
-    public static function process_ajax_request($ajax_action)
139
-    {
140
-        EE_Registry::instance()->REQ->set('action', $ajax_action);
141
-        EED_Single_Page_Checkout::instance()->_initialize();
142
-    }
143
-
144
-
145
-
146
-    /**
147
-     *    ajax display registration step
148
-     *
149
-     * @throws EE_Error
150
-     */
151
-    public static function display_reg_step()
152
-    {
153
-        EED_Single_Page_Checkout::process_ajax_request('display_spco_reg_step');
154
-    }
155
-
156
-
157
-
158
-    /**
159
-     *    ajax process registration step
160
-     *
161
-     * @throws EE_Error
162
-     */
163
-    public static function process_reg_step()
164
-    {
165
-        EED_Single_Page_Checkout::process_ajax_request('process_reg_step');
166
-    }
167
-
168
-
169
-
170
-    /**
171
-     *    ajax process registration step
172
-     *
173
-     * @throws EE_Error
174
-     */
175
-    public static function update_reg_step()
176
-    {
177
-        EED_Single_Page_Checkout::process_ajax_request('update_reg_step');
178
-    }
179
-
180
-
181
-
182
-    /**
183
-     *   update_checkout
184
-     *
185
-     * @access public
186
-     * @return void
187
-     * @throws EE_Error
188
-     */
189
-    public static function update_checkout()
190
-    {
191
-        EED_Single_Page_Checkout::process_ajax_request('update_checkout');
192
-    }
193
-
194
-
195
-
196
-    /**
197
-     *    load_request_handler
198
-     *
199
-     * @access    public
200
-     * @return    void
201
-     */
202
-    public static function load_request_handler()
203
-    {
204
-        // load core Request_Handler class
205
-        if (EE_Registry::instance()->REQ !== null) {
206
-            EE_Registry::instance()->load_core('Request_Handler');
207
-        }
208
-    }
209
-
210
-
211
-
212
-    /**
213
-     *    set_definitions
214
-     *
215
-     * @access    public
216
-     * @return    void
217
-     * @throws EE_Error
218
-     */
219
-    public static function set_definitions()
220
-    {
221
-        if(defined('SPCO_BASE_PATH')) {
222
-            return;
223
-        }
224
-        define(
225
-            'SPCO_BASE_PATH',
226
-            rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS) . DS
227
-        );
228
-        define('SPCO_CSS_URL', plugin_dir_url(__FILE__) . 'css' . DS);
229
-        define('SPCO_IMG_URL', plugin_dir_url(__FILE__) . 'img' . DS);
230
-        define('SPCO_JS_URL', plugin_dir_url(__FILE__) . 'js' . DS);
231
-        define('SPCO_INC_PATH', SPCO_BASE_PATH . 'inc' . DS);
232
-        define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps' . DS);
233
-        define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates' . DS);
234
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, true);
235
-        EE_Registry::$i18n_js_strings['registration_expiration_notice'] = EED_Single_Page_Checkout::getRegistrationExpirationNotice();
236
-    }
237
-
238
-
239
-
240
-    /**
241
-     * load_reg_steps
242
-     * loads and instantiates each reg step based on the EE_Registry::instance()->CFG->registration->reg_steps array
243
-     *
244
-     * @access    private
245
-     * @throws EE_Error
246
-     */
247
-    public static function load_reg_steps()
248
-    {
249
-        static $reg_steps_loaded = false;
250
-        if ($reg_steps_loaded) {
251
-            return;
252
-        }
253
-        // filter list of reg_steps
254
-        $reg_steps_to_load = (array)apply_filters(
255
-            'AHEE__SPCO__load_reg_steps__reg_steps_to_load',
256
-            EED_Single_Page_Checkout::get_reg_steps()
257
-        );
258
-        // sort by key (order)
259
-        ksort($reg_steps_to_load);
260
-        // loop through folders
261
-        foreach ($reg_steps_to_load as $order => $reg_step) {
262
-            // we need a
263
-            if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) {
264
-                // copy over to the reg_steps_array
265
-                EED_Single_Page_Checkout::$_reg_steps_array[$order] = $reg_step;
266
-                // register custom key route for each reg step
267
-                // ie: step=>"slug" - this is the entire reason we load the reg steps array now
268
-                EE_Config::register_route(
269
-                    $reg_step['slug'],
270
-                    'EED_Single_Page_Checkout',
271
-                    'run',
272
-                    'step'
273
-                );
274
-                // add AJAX or other hooks
275
-                if (isset($reg_step['has_hooks']) && $reg_step['has_hooks']) {
276
-                    // setup autoloaders if necessary
277
-                    if ( ! class_exists($reg_step['class_name'])) {
278
-                        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(
279
-                            $reg_step['file_path'],
280
-                            true
281
-                        );
282
-                    }
283
-                    if (is_callable($reg_step['class_name'], 'set_hooks')) {
284
-                        call_user_func(array($reg_step['class_name'], 'set_hooks'));
285
-                    }
286
-                }
287
-            }
288
-        }
289
-        $reg_steps_loaded = true;
290
-    }
291
-
292
-
293
-
294
-    /**
295
-     *    get_reg_steps
296
-     *
297
-     * @access    public
298
-     * @return    array
299
-     */
300
-    public static function get_reg_steps()
301
-    {
302
-        $reg_steps = EE_Registry::instance()->CFG->registration->reg_steps;
303
-        if (empty($reg_steps)) {
304
-            $reg_steps = array(
305
-                10  => array(
306
-                    'file_path'  => SPCO_REG_STEPS_PATH . 'attendee_information',
307
-                    'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information',
308
-                    'slug'       => 'attendee_information',
309
-                    'has_hooks'  => false,
310
-                ),
311
-                20  => array(
312
-                    'file_path'  => SPCO_REG_STEPS_PATH . 'registration_confirmation',
313
-                    'class_name' => 'EE_SPCO_Reg_Step_Registration_Confirmation',
314
-                    'slug'       => 'registration_confirmation',
315
-                    'has_hooks'  => false,
316
-                ),
317
-                30  => array(
318
-                    'file_path'  => SPCO_REG_STEPS_PATH . 'payment_options',
319
-                    'class_name' => 'EE_SPCO_Reg_Step_Payment_Options',
320
-                    'slug'       => 'payment_options',
321
-                    'has_hooks'  => true,
322
-                ),
323
-                999 => array(
324
-                    'file_path'  => SPCO_REG_STEPS_PATH . 'finalize_registration',
325
-                    'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration',
326
-                    'slug'       => 'finalize_registration',
327
-                    'has_hooks'  => false,
328
-                ),
329
-            );
330
-        }
331
-        return $reg_steps;
332
-    }
333
-
334
-
335
-
336
-    /**
337
-     *    registration_checkout_for_admin
338
-     *
339
-     * @access    public
340
-     * @return    string
341
-     * @throws EE_Error
342
-     */
343
-    public static function registration_checkout_for_admin()
344
-    {
345
-        EED_Single_Page_Checkout::load_request_handler();
346
-        EE_Registry::instance()->REQ->set('step', 'attendee_information');
347
-        EE_Registry::instance()->REQ->set('action', 'display_spco_reg_step');
348
-        EE_Registry::instance()->REQ->set('process_form_submission', false);
349
-        EED_Single_Page_Checkout::instance()->_initialize();
350
-        EED_Single_Page_Checkout::instance()->_display_spco_reg_form();
351
-        return EE_Registry::instance()->REQ->get_output();
352
-    }
353
-
354
-
355
-
356
-    /**
357
-     * process_registration_from_admin
358
-     *
359
-     * @access public
360
-     * @return \EE_Transaction
361
-     * @throws EE_Error
362
-     */
363
-    public static function process_registration_from_admin()
364
-    {
365
-        EED_Single_Page_Checkout::load_request_handler();
366
-        EE_Registry::instance()->REQ->set('step', 'attendee_information');
367
-        EE_Registry::instance()->REQ->set('action', 'process_reg_step');
368
-        EE_Registry::instance()->REQ->set('process_form_submission', true);
369
-        EED_Single_Page_Checkout::instance()->_initialize();
370
-        if (EED_Single_Page_Checkout::instance()->checkout->current_step->completed()) {
371
-            $final_reg_step = end(EED_Single_Page_Checkout::instance()->checkout->reg_steps);
372
-            if ($final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) {
373
-                EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated($final_reg_step);
374
-                if ($final_reg_step->process_reg_step()) {
375
-                    $final_reg_step->set_completed();
376
-                    EED_Single_Page_Checkout::instance()->checkout->update_txn_reg_steps_array();
377
-                    return EED_Single_Page_Checkout::instance()->checkout->transaction;
378
-                }
379
-            }
380
-        }
381
-        return null;
382
-    }
383
-
384
-
385
-
386
-    /**
387
-     *    run
388
-     *
389
-     * @access    public
390
-     * @param WP_Query $WP_Query
391
-     * @return    void
392
-     * @throws EE_Error
393
-     */
394
-    public function run($WP_Query)
395
-    {
396
-        if (
397
-            $WP_Query instanceof WP_Query
398
-            && $WP_Query->is_main_query()
399
-            && apply_filters('FHEE__EED_Single_Page_Checkout__run', true)
400
-            && $this->_is_reg_checkout()
401
-        ) {
402
-            $this->_initialize();
403
-        }
404
-    }
405
-
406
-
407
-
408
-    /**
409
-     * determines whether current url matches reg page url
410
-     *
411
-     * @return bool
412
-     */
413
-    protected function _is_reg_checkout()
414
-    {
415
-        // get current permalink for reg page without any extra query args
416
-        $reg_page_url = \get_permalink(EE_Config::instance()->core->reg_page_id);
417
-        // get request URI for current request, but without the scheme or host
418
-        $current_request_uri = \EEH_URL::filter_input_server_url('REQUEST_URI');
419
-        $current_request_uri = html_entity_decode($current_request_uri);
420
-        // get array of query args from the current request URI
421
-        $query_args = \EEH_URL::get_query_string($current_request_uri);
422
-        // grab page id if it is set
423
-        $page_id = isset($query_args['page_id']) ? absint($query_args['page_id']) : 0;
424
-        // and remove the page id from the query args (we will re-add it later)
425
-        unset($query_args['page_id']);
426
-        // now strip all query args from current request URI
427
-        $current_request_uri = remove_query_arg(array_keys($query_args), $current_request_uri);
428
-        // and re-add the page id if it was set
429
-        if ($page_id) {
430
-            $current_request_uri = add_query_arg('page_id', $page_id, $current_request_uri);
431
-        }
432
-        // remove slashes and ?
433
-        $current_request_uri = trim($current_request_uri, '?/');
434
-        // is current request URI part of the known full reg page URL ?
435
-        return ! empty($current_request_uri) && strpos($reg_page_url, $current_request_uri) !== false;
436
-    }
437
-
438
-
439
-
440
-    /**
441
-     * @param WP_Query $wp_query
442
-     * @return    void
443
-     * @throws EE_Error
444
-     */
445
-    public static function init($wp_query)
446
-    {
447
-        EED_Single_Page_Checkout::instance()->run($wp_query);
448
-    }
449
-
450
-
451
-
452
-    /**
453
-     *    _initialize - initial module setup
454
-     *
455
-     * @access    private
456
-     * @throws EE_Error
457
-     * @return    void
458
-     */
459
-    private function _initialize()
460
-    {
461
-        // ensure SPCO doesn't run twice
462
-        if (EED_Single_Page_Checkout::$_initialized) {
463
-            return;
464
-        }
465
-        try {
466
-            EED_Single_Page_Checkout::load_reg_steps();
467
-            $this->_verify_session();
468
-            // setup the EE_Checkout object
469
-            $this->checkout = $this->_initialize_checkout();
470
-            // filter checkout
471
-            $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout);
472
-            // get the $_GET
473
-            $this->_get_request_vars();
474
-            if ($this->_block_bots()) {
475
-                return;
476
-            }
477
-            // filter continue_reg
478
-            $this->checkout->continue_reg = apply_filters(
479
-                'FHEE__EED_Single_Page_Checkout__init___continue_reg',
480
-                true,
481
-                $this->checkout
482
-            );
483
-            // load the reg steps array
484
-            if ( ! $this->_load_and_instantiate_reg_steps()) {
485
-                EED_Single_Page_Checkout::$_initialized = true;
486
-                return;
487
-            }
488
-            // set the current step
489
-            $this->checkout->set_current_step($this->checkout->step);
490
-            // and the next step
491
-            $this->checkout->set_next_step();
492
-            // verify that everything has been setup correctly
493
-            if ( ! ($this->_verify_transaction_and_get_registrations() && $this->_final_verifications())) {
494
-                EED_Single_Page_Checkout::$_initialized = true;
495
-                return;
496
-            }
497
-            // lock the transaction
498
-            $this->checkout->transaction->lock();
499
-            // make sure all of our cached objects are added to their respective model entity mappers
500
-            $this->checkout->refresh_all_entities();
501
-            // set amount owing
502
-            $this->checkout->amount_owing = $this->checkout->transaction->remaining();
503
-            // initialize each reg step, which gives them the chance to potentially alter the process
504
-            $this->_initialize_reg_steps();
505
-            // DEBUG LOG
506
-            //$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ );
507
-            // get reg form
508
-            if( ! $this->_check_form_submission()) {
509
-                EED_Single_Page_Checkout::$_initialized = true;
510
-                return;
511
-            }
512
-            // checkout the action!!!
513
-            $this->_process_form_action();
514
-            // add some style and make it dance
515
-            $this->add_styles_and_scripts();
516
-            // kk... SPCO has successfully run
517
-            EED_Single_Page_Checkout::$_initialized = true;
518
-            // set no cache headers and constants
519
-            EE_System::do_not_cache();
520
-            // add anchor
521
-            add_action('loop_start', array($this, 'set_checkout_anchor'), 1);
522
-            // remove transaction lock
523
-            add_action('shutdown', array($this, 'unlock_transaction'), 1);
524
-        } catch (Exception $e) {
525
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
526
-        }
527
-    }
528
-
529
-
530
-
531
-    /**
532
-     *    _verify_session
533
-     * checks that the session is valid and not expired
534
-     *
535
-     * @access    private
536
-     * @throws EE_Error
537
-     */
538
-    private function _verify_session()
539
-    {
540
-        if ( ! EE_Registry::instance()->SSN instanceof EE_Session) {
541
-            throw new EE_Error(__('The EE_Session class could not be loaded.', 'event_espresso'));
542
-        }
543
-        $clear_session_requested = filter_var(
544
-            EE_Registry::instance()->REQ->get('clear_session', false),
545
-            FILTER_VALIDATE_BOOLEAN
546
-        );
547
-        // is session still valid ?
548
-        if ($clear_session_requested
549
-            || ( EE_Registry::instance()->SSN->expired()
550
-              && EE_Registry::instance()->REQ->get('e_reg_url_link', '') === ''
551
-            )
552
-        ) {
553
-            $this->checkout = new EE_Checkout();
554
-            EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
555
-            // EE_Registry::instance()->SSN->reset_cart();
556
-            // EE_Registry::instance()->SSN->reset_checkout();
557
-            // EE_Registry::instance()->SSN->reset_transaction();
558
-            if (! $clear_session_requested) {
559
-                EE_Error::add_attention(
560
-                    EE_Registry::$i18n_js_strings['registration_expiration_notice'],
561
-                    __FILE__, __FUNCTION__, __LINE__
562
-                );
563
-            }
564
-            // EE_Registry::instance()->SSN->reset_expired();
565
-        }
566
-    }
567
-
568
-
569
-
570
-    /**
571
-     *    _initialize_checkout
572
-     * loads and instantiates EE_Checkout
573
-     *
574
-     * @access    private
575
-     * @throws EE_Error
576
-     * @return EE_Checkout
577
-     */
578
-    private function _initialize_checkout()
579
-    {
580
-        // look in session for existing checkout
581
-        /** @type EE_Checkout $checkout */
582
-        $checkout = EE_Registry::instance()->SSN->checkout();
583
-        // verify
584
-        if ( ! $checkout instanceof EE_Checkout) {
585
-            // instantiate EE_Checkout object for handling the properties of the current checkout process
586
-            $checkout = EE_Registry::instance()->load_file(
587
-                SPCO_INC_PATH,
588
-                'EE_Checkout',
589
-                'class', array(),
590
-                false
591
-            );
592
-        } else {
593
-            if ($checkout->current_step->is_final_step() && $checkout->exit_spco() === true) {
594
-                $this->unlock_transaction();
595
-                wp_safe_redirect($checkout->redirect_url);
596
-                exit();
597
-            }
598
-        }
599
-        $checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout);
600
-        // verify again
601
-        if ( ! $checkout instanceof EE_Checkout) {
602
-            throw new EE_Error(__('The EE_Checkout class could not be loaded.', 'event_espresso'));
603
-        }
604
-        // reset anything that needs a clean slate for each request
605
-        $checkout->reset_for_current_request();
606
-        return $checkout;
607
-    }
608
-
609
-
610
-
611
-    /**
612
-     *    _get_request_vars
613
-     *
614
-     * @access    private
615
-     * @return    void
616
-     * @throws EE_Error
617
-     */
618
-    private function _get_request_vars()
619
-    {
620
-        // load classes
621
-        EED_Single_Page_Checkout::load_request_handler();
622
-        //make sure this request is marked as belonging to EE
623
-        EE_Registry::instance()->REQ->set_espresso_page(true);
624
-        // which step is being requested ?
625
-        $this->checkout->step = EE_Registry::instance()->REQ->get('step', $this->_get_first_step());
626
-        // which step is being edited ?
627
-        $this->checkout->edit_step = EE_Registry::instance()->REQ->get('edit_step', '');
628
-        // and what we're doing on the current step
629
-        $this->checkout->action = EE_Registry::instance()->REQ->get('action', 'display_spco_reg_step');
630
-        // timestamp
631
-        $this->checkout->uts = EE_Registry::instance()->REQ->get('uts', 0);
632
-        // returning to edit ?
633
-        $this->checkout->reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link', '');
634
-        // add reg url link to registration query params
635
-        if ($this->checkout->reg_url_link && strpos($this->checkout->reg_url_link, '1-') !== 0) {
636
-            $this->checkout->reg_cache_where_params[0]['REG_url_link'] = $this->checkout->reg_url_link;
637
-        }
638
-        // or some other kind of revisit ?
639
-        $this->checkout->revisit = filter_var(
640
-            EE_Registry::instance()->REQ->get('revisit', false),
641
-            FILTER_VALIDATE_BOOLEAN
642
-        );
643
-        // and whether or not to generate a reg form for this request
644
-        $this->checkout->generate_reg_form = filter_var(
645
-            EE_Registry::instance()->REQ->get('generate_reg_form', true),
646
-            FILTER_VALIDATE_BOOLEAN
647
-        );
648
-        // and whether or not to process a reg form submission for this request
649
-        $this->checkout->process_form_submission = filter_var(
650
-            EE_Registry::instance()->REQ->get(
651
-                'process_form_submission',
652
-                $this->checkout->action === 'process_reg_step'
653
-            ),
654
-            FILTER_VALIDATE_BOOLEAN
655
-        );
656
-        $this->checkout->process_form_submission = filter_var(
657
-            $this->checkout->action !== 'display_spco_reg_step'
658
-                ? $this->checkout->process_form_submission
659
-                : false,
660
-            FILTER_VALIDATE_BOOLEAN
661
-        );
662
-        // $this->_display_request_vars();
663
-    }
664
-
665
-
666
-
667
-    /**
668
-     *  _display_request_vars
669
-     *
670
-     * @access    protected
671
-     * @return    void
672
-     */
673
-    protected function _display_request_vars()
674
-    {
675
-        if ( ! WP_DEBUG) {
676
-            return;
677
-        }
678
-        EEH_Debug_Tools::printr($_REQUEST, '$_REQUEST', __FILE__, __LINE__);
679
-        EEH_Debug_Tools::printr($this->checkout->step, '$this->checkout->step', __FILE__, __LINE__);
680
-        EEH_Debug_Tools::printr($this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__);
681
-        EEH_Debug_Tools::printr($this->checkout->action, '$this->checkout->action', __FILE__, __LINE__);
682
-        EEH_Debug_Tools::printr($this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__);
683
-        EEH_Debug_Tools::printr($this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__);
684
-        EEH_Debug_Tools::printr($this->checkout->generate_reg_form, '$this->checkout->generate_reg_form', __FILE__, __LINE__);
685
-        EEH_Debug_Tools::printr($this->checkout->process_form_submission, '$this->checkout->process_form_submission', __FILE__, __LINE__);
686
-    }
687
-
688
-
689
-
690
-    /**
691
-     * _block_bots
692
-     * checks that the incoming request has either of the following set:
693
-     *  a uts (unix timestamp) which indicates that the request was redirected from the Ticket Selector
694
-     *  a REG URL Link, which indicates that the request is a return visit to SPCO for a valid TXN
695
-     * so if you're not coming from the Ticket Selector nor returning for a valid IP...
696
-     * then where you coming from man?
697
-     *
698
-     * @return boolean
699
-     */
700
-    private function _block_bots()
701
-    {
702
-        $invalid_checkout_access = EED_Invalid_Checkout_Access::getInvalidCheckoutAccess();
703
-        if ($invalid_checkout_access->checkoutAccessIsInvalid($this->checkout)) {
704
-            return true;
705
-        }
706
-        return false;
707
-    }
708
-
709
-
710
-
711
-    /**
712
-     *    _get_first_step
713
-     *  gets slug for first step in $_reg_steps_array
714
-     *
715
-     * @access    private
716
-     * @throws EE_Error
717
-     * @return    string
718
-     */
719
-    private function _get_first_step()
720
-    {
721
-        $first_step = reset(EED_Single_Page_Checkout::$_reg_steps_array);
722
-        return isset($first_step['slug']) ? $first_step['slug'] : 'attendee_information';
723
-    }
724
-
725
-
726
-
727
-    /**
728
-     *    _load_and_instantiate_reg_steps
729
-     *  instantiates each reg step based on the loaded reg_steps array
730
-     *
731
-     * @access    private
732
-     * @throws EE_Error
733
-     * @return    bool
734
-     */
735
-    private function _load_and_instantiate_reg_steps()
736
-    {
737
-        do_action('AHEE__Single_Page_Checkout___load_and_instantiate_reg_steps__start', $this->checkout);
738
-        // have reg_steps already been instantiated ?
739
-        if (
740
-            empty($this->checkout->reg_steps)
741
-            || apply_filters('FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout)
742
-        ) {
743
-            // if not, then loop through raw reg steps array
744
-            foreach (EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step) {
745
-                if ( ! $this->_load_and_instantiate_reg_step($reg_step, $order)) {
746
-                    return false;
747
-                }
748
-            }
749
-            EE_Registry::instance()->CFG->registration->skip_reg_confirmation = true;
750
-            EE_Registry::instance()->CFG->registration->reg_confirmation_last = true;
751
-            // skip the registration_confirmation page ?
752
-            if (EE_Registry::instance()->CFG->registration->skip_reg_confirmation) {
753
-                // just remove it from the reg steps array
754
-                $this->checkout->remove_reg_step('registration_confirmation', false);
755
-            } else if (
756
-                isset($this->checkout->reg_steps['registration_confirmation'])
757
-                && EE_Registry::instance()->CFG->registration->reg_confirmation_last
758
-            ) {
759
-                // set the order to something big like 100
760
-                $this->checkout->set_reg_step_order('registration_confirmation', 100);
761
-            }
762
-            // filter the array for good luck
763
-            $this->checkout->reg_steps = apply_filters(
764
-                'FHEE__Single_Page_Checkout__load_reg_steps__reg_steps',
765
-                $this->checkout->reg_steps
766
-            );
767
-            // finally re-sort based on the reg step class order properties
768
-            $this->checkout->sort_reg_steps();
769
-        } else {
770
-            foreach ($this->checkout->reg_steps as $reg_step) {
771
-                // set all current step stati to FALSE
772
-                $reg_step->set_is_current_step(false);
773
-            }
774
-        }
775
-        if (empty($this->checkout->reg_steps)) {
776
-            EE_Error::add_error(
777
-                __('No Reg Steps were loaded..', 'event_espresso'),
778
-                __FILE__, __FUNCTION__, __LINE__
779
-            );
780
-            return false;
781
-        }
782
-        // make reg step details available to JS
783
-        $this->checkout->set_reg_step_JSON_info();
784
-        return true;
785
-    }
786
-
787
-
788
-
789
-    /**
790
-     *     _load_and_instantiate_reg_step
791
-     *
792
-     * @access    private
793
-     * @param array $reg_step
794
-     * @param int   $order
795
-     * @return bool
796
-     */
797
-    private function _load_and_instantiate_reg_step($reg_step = array(), $order = 0)
798
-    {
799
-        // we need a file_path, class_name, and slug to add a reg step
800
-        if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) {
801
-            // if editing a specific step, but this is NOT that step... (and it's not the 'finalize_registration' step)
802
-            if (
803
-                $this->checkout->reg_url_link
804
-                && $this->checkout->step !== $reg_step['slug']
805
-                && $reg_step['slug'] !== 'finalize_registration'
806
-                // normally at this point we would NOT load the reg step, but this filter can change that
807
-                && apply_filters(
808
-                    'FHEE__Single_Page_Checkout___load_and_instantiate_reg_step__bypass_reg_step',
809
-                    true,
810
-                    $reg_step,
811
-                    $this->checkout
812
-                )
813
-            ) {
814
-                return true;
815
-            }
816
-            // instantiate step class using file path and class name
817
-            $reg_step_obj = EE_Registry::instance()->load_file(
818
-                $reg_step['file_path'],
819
-                $reg_step['class_name'],
820
-                'class',
821
-                $this->checkout,
822
-                false
823
-            );
824
-            // did we gets the goods ?
825
-            if ($reg_step_obj instanceof EE_SPCO_Reg_Step) {
826
-                // set reg step order based on config
827
-                $reg_step_obj->set_order($order);
828
-                // add instantiated reg step object to the master reg steps array
829
-                $this->checkout->add_reg_step($reg_step_obj);
830
-            } else {
831
-                EE_Error::add_error(
832
-                    __('The current step could not be set.', 'event_espresso'),
833
-                    __FILE__, __FUNCTION__, __LINE__
834
-                );
835
-                return false;
836
-            }
837
-        } else {
838
-            if (WP_DEBUG) {
839
-                EE_Error::add_error(
840
-                    sprintf(
841
-                        __(
842
-                            'A registration step could not be loaded. One or more of the following data points is invalid:%4$s%5$sFile Path: %1$s%6$s%5$sClass Name: %2$s%6$s%5$sSlug: %3$s%6$s%7$s',
843
-                            'event_espresso'
844
-                        ),
845
-                        isset($reg_step['file_path']) ? $reg_step['file_path'] : '',
846
-                        isset($reg_step['class_name']) ? $reg_step['class_name'] : '',
847
-                        isset($reg_step['slug']) ? $reg_step['slug'] : '',
848
-                        '<ul>',
849
-                        '<li>',
850
-                        '</li>',
851
-                        '</ul>'
852
-                    ),
853
-                    __FILE__, __FUNCTION__, __LINE__
854
-                );
855
-            }
856
-            return false;
857
-        }
858
-        return true;
859
-    }
860
-
861
-
862
-    /**
863
-     * _verify_transaction_and_get_registrations
864
-     *
865
-     * @access private
866
-     * @return bool
867
-     * @throws InvalidDataTypeException
868
-     * @throws InvalidEntityException
869
-     * @throws EE_Error
870
-     */
871
-    private function _verify_transaction_and_get_registrations()
872
-    {
873
-        // was there already a valid transaction in the checkout from the session ?
874
-        if ( ! $this->checkout->transaction instanceof EE_Transaction) {
875
-            // get transaction from db or session
876
-            $this->checkout->transaction = $this->checkout->reg_url_link && ! is_admin()
877
-                ? $this->_get_transaction_and_cart_for_previous_visit()
878
-                : $this->_get_cart_for_current_session_and_setup_new_transaction();
879
-            if ( ! $this->checkout->transaction instanceof EE_Transaction) {
880
-                EE_Error::add_error(
881
-                    __('Your Registration and Transaction information could not be retrieved from the db.',
882
-                        'event_espresso'),
883
-                    __FILE__, __FUNCTION__, __LINE__
884
-                );
885
-                $this->checkout->transaction = EE_Transaction::new_instance();
886
-                // add some style and make it dance
887
-                $this->add_styles_and_scripts();
888
-                EED_Single_Page_Checkout::$_initialized = true;
889
-                return false;
890
-            }
891
-            // and the registrations for the transaction
892
-            $this->_get_registrations($this->checkout->transaction);
893
-        }
894
-        return true;
895
-    }
896
-
897
-
898
-
899
-    /**
900
-     * _get_transaction_and_cart_for_previous_visit
901
-     *
902
-     * @access private
903
-     * @return mixed EE_Transaction|NULL
904
-     */
905
-    private function _get_transaction_and_cart_for_previous_visit()
906
-    {
907
-        /** @var $TXN_model EEM_Transaction */
908
-        $TXN_model = EE_Registry::instance()->load_model('Transaction');
909
-        // because the reg_url_link is present in the request,
910
-        // this is a return visit to SPCO, so we'll get the transaction data from the db
911
-        $transaction = $TXN_model->get_transaction_from_reg_url_link($this->checkout->reg_url_link);
912
-        // verify transaction
913
-        if ($transaction instanceof EE_Transaction) {
914
-            // and get the cart that was used for that transaction
915
-            $this->checkout->cart = $this->_get_cart_for_transaction($transaction);
916
-            return $transaction;
917
-        }
918
-        EE_Error::add_error(
919
-            __('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'),
920
-            __FILE__, __FUNCTION__, __LINE__
921
-        );
922
-        return null;
923
-
924
-    }
925
-
926
-
927
-
928
-    /**
929
-     * _get_cart_for_transaction
930
-     *
931
-     * @access private
932
-     * @param EE_Transaction $transaction
933
-     * @return EE_Cart
934
-     */
935
-    private function _get_cart_for_transaction($transaction)
936
-    {
937
-        return $this->checkout->get_cart_for_transaction($transaction);
938
-    }
939
-
940
-
941
-
942
-    /**
943
-     * get_cart_for_transaction
944
-     *
945
-     * @access public
946
-     * @param EE_Transaction $transaction
947
-     * @return EE_Cart
948
-     */
949
-    public function get_cart_for_transaction(EE_Transaction $transaction)
950
-    {
951
-        return $this->checkout->get_cart_for_transaction($transaction);
952
-    }
953
-
954
-
955
-
956
-    /**
957
-     * _get_transaction_and_cart_for_current_session
958
-     *    generates a new EE_Transaction object and adds it to the $_transaction property.
959
-     *
960
-     * @access private
961
-     * @return EE_Transaction
962
-     * @throws EE_Error
963
-     */
964
-    private function _get_cart_for_current_session_and_setup_new_transaction()
965
-    {
966
-        //  if there's no transaction, then this is the FIRST visit to SPCO
967
-        // so load up the cart ( passing nothing for the TXN because it doesn't exist yet )
968
-        $this->checkout->cart = $this->_get_cart_for_transaction(null);
969
-        // and then create a new transaction
970
-        $transaction = $this->_initialize_transaction();
971
-        // verify transaction
972
-        if ($transaction instanceof EE_Transaction) {
973
-            // save it so that we have an ID for other objects to use
974
-            $transaction->save();
975
-            // and save TXN data to the cart
976
-            $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($transaction->ID());
977
-        } else {
978
-            EE_Error::add_error(
979
-                __('A Valid Transaction could not be initialized.', 'event_espresso'),
980
-                __FILE__, __FUNCTION__, __LINE__
981
-            );
982
-        }
983
-        return $transaction;
984
-    }
985
-
986
-
987
-
988
-    /**
989
-     *    generates a new EE_Transaction object and adds it to the $_transaction property.
990
-     *
991
-     * @access private
992
-     * @return mixed EE_Transaction|NULL
993
-     */
994
-    private function _initialize_transaction()
995
-    {
996
-        try {
997
-            // ensure cart totals have been calculated
998
-            $this->checkout->cart->get_grand_total()->recalculate_total_including_taxes();
999
-            // grab the cart grand total
1000
-            $cart_total = $this->checkout->cart->get_cart_grand_total();
1001
-            // create new TXN
1002
-            $transaction = EE_Transaction::new_instance(
1003
-                array(
1004
-                    'TXN_reg_steps' => $this->checkout->initialize_txn_reg_steps_array(),
1005
-                    'TXN_total'     => $cart_total > 0 ? $cart_total : 0,
1006
-                    'TXN_paid'      => 0,
1007
-                    'STS_ID'        => EEM_Transaction::failed_status_code,
1008
-                )
1009
-            );
1010
-            // save it so that we have an ID for other objects to use
1011
-            $transaction->save();
1012
-            // set cron job for following up on TXNs after their session has expired
1013
-            EE_Cron_Tasks::schedule_expired_transaction_check(
1014
-                EE_Registry::instance()->SSN->expiration() + 1,
1015
-                $transaction->ID()
1016
-            );
1017
-            return $transaction;
1018
-        } catch (Exception $e) {
1019
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
1020
-        }
1021
-        return null;
1022
-    }
1023
-
1024
-
1025
-    /**
1026
-     * _get_registrations
1027
-     *
1028
-     * @access private
1029
-     * @param EE_Transaction $transaction
1030
-     * @return void
1031
-     * @throws InvalidDataTypeException
1032
-     * @throws InvalidEntityException
1033
-     * @throws EE_Error
1034
-     */
1035
-    private function _get_registrations(EE_Transaction $transaction)
1036
-    {
1037
-        // first step: grab the registrants  { : o
1038
-        $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false);
1039
-        $this->checkout->total_ticket_count = count($registrations);
1040
-        // verify registrations have been set
1041
-        if (empty($registrations)) {
1042
-            // if no cached registrations, then check the db
1043
-            $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false);
1044
-            // still nothing ? well as long as this isn't a revisit
1045
-            if (empty($registrations) && ! $this->checkout->revisit) {
1046
-                // generate new registrations from scratch
1047
-                $registrations = $this->_initialize_registrations($transaction);
1048
-            }
1049
-        }
1050
-        // sort by their original registration order
1051
-        usort($registrations, array('EED_Single_Page_Checkout', 'sort_registrations_by_REG_count'));
1052
-        // then loop thru the array
1053
-        foreach ($registrations as $registration) {
1054
-            // verify each registration
1055
-            if ($registration instanceof EE_Registration) {
1056
-                // we display all attendee info for the primary registrant
1057
-                if ($this->checkout->reg_url_link === $registration->reg_url_link()
1058
-                    && $registration->is_primary_registrant()
1059
-                ) {
1060
-                    $this->checkout->primary_revisit = true;
1061
-                    break;
1062
-                }
1063
-                if ($this->checkout->revisit && $this->checkout->reg_url_link !== $registration->reg_url_link()) {
1064
-                    // but hide info if it doesn't belong to you
1065
-                    $transaction->clear_cache('Registration', $registration->ID());
1066
-                    $this->checkout->total_ticket_count--;
1067
-                }
1068
-                $this->checkout->set_reg_status_updated($registration->ID(), false);
1069
-            }
1070
-        }
1071
-    }
1072
-
1073
-
1074
-    /**
1075
-     *    adds related EE_Registration objects for each ticket in the cart to the current EE_Transaction object
1076
-     *
1077
-     * @access private
1078
-     * @param EE_Transaction $transaction
1079
-     * @return    array
1080
-     * @throws InvalidDataTypeException
1081
-     * @throws InvalidEntityException
1082
-     * @throws EE_Error
1083
-     */
1084
-    private function _initialize_registrations(EE_Transaction $transaction)
1085
-    {
1086
-        $att_nmbr = 0;
1087
-        $registrations = array();
1088
-        if ($transaction instanceof EE_Transaction) {
1089
-            /** @type EE_Registration_Processor $registration_processor */
1090
-            $registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
1091
-            $this->checkout->total_ticket_count = $this->checkout->cart->all_ticket_quantity_count();
1092
-            // now let's add the cart items to the $transaction
1093
-            foreach ($this->checkout->cart->get_tickets() as $line_item) {
1094
-                //do the following for each ticket of this type they selected
1095
-                for ($x = 1; $x <= $line_item->quantity(); $x++) {
1096
-                    $att_nmbr++;
1097
-                    /** @var EventEspresso\core\services\commands\registration\CreateRegistrationCommand $CreateRegistrationCommand */
1098
-                    $CreateRegistrationCommand = EE_Registry::instance()->create(
1099
-                        'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
1100
-                        array(
1101
-                            $transaction,
1102
-                            $line_item,
1103
-                            $att_nmbr,
1104
-                            $this->checkout->total_ticket_count,
1105
-                        )
1106
-                    );
1107
-                    // override capabilities for frontend registrations
1108
-                    if ( ! is_admin()) {
1109
-                        $CreateRegistrationCommand->setCapCheck(
1110
-                            new PublicCapabilities('', 'create_new_registration')
1111
-                        );
1112
-                    }
1113
-                    $registration = EE_Registry::instance()->BUS->execute($CreateRegistrationCommand);
1114
-                    if ( ! $registration instanceof EE_Registration) {
1115
-                        throw new InvalidEntityException($registration, 'EE_Registration');
1116
-                    }
1117
-                    $registrations[ $registration->ID() ] = $registration;
1118
-                }
1119
-            }
1120
-            $registration_processor->fix_reg_final_price_rounding_issue($transaction);
1121
-        }
1122
-        return $registrations;
1123
-    }
1124
-
1125
-
1126
-
1127
-    /**
1128
-     * sorts registrations by REG_count
1129
-     *
1130
-     * @access public
1131
-     * @param EE_Registration $reg_A
1132
-     * @param EE_Registration $reg_B
1133
-     * @return int
1134
-     */
1135
-    public static function sort_registrations_by_REG_count(EE_Registration $reg_A, EE_Registration $reg_B)
1136
-    {
1137
-        // this shouldn't ever happen within the same TXN, but oh well
1138
-        if ($reg_A->count() === $reg_B->count()) {
1139
-            return 0;
1140
-        }
1141
-        return ($reg_A->count() > $reg_B->count()) ? 1 : -1;
1142
-    }
1143
-
1144
-
1145
-
1146
-    /**
1147
-     *    _final_verifications
1148
-     * just makes sure that everything is set up correctly before proceeding
1149
-     *
1150
-     * @access    private
1151
-     * @return    bool
1152
-     * @throws EE_Error
1153
-     */
1154
-    private function _final_verifications()
1155
-    {
1156
-        // filter checkout
1157
-        $this->checkout = apply_filters(
1158
-            'FHEE__EED_Single_Page_Checkout___final_verifications__checkout',
1159
-            $this->checkout
1160
-        );
1161
-        //verify that current step is still set correctly
1162
-        if ( ! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) {
1163
-            EE_Error::add_error(
1164
-                __('We\'re sorry but the registration process can not proceed because one or more registration steps were not setup correctly. Please refresh the page and try again or contact support.', 'event_espresso'),
1165
-                __FILE__,
1166
-                __FUNCTION__,
1167
-                __LINE__
1168
-            );
1169
-            return false;
1170
-        }
1171
-        // if returning to SPCO, then verify that primary registrant is set
1172
-        if ( ! empty($this->checkout->reg_url_link)) {
1173
-            $valid_registrant = $this->checkout->transaction->primary_registration();
1174
-            if ( ! $valid_registrant instanceof EE_Registration) {
1175
-                EE_Error::add_error(
1176
-                    __('We\'re sorry but there appears to be an error with the "reg_url_link" or the primary registrant for this transaction. Please refresh the page and try again or contact support.', 'event_espresso'),
1177
-                    __FILE__,
1178
-                    __FUNCTION__,
1179
-                    __LINE__
1180
-                );
1181
-                return false;
1182
-            }
1183
-            $valid_registrant = null;
1184
-            foreach (
1185
-                $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) as $registration
1186
-            ) {
1187
-                if (
1188
-                    $registration instanceof EE_Registration
1189
-                    && $registration->reg_url_link() === $this->checkout->reg_url_link
1190
-                ) {
1191
-                    $valid_registrant = $registration;
1192
-                }
1193
-            }
1194
-            if ( ! $valid_registrant instanceof EE_Registration) {
1195
-                // hmmm... maybe we have the wrong session because the user is opening multiple tabs ?
1196
-                if (EED_Single_Page_Checkout::$_checkout_verified) {
1197
-                    // clear the session, mark the checkout as unverified, and try again
1198
-                    EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
1199
-                    EED_Single_Page_Checkout::$_initialized = false;
1200
-                    EED_Single_Page_Checkout::$_checkout_verified = false;
1201
-                    $this->_initialize();
1202
-                    EE_Error::reset_notices();
1203
-                    return false;
1204
-                }
1205
-                EE_Error::add_error(
1206
-                    __(
1207
-                        'We\'re sorry but there appears to be an error with the "reg_url_link" or the transaction itself. Please refresh the page and try again or contact support.',
1208
-                        'event_espresso'
1209
-                    ),
1210
-                    __FILE__,
1211
-                    __FUNCTION__,
1212
-                    __LINE__
1213
-                );
1214
-                return false;
1215
-            }
1216
-        }
1217
-        // now that things have been kinda sufficiently verified,
1218
-        // let's add the checkout to the session so that it's available to other systems
1219
-        EE_Registry::instance()->SSN->set_checkout($this->checkout);
1220
-        return true;
1221
-    }
1222
-
1223
-
1224
-
1225
-    /**
1226
-     *    _initialize_reg_steps
1227
-     * first makes sure that EE_Transaction_Processor::set_reg_step_initiated() is called as required
1228
-     * then loops thru all of the active reg steps and calls the initialize_reg_step() method
1229
-     *
1230
-     * @access    private
1231
-     * @param bool $reinitializing
1232
-     * @throws EE_Error
1233
-     */
1234
-    private function _initialize_reg_steps($reinitializing = false)
1235
-    {
1236
-        $this->checkout->set_reg_step_initiated($this->checkout->current_step);
1237
-        // loop thru all steps to call their individual "initialize" methods and set i18n strings for JS
1238
-        foreach ($this->checkout->reg_steps as $reg_step) {
1239
-            if ( ! $reg_step->initialize_reg_step()) {
1240
-                // if not initialized then maybe this step is being removed...
1241
-                if ( ! $reinitializing && $reg_step->is_current_step()) {
1242
-                    // if it was the current step, then we need to start over here
1243
-                    $this->_initialize_reg_steps(true);
1244
-                    return;
1245
-                }
1246
-                continue;
1247
-            }
1248
-            // add css and JS for current step
1249
-            $reg_step->enqueue_styles_and_scripts();
1250
-            // i18n
1251
-            $reg_step->translate_js_strings();
1252
-            if ($reg_step->is_current_step()) {
1253
-                // the text that appears on the reg step form submit button
1254
-                $reg_step->set_submit_button_text();
1255
-            }
1256
-        }
1257
-        // dynamically creates hook point like: AHEE__Single_Page_Checkout___initialize_reg_step__attendee_information
1258
-        do_action(
1259
-            "AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}",
1260
-            $this->checkout->current_step
1261
-        );
1262
-    }
1263
-
1264
-
1265
-
1266
-    /**
1267
-     * _check_form_submission
1268
-     *
1269
-     * @access private
1270
-     * @return boolean
1271
-     */
1272
-    private function _check_form_submission()
1273
-    {
1274
-        //does this request require the reg form to be generated ?
1275
-        if ($this->checkout->generate_reg_form) {
1276
-            // ever heard that song by Blue Rodeo ?
1277
-            try {
1278
-                $this->checkout->current_step->reg_form = $this->checkout->current_step->generate_reg_form();
1279
-                // if not displaying a form, then check for form submission
1280
-                if (
1281
-                    $this->checkout->process_form_submission
1282
-                    && $this->checkout->current_step->reg_form->was_submitted()
1283
-                ) {
1284
-                    // clear out any old data in case this step is being run again
1285
-                    $this->checkout->current_step->set_valid_data(array());
1286
-                    // capture submitted form data
1287
-                    $this->checkout->current_step->reg_form->receive_form_submission(
1288
-                        apply_filters(
1289
-                            'FHEE__Single_Page_Checkout___check_form_submission__request_params',
1290
-                            EE_Registry::instance()->REQ->params(),
1291
-                            $this->checkout
1292
-                        )
1293
-                    );
1294
-                    // validate submitted form data
1295
-                    if ( ! $this->checkout->continue_reg || ! $this->checkout->current_step->reg_form->is_valid()) {
1296
-                        // thou shall not pass !!!
1297
-                        $this->checkout->continue_reg = false;
1298
-                        // any form validation errors?
1299
-                        if ($this->checkout->current_step->reg_form->submission_error_message() !== '') {
1300
-                            EE_Error::add_error(
1301
-                                $this->checkout->current_step->reg_form->submission_error_message(),
1302
-                                __FILE__, __FUNCTION__, __LINE__
1303
-                            );
1304
-                        }
1305
-                        // well not really... what will happen is
1306
-                        // we'll just get redirected back to redo the current step
1307
-                        $this->go_to_next_step();
1308
-                        return false;
1309
-                    }
1310
-                }
1311
-            } catch (EE_Error $e) {
1312
-                $e->get_error();
1313
-            }
1314
-        }
1315
-        return true;
1316
-    }
1317
-
1318
-
1319
-
1320
-    /**
1321
-     * _process_action
1322
-     *
1323
-     * @access private
1324
-     * @return void
1325
-     * @throws EE_Error
1326
-     */
1327
-    private function _process_form_action()
1328
-    {
1329
-        // what cha wanna do?
1330
-        switch ($this->checkout->action) {
1331
-            // AJAX next step reg form
1332
-            case 'display_spco_reg_step' :
1333
-                $this->checkout->redirect = false;
1334
-                if (EE_Registry::instance()->REQ->ajax) {
1335
-                    $this->checkout->json_response->set_reg_step_html(
1336
-                        $this->checkout->current_step->display_reg_form()
1337
-                    );
1338
-                }
1339
-                break;
1340
-            default :
1341
-                // meh... do one of those other steps first
1342
-                if (
1343
-                    ! empty($this->checkout->action)
1344
-                    && is_callable(array($this->checkout->current_step, $this->checkout->action))
1345
-                ) {
1346
-                    // dynamically creates hook point like:
1347
-                    //   AHEE__Single_Page_Checkout__before_attendee_information__process_reg_step
1348
-                    do_action(
1349
-                        "AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}",
1350
-                        $this->checkout->current_step
1351
-                    );
1352
-                    // call action on current step
1353
-                    if (call_user_func(array($this->checkout->current_step, $this->checkout->action))) {
1354
-                        // good registrant, you get to proceed
1355
-                        if (
1356
-                            $this->checkout->current_step->success_message() !== ''
1357
-                            && apply_filters(
1358
-                                'FHEE__Single_Page_Checkout___process_form_action__display_success',
1359
-                                false
1360
-                            )
1361
-                        ) {
1362
-                            EE_Error::add_success(
1363
-                                $this->checkout->current_step->success_message()
1364
-                                . '<br />' . $this->checkout->next_step->_instructions()
1365
-                            );
1366
-                        }
1367
-                        // pack it up, pack it in...
1368
-                        $this->_setup_redirect();
1369
-                    }
1370
-                    // dynamically creates hook point like:
1371
-                    //  AHEE__Single_Page_Checkout__after_payment_options__process_reg_step
1372
-                    do_action(
1373
-                        "AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}",
1374
-                        $this->checkout->current_step
1375
-                    );
1376
-                } else {
1377
-                    EE_Error::add_error(
1378
-                        sprintf(
1379
-                            __(
1380
-                                'The requested form action "%s" does not exist for the current "%s" registration step.',
1381
-                                'event_espresso'
1382
-                            ),
1383
-                            $this->checkout->action,
1384
-                            $this->checkout->current_step->name()
1385
-                        ),
1386
-                        __FILE__,
1387
-                        __FUNCTION__,
1388
-                        __LINE__
1389
-                    );
1390
-                }
1391
-            // end default
1392
-        }
1393
-        // store our progress so far
1394
-        $this->checkout->stash_transaction_and_checkout();
1395
-        // advance to the next step! If you pass GO, collect $200
1396
-        $this->go_to_next_step();
1397
-    }
1398
-
1399
-
1400
-
1401
-    /**
1402
-     *        add_styles_and_scripts
1403
-     *
1404
-     * @access        public
1405
-     * @return        void
1406
-     */
1407
-    public function add_styles_and_scripts()
1408
-    {
1409
-        // i18n
1410
-        $this->translate_js_strings();
1411
-        if ($this->checkout->admin_request) {
1412
-            add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10);
1413
-        } else {
1414
-            add_action('wp_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10);
1415
-        }
1416
-    }
1417
-
1418
-
1419
-
1420
-    /**
1421
-     *        translate_js_strings
1422
-     *
1423
-     * @access        public
1424
-     * @return        void
1425
-     */
1426
-    public function translate_js_strings()
1427
-    {
1428
-        EE_Registry::$i18n_js_strings['revisit'] = $this->checkout->revisit;
1429
-        EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->checkout->reg_url_link;
1430
-        EE_Registry::$i18n_js_strings['server_error'] = __(
1431
-            'An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again or contact support.',
1432
-            'event_espresso'
1433
-        );
1434
-        EE_Registry::$i18n_js_strings['invalid_json_response'] = __(
1435
-            'An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.',
1436
-            'event_espresso'
1437
-        );
1438
-        EE_Registry::$i18n_js_strings['validation_error'] = __(
1439
-            'There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.',
1440
-            'event_espresso'
1441
-        );
1442
-        EE_Registry::$i18n_js_strings['invalid_payment_method'] = __(
1443
-            'There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.',
1444
-            'event_espresso'
1445
-        );
1446
-        EE_Registry::$i18n_js_strings['reg_step_error'] = __(
1447
-            'This registration step could not be completed. Please refresh the page and try again.',
1448
-            'event_espresso'
1449
-        );
1450
-        EE_Registry::$i18n_js_strings['invalid_coupon'] = __(
1451
-            'We\'re sorry but that coupon code does not appear to be valid. If this is incorrect, please contact the site administrator.',
1452
-            'event_espresso'
1453
-        );
1454
-        EE_Registry::$i18n_js_strings['process_registration'] = sprintf(
1455
-            __(
1456
-                'Please wait while we process your registration.%sDo not refresh the page or navigate away while this is happening.%sThank you for your patience.',
1457
-                'event_espresso'
1458
-            ),
1459
-            '<br/>',
1460
-            '<br/>'
1461
-        );
1462
-        EE_Registry::$i18n_js_strings['language'] = get_bloginfo('language');
1463
-        EE_Registry::$i18n_js_strings['EESID'] = EE_Registry::instance()->SSN->id();
1464
-        EE_Registry::$i18n_js_strings['currency'] = EE_Registry::instance()->CFG->currency;
1465
-        EE_Registry::$i18n_js_strings['datepicker_yearRange'] = '-150:+20';
1466
-        EE_Registry::$i18n_js_strings['timer_years'] = __('years', 'event_espresso');
1467
-        EE_Registry::$i18n_js_strings['timer_months'] = __('months', 'event_espresso');
1468
-        EE_Registry::$i18n_js_strings['timer_weeks'] = __('weeks', 'event_espresso');
1469
-        EE_Registry::$i18n_js_strings['timer_days'] = __('days', 'event_espresso');
1470
-        EE_Registry::$i18n_js_strings['timer_hours'] = __('hours', 'event_espresso');
1471
-        EE_Registry::$i18n_js_strings['timer_minutes'] = __('minutes', 'event_espresso');
1472
-        EE_Registry::$i18n_js_strings['timer_seconds'] = __('seconds', 'event_espresso');
1473
-        EE_Registry::$i18n_js_strings['timer_year'] = __('year', 'event_espresso');
1474
-        EE_Registry::$i18n_js_strings['timer_month'] = __('month', 'event_espresso');
1475
-        EE_Registry::$i18n_js_strings['timer_week'] = __('week', 'event_espresso');
1476
-        EE_Registry::$i18n_js_strings['timer_day'] = __('day', 'event_espresso');
1477
-        EE_Registry::$i18n_js_strings['timer_hour'] = __('hour', 'event_espresso');
1478
-        EE_Registry::$i18n_js_strings['timer_minute'] = __('minute', 'event_espresso');
1479
-        EE_Registry::$i18n_js_strings['timer_second'] = __('second', 'event_espresso');
1480
-        EE_Registry::$i18n_js_strings['registration_expiration_notice'] = EED_Single_Page_Checkout::getRegistrationExpirationNotice();
1481
-        EE_Registry::$i18n_js_strings['ajax_submit'] = apply_filters(
1482
-            'FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit',
1483
-            true
1484
-        );
1485
-        EE_Registry::$i18n_js_strings['session_extension'] = absint(
1486
-            apply_filters('FHEE__EE_Session__extend_expiration__seconds_added', 10 * MINUTE_IN_SECONDS)
1487
-        );
1488
-        EE_Registry::$i18n_js_strings['session_expiration'] = gmdate(
1489
-            'M d, Y H:i:s',
1490
-            EE_Registry::instance()->SSN->expiration() + (get_option('gmt_offset') * HOUR_IN_SECONDS)
1491
-        );
1492
-    }
1493
-
1494
-
1495
-
1496
-    /**
1497
-     *    enqueue_styles_and_scripts
1498
-     *
1499
-     * @access        public
1500
-     * @return        void
1501
-     * @throws EE_Error
1502
-     */
1503
-    public function enqueue_styles_and_scripts()
1504
-    {
1505
-        // load css
1506
-        wp_register_style(
1507
-            'single_page_checkout',
1508
-            SPCO_CSS_URL . 'single_page_checkout.css',
1509
-            array('espresso_default'),
1510
-            EVENT_ESPRESSO_VERSION
1511
-        );
1512
-        wp_enqueue_style('single_page_checkout');
1513
-        // load JS
1514
-        wp_register_script(
1515
-            'jquery_plugin',
1516
-            EE_THIRD_PARTY_URL . 'jquery	.plugin.min.js',
1517
-            array('jquery'),
1518
-            '1.0.1',
1519
-            true
1520
-        );
1521
-        wp_register_script(
1522
-            'jquery_countdown',
1523
-            EE_THIRD_PARTY_URL . 'jquery	.countdown.min.js',
1524
-            array('jquery_plugin'),
1525
-            '2.0.2',
1526
-            true
1527
-        );
1528
-        wp_register_script(
1529
-            'single_page_checkout',
1530
-            SPCO_JS_URL . 'single_page_checkout.js',
1531
-            array('espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown'),
1532
-            EVENT_ESPRESSO_VERSION,
1533
-            true
1534
-        );
1535
-        if ($this->checkout->registration_form instanceof EE_Form_Section_Proper) {
1536
-            $this->checkout->registration_form->enqueue_js();
1537
-        }
1538
-        if ($this->checkout->current_step->reg_form instanceof EE_Form_Section_Proper) {
1539
-            $this->checkout->current_step->reg_form->enqueue_js();
1540
-        }
1541
-        wp_enqueue_script('single_page_checkout');
1542
-        /**
1543
-         * global action hook for enqueueing styles and scripts with
1544
-         * spco calls.
1545
-         */
1546
-        do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this);
1547
-        /**
1548
-         * dynamic action hook for enqueueing styles and scripts with spco calls.
1549
-         * The hook will end up being something like:
1550
-         *      AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information
1551
-         */
1552
-        do_action(
1553
-            'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(),
1554
-            $this
1555
-        );
1556
-    }
1557
-
1558
-
1559
-
1560
-    /**
1561
-     *    display the Registration Single Page Checkout Form
1562
-     *
1563
-     * @access    private
1564
-     * @return    void
1565
-     * @throws EE_Error
1566
-     */
1567
-    private function _display_spco_reg_form()
1568
-    {
1569
-        // if registering via the admin, just display the reg form for the current step
1570
-        if ($this->checkout->admin_request) {
1571
-            EE_Registry::instance()->REQ->add_output($this->checkout->current_step->display_reg_form());
1572
-        } else {
1573
-            // add powered by EE msg
1574
-            add_action('AHEE__SPCO__reg_form_footer', array('EED_Single_Page_Checkout', 'display_registration_footer'));
1575
-            $empty_cart = count(
1576
-                $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params)
1577
-            ) < 1;
1578
-            EE_Registry::$i18n_js_strings['empty_cart'] = $empty_cart;
1579
-            $cookies_not_set_msg = '';
1580
-            if ($empty_cart) {
1581
-                $cookies_not_set_msg = apply_filters(
1582
-                    'FHEE__Single_Page_Checkout__display_spco_reg_form__cookies_not_set_msg',
1583
-                    sprintf(
1584
-                        __(
1585
-                            '%1$s%3$sIt appears your browser is not currently set to accept Cookies%4$s%5$sIn order to register for events, you need to enable cookies.%7$sIf you require assistance, then click the following link to learn how to %8$senable cookies%9$s%6$s%2$s',
1586
-                            'event_espresso'
1587
-                        ),
1588
-                        '<div class="ee-attention hidden" id="ee-cookies-not-set-msg">',
1589
-                        '</div>',
1590
-                        '<h6 class="important-notice">',
1591
-                        '</h6>',
1592
-                        '<p>',
1593
-                        '</p>',
1594
-                        '<br />',
1595
-                        '<a href="http://www.whatarecookies.com/enable.asp" target="_blank">',
1596
-                        '</a>'
1597
-                    )
1598
-                );
1599
-            }
1600
-            $this->checkout->registration_form = new EE_Form_Section_Proper(
1601
-                array(
1602
-                    'name'            => 'single-page-checkout',
1603
-                    'html_id'         => 'ee-single-page-checkout-dv',
1604
-                    'layout_strategy' =>
1605
-                        new EE_Template_Layout(
1606
-                            array(
1607
-                                'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php',
1608
-                                'template_args'        => array(
1609
-                                    'empty_cart'              => $empty_cart,
1610
-                                    'revisit'                 => $this->checkout->revisit,
1611
-                                    'reg_steps'               => $this->checkout->reg_steps,
1612
-                                    'next_step'               => $this->checkout->next_step instanceof EE_SPCO_Reg_Step
1613
-                                        ? $this->checkout->next_step->slug()
1614
-                                        : '',
1615
-                                    'empty_msg'               => apply_filters(
1616
-                                        'FHEE__Single_Page_Checkout__display_spco_reg_form__empty_msg',
1617
-                                        sprintf(
1618
-                                            __(
1619
-                                                'You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.',
1620
-                                                'event_espresso'
1621
-                                            ),
1622
-                                            '<a href="'
1623
-                                            . get_post_type_archive_link('espresso_events')
1624
-                                            . '" title="',
1625
-                                            '">',
1626
-                                            '</a>'
1627
-                                        )
1628
-                                    ),
1629
-                                    'cookies_not_set_msg'     => $cookies_not_set_msg,
1630
-                                    'registration_time_limit' => $this->checkout->get_registration_time_limit(),
1631
-                                    'session_expiration'      => gmdate(
1632
-                                        'M d, Y H:i:s',
1633
-                                        EE_Registry::instance()->SSN->expiration()
1634
-                                        + (get_option('gmt_offset') * HOUR_IN_SECONDS)
1635
-                                    ),
1636
-                                ),
1637
-                            )
1638
-                        ),
1639
-                )
1640
-            );
1641
-            // load template and add to output sent that gets filtered into the_content()
1642
-            EE_Registry::instance()->REQ->add_output($this->checkout->registration_form->get_html());
1643
-        }
1644
-    }
1645
-
1646
-
1647
-
1648
-    /**
1649
-     *    add_extra_finalize_registration_inputs
1650
-     *
1651
-     * @access    public
1652
-     * @param $next_step
1653
-     * @internal  param string $label
1654
-     * @return void
1655
-     */
1656
-    public function add_extra_finalize_registration_inputs($next_step)
1657
-    {
1658
-        if ($next_step === 'finalize_registration') {
1659
-            echo '<div id="spco-extra-finalize_registration-inputs-dv"></div>';
1660
-        }
1661
-    }
1662
-
1663
-
1664
-
1665
-    /**
1666
-     *    display_registration_footer
1667
-     *
1668
-     * @access    public
1669
-     * @return    string
1670
-     */
1671
-    public static function display_registration_footer()
1672
-    {
1673
-        if (
1674
-        apply_filters(
1675
-            'FHEE__EE_Front__Controller__show_reg_footer',
1676
-            EE_Registry::instance()->CFG->admin->show_reg_footer
1677
-        )
1678
-        ) {
1679
-            add_filter(
1680
-                'FHEE__EEH_Template__powered_by_event_espresso__url',
1681
-                function ($url) {
1682
-                    return apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url);
1683
-                }
1684
-            );
1685
-            echo apply_filters(
1686
-                'FHEE__EE_Front_Controller__display_registration_footer',
1687
-                \EEH_Template::powered_by_event_espresso(
1688
-                    '',
1689
-                    'espresso-registration-footer-dv',
1690
-                    array('utm_content' => 'registration_checkout')
1691
-                )
1692
-            );
1693
-        }
1694
-        return '';
1695
-    }
1696
-
1697
-
1698
-
1699
-    /**
1700
-     *    unlock_transaction
1701
-     *
1702
-     * @access    public
1703
-     * @return    void
1704
-     * @throws EE_Error
1705
-     */
1706
-    public function unlock_transaction()
1707
-    {
1708
-        if ($this->checkout->transaction instanceof EE_Transaction) {
1709
-            $this->checkout->transaction->unlock();
1710
-        }
1711
-    }
1712
-
1713
-
1714
-
1715
-    /**
1716
-     *        _setup_redirect
1717
-     *
1718
-     * @access    private
1719
-     * @return void
1720
-     */
1721
-    private function _setup_redirect()
1722
-    {
1723
-        if ($this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step) {
1724
-            $this->checkout->redirect = true;
1725
-            if (empty($this->checkout->redirect_url)) {
1726
-                $this->checkout->redirect_url = $this->checkout->next_step->reg_step_url();
1727
-            }
1728
-            $this->checkout->redirect_url = apply_filters(
1729
-                'FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url',
1730
-                $this->checkout->redirect_url,
1731
-                $this->checkout
1732
-            );
1733
-        }
1734
-    }
1735
-
1736
-
1737
-
1738
-    /**
1739
-     *   handle ajax message responses and redirects
1740
-     *
1741
-     * @access public
1742
-     * @return void
1743
-     * @throws EE_Error
1744
-     */
1745
-    public function go_to_next_step()
1746
-    {
1747
-        if (EE_Registry::instance()->REQ->ajax) {
1748
-            // capture contents of output buffer we started earlier in the request, and insert into JSON response
1749
-            $this->checkout->json_response->set_unexpected_errors(ob_get_clean());
1750
-        }
1751
-        $this->unlock_transaction();
1752
-        // just return for these conditions
1753
-        if (
1754
-            $this->checkout->admin_request
1755
-            || $this->checkout->action === 'redirect_form'
1756
-            || $this->checkout->action === 'update_checkout'
1757
-        ) {
1758
-            return;
1759
-        }
1760
-        // AJAX response
1761
-        $this->_handle_json_response();
1762
-        // redirect to next step or the Thank You page
1763
-        $this->_handle_html_redirects();
1764
-        // hmmm... must be something wrong, so let's just display the form again !
1765
-        $this->_display_spco_reg_form();
1766
-    }
1767
-
1768
-
1769
-
1770
-    /**
1771
-     *   _handle_json_response
1772
-     *
1773
-     * @access protected
1774
-     * @return void
1775
-     */
1776
-    protected function _handle_json_response()
1777
-    {
1778
-        // if this is an ajax request
1779
-        if (EE_Registry::instance()->REQ->ajax) {
1780
-            // DEBUG LOG
1781
-            //$this->checkout->log(
1782
-            //	__CLASS__, __FUNCTION__, __LINE__,
1783
-            //	array(
1784
-            //		'json_response_redirect_url' => $this->checkout->json_response->redirect_url(),
1785
-            //		'redirect'                   => $this->checkout->redirect,
1786
-            //		'continue_reg'               => $this->checkout->continue_reg,
1787
-            //	)
1788
-            //);
1789
-            $this->checkout->json_response->set_registration_time_limit(
1790
-                $this->checkout->get_registration_time_limit()
1791
-            );
1792
-            $this->checkout->json_response->set_payment_amount($this->checkout->amount_owing);
1793
-            // just send the ajax (
1794
-            $json_response = apply_filters(
1795
-                'FHEE__EE_Single_Page_Checkout__JSON_response',
1796
-                $this->checkout->json_response
1797
-            );
1798
-            echo $json_response;
1799
-            exit();
1800
-        }
1801
-    }
1802
-
1803
-
1804
-
1805
-    /**
1806
-     *   _handle_redirects
1807
-     *
1808
-     * @access protected
1809
-     * @return void
1810
-     */
1811
-    protected function _handle_html_redirects()
1812
-    {
1813
-        // going somewhere ?
1814
-        if ($this->checkout->redirect && ! empty($this->checkout->redirect_url)) {
1815
-            // store notices in a transient
1816
-            EE_Error::get_notices(false, true, true);
1817
-            // DEBUG LOG
1818
-            //$this->checkout->log(
1819
-            //	__CLASS__, __FUNCTION__, __LINE__,
1820
-            //	array(
1821
-            //		'headers_sent' => headers_sent(),
1822
-            //		'redirect_url'     => $this->checkout->redirect_url,
1823
-            //		'headers_list'    => headers_list(),
1824
-            //	)
1825
-            //);
1826
-            wp_safe_redirect($this->checkout->redirect_url);
1827
-            exit();
1828
-        }
1829
-    }
1830
-
1831
-
1832
-
1833
-    /**
1834
-     *   set_checkout_anchor
1835
-     *
1836
-     * @access public
1837
-     * @return void
1838
-     */
1839
-    public function set_checkout_anchor()
1840
-    {
1841
-        echo '<a id="checkout" style="float: left; margin-left: -999em;"></a>';
1842
-    }
1843
-
1844
-    /**
1845
-     *    getRegistrationExpirationNotice
1846
-     *
1847
-     * @since 4.9.59.p
1848
-     * @access    public
1849
-     * @return    string
1850
-     */
1851
-    public static function getRegistrationExpirationNotice()
1852
-    {
1853
-        return sprintf(
1854
-            __('%1$sWe\'re sorry, but your registration time has expired.%2$s%3$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please accept our apologies for any inconvenience this may have caused.%8$s',
1855
-                'event_espresso'),
1856
-            '<h4 class="important-notice">',
1857
-            '</h4>',
1858
-            '<br />',
1859
-            '<p>',
1860
-            '<a href="' . get_post_type_archive_link('espresso_events') . '" title="',
1861
-            '">',
1862
-            '</a>',
1863
-            '</p>'
1864
-        );
1865
-    }
23
+	/**
24
+	 * $_initialized - has the SPCO controller already been initialized ?
25
+	 *
26
+	 * @access private
27
+	 * @var bool $_initialized
28
+	 */
29
+	private static $_initialized = false;
30
+
31
+
32
+	/**
33
+	 * $_checkout_verified - is the EE_Checkout verified as correct for this request ?
34
+	 *
35
+	 * @access private
36
+	 * @var bool $_valid_checkout
37
+	 */
38
+	private static $_checkout_verified = true;
39
+
40
+	/**
41
+	 *    $_reg_steps_array - holds initial array of reg steps
42
+	 *
43
+	 * @access private
44
+	 * @var array $_reg_steps_array
45
+	 */
46
+	private static $_reg_steps_array = array();
47
+
48
+	/**
49
+	 *    $checkout - EE_Checkout object for handling the properties of the current checkout process
50
+	 *
51
+	 * @access public
52
+	 * @var EE_Checkout $checkout
53
+	 */
54
+	public $checkout;
55
+
56
+
57
+
58
+	/**
59
+	 * @return EED_Module|EED_Single_Page_Checkout
60
+	 */
61
+	public static function instance()
62
+	{
63
+		add_filter('EED_Single_Page_Checkout__SPCO_active', '__return_true');
64
+		return parent::get_instance(__CLASS__);
65
+	}
66
+
67
+
68
+
69
+	/**
70
+	 * @return EE_CART
71
+	 */
72
+	public function cart()
73
+	{
74
+		return $this->checkout->cart;
75
+	}
76
+
77
+
78
+
79
+	/**
80
+	 * @return EE_Transaction
81
+	 */
82
+	public function transaction()
83
+	{
84
+		return $this->checkout->transaction;
85
+	}
86
+
87
+
88
+
89
+	/**
90
+	 *    set_hooks - for hooking into EE Core, other modules, etc
91
+	 *
92
+	 * @access    public
93
+	 * @return    void
94
+	 * @throws EE_Error
95
+	 */
96
+	public static function set_hooks()
97
+	{
98
+		EED_Single_Page_Checkout::set_definitions();
99
+	}
100
+
101
+
102
+
103
+	/**
104
+	 *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
105
+	 *
106
+	 * @access    public
107
+	 * @return    void
108
+	 * @throws EE_Error
109
+	 */
110
+	public static function set_hooks_admin()
111
+	{
112
+		EED_Single_Page_Checkout::set_definitions();
113
+		if ( ! (defined('DOING_AJAX') && DOING_AJAX)) {
114
+			return;
115
+		}
116
+		// going to start an output buffer in case anything gets accidentally output
117
+		// that might disrupt our JSON response
118
+		ob_start();
119
+		EED_Single_Page_Checkout::load_request_handler();
120
+		EED_Single_Page_Checkout::load_reg_steps();
121
+		// set ajax hooks
122
+		add_action('wp_ajax_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step'));
123
+		add_action('wp_ajax_nopriv_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step'));
124
+		add_action('wp_ajax_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step'));
125
+		add_action('wp_ajax_nopriv_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step'));
126
+		add_action('wp_ajax_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step'));
127
+		add_action('wp_ajax_nopriv_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step'));
128
+	}
129
+
130
+
131
+
132
+	/**
133
+	 *    process ajax request
134
+	 *
135
+	 * @param string $ajax_action
136
+	 * @throws EE_Error
137
+	 */
138
+	public static function process_ajax_request($ajax_action)
139
+	{
140
+		EE_Registry::instance()->REQ->set('action', $ajax_action);
141
+		EED_Single_Page_Checkout::instance()->_initialize();
142
+	}
143
+
144
+
145
+
146
+	/**
147
+	 *    ajax display registration step
148
+	 *
149
+	 * @throws EE_Error
150
+	 */
151
+	public static function display_reg_step()
152
+	{
153
+		EED_Single_Page_Checkout::process_ajax_request('display_spco_reg_step');
154
+	}
155
+
156
+
157
+
158
+	/**
159
+	 *    ajax process registration step
160
+	 *
161
+	 * @throws EE_Error
162
+	 */
163
+	public static function process_reg_step()
164
+	{
165
+		EED_Single_Page_Checkout::process_ajax_request('process_reg_step');
166
+	}
167
+
168
+
169
+
170
+	/**
171
+	 *    ajax process registration step
172
+	 *
173
+	 * @throws EE_Error
174
+	 */
175
+	public static function update_reg_step()
176
+	{
177
+		EED_Single_Page_Checkout::process_ajax_request('update_reg_step');
178
+	}
179
+
180
+
181
+
182
+	/**
183
+	 *   update_checkout
184
+	 *
185
+	 * @access public
186
+	 * @return void
187
+	 * @throws EE_Error
188
+	 */
189
+	public static function update_checkout()
190
+	{
191
+		EED_Single_Page_Checkout::process_ajax_request('update_checkout');
192
+	}
193
+
194
+
195
+
196
+	/**
197
+	 *    load_request_handler
198
+	 *
199
+	 * @access    public
200
+	 * @return    void
201
+	 */
202
+	public static function load_request_handler()
203
+	{
204
+		// load core Request_Handler class
205
+		if (EE_Registry::instance()->REQ !== null) {
206
+			EE_Registry::instance()->load_core('Request_Handler');
207
+		}
208
+	}
209
+
210
+
211
+
212
+	/**
213
+	 *    set_definitions
214
+	 *
215
+	 * @access    public
216
+	 * @return    void
217
+	 * @throws EE_Error
218
+	 */
219
+	public static function set_definitions()
220
+	{
221
+		if(defined('SPCO_BASE_PATH')) {
222
+			return;
223
+		}
224
+		define(
225
+			'SPCO_BASE_PATH',
226
+			rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS) . DS
227
+		);
228
+		define('SPCO_CSS_URL', plugin_dir_url(__FILE__) . 'css' . DS);
229
+		define('SPCO_IMG_URL', plugin_dir_url(__FILE__) . 'img' . DS);
230
+		define('SPCO_JS_URL', plugin_dir_url(__FILE__) . 'js' . DS);
231
+		define('SPCO_INC_PATH', SPCO_BASE_PATH . 'inc' . DS);
232
+		define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps' . DS);
233
+		define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates' . DS);
234
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, true);
235
+		EE_Registry::$i18n_js_strings['registration_expiration_notice'] = EED_Single_Page_Checkout::getRegistrationExpirationNotice();
236
+	}
237
+
238
+
239
+
240
+	/**
241
+	 * load_reg_steps
242
+	 * loads and instantiates each reg step based on the EE_Registry::instance()->CFG->registration->reg_steps array
243
+	 *
244
+	 * @access    private
245
+	 * @throws EE_Error
246
+	 */
247
+	public static function load_reg_steps()
248
+	{
249
+		static $reg_steps_loaded = false;
250
+		if ($reg_steps_loaded) {
251
+			return;
252
+		}
253
+		// filter list of reg_steps
254
+		$reg_steps_to_load = (array)apply_filters(
255
+			'AHEE__SPCO__load_reg_steps__reg_steps_to_load',
256
+			EED_Single_Page_Checkout::get_reg_steps()
257
+		);
258
+		// sort by key (order)
259
+		ksort($reg_steps_to_load);
260
+		// loop through folders
261
+		foreach ($reg_steps_to_load as $order => $reg_step) {
262
+			// we need a
263
+			if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) {
264
+				// copy over to the reg_steps_array
265
+				EED_Single_Page_Checkout::$_reg_steps_array[$order] = $reg_step;
266
+				// register custom key route for each reg step
267
+				// ie: step=>"slug" - this is the entire reason we load the reg steps array now
268
+				EE_Config::register_route(
269
+					$reg_step['slug'],
270
+					'EED_Single_Page_Checkout',
271
+					'run',
272
+					'step'
273
+				);
274
+				// add AJAX or other hooks
275
+				if (isset($reg_step['has_hooks']) && $reg_step['has_hooks']) {
276
+					// setup autoloaders if necessary
277
+					if ( ! class_exists($reg_step['class_name'])) {
278
+						EEH_Autoloader::register_autoloaders_for_each_file_in_folder(
279
+							$reg_step['file_path'],
280
+							true
281
+						);
282
+					}
283
+					if (is_callable($reg_step['class_name'], 'set_hooks')) {
284
+						call_user_func(array($reg_step['class_name'], 'set_hooks'));
285
+					}
286
+				}
287
+			}
288
+		}
289
+		$reg_steps_loaded = true;
290
+	}
291
+
292
+
293
+
294
+	/**
295
+	 *    get_reg_steps
296
+	 *
297
+	 * @access    public
298
+	 * @return    array
299
+	 */
300
+	public static function get_reg_steps()
301
+	{
302
+		$reg_steps = EE_Registry::instance()->CFG->registration->reg_steps;
303
+		if (empty($reg_steps)) {
304
+			$reg_steps = array(
305
+				10  => array(
306
+					'file_path'  => SPCO_REG_STEPS_PATH . 'attendee_information',
307
+					'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information',
308
+					'slug'       => 'attendee_information',
309
+					'has_hooks'  => false,
310
+				),
311
+				20  => array(
312
+					'file_path'  => SPCO_REG_STEPS_PATH . 'registration_confirmation',
313
+					'class_name' => 'EE_SPCO_Reg_Step_Registration_Confirmation',
314
+					'slug'       => 'registration_confirmation',
315
+					'has_hooks'  => false,
316
+				),
317
+				30  => array(
318
+					'file_path'  => SPCO_REG_STEPS_PATH . 'payment_options',
319
+					'class_name' => 'EE_SPCO_Reg_Step_Payment_Options',
320
+					'slug'       => 'payment_options',
321
+					'has_hooks'  => true,
322
+				),
323
+				999 => array(
324
+					'file_path'  => SPCO_REG_STEPS_PATH . 'finalize_registration',
325
+					'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration',
326
+					'slug'       => 'finalize_registration',
327
+					'has_hooks'  => false,
328
+				),
329
+			);
330
+		}
331
+		return $reg_steps;
332
+	}
333
+
334
+
335
+
336
+	/**
337
+	 *    registration_checkout_for_admin
338
+	 *
339
+	 * @access    public
340
+	 * @return    string
341
+	 * @throws EE_Error
342
+	 */
343
+	public static function registration_checkout_for_admin()
344
+	{
345
+		EED_Single_Page_Checkout::load_request_handler();
346
+		EE_Registry::instance()->REQ->set('step', 'attendee_information');
347
+		EE_Registry::instance()->REQ->set('action', 'display_spco_reg_step');
348
+		EE_Registry::instance()->REQ->set('process_form_submission', false);
349
+		EED_Single_Page_Checkout::instance()->_initialize();
350
+		EED_Single_Page_Checkout::instance()->_display_spco_reg_form();
351
+		return EE_Registry::instance()->REQ->get_output();
352
+	}
353
+
354
+
355
+
356
+	/**
357
+	 * process_registration_from_admin
358
+	 *
359
+	 * @access public
360
+	 * @return \EE_Transaction
361
+	 * @throws EE_Error
362
+	 */
363
+	public static function process_registration_from_admin()
364
+	{
365
+		EED_Single_Page_Checkout::load_request_handler();
366
+		EE_Registry::instance()->REQ->set('step', 'attendee_information');
367
+		EE_Registry::instance()->REQ->set('action', 'process_reg_step');
368
+		EE_Registry::instance()->REQ->set('process_form_submission', true);
369
+		EED_Single_Page_Checkout::instance()->_initialize();
370
+		if (EED_Single_Page_Checkout::instance()->checkout->current_step->completed()) {
371
+			$final_reg_step = end(EED_Single_Page_Checkout::instance()->checkout->reg_steps);
372
+			if ($final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) {
373
+				EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated($final_reg_step);
374
+				if ($final_reg_step->process_reg_step()) {
375
+					$final_reg_step->set_completed();
376
+					EED_Single_Page_Checkout::instance()->checkout->update_txn_reg_steps_array();
377
+					return EED_Single_Page_Checkout::instance()->checkout->transaction;
378
+				}
379
+			}
380
+		}
381
+		return null;
382
+	}
383
+
384
+
385
+
386
+	/**
387
+	 *    run
388
+	 *
389
+	 * @access    public
390
+	 * @param WP_Query $WP_Query
391
+	 * @return    void
392
+	 * @throws EE_Error
393
+	 */
394
+	public function run($WP_Query)
395
+	{
396
+		if (
397
+			$WP_Query instanceof WP_Query
398
+			&& $WP_Query->is_main_query()
399
+			&& apply_filters('FHEE__EED_Single_Page_Checkout__run', true)
400
+			&& $this->_is_reg_checkout()
401
+		) {
402
+			$this->_initialize();
403
+		}
404
+	}
405
+
406
+
407
+
408
+	/**
409
+	 * determines whether current url matches reg page url
410
+	 *
411
+	 * @return bool
412
+	 */
413
+	protected function _is_reg_checkout()
414
+	{
415
+		// get current permalink for reg page without any extra query args
416
+		$reg_page_url = \get_permalink(EE_Config::instance()->core->reg_page_id);
417
+		// get request URI for current request, but without the scheme or host
418
+		$current_request_uri = \EEH_URL::filter_input_server_url('REQUEST_URI');
419
+		$current_request_uri = html_entity_decode($current_request_uri);
420
+		// get array of query args from the current request URI
421
+		$query_args = \EEH_URL::get_query_string($current_request_uri);
422
+		// grab page id if it is set
423
+		$page_id = isset($query_args['page_id']) ? absint($query_args['page_id']) : 0;
424
+		// and remove the page id from the query args (we will re-add it later)
425
+		unset($query_args['page_id']);
426
+		// now strip all query args from current request URI
427
+		$current_request_uri = remove_query_arg(array_keys($query_args), $current_request_uri);
428
+		// and re-add the page id if it was set
429
+		if ($page_id) {
430
+			$current_request_uri = add_query_arg('page_id', $page_id, $current_request_uri);
431
+		}
432
+		// remove slashes and ?
433
+		$current_request_uri = trim($current_request_uri, '?/');
434
+		// is current request URI part of the known full reg page URL ?
435
+		return ! empty($current_request_uri) && strpos($reg_page_url, $current_request_uri) !== false;
436
+	}
437
+
438
+
439
+
440
+	/**
441
+	 * @param WP_Query $wp_query
442
+	 * @return    void
443
+	 * @throws EE_Error
444
+	 */
445
+	public static function init($wp_query)
446
+	{
447
+		EED_Single_Page_Checkout::instance()->run($wp_query);
448
+	}
449
+
450
+
451
+
452
+	/**
453
+	 *    _initialize - initial module setup
454
+	 *
455
+	 * @access    private
456
+	 * @throws EE_Error
457
+	 * @return    void
458
+	 */
459
+	private function _initialize()
460
+	{
461
+		// ensure SPCO doesn't run twice
462
+		if (EED_Single_Page_Checkout::$_initialized) {
463
+			return;
464
+		}
465
+		try {
466
+			EED_Single_Page_Checkout::load_reg_steps();
467
+			$this->_verify_session();
468
+			// setup the EE_Checkout object
469
+			$this->checkout = $this->_initialize_checkout();
470
+			// filter checkout
471
+			$this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout);
472
+			// get the $_GET
473
+			$this->_get_request_vars();
474
+			if ($this->_block_bots()) {
475
+				return;
476
+			}
477
+			// filter continue_reg
478
+			$this->checkout->continue_reg = apply_filters(
479
+				'FHEE__EED_Single_Page_Checkout__init___continue_reg',
480
+				true,
481
+				$this->checkout
482
+			);
483
+			// load the reg steps array
484
+			if ( ! $this->_load_and_instantiate_reg_steps()) {
485
+				EED_Single_Page_Checkout::$_initialized = true;
486
+				return;
487
+			}
488
+			// set the current step
489
+			$this->checkout->set_current_step($this->checkout->step);
490
+			// and the next step
491
+			$this->checkout->set_next_step();
492
+			// verify that everything has been setup correctly
493
+			if ( ! ($this->_verify_transaction_and_get_registrations() && $this->_final_verifications())) {
494
+				EED_Single_Page_Checkout::$_initialized = true;
495
+				return;
496
+			}
497
+			// lock the transaction
498
+			$this->checkout->transaction->lock();
499
+			// make sure all of our cached objects are added to their respective model entity mappers
500
+			$this->checkout->refresh_all_entities();
501
+			// set amount owing
502
+			$this->checkout->amount_owing = $this->checkout->transaction->remaining();
503
+			// initialize each reg step, which gives them the chance to potentially alter the process
504
+			$this->_initialize_reg_steps();
505
+			// DEBUG LOG
506
+			//$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ );
507
+			// get reg form
508
+			if( ! $this->_check_form_submission()) {
509
+				EED_Single_Page_Checkout::$_initialized = true;
510
+				return;
511
+			}
512
+			// checkout the action!!!
513
+			$this->_process_form_action();
514
+			// add some style and make it dance
515
+			$this->add_styles_and_scripts();
516
+			// kk... SPCO has successfully run
517
+			EED_Single_Page_Checkout::$_initialized = true;
518
+			// set no cache headers and constants
519
+			EE_System::do_not_cache();
520
+			// add anchor
521
+			add_action('loop_start', array($this, 'set_checkout_anchor'), 1);
522
+			// remove transaction lock
523
+			add_action('shutdown', array($this, 'unlock_transaction'), 1);
524
+		} catch (Exception $e) {
525
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
526
+		}
527
+	}
528
+
529
+
530
+
531
+	/**
532
+	 *    _verify_session
533
+	 * checks that the session is valid and not expired
534
+	 *
535
+	 * @access    private
536
+	 * @throws EE_Error
537
+	 */
538
+	private function _verify_session()
539
+	{
540
+		if ( ! EE_Registry::instance()->SSN instanceof EE_Session) {
541
+			throw new EE_Error(__('The EE_Session class could not be loaded.', 'event_espresso'));
542
+		}
543
+		$clear_session_requested = filter_var(
544
+			EE_Registry::instance()->REQ->get('clear_session', false),
545
+			FILTER_VALIDATE_BOOLEAN
546
+		);
547
+		// is session still valid ?
548
+		if ($clear_session_requested
549
+			|| ( EE_Registry::instance()->SSN->expired()
550
+			  && EE_Registry::instance()->REQ->get('e_reg_url_link', '') === ''
551
+			)
552
+		) {
553
+			$this->checkout = new EE_Checkout();
554
+			EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
555
+			// EE_Registry::instance()->SSN->reset_cart();
556
+			// EE_Registry::instance()->SSN->reset_checkout();
557
+			// EE_Registry::instance()->SSN->reset_transaction();
558
+			if (! $clear_session_requested) {
559
+				EE_Error::add_attention(
560
+					EE_Registry::$i18n_js_strings['registration_expiration_notice'],
561
+					__FILE__, __FUNCTION__, __LINE__
562
+				);
563
+			}
564
+			// EE_Registry::instance()->SSN->reset_expired();
565
+		}
566
+	}
567
+
568
+
569
+
570
+	/**
571
+	 *    _initialize_checkout
572
+	 * loads and instantiates EE_Checkout
573
+	 *
574
+	 * @access    private
575
+	 * @throws EE_Error
576
+	 * @return EE_Checkout
577
+	 */
578
+	private function _initialize_checkout()
579
+	{
580
+		// look in session for existing checkout
581
+		/** @type EE_Checkout $checkout */
582
+		$checkout = EE_Registry::instance()->SSN->checkout();
583
+		// verify
584
+		if ( ! $checkout instanceof EE_Checkout) {
585
+			// instantiate EE_Checkout object for handling the properties of the current checkout process
586
+			$checkout = EE_Registry::instance()->load_file(
587
+				SPCO_INC_PATH,
588
+				'EE_Checkout',
589
+				'class', array(),
590
+				false
591
+			);
592
+		} else {
593
+			if ($checkout->current_step->is_final_step() && $checkout->exit_spco() === true) {
594
+				$this->unlock_transaction();
595
+				wp_safe_redirect($checkout->redirect_url);
596
+				exit();
597
+			}
598
+		}
599
+		$checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout);
600
+		// verify again
601
+		if ( ! $checkout instanceof EE_Checkout) {
602
+			throw new EE_Error(__('The EE_Checkout class could not be loaded.', 'event_espresso'));
603
+		}
604
+		// reset anything that needs a clean slate for each request
605
+		$checkout->reset_for_current_request();
606
+		return $checkout;
607
+	}
608
+
609
+
610
+
611
+	/**
612
+	 *    _get_request_vars
613
+	 *
614
+	 * @access    private
615
+	 * @return    void
616
+	 * @throws EE_Error
617
+	 */
618
+	private function _get_request_vars()
619
+	{
620
+		// load classes
621
+		EED_Single_Page_Checkout::load_request_handler();
622
+		//make sure this request is marked as belonging to EE
623
+		EE_Registry::instance()->REQ->set_espresso_page(true);
624
+		// which step is being requested ?
625
+		$this->checkout->step = EE_Registry::instance()->REQ->get('step', $this->_get_first_step());
626
+		// which step is being edited ?
627
+		$this->checkout->edit_step = EE_Registry::instance()->REQ->get('edit_step', '');
628
+		// and what we're doing on the current step
629
+		$this->checkout->action = EE_Registry::instance()->REQ->get('action', 'display_spco_reg_step');
630
+		// timestamp
631
+		$this->checkout->uts = EE_Registry::instance()->REQ->get('uts', 0);
632
+		// returning to edit ?
633
+		$this->checkout->reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link', '');
634
+		// add reg url link to registration query params
635
+		if ($this->checkout->reg_url_link && strpos($this->checkout->reg_url_link, '1-') !== 0) {
636
+			$this->checkout->reg_cache_where_params[0]['REG_url_link'] = $this->checkout->reg_url_link;
637
+		}
638
+		// or some other kind of revisit ?
639
+		$this->checkout->revisit = filter_var(
640
+			EE_Registry::instance()->REQ->get('revisit', false),
641
+			FILTER_VALIDATE_BOOLEAN
642
+		);
643
+		// and whether or not to generate a reg form for this request
644
+		$this->checkout->generate_reg_form = filter_var(
645
+			EE_Registry::instance()->REQ->get('generate_reg_form', true),
646
+			FILTER_VALIDATE_BOOLEAN
647
+		);
648
+		// and whether or not to process a reg form submission for this request
649
+		$this->checkout->process_form_submission = filter_var(
650
+			EE_Registry::instance()->REQ->get(
651
+				'process_form_submission',
652
+				$this->checkout->action === 'process_reg_step'
653
+			),
654
+			FILTER_VALIDATE_BOOLEAN
655
+		);
656
+		$this->checkout->process_form_submission = filter_var(
657
+			$this->checkout->action !== 'display_spco_reg_step'
658
+				? $this->checkout->process_form_submission
659
+				: false,
660
+			FILTER_VALIDATE_BOOLEAN
661
+		);
662
+		// $this->_display_request_vars();
663
+	}
664
+
665
+
666
+
667
+	/**
668
+	 *  _display_request_vars
669
+	 *
670
+	 * @access    protected
671
+	 * @return    void
672
+	 */
673
+	protected function _display_request_vars()
674
+	{
675
+		if ( ! WP_DEBUG) {
676
+			return;
677
+		}
678
+		EEH_Debug_Tools::printr($_REQUEST, '$_REQUEST', __FILE__, __LINE__);
679
+		EEH_Debug_Tools::printr($this->checkout->step, '$this->checkout->step', __FILE__, __LINE__);
680
+		EEH_Debug_Tools::printr($this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__);
681
+		EEH_Debug_Tools::printr($this->checkout->action, '$this->checkout->action', __FILE__, __LINE__);
682
+		EEH_Debug_Tools::printr($this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__);
683
+		EEH_Debug_Tools::printr($this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__);
684
+		EEH_Debug_Tools::printr($this->checkout->generate_reg_form, '$this->checkout->generate_reg_form', __FILE__, __LINE__);
685
+		EEH_Debug_Tools::printr($this->checkout->process_form_submission, '$this->checkout->process_form_submission', __FILE__, __LINE__);
686
+	}
687
+
688
+
689
+
690
+	/**
691
+	 * _block_bots
692
+	 * checks that the incoming request has either of the following set:
693
+	 *  a uts (unix timestamp) which indicates that the request was redirected from the Ticket Selector
694
+	 *  a REG URL Link, which indicates that the request is a return visit to SPCO for a valid TXN
695
+	 * so if you're not coming from the Ticket Selector nor returning for a valid IP...
696
+	 * then where you coming from man?
697
+	 *
698
+	 * @return boolean
699
+	 */
700
+	private function _block_bots()
701
+	{
702
+		$invalid_checkout_access = EED_Invalid_Checkout_Access::getInvalidCheckoutAccess();
703
+		if ($invalid_checkout_access->checkoutAccessIsInvalid($this->checkout)) {
704
+			return true;
705
+		}
706
+		return false;
707
+	}
708
+
709
+
710
+
711
+	/**
712
+	 *    _get_first_step
713
+	 *  gets slug for first step in $_reg_steps_array
714
+	 *
715
+	 * @access    private
716
+	 * @throws EE_Error
717
+	 * @return    string
718
+	 */
719
+	private function _get_first_step()
720
+	{
721
+		$first_step = reset(EED_Single_Page_Checkout::$_reg_steps_array);
722
+		return isset($first_step['slug']) ? $first_step['slug'] : 'attendee_information';
723
+	}
724
+
725
+
726
+
727
+	/**
728
+	 *    _load_and_instantiate_reg_steps
729
+	 *  instantiates each reg step based on the loaded reg_steps array
730
+	 *
731
+	 * @access    private
732
+	 * @throws EE_Error
733
+	 * @return    bool
734
+	 */
735
+	private function _load_and_instantiate_reg_steps()
736
+	{
737
+		do_action('AHEE__Single_Page_Checkout___load_and_instantiate_reg_steps__start', $this->checkout);
738
+		// have reg_steps already been instantiated ?
739
+		if (
740
+			empty($this->checkout->reg_steps)
741
+			|| apply_filters('FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout)
742
+		) {
743
+			// if not, then loop through raw reg steps array
744
+			foreach (EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step) {
745
+				if ( ! $this->_load_and_instantiate_reg_step($reg_step, $order)) {
746
+					return false;
747
+				}
748
+			}
749
+			EE_Registry::instance()->CFG->registration->skip_reg_confirmation = true;
750
+			EE_Registry::instance()->CFG->registration->reg_confirmation_last = true;
751
+			// skip the registration_confirmation page ?
752
+			if (EE_Registry::instance()->CFG->registration->skip_reg_confirmation) {
753
+				// just remove it from the reg steps array
754
+				$this->checkout->remove_reg_step('registration_confirmation', false);
755
+			} else if (
756
+				isset($this->checkout->reg_steps['registration_confirmation'])
757
+				&& EE_Registry::instance()->CFG->registration->reg_confirmation_last
758
+			) {
759
+				// set the order to something big like 100
760
+				$this->checkout->set_reg_step_order('registration_confirmation', 100);
761
+			}
762
+			// filter the array for good luck
763
+			$this->checkout->reg_steps = apply_filters(
764
+				'FHEE__Single_Page_Checkout__load_reg_steps__reg_steps',
765
+				$this->checkout->reg_steps
766
+			);
767
+			// finally re-sort based on the reg step class order properties
768
+			$this->checkout->sort_reg_steps();
769
+		} else {
770
+			foreach ($this->checkout->reg_steps as $reg_step) {
771
+				// set all current step stati to FALSE
772
+				$reg_step->set_is_current_step(false);
773
+			}
774
+		}
775
+		if (empty($this->checkout->reg_steps)) {
776
+			EE_Error::add_error(
777
+				__('No Reg Steps were loaded..', 'event_espresso'),
778
+				__FILE__, __FUNCTION__, __LINE__
779
+			);
780
+			return false;
781
+		}
782
+		// make reg step details available to JS
783
+		$this->checkout->set_reg_step_JSON_info();
784
+		return true;
785
+	}
786
+
787
+
788
+
789
+	/**
790
+	 *     _load_and_instantiate_reg_step
791
+	 *
792
+	 * @access    private
793
+	 * @param array $reg_step
794
+	 * @param int   $order
795
+	 * @return bool
796
+	 */
797
+	private function _load_and_instantiate_reg_step($reg_step = array(), $order = 0)
798
+	{
799
+		// we need a file_path, class_name, and slug to add a reg step
800
+		if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) {
801
+			// if editing a specific step, but this is NOT that step... (and it's not the 'finalize_registration' step)
802
+			if (
803
+				$this->checkout->reg_url_link
804
+				&& $this->checkout->step !== $reg_step['slug']
805
+				&& $reg_step['slug'] !== 'finalize_registration'
806
+				// normally at this point we would NOT load the reg step, but this filter can change that
807
+				&& apply_filters(
808
+					'FHEE__Single_Page_Checkout___load_and_instantiate_reg_step__bypass_reg_step',
809
+					true,
810
+					$reg_step,
811
+					$this->checkout
812
+				)
813
+			) {
814
+				return true;
815
+			}
816
+			// instantiate step class using file path and class name
817
+			$reg_step_obj = EE_Registry::instance()->load_file(
818
+				$reg_step['file_path'],
819
+				$reg_step['class_name'],
820
+				'class',
821
+				$this->checkout,
822
+				false
823
+			);
824
+			// did we gets the goods ?
825
+			if ($reg_step_obj instanceof EE_SPCO_Reg_Step) {
826
+				// set reg step order based on config
827
+				$reg_step_obj->set_order($order);
828
+				// add instantiated reg step object to the master reg steps array
829
+				$this->checkout->add_reg_step($reg_step_obj);
830
+			} else {
831
+				EE_Error::add_error(
832
+					__('The current step could not be set.', 'event_espresso'),
833
+					__FILE__, __FUNCTION__, __LINE__
834
+				);
835
+				return false;
836
+			}
837
+		} else {
838
+			if (WP_DEBUG) {
839
+				EE_Error::add_error(
840
+					sprintf(
841
+						__(
842
+							'A registration step could not be loaded. One or more of the following data points is invalid:%4$s%5$sFile Path: %1$s%6$s%5$sClass Name: %2$s%6$s%5$sSlug: %3$s%6$s%7$s',
843
+							'event_espresso'
844
+						),
845
+						isset($reg_step['file_path']) ? $reg_step['file_path'] : '',
846
+						isset($reg_step['class_name']) ? $reg_step['class_name'] : '',
847
+						isset($reg_step['slug']) ? $reg_step['slug'] : '',
848
+						'<ul>',
849
+						'<li>',
850
+						'</li>',
851
+						'</ul>'
852
+					),
853
+					__FILE__, __FUNCTION__, __LINE__
854
+				);
855
+			}
856
+			return false;
857
+		}
858
+		return true;
859
+	}
860
+
861
+
862
+	/**
863
+	 * _verify_transaction_and_get_registrations
864
+	 *
865
+	 * @access private
866
+	 * @return bool
867
+	 * @throws InvalidDataTypeException
868
+	 * @throws InvalidEntityException
869
+	 * @throws EE_Error
870
+	 */
871
+	private function _verify_transaction_and_get_registrations()
872
+	{
873
+		// was there already a valid transaction in the checkout from the session ?
874
+		if ( ! $this->checkout->transaction instanceof EE_Transaction) {
875
+			// get transaction from db or session
876
+			$this->checkout->transaction = $this->checkout->reg_url_link && ! is_admin()
877
+				? $this->_get_transaction_and_cart_for_previous_visit()
878
+				: $this->_get_cart_for_current_session_and_setup_new_transaction();
879
+			if ( ! $this->checkout->transaction instanceof EE_Transaction) {
880
+				EE_Error::add_error(
881
+					__('Your Registration and Transaction information could not be retrieved from the db.',
882
+						'event_espresso'),
883
+					__FILE__, __FUNCTION__, __LINE__
884
+				);
885
+				$this->checkout->transaction = EE_Transaction::new_instance();
886
+				// add some style and make it dance
887
+				$this->add_styles_and_scripts();
888
+				EED_Single_Page_Checkout::$_initialized = true;
889
+				return false;
890
+			}
891
+			// and the registrations for the transaction
892
+			$this->_get_registrations($this->checkout->transaction);
893
+		}
894
+		return true;
895
+	}
896
+
897
+
898
+
899
+	/**
900
+	 * _get_transaction_and_cart_for_previous_visit
901
+	 *
902
+	 * @access private
903
+	 * @return mixed EE_Transaction|NULL
904
+	 */
905
+	private function _get_transaction_and_cart_for_previous_visit()
906
+	{
907
+		/** @var $TXN_model EEM_Transaction */
908
+		$TXN_model = EE_Registry::instance()->load_model('Transaction');
909
+		// because the reg_url_link is present in the request,
910
+		// this is a return visit to SPCO, so we'll get the transaction data from the db
911
+		$transaction = $TXN_model->get_transaction_from_reg_url_link($this->checkout->reg_url_link);
912
+		// verify transaction
913
+		if ($transaction instanceof EE_Transaction) {
914
+			// and get the cart that was used for that transaction
915
+			$this->checkout->cart = $this->_get_cart_for_transaction($transaction);
916
+			return $transaction;
917
+		}
918
+		EE_Error::add_error(
919
+			__('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'),
920
+			__FILE__, __FUNCTION__, __LINE__
921
+		);
922
+		return null;
923
+
924
+	}
925
+
926
+
927
+
928
+	/**
929
+	 * _get_cart_for_transaction
930
+	 *
931
+	 * @access private
932
+	 * @param EE_Transaction $transaction
933
+	 * @return EE_Cart
934
+	 */
935
+	private function _get_cart_for_transaction($transaction)
936
+	{
937
+		return $this->checkout->get_cart_for_transaction($transaction);
938
+	}
939
+
940
+
941
+
942
+	/**
943
+	 * get_cart_for_transaction
944
+	 *
945
+	 * @access public
946
+	 * @param EE_Transaction $transaction
947
+	 * @return EE_Cart
948
+	 */
949
+	public function get_cart_for_transaction(EE_Transaction $transaction)
950
+	{
951
+		return $this->checkout->get_cart_for_transaction($transaction);
952
+	}
953
+
954
+
955
+
956
+	/**
957
+	 * _get_transaction_and_cart_for_current_session
958
+	 *    generates a new EE_Transaction object and adds it to the $_transaction property.
959
+	 *
960
+	 * @access private
961
+	 * @return EE_Transaction
962
+	 * @throws EE_Error
963
+	 */
964
+	private function _get_cart_for_current_session_and_setup_new_transaction()
965
+	{
966
+		//  if there's no transaction, then this is the FIRST visit to SPCO
967
+		// so load up the cart ( passing nothing for the TXN because it doesn't exist yet )
968
+		$this->checkout->cart = $this->_get_cart_for_transaction(null);
969
+		// and then create a new transaction
970
+		$transaction = $this->_initialize_transaction();
971
+		// verify transaction
972
+		if ($transaction instanceof EE_Transaction) {
973
+			// save it so that we have an ID for other objects to use
974
+			$transaction->save();
975
+			// and save TXN data to the cart
976
+			$this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($transaction->ID());
977
+		} else {
978
+			EE_Error::add_error(
979
+				__('A Valid Transaction could not be initialized.', 'event_espresso'),
980
+				__FILE__, __FUNCTION__, __LINE__
981
+			);
982
+		}
983
+		return $transaction;
984
+	}
985
+
986
+
987
+
988
+	/**
989
+	 *    generates a new EE_Transaction object and adds it to the $_transaction property.
990
+	 *
991
+	 * @access private
992
+	 * @return mixed EE_Transaction|NULL
993
+	 */
994
+	private function _initialize_transaction()
995
+	{
996
+		try {
997
+			// ensure cart totals have been calculated
998
+			$this->checkout->cart->get_grand_total()->recalculate_total_including_taxes();
999
+			// grab the cart grand total
1000
+			$cart_total = $this->checkout->cart->get_cart_grand_total();
1001
+			// create new TXN
1002
+			$transaction = EE_Transaction::new_instance(
1003
+				array(
1004
+					'TXN_reg_steps' => $this->checkout->initialize_txn_reg_steps_array(),
1005
+					'TXN_total'     => $cart_total > 0 ? $cart_total : 0,
1006
+					'TXN_paid'      => 0,
1007
+					'STS_ID'        => EEM_Transaction::failed_status_code,
1008
+				)
1009
+			);
1010
+			// save it so that we have an ID for other objects to use
1011
+			$transaction->save();
1012
+			// set cron job for following up on TXNs after their session has expired
1013
+			EE_Cron_Tasks::schedule_expired_transaction_check(
1014
+				EE_Registry::instance()->SSN->expiration() + 1,
1015
+				$transaction->ID()
1016
+			);
1017
+			return $transaction;
1018
+		} catch (Exception $e) {
1019
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
1020
+		}
1021
+		return null;
1022
+	}
1023
+
1024
+
1025
+	/**
1026
+	 * _get_registrations
1027
+	 *
1028
+	 * @access private
1029
+	 * @param EE_Transaction $transaction
1030
+	 * @return void
1031
+	 * @throws InvalidDataTypeException
1032
+	 * @throws InvalidEntityException
1033
+	 * @throws EE_Error
1034
+	 */
1035
+	private function _get_registrations(EE_Transaction $transaction)
1036
+	{
1037
+		// first step: grab the registrants  { : o
1038
+		$registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false);
1039
+		$this->checkout->total_ticket_count = count($registrations);
1040
+		// verify registrations have been set
1041
+		if (empty($registrations)) {
1042
+			// if no cached registrations, then check the db
1043
+			$registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false);
1044
+			// still nothing ? well as long as this isn't a revisit
1045
+			if (empty($registrations) && ! $this->checkout->revisit) {
1046
+				// generate new registrations from scratch
1047
+				$registrations = $this->_initialize_registrations($transaction);
1048
+			}
1049
+		}
1050
+		// sort by their original registration order
1051
+		usort($registrations, array('EED_Single_Page_Checkout', 'sort_registrations_by_REG_count'));
1052
+		// then loop thru the array
1053
+		foreach ($registrations as $registration) {
1054
+			// verify each registration
1055
+			if ($registration instanceof EE_Registration) {
1056
+				// we display all attendee info for the primary registrant
1057
+				if ($this->checkout->reg_url_link === $registration->reg_url_link()
1058
+					&& $registration->is_primary_registrant()
1059
+				) {
1060
+					$this->checkout->primary_revisit = true;
1061
+					break;
1062
+				}
1063
+				if ($this->checkout->revisit && $this->checkout->reg_url_link !== $registration->reg_url_link()) {
1064
+					// but hide info if it doesn't belong to you
1065
+					$transaction->clear_cache('Registration', $registration->ID());
1066
+					$this->checkout->total_ticket_count--;
1067
+				}
1068
+				$this->checkout->set_reg_status_updated($registration->ID(), false);
1069
+			}
1070
+		}
1071
+	}
1072
+
1073
+
1074
+	/**
1075
+	 *    adds related EE_Registration objects for each ticket in the cart to the current EE_Transaction object
1076
+	 *
1077
+	 * @access private
1078
+	 * @param EE_Transaction $transaction
1079
+	 * @return    array
1080
+	 * @throws InvalidDataTypeException
1081
+	 * @throws InvalidEntityException
1082
+	 * @throws EE_Error
1083
+	 */
1084
+	private function _initialize_registrations(EE_Transaction $transaction)
1085
+	{
1086
+		$att_nmbr = 0;
1087
+		$registrations = array();
1088
+		if ($transaction instanceof EE_Transaction) {
1089
+			/** @type EE_Registration_Processor $registration_processor */
1090
+			$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
1091
+			$this->checkout->total_ticket_count = $this->checkout->cart->all_ticket_quantity_count();
1092
+			// now let's add the cart items to the $transaction
1093
+			foreach ($this->checkout->cart->get_tickets() as $line_item) {
1094
+				//do the following for each ticket of this type they selected
1095
+				for ($x = 1; $x <= $line_item->quantity(); $x++) {
1096
+					$att_nmbr++;
1097
+					/** @var EventEspresso\core\services\commands\registration\CreateRegistrationCommand $CreateRegistrationCommand */
1098
+					$CreateRegistrationCommand = EE_Registry::instance()->create(
1099
+						'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
1100
+						array(
1101
+							$transaction,
1102
+							$line_item,
1103
+							$att_nmbr,
1104
+							$this->checkout->total_ticket_count,
1105
+						)
1106
+					);
1107
+					// override capabilities for frontend registrations
1108
+					if ( ! is_admin()) {
1109
+						$CreateRegistrationCommand->setCapCheck(
1110
+							new PublicCapabilities('', 'create_new_registration')
1111
+						);
1112
+					}
1113
+					$registration = EE_Registry::instance()->BUS->execute($CreateRegistrationCommand);
1114
+					if ( ! $registration instanceof EE_Registration) {
1115
+						throw new InvalidEntityException($registration, 'EE_Registration');
1116
+					}
1117
+					$registrations[ $registration->ID() ] = $registration;
1118
+				}
1119
+			}
1120
+			$registration_processor->fix_reg_final_price_rounding_issue($transaction);
1121
+		}
1122
+		return $registrations;
1123
+	}
1124
+
1125
+
1126
+
1127
+	/**
1128
+	 * sorts registrations by REG_count
1129
+	 *
1130
+	 * @access public
1131
+	 * @param EE_Registration $reg_A
1132
+	 * @param EE_Registration $reg_B
1133
+	 * @return int
1134
+	 */
1135
+	public static function sort_registrations_by_REG_count(EE_Registration $reg_A, EE_Registration $reg_B)
1136
+	{
1137
+		// this shouldn't ever happen within the same TXN, but oh well
1138
+		if ($reg_A->count() === $reg_B->count()) {
1139
+			return 0;
1140
+		}
1141
+		return ($reg_A->count() > $reg_B->count()) ? 1 : -1;
1142
+	}
1143
+
1144
+
1145
+
1146
+	/**
1147
+	 *    _final_verifications
1148
+	 * just makes sure that everything is set up correctly before proceeding
1149
+	 *
1150
+	 * @access    private
1151
+	 * @return    bool
1152
+	 * @throws EE_Error
1153
+	 */
1154
+	private function _final_verifications()
1155
+	{
1156
+		// filter checkout
1157
+		$this->checkout = apply_filters(
1158
+			'FHEE__EED_Single_Page_Checkout___final_verifications__checkout',
1159
+			$this->checkout
1160
+		);
1161
+		//verify that current step is still set correctly
1162
+		if ( ! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) {
1163
+			EE_Error::add_error(
1164
+				__('We\'re sorry but the registration process can not proceed because one or more registration steps were not setup correctly. Please refresh the page and try again or contact support.', 'event_espresso'),
1165
+				__FILE__,
1166
+				__FUNCTION__,
1167
+				__LINE__
1168
+			);
1169
+			return false;
1170
+		}
1171
+		// if returning to SPCO, then verify that primary registrant is set
1172
+		if ( ! empty($this->checkout->reg_url_link)) {
1173
+			$valid_registrant = $this->checkout->transaction->primary_registration();
1174
+			if ( ! $valid_registrant instanceof EE_Registration) {
1175
+				EE_Error::add_error(
1176
+					__('We\'re sorry but there appears to be an error with the "reg_url_link" or the primary registrant for this transaction. Please refresh the page and try again or contact support.', 'event_espresso'),
1177
+					__FILE__,
1178
+					__FUNCTION__,
1179
+					__LINE__
1180
+				);
1181
+				return false;
1182
+			}
1183
+			$valid_registrant = null;
1184
+			foreach (
1185
+				$this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) as $registration
1186
+			) {
1187
+				if (
1188
+					$registration instanceof EE_Registration
1189
+					&& $registration->reg_url_link() === $this->checkout->reg_url_link
1190
+				) {
1191
+					$valid_registrant = $registration;
1192
+				}
1193
+			}
1194
+			if ( ! $valid_registrant instanceof EE_Registration) {
1195
+				// hmmm... maybe we have the wrong session because the user is opening multiple tabs ?
1196
+				if (EED_Single_Page_Checkout::$_checkout_verified) {
1197
+					// clear the session, mark the checkout as unverified, and try again
1198
+					EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
1199
+					EED_Single_Page_Checkout::$_initialized = false;
1200
+					EED_Single_Page_Checkout::$_checkout_verified = false;
1201
+					$this->_initialize();
1202
+					EE_Error::reset_notices();
1203
+					return false;
1204
+				}
1205
+				EE_Error::add_error(
1206
+					__(
1207
+						'We\'re sorry but there appears to be an error with the "reg_url_link" or the transaction itself. Please refresh the page and try again or contact support.',
1208
+						'event_espresso'
1209
+					),
1210
+					__FILE__,
1211
+					__FUNCTION__,
1212
+					__LINE__
1213
+				);
1214
+				return false;
1215
+			}
1216
+		}
1217
+		// now that things have been kinda sufficiently verified,
1218
+		// let's add the checkout to the session so that it's available to other systems
1219
+		EE_Registry::instance()->SSN->set_checkout($this->checkout);
1220
+		return true;
1221
+	}
1222
+
1223
+
1224
+
1225
+	/**
1226
+	 *    _initialize_reg_steps
1227
+	 * first makes sure that EE_Transaction_Processor::set_reg_step_initiated() is called as required
1228
+	 * then loops thru all of the active reg steps and calls the initialize_reg_step() method
1229
+	 *
1230
+	 * @access    private
1231
+	 * @param bool $reinitializing
1232
+	 * @throws EE_Error
1233
+	 */
1234
+	private function _initialize_reg_steps($reinitializing = false)
1235
+	{
1236
+		$this->checkout->set_reg_step_initiated($this->checkout->current_step);
1237
+		// loop thru all steps to call their individual "initialize" methods and set i18n strings for JS
1238
+		foreach ($this->checkout->reg_steps as $reg_step) {
1239
+			if ( ! $reg_step->initialize_reg_step()) {
1240
+				// if not initialized then maybe this step is being removed...
1241
+				if ( ! $reinitializing && $reg_step->is_current_step()) {
1242
+					// if it was the current step, then we need to start over here
1243
+					$this->_initialize_reg_steps(true);
1244
+					return;
1245
+				}
1246
+				continue;
1247
+			}
1248
+			// add css and JS for current step
1249
+			$reg_step->enqueue_styles_and_scripts();
1250
+			// i18n
1251
+			$reg_step->translate_js_strings();
1252
+			if ($reg_step->is_current_step()) {
1253
+				// the text that appears on the reg step form submit button
1254
+				$reg_step->set_submit_button_text();
1255
+			}
1256
+		}
1257
+		// dynamically creates hook point like: AHEE__Single_Page_Checkout___initialize_reg_step__attendee_information
1258
+		do_action(
1259
+			"AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}",
1260
+			$this->checkout->current_step
1261
+		);
1262
+	}
1263
+
1264
+
1265
+
1266
+	/**
1267
+	 * _check_form_submission
1268
+	 *
1269
+	 * @access private
1270
+	 * @return boolean
1271
+	 */
1272
+	private function _check_form_submission()
1273
+	{
1274
+		//does this request require the reg form to be generated ?
1275
+		if ($this->checkout->generate_reg_form) {
1276
+			// ever heard that song by Blue Rodeo ?
1277
+			try {
1278
+				$this->checkout->current_step->reg_form = $this->checkout->current_step->generate_reg_form();
1279
+				// if not displaying a form, then check for form submission
1280
+				if (
1281
+					$this->checkout->process_form_submission
1282
+					&& $this->checkout->current_step->reg_form->was_submitted()
1283
+				) {
1284
+					// clear out any old data in case this step is being run again
1285
+					$this->checkout->current_step->set_valid_data(array());
1286
+					// capture submitted form data
1287
+					$this->checkout->current_step->reg_form->receive_form_submission(
1288
+						apply_filters(
1289
+							'FHEE__Single_Page_Checkout___check_form_submission__request_params',
1290
+							EE_Registry::instance()->REQ->params(),
1291
+							$this->checkout
1292
+						)
1293
+					);
1294
+					// validate submitted form data
1295
+					if ( ! $this->checkout->continue_reg || ! $this->checkout->current_step->reg_form->is_valid()) {
1296
+						// thou shall not pass !!!
1297
+						$this->checkout->continue_reg = false;
1298
+						// any form validation errors?
1299
+						if ($this->checkout->current_step->reg_form->submission_error_message() !== '') {
1300
+							EE_Error::add_error(
1301
+								$this->checkout->current_step->reg_form->submission_error_message(),
1302
+								__FILE__, __FUNCTION__, __LINE__
1303
+							);
1304
+						}
1305
+						// well not really... what will happen is
1306
+						// we'll just get redirected back to redo the current step
1307
+						$this->go_to_next_step();
1308
+						return false;
1309
+					}
1310
+				}
1311
+			} catch (EE_Error $e) {
1312
+				$e->get_error();
1313
+			}
1314
+		}
1315
+		return true;
1316
+	}
1317
+
1318
+
1319
+
1320
+	/**
1321
+	 * _process_action
1322
+	 *
1323
+	 * @access private
1324
+	 * @return void
1325
+	 * @throws EE_Error
1326
+	 */
1327
+	private function _process_form_action()
1328
+	{
1329
+		// what cha wanna do?
1330
+		switch ($this->checkout->action) {
1331
+			// AJAX next step reg form
1332
+			case 'display_spco_reg_step' :
1333
+				$this->checkout->redirect = false;
1334
+				if (EE_Registry::instance()->REQ->ajax) {
1335
+					$this->checkout->json_response->set_reg_step_html(
1336
+						$this->checkout->current_step->display_reg_form()
1337
+					);
1338
+				}
1339
+				break;
1340
+			default :
1341
+				// meh... do one of those other steps first
1342
+				if (
1343
+					! empty($this->checkout->action)
1344
+					&& is_callable(array($this->checkout->current_step, $this->checkout->action))
1345
+				) {
1346
+					// dynamically creates hook point like:
1347
+					//   AHEE__Single_Page_Checkout__before_attendee_information__process_reg_step
1348
+					do_action(
1349
+						"AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}",
1350
+						$this->checkout->current_step
1351
+					);
1352
+					// call action on current step
1353
+					if (call_user_func(array($this->checkout->current_step, $this->checkout->action))) {
1354
+						// good registrant, you get to proceed
1355
+						if (
1356
+							$this->checkout->current_step->success_message() !== ''
1357
+							&& apply_filters(
1358
+								'FHEE__Single_Page_Checkout___process_form_action__display_success',
1359
+								false
1360
+							)
1361
+						) {
1362
+							EE_Error::add_success(
1363
+								$this->checkout->current_step->success_message()
1364
+								. '<br />' . $this->checkout->next_step->_instructions()
1365
+							);
1366
+						}
1367
+						// pack it up, pack it in...
1368
+						$this->_setup_redirect();
1369
+					}
1370
+					// dynamically creates hook point like:
1371
+					//  AHEE__Single_Page_Checkout__after_payment_options__process_reg_step
1372
+					do_action(
1373
+						"AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}",
1374
+						$this->checkout->current_step
1375
+					);
1376
+				} else {
1377
+					EE_Error::add_error(
1378
+						sprintf(
1379
+							__(
1380
+								'The requested form action "%s" does not exist for the current "%s" registration step.',
1381
+								'event_espresso'
1382
+							),
1383
+							$this->checkout->action,
1384
+							$this->checkout->current_step->name()
1385
+						),
1386
+						__FILE__,
1387
+						__FUNCTION__,
1388
+						__LINE__
1389
+					);
1390
+				}
1391
+			// end default
1392
+		}
1393
+		// store our progress so far
1394
+		$this->checkout->stash_transaction_and_checkout();
1395
+		// advance to the next step! If you pass GO, collect $200
1396
+		$this->go_to_next_step();
1397
+	}
1398
+
1399
+
1400
+
1401
+	/**
1402
+	 *        add_styles_and_scripts
1403
+	 *
1404
+	 * @access        public
1405
+	 * @return        void
1406
+	 */
1407
+	public function add_styles_and_scripts()
1408
+	{
1409
+		// i18n
1410
+		$this->translate_js_strings();
1411
+		if ($this->checkout->admin_request) {
1412
+			add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10);
1413
+		} else {
1414
+			add_action('wp_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10);
1415
+		}
1416
+	}
1417
+
1418
+
1419
+
1420
+	/**
1421
+	 *        translate_js_strings
1422
+	 *
1423
+	 * @access        public
1424
+	 * @return        void
1425
+	 */
1426
+	public function translate_js_strings()
1427
+	{
1428
+		EE_Registry::$i18n_js_strings['revisit'] = $this->checkout->revisit;
1429
+		EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->checkout->reg_url_link;
1430
+		EE_Registry::$i18n_js_strings['server_error'] = __(
1431
+			'An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again or contact support.',
1432
+			'event_espresso'
1433
+		);
1434
+		EE_Registry::$i18n_js_strings['invalid_json_response'] = __(
1435
+			'An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.',
1436
+			'event_espresso'
1437
+		);
1438
+		EE_Registry::$i18n_js_strings['validation_error'] = __(
1439
+			'There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.',
1440
+			'event_espresso'
1441
+		);
1442
+		EE_Registry::$i18n_js_strings['invalid_payment_method'] = __(
1443
+			'There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.',
1444
+			'event_espresso'
1445
+		);
1446
+		EE_Registry::$i18n_js_strings['reg_step_error'] = __(
1447
+			'This registration step could not be completed. Please refresh the page and try again.',
1448
+			'event_espresso'
1449
+		);
1450
+		EE_Registry::$i18n_js_strings['invalid_coupon'] = __(
1451
+			'We\'re sorry but that coupon code does not appear to be valid. If this is incorrect, please contact the site administrator.',
1452
+			'event_espresso'
1453
+		);
1454
+		EE_Registry::$i18n_js_strings['process_registration'] = sprintf(
1455
+			__(
1456
+				'Please wait while we process your registration.%sDo not refresh the page or navigate away while this is happening.%sThank you for your patience.',
1457
+				'event_espresso'
1458
+			),
1459
+			'<br/>',
1460
+			'<br/>'
1461
+		);
1462
+		EE_Registry::$i18n_js_strings['language'] = get_bloginfo('language');
1463
+		EE_Registry::$i18n_js_strings['EESID'] = EE_Registry::instance()->SSN->id();
1464
+		EE_Registry::$i18n_js_strings['currency'] = EE_Registry::instance()->CFG->currency;
1465
+		EE_Registry::$i18n_js_strings['datepicker_yearRange'] = '-150:+20';
1466
+		EE_Registry::$i18n_js_strings['timer_years'] = __('years', 'event_espresso');
1467
+		EE_Registry::$i18n_js_strings['timer_months'] = __('months', 'event_espresso');
1468
+		EE_Registry::$i18n_js_strings['timer_weeks'] = __('weeks', 'event_espresso');
1469
+		EE_Registry::$i18n_js_strings['timer_days'] = __('days', 'event_espresso');
1470
+		EE_Registry::$i18n_js_strings['timer_hours'] = __('hours', 'event_espresso');
1471
+		EE_Registry::$i18n_js_strings['timer_minutes'] = __('minutes', 'event_espresso');
1472
+		EE_Registry::$i18n_js_strings['timer_seconds'] = __('seconds', 'event_espresso');
1473
+		EE_Registry::$i18n_js_strings['timer_year'] = __('year', 'event_espresso');
1474
+		EE_Registry::$i18n_js_strings['timer_month'] = __('month', 'event_espresso');
1475
+		EE_Registry::$i18n_js_strings['timer_week'] = __('week', 'event_espresso');
1476
+		EE_Registry::$i18n_js_strings['timer_day'] = __('day', 'event_espresso');
1477
+		EE_Registry::$i18n_js_strings['timer_hour'] = __('hour', 'event_espresso');
1478
+		EE_Registry::$i18n_js_strings['timer_minute'] = __('minute', 'event_espresso');
1479
+		EE_Registry::$i18n_js_strings['timer_second'] = __('second', 'event_espresso');
1480
+		EE_Registry::$i18n_js_strings['registration_expiration_notice'] = EED_Single_Page_Checkout::getRegistrationExpirationNotice();
1481
+		EE_Registry::$i18n_js_strings['ajax_submit'] = apply_filters(
1482
+			'FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit',
1483
+			true
1484
+		);
1485
+		EE_Registry::$i18n_js_strings['session_extension'] = absint(
1486
+			apply_filters('FHEE__EE_Session__extend_expiration__seconds_added', 10 * MINUTE_IN_SECONDS)
1487
+		);
1488
+		EE_Registry::$i18n_js_strings['session_expiration'] = gmdate(
1489
+			'M d, Y H:i:s',
1490
+			EE_Registry::instance()->SSN->expiration() + (get_option('gmt_offset') * HOUR_IN_SECONDS)
1491
+		);
1492
+	}
1493
+
1494
+
1495
+
1496
+	/**
1497
+	 *    enqueue_styles_and_scripts
1498
+	 *
1499
+	 * @access        public
1500
+	 * @return        void
1501
+	 * @throws EE_Error
1502
+	 */
1503
+	public function enqueue_styles_and_scripts()
1504
+	{
1505
+		// load css
1506
+		wp_register_style(
1507
+			'single_page_checkout',
1508
+			SPCO_CSS_URL . 'single_page_checkout.css',
1509
+			array('espresso_default'),
1510
+			EVENT_ESPRESSO_VERSION
1511
+		);
1512
+		wp_enqueue_style('single_page_checkout');
1513
+		// load JS
1514
+		wp_register_script(
1515
+			'jquery_plugin',
1516
+			EE_THIRD_PARTY_URL . 'jquery	.plugin.min.js',
1517
+			array('jquery'),
1518
+			'1.0.1',
1519
+			true
1520
+		);
1521
+		wp_register_script(
1522
+			'jquery_countdown',
1523
+			EE_THIRD_PARTY_URL . 'jquery	.countdown.min.js',
1524
+			array('jquery_plugin'),
1525
+			'2.0.2',
1526
+			true
1527
+		);
1528
+		wp_register_script(
1529
+			'single_page_checkout',
1530
+			SPCO_JS_URL . 'single_page_checkout.js',
1531
+			array('espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown'),
1532
+			EVENT_ESPRESSO_VERSION,
1533
+			true
1534
+		);
1535
+		if ($this->checkout->registration_form instanceof EE_Form_Section_Proper) {
1536
+			$this->checkout->registration_form->enqueue_js();
1537
+		}
1538
+		if ($this->checkout->current_step->reg_form instanceof EE_Form_Section_Proper) {
1539
+			$this->checkout->current_step->reg_form->enqueue_js();
1540
+		}
1541
+		wp_enqueue_script('single_page_checkout');
1542
+		/**
1543
+		 * global action hook for enqueueing styles and scripts with
1544
+		 * spco calls.
1545
+		 */
1546
+		do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this);
1547
+		/**
1548
+		 * dynamic action hook for enqueueing styles and scripts with spco calls.
1549
+		 * The hook will end up being something like:
1550
+		 *      AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information
1551
+		 */
1552
+		do_action(
1553
+			'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(),
1554
+			$this
1555
+		);
1556
+	}
1557
+
1558
+
1559
+
1560
+	/**
1561
+	 *    display the Registration Single Page Checkout Form
1562
+	 *
1563
+	 * @access    private
1564
+	 * @return    void
1565
+	 * @throws EE_Error
1566
+	 */
1567
+	private function _display_spco_reg_form()
1568
+	{
1569
+		// if registering via the admin, just display the reg form for the current step
1570
+		if ($this->checkout->admin_request) {
1571
+			EE_Registry::instance()->REQ->add_output($this->checkout->current_step->display_reg_form());
1572
+		} else {
1573
+			// add powered by EE msg
1574
+			add_action('AHEE__SPCO__reg_form_footer', array('EED_Single_Page_Checkout', 'display_registration_footer'));
1575
+			$empty_cart = count(
1576
+				$this->checkout->transaction->registrations($this->checkout->reg_cache_where_params)
1577
+			) < 1;
1578
+			EE_Registry::$i18n_js_strings['empty_cart'] = $empty_cart;
1579
+			$cookies_not_set_msg = '';
1580
+			if ($empty_cart) {
1581
+				$cookies_not_set_msg = apply_filters(
1582
+					'FHEE__Single_Page_Checkout__display_spco_reg_form__cookies_not_set_msg',
1583
+					sprintf(
1584
+						__(
1585
+							'%1$s%3$sIt appears your browser is not currently set to accept Cookies%4$s%5$sIn order to register for events, you need to enable cookies.%7$sIf you require assistance, then click the following link to learn how to %8$senable cookies%9$s%6$s%2$s',
1586
+							'event_espresso'
1587
+						),
1588
+						'<div class="ee-attention hidden" id="ee-cookies-not-set-msg">',
1589
+						'</div>',
1590
+						'<h6 class="important-notice">',
1591
+						'</h6>',
1592
+						'<p>',
1593
+						'</p>',
1594
+						'<br />',
1595
+						'<a href="http://www.whatarecookies.com/enable.asp" target="_blank">',
1596
+						'</a>'
1597
+					)
1598
+				);
1599
+			}
1600
+			$this->checkout->registration_form = new EE_Form_Section_Proper(
1601
+				array(
1602
+					'name'            => 'single-page-checkout',
1603
+					'html_id'         => 'ee-single-page-checkout-dv',
1604
+					'layout_strategy' =>
1605
+						new EE_Template_Layout(
1606
+							array(
1607
+								'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php',
1608
+								'template_args'        => array(
1609
+									'empty_cart'              => $empty_cart,
1610
+									'revisit'                 => $this->checkout->revisit,
1611
+									'reg_steps'               => $this->checkout->reg_steps,
1612
+									'next_step'               => $this->checkout->next_step instanceof EE_SPCO_Reg_Step
1613
+										? $this->checkout->next_step->slug()
1614
+										: '',
1615
+									'empty_msg'               => apply_filters(
1616
+										'FHEE__Single_Page_Checkout__display_spco_reg_form__empty_msg',
1617
+										sprintf(
1618
+											__(
1619
+												'You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.',
1620
+												'event_espresso'
1621
+											),
1622
+											'<a href="'
1623
+											. get_post_type_archive_link('espresso_events')
1624
+											. '" title="',
1625
+											'">',
1626
+											'</a>'
1627
+										)
1628
+									),
1629
+									'cookies_not_set_msg'     => $cookies_not_set_msg,
1630
+									'registration_time_limit' => $this->checkout->get_registration_time_limit(),
1631
+									'session_expiration'      => gmdate(
1632
+										'M d, Y H:i:s',
1633
+										EE_Registry::instance()->SSN->expiration()
1634
+										+ (get_option('gmt_offset') * HOUR_IN_SECONDS)
1635
+									),
1636
+								),
1637
+							)
1638
+						),
1639
+				)
1640
+			);
1641
+			// load template and add to output sent that gets filtered into the_content()
1642
+			EE_Registry::instance()->REQ->add_output($this->checkout->registration_form->get_html());
1643
+		}
1644
+	}
1645
+
1646
+
1647
+
1648
+	/**
1649
+	 *    add_extra_finalize_registration_inputs
1650
+	 *
1651
+	 * @access    public
1652
+	 * @param $next_step
1653
+	 * @internal  param string $label
1654
+	 * @return void
1655
+	 */
1656
+	public function add_extra_finalize_registration_inputs($next_step)
1657
+	{
1658
+		if ($next_step === 'finalize_registration') {
1659
+			echo '<div id="spco-extra-finalize_registration-inputs-dv"></div>';
1660
+		}
1661
+	}
1662
+
1663
+
1664
+
1665
+	/**
1666
+	 *    display_registration_footer
1667
+	 *
1668
+	 * @access    public
1669
+	 * @return    string
1670
+	 */
1671
+	public static function display_registration_footer()
1672
+	{
1673
+		if (
1674
+		apply_filters(
1675
+			'FHEE__EE_Front__Controller__show_reg_footer',
1676
+			EE_Registry::instance()->CFG->admin->show_reg_footer
1677
+		)
1678
+		) {
1679
+			add_filter(
1680
+				'FHEE__EEH_Template__powered_by_event_espresso__url',
1681
+				function ($url) {
1682
+					return apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url);
1683
+				}
1684
+			);
1685
+			echo apply_filters(
1686
+				'FHEE__EE_Front_Controller__display_registration_footer',
1687
+				\EEH_Template::powered_by_event_espresso(
1688
+					'',
1689
+					'espresso-registration-footer-dv',
1690
+					array('utm_content' => 'registration_checkout')
1691
+				)
1692
+			);
1693
+		}
1694
+		return '';
1695
+	}
1696
+
1697
+
1698
+
1699
+	/**
1700
+	 *    unlock_transaction
1701
+	 *
1702
+	 * @access    public
1703
+	 * @return    void
1704
+	 * @throws EE_Error
1705
+	 */
1706
+	public function unlock_transaction()
1707
+	{
1708
+		if ($this->checkout->transaction instanceof EE_Transaction) {
1709
+			$this->checkout->transaction->unlock();
1710
+		}
1711
+	}
1712
+
1713
+
1714
+
1715
+	/**
1716
+	 *        _setup_redirect
1717
+	 *
1718
+	 * @access    private
1719
+	 * @return void
1720
+	 */
1721
+	private function _setup_redirect()
1722
+	{
1723
+		if ($this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step) {
1724
+			$this->checkout->redirect = true;
1725
+			if (empty($this->checkout->redirect_url)) {
1726
+				$this->checkout->redirect_url = $this->checkout->next_step->reg_step_url();
1727
+			}
1728
+			$this->checkout->redirect_url = apply_filters(
1729
+				'FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url',
1730
+				$this->checkout->redirect_url,
1731
+				$this->checkout
1732
+			);
1733
+		}
1734
+	}
1735
+
1736
+
1737
+
1738
+	/**
1739
+	 *   handle ajax message responses and redirects
1740
+	 *
1741
+	 * @access public
1742
+	 * @return void
1743
+	 * @throws EE_Error
1744
+	 */
1745
+	public function go_to_next_step()
1746
+	{
1747
+		if (EE_Registry::instance()->REQ->ajax) {
1748
+			// capture contents of output buffer we started earlier in the request, and insert into JSON response
1749
+			$this->checkout->json_response->set_unexpected_errors(ob_get_clean());
1750
+		}
1751
+		$this->unlock_transaction();
1752
+		// just return for these conditions
1753
+		if (
1754
+			$this->checkout->admin_request
1755
+			|| $this->checkout->action === 'redirect_form'
1756
+			|| $this->checkout->action === 'update_checkout'
1757
+		) {
1758
+			return;
1759
+		}
1760
+		// AJAX response
1761
+		$this->_handle_json_response();
1762
+		// redirect to next step or the Thank You page
1763
+		$this->_handle_html_redirects();
1764
+		// hmmm... must be something wrong, so let's just display the form again !
1765
+		$this->_display_spco_reg_form();
1766
+	}
1767
+
1768
+
1769
+
1770
+	/**
1771
+	 *   _handle_json_response
1772
+	 *
1773
+	 * @access protected
1774
+	 * @return void
1775
+	 */
1776
+	protected function _handle_json_response()
1777
+	{
1778
+		// if this is an ajax request
1779
+		if (EE_Registry::instance()->REQ->ajax) {
1780
+			// DEBUG LOG
1781
+			//$this->checkout->log(
1782
+			//	__CLASS__, __FUNCTION__, __LINE__,
1783
+			//	array(
1784
+			//		'json_response_redirect_url' => $this->checkout->json_response->redirect_url(),
1785
+			//		'redirect'                   => $this->checkout->redirect,
1786
+			//		'continue_reg'               => $this->checkout->continue_reg,
1787
+			//	)
1788
+			//);
1789
+			$this->checkout->json_response->set_registration_time_limit(
1790
+				$this->checkout->get_registration_time_limit()
1791
+			);
1792
+			$this->checkout->json_response->set_payment_amount($this->checkout->amount_owing);
1793
+			// just send the ajax (
1794
+			$json_response = apply_filters(
1795
+				'FHEE__EE_Single_Page_Checkout__JSON_response',
1796
+				$this->checkout->json_response
1797
+			);
1798
+			echo $json_response;
1799
+			exit();
1800
+		}
1801
+	}
1802
+
1803
+
1804
+
1805
+	/**
1806
+	 *   _handle_redirects
1807
+	 *
1808
+	 * @access protected
1809
+	 * @return void
1810
+	 */
1811
+	protected function _handle_html_redirects()
1812
+	{
1813
+		// going somewhere ?
1814
+		if ($this->checkout->redirect && ! empty($this->checkout->redirect_url)) {
1815
+			// store notices in a transient
1816
+			EE_Error::get_notices(false, true, true);
1817
+			// DEBUG LOG
1818
+			//$this->checkout->log(
1819
+			//	__CLASS__, __FUNCTION__, __LINE__,
1820
+			//	array(
1821
+			//		'headers_sent' => headers_sent(),
1822
+			//		'redirect_url'     => $this->checkout->redirect_url,
1823
+			//		'headers_list'    => headers_list(),
1824
+			//	)
1825
+			//);
1826
+			wp_safe_redirect($this->checkout->redirect_url);
1827
+			exit();
1828
+		}
1829
+	}
1830
+
1831
+
1832
+
1833
+	/**
1834
+	 *   set_checkout_anchor
1835
+	 *
1836
+	 * @access public
1837
+	 * @return void
1838
+	 */
1839
+	public function set_checkout_anchor()
1840
+	{
1841
+		echo '<a id="checkout" style="float: left; margin-left: -999em;"></a>';
1842
+	}
1843
+
1844
+	/**
1845
+	 *    getRegistrationExpirationNotice
1846
+	 *
1847
+	 * @since 4.9.59.p
1848
+	 * @access    public
1849
+	 * @return    string
1850
+	 */
1851
+	public static function getRegistrationExpirationNotice()
1852
+	{
1853
+		return sprintf(
1854
+			__('%1$sWe\'re sorry, but your registration time has expired.%2$s%3$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please accept our apologies for any inconvenience this may have caused.%8$s',
1855
+				'event_espresso'),
1856
+			'<h4 class="important-notice">',
1857
+			'</h4>',
1858
+			'<br />',
1859
+			'<p>',
1860
+			'<a href="' . get_post_type_archive_link('espresso_events') . '" title="',
1861
+			'">',
1862
+			'</a>',
1863
+			'</p>'
1864
+		);
1865
+	}
1866 1866
 
1867 1867
 }
1868 1868
 // End of file EED_Single_Page_Checkout.module.php
Please login to merge, or discard this patch.