Completed
Branch BUG-9042-ics-organizer-email (7b2e23)
by
unknown
29:24 queued 16:15
created
modules/events_archive/EventsArchiveIframe.php 2 patches
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 use EventEspresso\core\libraries\iframe_display\Iframe;
5 5
 
6 6
 if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
7
-    exit( 'No direct script access allowed' );
7
+	exit( 'No direct script access allowed' );
8 8
 }
9 9
 
10 10
 
@@ -21,56 +21,56 @@  discard block
 block discarded – undo
21 21
 
22 22
 
23 23
 
24
-    /**
25
-     * EventsArchiveIframe constructor.
26
-     *
27
-     * @param \EED_Events_Archive $EED_Events_Archive
28
-     * @throws \DomainException
29
-     */
30
-    public function __construct( $EED_Events_Archive )
31
-    {
32
-        \EE_Registry::instance()->REQ->set_espresso_page( true );
33
-        add_filter('FHEE__EED_Events_Archive__event_list_iframe', '__return_true');
34
-        $EED_Events_Archive->event_list();
35
-        $event_list = new \EES_Espresso_Events();
36
-        parent::__construct(
37
-            esc_html__( 'Event List', 'event_espresso' ),
38
-            $event_list->process_shortcode()
39
-        );
40
-        $this->addStylesheets(
41
-            apply_filters(
42
-                'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
43
-                array(
44
-                    'espresso_default'           => is_readable( EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css' )
45
-                        ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION
46
-                        : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION,
47
-                ),
48
-                $this
49
-            )
50
-        );
51
-        $this->addScripts(
52
-            apply_filters(
53
-                'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js',
54
-                array(
55
-                    'gmap_api' => sprintf(
56
-                        'https://maps.googleapis.com/maps/api/js?key=%s',
57
-                        apply_filters(
58
-                            'FHEE__EEH_Maps__espresso_google_maps_js__api_key',
59
-                            \EE_Registry::instance()->CFG->map_settings->google_map_api_key
60
-                        )
61
-                    ),
62
-                    'ee_gmap'  => EE_HELPERS_ASSETS . 'ee_gmap.js?ver=1.0',
63
-                ),
64
-                $this
65
-            )
66
-        );
67
-        $this->addLocalizedVars(
68
-            array(
69
-                'ee_gmap' => \EEH_Maps::$gmap_vars,
70
-            ),
71
-            'ee_gmap_vars'
72
-        );
73
-    }
24
+	/**
25
+	 * EventsArchiveIframe constructor.
26
+	 *
27
+	 * @param \EED_Events_Archive $EED_Events_Archive
28
+	 * @throws \DomainException
29
+	 */
30
+	public function __construct( $EED_Events_Archive )
31
+	{
32
+		\EE_Registry::instance()->REQ->set_espresso_page( true );
33
+		add_filter('FHEE__EED_Events_Archive__event_list_iframe', '__return_true');
34
+		$EED_Events_Archive->event_list();
35
+		$event_list = new \EES_Espresso_Events();
36
+		parent::__construct(
37
+			esc_html__( 'Event List', 'event_espresso' ),
38
+			$event_list->process_shortcode()
39
+		);
40
+		$this->addStylesheets(
41
+			apply_filters(
42
+				'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
43
+				array(
44
+					'espresso_default'           => is_readable( EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css' )
45
+						? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION
46
+						: EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION,
47
+				),
48
+				$this
49
+			)
50
+		);
51
+		$this->addScripts(
52
+			apply_filters(
53
+				'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js',
54
+				array(
55
+					'gmap_api' => sprintf(
56
+						'https://maps.googleapis.com/maps/api/js?key=%s',
57
+						apply_filters(
58
+							'FHEE__EEH_Maps__espresso_google_maps_js__api_key',
59
+							\EE_Registry::instance()->CFG->map_settings->google_map_api_key
60
+						)
61
+					),
62
+					'ee_gmap'  => EE_HELPERS_ASSETS . 'ee_gmap.js?ver=1.0',
63
+				),
64
+				$this
65
+			)
66
+		);
67
+		$this->addLocalizedVars(
68
+			array(
69
+				'ee_gmap' => \EEH_Maps::$gmap_vars,
70
+			),
71
+			'ee_gmap_vars'
72
+		);
73
+	}
74 74
 
75 75
 
76 76
 
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -3,8 +3,8 @@  discard block
 block discarded – undo
3 3
 
4 4
 use EventEspresso\core\libraries\iframe_display\Iframe;
5 5
 
6
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
7
-    exit( 'No direct script access allowed' );
6
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
7
+    exit('No direct script access allowed');
8 8
 }
9 9
 
10 10
 
@@ -27,23 +27,23 @@  discard block
 block discarded – undo
27 27
      * @param \EED_Events_Archive $EED_Events_Archive
28 28
      * @throws \DomainException
29 29
      */
30
-    public function __construct( $EED_Events_Archive )
30
+    public function __construct($EED_Events_Archive)
31 31
     {
32
-        \EE_Registry::instance()->REQ->set_espresso_page( true );
32
+        \EE_Registry::instance()->REQ->set_espresso_page(true);
33 33
         add_filter('FHEE__EED_Events_Archive__event_list_iframe', '__return_true');
34 34
         $EED_Events_Archive->event_list();
35 35
         $event_list = new \EES_Espresso_Events();
36 36
         parent::__construct(
37
-            esc_html__( 'Event List', 'event_espresso' ),
37
+            esc_html__('Event List', 'event_espresso'),
38 38
             $event_list->process_shortcode()
39 39
         );
40 40
         $this->addStylesheets(
41 41
             apply_filters(
42 42
                 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
43 43
                 array(
44
-                    'espresso_default'           => is_readable( EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css' )
45
-                        ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION
46
-                        : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION,
44
+                    'espresso_default'           => is_readable(EVENT_ESPRESSO_UPLOAD_DIR.'css/style.css')
45
+                        ? EVENT_ESPRESSO_UPLOAD_DIR.'css/espresso_default.css?ver='.EVENT_ESPRESSO_VERSION
46
+                        : EE_GLOBAL_ASSETS_URL.'css/espresso_default.css?ver='.EVENT_ESPRESSO_VERSION,
47 47
                 ),
48 48
                 $this
49 49
             )
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
                             \EE_Registry::instance()->CFG->map_settings->google_map_api_key
60 60
                         )
61 61
                     ),
62
-                    'ee_gmap'  => EE_HELPERS_ASSETS . 'ee_gmap.js?ver=1.0',
62
+                    'ee_gmap'  => EE_HELPERS_ASSETS.'ee_gmap.js?ver=1.0',
63 63
                 ),
64 64
                 $this
65 65
             )
Please login to merge, or discard this patch.
core/libraries/iframe_display/Iframe.php 2 patches
Indentation   +306 added lines, -306 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 namespace EventEspresso\core\libraries\iframe_display;
3 3
 
4 4
 if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
5
-    exit( 'No direct script access allowed' );
5
+	exit( 'No direct script access allowed' );
6 6
 }
7 7
 
8 8
 
@@ -18,338 +18,338 @@  discard block
 block discarded – undo
18 18
 class Iframe
19 19
 {
20 20
 
21
-    /*
21
+	/*
22 22
     * HTML for notices and ajax gif
23 23
     * @var string $title
24 24
     */
25
-    protected $title = '';
25
+	protected $title = '';
26 26
 
27
-    /*
27
+	/*
28 28
     * HTML for the content being displayed
29 29
     * @var string $content
30 30
     */
31
-    protected $content = '';
31
+	protected $content = '';
32 32
 
33
-    /*
33
+	/*
34 34
     * whether or not to call wp_head() and wp_footer()
35 35
     * @var boolean $enqueue_wp_assets
36 36
     */
37
-    protected $enqueue_wp_assets = false;
37
+	protected $enqueue_wp_assets = false;
38 38
 
39
-    /*
39
+	/*
40 40
     * an array of CSS URLs
41 41
     * @var array $css
42 42
     */
43
-    protected $css = array();
43
+	protected $css = array();
44 44
 
45
-    /*
45
+	/*
46 46
     * an array of JS URLs to be set in the HTML header.
47 47
     * @var array $header_js
48 48
     */
49
-    protected $header_js = array();
49
+	protected $header_js = array();
50 50
 
51
-    /*
51
+	/*
52 52
     * an array of JS URLs to be displayed before the HTML </body> tag
53 53
     * @var array $footer_js
54 54
     */
55
-    protected $footer_js = array();
55
+	protected $footer_js = array();
56 56
 
57
-    /*
57
+	/*
58 58
     * an array of JSON vars to be set in the HTML header.
59 59
     * @var array $localized_vars
60 60
     */
61
-    protected $localized_vars = array();
62
-
63
-
64
-
65
-    /**
66
-     * Iframe constructor
67
-     *
68
-     * @param string $title
69
-     * @param string $content
70
-     * @throws \DomainException
71
-     */
72
-    public function __construct( $title, $content )
73
-    {
74
-        global $wp_version;
75
-        if ( ! defined( 'EE_IFRAME_DIR_URL' ) ) {
76
-            define( 'EE_IFRAME_DIR_URL', plugin_dir_url( __FILE__ ) );
77
-        }
78
-        $this->setContent( $content );
79
-        $this->setTitle( $title );
80
-        $this->addStylesheets(
81
-            apply_filters(
82
-                'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_css',
83
-                array(
84
-                    'site_theme'       => get_stylesheet_directory_uri() . DS
85
-                                          . 'style.css?ver=' . EVENT_ESPRESSO_VERSION,
86
-                    'dashicons'        => includes_url( 'css/dashicons.min.css?ver=' . $wp_version ),
87
-                    'espresso_default' => EE_GLOBAL_ASSETS_URL
88
-                                          . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION,
89
-                ),
90
-                $this
91
-            )
92
-        );
93
-        $this->addScripts(
94
-            apply_filters(
95
-                'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_js',
96
-                array(
97
-                    'jquery'        => includes_url( 'js/jquery/jquery.js?ver=' . $wp_version ),
98
-                    'espresso_core' => EE_GLOBAL_ASSETS_URL
99
-                                       . 'scripts/espresso_core.js?ver=' . EVENT_ESPRESSO_VERSION,
100
-                ),
101
-                $this
102
-            )
103
-        );
104
-        if (
105
-            apply_filters(
106
-                'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__load_default_theme_stylesheet',
107
-                false
108
-            )
109
-        ) {
110
-            $this->addStylesheets(
111
-                apply_filters(
112
-                    'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_theme_stylesheet',
113
-                    array('default_theme_stylesheet' => get_stylesheet_uri()),
114
-                    $this
115
-                )
116
-            );
117
-        }
118
-    }
119
-
120
-
121
-
122
-    /**
123
-     * @param string $title
124
-     * @throws \DomainException
125
-     */
126
-    public function setTitle( $title )
127
-    {
128
-        if ( empty( $title ) ) {
129
-            throw new \DomainException(
130
-                esc_html__( 'You must provide a page title in order to create an iframe.', 'event_espresso' )
131
-            );
132
-        }
133
-        $this->title = $title;
134
-    }
135
-
136
-
137
-
138
-    /**
139
-     * @param string $content
140
-     * @throws \DomainException
141
-     */
142
-    public function setContent( $content )
143
-    {
144
-        if ( empty( $content ) ) {
145
-            throw new \DomainException(
146
-                esc_html__( 'You must provide content in order to create an iframe.', 'event_espresso' )
147
-            );
148
-        }
149
-        $this->content = $content;
150
-    }
151
-
152
-
153
-
154
-    /**
155
-     * @param boolean $enqueue_wp_assets
156
-     */
157
-    public function setEnqueueWpAssets( $enqueue_wp_assets )
158
-    {
159
-        $this->enqueue_wp_assets = filter_var( $enqueue_wp_assets, FILTER_VALIDATE_BOOLEAN );
160
-    }
161
-
162
-
163
-
164
-    /**
165
-     * @param array $stylesheets
166
-     * @throws \DomainException
167
-     */
168
-    public function addStylesheets( array $stylesheets )
169
-    {
170
-        if ( empty( $stylesheets ) ) {
171
-            throw new \DomainException(
172
-                esc_html__(
173
-                    'A non-empty array of URLs, is required to add a CSS stylesheet to an iframe.',
174
-                    'event_espresso'
175
-                )
176
-            );
177
-        }
178
-        foreach ( $stylesheets as $handle => $stylesheet ) {
179
-            $this->css[ $handle ] = $stylesheet;
180
-        }
181
-    }
182
-
183
-
184
-
185
-    /**
186
-     * @param array $scripts
187
-     * @param bool  $add_to_header
188
-     * @throws \DomainException
189
-     */
190
-    public function addScripts( array $scripts, $add_to_header = false )
191
-    {
192
-        if ( empty( $scripts ) ) {
193
-            throw new \DomainException(
194
-                esc_html__(
195
-                    'A non-empty array of URLs, is required to add Javascript to an iframe.',
196
-                    'event_espresso'
197
-                )
198
-            );
199
-        }
200
-        foreach ( $scripts as $handle => $script ) {
201
-            if ( $add_to_header ) {
202
-                $this->header_js[ $handle ] = $script;
203
-            } else {
204
-                $this->footer_js[ $handle ] = $script;
205
-            }
206
-        }
207
-    }
208
-
209
-
210
-
211
-    /**
212
-     * @param array  $vars
213
-     * @param string $var_name
214
-     * @throws \DomainException
215
-     */
216
-    public function addLocalizedVars( array $vars, $var_name = 'eei18n' )
217
-    {
218
-        if ( empty( $vars ) ) {
219
-            throw new \DomainException(
220
-                esc_html__(
221
-                    'A non-empty array of vars, is required to add localized Javascript vars to an iframe.',
222
-                    'event_espresso'
223
-                )
224
-            );
225
-        }
226
-        foreach ( $vars as $handle => $var ) {
227
-            if ( $var_name === 'eei18n' ) {
228
-                \EE_Registry::$i18n_js_strings[ $handle ] = $var;
229
-            } else {
230
-                if ( ! isset( $this->localized_vars[ $var_name ] ) ) {
231
-                    $this->localized_vars[ $var_name ] = array();
232
-                }
233
-                $this->localized_vars[ $var_name ][ $handle ] = $var;
234
-            }
235
-        }
236
-    }
237
-
238
-
239
-
240
-    /**
241
-     * @param string $utm_content
242
-     * @throws \DomainException
243
-     */
244
-    public function display($utm_content = '')
245
-    {
246
-        $this->content .= \EEH_Template::powered_by_event_espresso(
247
-            '',
248
-            '',
249
-            ! empty($utm_content) ? array('utm_content' => $utm_content) : array()
250
-        );
251
-        \EE_System::do_not_cache();
252
-        echo $this->getTemplate();
253
-        exit;
254
-    }
255
-
256
-
257
-
258
-    /**
259
-     * @return string
260
-     * @throws \DomainException
261
-     */
262
-    public function getTemplate()
263
-    {
264
-        return \EEH_Template::display_template(
265
-            __DIR__ . DIRECTORY_SEPARATOR . 'iframe_wrapper.template.php',
266
-            array(
267
-                'title'             => apply_filters(
268
-                    'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__title',
269
-                    $this->title,
270
-                    $this
271
-                ),
272
-                'content'           => apply_filters(
273
-                    'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__content',
274
-                    $this->content,
275
-                    $this
276
-                ),
277
-                'enqueue_wp_assets' => apply_filters(
278
-                    'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__enqueue_wp_assets',
279
-                    $this->enqueue_wp_assets,
280
-                    $this
281
-                ),
282
-                'css'               => (array)apply_filters(
283
-                    'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__css_urls',
284
-                    $this->css,
285
-                    $this
286
-                ),
287
-                'header_js'         => (array)apply_filters(
288
-                    'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__header_js_urls',
289
-                    $this->header_js,
290
-                    $this
291
-                ),
292
-                'footer_js'         => (array)apply_filters(
293
-                    'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__footer_js_urls',
294
-                    $this->footer_js,
295
-                    $this
296
-                ),
297
-                'eei18n'            => apply_filters(
298
-                    'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__eei18n_js_strings',
299
-                    \EE_Registry::localize_i18n_js_strings() . $this->localizeJsonVars(),
300
-                    $this
301
-                ),
302
-                'notices'           => \EEH_Template::display_template(
303
-                    EE_TEMPLATES . 'espresso-ajax-notices.template.php',
304
-                    array(),
305
-                    true
306
-                ),
307
-            ),
308
-            true,
309
-            true
310
-        );
311
-    }
312
-
313
-
314
-
315
-    /**
316
-     * localizeJsonVars
317
-     *
318
-     * @return string
319
-     */
320
-    public function localizeJsonVars()
321
-    {
322
-        $JSON = '';
323
-        foreach ( (array)$this->localized_vars as $var_name => $vars ) {
324
-            foreach ( (array)$vars as $key => $value ) {
325
-                $this->localized_vars[ $var_name ] = $this->encodeJsonVars( $value );
326
-            }
327
-            $JSON .= "/* <![CDATA[ */ var {$var_name} = ";
328
-            $JSON .= wp_json_encode( $this->localized_vars[ $var_name ] );
329
-            $JSON .= '; /* ]]> */';
330
-        }
331
-        return $JSON;
332
-    }
333
-
334
-
335
-
336
-    /**
337
-     * @param bool|int|float|string|array $var
338
-     * @return array
339
-     */
340
-    public function encodeJsonVars( $var )
341
-    {
342
-        if ( is_array( $var ) ) {
343
-            $localized_vars = array();
344
-            foreach ( (array)$var as $key => $value ) {
345
-                $localized_vars[ $key ] = $this->encodeJsonVars( $value );
346
-            }
347
-            return $localized_vars;
348
-        } else if ( is_scalar( $var ) ) {
349
-            return html_entity_decode( (string)$var, ENT_QUOTES, 'UTF-8' );
350
-        }
351
-        return null;
352
-    }
61
+	protected $localized_vars = array();
62
+
63
+
64
+
65
+	/**
66
+	 * Iframe constructor
67
+	 *
68
+	 * @param string $title
69
+	 * @param string $content
70
+	 * @throws \DomainException
71
+	 */
72
+	public function __construct( $title, $content )
73
+	{
74
+		global $wp_version;
75
+		if ( ! defined( 'EE_IFRAME_DIR_URL' ) ) {
76
+			define( 'EE_IFRAME_DIR_URL', plugin_dir_url( __FILE__ ) );
77
+		}
78
+		$this->setContent( $content );
79
+		$this->setTitle( $title );
80
+		$this->addStylesheets(
81
+			apply_filters(
82
+				'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_css',
83
+				array(
84
+					'site_theme'       => get_stylesheet_directory_uri() . DS
85
+										  . 'style.css?ver=' . EVENT_ESPRESSO_VERSION,
86
+					'dashicons'        => includes_url( 'css/dashicons.min.css?ver=' . $wp_version ),
87
+					'espresso_default' => EE_GLOBAL_ASSETS_URL
88
+										  . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION,
89
+				),
90
+				$this
91
+			)
92
+		);
93
+		$this->addScripts(
94
+			apply_filters(
95
+				'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_js',
96
+				array(
97
+					'jquery'        => includes_url( 'js/jquery/jquery.js?ver=' . $wp_version ),
98
+					'espresso_core' => EE_GLOBAL_ASSETS_URL
99
+									   . 'scripts/espresso_core.js?ver=' . EVENT_ESPRESSO_VERSION,
100
+				),
101
+				$this
102
+			)
103
+		);
104
+		if (
105
+			apply_filters(
106
+				'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__load_default_theme_stylesheet',
107
+				false
108
+			)
109
+		) {
110
+			$this->addStylesheets(
111
+				apply_filters(
112
+					'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_theme_stylesheet',
113
+					array('default_theme_stylesheet' => get_stylesheet_uri()),
114
+					$this
115
+				)
116
+			);
117
+		}
118
+	}
119
+
120
+
121
+
122
+	/**
123
+	 * @param string $title
124
+	 * @throws \DomainException
125
+	 */
126
+	public function setTitle( $title )
127
+	{
128
+		if ( empty( $title ) ) {
129
+			throw new \DomainException(
130
+				esc_html__( 'You must provide a page title in order to create an iframe.', 'event_espresso' )
131
+			);
132
+		}
133
+		$this->title = $title;
134
+	}
135
+
136
+
137
+
138
+	/**
139
+	 * @param string $content
140
+	 * @throws \DomainException
141
+	 */
142
+	public function setContent( $content )
143
+	{
144
+		if ( empty( $content ) ) {
145
+			throw new \DomainException(
146
+				esc_html__( 'You must provide content in order to create an iframe.', 'event_espresso' )
147
+			);
148
+		}
149
+		$this->content = $content;
150
+	}
151
+
152
+
153
+
154
+	/**
155
+	 * @param boolean $enqueue_wp_assets
156
+	 */
157
+	public function setEnqueueWpAssets( $enqueue_wp_assets )
158
+	{
159
+		$this->enqueue_wp_assets = filter_var( $enqueue_wp_assets, FILTER_VALIDATE_BOOLEAN );
160
+	}
161
+
162
+
163
+
164
+	/**
165
+	 * @param array $stylesheets
166
+	 * @throws \DomainException
167
+	 */
168
+	public function addStylesheets( array $stylesheets )
169
+	{
170
+		if ( empty( $stylesheets ) ) {
171
+			throw new \DomainException(
172
+				esc_html__(
173
+					'A non-empty array of URLs, is required to add a CSS stylesheet to an iframe.',
174
+					'event_espresso'
175
+				)
176
+			);
177
+		}
178
+		foreach ( $stylesheets as $handle => $stylesheet ) {
179
+			$this->css[ $handle ] = $stylesheet;
180
+		}
181
+	}
182
+
183
+
184
+
185
+	/**
186
+	 * @param array $scripts
187
+	 * @param bool  $add_to_header
188
+	 * @throws \DomainException
189
+	 */
190
+	public function addScripts( array $scripts, $add_to_header = false )
191
+	{
192
+		if ( empty( $scripts ) ) {
193
+			throw new \DomainException(
194
+				esc_html__(
195
+					'A non-empty array of URLs, is required to add Javascript to an iframe.',
196
+					'event_espresso'
197
+				)
198
+			);
199
+		}
200
+		foreach ( $scripts as $handle => $script ) {
201
+			if ( $add_to_header ) {
202
+				$this->header_js[ $handle ] = $script;
203
+			} else {
204
+				$this->footer_js[ $handle ] = $script;
205
+			}
206
+		}
207
+	}
208
+
209
+
210
+
211
+	/**
212
+	 * @param array  $vars
213
+	 * @param string $var_name
214
+	 * @throws \DomainException
215
+	 */
216
+	public function addLocalizedVars( array $vars, $var_name = 'eei18n' )
217
+	{
218
+		if ( empty( $vars ) ) {
219
+			throw new \DomainException(
220
+				esc_html__(
221
+					'A non-empty array of vars, is required to add localized Javascript vars to an iframe.',
222
+					'event_espresso'
223
+				)
224
+			);
225
+		}
226
+		foreach ( $vars as $handle => $var ) {
227
+			if ( $var_name === 'eei18n' ) {
228
+				\EE_Registry::$i18n_js_strings[ $handle ] = $var;
229
+			} else {
230
+				if ( ! isset( $this->localized_vars[ $var_name ] ) ) {
231
+					$this->localized_vars[ $var_name ] = array();
232
+				}
233
+				$this->localized_vars[ $var_name ][ $handle ] = $var;
234
+			}
235
+		}
236
+	}
237
+
238
+
239
+
240
+	/**
241
+	 * @param string $utm_content
242
+	 * @throws \DomainException
243
+	 */
244
+	public function display($utm_content = '')
245
+	{
246
+		$this->content .= \EEH_Template::powered_by_event_espresso(
247
+			'',
248
+			'',
249
+			! empty($utm_content) ? array('utm_content' => $utm_content) : array()
250
+		);
251
+		\EE_System::do_not_cache();
252
+		echo $this->getTemplate();
253
+		exit;
254
+	}
255
+
256
+
257
+
258
+	/**
259
+	 * @return string
260
+	 * @throws \DomainException
261
+	 */
262
+	public function getTemplate()
263
+	{
264
+		return \EEH_Template::display_template(
265
+			__DIR__ . DIRECTORY_SEPARATOR . 'iframe_wrapper.template.php',
266
+			array(
267
+				'title'             => apply_filters(
268
+					'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__title',
269
+					$this->title,
270
+					$this
271
+				),
272
+				'content'           => apply_filters(
273
+					'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__content',
274
+					$this->content,
275
+					$this
276
+				),
277
+				'enqueue_wp_assets' => apply_filters(
278
+					'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__enqueue_wp_assets',
279
+					$this->enqueue_wp_assets,
280
+					$this
281
+				),
282
+				'css'               => (array)apply_filters(
283
+					'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__css_urls',
284
+					$this->css,
285
+					$this
286
+				),
287
+				'header_js'         => (array)apply_filters(
288
+					'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__header_js_urls',
289
+					$this->header_js,
290
+					$this
291
+				),
292
+				'footer_js'         => (array)apply_filters(
293
+					'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__footer_js_urls',
294
+					$this->footer_js,
295
+					$this
296
+				),
297
+				'eei18n'            => apply_filters(
298
+					'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__eei18n_js_strings',
299
+					\EE_Registry::localize_i18n_js_strings() . $this->localizeJsonVars(),
300
+					$this
301
+				),
302
+				'notices'           => \EEH_Template::display_template(
303
+					EE_TEMPLATES . 'espresso-ajax-notices.template.php',
304
+					array(),
305
+					true
306
+				),
307
+			),
308
+			true,
309
+			true
310
+		);
311
+	}
312
+
313
+
314
+
315
+	/**
316
+	 * localizeJsonVars
317
+	 *
318
+	 * @return string
319
+	 */
320
+	public function localizeJsonVars()
321
+	{
322
+		$JSON = '';
323
+		foreach ( (array)$this->localized_vars as $var_name => $vars ) {
324
+			foreach ( (array)$vars as $key => $value ) {
325
+				$this->localized_vars[ $var_name ] = $this->encodeJsonVars( $value );
326
+			}
327
+			$JSON .= "/* <![CDATA[ */ var {$var_name} = ";
328
+			$JSON .= wp_json_encode( $this->localized_vars[ $var_name ] );
329
+			$JSON .= '; /* ]]> */';
330
+		}
331
+		return $JSON;
332
+	}
333
+
334
+
335
+
336
+	/**
337
+	 * @param bool|int|float|string|array $var
338
+	 * @return array
339
+	 */
340
+	public function encodeJsonVars( $var )
341
+	{
342
+		if ( is_array( $var ) ) {
343
+			$localized_vars = array();
344
+			foreach ( (array)$var as $key => $value ) {
345
+				$localized_vars[ $key ] = $this->encodeJsonVars( $value );
346
+			}
347
+			return $localized_vars;
348
+		} else if ( is_scalar( $var ) ) {
349
+			return html_entity_decode( (string)$var, ENT_QUOTES, 'UTF-8' );
350
+		}
351
+		return null;
352
+	}
353 353
 
354 354
 
355 355
 
Please login to merge, or discard this patch.
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace EventEspresso\core\libraries\iframe_display;
3 3
 
4
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
5
-    exit( 'No direct script access allowed' );
4
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
5
+    exit('No direct script access allowed');
6 6
 }
7 7
 
8 8
 
@@ -69,23 +69,23 @@  discard block
 block discarded – undo
69 69
      * @param string $content
70 70
      * @throws \DomainException
71 71
      */
72
-    public function __construct( $title, $content )
72
+    public function __construct($title, $content)
73 73
     {
74 74
         global $wp_version;
75
-        if ( ! defined( 'EE_IFRAME_DIR_URL' ) ) {
76
-            define( 'EE_IFRAME_DIR_URL', plugin_dir_url( __FILE__ ) );
75
+        if ( ! defined('EE_IFRAME_DIR_URL')) {
76
+            define('EE_IFRAME_DIR_URL', plugin_dir_url(__FILE__));
77 77
         }
78
-        $this->setContent( $content );
79
-        $this->setTitle( $title );
78
+        $this->setContent($content);
79
+        $this->setTitle($title);
80 80
         $this->addStylesheets(
81 81
             apply_filters(
82 82
                 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_css',
83 83
                 array(
84
-                    'site_theme'       => get_stylesheet_directory_uri() . DS
85
-                                          . 'style.css?ver=' . EVENT_ESPRESSO_VERSION,
86
-                    'dashicons'        => includes_url( 'css/dashicons.min.css?ver=' . $wp_version ),
84
+                    'site_theme'       => get_stylesheet_directory_uri().DS
85
+                                          . 'style.css?ver='.EVENT_ESPRESSO_VERSION,
86
+                    'dashicons'        => includes_url('css/dashicons.min.css?ver='.$wp_version),
87 87
                     'espresso_default' => EE_GLOBAL_ASSETS_URL
88
-                                          . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION,
88
+                                          . 'css/espresso_default.css?ver='.EVENT_ESPRESSO_VERSION,
89 89
                 ),
90 90
                 $this
91 91
             )
@@ -94,9 +94,9 @@  discard block
 block discarded – undo
94 94
             apply_filters(
95 95
                 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_js',
96 96
                 array(
97
-                    'jquery'        => includes_url( 'js/jquery/jquery.js?ver=' . $wp_version ),
97
+                    'jquery'        => includes_url('js/jquery/jquery.js?ver='.$wp_version),
98 98
                     'espresso_core' => EE_GLOBAL_ASSETS_URL
99
-                                       . 'scripts/espresso_core.js?ver=' . EVENT_ESPRESSO_VERSION,
99
+                                       . 'scripts/espresso_core.js?ver='.EVENT_ESPRESSO_VERSION,
100 100
                 ),
101 101
                 $this
102 102
             )
@@ -123,11 +123,11 @@  discard block
 block discarded – undo
123 123
      * @param string $title
124 124
      * @throws \DomainException
125 125
      */
126
-    public function setTitle( $title )
126
+    public function setTitle($title)
127 127
     {
128
-        if ( empty( $title ) ) {
128
+        if (empty($title)) {
129 129
             throw new \DomainException(
130
-                esc_html__( 'You must provide a page title in order to create an iframe.', 'event_espresso' )
130
+                esc_html__('You must provide a page title in order to create an iframe.', 'event_espresso')
131 131
             );
132 132
         }
133 133
         $this->title = $title;
@@ -139,11 +139,11 @@  discard block
 block discarded – undo
139 139
      * @param string $content
140 140
      * @throws \DomainException
141 141
      */
142
-    public function setContent( $content )
142
+    public function setContent($content)
143 143
     {
144
-        if ( empty( $content ) ) {
144
+        if (empty($content)) {
145 145
             throw new \DomainException(
146
-                esc_html__( 'You must provide content in order to create an iframe.', 'event_espresso' )
146
+                esc_html__('You must provide content in order to create an iframe.', 'event_espresso')
147 147
             );
148 148
         }
149 149
         $this->content = $content;
@@ -154,9 +154,9 @@  discard block
 block discarded – undo
154 154
     /**
155 155
      * @param boolean $enqueue_wp_assets
156 156
      */
157
-    public function setEnqueueWpAssets( $enqueue_wp_assets )
157
+    public function setEnqueueWpAssets($enqueue_wp_assets)
158 158
     {
159
-        $this->enqueue_wp_assets = filter_var( $enqueue_wp_assets, FILTER_VALIDATE_BOOLEAN );
159
+        $this->enqueue_wp_assets = filter_var($enqueue_wp_assets, FILTER_VALIDATE_BOOLEAN);
160 160
     }
161 161
 
162 162
 
@@ -165,9 +165,9 @@  discard block
 block discarded – undo
165 165
      * @param array $stylesheets
166 166
      * @throws \DomainException
167 167
      */
168
-    public function addStylesheets( array $stylesheets )
168
+    public function addStylesheets(array $stylesheets)
169 169
     {
170
-        if ( empty( $stylesheets ) ) {
170
+        if (empty($stylesheets)) {
171 171
             throw new \DomainException(
172 172
                 esc_html__(
173 173
                     'A non-empty array of URLs, is required to add a CSS stylesheet to an iframe.',
@@ -175,8 +175,8 @@  discard block
 block discarded – undo
175 175
                 )
176 176
             );
177 177
         }
178
-        foreach ( $stylesheets as $handle => $stylesheet ) {
179
-            $this->css[ $handle ] = $stylesheet;
178
+        foreach ($stylesheets as $handle => $stylesheet) {
179
+            $this->css[$handle] = $stylesheet;
180 180
         }
181 181
     }
182 182
 
@@ -187,9 +187,9 @@  discard block
 block discarded – undo
187 187
      * @param bool  $add_to_header
188 188
      * @throws \DomainException
189 189
      */
190
-    public function addScripts( array $scripts, $add_to_header = false )
190
+    public function addScripts(array $scripts, $add_to_header = false)
191 191
     {
192
-        if ( empty( $scripts ) ) {
192
+        if (empty($scripts)) {
193 193
             throw new \DomainException(
194 194
                 esc_html__(
195 195
                     'A non-empty array of URLs, is required to add Javascript to an iframe.',
@@ -197,11 +197,11 @@  discard block
 block discarded – undo
197 197
                 )
198 198
             );
199 199
         }
200
-        foreach ( $scripts as $handle => $script ) {
201
-            if ( $add_to_header ) {
202
-                $this->header_js[ $handle ] = $script;
200
+        foreach ($scripts as $handle => $script) {
201
+            if ($add_to_header) {
202
+                $this->header_js[$handle] = $script;
203 203
             } else {
204
-                $this->footer_js[ $handle ] = $script;
204
+                $this->footer_js[$handle] = $script;
205 205
             }
206 206
         }
207 207
     }
@@ -213,9 +213,9 @@  discard block
 block discarded – undo
213 213
      * @param string $var_name
214 214
      * @throws \DomainException
215 215
      */
216
-    public function addLocalizedVars( array $vars, $var_name = 'eei18n' )
216
+    public function addLocalizedVars(array $vars, $var_name = 'eei18n')
217 217
     {
218
-        if ( empty( $vars ) ) {
218
+        if (empty($vars)) {
219 219
             throw new \DomainException(
220 220
                 esc_html__(
221 221
                     'A non-empty array of vars, is required to add localized Javascript vars to an iframe.',
@@ -223,14 +223,14 @@  discard block
 block discarded – undo
223 223
                 )
224 224
             );
225 225
         }
226
-        foreach ( $vars as $handle => $var ) {
227
-            if ( $var_name === 'eei18n' ) {
228
-                \EE_Registry::$i18n_js_strings[ $handle ] = $var;
226
+        foreach ($vars as $handle => $var) {
227
+            if ($var_name === 'eei18n') {
228
+                \EE_Registry::$i18n_js_strings[$handle] = $var;
229 229
             } else {
230
-                if ( ! isset( $this->localized_vars[ $var_name ] ) ) {
231
-                    $this->localized_vars[ $var_name ] = array();
230
+                if ( ! isset($this->localized_vars[$var_name])) {
231
+                    $this->localized_vars[$var_name] = array();
232 232
                 }
233
-                $this->localized_vars[ $var_name ][ $handle ] = $var;
233
+                $this->localized_vars[$var_name][$handle] = $var;
234 234
             }
235 235
         }
236 236
     }
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
     public function getTemplate()
263 263
     {
264 264
         return \EEH_Template::display_template(
265
-            __DIR__ . DIRECTORY_SEPARATOR . 'iframe_wrapper.template.php',
265
+            __DIR__.DIRECTORY_SEPARATOR.'iframe_wrapper.template.php',
266 266
             array(
267 267
                 'title'             => apply_filters(
268 268
                     'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__title',
@@ -279,28 +279,28 @@  discard block
 block discarded – undo
279 279
                     $this->enqueue_wp_assets,
280 280
                     $this
281 281
                 ),
282
-                'css'               => (array)apply_filters(
282
+                'css'               => (array) apply_filters(
283 283
                     'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__css_urls',
284 284
                     $this->css,
285 285
                     $this
286 286
                 ),
287
-                'header_js'         => (array)apply_filters(
287
+                'header_js'         => (array) apply_filters(
288 288
                     'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__header_js_urls',
289 289
                     $this->header_js,
290 290
                     $this
291 291
                 ),
292
-                'footer_js'         => (array)apply_filters(
292
+                'footer_js'         => (array) apply_filters(
293 293
                     'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__footer_js_urls',
294 294
                     $this->footer_js,
295 295
                     $this
296 296
                 ),
297 297
                 'eei18n'            => apply_filters(
298 298
                     'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__eei18n_js_strings',
299
-                    \EE_Registry::localize_i18n_js_strings() . $this->localizeJsonVars(),
299
+                    \EE_Registry::localize_i18n_js_strings().$this->localizeJsonVars(),
300 300
                     $this
301 301
                 ),
302 302
                 'notices'           => \EEH_Template::display_template(
303
-                    EE_TEMPLATES . 'espresso-ajax-notices.template.php',
303
+                    EE_TEMPLATES.'espresso-ajax-notices.template.php',
304 304
                     array(),
305 305
                     true
306 306
                 ),
@@ -320,12 +320,12 @@  discard block
 block discarded – undo
320 320
     public function localizeJsonVars()
321 321
     {
322 322
         $JSON = '';
323
-        foreach ( (array)$this->localized_vars as $var_name => $vars ) {
324
-            foreach ( (array)$vars as $key => $value ) {
325
-                $this->localized_vars[ $var_name ] = $this->encodeJsonVars( $value );
323
+        foreach ((array) $this->localized_vars as $var_name => $vars) {
324
+            foreach ((array) $vars as $key => $value) {
325
+                $this->localized_vars[$var_name] = $this->encodeJsonVars($value);
326 326
             }
327 327
             $JSON .= "/* <![CDATA[ */ var {$var_name} = ";
328
-            $JSON .= wp_json_encode( $this->localized_vars[ $var_name ] );
328
+            $JSON .= wp_json_encode($this->localized_vars[$var_name]);
329 329
             $JSON .= '; /* ]]> */';
330 330
         }
331 331
         return $JSON;
@@ -337,16 +337,16 @@  discard block
 block discarded – undo
337 337
      * @param bool|int|float|string|array $var
338 338
      * @return array
339 339
      */
340
-    public function encodeJsonVars( $var )
340
+    public function encodeJsonVars($var)
341 341
     {
342
-        if ( is_array( $var ) ) {
342
+        if (is_array($var)) {
343 343
             $localized_vars = array();
344
-            foreach ( (array)$var as $key => $value ) {
345
-                $localized_vars[ $key ] = $this->encodeJsonVars( $value );
344
+            foreach ((array) $var as $key => $value) {
345
+                $localized_vars[$key] = $this->encodeJsonVars($value);
346 346
             }
347 347
             return $localized_vars;
348
-        } else if ( is_scalar( $var ) ) {
349
-            return html_entity_decode( (string)$var, ENT_QUOTES, 'UTF-8' );
348
+        } else if (is_scalar($var)) {
349
+            return html_entity_decode((string) $var, ENT_QUOTES, 'UTF-8');
350 350
         }
351 351
         return null;
352 352
     }
Please login to merge, or discard this patch.
form_sections/inputs/EE_Checkbox_Dropdown_Selector_Input.input.php 2 patches
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 
5 5
 
@@ -17,65 +17,65 @@  discard block
 block discarded – undo
17 17
 class EE_Checkbox_Dropdown_Selector_Input extends EE_Form_Input_With_Options_Base
18 18
 {
19 19
 
20
-    /**
21
-     * @var string text to display on the select button itself
22
-     */
23
-    protected $_select_button_text;
20
+	/**
21
+	 * @var string text to display on the select button itself
22
+	 */
23
+	protected $_select_button_text;
24 24
 
25
-    /**
26
-     * @param array $answer_options
27
-     * @param array $input_settings
28
-     */
29
-    public function __construct($answer_options, $input_settings = array())
30
-    {
31
-        $this->_select_button_text = EEH_Array::is_set( $input_settings, 'select_button_text',
32
-            esc_html__('Select', 'event_espresso'));
33
-        $display_strategy = new EE_Checkbox_Dropdown_Selector_Display_Strategy();
34
-        $this->_set_display_strategy($display_strategy);
35
-        $this->load_iframe_assets($display_strategy);
36
-        $this->_add_validation_strategy(
37
-            new EE_Many_Valued_Validation_Strategy(
38
-                array(
39
-                    new EE_Enum_Validation_Strategy(
40
-                        isset($input_settings['validation_error_message'])
41
-                            ? $input_settings['validation_error_message']
42
-                            : null
43
-                    ),
44
-                )
45
-            )
46
-        );
47
-        $this->_multiple_selections = true;
48
-        parent::__construct($answer_options, $input_settings);
49
-    }
25
+	/**
26
+	 * @param array $answer_options
27
+	 * @param array $input_settings
28
+	 */
29
+	public function __construct($answer_options, $input_settings = array())
30
+	{
31
+		$this->_select_button_text = EEH_Array::is_set( $input_settings, 'select_button_text',
32
+			esc_html__('Select', 'event_espresso'));
33
+		$display_strategy = new EE_Checkbox_Dropdown_Selector_Display_Strategy();
34
+		$this->_set_display_strategy($display_strategy);
35
+		$this->load_iframe_assets($display_strategy);
36
+		$this->_add_validation_strategy(
37
+			new EE_Many_Valued_Validation_Strategy(
38
+				array(
39
+					new EE_Enum_Validation_Strategy(
40
+						isset($input_settings['validation_error_message'])
41
+							? $input_settings['validation_error_message']
42
+							: null
43
+					),
44
+				)
45
+			)
46
+		);
47
+		$this->_multiple_selections = true;
48
+		parent::__construct($answer_options, $input_settings);
49
+	}
50 50
 
51
-    /*
51
+	/*
52 52
      * Returns the text to display in the select button
53 53
      */
54
-    public function select_button_text(){
55
-        return $this->_select_button_text;
56
-    }
54
+	public function select_button_text(){
55
+		return $this->_select_button_text;
56
+	}
57 57
 
58
-    /*
58
+	/*
59 59
      * add css and js for iframes
60 60
      */
61
-    protected function load_iframe_assets(EE_Checkbox_Dropdown_Selector_Display_Strategy $display_strategy){
62
-        add_filter(
63
-            'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css',
64
-            array($display_strategy, 'iframe_css')
65
-        );
66
-        add_filter(
67
-            'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
68
-            array($display_strategy, 'iframe_js')
69
-        );
70
-        add_filter(
71
-            'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
72
-            array($display_strategy, 'iframe_css')
73
-        );
74
-        add_filter(
75
-            'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js',
76
-            array($display_strategy, 'iframe_js')
77
-        );
78
-    }
61
+	protected function load_iframe_assets(EE_Checkbox_Dropdown_Selector_Display_Strategy $display_strategy){
62
+		add_filter(
63
+			'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css',
64
+			array($display_strategy, 'iframe_css')
65
+		);
66
+		add_filter(
67
+			'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
68
+			array($display_strategy, 'iframe_js')
69
+		);
70
+		add_filter(
71
+			'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
72
+			array($display_strategy, 'iframe_css')
73
+		);
74
+		add_filter(
75
+			'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js',
76
+			array($display_strategy, 'iframe_js')
77
+		);
78
+	}
79 79
 
80 80
 
81 81
 }
82 82
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
      */
29 29
     public function __construct($answer_options, $input_settings = array())
30 30
     {
31
-        $this->_select_button_text = EEH_Array::is_set( $input_settings, 'select_button_text',
31
+        $this->_select_button_text = EEH_Array::is_set($input_settings, 'select_button_text',
32 32
             esc_html__('Select', 'event_espresso'));
33 33
         $display_strategy = new EE_Checkbox_Dropdown_Selector_Display_Strategy();
34 34
         $this->_set_display_strategy($display_strategy);
@@ -51,14 +51,14 @@  discard block
 block discarded – undo
51 51
     /*
52 52
      * Returns the text to display in the select button
53 53
      */
54
-    public function select_button_text(){
54
+    public function select_button_text() {
55 55
         return $this->_select_button_text;
56 56
     }
57 57
 
58 58
     /*
59 59
      * add css and js for iframes
60 60
      */
61
-    protected function load_iframe_assets(EE_Checkbox_Dropdown_Selector_Display_Strategy $display_strategy){
61
+    protected function load_iframe_assets(EE_Checkbox_Dropdown_Selector_Display_Strategy $display_strategy) {
62 62
         add_filter(
63 63
             'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css',
64 64
             array($display_strategy, 'iframe_css')
Please login to merge, or discard this patch.
admin_pages/events/Events_Admin_Page.core.php 2 patches
Indentation   +2567 added lines, -2567 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
-    exit('NO direct script access allowed');
3
+	exit('NO direct script access allowed');
4 4
 }
5 5
 
6 6
 
@@ -17,2573 +17,2573 @@  discard block
 block discarded – undo
17 17
 class Events_Admin_Page extends EE_Admin_Page_CPT
18 18
 {
19 19
 
20
-    /**
21
-     * This will hold the event object for event_details screen.
22
-     *
23
-     * @access protected
24
-     * @var EE_Event $_event
25
-     */
26
-    protected $_event;
27
-
28
-
29
-    /**
30
-     * This will hold the category object for category_details screen.
31
-     *
32
-     * @var stdClass $_category
33
-     */
34
-    protected $_category;
35
-
36
-
37
-    /**
38
-     * This will hold the event model instance
39
-     *
40
-     * @var EEM_Event $_event_model
41
-     */
42
-    protected $_event_model;
43
-
44
-
45
-
46
-    /**
47
-     * @var EE_Event
48
-     */
49
-    protected $_cpt_model_obj = false;
50
-
51
-
52
-
53
-    protected function _init_page_props()
54
-    {
55
-        $this->page_slug = EVENTS_PG_SLUG;
56
-        $this->page_label = EVENTS_LABEL;
57
-        $this->_admin_base_url = EVENTS_ADMIN_URL;
58
-        $this->_admin_base_path = EVENTS_ADMIN;
59
-        $this->_cpt_model_names = array(
60
-            'create_new' => 'EEM_Event',
61
-            'edit'       => 'EEM_Event',
62
-        );
63
-        $this->_cpt_edit_routes = array(
64
-            'espresso_events' => 'edit',
65
-        );
66
-        add_action(
67
-            'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object',
68
-            array($this, 'verify_event_edit')
69
-        );
70
-    }
71
-
72
-
73
-
74
-    protected function _ajax_hooks()
75
-    {
76
-        //todo: all hooks for events ajax goes in here.
77
-    }
78
-
79
-
80
-
81
-    protected function _define_page_props()
82
-    {
83
-        $this->_admin_page_title = EVENTS_LABEL;
84
-        $this->_labels = array(
85
-            'buttons'      => array(
86
-                'add'             => esc_html__('Add New Event', 'event_espresso'),
87
-                'edit'            => esc_html__('Edit Event', 'event_espresso'),
88
-                'delete'          => esc_html__('Delete Event', 'event_espresso'),
89
-                'add_category'    => esc_html__('Add New Category', 'event_espresso'),
90
-                'edit_category'   => esc_html__('Edit Category', 'event_espresso'),
91
-                'delete_category' => esc_html__('Delete Category', 'event_espresso'),
92
-            ),
93
-            'editor_title' => array(
94
-                'espresso_events' => esc_html__('Enter event title here', 'event_espresso'),
95
-            ),
96
-            'publishbox'   => array(
97
-                'create_new'        => esc_html__('Save New Event', 'event_espresso'),
98
-                'edit'              => esc_html__('Update Event', 'event_espresso'),
99
-                'add_category'      => esc_html__('Save New Category', 'event_espresso'),
100
-                'edit_category'     => esc_html__('Update Category', 'event_espresso'),
101
-                'template_settings' => esc_html__('Update Settings', 'event_espresso'),
102
-            ),
103
-        );
104
-    }
105
-
106
-
107
-
108
-    protected function _set_page_routes()
109
-    {
110
-        //load formatter helper
111
-        //load field generator helper
112
-        //is there a evt_id in the request?
113
-        $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID'])
114
-            ? $this->_req_data['EVT_ID'] : 0;
115
-        $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id;
116
-        $this->_page_routes = array(
117
-            'default'                       => array(
118
-                'func'       => '_events_overview_list_table',
119
-                'capability' => 'ee_read_events',
120
-            ),
121
-            'create_new'                    => array(
122
-                'func'       => '_create_new_cpt_item',
123
-                'capability' => 'ee_edit_events',
124
-            ),
125
-            'edit'                          => array(
126
-                'func'       => '_edit_cpt_item',
127
-                'capability' => 'ee_edit_event',
128
-                'obj_id'     => $evt_id,
129
-            ),
130
-            'copy_event'                    => array(
131
-                'func'       => '_copy_events',
132
-                'capability' => 'ee_edit_event',
133
-                'obj_id'     => $evt_id,
134
-                'noheader'   => true,
135
-            ),
136
-            'trash_event'                   => array(
137
-                'func'       => '_trash_or_restore_event',
138
-                'args'       => array('event_status' => 'trash'),
139
-                'capability' => 'ee_delete_event',
140
-                'obj_id'     => $evt_id,
141
-                'noheader'   => true,
142
-            ),
143
-            'trash_events'                  => array(
144
-                'func'       => '_trash_or_restore_events',
145
-                'args'       => array('event_status' => 'trash'),
146
-                'capability' => 'ee_delete_events',
147
-                'noheader'   => true,
148
-            ),
149
-            'restore_event'                 => array(
150
-                'func'       => '_trash_or_restore_event',
151
-                'args'       => array('event_status' => 'draft'),
152
-                'capability' => 'ee_delete_event',
153
-                'obj_id'     => $evt_id,
154
-                'noheader'   => true,
155
-            ),
156
-            'restore_events'                => array(
157
-                'func'       => '_trash_or_restore_events',
158
-                'args'       => array('event_status' => 'draft'),
159
-                'capability' => 'ee_delete_events',
160
-                'noheader'   => true,
161
-            ),
162
-            'delete_event'                  => array(
163
-                'func'       => '_delete_event',
164
-                'capability' => 'ee_delete_event',
165
-                'obj_id'     => $evt_id,
166
-                'noheader'   => true,
167
-            ),
168
-            'delete_events'                 => array(
169
-                'func'       => '_delete_events',
170
-                'capability' => 'ee_delete_events',
171
-                'noheader'   => true,
172
-            ),
173
-            'view_report'                   => array(
174
-                'func'      => '_view_report',
175
-                'capablity' => 'ee_edit_events',
176
-            ),
177
-            'default_event_settings'        => array(
178
-                'func'       => '_default_event_settings',
179
-                'capability' => 'manage_options',
180
-            ),
181
-            'update_default_event_settings' => array(
182
-                'func'       => '_update_default_event_settings',
183
-                'capability' => 'manage_options',
184
-                'noheader'   => true,
185
-            ),
186
-            'template_settings'             => array(
187
-                'func'       => '_template_settings',
188
-                'capability' => 'manage_options',
189
-            ),
190
-            //event category tab related
191
-            'add_category'                  => array(
192
-                'func'       => '_category_details',
193
-                'capability' => 'ee_edit_event_category',
194
-                'args'       => array('add'),
195
-            ),
196
-            'edit_category'                 => array(
197
-                'func'       => '_category_details',
198
-                'capability' => 'ee_edit_event_category',
199
-                'args'       => array('edit'),
200
-            ),
201
-            'delete_categories'             => array(
202
-                'func'       => '_delete_categories',
203
-                'capability' => 'ee_delete_event_category',
204
-                'noheader'   => true,
205
-            ),
206
-            'delete_category'               => array(
207
-                'func'       => '_delete_categories',
208
-                'capability' => 'ee_delete_event_category',
209
-                'noheader'   => true,
210
-            ),
211
-            'insert_category'               => array(
212
-                'func'       => '_insert_or_update_category',
213
-                'args'       => array('new_category' => true),
214
-                'capability' => 'ee_edit_event_category',
215
-                'noheader'   => true,
216
-            ),
217
-            'update_category'               => array(
218
-                'func'       => '_insert_or_update_category',
219
-                'args'       => array('new_category' => false),
220
-                'capability' => 'ee_edit_event_category',
221
-                'noheader'   => true,
222
-            ),
223
-            'category_list'                 => array(
224
-                'func'       => '_category_list_table',
225
-                'capability' => 'ee_manage_event_categories',
226
-            ),
227
-        );
228
-    }
229
-
230
-
231
-
232
-    protected function _set_page_config()
233
-    {
234
-        $this->_page_config = array(
235
-            'default'                => array(
236
-                'nav'           => array(
237
-                    'label' => esc_html__('Overview', 'event_espresso'),
238
-                    'order' => 10,
239
-                ),
240
-                'list_table'    => 'Events_Admin_List_Table',
241
-                'help_tabs'     => array(
242
-                    'events_overview_help_tab'                       => array(
243
-                        'title'    => esc_html__('Events Overview', 'event_espresso'),
244
-                        'filename' => 'events_overview',
245
-                    ),
246
-                    'events_overview_table_column_headings_help_tab' => array(
247
-                        'title'    => esc_html__('Events Overview Table Column Headings', 'event_espresso'),
248
-                        'filename' => 'events_overview_table_column_headings',
249
-                    ),
250
-                    'events_overview_filters_help_tab'               => array(
251
-                        'title'    => esc_html__('Events Overview Filters', 'event_espresso'),
252
-                        'filename' => 'events_overview_filters',
253
-                    ),
254
-                    'events_overview_view_help_tab'                  => array(
255
-                        'title'    => esc_html__('Events Overview Views', 'event_espresso'),
256
-                        'filename' => 'events_overview_views',
257
-                    ),
258
-                    'events_overview_other_help_tab'                 => array(
259
-                        'title'    => esc_html__('Events Overview Other', 'event_espresso'),
260
-                        'filename' => 'events_overview_other',
261
-                    ),
262
-                ),
263
-                'help_tour'     => array(
264
-                    'Event_Overview_Help_Tour',
265
-                    //'New_Features_Test_Help_Tour' for testing multiple help tour
266
-                ),
267
-                'qtips'         => array(
268
-                    'EE_Event_List_Table_Tips',
269
-                ),
270
-                'require_nonce' => false,
271
-            ),
272
-            'create_new'             => array(
273
-                'nav'           => array(
274
-                    'label'      => esc_html__('Add Event', 'event_espresso'),
275
-                    'order'      => 5,
276
-                    'persistent' => false,
277
-                ),
278
-                'metaboxes'     => array('_register_event_editor_meta_boxes'),
279
-                'help_tabs'     => array(
280
-                    'event_editor_help_tab'                            => array(
281
-                        'title'    => esc_html__('Event Editor', 'event_espresso'),
282
-                        'filename' => 'event_editor',
283
-                    ),
284
-                    'event_editor_title_richtexteditor_help_tab'       => array(
285
-                        'title'    => esc_html__('Event Title & Rich Text Editor', 'event_espresso'),
286
-                        'filename' => 'event_editor_title_richtexteditor',
287
-                    ),
288
-                    'event_editor_venue_details_help_tab'              => array(
289
-                        'title'    => esc_html__('Event Venue Details', 'event_espresso'),
290
-                        'filename' => 'event_editor_venue_details',
291
-                    ),
292
-                    'event_editor_event_datetimes_help_tab'            => array(
293
-                        'title'    => esc_html__('Event Datetimes', 'event_espresso'),
294
-                        'filename' => 'event_editor_event_datetimes',
295
-                    ),
296
-                    'event_editor_event_tickets_help_tab'              => array(
297
-                        'title'    => esc_html__('Event Tickets', 'event_espresso'),
298
-                        'filename' => 'event_editor_event_tickets',
299
-                    ),
300
-                    'event_editor_event_registration_options_help_tab' => array(
301
-                        'title'    => esc_html__('Event Registration Options', 'event_espresso'),
302
-                        'filename' => 'event_editor_event_registration_options',
303
-                    ),
304
-                    'event_editor_tags_categories_help_tab'            => array(
305
-                        'title'    => esc_html__('Event Tags & Categories', 'event_espresso'),
306
-                        'filename' => 'event_editor_tags_categories',
307
-                    ),
308
-                    'event_editor_questions_registrants_help_tab'      => array(
309
-                        'title'    => esc_html__('Questions for Registrants', 'event_espresso'),
310
-                        'filename' => 'event_editor_questions_registrants',
311
-                    ),
312
-                    'event_editor_save_new_event_help_tab'             => array(
313
-                        'title'    => esc_html__('Save New Event', 'event_espresso'),
314
-                        'filename' => 'event_editor_save_new_event',
315
-                    ),
316
-                    'event_editor_other_help_tab'                      => array(
317
-                        'title'    => esc_html__('Event Other', 'event_espresso'),
318
-                        'filename' => 'event_editor_other',
319
-                    ),
320
-                ),
321
-                'help_tour'     => array(
322
-                    'Event_Editor_Help_Tour',
323
-                ),
324
-                'qtips'         => array('EE_Event_Editor_Decaf_Tips'),
325
-                'require_nonce' => false,
326
-            ),
327
-            'edit'                   => array(
328
-                'nav'           => array(
329
-                    'label'      => esc_html__('Edit Event', 'event_espresso'),
330
-                    'order'      => 5,
331
-                    'persistent' => false,
332
-                    'url'        => isset($this->_req_data['post'])
333
-                        ? EE_Admin_Page::add_query_args_and_nonce(
334
-                            array('post' => $this->_req_data['post'], 'action' => 'edit'),
335
-                            $this->_current_page_view_url
336
-                        )
337
-                        : $this->_admin_base_url,
338
-                ),
339
-                'metaboxes'     => array('_register_event_editor_meta_boxes'),
340
-                'help_tabs'     => array(
341
-                    'event_editor_help_tab'                            => array(
342
-                        'title'    => esc_html__('Event Editor', 'event_espresso'),
343
-                        'filename' => 'event_editor',
344
-                    ),
345
-                    'event_editor_title_richtexteditor_help_tab'       => array(
346
-                        'title'    => esc_html__('Event Title & Rich Text Editor', 'event_espresso'),
347
-                        'filename' => 'event_editor_title_richtexteditor',
348
-                    ),
349
-                    'event_editor_venue_details_help_tab'              => array(
350
-                        'title'    => esc_html__('Event Venue Details', 'event_espresso'),
351
-                        'filename' => 'event_editor_venue_details',
352
-                    ),
353
-                    'event_editor_event_datetimes_help_tab'            => array(
354
-                        'title'    => esc_html__('Event Datetimes', 'event_espresso'),
355
-                        'filename' => 'event_editor_event_datetimes',
356
-                    ),
357
-                    'event_editor_event_tickets_help_tab'              => array(
358
-                        'title'    => esc_html__('Event Tickets', 'event_espresso'),
359
-                        'filename' => 'event_editor_event_tickets',
360
-                    ),
361
-                    'event_editor_event_registration_options_help_tab' => array(
362
-                        'title'    => esc_html__('Event Registration Options', 'event_espresso'),
363
-                        'filename' => 'event_editor_event_registration_options',
364
-                    ),
365
-                    'event_editor_tags_categories_help_tab'            => array(
366
-                        'title'    => esc_html__('Event Tags & Categories', 'event_espresso'),
367
-                        'filename' => 'event_editor_tags_categories',
368
-                    ),
369
-                    'event_editor_questions_registrants_help_tab'      => array(
370
-                        'title'    => esc_html__('Questions for Registrants', 'event_espresso'),
371
-                        'filename' => 'event_editor_questions_registrants',
372
-                    ),
373
-                    'event_editor_save_new_event_help_tab'             => array(
374
-                        'title'    => esc_html__('Save New Event', 'event_espresso'),
375
-                        'filename' => 'event_editor_save_new_event',
376
-                    ),
377
-                    'event_editor_other_help_tab'                      => array(
378
-                        'title'    => esc_html__('Event Other', 'event_espresso'),
379
-                        'filename' => 'event_editor_other',
380
-                    ),
381
-                ),
382
-                /*'help_tour' => array(
20
+	/**
21
+	 * This will hold the event object for event_details screen.
22
+	 *
23
+	 * @access protected
24
+	 * @var EE_Event $_event
25
+	 */
26
+	protected $_event;
27
+
28
+
29
+	/**
30
+	 * This will hold the category object for category_details screen.
31
+	 *
32
+	 * @var stdClass $_category
33
+	 */
34
+	protected $_category;
35
+
36
+
37
+	/**
38
+	 * This will hold the event model instance
39
+	 *
40
+	 * @var EEM_Event $_event_model
41
+	 */
42
+	protected $_event_model;
43
+
44
+
45
+
46
+	/**
47
+	 * @var EE_Event
48
+	 */
49
+	protected $_cpt_model_obj = false;
50
+
51
+
52
+
53
+	protected function _init_page_props()
54
+	{
55
+		$this->page_slug = EVENTS_PG_SLUG;
56
+		$this->page_label = EVENTS_LABEL;
57
+		$this->_admin_base_url = EVENTS_ADMIN_URL;
58
+		$this->_admin_base_path = EVENTS_ADMIN;
59
+		$this->_cpt_model_names = array(
60
+			'create_new' => 'EEM_Event',
61
+			'edit'       => 'EEM_Event',
62
+		);
63
+		$this->_cpt_edit_routes = array(
64
+			'espresso_events' => 'edit',
65
+		);
66
+		add_action(
67
+			'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object',
68
+			array($this, 'verify_event_edit')
69
+		);
70
+	}
71
+
72
+
73
+
74
+	protected function _ajax_hooks()
75
+	{
76
+		//todo: all hooks for events ajax goes in here.
77
+	}
78
+
79
+
80
+
81
+	protected function _define_page_props()
82
+	{
83
+		$this->_admin_page_title = EVENTS_LABEL;
84
+		$this->_labels = array(
85
+			'buttons'      => array(
86
+				'add'             => esc_html__('Add New Event', 'event_espresso'),
87
+				'edit'            => esc_html__('Edit Event', 'event_espresso'),
88
+				'delete'          => esc_html__('Delete Event', 'event_espresso'),
89
+				'add_category'    => esc_html__('Add New Category', 'event_espresso'),
90
+				'edit_category'   => esc_html__('Edit Category', 'event_espresso'),
91
+				'delete_category' => esc_html__('Delete Category', 'event_espresso'),
92
+			),
93
+			'editor_title' => array(
94
+				'espresso_events' => esc_html__('Enter event title here', 'event_espresso'),
95
+			),
96
+			'publishbox'   => array(
97
+				'create_new'        => esc_html__('Save New Event', 'event_espresso'),
98
+				'edit'              => esc_html__('Update Event', 'event_espresso'),
99
+				'add_category'      => esc_html__('Save New Category', 'event_espresso'),
100
+				'edit_category'     => esc_html__('Update Category', 'event_espresso'),
101
+				'template_settings' => esc_html__('Update Settings', 'event_espresso'),
102
+			),
103
+		);
104
+	}
105
+
106
+
107
+
108
+	protected function _set_page_routes()
109
+	{
110
+		//load formatter helper
111
+		//load field generator helper
112
+		//is there a evt_id in the request?
113
+		$evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID'])
114
+			? $this->_req_data['EVT_ID'] : 0;
115
+		$evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id;
116
+		$this->_page_routes = array(
117
+			'default'                       => array(
118
+				'func'       => '_events_overview_list_table',
119
+				'capability' => 'ee_read_events',
120
+			),
121
+			'create_new'                    => array(
122
+				'func'       => '_create_new_cpt_item',
123
+				'capability' => 'ee_edit_events',
124
+			),
125
+			'edit'                          => array(
126
+				'func'       => '_edit_cpt_item',
127
+				'capability' => 'ee_edit_event',
128
+				'obj_id'     => $evt_id,
129
+			),
130
+			'copy_event'                    => array(
131
+				'func'       => '_copy_events',
132
+				'capability' => 'ee_edit_event',
133
+				'obj_id'     => $evt_id,
134
+				'noheader'   => true,
135
+			),
136
+			'trash_event'                   => array(
137
+				'func'       => '_trash_or_restore_event',
138
+				'args'       => array('event_status' => 'trash'),
139
+				'capability' => 'ee_delete_event',
140
+				'obj_id'     => $evt_id,
141
+				'noheader'   => true,
142
+			),
143
+			'trash_events'                  => array(
144
+				'func'       => '_trash_or_restore_events',
145
+				'args'       => array('event_status' => 'trash'),
146
+				'capability' => 'ee_delete_events',
147
+				'noheader'   => true,
148
+			),
149
+			'restore_event'                 => array(
150
+				'func'       => '_trash_or_restore_event',
151
+				'args'       => array('event_status' => 'draft'),
152
+				'capability' => 'ee_delete_event',
153
+				'obj_id'     => $evt_id,
154
+				'noheader'   => true,
155
+			),
156
+			'restore_events'                => array(
157
+				'func'       => '_trash_or_restore_events',
158
+				'args'       => array('event_status' => 'draft'),
159
+				'capability' => 'ee_delete_events',
160
+				'noheader'   => true,
161
+			),
162
+			'delete_event'                  => array(
163
+				'func'       => '_delete_event',
164
+				'capability' => 'ee_delete_event',
165
+				'obj_id'     => $evt_id,
166
+				'noheader'   => true,
167
+			),
168
+			'delete_events'                 => array(
169
+				'func'       => '_delete_events',
170
+				'capability' => 'ee_delete_events',
171
+				'noheader'   => true,
172
+			),
173
+			'view_report'                   => array(
174
+				'func'      => '_view_report',
175
+				'capablity' => 'ee_edit_events',
176
+			),
177
+			'default_event_settings'        => array(
178
+				'func'       => '_default_event_settings',
179
+				'capability' => 'manage_options',
180
+			),
181
+			'update_default_event_settings' => array(
182
+				'func'       => '_update_default_event_settings',
183
+				'capability' => 'manage_options',
184
+				'noheader'   => true,
185
+			),
186
+			'template_settings'             => array(
187
+				'func'       => '_template_settings',
188
+				'capability' => 'manage_options',
189
+			),
190
+			//event category tab related
191
+			'add_category'                  => array(
192
+				'func'       => '_category_details',
193
+				'capability' => 'ee_edit_event_category',
194
+				'args'       => array('add'),
195
+			),
196
+			'edit_category'                 => array(
197
+				'func'       => '_category_details',
198
+				'capability' => 'ee_edit_event_category',
199
+				'args'       => array('edit'),
200
+			),
201
+			'delete_categories'             => array(
202
+				'func'       => '_delete_categories',
203
+				'capability' => 'ee_delete_event_category',
204
+				'noheader'   => true,
205
+			),
206
+			'delete_category'               => array(
207
+				'func'       => '_delete_categories',
208
+				'capability' => 'ee_delete_event_category',
209
+				'noheader'   => true,
210
+			),
211
+			'insert_category'               => array(
212
+				'func'       => '_insert_or_update_category',
213
+				'args'       => array('new_category' => true),
214
+				'capability' => 'ee_edit_event_category',
215
+				'noheader'   => true,
216
+			),
217
+			'update_category'               => array(
218
+				'func'       => '_insert_or_update_category',
219
+				'args'       => array('new_category' => false),
220
+				'capability' => 'ee_edit_event_category',
221
+				'noheader'   => true,
222
+			),
223
+			'category_list'                 => array(
224
+				'func'       => '_category_list_table',
225
+				'capability' => 'ee_manage_event_categories',
226
+			),
227
+		);
228
+	}
229
+
230
+
231
+
232
+	protected function _set_page_config()
233
+	{
234
+		$this->_page_config = array(
235
+			'default'                => array(
236
+				'nav'           => array(
237
+					'label' => esc_html__('Overview', 'event_espresso'),
238
+					'order' => 10,
239
+				),
240
+				'list_table'    => 'Events_Admin_List_Table',
241
+				'help_tabs'     => array(
242
+					'events_overview_help_tab'                       => array(
243
+						'title'    => esc_html__('Events Overview', 'event_espresso'),
244
+						'filename' => 'events_overview',
245
+					),
246
+					'events_overview_table_column_headings_help_tab' => array(
247
+						'title'    => esc_html__('Events Overview Table Column Headings', 'event_espresso'),
248
+						'filename' => 'events_overview_table_column_headings',
249
+					),
250
+					'events_overview_filters_help_tab'               => array(
251
+						'title'    => esc_html__('Events Overview Filters', 'event_espresso'),
252
+						'filename' => 'events_overview_filters',
253
+					),
254
+					'events_overview_view_help_tab'                  => array(
255
+						'title'    => esc_html__('Events Overview Views', 'event_espresso'),
256
+						'filename' => 'events_overview_views',
257
+					),
258
+					'events_overview_other_help_tab'                 => array(
259
+						'title'    => esc_html__('Events Overview Other', 'event_espresso'),
260
+						'filename' => 'events_overview_other',
261
+					),
262
+				),
263
+				'help_tour'     => array(
264
+					'Event_Overview_Help_Tour',
265
+					//'New_Features_Test_Help_Tour' for testing multiple help tour
266
+				),
267
+				'qtips'         => array(
268
+					'EE_Event_List_Table_Tips',
269
+				),
270
+				'require_nonce' => false,
271
+			),
272
+			'create_new'             => array(
273
+				'nav'           => array(
274
+					'label'      => esc_html__('Add Event', 'event_espresso'),
275
+					'order'      => 5,
276
+					'persistent' => false,
277
+				),
278
+				'metaboxes'     => array('_register_event_editor_meta_boxes'),
279
+				'help_tabs'     => array(
280
+					'event_editor_help_tab'                            => array(
281
+						'title'    => esc_html__('Event Editor', 'event_espresso'),
282
+						'filename' => 'event_editor',
283
+					),
284
+					'event_editor_title_richtexteditor_help_tab'       => array(
285
+						'title'    => esc_html__('Event Title & Rich Text Editor', 'event_espresso'),
286
+						'filename' => 'event_editor_title_richtexteditor',
287
+					),
288
+					'event_editor_venue_details_help_tab'              => array(
289
+						'title'    => esc_html__('Event Venue Details', 'event_espresso'),
290
+						'filename' => 'event_editor_venue_details',
291
+					),
292
+					'event_editor_event_datetimes_help_tab'            => array(
293
+						'title'    => esc_html__('Event Datetimes', 'event_espresso'),
294
+						'filename' => 'event_editor_event_datetimes',
295
+					),
296
+					'event_editor_event_tickets_help_tab'              => array(
297
+						'title'    => esc_html__('Event Tickets', 'event_espresso'),
298
+						'filename' => 'event_editor_event_tickets',
299
+					),
300
+					'event_editor_event_registration_options_help_tab' => array(
301
+						'title'    => esc_html__('Event Registration Options', 'event_espresso'),
302
+						'filename' => 'event_editor_event_registration_options',
303
+					),
304
+					'event_editor_tags_categories_help_tab'            => array(
305
+						'title'    => esc_html__('Event Tags & Categories', 'event_espresso'),
306
+						'filename' => 'event_editor_tags_categories',
307
+					),
308
+					'event_editor_questions_registrants_help_tab'      => array(
309
+						'title'    => esc_html__('Questions for Registrants', 'event_espresso'),
310
+						'filename' => 'event_editor_questions_registrants',
311
+					),
312
+					'event_editor_save_new_event_help_tab'             => array(
313
+						'title'    => esc_html__('Save New Event', 'event_espresso'),
314
+						'filename' => 'event_editor_save_new_event',
315
+					),
316
+					'event_editor_other_help_tab'                      => array(
317
+						'title'    => esc_html__('Event Other', 'event_espresso'),
318
+						'filename' => 'event_editor_other',
319
+					),
320
+				),
321
+				'help_tour'     => array(
322
+					'Event_Editor_Help_Tour',
323
+				),
324
+				'qtips'         => array('EE_Event_Editor_Decaf_Tips'),
325
+				'require_nonce' => false,
326
+			),
327
+			'edit'                   => array(
328
+				'nav'           => array(
329
+					'label'      => esc_html__('Edit Event', 'event_espresso'),
330
+					'order'      => 5,
331
+					'persistent' => false,
332
+					'url'        => isset($this->_req_data['post'])
333
+						? EE_Admin_Page::add_query_args_and_nonce(
334
+							array('post' => $this->_req_data['post'], 'action' => 'edit'),
335
+							$this->_current_page_view_url
336
+						)
337
+						: $this->_admin_base_url,
338
+				),
339
+				'metaboxes'     => array('_register_event_editor_meta_boxes'),
340
+				'help_tabs'     => array(
341
+					'event_editor_help_tab'                            => array(
342
+						'title'    => esc_html__('Event Editor', 'event_espresso'),
343
+						'filename' => 'event_editor',
344
+					),
345
+					'event_editor_title_richtexteditor_help_tab'       => array(
346
+						'title'    => esc_html__('Event Title & Rich Text Editor', 'event_espresso'),
347
+						'filename' => 'event_editor_title_richtexteditor',
348
+					),
349
+					'event_editor_venue_details_help_tab'              => array(
350
+						'title'    => esc_html__('Event Venue Details', 'event_espresso'),
351
+						'filename' => 'event_editor_venue_details',
352
+					),
353
+					'event_editor_event_datetimes_help_tab'            => array(
354
+						'title'    => esc_html__('Event Datetimes', 'event_espresso'),
355
+						'filename' => 'event_editor_event_datetimes',
356
+					),
357
+					'event_editor_event_tickets_help_tab'              => array(
358
+						'title'    => esc_html__('Event Tickets', 'event_espresso'),
359
+						'filename' => 'event_editor_event_tickets',
360
+					),
361
+					'event_editor_event_registration_options_help_tab' => array(
362
+						'title'    => esc_html__('Event Registration Options', 'event_espresso'),
363
+						'filename' => 'event_editor_event_registration_options',
364
+					),
365
+					'event_editor_tags_categories_help_tab'            => array(
366
+						'title'    => esc_html__('Event Tags & Categories', 'event_espresso'),
367
+						'filename' => 'event_editor_tags_categories',
368
+					),
369
+					'event_editor_questions_registrants_help_tab'      => array(
370
+						'title'    => esc_html__('Questions for Registrants', 'event_espresso'),
371
+						'filename' => 'event_editor_questions_registrants',
372
+					),
373
+					'event_editor_save_new_event_help_tab'             => array(
374
+						'title'    => esc_html__('Save New Event', 'event_espresso'),
375
+						'filename' => 'event_editor_save_new_event',
376
+					),
377
+					'event_editor_other_help_tab'                      => array(
378
+						'title'    => esc_html__('Event Other', 'event_espresso'),
379
+						'filename' => 'event_editor_other',
380
+					),
381
+				),
382
+				/*'help_tour' => array(
383 383
 					'Event_Edit_Help_Tour'
384 384
 				),*/
385
-                'qtips'         => array('EE_Event_Editor_Decaf_Tips'),
386
-                'require_nonce' => false,
387
-            ),
388
-            'default_event_settings' => array(
389
-                'nav'           => array(
390
-                    'label' => esc_html__('Default Settings', 'event_espresso'),
391
-                    'order' => 40,
392
-                ),
393
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
394
-                'labels'        => array(
395
-                    'publishbox' => esc_html__('Update Settings', 'event_espresso'),
396
-                ),
397
-                'help_tabs'     => array(
398
-                    'default_settings_help_tab'        => array(
399
-                        'title'    => esc_html__('Default Event Settings', 'event_espresso'),
400
-                        'filename' => 'events_default_settings',
401
-                    ),
402
-                    'default_settings_status_help_tab' => array(
403
-                        'title'    => esc_html__('Default Registration Status', 'event_espresso'),
404
-                        'filename' => 'events_default_settings_status',
405
-                    ),
406
-                ),
407
-                'help_tour'     => array('Event_Default_Settings_Help_Tour'),
408
-                'require_nonce' => false,
409
-            ),
410
-            //template settings
411
-            'template_settings'      => array(
412
-                'nav'           => array(
413
-                    'label' => esc_html__('Templates', 'event_espresso'),
414
-                    'order' => 30,
415
-                ),
416
-                'metaboxes'     => $this->_default_espresso_metaboxes,
417
-                'help_tabs'     => array(
418
-                    'general_settings_templates_help_tab' => array(
419
-                        'title'    => esc_html__('Templates', 'event_espresso'),
420
-                        'filename' => 'general_settings_templates',
421
-                    ),
422
-                ),
423
-                'help_tour'     => array('Templates_Help_Tour'),
424
-                'require_nonce' => false,
425
-            ),
426
-            //event category stuff
427
-            'add_category'           => array(
428
-                'nav'           => array(
429
-                    'label'      => esc_html__('Add Category', 'event_espresso'),
430
-                    'order'      => 15,
431
-                    'persistent' => false,
432
-                ),
433
-                'help_tabs'     => array(
434
-                    'add_category_help_tab' => array(
435
-                        'title'    => esc_html__('Add New Event Category', 'event_espresso'),
436
-                        'filename' => 'events_add_category',
437
-                    ),
438
-                ),
439
-                'help_tour'     => array('Event_Add_Category_Help_Tour'),
440
-                'metaboxes'     => array('_publish_post_box'),
441
-                'require_nonce' => false,
442
-            ),
443
-            'edit_category'          => array(
444
-                'nav'           => array(
445
-                    'label'      => esc_html__('Edit Category', 'event_espresso'),
446
-                    'order'      => 15,
447
-                    'persistent' => false,
448
-                    'url'        => isset($this->_req_data['EVT_CAT_ID'])
449
-                        ? add_query_arg(
450
-                            array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID']),
451
-                            $this->_current_page_view_url
452
-                        )
453
-                        : $this->_admin_base_url,
454
-                ),
455
-                'help_tabs'     => array(
456
-                    'edit_category_help_tab' => array(
457
-                        'title'    => esc_html__('Edit Event Category', 'event_espresso'),
458
-                        'filename' => 'events_edit_category',
459
-                    ),
460
-                ),
461
-                /*'help_tour' => array('Event_Edit_Category_Help_Tour'),*/
462
-                'metaboxes'     => array('_publish_post_box'),
463
-                'require_nonce' => false,
464
-            ),
465
-            'category_list'          => array(
466
-                'nav'           => array(
467
-                    'label' => esc_html__('Categories', 'event_espresso'),
468
-                    'order' => 20,
469
-                ),
470
-                'list_table'    => 'Event_Categories_Admin_List_Table',
471
-                'help_tabs'     => array(
472
-                    'events_categories_help_tab'                       => array(
473
-                        'title'    => esc_html__('Event Categories', 'event_espresso'),
474
-                        'filename' => 'events_categories',
475
-                    ),
476
-                    'events_categories_table_column_headings_help_tab' => array(
477
-                        'title'    => esc_html__('Event Categories Table Column Headings', 'event_espresso'),
478
-                        'filename' => 'events_categories_table_column_headings',
479
-                    ),
480
-                    'events_categories_view_help_tab'                  => array(
481
-                        'title'    => esc_html__('Event Categories Views', 'event_espresso'),
482
-                        'filename' => 'events_categories_views',
483
-                    ),
484
-                    'events_categories_other_help_tab'                 => array(
485
-                        'title'    => esc_html__('Event Categories Other', 'event_espresso'),
486
-                        'filename' => 'events_categories_other',
487
-                    ),
488
-                ),
489
-                'help_tour'     => array(
490
-                    'Event_Categories_Help_Tour',
491
-                ),
492
-                'metaboxes'     => $this->_default_espresso_metaboxes,
493
-                'require_nonce' => false,
494
-            ),
495
-        );
496
-    }
497
-
498
-
499
-
500
-    protected function _add_screen_options()
501
-    {
502
-        //todo
503
-    }
504
-
505
-
506
-
507
-    protected function _add_screen_options_default()
508
-    {
509
-        $this->_per_page_screen_option();
510
-    }
511
-
512
-
513
-
514
-    protected function _add_screen_options_category_list()
515
-    {
516
-        $page_title = $this->_admin_page_title;
517
-        $this->_admin_page_title = esc_html__('Categories', 'event_espresso');
518
-        $this->_per_page_screen_option();
519
-        $this->_admin_page_title = $page_title;
520
-    }
521
-
522
-
523
-
524
-    protected function _add_feature_pointers()
525
-    {
526
-        //todo
527
-    }
528
-
529
-
530
-
531
-    public function load_scripts_styles()
532
-    {
533
-        wp_register_style(
534
-            'events-admin-css',
535
-            EVENTS_ASSETS_URL . 'events-admin-page.css',
536
-            array(),
537
-            EVENT_ESPRESSO_VERSION
538
-        );
539
-        wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION);
540
-        wp_enqueue_style('events-admin-css');
541
-        wp_enqueue_style('ee-cat-admin');
542
-        //todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details
543
-        //registers for all views
544
-        //scripts
545
-        wp_register_script(
546
-            'event_editor_js',
547
-            EVENTS_ASSETS_URL . 'event_editor.js',
548
-            array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'),
549
-            EVENT_ESPRESSO_VERSION,
550
-            true
551
-        );
552
-    }
553
-
554
-
555
-
556
-    /**
557
-     * enqueuing scripts and styles specific to this view
558
-     *
559
-     * @return void
560
-     */
561
-    public function load_scripts_styles_create_new()
562
-    {
563
-        $this->load_scripts_styles_edit();
564
-    }
565
-
566
-
567
-
568
-    /**
569
-     * enqueuing scripts and styles specific to this view
570
-     *
571
-     * @return void
572
-     */
573
-    public function load_scripts_styles_edit()
574
-    {
575
-        //styles
576
-        wp_enqueue_style('espresso-ui-theme');
577
-        wp_register_style(
578
-            'event-editor-css',
579
-            EVENTS_ASSETS_URL . 'event-editor.css',
580
-            array('ee-admin-css'),
581
-            EVENT_ESPRESSO_VERSION
582
-        );
583
-        wp_enqueue_style('event-editor-css');
584
-        //scripts
585
-        wp_register_script(
586
-            'event-datetime-metabox',
587
-            EVENTS_ASSETS_URL . 'event-datetime-metabox.js',
588
-            array('event_editor_js', 'ee-datepicker'),
589
-            EVENT_ESPRESSO_VERSION
590
-        );
591
-        wp_enqueue_script('event-datetime-metabox');
592
-    }
593
-
594
-
595
-
596
-    public function load_scripts_styles_add_category()
597
-    {
598
-        $this->load_scripts_styles_edit_category();
599
-    }
600
-
601
-
602
-
603
-    public function load_scripts_styles_edit_category()
604
-    {
605
-    }
606
-
607
-
608
-
609
-    protected function _set_list_table_views_category_list()
610
-    {
611
-        $this->_views = array(
612
-            'all' => array(
613
-                'slug'        => 'all',
614
-                'label'       => esc_html__('All', 'event_espresso'),
615
-                'count'       => 0,
616
-                'bulk_action' => array(
617
-                    'delete_categories' => esc_html__('Delete Permanently', 'event_espresso'),
618
-                ),
619
-            ),
620
-        );
621
-    }
622
-
623
-
624
-
625
-    public function admin_init()
626
-    {
627
-        EE_Registry::$i18n_js_strings['image_confirm'] = esc_html__(
628
-            'Do you really want to delete this image? Please remember to update your event to complete the removal.',
629
-            'event_espresso'
630
-        );
631
-    }
632
-
633
-
634
-
635
-    //nothing needed for events with these methods.
636
-    public function admin_notices()
637
-    {
638
-    }
639
-
640
-
641
-
642
-    public function admin_footer_scripts()
643
-    {
644
-    }
645
-
646
-
647
-
648
-    /**
649
-     * Call this function to verify if an event is public and has tickets for sale.  If it does, then we need to show a
650
-     * warning (via EE_Error::add_error());
651
-     *
652
-     * @param  EE_Event $event Event object
653
-     * @access public
654
-     * @return void
655
-     */
656
-    public function verify_event_edit($event = null)
657
-    {
658
-        // no event?
659
-        if (empty($event)) {
660
-            // set event
661
-            $event = $this->_cpt_model_obj;
662
-        }
663
-        // STILL no event?
664
-        if (empty ($event)) {
665
-            return;
666
-        }
667
-        $orig_status = $event->status();
668
-        // first check if event is active.
669
-        if (
670
-            $orig_status === EEM_Event::cancelled
671
-            || $orig_status === EEM_Event::postponed
672
-            || $event->is_expired()
673
-            || $event->is_inactive()
674
-        ) {
675
-            return;
676
-        }
677
-        //made it here so it IS active... next check that any of the tickets are sold.
678
-        if ($event->is_sold_out(true)) {
679
-            if ($orig_status !== EEM_Event::sold_out && $event->status() !== $orig_status) {
680
-                EE_Error::add_attention(
681
-                    sprintf(
682
-                        esc_html__(
683
-                            'Please note that the Event Status has automatically been changed to %s because there are no more spaces available for this event.  However, this change is not permanent until you update the event.  You can change the status back to something else before updating if you wish.',
684
-                            'event_espresso'
685
-                        ),
686
-                        EEH_Template::pretty_status(EEM_Event::sold_out, false, 'sentence')
687
-                    )
688
-                );
689
-            }
690
-            return;
691
-        } else if ($orig_status === EEM_Event::sold_out) {
692
-            EE_Error::add_attention(
693
-                sprintf(
694
-                    esc_html__(
695
-                        'Please note that the Event Status has automatically been changed to %s because more spaces have become available for this event, most likely due to abandoned transactions freeing up reserved tickets.  However, this change is not permanent until you update the event. If you wish, you can change the status back to something else before updating.',
696
-                        'event_espresso'
697
-                    ),
698
-                    EEH_Template::pretty_status($event->status(), false, 'sentence')
699
-                )
700
-            );
701
-        }
702
-        //now we need to determine if the event has any tickets on sale.  If not then we dont' show the error
703
-        if ( ! $event->tickets_on_sale()) {
704
-            return;
705
-        }
706
-        //made it here so show warning
707
-        $this->_edit_event_warning();
708
-    }
709
-
710
-
711
-
712
-    /**
713
-     * This is the text used for when an event is being edited that is public and has tickets for sale.
714
-     * When needed, hook this into a EE_Error::add_error() notice.
715
-     *
716
-     * @access protected
717
-     * @return void
718
-     */
719
-    protected function _edit_event_warning()
720
-    {
721
-        // we don't want to add warnings during these requests
722
-        if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'editpost') {
723
-            return;
724
-        }
725
-        EE_Error::add_attention(
726
-            esc_html__(
727
-                'Please be advised that this event has been published and is open for registrations on your website. If you update any registration-related details (i.e. custom questions, messages, tickets, datetimes, etc.) while a registration is in process, the registration process could be interrupted and result in errors for the person registering and potentially incorrect registration or transaction data inside Event Espresso. We recommend editing events during a period of slow traffic, or even temporarily changing the status of an event to "Draft" until your edits are complete.',
728
-                'event_espresso'
729
-            )
730
-        );
731
-    }
732
-
733
-
734
-
735
-    /**
736
-     * When a user is creating a new event, notify them if they haven't set their timezone.
737
-     * Otherwise, do the normal logic
738
-     *
739
-     * @return string
740
-     * @throws \EE_Error
741
-     */
742
-    protected function _create_new_cpt_item()
743
-    {
744
-        $gmt_offset = get_option('gmt_offset');
745
-        //only nag them about setting their timezone if it's their first event, and they haven't already done it
746
-        if ($gmt_offset === '0' && ! EEM_Event::instance()->exists(array())) {
747
-            EE_Error::add_attention(
748
-                sprintf(
749
-                    __(
750
-                        'Your website\'s timezone is currently set to UTC + 0. We recommend updating your timezone to a city or region near you before you create an event. Your timezone can be updated through the %1$sGeneral Settings%2$s page.',
751
-                        'event_espresso'
752
-                    ),
753
-                    '<a href="' . admin_url('options-general.php') . '">',
754
-                    '</a>'
755
-                ),
756
-                __FILE__,
757
-                __FUNCTION__,
758
-                __LINE__
759
-            );
760
-        }
761
-        return parent::_create_new_cpt_item();
762
-    }
763
-
764
-
765
-
766
-    protected function _set_list_table_views_default()
767
-    {
768
-        $this->_views = array(
769
-            'all'   => array(
770
-                'slug'        => 'all',
771
-                'label'       => esc_html__('View All Events', 'event_espresso'),
772
-                'count'       => 0,
773
-                'bulk_action' => array(
774
-                    'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
775
-                ),
776
-            ),
777
-            'draft' => array(
778
-                'slug'        => 'draft',
779
-                'label'       => esc_html__('Draft', 'event_espresso'),
780
-                'count'       => 0,
781
-                'bulk_action' => array(
782
-                    'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
783
-                ),
784
-            ),
785
-        );
786
-        if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) {
787
-            $this->_views['trash'] = array(
788
-                'slug'        => 'trash',
789
-                'label'       => esc_html__('Trash', 'event_espresso'),
790
-                'count'       => 0,
791
-                'bulk_action' => array(
792
-                    'restore_events' => esc_html__('Restore From Trash', 'event_espresso'),
793
-                    'delete_events'  => esc_html__('Delete Permanently', 'event_espresso'),
794
-                ),
795
-            );
796
-        }
797
-    }
798
-
799
-
800
-
801
-    /**
802
-     * @return array
803
-     */
804
-    protected function _event_legend_items()
805
-    {
806
-        $items = array(
807
-            'view_details'   => array(
808
-                'class' => 'dashicons dashicons-search',
809
-                'desc'  => esc_html__('View Event', 'event_espresso'),
810
-            ),
811
-            'edit_event'     => array(
812
-                'class' => 'ee-icon ee-icon-calendar-edit',
813
-                'desc'  => esc_html__('Edit Event Details', 'event_espresso'),
814
-            ),
815
-            'view_attendees' => array(
816
-                'class' => 'dashicons dashicons-groups',
817
-                'desc'  => esc_html__('View Registrations for Event', 'event_espresso'),
818
-            ),
819
-        );
820
-        $items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items);
821
-        $statuses = array(
822
-            'sold_out_status'  => array(
823
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out,
824
-                'desc'  => EEH_Template::pretty_status(EE_Datetime::sold_out, false, 'sentence'),
825
-            ),
826
-            'active_status'    => array(
827
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active,
828
-                'desc'  => EEH_Template::pretty_status(EE_Datetime::active, false, 'sentence'),
829
-            ),
830
-            'upcoming_status'  => array(
831
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming,
832
-                'desc'  => EEH_Template::pretty_status(EE_Datetime::upcoming, false, 'sentence'),
833
-            ),
834
-            'postponed_status' => array(
835
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed,
836
-                'desc'  => EEH_Template::pretty_status(EE_Datetime::postponed, false, 'sentence'),
837
-            ),
838
-            'cancelled_status' => array(
839
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled,
840
-                'desc'  => EEH_Template::pretty_status(EE_Datetime::cancelled, false, 'sentence'),
841
-            ),
842
-            'expired_status'   => array(
843
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired,
844
-                'desc'  => EEH_Template::pretty_status(EE_Datetime::expired, false, 'sentence'),
845
-            ),
846
-            'inactive_status'  => array(
847
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive,
848
-                'desc'  => EEH_Template::pretty_status(EE_Datetime::inactive, false, 'sentence'),
849
-            ),
850
-        );
851
-        $statuses = apply_filters('FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses);
852
-        return array_merge($items, $statuses);
853
-    }
854
-
855
-
856
-
857
-    /**
858
-     * _event_model
859
-     *
860
-     * @return EEM_Event
861
-     */
862
-    private function _event_model()
863
-    {
864
-        if ( ! $this->_event_model instanceof EEM_Event) {
865
-            $this->_event_model = EE_Registry::instance()->load_model('Event');
866
-        }
867
-        return $this->_event_model;
868
-    }
869
-
870
-
871
-
872
-    /**
873
-     * Adds extra buttons to the WP CPT permalink field row.
874
-     * Method is called from parent and is hooked into the wp 'get_sample_permalink_html' filter.
875
-     *
876
-     * @param  string $return    the current html
877
-     * @param  int    $id        the post id for the page
878
-     * @param  string $new_title What the title is
879
-     * @param  string $new_slug  what the slug is
880
-     * @return string            The new html string for the permalink area
881
-     */
882
-    public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug)
883
-    {
884
-        //make sure this is only when editing
885
-        if ( ! empty($id)) {
886
-            $post = get_post($id);
887
-            $return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#"  tabindex="-1">'
888
-                       . esc_html__('Shortcode', 'event_espresso')
889
-                       . '</a> ';
890
-            $return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id='
891
-                       . $post->ID
892
-                       . ']">';
893
-        }
894
-        return $return;
895
-    }
896
-
897
-
898
-
899
-    /**
900
-     * _events_overview_list_table
901
-     * This contains the logic for showing the events_overview list
902
-     *
903
-     * @access protected
904
-     * @return void
905
-     * @throws \EE_Error
906
-     */
907
-    protected function _events_overview_list_table()
908
-    {
909
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
910
-        $this->_template_args['after_list_table'] = ! empty($this->_template_args['after_list_table'])
911
-            ? (array)$this->_template_args['after_list_table']
912
-            : array();
913
-        $this->_template_args['after_list_table']['view_event_list_button'] = EEH_HTML::br()
914
-                                                                              . EEH_Template::get_button_or_link(
915
-                get_post_type_archive_link('espresso_events'),
916
-                esc_html__("View Event Archive Page", "event_espresso"),
917
-                'button'
918
-            );
919
-        $this->_template_args['after_list_table']['legend'] = $this->_display_legend($this->_event_legend_items());
920
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
921
-                'create_new',
922
-                'add',
923
-                array(),
924
-                'add-new-h2'
925
-            );
926
-        $this->display_admin_list_table_page_with_no_sidebar();
927
-    }
928
-
929
-
930
-
931
-    /**
932
-     * this allows for extra misc actions in the default WP publish box
933
-     *
934
-     * @return void
935
-     */
936
-    public function extra_misc_actions_publish_box()
937
-    {
938
-        $this->_generate_publish_box_extra_content();
939
-    }
940
-
941
-
942
-
943
-    /**
944
-     * This is hooked into the WordPress do_action('save_post') hook and runs after the custom post type has been
945
-     * saved.  Child classes are required to declare this method.  Typically you would use this to save any additional
946
-     * data.
947
-     * Keep in mind also that "save_post" runs on EVERY post update to the database.
948
-     * ALSO very important.  When a post transitions from scheduled to published, the save_post action is fired but you
949
-     * will NOT have any _POST data containing any extra info you may have from other meta saves.  So MAKE sure that
950
-     * you handle this accordingly.
951
-     *
952
-     * @access protected
953
-     * @abstract
954
-     * @param  string $post_id The ID of the cpt that was saved (so you can link relationally)
955
-     * @param  object $post    The post object of the cpt that was saved.
956
-     * @return void
957
-     */
958
-    protected function _insert_update_cpt_item($post_id, $post)
959
-    {
960
-        if ($post instanceof WP_Post && $post->post_type !== 'espresso_events') {
961
-            //get out we're not processing an event save.
962
-            return;
963
-        }
964
-        $event_values = array(
965
-            'EVT_display_desc'                => ! empty($this->_req_data['display_desc']) ? 1 : 0,
966
-            'EVT_display_ticket_selector'     => ! empty($this->_req_data['display_ticket_selector']) ? 1 : 0,
967
-            'EVT_additional_limit'            => min(
968
-                apply_filters('FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255),
969
-                ! empty($this->_req_data['additional_limit']) ? $this->_req_data['additional_limit'] : null
970
-            ),
971
-            'EVT_default_registration_status' => ! empty($this->_req_data['EVT_default_registration_status'])
972
-                ? $this->_req_data['EVT_default_registration_status']
973
-                : EE_Registry::instance()->CFG->registration->default_STS_ID,
974
-            'EVT_member_only'                 => ! empty($this->_req_data['member_only']) ? 1 : 0,
975
-            'EVT_allow_overflow'              => ! empty($this->_req_data['EVT_allow_overflow']) ? 1 : 0,
976
-            'EVT_timezone_string'             => ! empty($this->_req_data['timezone_string'])
977
-                ? $this->_req_data['timezone_string'] : null,
978
-            'EVT_external_URL'                => ! empty($this->_req_data['externalURL'])
979
-                ? $this->_req_data['externalURL'] : null,
980
-            'EVT_phone'                       => ! empty($this->_req_data['event_phone'])
981
-                ? $this->_req_data['event_phone'] : null,
982
-        );
983
-        //update event
984
-        $success = $this->_event_model()->update_by_ID($event_values, $post_id);
985
-        //get event_object for other metaboxes... though it would seem to make sense to just use $this->_event_model()->get_one_by_ID( $post_id ).. i have to setup where conditions to override the filters in the model that filter out autodraft and inherit statuses so we GET the inherit id!
986
-        $get_one_where = array($this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status);
987
-        $event = $this->_event_model()->get_one(array($get_one_where));
988
-        //the following are default callbacks for event attachment updates that can be overridden by caffeinated functionality and/or addons.
989
-        $event_update_callbacks = apply_filters(
990
-            'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks',
991
-            array(array($this, '_default_venue_update'), array($this, '_default_tickets_update'))
992
-        );
993
-        $att_success = true;
994
-        foreach ($event_update_callbacks as $e_callback) {
995
-            $_succ = call_user_func_array($e_callback, array($event, $this->_req_data));
996
-            $att_success = ! $att_success ? $att_success
997
-                : $_succ; //if ANY of these updates fail then we want the appropriate global error message
998
-        }
999
-        //any errors?
1000
-        if ($success && false === $att_success) {
1001
-            EE_Error::add_error(
1002
-                esc_html__(
1003
-                    'Event Details saved successfully but something went wrong with saving attachments.',
1004
-                    'event_espresso'
1005
-                ),
1006
-                __FILE__,
1007
-                __FUNCTION__,
1008
-                __LINE__
1009
-            );
1010
-        } else if ($success === false) {
1011
-            EE_Error::add_error(
1012
-                esc_html__('Event Details did not save successfully.', 'event_espresso'),
1013
-                __FILE__,
1014
-                __FUNCTION__,
1015
-                __LINE__
1016
-            );
1017
-        }
1018
-    }
1019
-
1020
-
1021
-
1022
-    /**
1023
-     * @see parent::restore_item()
1024
-     * @param int $post_id
1025
-     * @param int $revision_id
1026
-     */
1027
-    protected function _restore_cpt_item($post_id, $revision_id)
1028
-    {
1029
-        //copy existing event meta to new post
1030
-        $post_evt = $this->_event_model()->get_one_by_ID($post_id);
1031
-        if ($post_evt instanceof EE_Event) {
1032
-            //meta revision restore
1033
-            $post_evt->restore_revision($revision_id);
1034
-            //related objs restore
1035
-            $post_evt->restore_revision($revision_id, array('Venue', 'Datetime', 'Price'));
1036
-        }
1037
-    }
1038
-
1039
-
1040
-
1041
-    /**
1042
-     * Attach the venue to the Event
1043
-     *
1044
-     * @param  \EE_Event $evtobj Event Object to add the venue to
1045
-     * @param  array     $data   The request data from the form
1046
-     * @return bool           Success or fail.
1047
-     */
1048
-    protected function _default_venue_update(\EE_Event $evtobj, $data)
1049
-    {
1050
-        require_once(EE_MODELS . 'EEM_Venue.model.php');
1051
-        $venue_model = EE_Registry::instance()->load_model('Venue');
1052
-        $rows_affected = null;
1053
-        $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null;
1054
-        // very important.  If we don't have a venue name...
1055
-        // then we'll get out because not necessary to create empty venue
1056
-        if (empty($data['venue_title'])) {
1057
-            return false;
1058
-        }
1059
-        $venue_array = array(
1060
-            'VNU_wp_user'         => $evtobj->get('EVT_wp_user'),
1061
-            'VNU_name'            => ! empty($data['venue_title']) ? $data['venue_title'] : null,
1062
-            'VNU_desc'            => ! empty($data['venue_description']) ? $data['venue_description'] : null,
1063
-            'VNU_identifier'      => ! empty($data['venue_identifier']) ? $data['venue_identifier'] : null,
1064
-            'VNU_short_desc'      => ! empty($data['venue_short_description']) ? $data['venue_short_description']
1065
-                : null,
1066
-            'VNU_address'         => ! empty($data['address']) ? $data['address'] : null,
1067
-            'VNU_address2'        => ! empty($data['address2']) ? $data['address2'] : null,
1068
-            'VNU_city'            => ! empty($data['city']) ? $data['city'] : null,
1069
-            'STA_ID'              => ! empty($data['state']) ? $data['state'] : null,
1070
-            'CNT_ISO'             => ! empty($data['countries']) ? $data['countries'] : null,
1071
-            'VNU_zip'             => ! empty($data['zip']) ? $data['zip'] : null,
1072
-            'VNU_phone'           => ! empty($data['venue_phone']) ? $data['venue_phone'] : null,
1073
-            'VNU_capacity'        => ! empty($data['venue_capacity']) ? $data['venue_capacity'] : null,
1074
-            'VNU_url'             => ! empty($data['venue_url']) ? $data['venue_url'] : null,
1075
-            'VNU_virtual_phone'   => ! empty($data['virtual_phone']) ? $data['virtual_phone'] : null,
1076
-            'VNU_virtual_url'     => ! empty($data['virtual_url']) ? $data['virtual_url'] : null,
1077
-            'VNU_enable_for_gmap' => isset($data['enable_for_gmap']) ? 1 : 0,
1078
-            'status'              => 'publish',
1079
-        );
1080
-        //if we've got the venue_id then we're just updating the existing venue so let's do that and then get out.
1081
-        if ( ! empty($venue_id)) {
1082
-            $update_where = array($venue_model->primary_key_name() => $venue_id);
1083
-            $rows_affected = $venue_model->update($venue_array, array($update_where));
1084
-            //we've gotta make sure that the venue is always attached to a revision.. add_relation_to should take care of making sure that the relation is already present.
1085
-            $evtobj->_add_relation_to($venue_id, 'Venue');
1086
-            return $rows_affected > 0 ? true : false;
1087
-        } else {
1088
-            //we insert the venue
1089
-            $venue_id = $venue_model->insert($venue_array);
1090
-            $evtobj->_add_relation_to($venue_id, 'Venue');
1091
-            return ! empty($venue_id) ? true : false;
1092
-        }
1093
-        //when we have the ancestor come in it's already been handled by the revision save.
1094
-    }
1095
-
1096
-
1097
-
1098
-    /**
1099
-     * Handles saving everything related to Tickets (datetimes, tickets, prices)
1100
-     *
1101
-     * @param  EE_Event $evtobj The Event object we're attaching data to
1102
-     * @param  array    $data   The request data from the form
1103
-     * @return array
1104
-     */
1105
-    protected function _default_tickets_update(EE_Event $evtobj, $data)
1106
-    {
1107
-        $success = true;
1108
-        $saved_dtt = null;
1109
-        $saved_tickets = array();
1110
-        $incoming_date_formats = array('Y-m-d', 'h:i a');
1111
-        foreach ($data['edit_event_datetimes'] as $row => $dtt) {
1112
-            //trim all values to ensure any excess whitespace is removed.
1113
-            $dtt = array_map('trim', $dtt);
1114
-            $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end']
1115
-                : $dtt['DTT_EVT_start'];
1116
-            $datetime_values = array(
1117
-                'DTT_ID'        => ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : null,
1118
-                'DTT_EVT_start' => $dtt['DTT_EVT_start'],
1119
-                'DTT_EVT_end'   => $dtt['DTT_EVT_end'],
1120
-                'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'],
1121
-                'DTT_order'     => $row,
1122
-            );
1123
-            //if we have an id then let's get existing object first and then set the new values.  Otherwise we instantiate a new object for save.
1124
-            if ( ! empty($dtt['DTT_ID'])) {
1125
-                $DTM = EE_Registry::instance()
1126
-                                  ->load_model('Datetime', array($evtobj->get_timezone()))
1127
-                                  ->get_one_by_ID($dtt['DTT_ID']);
1128
-                $DTM->set_date_format($incoming_date_formats[0]);
1129
-                $DTM->set_time_format($incoming_date_formats[1]);
1130
-                foreach ($datetime_values as $field => $value) {
1131
-                    $DTM->set($field, $value);
1132
-                }
1133
-                //make sure the $dtt_id here is saved just in case after the add_relation_to() the autosave replaces it.  We need to do this so we dont' TRASH the parent DTT.
1134
-                $saved_dtts[$DTM->ID()] = $DTM;
1135
-            } else {
1136
-                $DTM = EE_Registry::instance()->load_class(
1137
-                    'Datetime',
1138
-                    array($datetime_values, $evtobj->get_timezone(), $incoming_date_formats),
1139
-                    false,
1140
-                    false
1141
-                );
1142
-                foreach ($datetime_values as $field => $value) {
1143
-                    $DTM->set($field, $value);
1144
-                }
1145
-            }
1146
-            $DTM->save();
1147
-            $DTT = $evtobj->_add_relation_to($DTM, 'Datetime');
1148
-            //load DTT helper
1149
-            //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date.
1150
-            if ($DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end')) {
1151
-                $DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start'));
1152
-                $DTT = EEH_DTT_Helper::date_time_add($DTT, 'DTT_EVT_end', 'days');
1153
-                $DTT->save();
1154
-            }
1155
-            //now we got to make sure we add the new DTT_ID to the $saved_dtts array  because it is possible there was a new one created for the autosave.
1156
-            $saved_dtt = $DTT;
1157
-            $success = ! $success ? $success : $DTT;
1158
-            //if ANY of these updates fail then we want the appropriate global error message.
1159
-            // //todo this is actually sucky we need a better error message but this is what it is for now.
1160
-        }
1161
-        //no dtts get deleted so we don't do any of that logic here.
1162
-        //update tickets next
1163
-        $old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array();
1164
-        foreach ($data['edit_tickets'] as $row => $tkt) {
1165
-            $incoming_date_formats = array('Y-m-d', 'h:i a');
1166
-            $update_prices = false;
1167
-            $ticket_price = isset($data['edit_prices'][$row][1]['PRC_amount'])
1168
-                ? $data['edit_prices'][$row][1]['PRC_amount'] : 0;
1169
-            // trim inputs to ensure any excess whitespace is removed.
1170
-            $tkt = array_map('trim', $tkt);
1171
-            if (empty($tkt['TKT_start_date'])) {
1172
-                //let's use now in the set timezone.
1173
-                $now = new DateTime('now', new DateTimeZone($evtobj->get_timezone()));
1174
-                $tkt['TKT_start_date'] = $now->format($incoming_date_formats[0] . ' ' . $incoming_date_formats[1]);
1175
-            }
1176
-            if (empty($tkt['TKT_end_date'])) {
1177
-                //use the start date of the first datetime
1178
-                $dtt = $evtobj->first_datetime();
1179
-                $tkt['TKT_end_date'] = $dtt->start_date_and_time(
1180
-                    $incoming_date_formats[0],
1181
-                    $incoming_date_formats[1]
1182
-                );
1183
-            }
1184
-            $TKT_values = array(
1185
-                'TKT_ID'          => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : null,
1186
-                'TTM_ID'          => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0,
1187
-                'TKT_name'        => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '',
1188
-                'TKT_description' => ! empty($tkt['TKT_description']) ? $tkt['TKT_description'] : '',
1189
-                'TKT_start_date'  => $tkt['TKT_start_date'],
1190
-                'TKT_end_date'    => $tkt['TKT_end_date'],
1191
-                'TKT_qty'         => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'],
1192
-                'TKT_uses'        => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'],
1193
-                'TKT_min'         => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'],
1194
-                'TKT_max'         => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'],
1195
-                'TKT_row'         => $row,
1196
-                'TKT_order'       => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : $row,
1197
-                'TKT_price'       => $ticket_price,
1198
-            );
1199
-            //if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly, which means in turn that the prices will become new prices as well.
1200
-            if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) {
1201
-                $TKT_values['TKT_ID'] = 0;
1202
-                $TKT_values['TKT_is_default'] = 0;
1203
-                $TKT_values['TKT_price'] = $ticket_price;
1204
-                $update_prices = true;
1205
-            }
1206
-            //if we have a TKT_ID then we need to get that existing TKT_obj and update it
1207
-            //we actually do our saves a head of doing any add_relations to because its entirely possible that this ticket didn't removed or added to any datetime in the session but DID have it's items modified.
1208
-            //keep in mind that if the TKT has been sold (and we have changed pricing information), then we won't be updating the tkt but instead a new tkt will be created and the old one archived.
1209
-            if ( ! empty($tkt['TKT_ID'])) {
1210
-                $TKT = EE_Registry::instance()
1211
-                                  ->load_model('Ticket', array($evtobj->get_timezone()))
1212
-                                  ->get_one_by_ID($tkt['TKT_ID']);
1213
-                if ($TKT instanceof EE_Ticket) {
1214
-                    $ticket_sold = $TKT->count_related(
1215
-                        'Registration',
1216
-                        array(
1217
-                            array(
1218
-                                'STS_ID' => array(
1219
-                                    'NOT IN',
1220
-                                    array(EEM_Registration::status_id_incomplete),
1221
-                                ),
1222
-                            ),
1223
-                        )
1224
-                    ) > 0 ? true : false;
1225
-                    //let's just check the total price for the existing ticket and determine if it matches the new total price.  if they are different then we create a new ticket (if tkts sold) if they aren't different then we go ahead and modify existing ticket.
1226
-                    $create_new_TKT = $ticket_sold && $ticket_price != $TKT->get('TKT_price')
1227
-                                      && ! $TKT->get(
1228
-                        'TKT_deleted'
1229
-                    ) ? true : false;
1230
-                    $TKT->set_date_format($incoming_date_formats[0]);
1231
-                    $TKT->set_time_format($incoming_date_formats[1]);
1232
-                    //set new values
1233
-                    foreach ($TKT_values as $field => $value) {
1234
-                        if ($field == 'TKT_qty') {
1235
-                            $TKT->set_qty($value);
1236
-                        } else {
1237
-                            $TKT->set($field, $value);
1238
-                        }
1239
-                    }
1240
-                    //if $create_new_TKT is false then we can safely update the existing ticket.  Otherwise we have to create a new ticket.
1241
-                    if ($create_new_TKT) {
1242
-                        //archive the old ticket first
1243
-                        $TKT->set('TKT_deleted', 1);
1244
-                        $TKT->save();
1245
-                        //make sure this ticket is still recorded in our saved_tkts so we don't run it through the regular trash routine.
1246
-                        $saved_tickets[$TKT->ID()] = $TKT;
1247
-                        //create new ticket that's a copy of the existing except a new id of course (and not archived) AND has the new TKT_price associated with it.
1248
-                        $TKT = clone $TKT;
1249
-                        $TKT->set('TKT_ID', 0);
1250
-                        $TKT->set('TKT_deleted', 0);
1251
-                        $TKT->set('TKT_price', $ticket_price);
1252
-                        $TKT->set('TKT_sold', 0);
1253
-                        //now we need to make sure that $new prices are created as well and attached to new ticket.
1254
-                        $update_prices = true;
1255
-                    }
1256
-                    //make sure price is set if it hasn't been already
1257
-                    $TKT->set('TKT_price', $ticket_price);
1258
-                }
1259
-            } else {
1260
-                //no TKT_id so a new TKT
1261
-                $TKT_values['TKT_price'] = $ticket_price;
1262
-                $TKT = EE_Registry::instance()->load_class('Ticket', array($TKT_values), false, false);
1263
-                if ($TKT instanceof EE_Ticket) {
1264
-                    //need to reset values to properly account for the date formats
1265
-                    $TKT->set_date_format($incoming_date_formats[0]);
1266
-                    $TKT->set_time_format($incoming_date_formats[1]);
1267
-                    $TKT->set_timezone($evtobj->get_timezone());
1268
-                    //set new values
1269
-                    foreach ($TKT_values as $field => $value) {
1270
-                        if ($field == 'TKT_qty') {
1271
-                            $TKT->set_qty($value);
1272
-                        } else {
1273
-                            $TKT->set($field, $value);
1274
-                        }
1275
-                    }
1276
-                    $update_prices = true;
1277
-                }
1278
-            }
1279
-            // cap ticket qty by datetime reg limits
1280
-            $TKT->set_qty(min($TKT->qty(), $TKT->qty('reg_limit')));
1281
-            //update ticket.
1282
-            $TKT->save();
1283
-            //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date.
1284
-            if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) {
1285
-                $TKT->set('TKT_end_date', $TKT->get('TKT_start_date'));
1286
-                $TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days');
1287
-                $TKT->save();
1288
-            }
1289
-            //initially let's add the ticket to the dtt
1290
-            $saved_dtt->_add_relation_to($TKT, 'Ticket');
1291
-            $saved_tickets[$TKT->ID()] = $TKT;
1292
-            //add prices to ticket
1293
-            $this->_add_prices_to_ticket($data['edit_prices'][$row], $TKT, $update_prices);
1294
-        }
1295
-        //however now we need to handle permanently deleting tickets via the ui.  Keep in mind that the ui does not allow deleting/archiving tickets that have ticket sold.  However, it does allow for deleting tickets that have no tickets sold, in which case we want to get rid of permanently because there is no need to save in db.
1296
-        $old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets;
1297
-        $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets));
1298
-        foreach ($tickets_removed as $id) {
1299
-            $id = absint($id);
1300
-            //get the ticket for this id
1301
-            $tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id);
1302
-            //need to get all the related datetimes on this ticket and remove from every single one of them (remember this process can ONLY kick off if there are NO tkts_sold)
1303
-            $dtts = $tkt_to_remove->get_many_related('Datetime');
1304
-            foreach ($dtts as $dtt) {
1305
-                $tkt_to_remove->_remove_relation_to($dtt, 'Datetime');
1306
-            }
1307
-            //need to do the same for prices (except these prices can also be deleted because again, tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived))
1308
-            $tkt_to_remove->delete_related_permanently('Price');
1309
-            //finally let's delete this ticket (which should not be blocked at this point b/c we've removed all our relationships)
1310
-            $tkt_to_remove->delete_permanently();
1311
-        }
1312
-        return array($saved_dtt, $saved_tickets);
1313
-    }
1314
-
1315
-
1316
-
1317
-    /**
1318
-     * This attaches a list of given prices to a ticket.
1319
-     * Note we dont' have to worry about ever removing relationships (or archiving prices) because if there is a change
1320
-     * in price information on a ticket, a new ticket is created anyways so the archived ticket will retain the old
1321
-     * price info and prices are automatically "archived" via the ticket.
1322
-     *
1323
-     * @access  private
1324
-     * @param array     $prices     Array of prices from the form.
1325
-     * @param EE_Ticket $ticket     EE_Ticket object that prices are being attached to.
1326
-     * @param bool      $new_prices Whether attach existing incoming prices or create new ones.
1327
-     * @return  void
1328
-     */
1329
-    private function _add_prices_to_ticket($prices, EE_Ticket $ticket, $new_prices = false)
1330
-    {
1331
-        foreach ($prices as $row => $prc) {
1332
-            $PRC_values = array(
1333
-                'PRC_ID'         => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : null,
1334
-                'PRT_ID'         => ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : null,
1335
-                'PRC_amount'     => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0,
1336
-                'PRC_name'       => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '',
1337
-                'PRC_desc'       => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '',
1338
-                'PRC_is_default' => 0, //make sure prices are NOT set as default from this context
1339
-                'PRC_order'      => $row,
1340
-            );
1341
-            if ($new_prices || empty($PRC_values['PRC_ID'])) {
1342
-                $PRC_values['PRC_ID'] = 0;
1343
-                $PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), false, false);
1344
-            } else {
1345
-                $PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']);
1346
-                //update this price with new values
1347
-                foreach ($PRC_values as $field => $newprc) {
1348
-                    $PRC->set($field, $newprc);
1349
-                }
1350
-                $PRC->save();
1351
-            }
1352
-            $ticket->_add_relation_to($PRC, 'Price');
1353
-        }
1354
-    }
1355
-
1356
-
1357
-
1358
-    /**
1359
-     * Add in our autosave ajax handlers
1360
-     *
1361
-     * @return void
1362
-     */
1363
-    protected function _ee_autosave_create_new()
1364
-    {
1365
-        // $this->_ee_autosave_edit();
1366
-    }
1367
-
1368
-
1369
-
1370
-    protected function _ee_autosave_edit()
1371
-    {
1372
-        return; //TEMPORARILY EXITING CAUSE THIS IS A TODO
1373
-    }
1374
-
1375
-
1376
-
1377
-    /**
1378
-     *    _generate_publish_box_extra_content
1379
-     *
1380
-     * @access private
1381
-     * @return void
1382
-     */
1383
-    private function _generate_publish_box_extra_content()
1384
-    {
1385
-        //load formatter helper
1386
-        //args for getting related registrations
1387
-        $approved_query_args = array(
1388
-            array(
1389
-                'REG_deleted' => 0,
1390
-                'STS_ID'      => EEM_Registration::status_id_approved,
1391
-            ),
1392
-        );
1393
-        $not_approved_query_args = array(
1394
-            array(
1395
-                'REG_deleted' => 0,
1396
-                'STS_ID'      => EEM_Registration::status_id_not_approved,
1397
-            ),
1398
-        );
1399
-        $pending_payment_query_args = array(
1400
-            array(
1401
-                'REG_deleted' => 0,
1402
-                'STS_ID'      => EEM_Registration::status_id_pending_payment,
1403
-            ),
1404
-        );
1405
-        // publish box
1406
-        $publish_box_extra_args = array(
1407
-            'view_approved_reg_url'        => add_query_arg(
1408
-                array(
1409
-                    'action'      => 'default',
1410
-                    'event_id'    => $this->_cpt_model_obj->ID(),
1411
-                    '_reg_status' => EEM_Registration::status_id_approved,
1412
-                ),
1413
-                REG_ADMIN_URL
1414
-            ),
1415
-            'view_not_approved_reg_url'    => add_query_arg(
1416
-                array(
1417
-                    'action'      => 'default',
1418
-                    'event_id'    => $this->_cpt_model_obj->ID(),
1419
-                    '_reg_status' => EEM_Registration::status_id_not_approved,
1420
-                ),
1421
-                REG_ADMIN_URL
1422
-            ),
1423
-            'view_pending_payment_reg_url' => add_query_arg(
1424
-                array(
1425
-                    'action'      => 'default',
1426
-                    'event_id'    => $this->_cpt_model_obj->ID(),
1427
-                    '_reg_status' => EEM_Registration::status_id_pending_payment,
1428
-                ),
1429
-                REG_ADMIN_URL
1430
-            ),
1431
-            'approved_regs'                => $this->_cpt_model_obj->count_related(
1432
-                'Registration',
1433
-                $approved_query_args
1434
-            ),
1435
-            'not_approved_regs'            => $this->_cpt_model_obj->count_related(
1436
-                'Registration',
1437
-                $not_approved_query_args
1438
-            ),
1439
-            'pending_payment_regs'         => $this->_cpt_model_obj->count_related(
1440
-                'Registration',
1441
-                $pending_payment_query_args
1442
-            ),
1443
-            'misc_pub_section_class'       => apply_filters(
1444
-                'FHEE_Events_Admin_Page___generate_publish_box_extra_content__misc_pub_section_class',
1445
-                'misc-pub-section'
1446
-            ),
1447
-            //'email_attendees_url' => add_query_arg(
1448
-            //	array(
1449
-            //		'event_admin_reports' => 'event_newsletter',
1450
-            //		'event_id' => $this->_cpt_model_obj->id
1451
-            //	),
1452
-            //	'admin.php?page=espresso_registrations'
1453
-            //),
1454
-        );
1455
-        ob_start();
1456
-        do_action(
1457
-            'AHEE__Events_Admin_Page___generate_publish_box_extra_content__event_editor_overview_add',
1458
-            $this->_cpt_model_obj
1459
-        );
1460
-        $publish_box_extra_args['event_editor_overview_add'] = ob_get_clean();
1461
-        // load template
1462
-        EEH_Template::display_template(
1463
-            EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php',
1464
-            $publish_box_extra_args
1465
-        );
1466
-    }
1467
-
1468
-
1469
-
1470
-    /**
1471
-     * This just returns whatever is set as the _event object property
1472
-     * //todo this will become obsolete once the models are in place
1473
-     *
1474
-     * @return object
1475
-     */
1476
-    public function get_event_object()
1477
-    {
1478
-        return $this->_cpt_model_obj;
1479
-    }
1480
-
1481
-
1482
-
1483
-
1484
-    /** METABOXES * */
1485
-    /**
1486
-     * _register_event_editor_meta_boxes
1487
-     * add all metaboxes related to the event_editor
1488
-     *
1489
-     * @return void
1490
-     */
1491
-    protected function _register_event_editor_meta_boxes()
1492
-    {
1493
-        $this->verify_cpt_object();
1494
-        add_meta_box(
1495
-            'espresso_event_editor_tickets',
1496
-            esc_html__('Event Datetime & Ticket', 'event_espresso'),
1497
-            array($this, 'ticket_metabox'),
1498
-            $this->page_slug,
1499
-            'normal',
1500
-            'high'
1501
-        );
1502
-        add_meta_box(
1503
-            'espresso_event_editor_event_options',
1504
-            esc_html__('Event Registration Options', 'event_espresso'),
1505
-            array($this, 'registration_options_meta_box'),
1506
-            $this->page_slug,
1507
-            'side',
1508
-            'default'
1509
-        );
1510
-        // NOTE: if you're looking for other metaboxes in here,
1511
-        // where a metabox has a related management page in the admin
1512
-        // you will find it setup in the related management page's "_Hooks" file.
1513
-        // i.e. messages metabox is found in "espresso_events_Messages_Hooks.class.php".
1514
-    }
1515
-
1516
-
1517
-
1518
-    public function ticket_metabox()
1519
-    {
1520
-        $existing_datetime_ids = $existing_ticket_ids = array();
1521
-        //defaults for template args
1522
-        $template_args = array(
1523
-            'existing_datetime_ids'    => '',
1524
-            'event_datetime_help_link' => '',
1525
-            'ticket_options_help_link' => '',
1526
-            'time'                     => null,
1527
-            'ticket_rows'              => '',
1528
-            'existing_ticket_ids'      => '',
1529
-            'total_ticket_rows'        => 1,
1530
-            'ticket_js_structure'      => '',
1531
-            'trash_icon'               => 'ee-lock-icon',
1532
-            'disabled'                 => '',
1533
-        );
1534
-        $event_id = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : null;
1535
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1536
-        /**
1537
-         * 1. Start with retrieving Datetimes
1538
-         * 2. Fore each datetime get related tickets
1539
-         * 3. For each ticket get related prices
1540
-         */
1541
-        $times = EE_Registry::instance()->load_model('Datetime')->get_all_event_dates($event_id);
1542
-        /** @type EE_Datetime $first_datetime */
1543
-        $first_datetime = reset($times);
1544
-        //do we get related tickets?
1545
-        if ($first_datetime instanceof EE_Datetime
1546
-            && $first_datetime->ID() !== 0
1547
-        ) {
1548
-            $existing_datetime_ids[] = $first_datetime->get('DTT_ID');
1549
-            $template_args['time'] = $first_datetime;
1550
-            $related_tickets = $first_datetime->tickets(
1551
-                array(
1552
-                    array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)),
1553
-                    'default_where_conditions' => 'none',
1554
-                )
1555
-            );
1556
-            if ( ! empty($related_tickets)) {
1557
-                $template_args['total_ticket_rows'] = count($related_tickets);
1558
-                $row = 0;
1559
-                foreach ($related_tickets as $ticket) {
1560
-                    $existing_ticket_ids[] = $ticket->get('TKT_ID');
1561
-                    $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, false, $row);
1562
-                    $row++;
1563
-                }
1564
-            } else {
1565
-                $template_args['total_ticket_rows'] = 1;
1566
-                /** @type EE_Ticket $ticket */
1567
-                $ticket = EE_Registry::instance()->load_model('Ticket')->create_default_object();
1568
-                $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket);
1569
-            }
1570
-        } else {
1571
-            $template_args['time'] = $times[0];
1572
-            /** @type EE_Ticket $ticket */
1573
-            $ticket = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets();
1574
-            $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket[1]);
1575
-            // NOTE: we're just sending the first default row
1576
-            // (decaf can't manage default tickets so this should be sufficient);
1577
-        }
1578
-        $template_args['event_datetime_help_link'] = $this->_get_help_tab_link(
1579
-            'event_editor_event_datetimes_help_tab'
1580
-        );
1581
-        $template_args['ticket_options_help_link'] = $this->_get_help_tab_link('ticket_options_info');
1582
-        $template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids);
1583
-        $template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids);
1584
-        $template_args['ticket_js_structure'] = $this->_get_ticket_row(
1585
-            EE_Registry::instance()->load_model('Ticket')->create_default_object(),
1586
-            true
1587
-        );
1588
-        $template = apply_filters(
1589
-            'FHEE__Events_Admin_Page__ticket_metabox__template',
1590
-            EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php'
1591
-        );
1592
-        EEH_Template::display_template($template, $template_args);
1593
-    }
1594
-
1595
-
1596
-
1597
-    /**
1598
-     * Setup an individual ticket form for the decaf event editor page
1599
-     *
1600
-     * @access private
1601
-     * @param  EE_Ticket $ticket   the ticket object
1602
-     * @param  boolean   $skeleton whether we're generating a skeleton for js manipulation
1603
-     * @param int        $row
1604
-     * @return string generated html for the ticket row.
1605
-     */
1606
-    private function _get_ticket_row($ticket, $skeleton = false, $row = 0)
1607
-    {
1608
-        $template_args = array(
1609
-            'tkt_status_class'    => ' tkt-status-' . $ticket->ticket_status(),
1610
-            'tkt_archive_class'   => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived'
1611
-                : '',
1612
-            'ticketrow'           => $skeleton ? 'TICKETNUM' : $row,
1613
-            'TKT_ID'              => $ticket->get('TKT_ID'),
1614
-            'TKT_name'            => $ticket->get('TKT_name'),
1615
-            'TKT_start_date'      => $skeleton ? '' : $ticket->get_date('TKT_start_date', 'Y-m-d h:i a'),
1616
-            'TKT_end_date'        => $skeleton ? '' : $ticket->get_date('TKT_end_date', 'Y-m-d h:i a'),
1617
-            'TKT_is_default'      => $ticket->get('TKT_is_default'),
1618
-            'TKT_qty'             => $ticket->get_pretty('TKT_qty', 'input'),
1619
-            'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets',
1620
-            'TKT_sold'            => $skeleton ? 0 : $ticket->get('TKT_sold'),
1621
-            'trash_icon'          => ($skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted')))
1622
-                                     && ( ! empty($ticket) && $ticket->get('TKT_sold') === 0)
1623
-                ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon',
1624
-            'disabled'            => $skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted')) ? ''
1625
-                : ' disabled=disabled',
1626
-        );
1627
-        $price = $ticket->ID() !== 0
1628
-            ? $ticket->get_first_related('Price', array('default_where_conditions' => 'none'))
1629
-            : EE_Registry::instance()->load_model('Price')->create_default_object();
1630
-        $price_args = array(
1631
-            'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign,
1632
-            'PRC_amount'            => $price->get('PRC_amount'),
1633
-            'PRT_ID'                => $price->get('PRT_ID'),
1634
-            'PRC_ID'                => $price->get('PRC_ID'),
1635
-            'PRC_is_default'        => $price->get('PRC_is_default'),
1636
-        );
1637
-        //make sure we have default start and end dates if skeleton
1638
-        //handle rows that should NOT be empty
1639
-        if (empty($template_args['TKT_start_date'])) {
1640
-            //if empty then the start date will be now.
1641
-            $template_args['TKT_start_date'] = date('Y-m-d h:i a', current_time('timestamp'));
1642
-        }
1643
-        if (empty($template_args['TKT_end_date'])) {
1644
-            //get the earliest datetime (if present);
1645
-            $earliest_dtt = $this->_cpt_model_obj->ID() > 0
1646
-                ? $this->_cpt_model_obj->get_first_related(
1647
-                    'Datetime',
1648
-                    array('order_by' => array('DTT_EVT_start' => 'ASC'))
1649
-                )
1650
-                : null;
1651
-            if ( ! empty($earliest_dtt)) {
1652
-                $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a');
1653
-            } else {
1654
-                $template_args['TKT_end_date'] = date(
1655
-                    'Y-m-d h:i a',
1656
-                    mktime(0, 0, 0, date("m"), date("d") + 7, date("Y"))
1657
-                );
1658
-            }
1659
-        }
1660
-        $template_args = array_merge($template_args, $price_args);
1661
-        $template = apply_filters(
1662
-            'FHEE__Events_Admin_Page__get_ticket_row__template',
1663
-            EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php',
1664
-            $ticket
1665
-        );
1666
-        return EEH_Template::display_template($template, $template_args, true);
1667
-    }
1668
-
1669
-
1670
-
1671
-    public function registration_options_meta_box()
1672
-    {
1673
-        $yes_no_values = array(
1674
-            array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')),
1675
-            array('id' => false, 'text' => esc_html__('No', 'event_espresso')),
1676
-        );
1677
-        $default_reg_status_values = EEM_Registration::reg_status_array(
1678
-            array(
1679
-                EEM_Registration::status_id_cancelled,
1680
-                EEM_Registration::status_id_declined,
1681
-                EEM_Registration::status_id_incomplete,
1682
-            ),
1683
-            true
1684
-        );
1685
-        //$template_args['is_active_select'] = EEH_Form_Fields::select_input('is_active', $yes_no_values, $this->_cpt_model_obj->is_active());
1686
-        $template_args['_event'] = $this->_cpt_model_obj;
1687
-        $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false);
1688
-        $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit();
1689
-        $template_args['default_registration_status'] = EEH_Form_Fields::select_input(
1690
-            'default_reg_status',
1691
-            $default_reg_status_values,
1692
-            $this->_cpt_model_obj->default_registration_status()
1693
-        );
1694
-        $template_args['display_description'] = EEH_Form_Fields::select_input(
1695
-            'display_desc',
1696
-            $yes_no_values,
1697
-            $this->_cpt_model_obj->display_description()
1698
-        );
1699
-        $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input(
1700
-            'display_ticket_selector',
1701
-            $yes_no_values,
1702
-            $this->_cpt_model_obj->display_ticket_selector(),
1703
-            '',
1704
-            '',
1705
-            false
1706
-        );
1707
-        $template_args['additional_registration_options'] = apply_filters(
1708
-            'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options',
1709
-            '',
1710
-            $template_args,
1711
-            $yes_no_values,
1712
-            $default_reg_status_values
1713
-        );
1714
-        EEH_Template::display_template(
1715
-            EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php',
1716
-            $template_args
1717
-        );
1718
-    }
1719
-
1720
-
1721
-
1722
-    /**
1723
-     * _get_events()
1724
-     * This method simply returns all the events (for the given _view and paging)
1725
-     *
1726
-     * @access public
1727
-     * @param int  $per_page     count of items per page (20 default);
1728
-     * @param int  $current_page what is the current page being viewed.
1729
-     * @param bool $count        if TRUE then we just return a count of ALL events matching the given _view.
1730
-     *                           If FALSE then we return an array of event objects
1731
-     *                           that match the given _view and paging parameters.
1732
-     * @return array an array of event objects.
1733
-     */
1734
-    public function get_events($per_page = 10, $current_page = 1, $count = false)
1735
-    {
1736
-        $EEME = $this->_event_model();
1737
-        $offset = ($current_page - 1) * $per_page;
1738
-        $limit = $count ? null : $offset . ',' . $per_page;
1739
-        $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID';
1740
-        $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC";
1741
-        if (isset($this->_req_data['month_range'])) {
1742
-            $pieces = explode(' ', $this->_req_data['month_range'], 3);
1743
-            $month_r = ! empty($pieces[0]) ? date('m', strtotime($pieces[0])) : '';
1744
-            $year_r = ! empty($pieces[1]) ? $pieces[1] : '';
1745
-        }
1746
-        $where = array();
1747
-        $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null;
1748
-        //determine what post_status our condition will have for the query.
1749
-        switch ($status) {
1750
-            case 'month' :
1751
-            case 'today' :
1752
-            case null :
1753
-            case 'all' :
1754
-                break;
1755
-            case 'draft' :
1756
-                $where['status'] = array('IN', array('draft', 'auto-draft'));
1757
-                break;
1758
-            default :
1759
-                $where['status'] = $status;
1760
-        }
1761
-        //categories?
1762
-        $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0
1763
-            ? $this->_req_data['EVT_CAT'] : null;
1764
-        if ( ! empty ($category)) {
1765
-            $where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories';
1766
-            $where['Term_Taxonomy.term_id'] = $category;
1767
-        }
1768
-        //date where conditions
1769
-        $start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start');
1770
-        if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') {
1771
-            $DateTime = new DateTime(
1772
-                $year_r . '-' . $month_r . '-01 00:00:00',
1773
-                new DateTimeZone(EEM_Datetime::instance()->get_timezone())
1774
-            );
1775
-            $start = $DateTime->format(implode(' ', $start_formats));
1776
-            $end = $DateTime->setDate($year_r, $month_r, $DateTime
1777
-                ->format('t'))->setTime(23, 59, 59)
1778
-                            ->format(implode(' ', $start_formats));
1779
-            $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1780
-        } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'today') {
1781
-            $DateTime = new DateTime('now', new DateTimeZone(EEM_Event::instance()->get_timezone()));
1782
-            $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats));
1783
-            $end = $DateTime->setTime(23, 59, 59)->format(implode(' ', $start_formats));
1784
-            $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1785
-        } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'month') {
1786
-            $now = date('Y-m-01');
1787
-            $DateTime = new DateTime($now, new DateTimeZone(EEM_Event::instance()->get_timezone()));
1788
-            $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats));
1789
-            $end = $DateTime->setDate(date('Y'), date('m'), $DateTime->format('t'))
1790
-                            ->setTime(23, 59, 59)
1791
-                            ->format(implode(' ', $start_formats));
1792
-            $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1793
-        }
1794
-        if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) {
1795
-            $where['EVT_wp_user'] = get_current_user_id();
1796
-        } else {
1797
-            if ( ! isset($where['status'])) {
1798
-                if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) {
1799
-                    $where['OR'] = array(
1800
-                        'status*restrict_private' => array('!=', 'private'),
1801
-                        'AND'                     => array(
1802
-                            'status*inclusive' => array('=', 'private'),
1803
-                            'EVT_wp_user'      => get_current_user_id(),
1804
-                        ),
1805
-                    );
1806
-                }
1807
-            }
1808
-        }
1809
-        if (isset($this->_req_data['EVT_wp_user'])) {
1810
-            if ($this->_req_data['EVT_wp_user'] != get_current_user_id()
1811
-                && EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')
1812
-            ) {
1813
-                $where['EVT_wp_user'] = $this->_req_data['EVT_wp_user'];
1814
-            }
1815
-        }
1816
-        //search query handling
1817
-        if (isset($this->_req_data['s'])) {
1818
-            $search_string = '%' . $this->_req_data['s'] . '%';
1819
-            $where['OR'] = array(
1820
-                'EVT_name'       => array('LIKE', $search_string),
1821
-                'EVT_desc'       => array('LIKE', $search_string),
1822
-                'EVT_short_desc' => array('LIKE', $search_string),
1823
-            );
1824
-        }
1825
-        $where = apply_filters('FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data);
1826
-        $query_params = apply_filters(
1827
-            'FHEE__Events_Admin_Page__get_events__query_params',
1828
-            array(
1829
-                $where,
1830
-                'limit'    => $limit,
1831
-                'order_by' => $orderby,
1832
-                'order'    => $order,
1833
-                'group_by' => 'EVT_ID',
1834
-            ),
1835
-            $this->_req_data
1836
-        );
1837
-        //let's first check if we have special requests coming in.
1838
-        if (isset($this->_req_data['active_status'])) {
1839
-            switch ($this->_req_data['active_status']) {
1840
-                case 'upcoming' :
1841
-                    return $EEME->get_upcoming_events($query_params, $count);
1842
-                    break;
1843
-                case 'expired' :
1844
-                    return $EEME->get_expired_events($query_params, $count);
1845
-                    break;
1846
-                case 'active' :
1847
-                    return $EEME->get_active_events($query_params, $count);
1848
-                    break;
1849
-                case 'inactive' :
1850
-                    return $EEME->get_inactive_events($query_params, $count);
1851
-                    break;
1852
-            }
1853
-        }
1854
-        $events = $count ? $EEME->count(array($where), 'EVT_ID', true) : $EEME->get_all($query_params);
1855
-        return $events;
1856
-    }
1857
-
1858
-
1859
-
1860
-    /**
1861
-     * handling for WordPress CPT actions (trash, restore, delete)
1862
-     *
1863
-     * @param string $post_id
1864
-     */
1865
-    public function trash_cpt_item($post_id)
1866
-    {
1867
-        $this->_req_data['EVT_ID'] = $post_id;
1868
-        $this->_trash_or_restore_event('trash', false);
1869
-    }
1870
-
1871
-
1872
-
1873
-    /**
1874
-     * @param string $post_id
1875
-     */
1876
-    public function restore_cpt_item($post_id)
1877
-    {
1878
-        $this->_req_data['EVT_ID'] = $post_id;
1879
-        $this->_trash_or_restore_event('draft', false);
1880
-    }
1881
-
1882
-
1883
-
1884
-    /**
1885
-     * @param string $post_id
1886
-     */
1887
-    public function delete_cpt_item($post_id)
1888
-    {
1889
-        $this->_req_data['EVT_ID'] = $post_id;
1890
-        $this->_delete_event(false);
1891
-    }
1892
-
1893
-
1894
-
1895
-    /**
1896
-     * _trash_or_restore_event
1897
-     *
1898
-     * @access protected
1899
-     * @param  string $event_status
1900
-     * @param bool    $redirect_after
1901
-     */
1902
-    protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = true)
1903
-    {
1904
-        //determine the event id and set to array.
1905
-        $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : false;
1906
-        // loop thru events
1907
-        if ($EVT_ID) {
1908
-            // clean status
1909
-            $event_status = sanitize_key($event_status);
1910
-            // grab status
1911
-            if ( ! empty($event_status)) {
1912
-                $success = $this->_change_event_status($EVT_ID, $event_status);
1913
-            } else {
1914
-                $success = false;
1915
-                $msg = esc_html__(
1916
-                    'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.',
1917
-                    'event_espresso'
1918
-                );
1919
-                EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1920
-            }
1921
-        } else {
1922
-            $success = false;
1923
-            $msg = esc_html__(
1924
-                'An error occurred. The event could not be moved to the trash because a valid event ID was not not supplied.',
1925
-                'event_espresso'
1926
-            );
1927
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1928
-        }
1929
-        $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash';
1930
-        if ($redirect_after) {
1931
-            $this->_redirect_after_action($success, 'Event', $action, array('action' => 'default'));
1932
-        }
1933
-    }
1934
-
1935
-
1936
-
1937
-    /**
1938
-     * _trash_or_restore_events
1939
-     *
1940
-     * @access protected
1941
-     * @param  string $event_status
1942
-     * @return void
1943
-     */
1944
-    protected function _trash_or_restore_events($event_status = 'trash')
1945
-    {
1946
-        // clean status
1947
-        $event_status = sanitize_key($event_status);
1948
-        // grab status
1949
-        if ( ! empty($event_status)) {
1950
-            $success = true;
1951
-            //determine the event id and set to array.
1952
-            $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array();
1953
-            // loop thru events
1954
-            foreach ($EVT_IDs as $EVT_ID) {
1955
-                if ($EVT_ID = absint($EVT_ID)) {
1956
-                    $results = $this->_change_event_status($EVT_ID, $event_status);
1957
-                    $success = $results !== false ? $success : false;
1958
-                } else {
1959
-                    $msg = sprintf(
1960
-                        esc_html__(
1961
-                            'An error occurred. Event #%d could not be moved to the trash because a valid event ID was not not supplied.',
1962
-                            'event_espresso'
1963
-                        ),
1964
-                        $EVT_ID
1965
-                    );
1966
-                    EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1967
-                    $success = false;
1968
-                }
1969
-            }
1970
-        } else {
1971
-            $success = false;
1972
-            $msg = esc_html__(
1973
-                'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.',
1974
-                'event_espresso'
1975
-            );
1976
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1977
-        }
1978
-        // in order to force a pluralized result message we need to send back a success status greater than 1
1979
-        $success = $success ? 2 : false;
1980
-        $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash';
1981
-        $this->_redirect_after_action($success, 'Events', $action, array('action' => 'default'));
1982
-    }
1983
-
1984
-
1985
-
1986
-    /**
1987
-     * _trash_or_restore_events
1988
-     *
1989
-     * @access  private
1990
-     * @param  int    $EVT_ID
1991
-     * @param  string $event_status
1992
-     * @return bool
1993
-     */
1994
-    private function _change_event_status($EVT_ID = 0, $event_status = '')
1995
-    {
1996
-        // grab event id
1997
-        if ( ! $EVT_ID) {
1998
-            $msg = esc_html__(
1999
-                'An error occurred. No Event ID or an invalid Event ID was received.',
2000
-                'event_espresso'
2001
-            );
2002
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2003
-            return false;
2004
-        }
2005
-        $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID);
2006
-        // clean status
2007
-        $event_status = sanitize_key($event_status);
2008
-        // grab status
2009
-        if (empty($event_status)) {
2010
-            $msg = esc_html__(
2011
-                'An error occurred. No Event Status or an invalid Event Status was received.',
2012
-                'event_espresso'
2013
-            );
2014
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2015
-            return false;
2016
-        }
2017
-        // was event trashed or restored ?
2018
-        switch ($event_status) {
2019
-            case 'draft' :
2020
-                $action = 'restored from the trash';
2021
-                $hook = 'AHEE_event_restored_from_trash';
2022
-                break;
2023
-            case 'trash' :
2024
-                $action = 'moved to the trash';
2025
-                $hook = 'AHEE_event_moved_to_trash';
2026
-                break;
2027
-            default :
2028
-                $action = 'updated';
2029
-                $hook = false;
2030
-        }
2031
-        //use class to change status
2032
-        $this->_cpt_model_obj->set_status($event_status);
2033
-        $success = $this->_cpt_model_obj->save();
2034
-        if ($success === false) {
2035
-            $msg = sprintf(esc_html__('An error occurred. The event could not be %s.', 'event_espresso'), $action);
2036
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2037
-            return false;
2038
-        }
2039
-        if ($hook) {
2040
-            do_action($hook);
2041
-        }
2042
-        return true;
2043
-    }
2044
-
2045
-
2046
-
2047
-    /**
2048
-     * _delete_event
2049
-     *
2050
-     * @access protected
2051
-     * @param bool $redirect_after
2052
-     */
2053
-    protected function _delete_event($redirect_after = true)
2054
-    {
2055
-        //determine the event id and set to array.
2056
-        $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : null;
2057
-        $EVT_ID = isset($this->_req_data['post']) ? absint($this->_req_data['post']) : $EVT_ID;
2058
-        // loop thru events
2059
-        if ($EVT_ID) {
2060
-            $success = $this->_permanently_delete_event($EVT_ID);
2061
-            // get list of events with no prices
2062
-            $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array());
2063
-            // remove this event from the list of events with no prices
2064
-            if (isset($espresso_no_ticket_prices[$EVT_ID])) {
2065
-                unset($espresso_no_ticket_prices[$EVT_ID]);
2066
-            }
2067
-            update_option('ee_no_ticket_prices', $espresso_no_ticket_prices);
2068
-        } else {
2069
-            $success = false;
2070
-            $msg = esc_html__(
2071
-                'An error occurred. An event could not be deleted because a valid event ID was not not supplied.',
2072
-                'event_espresso'
2073
-            );
2074
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2075
-        }
2076
-        if ($redirect_after) {
2077
-            $this->_redirect_after_action(
2078
-                $success,
2079
-                'Event',
2080
-                'deleted',
2081
-                array('action' => 'default', 'status' => 'trash')
2082
-            );
2083
-        }
2084
-    }
2085
-
2086
-
2087
-
2088
-    /**
2089
-     * _delete_events
2090
-     *
2091
-     * @access protected
2092
-     * @return void
2093
-     */
2094
-    protected function _delete_events()
2095
-    {
2096
-        $success = true;
2097
-        // get list of events with no prices
2098
-        $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array());
2099
-        //determine the event id and set to array.
2100
-        $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array();
2101
-        // loop thru events
2102
-        foreach ($EVT_IDs as $EVT_ID) {
2103
-            $EVT_ID = absint($EVT_ID);
2104
-            if ($EVT_ID) {
2105
-                $results = $this->_permanently_delete_event($EVT_ID);
2106
-                $success = $results !== false ? $success : false;
2107
-                // remove this event from the list of events with no prices
2108
-                unset($espresso_no_ticket_prices[$EVT_ID]);
2109
-            } else {
2110
-                $success = false;
2111
-                $msg = esc_html__(
2112
-                    'An error occurred. An event could not be deleted because a valid event ID was not not supplied.',
2113
-                    'event_espresso'
2114
-                );
2115
-                EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2116
-            }
2117
-        }
2118
-        update_option('ee_no_ticket_prices', $espresso_no_ticket_prices);
2119
-        // in order to force a pluralized result message we need to send back a success status greater than 1
2120
-        $success = $success ? 2 : false;
2121
-        $this->_redirect_after_action($success, 'Events', 'deleted', array('action' => 'default'));
2122
-    }
2123
-
2124
-
2125
-
2126
-    /**
2127
-     * _permanently_delete_event
2128
-     *
2129
-     * @access  private
2130
-     * @param  int $EVT_ID
2131
-     * @return bool
2132
-     */
2133
-    private function _permanently_delete_event($EVT_ID = 0)
2134
-    {
2135
-        // grab event id
2136
-        if ( ! $EVT_ID) {
2137
-            $msg = esc_html__(
2138
-                'An error occurred. No Event ID or an invalid Event ID was received.',
2139
-                'event_espresso'
2140
-            );
2141
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2142
-            return false;
2143
-        }
2144
-        if (
2145
-            ! $this->_cpt_model_obj instanceof EE_Event
2146
-            || $this->_cpt_model_obj->ID() !== $EVT_ID
2147
-        ) {
2148
-            $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID);
2149
-        }
2150
-        if ( ! $this->_cpt_model_obj instanceof EE_Event) {
2151
-            return false;
2152
-        }
2153
-        //need to delete related tickets and prices first.
2154
-        $datetimes = $this->_cpt_model_obj->get_many_related('Datetime');
2155
-        foreach ($datetimes as $datetime) {
2156
-            $this->_cpt_model_obj->_remove_relation_to($datetime, 'Datetime');
2157
-            $tickets = $datetime->get_many_related('Ticket');
2158
-            foreach ($tickets as $ticket) {
2159
-                $ticket->_remove_relation_to($datetime, 'Datetime');
2160
-                $ticket->delete_related_permanently('Price');
2161
-                $ticket->delete_permanently();
2162
-            }
2163
-            $datetime->delete();
2164
-        }
2165
-        //what about related venues or terms?
2166
-        $venues = $this->_cpt_model_obj->get_many_related('Venue');
2167
-        foreach ($venues as $venue) {
2168
-            $this->_cpt_model_obj->_remove_relation_to($venue, 'Venue');
2169
-        }
2170
-        //any attached question groups?
2171
-        $question_groups = $this->_cpt_model_obj->get_many_related('Question_Group');
2172
-        if ( ! empty($question_groups)) {
2173
-            foreach ($question_groups as $question_group) {
2174
-                $this->_cpt_model_obj->_remove_relation_to($question_group, 'Question_Group');
2175
-            }
2176
-        }
2177
-        //Message Template Groups
2178
-        $this->_cpt_model_obj->_remove_relations('Message_Template_Group');
2179
-        /** @type EE_Term_Taxonomy[] $term_taxonomies */
2180
-        $term_taxonomies = $this->_cpt_model_obj->term_taxonomies();
2181
-        foreach ($term_taxonomies as $term_taxonomy) {
2182
-            $this->_cpt_model_obj->remove_relation_to_term_taxonomy($term_taxonomy);
2183
-        }
2184
-        $success = $this->_cpt_model_obj->delete_permanently();
2185
-        // did it all go as planned ?
2186
-        if ($success) {
2187
-            $msg = sprintf(esc_html__('Event ID # %d has been deleted.', 'event_espresso'), $EVT_ID);
2188
-            EE_Error::add_success($msg);
2189
-        } else {
2190
-            $msg = sprintf(
2191
-                esc_html__('An error occurred. Event ID # %d could not be deleted.', 'event_espresso'),
2192
-                $EVT_ID
2193
-            );
2194
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2195
-            return false;
2196
-        }
2197
-        do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID);
2198
-        return true;
2199
-    }
2200
-
2201
-
2202
-
2203
-    /**
2204
-     * get total number of events
2205
-     *
2206
-     * @access public
2207
-     * @return int
2208
-     */
2209
-    public function total_events()
2210
-    {
2211
-        $count = EEM_Event::instance()->count(array('caps' => 'read_admin'), 'EVT_ID', true);
2212
-        return $count;
2213
-    }
2214
-
2215
-
2216
-
2217
-    /**
2218
-     * get total number of draft events
2219
-     *
2220
-     * @access public
2221
-     * @return int
2222
-     */
2223
-    public function total_events_draft()
2224
-    {
2225
-        $where = array(
2226
-            'status' => array('IN', array('draft', 'auto-draft')),
2227
-        );
2228
-        $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
2229
-        return $count;
2230
-    }
2231
-
2232
-
2233
-
2234
-    /**
2235
-     * get total number of trashed events
2236
-     *
2237
-     * @access public
2238
-     * @return int
2239
-     */
2240
-    public function total_trashed_events()
2241
-    {
2242
-        $where = array(
2243
-            'status' => 'trash',
2244
-        );
2245
-        $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
2246
-        return $count;
2247
-    }
2248
-
2249
-
2250
-
2251
-    /**
2252
-     *    _default_event_settings
2253
-     *    This generates the Default Settings Tab
2254
-     *
2255
-     * @return void
2256
-     */
2257
-    protected function _default_event_settings()
2258
-    {
2259
-        $this->_template_args['values'] = $this->_yes_no_values;
2260
-        $this->_template_args['reg_status_array'] = EEM_Registration::reg_status_array(
2261
-        // exclude array
2262
-            array(
2263
-                EEM_Registration::status_id_cancelled,
2264
-                EEM_Registration::status_id_declined,
2265
-                EEM_Registration::status_id_incomplete,
2266
-                EEM_Registration::status_id_wait_list,
2267
-            ),
2268
-            // translated
2269
-            true
2270
-        );
2271
-        $this->_template_args['default_reg_status'] = isset(
2272
-                                                          EE_Registry::instance()->CFG->registration->default_STS_ID
2273
-                                                      )
2274
-                                                      && array_key_exists(
2275
-                                                          EE_Registry::instance()->CFG->registration->default_STS_ID,
2276
-                                                          $this->_template_args['reg_status_array']
2277
-                                                      )
2278
-            ? sanitize_text_field(EE_Registry::instance()->CFG->registration->default_STS_ID)
2279
-            : EEM_Registration::status_id_pending_payment;
2280
-        $this->_set_add_edit_form_tags('update_default_event_settings');
2281
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
2282
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2283
-            EVENTS_TEMPLATE_PATH . 'event_settings.template.php',
2284
-            $this->_template_args,
2285
-            true
2286
-        );
2287
-        $this->display_admin_page_with_sidebar();
2288
-    }
2289
-
2290
-
2291
-
2292
-    /**
2293
-     * _update_default_event_settings
2294
-     *
2295
-     * @access protected
2296
-     * @return void
2297
-     */
2298
-    protected function _update_default_event_settings()
2299
-    {
2300
-        EE_Config::instance()->registration->default_STS_ID = isset($this->_req_data['default_reg_status'])
2301
-            ? sanitize_text_field($this->_req_data['default_reg_status'])
2302
-            : EEM_Registration::status_id_pending_payment;
2303
-        $what = 'Default Event Settings';
2304
-        $success = $this->_update_espresso_configuration(
2305
-            $what,
2306
-            EE_Config::instance(),
2307
-            __FILE__,
2308
-            __FUNCTION__,
2309
-            __LINE__
2310
-        );
2311
-        $this->_redirect_after_action($success, $what, 'updated', array('action' => 'default_event_settings'));
2312
-    }
2313
-
2314
-
2315
-
2316
-    /*************        Templates        *************/
2317
-    protected function _template_settings()
2318
-    {
2319
-        $this->_admin_page_title = esc_html__('Template Settings (Preview)', 'event_espresso');
2320
-        $this->_template_args['preview_img'] = '<img src="'
2321
-                                               . EVENTS_ASSETS_URL
2322
-                                               . DS
2323
-                                               . 'images'
2324
-                                               . DS
2325
-                                               . 'caffeinated_template_features.jpg" alt="'
2326
-                                               . esc_attr__('Template Settings Preview screenshot', 'event_espresso')
2327
-                                               . '" />';
2328
-        $this->_template_args['preview_text'] = '<strong>' . esc_html__(
2329
-                'Template Settings is a feature that is only available in the premium version of Event Espresso 4 which is available with a support license purchase on EventEspresso.com. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.',
2330
-                'event_espresso'
2331
-            ) . '</strong>';
2332
-        $this->display_admin_caf_preview_page('template_settings_tab');
2333
-    }
2334
-
2335
-
2336
-    /** Event Category Stuff **/
2337
-    /**
2338
-     * set the _category property with the category object for the loaded page.
2339
-     *
2340
-     * @access private
2341
-     * @return void
2342
-     */
2343
-    private function _set_category_object()
2344
-    {
2345
-        if (isset($this->_category->id) && ! empty($this->_category->id)) {
2346
-            return;
2347
-        } //already have the category object so get out.
2348
-        //set default category object
2349
-        $this->_set_empty_category_object();
2350
-        //only set if we've got an id
2351
-        if ( ! isset($this->_req_data['EVT_CAT_ID'])) {
2352
-            return;
2353
-        }
2354
-        $category_id = absint($this->_req_data['EVT_CAT_ID']);
2355
-        $term = get_term($category_id, 'espresso_event_categories');
2356
-        if ( ! empty($term)) {
2357
-            $this->_category->category_name = $term->name;
2358
-            $this->_category->category_identifier = $term->slug;
2359
-            $this->_category->category_desc = $term->description;
2360
-            $this->_category->id = $term->term_id;
2361
-            $this->_category->parent = $term->parent;
2362
-        }
2363
-    }
2364
-
2365
-
2366
-
2367
-    private function _set_empty_category_object()
2368
-    {
2369
-        $this->_category = new stdClass();
2370
-        $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = '';
2371
-        $this->_category->id = $this->_category->parent = 0;
2372
-    }
2373
-
2374
-
2375
-
2376
-    protected function _category_list_table()
2377
-    {
2378
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2379
-        $this->_search_btn_label = esc_html__('Categories', 'event_espresso');
2380
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
2381
-                'add_category',
2382
-                'add_category',
2383
-                array(),
2384
-                'add-new-h2'
2385
-            );
2386
-        $this->display_admin_list_table_page_with_sidebar();
2387
-    }
2388
-
2389
-
2390
-
2391
-    /**
2392
-     * @param $view
2393
-     */
2394
-    protected function _category_details($view)
2395
-    {
2396
-        //load formatter helper
2397
-        //load field generator helper
2398
-        $route = $view == 'edit' ? 'update_category' : 'insert_category';
2399
-        $this->_set_add_edit_form_tags($route);
2400
-        $this->_set_category_object();
2401
-        $id = ! empty($this->_category->id) ? $this->_category->id : '';
2402
-        $delete_action = 'delete_category';
2403
-        //custom redirect
2404
-        $redirect = EE_Admin_Page::add_query_args_and_nonce(
2405
-            array('action' => 'category_list'),
2406
-            $this->_admin_base_url
2407
-        );
2408
-        $this->_set_publish_post_box_vars('EVT_CAT_ID', $id, $delete_action, $redirect);
2409
-        //take care of contents
2410
-        $this->_template_args['admin_page_content'] = $this->_category_details_content();
2411
-        $this->display_admin_page_with_sidebar();
2412
-    }
2413
-
2414
-
2415
-
2416
-    /**
2417
-     * @return mixed
2418
-     */
2419
-    protected function _category_details_content()
2420
-    {
2421
-        $editor_args['category_desc'] = array(
2422
-            'type'          => 'wp_editor',
2423
-            'value'         => EEH_Formatter::admin_format_content($this->_category->category_desc),
2424
-            'class'         => 'my_editor_custom',
2425
-            'wpeditor_args' => array('media_buttons' => false),
2426
-        );
2427
-        $_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array');
2428
-        $all_terms = get_terms(
2429
-            array('espresso_event_categories'),
2430
-            array('hide_empty' => 0, 'exclude' => array($this->_category->id))
2431
-        );
2432
-        //setup category select for term parents.
2433
-        $category_select_values[] = array(
2434
-            'text' => esc_html__('No Parent', 'event_espresso'),
2435
-            'id'   => 0,
2436
-        );
2437
-        foreach ($all_terms as $term) {
2438
-            $category_select_values[] = array(
2439
-                'text' => $term->name,
2440
-                'id'   => $term->term_id,
2441
-            );
2442
-        }
2443
-        $category_select = EEH_Form_Fields::select_input(
2444
-            'category_parent',
2445
-            $category_select_values,
2446
-            $this->_category->parent
2447
-        );
2448
-        $template_args = array(
2449
-            'category'                 => $this->_category,
2450
-            'category_select'          => $category_select,
2451
-            'unique_id_info_help_link' => $this->_get_help_tab_link('unique_id_info'),
2452
-            'category_desc_editor'     => $_wp_editor['category_desc']['field'],
2453
-            'disable'                  => '',
2454
-            'disabled_message'         => false,
2455
-        );
2456
-        $template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php';
2457
-        return EEH_Template::display_template($template, $template_args, true);
2458
-    }
2459
-
2460
-
2461
-
2462
-    protected function _delete_categories()
2463
-    {
2464
-        $cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array)$this->_req_data['EVT_CAT_ID']
2465
-            : (array)$this->_req_data['category_id'];
2466
-        foreach ($cat_ids as $cat_id) {
2467
-            $this->_delete_category($cat_id);
2468
-        }
2469
-        //doesn't matter what page we're coming from... we're going to the same place after delete.
2470
-        $query_args = array(
2471
-            'action' => 'category_list',
2472
-        );
2473
-        $this->_redirect_after_action(0, '', '', $query_args);
2474
-    }
2475
-
2476
-
2477
-
2478
-    /**
2479
-     * @param $cat_id
2480
-     */
2481
-    protected function _delete_category($cat_id)
2482
-    {
2483
-        $cat_id = absint($cat_id);
2484
-        wp_delete_term($cat_id, 'espresso_event_categories');
2485
-    }
2486
-
2487
-
2488
-
2489
-    /**
2490
-     * @param $new_category
2491
-     */
2492
-    protected function _insert_or_update_category($new_category)
2493
-    {
2494
-        $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category(true);
2495
-        $success = 0; //we already have a success message so lets not send another.
2496
-        if ($cat_id) {
2497
-            $query_args = array(
2498
-                'action'     => 'edit_category',
2499
-                'EVT_CAT_ID' => $cat_id,
2500
-            );
2501
-        } else {
2502
-            $query_args = array('action' => 'add_category');
2503
-        }
2504
-        $this->_redirect_after_action($success, '', '', $query_args, true);
2505
-    }
2506
-
2507
-
2508
-
2509
-    /**
2510
-     * @param bool $update
2511
-     * @return bool|mixed|string
2512
-     */
2513
-    private function _insert_category($update = false)
2514
-    {
2515
-        $cat_id = $update ? $this->_req_data['EVT_CAT_ID'] : '';
2516
-        $category_name = isset($this->_req_data['category_name']) ? $this->_req_data['category_name'] : '';
2517
-        $category_desc = isset($this->_req_data['category_desc']) ? $this->_req_data['category_desc'] : '';
2518
-        $category_parent = isset($this->_req_data['category_parent']) ? $this->_req_data['category_parent'] : 0;
2519
-        if (empty($category_name)) {
2520
-            $msg = esc_html__('You must add a name for the category.', 'event_espresso');
2521
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2522
-            return false;
2523
-        }
2524
-        $term_args = array(
2525
-            'name'        => $category_name,
2526
-            'description' => $category_desc,
2527
-            'parent'      => $category_parent,
2528
-        );
2529
-        //was the category_identifier input disabled?
2530
-        if (isset($this->_req_data['category_identifier'])) {
2531
-            $term_args['slug'] = $this->_req_data['category_identifier'];
2532
-        }
2533
-        $insert_ids = $update
2534
-            ? wp_update_term($cat_id, 'espresso_event_categories', $term_args)
2535
-            : wp_insert_term($category_name, 'espresso_event_categories', $term_args);
2536
-        if ( ! is_array($insert_ids)) {
2537
-            $msg = esc_html__(
2538
-                'An error occurred and the category has not been saved to the database.',
2539
-                'event_espresso'
2540
-            );
2541
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2542
-        } else {
2543
-            $cat_id = $insert_ids['term_id'];
2544
-            $msg = sprintf(esc_html__('The category %s was successfully saved', 'event_espresso'), $category_name);
2545
-            EE_Error::add_success($msg);
2546
-        }
2547
-        return $cat_id;
2548
-    }
2549
-
2550
-
2551
-
2552
-    /**
2553
-     * @param int  $per_page
2554
-     * @param int  $current_page
2555
-     * @param bool $count
2556
-     * @return \EE_Base_Class[]|int
2557
-     */
2558
-    public function get_categories($per_page = 10, $current_page = 1, $count = false)
2559
-    {
2560
-        //testing term stuff
2561
-        $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'Term.term_id';
2562
-        $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC';
2563
-        $limit = ($current_page - 1) * $per_page;
2564
-        $where = array('taxonomy' => 'espresso_event_categories');
2565
-        if (isset($this->_req_data['s'])) {
2566
-            $sstr = '%' . $this->_req_data['s'] . '%';
2567
-            $where['OR'] = array(
2568
-                'Term.name'   => array('LIKE', $sstr),
2569
-                'description' => array('LIKE', $sstr),
2570
-            );
2571
-        }
2572
-        $query_params = array(
2573
-            $where,
2574
-            'order_by'   => array($orderby => $order),
2575
-            'limit'      => $limit . ',' . $per_page,
2576
-            'force_join' => array('Term'),
2577
-        );
2578
-        $categories = $count
2579
-            ? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id')
2580
-            : EEM_Term_Taxonomy::instance()->get_all($query_params);
2581
-        return $categories;
2582
-    }
2583
-
2584
-
2585
-
2586
-    /* end category stuff */
2587
-    /**************/
385
+				'qtips'         => array('EE_Event_Editor_Decaf_Tips'),
386
+				'require_nonce' => false,
387
+			),
388
+			'default_event_settings' => array(
389
+				'nav'           => array(
390
+					'label' => esc_html__('Default Settings', 'event_espresso'),
391
+					'order' => 40,
392
+				),
393
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
394
+				'labels'        => array(
395
+					'publishbox' => esc_html__('Update Settings', 'event_espresso'),
396
+				),
397
+				'help_tabs'     => array(
398
+					'default_settings_help_tab'        => array(
399
+						'title'    => esc_html__('Default Event Settings', 'event_espresso'),
400
+						'filename' => 'events_default_settings',
401
+					),
402
+					'default_settings_status_help_tab' => array(
403
+						'title'    => esc_html__('Default Registration Status', 'event_espresso'),
404
+						'filename' => 'events_default_settings_status',
405
+					),
406
+				),
407
+				'help_tour'     => array('Event_Default_Settings_Help_Tour'),
408
+				'require_nonce' => false,
409
+			),
410
+			//template settings
411
+			'template_settings'      => array(
412
+				'nav'           => array(
413
+					'label' => esc_html__('Templates', 'event_espresso'),
414
+					'order' => 30,
415
+				),
416
+				'metaboxes'     => $this->_default_espresso_metaboxes,
417
+				'help_tabs'     => array(
418
+					'general_settings_templates_help_tab' => array(
419
+						'title'    => esc_html__('Templates', 'event_espresso'),
420
+						'filename' => 'general_settings_templates',
421
+					),
422
+				),
423
+				'help_tour'     => array('Templates_Help_Tour'),
424
+				'require_nonce' => false,
425
+			),
426
+			//event category stuff
427
+			'add_category'           => array(
428
+				'nav'           => array(
429
+					'label'      => esc_html__('Add Category', 'event_espresso'),
430
+					'order'      => 15,
431
+					'persistent' => false,
432
+				),
433
+				'help_tabs'     => array(
434
+					'add_category_help_tab' => array(
435
+						'title'    => esc_html__('Add New Event Category', 'event_espresso'),
436
+						'filename' => 'events_add_category',
437
+					),
438
+				),
439
+				'help_tour'     => array('Event_Add_Category_Help_Tour'),
440
+				'metaboxes'     => array('_publish_post_box'),
441
+				'require_nonce' => false,
442
+			),
443
+			'edit_category'          => array(
444
+				'nav'           => array(
445
+					'label'      => esc_html__('Edit Category', 'event_espresso'),
446
+					'order'      => 15,
447
+					'persistent' => false,
448
+					'url'        => isset($this->_req_data['EVT_CAT_ID'])
449
+						? add_query_arg(
450
+							array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID']),
451
+							$this->_current_page_view_url
452
+						)
453
+						: $this->_admin_base_url,
454
+				),
455
+				'help_tabs'     => array(
456
+					'edit_category_help_tab' => array(
457
+						'title'    => esc_html__('Edit Event Category', 'event_espresso'),
458
+						'filename' => 'events_edit_category',
459
+					),
460
+				),
461
+				/*'help_tour' => array('Event_Edit_Category_Help_Tour'),*/
462
+				'metaboxes'     => array('_publish_post_box'),
463
+				'require_nonce' => false,
464
+			),
465
+			'category_list'          => array(
466
+				'nav'           => array(
467
+					'label' => esc_html__('Categories', 'event_espresso'),
468
+					'order' => 20,
469
+				),
470
+				'list_table'    => 'Event_Categories_Admin_List_Table',
471
+				'help_tabs'     => array(
472
+					'events_categories_help_tab'                       => array(
473
+						'title'    => esc_html__('Event Categories', 'event_espresso'),
474
+						'filename' => 'events_categories',
475
+					),
476
+					'events_categories_table_column_headings_help_tab' => array(
477
+						'title'    => esc_html__('Event Categories Table Column Headings', 'event_espresso'),
478
+						'filename' => 'events_categories_table_column_headings',
479
+					),
480
+					'events_categories_view_help_tab'                  => array(
481
+						'title'    => esc_html__('Event Categories Views', 'event_espresso'),
482
+						'filename' => 'events_categories_views',
483
+					),
484
+					'events_categories_other_help_tab'                 => array(
485
+						'title'    => esc_html__('Event Categories Other', 'event_espresso'),
486
+						'filename' => 'events_categories_other',
487
+					),
488
+				),
489
+				'help_tour'     => array(
490
+					'Event_Categories_Help_Tour',
491
+				),
492
+				'metaboxes'     => $this->_default_espresso_metaboxes,
493
+				'require_nonce' => false,
494
+			),
495
+		);
496
+	}
497
+
498
+
499
+
500
+	protected function _add_screen_options()
501
+	{
502
+		//todo
503
+	}
504
+
505
+
506
+
507
+	protected function _add_screen_options_default()
508
+	{
509
+		$this->_per_page_screen_option();
510
+	}
511
+
512
+
513
+
514
+	protected function _add_screen_options_category_list()
515
+	{
516
+		$page_title = $this->_admin_page_title;
517
+		$this->_admin_page_title = esc_html__('Categories', 'event_espresso');
518
+		$this->_per_page_screen_option();
519
+		$this->_admin_page_title = $page_title;
520
+	}
521
+
522
+
523
+
524
+	protected function _add_feature_pointers()
525
+	{
526
+		//todo
527
+	}
528
+
529
+
530
+
531
+	public function load_scripts_styles()
532
+	{
533
+		wp_register_style(
534
+			'events-admin-css',
535
+			EVENTS_ASSETS_URL . 'events-admin-page.css',
536
+			array(),
537
+			EVENT_ESPRESSO_VERSION
538
+		);
539
+		wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION);
540
+		wp_enqueue_style('events-admin-css');
541
+		wp_enqueue_style('ee-cat-admin');
542
+		//todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details
543
+		//registers for all views
544
+		//scripts
545
+		wp_register_script(
546
+			'event_editor_js',
547
+			EVENTS_ASSETS_URL . 'event_editor.js',
548
+			array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'),
549
+			EVENT_ESPRESSO_VERSION,
550
+			true
551
+		);
552
+	}
553
+
554
+
555
+
556
+	/**
557
+	 * enqueuing scripts and styles specific to this view
558
+	 *
559
+	 * @return void
560
+	 */
561
+	public function load_scripts_styles_create_new()
562
+	{
563
+		$this->load_scripts_styles_edit();
564
+	}
565
+
566
+
567
+
568
+	/**
569
+	 * enqueuing scripts and styles specific to this view
570
+	 *
571
+	 * @return void
572
+	 */
573
+	public function load_scripts_styles_edit()
574
+	{
575
+		//styles
576
+		wp_enqueue_style('espresso-ui-theme');
577
+		wp_register_style(
578
+			'event-editor-css',
579
+			EVENTS_ASSETS_URL . 'event-editor.css',
580
+			array('ee-admin-css'),
581
+			EVENT_ESPRESSO_VERSION
582
+		);
583
+		wp_enqueue_style('event-editor-css');
584
+		//scripts
585
+		wp_register_script(
586
+			'event-datetime-metabox',
587
+			EVENTS_ASSETS_URL . 'event-datetime-metabox.js',
588
+			array('event_editor_js', 'ee-datepicker'),
589
+			EVENT_ESPRESSO_VERSION
590
+		);
591
+		wp_enqueue_script('event-datetime-metabox');
592
+	}
593
+
594
+
595
+
596
+	public function load_scripts_styles_add_category()
597
+	{
598
+		$this->load_scripts_styles_edit_category();
599
+	}
600
+
601
+
602
+
603
+	public function load_scripts_styles_edit_category()
604
+	{
605
+	}
606
+
607
+
608
+
609
+	protected function _set_list_table_views_category_list()
610
+	{
611
+		$this->_views = array(
612
+			'all' => array(
613
+				'slug'        => 'all',
614
+				'label'       => esc_html__('All', 'event_espresso'),
615
+				'count'       => 0,
616
+				'bulk_action' => array(
617
+					'delete_categories' => esc_html__('Delete Permanently', 'event_espresso'),
618
+				),
619
+			),
620
+		);
621
+	}
622
+
623
+
624
+
625
+	public function admin_init()
626
+	{
627
+		EE_Registry::$i18n_js_strings['image_confirm'] = esc_html__(
628
+			'Do you really want to delete this image? Please remember to update your event to complete the removal.',
629
+			'event_espresso'
630
+		);
631
+	}
632
+
633
+
634
+
635
+	//nothing needed for events with these methods.
636
+	public function admin_notices()
637
+	{
638
+	}
639
+
640
+
641
+
642
+	public function admin_footer_scripts()
643
+	{
644
+	}
645
+
646
+
647
+
648
+	/**
649
+	 * Call this function to verify if an event is public and has tickets for sale.  If it does, then we need to show a
650
+	 * warning (via EE_Error::add_error());
651
+	 *
652
+	 * @param  EE_Event $event Event object
653
+	 * @access public
654
+	 * @return void
655
+	 */
656
+	public function verify_event_edit($event = null)
657
+	{
658
+		// no event?
659
+		if (empty($event)) {
660
+			// set event
661
+			$event = $this->_cpt_model_obj;
662
+		}
663
+		// STILL no event?
664
+		if (empty ($event)) {
665
+			return;
666
+		}
667
+		$orig_status = $event->status();
668
+		// first check if event is active.
669
+		if (
670
+			$orig_status === EEM_Event::cancelled
671
+			|| $orig_status === EEM_Event::postponed
672
+			|| $event->is_expired()
673
+			|| $event->is_inactive()
674
+		) {
675
+			return;
676
+		}
677
+		//made it here so it IS active... next check that any of the tickets are sold.
678
+		if ($event->is_sold_out(true)) {
679
+			if ($orig_status !== EEM_Event::sold_out && $event->status() !== $orig_status) {
680
+				EE_Error::add_attention(
681
+					sprintf(
682
+						esc_html__(
683
+							'Please note that the Event Status has automatically been changed to %s because there are no more spaces available for this event.  However, this change is not permanent until you update the event.  You can change the status back to something else before updating if you wish.',
684
+							'event_espresso'
685
+						),
686
+						EEH_Template::pretty_status(EEM_Event::sold_out, false, 'sentence')
687
+					)
688
+				);
689
+			}
690
+			return;
691
+		} else if ($orig_status === EEM_Event::sold_out) {
692
+			EE_Error::add_attention(
693
+				sprintf(
694
+					esc_html__(
695
+						'Please note that the Event Status has automatically been changed to %s because more spaces have become available for this event, most likely due to abandoned transactions freeing up reserved tickets.  However, this change is not permanent until you update the event. If you wish, you can change the status back to something else before updating.',
696
+						'event_espresso'
697
+					),
698
+					EEH_Template::pretty_status($event->status(), false, 'sentence')
699
+				)
700
+			);
701
+		}
702
+		//now we need to determine if the event has any tickets on sale.  If not then we dont' show the error
703
+		if ( ! $event->tickets_on_sale()) {
704
+			return;
705
+		}
706
+		//made it here so show warning
707
+		$this->_edit_event_warning();
708
+	}
709
+
710
+
711
+
712
+	/**
713
+	 * This is the text used for when an event is being edited that is public and has tickets for sale.
714
+	 * When needed, hook this into a EE_Error::add_error() notice.
715
+	 *
716
+	 * @access protected
717
+	 * @return void
718
+	 */
719
+	protected function _edit_event_warning()
720
+	{
721
+		// we don't want to add warnings during these requests
722
+		if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'editpost') {
723
+			return;
724
+		}
725
+		EE_Error::add_attention(
726
+			esc_html__(
727
+				'Please be advised that this event has been published and is open for registrations on your website. If you update any registration-related details (i.e. custom questions, messages, tickets, datetimes, etc.) while a registration is in process, the registration process could be interrupted and result in errors for the person registering and potentially incorrect registration or transaction data inside Event Espresso. We recommend editing events during a period of slow traffic, or even temporarily changing the status of an event to "Draft" until your edits are complete.',
728
+				'event_espresso'
729
+			)
730
+		);
731
+	}
732
+
733
+
734
+
735
+	/**
736
+	 * When a user is creating a new event, notify them if they haven't set their timezone.
737
+	 * Otherwise, do the normal logic
738
+	 *
739
+	 * @return string
740
+	 * @throws \EE_Error
741
+	 */
742
+	protected function _create_new_cpt_item()
743
+	{
744
+		$gmt_offset = get_option('gmt_offset');
745
+		//only nag them about setting their timezone if it's their first event, and they haven't already done it
746
+		if ($gmt_offset === '0' && ! EEM_Event::instance()->exists(array())) {
747
+			EE_Error::add_attention(
748
+				sprintf(
749
+					__(
750
+						'Your website\'s timezone is currently set to UTC + 0. We recommend updating your timezone to a city or region near you before you create an event. Your timezone can be updated through the %1$sGeneral Settings%2$s page.',
751
+						'event_espresso'
752
+					),
753
+					'<a href="' . admin_url('options-general.php') . '">',
754
+					'</a>'
755
+				),
756
+				__FILE__,
757
+				__FUNCTION__,
758
+				__LINE__
759
+			);
760
+		}
761
+		return parent::_create_new_cpt_item();
762
+	}
763
+
764
+
765
+
766
+	protected function _set_list_table_views_default()
767
+	{
768
+		$this->_views = array(
769
+			'all'   => array(
770
+				'slug'        => 'all',
771
+				'label'       => esc_html__('View All Events', 'event_espresso'),
772
+				'count'       => 0,
773
+				'bulk_action' => array(
774
+					'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
775
+				),
776
+			),
777
+			'draft' => array(
778
+				'slug'        => 'draft',
779
+				'label'       => esc_html__('Draft', 'event_espresso'),
780
+				'count'       => 0,
781
+				'bulk_action' => array(
782
+					'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
783
+				),
784
+			),
785
+		);
786
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) {
787
+			$this->_views['trash'] = array(
788
+				'slug'        => 'trash',
789
+				'label'       => esc_html__('Trash', 'event_espresso'),
790
+				'count'       => 0,
791
+				'bulk_action' => array(
792
+					'restore_events' => esc_html__('Restore From Trash', 'event_espresso'),
793
+					'delete_events'  => esc_html__('Delete Permanently', 'event_espresso'),
794
+				),
795
+			);
796
+		}
797
+	}
798
+
799
+
800
+
801
+	/**
802
+	 * @return array
803
+	 */
804
+	protected function _event_legend_items()
805
+	{
806
+		$items = array(
807
+			'view_details'   => array(
808
+				'class' => 'dashicons dashicons-search',
809
+				'desc'  => esc_html__('View Event', 'event_espresso'),
810
+			),
811
+			'edit_event'     => array(
812
+				'class' => 'ee-icon ee-icon-calendar-edit',
813
+				'desc'  => esc_html__('Edit Event Details', 'event_espresso'),
814
+			),
815
+			'view_attendees' => array(
816
+				'class' => 'dashicons dashicons-groups',
817
+				'desc'  => esc_html__('View Registrations for Event', 'event_espresso'),
818
+			),
819
+		);
820
+		$items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items);
821
+		$statuses = array(
822
+			'sold_out_status'  => array(
823
+				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out,
824
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::sold_out, false, 'sentence'),
825
+			),
826
+			'active_status'    => array(
827
+				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active,
828
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::active, false, 'sentence'),
829
+			),
830
+			'upcoming_status'  => array(
831
+				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming,
832
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::upcoming, false, 'sentence'),
833
+			),
834
+			'postponed_status' => array(
835
+				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed,
836
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::postponed, false, 'sentence'),
837
+			),
838
+			'cancelled_status' => array(
839
+				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled,
840
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::cancelled, false, 'sentence'),
841
+			),
842
+			'expired_status'   => array(
843
+				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired,
844
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::expired, false, 'sentence'),
845
+			),
846
+			'inactive_status'  => array(
847
+				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive,
848
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::inactive, false, 'sentence'),
849
+			),
850
+		);
851
+		$statuses = apply_filters('FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses);
852
+		return array_merge($items, $statuses);
853
+	}
854
+
855
+
856
+
857
+	/**
858
+	 * _event_model
859
+	 *
860
+	 * @return EEM_Event
861
+	 */
862
+	private function _event_model()
863
+	{
864
+		if ( ! $this->_event_model instanceof EEM_Event) {
865
+			$this->_event_model = EE_Registry::instance()->load_model('Event');
866
+		}
867
+		return $this->_event_model;
868
+	}
869
+
870
+
871
+
872
+	/**
873
+	 * Adds extra buttons to the WP CPT permalink field row.
874
+	 * Method is called from parent and is hooked into the wp 'get_sample_permalink_html' filter.
875
+	 *
876
+	 * @param  string $return    the current html
877
+	 * @param  int    $id        the post id for the page
878
+	 * @param  string $new_title What the title is
879
+	 * @param  string $new_slug  what the slug is
880
+	 * @return string            The new html string for the permalink area
881
+	 */
882
+	public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug)
883
+	{
884
+		//make sure this is only when editing
885
+		if ( ! empty($id)) {
886
+			$post = get_post($id);
887
+			$return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#"  tabindex="-1">'
888
+					   . esc_html__('Shortcode', 'event_espresso')
889
+					   . '</a> ';
890
+			$return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id='
891
+					   . $post->ID
892
+					   . ']">';
893
+		}
894
+		return $return;
895
+	}
896
+
897
+
898
+
899
+	/**
900
+	 * _events_overview_list_table
901
+	 * This contains the logic for showing the events_overview list
902
+	 *
903
+	 * @access protected
904
+	 * @return void
905
+	 * @throws \EE_Error
906
+	 */
907
+	protected function _events_overview_list_table()
908
+	{
909
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
910
+		$this->_template_args['after_list_table'] = ! empty($this->_template_args['after_list_table'])
911
+			? (array)$this->_template_args['after_list_table']
912
+			: array();
913
+		$this->_template_args['after_list_table']['view_event_list_button'] = EEH_HTML::br()
914
+																			  . EEH_Template::get_button_or_link(
915
+				get_post_type_archive_link('espresso_events'),
916
+				esc_html__("View Event Archive Page", "event_espresso"),
917
+				'button'
918
+			);
919
+		$this->_template_args['after_list_table']['legend'] = $this->_display_legend($this->_event_legend_items());
920
+		$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
921
+				'create_new',
922
+				'add',
923
+				array(),
924
+				'add-new-h2'
925
+			);
926
+		$this->display_admin_list_table_page_with_no_sidebar();
927
+	}
928
+
929
+
930
+
931
+	/**
932
+	 * this allows for extra misc actions in the default WP publish box
933
+	 *
934
+	 * @return void
935
+	 */
936
+	public function extra_misc_actions_publish_box()
937
+	{
938
+		$this->_generate_publish_box_extra_content();
939
+	}
940
+
941
+
942
+
943
+	/**
944
+	 * This is hooked into the WordPress do_action('save_post') hook and runs after the custom post type has been
945
+	 * saved.  Child classes are required to declare this method.  Typically you would use this to save any additional
946
+	 * data.
947
+	 * Keep in mind also that "save_post" runs on EVERY post update to the database.
948
+	 * ALSO very important.  When a post transitions from scheduled to published, the save_post action is fired but you
949
+	 * will NOT have any _POST data containing any extra info you may have from other meta saves.  So MAKE sure that
950
+	 * you handle this accordingly.
951
+	 *
952
+	 * @access protected
953
+	 * @abstract
954
+	 * @param  string $post_id The ID of the cpt that was saved (so you can link relationally)
955
+	 * @param  object $post    The post object of the cpt that was saved.
956
+	 * @return void
957
+	 */
958
+	protected function _insert_update_cpt_item($post_id, $post)
959
+	{
960
+		if ($post instanceof WP_Post && $post->post_type !== 'espresso_events') {
961
+			//get out we're not processing an event save.
962
+			return;
963
+		}
964
+		$event_values = array(
965
+			'EVT_display_desc'                => ! empty($this->_req_data['display_desc']) ? 1 : 0,
966
+			'EVT_display_ticket_selector'     => ! empty($this->_req_data['display_ticket_selector']) ? 1 : 0,
967
+			'EVT_additional_limit'            => min(
968
+				apply_filters('FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255),
969
+				! empty($this->_req_data['additional_limit']) ? $this->_req_data['additional_limit'] : null
970
+			),
971
+			'EVT_default_registration_status' => ! empty($this->_req_data['EVT_default_registration_status'])
972
+				? $this->_req_data['EVT_default_registration_status']
973
+				: EE_Registry::instance()->CFG->registration->default_STS_ID,
974
+			'EVT_member_only'                 => ! empty($this->_req_data['member_only']) ? 1 : 0,
975
+			'EVT_allow_overflow'              => ! empty($this->_req_data['EVT_allow_overflow']) ? 1 : 0,
976
+			'EVT_timezone_string'             => ! empty($this->_req_data['timezone_string'])
977
+				? $this->_req_data['timezone_string'] : null,
978
+			'EVT_external_URL'                => ! empty($this->_req_data['externalURL'])
979
+				? $this->_req_data['externalURL'] : null,
980
+			'EVT_phone'                       => ! empty($this->_req_data['event_phone'])
981
+				? $this->_req_data['event_phone'] : null,
982
+		);
983
+		//update event
984
+		$success = $this->_event_model()->update_by_ID($event_values, $post_id);
985
+		//get event_object for other metaboxes... though it would seem to make sense to just use $this->_event_model()->get_one_by_ID( $post_id ).. i have to setup where conditions to override the filters in the model that filter out autodraft and inherit statuses so we GET the inherit id!
986
+		$get_one_where = array($this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status);
987
+		$event = $this->_event_model()->get_one(array($get_one_where));
988
+		//the following are default callbacks for event attachment updates that can be overridden by caffeinated functionality and/or addons.
989
+		$event_update_callbacks = apply_filters(
990
+			'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks',
991
+			array(array($this, '_default_venue_update'), array($this, '_default_tickets_update'))
992
+		);
993
+		$att_success = true;
994
+		foreach ($event_update_callbacks as $e_callback) {
995
+			$_succ = call_user_func_array($e_callback, array($event, $this->_req_data));
996
+			$att_success = ! $att_success ? $att_success
997
+				: $_succ; //if ANY of these updates fail then we want the appropriate global error message
998
+		}
999
+		//any errors?
1000
+		if ($success && false === $att_success) {
1001
+			EE_Error::add_error(
1002
+				esc_html__(
1003
+					'Event Details saved successfully but something went wrong with saving attachments.',
1004
+					'event_espresso'
1005
+				),
1006
+				__FILE__,
1007
+				__FUNCTION__,
1008
+				__LINE__
1009
+			);
1010
+		} else if ($success === false) {
1011
+			EE_Error::add_error(
1012
+				esc_html__('Event Details did not save successfully.', 'event_espresso'),
1013
+				__FILE__,
1014
+				__FUNCTION__,
1015
+				__LINE__
1016
+			);
1017
+		}
1018
+	}
1019
+
1020
+
1021
+
1022
+	/**
1023
+	 * @see parent::restore_item()
1024
+	 * @param int $post_id
1025
+	 * @param int $revision_id
1026
+	 */
1027
+	protected function _restore_cpt_item($post_id, $revision_id)
1028
+	{
1029
+		//copy existing event meta to new post
1030
+		$post_evt = $this->_event_model()->get_one_by_ID($post_id);
1031
+		if ($post_evt instanceof EE_Event) {
1032
+			//meta revision restore
1033
+			$post_evt->restore_revision($revision_id);
1034
+			//related objs restore
1035
+			$post_evt->restore_revision($revision_id, array('Venue', 'Datetime', 'Price'));
1036
+		}
1037
+	}
1038
+
1039
+
1040
+
1041
+	/**
1042
+	 * Attach the venue to the Event
1043
+	 *
1044
+	 * @param  \EE_Event $evtobj Event Object to add the venue to
1045
+	 * @param  array     $data   The request data from the form
1046
+	 * @return bool           Success or fail.
1047
+	 */
1048
+	protected function _default_venue_update(\EE_Event $evtobj, $data)
1049
+	{
1050
+		require_once(EE_MODELS . 'EEM_Venue.model.php');
1051
+		$venue_model = EE_Registry::instance()->load_model('Venue');
1052
+		$rows_affected = null;
1053
+		$venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null;
1054
+		// very important.  If we don't have a venue name...
1055
+		// then we'll get out because not necessary to create empty venue
1056
+		if (empty($data['venue_title'])) {
1057
+			return false;
1058
+		}
1059
+		$venue_array = array(
1060
+			'VNU_wp_user'         => $evtobj->get('EVT_wp_user'),
1061
+			'VNU_name'            => ! empty($data['venue_title']) ? $data['venue_title'] : null,
1062
+			'VNU_desc'            => ! empty($data['venue_description']) ? $data['venue_description'] : null,
1063
+			'VNU_identifier'      => ! empty($data['venue_identifier']) ? $data['venue_identifier'] : null,
1064
+			'VNU_short_desc'      => ! empty($data['venue_short_description']) ? $data['venue_short_description']
1065
+				: null,
1066
+			'VNU_address'         => ! empty($data['address']) ? $data['address'] : null,
1067
+			'VNU_address2'        => ! empty($data['address2']) ? $data['address2'] : null,
1068
+			'VNU_city'            => ! empty($data['city']) ? $data['city'] : null,
1069
+			'STA_ID'              => ! empty($data['state']) ? $data['state'] : null,
1070
+			'CNT_ISO'             => ! empty($data['countries']) ? $data['countries'] : null,
1071
+			'VNU_zip'             => ! empty($data['zip']) ? $data['zip'] : null,
1072
+			'VNU_phone'           => ! empty($data['venue_phone']) ? $data['venue_phone'] : null,
1073
+			'VNU_capacity'        => ! empty($data['venue_capacity']) ? $data['venue_capacity'] : null,
1074
+			'VNU_url'             => ! empty($data['venue_url']) ? $data['venue_url'] : null,
1075
+			'VNU_virtual_phone'   => ! empty($data['virtual_phone']) ? $data['virtual_phone'] : null,
1076
+			'VNU_virtual_url'     => ! empty($data['virtual_url']) ? $data['virtual_url'] : null,
1077
+			'VNU_enable_for_gmap' => isset($data['enable_for_gmap']) ? 1 : 0,
1078
+			'status'              => 'publish',
1079
+		);
1080
+		//if we've got the venue_id then we're just updating the existing venue so let's do that and then get out.
1081
+		if ( ! empty($venue_id)) {
1082
+			$update_where = array($venue_model->primary_key_name() => $venue_id);
1083
+			$rows_affected = $venue_model->update($venue_array, array($update_where));
1084
+			//we've gotta make sure that the venue is always attached to a revision.. add_relation_to should take care of making sure that the relation is already present.
1085
+			$evtobj->_add_relation_to($venue_id, 'Venue');
1086
+			return $rows_affected > 0 ? true : false;
1087
+		} else {
1088
+			//we insert the venue
1089
+			$venue_id = $venue_model->insert($venue_array);
1090
+			$evtobj->_add_relation_to($venue_id, 'Venue');
1091
+			return ! empty($venue_id) ? true : false;
1092
+		}
1093
+		//when we have the ancestor come in it's already been handled by the revision save.
1094
+	}
1095
+
1096
+
1097
+
1098
+	/**
1099
+	 * Handles saving everything related to Tickets (datetimes, tickets, prices)
1100
+	 *
1101
+	 * @param  EE_Event $evtobj The Event object we're attaching data to
1102
+	 * @param  array    $data   The request data from the form
1103
+	 * @return array
1104
+	 */
1105
+	protected function _default_tickets_update(EE_Event $evtobj, $data)
1106
+	{
1107
+		$success = true;
1108
+		$saved_dtt = null;
1109
+		$saved_tickets = array();
1110
+		$incoming_date_formats = array('Y-m-d', 'h:i a');
1111
+		foreach ($data['edit_event_datetimes'] as $row => $dtt) {
1112
+			//trim all values to ensure any excess whitespace is removed.
1113
+			$dtt = array_map('trim', $dtt);
1114
+			$dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end']
1115
+				: $dtt['DTT_EVT_start'];
1116
+			$datetime_values = array(
1117
+				'DTT_ID'        => ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : null,
1118
+				'DTT_EVT_start' => $dtt['DTT_EVT_start'],
1119
+				'DTT_EVT_end'   => $dtt['DTT_EVT_end'],
1120
+				'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'],
1121
+				'DTT_order'     => $row,
1122
+			);
1123
+			//if we have an id then let's get existing object first and then set the new values.  Otherwise we instantiate a new object for save.
1124
+			if ( ! empty($dtt['DTT_ID'])) {
1125
+				$DTM = EE_Registry::instance()
1126
+								  ->load_model('Datetime', array($evtobj->get_timezone()))
1127
+								  ->get_one_by_ID($dtt['DTT_ID']);
1128
+				$DTM->set_date_format($incoming_date_formats[0]);
1129
+				$DTM->set_time_format($incoming_date_formats[1]);
1130
+				foreach ($datetime_values as $field => $value) {
1131
+					$DTM->set($field, $value);
1132
+				}
1133
+				//make sure the $dtt_id here is saved just in case after the add_relation_to() the autosave replaces it.  We need to do this so we dont' TRASH the parent DTT.
1134
+				$saved_dtts[$DTM->ID()] = $DTM;
1135
+			} else {
1136
+				$DTM = EE_Registry::instance()->load_class(
1137
+					'Datetime',
1138
+					array($datetime_values, $evtobj->get_timezone(), $incoming_date_formats),
1139
+					false,
1140
+					false
1141
+				);
1142
+				foreach ($datetime_values as $field => $value) {
1143
+					$DTM->set($field, $value);
1144
+				}
1145
+			}
1146
+			$DTM->save();
1147
+			$DTT = $evtobj->_add_relation_to($DTM, 'Datetime');
1148
+			//load DTT helper
1149
+			//before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date.
1150
+			if ($DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end')) {
1151
+				$DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start'));
1152
+				$DTT = EEH_DTT_Helper::date_time_add($DTT, 'DTT_EVT_end', 'days');
1153
+				$DTT->save();
1154
+			}
1155
+			//now we got to make sure we add the new DTT_ID to the $saved_dtts array  because it is possible there was a new one created for the autosave.
1156
+			$saved_dtt = $DTT;
1157
+			$success = ! $success ? $success : $DTT;
1158
+			//if ANY of these updates fail then we want the appropriate global error message.
1159
+			// //todo this is actually sucky we need a better error message but this is what it is for now.
1160
+		}
1161
+		//no dtts get deleted so we don't do any of that logic here.
1162
+		//update tickets next
1163
+		$old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array();
1164
+		foreach ($data['edit_tickets'] as $row => $tkt) {
1165
+			$incoming_date_formats = array('Y-m-d', 'h:i a');
1166
+			$update_prices = false;
1167
+			$ticket_price = isset($data['edit_prices'][$row][1]['PRC_amount'])
1168
+				? $data['edit_prices'][$row][1]['PRC_amount'] : 0;
1169
+			// trim inputs to ensure any excess whitespace is removed.
1170
+			$tkt = array_map('trim', $tkt);
1171
+			if (empty($tkt['TKT_start_date'])) {
1172
+				//let's use now in the set timezone.
1173
+				$now = new DateTime('now', new DateTimeZone($evtobj->get_timezone()));
1174
+				$tkt['TKT_start_date'] = $now->format($incoming_date_formats[0] . ' ' . $incoming_date_formats[1]);
1175
+			}
1176
+			if (empty($tkt['TKT_end_date'])) {
1177
+				//use the start date of the first datetime
1178
+				$dtt = $evtobj->first_datetime();
1179
+				$tkt['TKT_end_date'] = $dtt->start_date_and_time(
1180
+					$incoming_date_formats[0],
1181
+					$incoming_date_formats[1]
1182
+				);
1183
+			}
1184
+			$TKT_values = array(
1185
+				'TKT_ID'          => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : null,
1186
+				'TTM_ID'          => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0,
1187
+				'TKT_name'        => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '',
1188
+				'TKT_description' => ! empty($tkt['TKT_description']) ? $tkt['TKT_description'] : '',
1189
+				'TKT_start_date'  => $tkt['TKT_start_date'],
1190
+				'TKT_end_date'    => $tkt['TKT_end_date'],
1191
+				'TKT_qty'         => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'],
1192
+				'TKT_uses'        => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'],
1193
+				'TKT_min'         => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'],
1194
+				'TKT_max'         => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'],
1195
+				'TKT_row'         => $row,
1196
+				'TKT_order'       => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : $row,
1197
+				'TKT_price'       => $ticket_price,
1198
+			);
1199
+			//if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly, which means in turn that the prices will become new prices as well.
1200
+			if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) {
1201
+				$TKT_values['TKT_ID'] = 0;
1202
+				$TKT_values['TKT_is_default'] = 0;
1203
+				$TKT_values['TKT_price'] = $ticket_price;
1204
+				$update_prices = true;
1205
+			}
1206
+			//if we have a TKT_ID then we need to get that existing TKT_obj and update it
1207
+			//we actually do our saves a head of doing any add_relations to because its entirely possible that this ticket didn't removed or added to any datetime in the session but DID have it's items modified.
1208
+			//keep in mind that if the TKT has been sold (and we have changed pricing information), then we won't be updating the tkt but instead a new tkt will be created and the old one archived.
1209
+			if ( ! empty($tkt['TKT_ID'])) {
1210
+				$TKT = EE_Registry::instance()
1211
+								  ->load_model('Ticket', array($evtobj->get_timezone()))
1212
+								  ->get_one_by_ID($tkt['TKT_ID']);
1213
+				if ($TKT instanceof EE_Ticket) {
1214
+					$ticket_sold = $TKT->count_related(
1215
+						'Registration',
1216
+						array(
1217
+							array(
1218
+								'STS_ID' => array(
1219
+									'NOT IN',
1220
+									array(EEM_Registration::status_id_incomplete),
1221
+								),
1222
+							),
1223
+						)
1224
+					) > 0 ? true : false;
1225
+					//let's just check the total price for the existing ticket and determine if it matches the new total price.  if they are different then we create a new ticket (if tkts sold) if they aren't different then we go ahead and modify existing ticket.
1226
+					$create_new_TKT = $ticket_sold && $ticket_price != $TKT->get('TKT_price')
1227
+									  && ! $TKT->get(
1228
+						'TKT_deleted'
1229
+					) ? true : false;
1230
+					$TKT->set_date_format($incoming_date_formats[0]);
1231
+					$TKT->set_time_format($incoming_date_formats[1]);
1232
+					//set new values
1233
+					foreach ($TKT_values as $field => $value) {
1234
+						if ($field == 'TKT_qty') {
1235
+							$TKT->set_qty($value);
1236
+						} else {
1237
+							$TKT->set($field, $value);
1238
+						}
1239
+					}
1240
+					//if $create_new_TKT is false then we can safely update the existing ticket.  Otherwise we have to create a new ticket.
1241
+					if ($create_new_TKT) {
1242
+						//archive the old ticket first
1243
+						$TKT->set('TKT_deleted', 1);
1244
+						$TKT->save();
1245
+						//make sure this ticket is still recorded in our saved_tkts so we don't run it through the regular trash routine.
1246
+						$saved_tickets[$TKT->ID()] = $TKT;
1247
+						//create new ticket that's a copy of the existing except a new id of course (and not archived) AND has the new TKT_price associated with it.
1248
+						$TKT = clone $TKT;
1249
+						$TKT->set('TKT_ID', 0);
1250
+						$TKT->set('TKT_deleted', 0);
1251
+						$TKT->set('TKT_price', $ticket_price);
1252
+						$TKT->set('TKT_sold', 0);
1253
+						//now we need to make sure that $new prices are created as well and attached to new ticket.
1254
+						$update_prices = true;
1255
+					}
1256
+					//make sure price is set if it hasn't been already
1257
+					$TKT->set('TKT_price', $ticket_price);
1258
+				}
1259
+			} else {
1260
+				//no TKT_id so a new TKT
1261
+				$TKT_values['TKT_price'] = $ticket_price;
1262
+				$TKT = EE_Registry::instance()->load_class('Ticket', array($TKT_values), false, false);
1263
+				if ($TKT instanceof EE_Ticket) {
1264
+					//need to reset values to properly account for the date formats
1265
+					$TKT->set_date_format($incoming_date_formats[0]);
1266
+					$TKT->set_time_format($incoming_date_formats[1]);
1267
+					$TKT->set_timezone($evtobj->get_timezone());
1268
+					//set new values
1269
+					foreach ($TKT_values as $field => $value) {
1270
+						if ($field == 'TKT_qty') {
1271
+							$TKT->set_qty($value);
1272
+						} else {
1273
+							$TKT->set($field, $value);
1274
+						}
1275
+					}
1276
+					$update_prices = true;
1277
+				}
1278
+			}
1279
+			// cap ticket qty by datetime reg limits
1280
+			$TKT->set_qty(min($TKT->qty(), $TKT->qty('reg_limit')));
1281
+			//update ticket.
1282
+			$TKT->save();
1283
+			//before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date.
1284
+			if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) {
1285
+				$TKT->set('TKT_end_date', $TKT->get('TKT_start_date'));
1286
+				$TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days');
1287
+				$TKT->save();
1288
+			}
1289
+			//initially let's add the ticket to the dtt
1290
+			$saved_dtt->_add_relation_to($TKT, 'Ticket');
1291
+			$saved_tickets[$TKT->ID()] = $TKT;
1292
+			//add prices to ticket
1293
+			$this->_add_prices_to_ticket($data['edit_prices'][$row], $TKT, $update_prices);
1294
+		}
1295
+		//however now we need to handle permanently deleting tickets via the ui.  Keep in mind that the ui does not allow deleting/archiving tickets that have ticket sold.  However, it does allow for deleting tickets that have no tickets sold, in which case we want to get rid of permanently because there is no need to save in db.
1296
+		$old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets;
1297
+		$tickets_removed = array_diff($old_tickets, array_keys($saved_tickets));
1298
+		foreach ($tickets_removed as $id) {
1299
+			$id = absint($id);
1300
+			//get the ticket for this id
1301
+			$tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id);
1302
+			//need to get all the related datetimes on this ticket and remove from every single one of them (remember this process can ONLY kick off if there are NO tkts_sold)
1303
+			$dtts = $tkt_to_remove->get_many_related('Datetime');
1304
+			foreach ($dtts as $dtt) {
1305
+				$tkt_to_remove->_remove_relation_to($dtt, 'Datetime');
1306
+			}
1307
+			//need to do the same for prices (except these prices can also be deleted because again, tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived))
1308
+			$tkt_to_remove->delete_related_permanently('Price');
1309
+			//finally let's delete this ticket (which should not be blocked at this point b/c we've removed all our relationships)
1310
+			$tkt_to_remove->delete_permanently();
1311
+		}
1312
+		return array($saved_dtt, $saved_tickets);
1313
+	}
1314
+
1315
+
1316
+
1317
+	/**
1318
+	 * This attaches a list of given prices to a ticket.
1319
+	 * Note we dont' have to worry about ever removing relationships (or archiving prices) because if there is a change
1320
+	 * in price information on a ticket, a new ticket is created anyways so the archived ticket will retain the old
1321
+	 * price info and prices are automatically "archived" via the ticket.
1322
+	 *
1323
+	 * @access  private
1324
+	 * @param array     $prices     Array of prices from the form.
1325
+	 * @param EE_Ticket $ticket     EE_Ticket object that prices are being attached to.
1326
+	 * @param bool      $new_prices Whether attach existing incoming prices or create new ones.
1327
+	 * @return  void
1328
+	 */
1329
+	private function _add_prices_to_ticket($prices, EE_Ticket $ticket, $new_prices = false)
1330
+	{
1331
+		foreach ($prices as $row => $prc) {
1332
+			$PRC_values = array(
1333
+				'PRC_ID'         => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : null,
1334
+				'PRT_ID'         => ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : null,
1335
+				'PRC_amount'     => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0,
1336
+				'PRC_name'       => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '',
1337
+				'PRC_desc'       => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '',
1338
+				'PRC_is_default' => 0, //make sure prices are NOT set as default from this context
1339
+				'PRC_order'      => $row,
1340
+			);
1341
+			if ($new_prices || empty($PRC_values['PRC_ID'])) {
1342
+				$PRC_values['PRC_ID'] = 0;
1343
+				$PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), false, false);
1344
+			} else {
1345
+				$PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']);
1346
+				//update this price with new values
1347
+				foreach ($PRC_values as $field => $newprc) {
1348
+					$PRC->set($field, $newprc);
1349
+				}
1350
+				$PRC->save();
1351
+			}
1352
+			$ticket->_add_relation_to($PRC, 'Price');
1353
+		}
1354
+	}
1355
+
1356
+
1357
+
1358
+	/**
1359
+	 * Add in our autosave ajax handlers
1360
+	 *
1361
+	 * @return void
1362
+	 */
1363
+	protected function _ee_autosave_create_new()
1364
+	{
1365
+		// $this->_ee_autosave_edit();
1366
+	}
1367
+
1368
+
1369
+
1370
+	protected function _ee_autosave_edit()
1371
+	{
1372
+		return; //TEMPORARILY EXITING CAUSE THIS IS A TODO
1373
+	}
1374
+
1375
+
1376
+
1377
+	/**
1378
+	 *    _generate_publish_box_extra_content
1379
+	 *
1380
+	 * @access private
1381
+	 * @return void
1382
+	 */
1383
+	private function _generate_publish_box_extra_content()
1384
+	{
1385
+		//load formatter helper
1386
+		//args for getting related registrations
1387
+		$approved_query_args = array(
1388
+			array(
1389
+				'REG_deleted' => 0,
1390
+				'STS_ID'      => EEM_Registration::status_id_approved,
1391
+			),
1392
+		);
1393
+		$not_approved_query_args = array(
1394
+			array(
1395
+				'REG_deleted' => 0,
1396
+				'STS_ID'      => EEM_Registration::status_id_not_approved,
1397
+			),
1398
+		);
1399
+		$pending_payment_query_args = array(
1400
+			array(
1401
+				'REG_deleted' => 0,
1402
+				'STS_ID'      => EEM_Registration::status_id_pending_payment,
1403
+			),
1404
+		);
1405
+		// publish box
1406
+		$publish_box_extra_args = array(
1407
+			'view_approved_reg_url'        => add_query_arg(
1408
+				array(
1409
+					'action'      => 'default',
1410
+					'event_id'    => $this->_cpt_model_obj->ID(),
1411
+					'_reg_status' => EEM_Registration::status_id_approved,
1412
+				),
1413
+				REG_ADMIN_URL
1414
+			),
1415
+			'view_not_approved_reg_url'    => add_query_arg(
1416
+				array(
1417
+					'action'      => 'default',
1418
+					'event_id'    => $this->_cpt_model_obj->ID(),
1419
+					'_reg_status' => EEM_Registration::status_id_not_approved,
1420
+				),
1421
+				REG_ADMIN_URL
1422
+			),
1423
+			'view_pending_payment_reg_url' => add_query_arg(
1424
+				array(
1425
+					'action'      => 'default',
1426
+					'event_id'    => $this->_cpt_model_obj->ID(),
1427
+					'_reg_status' => EEM_Registration::status_id_pending_payment,
1428
+				),
1429
+				REG_ADMIN_URL
1430
+			),
1431
+			'approved_regs'                => $this->_cpt_model_obj->count_related(
1432
+				'Registration',
1433
+				$approved_query_args
1434
+			),
1435
+			'not_approved_regs'            => $this->_cpt_model_obj->count_related(
1436
+				'Registration',
1437
+				$not_approved_query_args
1438
+			),
1439
+			'pending_payment_regs'         => $this->_cpt_model_obj->count_related(
1440
+				'Registration',
1441
+				$pending_payment_query_args
1442
+			),
1443
+			'misc_pub_section_class'       => apply_filters(
1444
+				'FHEE_Events_Admin_Page___generate_publish_box_extra_content__misc_pub_section_class',
1445
+				'misc-pub-section'
1446
+			),
1447
+			//'email_attendees_url' => add_query_arg(
1448
+			//	array(
1449
+			//		'event_admin_reports' => 'event_newsletter',
1450
+			//		'event_id' => $this->_cpt_model_obj->id
1451
+			//	),
1452
+			//	'admin.php?page=espresso_registrations'
1453
+			//),
1454
+		);
1455
+		ob_start();
1456
+		do_action(
1457
+			'AHEE__Events_Admin_Page___generate_publish_box_extra_content__event_editor_overview_add',
1458
+			$this->_cpt_model_obj
1459
+		);
1460
+		$publish_box_extra_args['event_editor_overview_add'] = ob_get_clean();
1461
+		// load template
1462
+		EEH_Template::display_template(
1463
+			EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php',
1464
+			$publish_box_extra_args
1465
+		);
1466
+	}
1467
+
1468
+
1469
+
1470
+	/**
1471
+	 * This just returns whatever is set as the _event object property
1472
+	 * //todo this will become obsolete once the models are in place
1473
+	 *
1474
+	 * @return object
1475
+	 */
1476
+	public function get_event_object()
1477
+	{
1478
+		return $this->_cpt_model_obj;
1479
+	}
1480
+
1481
+
1482
+
1483
+
1484
+	/** METABOXES * */
1485
+	/**
1486
+	 * _register_event_editor_meta_boxes
1487
+	 * add all metaboxes related to the event_editor
1488
+	 *
1489
+	 * @return void
1490
+	 */
1491
+	protected function _register_event_editor_meta_boxes()
1492
+	{
1493
+		$this->verify_cpt_object();
1494
+		add_meta_box(
1495
+			'espresso_event_editor_tickets',
1496
+			esc_html__('Event Datetime & Ticket', 'event_espresso'),
1497
+			array($this, 'ticket_metabox'),
1498
+			$this->page_slug,
1499
+			'normal',
1500
+			'high'
1501
+		);
1502
+		add_meta_box(
1503
+			'espresso_event_editor_event_options',
1504
+			esc_html__('Event Registration Options', 'event_espresso'),
1505
+			array($this, 'registration_options_meta_box'),
1506
+			$this->page_slug,
1507
+			'side',
1508
+			'default'
1509
+		);
1510
+		// NOTE: if you're looking for other metaboxes in here,
1511
+		// where a metabox has a related management page in the admin
1512
+		// you will find it setup in the related management page's "_Hooks" file.
1513
+		// i.e. messages metabox is found in "espresso_events_Messages_Hooks.class.php".
1514
+	}
1515
+
1516
+
1517
+
1518
+	public function ticket_metabox()
1519
+	{
1520
+		$existing_datetime_ids = $existing_ticket_ids = array();
1521
+		//defaults for template args
1522
+		$template_args = array(
1523
+			'existing_datetime_ids'    => '',
1524
+			'event_datetime_help_link' => '',
1525
+			'ticket_options_help_link' => '',
1526
+			'time'                     => null,
1527
+			'ticket_rows'              => '',
1528
+			'existing_ticket_ids'      => '',
1529
+			'total_ticket_rows'        => 1,
1530
+			'ticket_js_structure'      => '',
1531
+			'trash_icon'               => 'ee-lock-icon',
1532
+			'disabled'                 => '',
1533
+		);
1534
+		$event_id = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : null;
1535
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1536
+		/**
1537
+		 * 1. Start with retrieving Datetimes
1538
+		 * 2. Fore each datetime get related tickets
1539
+		 * 3. For each ticket get related prices
1540
+		 */
1541
+		$times = EE_Registry::instance()->load_model('Datetime')->get_all_event_dates($event_id);
1542
+		/** @type EE_Datetime $first_datetime */
1543
+		$first_datetime = reset($times);
1544
+		//do we get related tickets?
1545
+		if ($first_datetime instanceof EE_Datetime
1546
+			&& $first_datetime->ID() !== 0
1547
+		) {
1548
+			$existing_datetime_ids[] = $first_datetime->get('DTT_ID');
1549
+			$template_args['time'] = $first_datetime;
1550
+			$related_tickets = $first_datetime->tickets(
1551
+				array(
1552
+					array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)),
1553
+					'default_where_conditions' => 'none',
1554
+				)
1555
+			);
1556
+			if ( ! empty($related_tickets)) {
1557
+				$template_args['total_ticket_rows'] = count($related_tickets);
1558
+				$row = 0;
1559
+				foreach ($related_tickets as $ticket) {
1560
+					$existing_ticket_ids[] = $ticket->get('TKT_ID');
1561
+					$template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, false, $row);
1562
+					$row++;
1563
+				}
1564
+			} else {
1565
+				$template_args['total_ticket_rows'] = 1;
1566
+				/** @type EE_Ticket $ticket */
1567
+				$ticket = EE_Registry::instance()->load_model('Ticket')->create_default_object();
1568
+				$template_args['ticket_rows'] .= $this->_get_ticket_row($ticket);
1569
+			}
1570
+		} else {
1571
+			$template_args['time'] = $times[0];
1572
+			/** @type EE_Ticket $ticket */
1573
+			$ticket = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets();
1574
+			$template_args['ticket_rows'] .= $this->_get_ticket_row($ticket[1]);
1575
+			// NOTE: we're just sending the first default row
1576
+			// (decaf can't manage default tickets so this should be sufficient);
1577
+		}
1578
+		$template_args['event_datetime_help_link'] = $this->_get_help_tab_link(
1579
+			'event_editor_event_datetimes_help_tab'
1580
+		);
1581
+		$template_args['ticket_options_help_link'] = $this->_get_help_tab_link('ticket_options_info');
1582
+		$template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids);
1583
+		$template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids);
1584
+		$template_args['ticket_js_structure'] = $this->_get_ticket_row(
1585
+			EE_Registry::instance()->load_model('Ticket')->create_default_object(),
1586
+			true
1587
+		);
1588
+		$template = apply_filters(
1589
+			'FHEE__Events_Admin_Page__ticket_metabox__template',
1590
+			EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php'
1591
+		);
1592
+		EEH_Template::display_template($template, $template_args);
1593
+	}
1594
+
1595
+
1596
+
1597
+	/**
1598
+	 * Setup an individual ticket form for the decaf event editor page
1599
+	 *
1600
+	 * @access private
1601
+	 * @param  EE_Ticket $ticket   the ticket object
1602
+	 * @param  boolean   $skeleton whether we're generating a skeleton for js manipulation
1603
+	 * @param int        $row
1604
+	 * @return string generated html for the ticket row.
1605
+	 */
1606
+	private function _get_ticket_row($ticket, $skeleton = false, $row = 0)
1607
+	{
1608
+		$template_args = array(
1609
+			'tkt_status_class'    => ' tkt-status-' . $ticket->ticket_status(),
1610
+			'tkt_archive_class'   => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived'
1611
+				: '',
1612
+			'ticketrow'           => $skeleton ? 'TICKETNUM' : $row,
1613
+			'TKT_ID'              => $ticket->get('TKT_ID'),
1614
+			'TKT_name'            => $ticket->get('TKT_name'),
1615
+			'TKT_start_date'      => $skeleton ? '' : $ticket->get_date('TKT_start_date', 'Y-m-d h:i a'),
1616
+			'TKT_end_date'        => $skeleton ? '' : $ticket->get_date('TKT_end_date', 'Y-m-d h:i a'),
1617
+			'TKT_is_default'      => $ticket->get('TKT_is_default'),
1618
+			'TKT_qty'             => $ticket->get_pretty('TKT_qty', 'input'),
1619
+			'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets',
1620
+			'TKT_sold'            => $skeleton ? 0 : $ticket->get('TKT_sold'),
1621
+			'trash_icon'          => ($skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted')))
1622
+									 && ( ! empty($ticket) && $ticket->get('TKT_sold') === 0)
1623
+				? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon',
1624
+			'disabled'            => $skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted')) ? ''
1625
+				: ' disabled=disabled',
1626
+		);
1627
+		$price = $ticket->ID() !== 0
1628
+			? $ticket->get_first_related('Price', array('default_where_conditions' => 'none'))
1629
+			: EE_Registry::instance()->load_model('Price')->create_default_object();
1630
+		$price_args = array(
1631
+			'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign,
1632
+			'PRC_amount'            => $price->get('PRC_amount'),
1633
+			'PRT_ID'                => $price->get('PRT_ID'),
1634
+			'PRC_ID'                => $price->get('PRC_ID'),
1635
+			'PRC_is_default'        => $price->get('PRC_is_default'),
1636
+		);
1637
+		//make sure we have default start and end dates if skeleton
1638
+		//handle rows that should NOT be empty
1639
+		if (empty($template_args['TKT_start_date'])) {
1640
+			//if empty then the start date will be now.
1641
+			$template_args['TKT_start_date'] = date('Y-m-d h:i a', current_time('timestamp'));
1642
+		}
1643
+		if (empty($template_args['TKT_end_date'])) {
1644
+			//get the earliest datetime (if present);
1645
+			$earliest_dtt = $this->_cpt_model_obj->ID() > 0
1646
+				? $this->_cpt_model_obj->get_first_related(
1647
+					'Datetime',
1648
+					array('order_by' => array('DTT_EVT_start' => 'ASC'))
1649
+				)
1650
+				: null;
1651
+			if ( ! empty($earliest_dtt)) {
1652
+				$template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a');
1653
+			} else {
1654
+				$template_args['TKT_end_date'] = date(
1655
+					'Y-m-d h:i a',
1656
+					mktime(0, 0, 0, date("m"), date("d") + 7, date("Y"))
1657
+				);
1658
+			}
1659
+		}
1660
+		$template_args = array_merge($template_args, $price_args);
1661
+		$template = apply_filters(
1662
+			'FHEE__Events_Admin_Page__get_ticket_row__template',
1663
+			EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php',
1664
+			$ticket
1665
+		);
1666
+		return EEH_Template::display_template($template, $template_args, true);
1667
+	}
1668
+
1669
+
1670
+
1671
+	public function registration_options_meta_box()
1672
+	{
1673
+		$yes_no_values = array(
1674
+			array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')),
1675
+			array('id' => false, 'text' => esc_html__('No', 'event_espresso')),
1676
+		);
1677
+		$default_reg_status_values = EEM_Registration::reg_status_array(
1678
+			array(
1679
+				EEM_Registration::status_id_cancelled,
1680
+				EEM_Registration::status_id_declined,
1681
+				EEM_Registration::status_id_incomplete,
1682
+			),
1683
+			true
1684
+		);
1685
+		//$template_args['is_active_select'] = EEH_Form_Fields::select_input('is_active', $yes_no_values, $this->_cpt_model_obj->is_active());
1686
+		$template_args['_event'] = $this->_cpt_model_obj;
1687
+		$template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false);
1688
+		$template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit();
1689
+		$template_args['default_registration_status'] = EEH_Form_Fields::select_input(
1690
+			'default_reg_status',
1691
+			$default_reg_status_values,
1692
+			$this->_cpt_model_obj->default_registration_status()
1693
+		);
1694
+		$template_args['display_description'] = EEH_Form_Fields::select_input(
1695
+			'display_desc',
1696
+			$yes_no_values,
1697
+			$this->_cpt_model_obj->display_description()
1698
+		);
1699
+		$template_args['display_ticket_selector'] = EEH_Form_Fields::select_input(
1700
+			'display_ticket_selector',
1701
+			$yes_no_values,
1702
+			$this->_cpt_model_obj->display_ticket_selector(),
1703
+			'',
1704
+			'',
1705
+			false
1706
+		);
1707
+		$template_args['additional_registration_options'] = apply_filters(
1708
+			'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options',
1709
+			'',
1710
+			$template_args,
1711
+			$yes_no_values,
1712
+			$default_reg_status_values
1713
+		);
1714
+		EEH_Template::display_template(
1715
+			EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php',
1716
+			$template_args
1717
+		);
1718
+	}
1719
+
1720
+
1721
+
1722
+	/**
1723
+	 * _get_events()
1724
+	 * This method simply returns all the events (for the given _view and paging)
1725
+	 *
1726
+	 * @access public
1727
+	 * @param int  $per_page     count of items per page (20 default);
1728
+	 * @param int  $current_page what is the current page being viewed.
1729
+	 * @param bool $count        if TRUE then we just return a count of ALL events matching the given _view.
1730
+	 *                           If FALSE then we return an array of event objects
1731
+	 *                           that match the given _view and paging parameters.
1732
+	 * @return array an array of event objects.
1733
+	 */
1734
+	public function get_events($per_page = 10, $current_page = 1, $count = false)
1735
+	{
1736
+		$EEME = $this->_event_model();
1737
+		$offset = ($current_page - 1) * $per_page;
1738
+		$limit = $count ? null : $offset . ',' . $per_page;
1739
+		$orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID';
1740
+		$order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC";
1741
+		if (isset($this->_req_data['month_range'])) {
1742
+			$pieces = explode(' ', $this->_req_data['month_range'], 3);
1743
+			$month_r = ! empty($pieces[0]) ? date('m', strtotime($pieces[0])) : '';
1744
+			$year_r = ! empty($pieces[1]) ? $pieces[1] : '';
1745
+		}
1746
+		$where = array();
1747
+		$status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null;
1748
+		//determine what post_status our condition will have for the query.
1749
+		switch ($status) {
1750
+			case 'month' :
1751
+			case 'today' :
1752
+			case null :
1753
+			case 'all' :
1754
+				break;
1755
+			case 'draft' :
1756
+				$where['status'] = array('IN', array('draft', 'auto-draft'));
1757
+				break;
1758
+			default :
1759
+				$where['status'] = $status;
1760
+		}
1761
+		//categories?
1762
+		$category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0
1763
+			? $this->_req_data['EVT_CAT'] : null;
1764
+		if ( ! empty ($category)) {
1765
+			$where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories';
1766
+			$where['Term_Taxonomy.term_id'] = $category;
1767
+		}
1768
+		//date where conditions
1769
+		$start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start');
1770
+		if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') {
1771
+			$DateTime = new DateTime(
1772
+				$year_r . '-' . $month_r . '-01 00:00:00',
1773
+				new DateTimeZone(EEM_Datetime::instance()->get_timezone())
1774
+			);
1775
+			$start = $DateTime->format(implode(' ', $start_formats));
1776
+			$end = $DateTime->setDate($year_r, $month_r, $DateTime
1777
+				->format('t'))->setTime(23, 59, 59)
1778
+							->format(implode(' ', $start_formats));
1779
+			$where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1780
+		} else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'today') {
1781
+			$DateTime = new DateTime('now', new DateTimeZone(EEM_Event::instance()->get_timezone()));
1782
+			$start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats));
1783
+			$end = $DateTime->setTime(23, 59, 59)->format(implode(' ', $start_formats));
1784
+			$where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1785
+		} else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'month') {
1786
+			$now = date('Y-m-01');
1787
+			$DateTime = new DateTime($now, new DateTimeZone(EEM_Event::instance()->get_timezone()));
1788
+			$start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats));
1789
+			$end = $DateTime->setDate(date('Y'), date('m'), $DateTime->format('t'))
1790
+							->setTime(23, 59, 59)
1791
+							->format(implode(' ', $start_formats));
1792
+			$where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1793
+		}
1794
+		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) {
1795
+			$where['EVT_wp_user'] = get_current_user_id();
1796
+		} else {
1797
+			if ( ! isset($where['status'])) {
1798
+				if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) {
1799
+					$where['OR'] = array(
1800
+						'status*restrict_private' => array('!=', 'private'),
1801
+						'AND'                     => array(
1802
+							'status*inclusive' => array('=', 'private'),
1803
+							'EVT_wp_user'      => get_current_user_id(),
1804
+						),
1805
+					);
1806
+				}
1807
+			}
1808
+		}
1809
+		if (isset($this->_req_data['EVT_wp_user'])) {
1810
+			if ($this->_req_data['EVT_wp_user'] != get_current_user_id()
1811
+				&& EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')
1812
+			) {
1813
+				$where['EVT_wp_user'] = $this->_req_data['EVT_wp_user'];
1814
+			}
1815
+		}
1816
+		//search query handling
1817
+		if (isset($this->_req_data['s'])) {
1818
+			$search_string = '%' . $this->_req_data['s'] . '%';
1819
+			$where['OR'] = array(
1820
+				'EVT_name'       => array('LIKE', $search_string),
1821
+				'EVT_desc'       => array('LIKE', $search_string),
1822
+				'EVT_short_desc' => array('LIKE', $search_string),
1823
+			);
1824
+		}
1825
+		$where = apply_filters('FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data);
1826
+		$query_params = apply_filters(
1827
+			'FHEE__Events_Admin_Page__get_events__query_params',
1828
+			array(
1829
+				$where,
1830
+				'limit'    => $limit,
1831
+				'order_by' => $orderby,
1832
+				'order'    => $order,
1833
+				'group_by' => 'EVT_ID',
1834
+			),
1835
+			$this->_req_data
1836
+		);
1837
+		//let's first check if we have special requests coming in.
1838
+		if (isset($this->_req_data['active_status'])) {
1839
+			switch ($this->_req_data['active_status']) {
1840
+				case 'upcoming' :
1841
+					return $EEME->get_upcoming_events($query_params, $count);
1842
+					break;
1843
+				case 'expired' :
1844
+					return $EEME->get_expired_events($query_params, $count);
1845
+					break;
1846
+				case 'active' :
1847
+					return $EEME->get_active_events($query_params, $count);
1848
+					break;
1849
+				case 'inactive' :
1850
+					return $EEME->get_inactive_events($query_params, $count);
1851
+					break;
1852
+			}
1853
+		}
1854
+		$events = $count ? $EEME->count(array($where), 'EVT_ID', true) : $EEME->get_all($query_params);
1855
+		return $events;
1856
+	}
1857
+
1858
+
1859
+
1860
+	/**
1861
+	 * handling for WordPress CPT actions (trash, restore, delete)
1862
+	 *
1863
+	 * @param string $post_id
1864
+	 */
1865
+	public function trash_cpt_item($post_id)
1866
+	{
1867
+		$this->_req_data['EVT_ID'] = $post_id;
1868
+		$this->_trash_or_restore_event('trash', false);
1869
+	}
1870
+
1871
+
1872
+
1873
+	/**
1874
+	 * @param string $post_id
1875
+	 */
1876
+	public function restore_cpt_item($post_id)
1877
+	{
1878
+		$this->_req_data['EVT_ID'] = $post_id;
1879
+		$this->_trash_or_restore_event('draft', false);
1880
+	}
1881
+
1882
+
1883
+
1884
+	/**
1885
+	 * @param string $post_id
1886
+	 */
1887
+	public function delete_cpt_item($post_id)
1888
+	{
1889
+		$this->_req_data['EVT_ID'] = $post_id;
1890
+		$this->_delete_event(false);
1891
+	}
1892
+
1893
+
1894
+
1895
+	/**
1896
+	 * _trash_or_restore_event
1897
+	 *
1898
+	 * @access protected
1899
+	 * @param  string $event_status
1900
+	 * @param bool    $redirect_after
1901
+	 */
1902
+	protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = true)
1903
+	{
1904
+		//determine the event id and set to array.
1905
+		$EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : false;
1906
+		// loop thru events
1907
+		if ($EVT_ID) {
1908
+			// clean status
1909
+			$event_status = sanitize_key($event_status);
1910
+			// grab status
1911
+			if ( ! empty($event_status)) {
1912
+				$success = $this->_change_event_status($EVT_ID, $event_status);
1913
+			} else {
1914
+				$success = false;
1915
+				$msg = esc_html__(
1916
+					'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.',
1917
+					'event_espresso'
1918
+				);
1919
+				EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1920
+			}
1921
+		} else {
1922
+			$success = false;
1923
+			$msg = esc_html__(
1924
+				'An error occurred. The event could not be moved to the trash because a valid event ID was not not supplied.',
1925
+				'event_espresso'
1926
+			);
1927
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1928
+		}
1929
+		$action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash';
1930
+		if ($redirect_after) {
1931
+			$this->_redirect_after_action($success, 'Event', $action, array('action' => 'default'));
1932
+		}
1933
+	}
1934
+
1935
+
1936
+
1937
+	/**
1938
+	 * _trash_or_restore_events
1939
+	 *
1940
+	 * @access protected
1941
+	 * @param  string $event_status
1942
+	 * @return void
1943
+	 */
1944
+	protected function _trash_or_restore_events($event_status = 'trash')
1945
+	{
1946
+		// clean status
1947
+		$event_status = sanitize_key($event_status);
1948
+		// grab status
1949
+		if ( ! empty($event_status)) {
1950
+			$success = true;
1951
+			//determine the event id and set to array.
1952
+			$EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array();
1953
+			// loop thru events
1954
+			foreach ($EVT_IDs as $EVT_ID) {
1955
+				if ($EVT_ID = absint($EVT_ID)) {
1956
+					$results = $this->_change_event_status($EVT_ID, $event_status);
1957
+					$success = $results !== false ? $success : false;
1958
+				} else {
1959
+					$msg = sprintf(
1960
+						esc_html__(
1961
+							'An error occurred. Event #%d could not be moved to the trash because a valid event ID was not not supplied.',
1962
+							'event_espresso'
1963
+						),
1964
+						$EVT_ID
1965
+					);
1966
+					EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1967
+					$success = false;
1968
+				}
1969
+			}
1970
+		} else {
1971
+			$success = false;
1972
+			$msg = esc_html__(
1973
+				'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.',
1974
+				'event_espresso'
1975
+			);
1976
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1977
+		}
1978
+		// in order to force a pluralized result message we need to send back a success status greater than 1
1979
+		$success = $success ? 2 : false;
1980
+		$action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash';
1981
+		$this->_redirect_after_action($success, 'Events', $action, array('action' => 'default'));
1982
+	}
1983
+
1984
+
1985
+
1986
+	/**
1987
+	 * _trash_or_restore_events
1988
+	 *
1989
+	 * @access  private
1990
+	 * @param  int    $EVT_ID
1991
+	 * @param  string $event_status
1992
+	 * @return bool
1993
+	 */
1994
+	private function _change_event_status($EVT_ID = 0, $event_status = '')
1995
+	{
1996
+		// grab event id
1997
+		if ( ! $EVT_ID) {
1998
+			$msg = esc_html__(
1999
+				'An error occurred. No Event ID or an invalid Event ID was received.',
2000
+				'event_espresso'
2001
+			);
2002
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2003
+			return false;
2004
+		}
2005
+		$this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID);
2006
+		// clean status
2007
+		$event_status = sanitize_key($event_status);
2008
+		// grab status
2009
+		if (empty($event_status)) {
2010
+			$msg = esc_html__(
2011
+				'An error occurred. No Event Status or an invalid Event Status was received.',
2012
+				'event_espresso'
2013
+			);
2014
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2015
+			return false;
2016
+		}
2017
+		// was event trashed or restored ?
2018
+		switch ($event_status) {
2019
+			case 'draft' :
2020
+				$action = 'restored from the trash';
2021
+				$hook = 'AHEE_event_restored_from_trash';
2022
+				break;
2023
+			case 'trash' :
2024
+				$action = 'moved to the trash';
2025
+				$hook = 'AHEE_event_moved_to_trash';
2026
+				break;
2027
+			default :
2028
+				$action = 'updated';
2029
+				$hook = false;
2030
+		}
2031
+		//use class to change status
2032
+		$this->_cpt_model_obj->set_status($event_status);
2033
+		$success = $this->_cpt_model_obj->save();
2034
+		if ($success === false) {
2035
+			$msg = sprintf(esc_html__('An error occurred. The event could not be %s.', 'event_espresso'), $action);
2036
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2037
+			return false;
2038
+		}
2039
+		if ($hook) {
2040
+			do_action($hook);
2041
+		}
2042
+		return true;
2043
+	}
2044
+
2045
+
2046
+
2047
+	/**
2048
+	 * _delete_event
2049
+	 *
2050
+	 * @access protected
2051
+	 * @param bool $redirect_after
2052
+	 */
2053
+	protected function _delete_event($redirect_after = true)
2054
+	{
2055
+		//determine the event id and set to array.
2056
+		$EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : null;
2057
+		$EVT_ID = isset($this->_req_data['post']) ? absint($this->_req_data['post']) : $EVT_ID;
2058
+		// loop thru events
2059
+		if ($EVT_ID) {
2060
+			$success = $this->_permanently_delete_event($EVT_ID);
2061
+			// get list of events with no prices
2062
+			$espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array());
2063
+			// remove this event from the list of events with no prices
2064
+			if (isset($espresso_no_ticket_prices[$EVT_ID])) {
2065
+				unset($espresso_no_ticket_prices[$EVT_ID]);
2066
+			}
2067
+			update_option('ee_no_ticket_prices', $espresso_no_ticket_prices);
2068
+		} else {
2069
+			$success = false;
2070
+			$msg = esc_html__(
2071
+				'An error occurred. An event could not be deleted because a valid event ID was not not supplied.',
2072
+				'event_espresso'
2073
+			);
2074
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2075
+		}
2076
+		if ($redirect_after) {
2077
+			$this->_redirect_after_action(
2078
+				$success,
2079
+				'Event',
2080
+				'deleted',
2081
+				array('action' => 'default', 'status' => 'trash')
2082
+			);
2083
+		}
2084
+	}
2085
+
2086
+
2087
+
2088
+	/**
2089
+	 * _delete_events
2090
+	 *
2091
+	 * @access protected
2092
+	 * @return void
2093
+	 */
2094
+	protected function _delete_events()
2095
+	{
2096
+		$success = true;
2097
+		// get list of events with no prices
2098
+		$espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array());
2099
+		//determine the event id and set to array.
2100
+		$EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array();
2101
+		// loop thru events
2102
+		foreach ($EVT_IDs as $EVT_ID) {
2103
+			$EVT_ID = absint($EVT_ID);
2104
+			if ($EVT_ID) {
2105
+				$results = $this->_permanently_delete_event($EVT_ID);
2106
+				$success = $results !== false ? $success : false;
2107
+				// remove this event from the list of events with no prices
2108
+				unset($espresso_no_ticket_prices[$EVT_ID]);
2109
+			} else {
2110
+				$success = false;
2111
+				$msg = esc_html__(
2112
+					'An error occurred. An event could not be deleted because a valid event ID was not not supplied.',
2113
+					'event_espresso'
2114
+				);
2115
+				EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2116
+			}
2117
+		}
2118
+		update_option('ee_no_ticket_prices', $espresso_no_ticket_prices);
2119
+		// in order to force a pluralized result message we need to send back a success status greater than 1
2120
+		$success = $success ? 2 : false;
2121
+		$this->_redirect_after_action($success, 'Events', 'deleted', array('action' => 'default'));
2122
+	}
2123
+
2124
+
2125
+
2126
+	/**
2127
+	 * _permanently_delete_event
2128
+	 *
2129
+	 * @access  private
2130
+	 * @param  int $EVT_ID
2131
+	 * @return bool
2132
+	 */
2133
+	private function _permanently_delete_event($EVT_ID = 0)
2134
+	{
2135
+		// grab event id
2136
+		if ( ! $EVT_ID) {
2137
+			$msg = esc_html__(
2138
+				'An error occurred. No Event ID or an invalid Event ID was received.',
2139
+				'event_espresso'
2140
+			);
2141
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2142
+			return false;
2143
+		}
2144
+		if (
2145
+			! $this->_cpt_model_obj instanceof EE_Event
2146
+			|| $this->_cpt_model_obj->ID() !== $EVT_ID
2147
+		) {
2148
+			$this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID);
2149
+		}
2150
+		if ( ! $this->_cpt_model_obj instanceof EE_Event) {
2151
+			return false;
2152
+		}
2153
+		//need to delete related tickets and prices first.
2154
+		$datetimes = $this->_cpt_model_obj->get_many_related('Datetime');
2155
+		foreach ($datetimes as $datetime) {
2156
+			$this->_cpt_model_obj->_remove_relation_to($datetime, 'Datetime');
2157
+			$tickets = $datetime->get_many_related('Ticket');
2158
+			foreach ($tickets as $ticket) {
2159
+				$ticket->_remove_relation_to($datetime, 'Datetime');
2160
+				$ticket->delete_related_permanently('Price');
2161
+				$ticket->delete_permanently();
2162
+			}
2163
+			$datetime->delete();
2164
+		}
2165
+		//what about related venues or terms?
2166
+		$venues = $this->_cpt_model_obj->get_many_related('Venue');
2167
+		foreach ($venues as $venue) {
2168
+			$this->_cpt_model_obj->_remove_relation_to($venue, 'Venue');
2169
+		}
2170
+		//any attached question groups?
2171
+		$question_groups = $this->_cpt_model_obj->get_many_related('Question_Group');
2172
+		if ( ! empty($question_groups)) {
2173
+			foreach ($question_groups as $question_group) {
2174
+				$this->_cpt_model_obj->_remove_relation_to($question_group, 'Question_Group');
2175
+			}
2176
+		}
2177
+		//Message Template Groups
2178
+		$this->_cpt_model_obj->_remove_relations('Message_Template_Group');
2179
+		/** @type EE_Term_Taxonomy[] $term_taxonomies */
2180
+		$term_taxonomies = $this->_cpt_model_obj->term_taxonomies();
2181
+		foreach ($term_taxonomies as $term_taxonomy) {
2182
+			$this->_cpt_model_obj->remove_relation_to_term_taxonomy($term_taxonomy);
2183
+		}
2184
+		$success = $this->_cpt_model_obj->delete_permanently();
2185
+		// did it all go as planned ?
2186
+		if ($success) {
2187
+			$msg = sprintf(esc_html__('Event ID # %d has been deleted.', 'event_espresso'), $EVT_ID);
2188
+			EE_Error::add_success($msg);
2189
+		} else {
2190
+			$msg = sprintf(
2191
+				esc_html__('An error occurred. Event ID # %d could not be deleted.', 'event_espresso'),
2192
+				$EVT_ID
2193
+			);
2194
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2195
+			return false;
2196
+		}
2197
+		do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID);
2198
+		return true;
2199
+	}
2200
+
2201
+
2202
+
2203
+	/**
2204
+	 * get total number of events
2205
+	 *
2206
+	 * @access public
2207
+	 * @return int
2208
+	 */
2209
+	public function total_events()
2210
+	{
2211
+		$count = EEM_Event::instance()->count(array('caps' => 'read_admin'), 'EVT_ID', true);
2212
+		return $count;
2213
+	}
2214
+
2215
+
2216
+
2217
+	/**
2218
+	 * get total number of draft events
2219
+	 *
2220
+	 * @access public
2221
+	 * @return int
2222
+	 */
2223
+	public function total_events_draft()
2224
+	{
2225
+		$where = array(
2226
+			'status' => array('IN', array('draft', 'auto-draft')),
2227
+		);
2228
+		$count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
2229
+		return $count;
2230
+	}
2231
+
2232
+
2233
+
2234
+	/**
2235
+	 * get total number of trashed events
2236
+	 *
2237
+	 * @access public
2238
+	 * @return int
2239
+	 */
2240
+	public function total_trashed_events()
2241
+	{
2242
+		$where = array(
2243
+			'status' => 'trash',
2244
+		);
2245
+		$count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
2246
+		return $count;
2247
+	}
2248
+
2249
+
2250
+
2251
+	/**
2252
+	 *    _default_event_settings
2253
+	 *    This generates the Default Settings Tab
2254
+	 *
2255
+	 * @return void
2256
+	 */
2257
+	protected function _default_event_settings()
2258
+	{
2259
+		$this->_template_args['values'] = $this->_yes_no_values;
2260
+		$this->_template_args['reg_status_array'] = EEM_Registration::reg_status_array(
2261
+		// exclude array
2262
+			array(
2263
+				EEM_Registration::status_id_cancelled,
2264
+				EEM_Registration::status_id_declined,
2265
+				EEM_Registration::status_id_incomplete,
2266
+				EEM_Registration::status_id_wait_list,
2267
+			),
2268
+			// translated
2269
+			true
2270
+		);
2271
+		$this->_template_args['default_reg_status'] = isset(
2272
+														  EE_Registry::instance()->CFG->registration->default_STS_ID
2273
+													  )
2274
+													  && array_key_exists(
2275
+														  EE_Registry::instance()->CFG->registration->default_STS_ID,
2276
+														  $this->_template_args['reg_status_array']
2277
+													  )
2278
+			? sanitize_text_field(EE_Registry::instance()->CFG->registration->default_STS_ID)
2279
+			: EEM_Registration::status_id_pending_payment;
2280
+		$this->_set_add_edit_form_tags('update_default_event_settings');
2281
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
2282
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2283
+			EVENTS_TEMPLATE_PATH . 'event_settings.template.php',
2284
+			$this->_template_args,
2285
+			true
2286
+		);
2287
+		$this->display_admin_page_with_sidebar();
2288
+	}
2289
+
2290
+
2291
+
2292
+	/**
2293
+	 * _update_default_event_settings
2294
+	 *
2295
+	 * @access protected
2296
+	 * @return void
2297
+	 */
2298
+	protected function _update_default_event_settings()
2299
+	{
2300
+		EE_Config::instance()->registration->default_STS_ID = isset($this->_req_data['default_reg_status'])
2301
+			? sanitize_text_field($this->_req_data['default_reg_status'])
2302
+			: EEM_Registration::status_id_pending_payment;
2303
+		$what = 'Default Event Settings';
2304
+		$success = $this->_update_espresso_configuration(
2305
+			$what,
2306
+			EE_Config::instance(),
2307
+			__FILE__,
2308
+			__FUNCTION__,
2309
+			__LINE__
2310
+		);
2311
+		$this->_redirect_after_action($success, $what, 'updated', array('action' => 'default_event_settings'));
2312
+	}
2313
+
2314
+
2315
+
2316
+	/*************        Templates        *************/
2317
+	protected function _template_settings()
2318
+	{
2319
+		$this->_admin_page_title = esc_html__('Template Settings (Preview)', 'event_espresso');
2320
+		$this->_template_args['preview_img'] = '<img src="'
2321
+											   . EVENTS_ASSETS_URL
2322
+											   . DS
2323
+											   . 'images'
2324
+											   . DS
2325
+											   . 'caffeinated_template_features.jpg" alt="'
2326
+											   . esc_attr__('Template Settings Preview screenshot', 'event_espresso')
2327
+											   . '" />';
2328
+		$this->_template_args['preview_text'] = '<strong>' . esc_html__(
2329
+				'Template Settings is a feature that is only available in the premium version of Event Espresso 4 which is available with a support license purchase on EventEspresso.com. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.',
2330
+				'event_espresso'
2331
+			) . '</strong>';
2332
+		$this->display_admin_caf_preview_page('template_settings_tab');
2333
+	}
2334
+
2335
+
2336
+	/** Event Category Stuff **/
2337
+	/**
2338
+	 * set the _category property with the category object for the loaded page.
2339
+	 *
2340
+	 * @access private
2341
+	 * @return void
2342
+	 */
2343
+	private function _set_category_object()
2344
+	{
2345
+		if (isset($this->_category->id) && ! empty($this->_category->id)) {
2346
+			return;
2347
+		} //already have the category object so get out.
2348
+		//set default category object
2349
+		$this->_set_empty_category_object();
2350
+		//only set if we've got an id
2351
+		if ( ! isset($this->_req_data['EVT_CAT_ID'])) {
2352
+			return;
2353
+		}
2354
+		$category_id = absint($this->_req_data['EVT_CAT_ID']);
2355
+		$term = get_term($category_id, 'espresso_event_categories');
2356
+		if ( ! empty($term)) {
2357
+			$this->_category->category_name = $term->name;
2358
+			$this->_category->category_identifier = $term->slug;
2359
+			$this->_category->category_desc = $term->description;
2360
+			$this->_category->id = $term->term_id;
2361
+			$this->_category->parent = $term->parent;
2362
+		}
2363
+	}
2364
+
2365
+
2366
+
2367
+	private function _set_empty_category_object()
2368
+	{
2369
+		$this->_category = new stdClass();
2370
+		$this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = '';
2371
+		$this->_category->id = $this->_category->parent = 0;
2372
+	}
2373
+
2374
+
2375
+
2376
+	protected function _category_list_table()
2377
+	{
2378
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2379
+		$this->_search_btn_label = esc_html__('Categories', 'event_espresso');
2380
+		$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
2381
+				'add_category',
2382
+				'add_category',
2383
+				array(),
2384
+				'add-new-h2'
2385
+			);
2386
+		$this->display_admin_list_table_page_with_sidebar();
2387
+	}
2388
+
2389
+
2390
+
2391
+	/**
2392
+	 * @param $view
2393
+	 */
2394
+	protected function _category_details($view)
2395
+	{
2396
+		//load formatter helper
2397
+		//load field generator helper
2398
+		$route = $view == 'edit' ? 'update_category' : 'insert_category';
2399
+		$this->_set_add_edit_form_tags($route);
2400
+		$this->_set_category_object();
2401
+		$id = ! empty($this->_category->id) ? $this->_category->id : '';
2402
+		$delete_action = 'delete_category';
2403
+		//custom redirect
2404
+		$redirect = EE_Admin_Page::add_query_args_and_nonce(
2405
+			array('action' => 'category_list'),
2406
+			$this->_admin_base_url
2407
+		);
2408
+		$this->_set_publish_post_box_vars('EVT_CAT_ID', $id, $delete_action, $redirect);
2409
+		//take care of contents
2410
+		$this->_template_args['admin_page_content'] = $this->_category_details_content();
2411
+		$this->display_admin_page_with_sidebar();
2412
+	}
2413
+
2414
+
2415
+
2416
+	/**
2417
+	 * @return mixed
2418
+	 */
2419
+	protected function _category_details_content()
2420
+	{
2421
+		$editor_args['category_desc'] = array(
2422
+			'type'          => 'wp_editor',
2423
+			'value'         => EEH_Formatter::admin_format_content($this->_category->category_desc),
2424
+			'class'         => 'my_editor_custom',
2425
+			'wpeditor_args' => array('media_buttons' => false),
2426
+		);
2427
+		$_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array');
2428
+		$all_terms = get_terms(
2429
+			array('espresso_event_categories'),
2430
+			array('hide_empty' => 0, 'exclude' => array($this->_category->id))
2431
+		);
2432
+		//setup category select for term parents.
2433
+		$category_select_values[] = array(
2434
+			'text' => esc_html__('No Parent', 'event_espresso'),
2435
+			'id'   => 0,
2436
+		);
2437
+		foreach ($all_terms as $term) {
2438
+			$category_select_values[] = array(
2439
+				'text' => $term->name,
2440
+				'id'   => $term->term_id,
2441
+			);
2442
+		}
2443
+		$category_select = EEH_Form_Fields::select_input(
2444
+			'category_parent',
2445
+			$category_select_values,
2446
+			$this->_category->parent
2447
+		);
2448
+		$template_args = array(
2449
+			'category'                 => $this->_category,
2450
+			'category_select'          => $category_select,
2451
+			'unique_id_info_help_link' => $this->_get_help_tab_link('unique_id_info'),
2452
+			'category_desc_editor'     => $_wp_editor['category_desc']['field'],
2453
+			'disable'                  => '',
2454
+			'disabled_message'         => false,
2455
+		);
2456
+		$template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php';
2457
+		return EEH_Template::display_template($template, $template_args, true);
2458
+	}
2459
+
2460
+
2461
+
2462
+	protected function _delete_categories()
2463
+	{
2464
+		$cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array)$this->_req_data['EVT_CAT_ID']
2465
+			: (array)$this->_req_data['category_id'];
2466
+		foreach ($cat_ids as $cat_id) {
2467
+			$this->_delete_category($cat_id);
2468
+		}
2469
+		//doesn't matter what page we're coming from... we're going to the same place after delete.
2470
+		$query_args = array(
2471
+			'action' => 'category_list',
2472
+		);
2473
+		$this->_redirect_after_action(0, '', '', $query_args);
2474
+	}
2475
+
2476
+
2477
+
2478
+	/**
2479
+	 * @param $cat_id
2480
+	 */
2481
+	protected function _delete_category($cat_id)
2482
+	{
2483
+		$cat_id = absint($cat_id);
2484
+		wp_delete_term($cat_id, 'espresso_event_categories');
2485
+	}
2486
+
2487
+
2488
+
2489
+	/**
2490
+	 * @param $new_category
2491
+	 */
2492
+	protected function _insert_or_update_category($new_category)
2493
+	{
2494
+		$cat_id = $new_category ? $this->_insert_category() : $this->_insert_category(true);
2495
+		$success = 0; //we already have a success message so lets not send another.
2496
+		if ($cat_id) {
2497
+			$query_args = array(
2498
+				'action'     => 'edit_category',
2499
+				'EVT_CAT_ID' => $cat_id,
2500
+			);
2501
+		} else {
2502
+			$query_args = array('action' => 'add_category');
2503
+		}
2504
+		$this->_redirect_after_action($success, '', '', $query_args, true);
2505
+	}
2506
+
2507
+
2508
+
2509
+	/**
2510
+	 * @param bool $update
2511
+	 * @return bool|mixed|string
2512
+	 */
2513
+	private function _insert_category($update = false)
2514
+	{
2515
+		$cat_id = $update ? $this->_req_data['EVT_CAT_ID'] : '';
2516
+		$category_name = isset($this->_req_data['category_name']) ? $this->_req_data['category_name'] : '';
2517
+		$category_desc = isset($this->_req_data['category_desc']) ? $this->_req_data['category_desc'] : '';
2518
+		$category_parent = isset($this->_req_data['category_parent']) ? $this->_req_data['category_parent'] : 0;
2519
+		if (empty($category_name)) {
2520
+			$msg = esc_html__('You must add a name for the category.', 'event_espresso');
2521
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2522
+			return false;
2523
+		}
2524
+		$term_args = array(
2525
+			'name'        => $category_name,
2526
+			'description' => $category_desc,
2527
+			'parent'      => $category_parent,
2528
+		);
2529
+		//was the category_identifier input disabled?
2530
+		if (isset($this->_req_data['category_identifier'])) {
2531
+			$term_args['slug'] = $this->_req_data['category_identifier'];
2532
+		}
2533
+		$insert_ids = $update
2534
+			? wp_update_term($cat_id, 'espresso_event_categories', $term_args)
2535
+			: wp_insert_term($category_name, 'espresso_event_categories', $term_args);
2536
+		if ( ! is_array($insert_ids)) {
2537
+			$msg = esc_html__(
2538
+				'An error occurred and the category has not been saved to the database.',
2539
+				'event_espresso'
2540
+			);
2541
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2542
+		} else {
2543
+			$cat_id = $insert_ids['term_id'];
2544
+			$msg = sprintf(esc_html__('The category %s was successfully saved', 'event_espresso'), $category_name);
2545
+			EE_Error::add_success($msg);
2546
+		}
2547
+		return $cat_id;
2548
+	}
2549
+
2550
+
2551
+
2552
+	/**
2553
+	 * @param int  $per_page
2554
+	 * @param int  $current_page
2555
+	 * @param bool $count
2556
+	 * @return \EE_Base_Class[]|int
2557
+	 */
2558
+	public function get_categories($per_page = 10, $current_page = 1, $count = false)
2559
+	{
2560
+		//testing term stuff
2561
+		$orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'Term.term_id';
2562
+		$order = isset($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC';
2563
+		$limit = ($current_page - 1) * $per_page;
2564
+		$where = array('taxonomy' => 'espresso_event_categories');
2565
+		if (isset($this->_req_data['s'])) {
2566
+			$sstr = '%' . $this->_req_data['s'] . '%';
2567
+			$where['OR'] = array(
2568
+				'Term.name'   => array('LIKE', $sstr),
2569
+				'description' => array('LIKE', $sstr),
2570
+			);
2571
+		}
2572
+		$query_params = array(
2573
+			$where,
2574
+			'order_by'   => array($orderby => $order),
2575
+			'limit'      => $limit . ',' . $per_page,
2576
+			'force_join' => array('Term'),
2577
+		);
2578
+		$categories = $count
2579
+			? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id')
2580
+			: EEM_Term_Taxonomy::instance()->get_all($query_params);
2581
+		return $categories;
2582
+	}
2583
+
2584
+
2585
+
2586
+	/* end category stuff */
2587
+	/**************/
2588 2588
 }
2589 2589
 //end class Events_Admin_Page
Please login to merge, or discard this patch.
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -532,11 +532,11 @@  discard block
 block discarded – undo
532 532
     {
533 533
         wp_register_style(
534 534
             'events-admin-css',
535
-            EVENTS_ASSETS_URL . 'events-admin-page.css',
535
+            EVENTS_ASSETS_URL.'events-admin-page.css',
536 536
             array(),
537 537
             EVENT_ESPRESSO_VERSION
538 538
         );
539
-        wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION);
539
+        wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL.'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION);
540 540
         wp_enqueue_style('events-admin-css');
541 541
         wp_enqueue_style('ee-cat-admin');
542 542
         //todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
         //scripts
545 545
         wp_register_script(
546 546
             'event_editor_js',
547
-            EVENTS_ASSETS_URL . 'event_editor.js',
547
+            EVENTS_ASSETS_URL.'event_editor.js',
548 548
             array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'),
549 549
             EVENT_ESPRESSO_VERSION,
550 550
             true
@@ -576,7 +576,7 @@  discard block
 block discarded – undo
576 576
         wp_enqueue_style('espresso-ui-theme');
577 577
         wp_register_style(
578 578
             'event-editor-css',
579
-            EVENTS_ASSETS_URL . 'event-editor.css',
579
+            EVENTS_ASSETS_URL.'event-editor.css',
580 580
             array('ee-admin-css'),
581 581
             EVENT_ESPRESSO_VERSION
582 582
         );
@@ -584,7 +584,7 @@  discard block
 block discarded – undo
584 584
         //scripts
585 585
         wp_register_script(
586 586
             'event-datetime-metabox',
587
-            EVENTS_ASSETS_URL . 'event-datetime-metabox.js',
587
+            EVENTS_ASSETS_URL.'event-datetime-metabox.js',
588 588
             array('event_editor_js', 'ee-datepicker'),
589 589
             EVENT_ESPRESSO_VERSION
590 590
         );
@@ -750,7 +750,7 @@  discard block
 block discarded – undo
750 750
                         'Your website\'s timezone is currently set to UTC + 0. We recommend updating your timezone to a city or region near you before you create an event. Your timezone can be updated through the %1$sGeneral Settings%2$s page.',
751 751
                         'event_espresso'
752 752
                     ),
753
-                    '<a href="' . admin_url('options-general.php') . '">',
753
+                    '<a href="'.admin_url('options-general.php').'">',
754 754
                     '</a>'
755 755
                 ),
756 756
                 __FILE__,
@@ -820,31 +820,31 @@  discard block
 block discarded – undo
820 820
         $items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items);
821 821
         $statuses = array(
822 822
             'sold_out_status'  => array(
823
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out,
823
+                'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::sold_out,
824 824
                 'desc'  => EEH_Template::pretty_status(EE_Datetime::sold_out, false, 'sentence'),
825 825
             ),
826 826
             'active_status'    => array(
827
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active,
827
+                'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::active,
828 828
                 'desc'  => EEH_Template::pretty_status(EE_Datetime::active, false, 'sentence'),
829 829
             ),
830 830
             'upcoming_status'  => array(
831
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming,
831
+                'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::upcoming,
832 832
                 'desc'  => EEH_Template::pretty_status(EE_Datetime::upcoming, false, 'sentence'),
833 833
             ),
834 834
             'postponed_status' => array(
835
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed,
835
+                'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::postponed,
836 836
                 'desc'  => EEH_Template::pretty_status(EE_Datetime::postponed, false, 'sentence'),
837 837
             ),
838 838
             'cancelled_status' => array(
839
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled,
839
+                'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::cancelled,
840 840
                 'desc'  => EEH_Template::pretty_status(EE_Datetime::cancelled, false, 'sentence'),
841 841
             ),
842 842
             'expired_status'   => array(
843
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired,
843
+                'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::expired,
844 844
                 'desc'  => EEH_Template::pretty_status(EE_Datetime::expired, false, 'sentence'),
845 845
             ),
846 846
             'inactive_status'  => array(
847
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive,
847
+                'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::inactive,
848 848
                 'desc'  => EEH_Template::pretty_status(EE_Datetime::inactive, false, 'sentence'),
849 849
             ),
850 850
         );
@@ -908,7 +908,7 @@  discard block
 block discarded – undo
908 908
     {
909 909
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
910 910
         $this->_template_args['after_list_table'] = ! empty($this->_template_args['after_list_table'])
911
-            ? (array)$this->_template_args['after_list_table']
911
+            ? (array) $this->_template_args['after_list_table']
912 912
             : array();
913 913
         $this->_template_args['after_list_table']['view_event_list_button'] = EEH_HTML::br()
914 914
                                                                               . EEH_Template::get_button_or_link(
@@ -917,7 +917,7 @@  discard block
 block discarded – undo
917 917
                 'button'
918 918
             );
919 919
         $this->_template_args['after_list_table']['legend'] = $this->_display_legend($this->_event_legend_items());
920
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
920
+        $this->_admin_page_title .= ' '.$this->get_action_link_or_button(
921 921
                 'create_new',
922 922
                 'add',
923 923
                 array(),
@@ -1047,7 +1047,7 @@  discard block
 block discarded – undo
1047 1047
      */
1048 1048
     protected function _default_venue_update(\EE_Event $evtobj, $data)
1049 1049
     {
1050
-        require_once(EE_MODELS . 'EEM_Venue.model.php');
1050
+        require_once(EE_MODELS.'EEM_Venue.model.php');
1051 1051
         $venue_model = EE_Registry::instance()->load_model('Venue');
1052 1052
         $rows_affected = null;
1053 1053
         $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null;
@@ -1171,7 +1171,7 @@  discard block
 block discarded – undo
1171 1171
             if (empty($tkt['TKT_start_date'])) {
1172 1172
                 //let's use now in the set timezone.
1173 1173
                 $now = new DateTime('now', new DateTimeZone($evtobj->get_timezone()));
1174
-                $tkt['TKT_start_date'] = $now->format($incoming_date_formats[0] . ' ' . $incoming_date_formats[1]);
1174
+                $tkt['TKT_start_date'] = $now->format($incoming_date_formats[0].' '.$incoming_date_formats[1]);
1175 1175
             }
1176 1176
             if (empty($tkt['TKT_end_date'])) {
1177 1177
                 //use the start date of the first datetime
@@ -1460,7 +1460,7 @@  discard block
 block discarded – undo
1460 1460
         $publish_box_extra_args['event_editor_overview_add'] = ob_get_clean();
1461 1461
         // load template
1462 1462
         EEH_Template::display_template(
1463
-            EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php',
1463
+            EVENTS_TEMPLATE_PATH.'event_publish_box_extras.template.php',
1464 1464
             $publish_box_extra_args
1465 1465
         );
1466 1466
     }
@@ -1587,7 +1587,7 @@  discard block
 block discarded – undo
1587 1587
         );
1588 1588
         $template = apply_filters(
1589 1589
             'FHEE__Events_Admin_Page__ticket_metabox__template',
1590
-            EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php'
1590
+            EVENTS_TEMPLATE_PATH.'event_tickets_metabox_main.template.php'
1591 1591
         );
1592 1592
         EEH_Template::display_template($template, $template_args);
1593 1593
     }
@@ -1606,7 +1606,7 @@  discard block
 block discarded – undo
1606 1606
     private function _get_ticket_row($ticket, $skeleton = false, $row = 0)
1607 1607
     {
1608 1608
         $template_args = array(
1609
-            'tkt_status_class'    => ' tkt-status-' . $ticket->ticket_status(),
1609
+            'tkt_status_class'    => ' tkt-status-'.$ticket->ticket_status(),
1610 1610
             'tkt_archive_class'   => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived'
1611 1611
                 : '',
1612 1612
             'ticketrow'           => $skeleton ? 'TICKETNUM' : $row,
@@ -1660,7 +1660,7 @@  discard block
 block discarded – undo
1660 1660
         $template_args = array_merge($template_args, $price_args);
1661 1661
         $template = apply_filters(
1662 1662
             'FHEE__Events_Admin_Page__get_ticket_row__template',
1663
-            EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php',
1663
+            EVENTS_TEMPLATE_PATH.'event_tickets_metabox_ticket_row.template.php',
1664 1664
             $ticket
1665 1665
         );
1666 1666
         return EEH_Template::display_template($template, $template_args, true);
@@ -1712,7 +1712,7 @@  discard block
 block discarded – undo
1712 1712
             $default_reg_status_values
1713 1713
         );
1714 1714
         EEH_Template::display_template(
1715
-            EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php',
1715
+            EVENTS_TEMPLATE_PATH.'event_registration_options.template.php',
1716 1716
             $template_args
1717 1717
         );
1718 1718
     }
@@ -1735,7 +1735,7 @@  discard block
 block discarded – undo
1735 1735
     {
1736 1736
         $EEME = $this->_event_model();
1737 1737
         $offset = ($current_page - 1) * $per_page;
1738
-        $limit = $count ? null : $offset . ',' . $per_page;
1738
+        $limit = $count ? null : $offset.','.$per_page;
1739 1739
         $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID';
1740 1740
         $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC";
1741 1741
         if (isset($this->_req_data['month_range'])) {
@@ -1769,7 +1769,7 @@  discard block
 block discarded – undo
1769 1769
         $start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start');
1770 1770
         if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') {
1771 1771
             $DateTime = new DateTime(
1772
-                $year_r . '-' . $month_r . '-01 00:00:00',
1772
+                $year_r.'-'.$month_r.'-01 00:00:00',
1773 1773
                 new DateTimeZone(EEM_Datetime::instance()->get_timezone())
1774 1774
             );
1775 1775
             $start = $DateTime->format(implode(' ', $start_formats));
@@ -1815,7 +1815,7 @@  discard block
 block discarded – undo
1815 1815
         }
1816 1816
         //search query handling
1817 1817
         if (isset($this->_req_data['s'])) {
1818
-            $search_string = '%' . $this->_req_data['s'] . '%';
1818
+            $search_string = '%'.$this->_req_data['s'].'%';
1819 1819
             $where['OR'] = array(
1820 1820
                 'EVT_name'       => array('LIKE', $search_string),
1821 1821
                 'EVT_desc'       => array('LIKE', $search_string),
@@ -1949,7 +1949,7 @@  discard block
 block discarded – undo
1949 1949
         if ( ! empty($event_status)) {
1950 1950
             $success = true;
1951 1951
             //determine the event id and set to array.
1952
-            $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array();
1952
+            $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array();
1953 1953
             // loop thru events
1954 1954
             foreach ($EVT_IDs as $EVT_ID) {
1955 1955
                 if ($EVT_ID = absint($EVT_ID)) {
@@ -2097,7 +2097,7 @@  discard block
 block discarded – undo
2097 2097
         // get list of events with no prices
2098 2098
         $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array());
2099 2099
         //determine the event id and set to array.
2100
-        $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array();
2100
+        $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array();
2101 2101
         // loop thru events
2102 2102
         foreach ($EVT_IDs as $EVT_ID) {
2103 2103
             $EVT_ID = absint($EVT_ID);
@@ -2280,7 +2280,7 @@  discard block
 block discarded – undo
2280 2280
         $this->_set_add_edit_form_tags('update_default_event_settings');
2281 2281
         $this->_set_publish_post_box_vars(null, false, false, null, false);
2282 2282
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2283
-            EVENTS_TEMPLATE_PATH . 'event_settings.template.php',
2283
+            EVENTS_TEMPLATE_PATH.'event_settings.template.php',
2284 2284
             $this->_template_args,
2285 2285
             true
2286 2286
         );
@@ -2325,10 +2325,10 @@  discard block
 block discarded – undo
2325 2325
                                                . 'caffeinated_template_features.jpg" alt="'
2326 2326
                                                . esc_attr__('Template Settings Preview screenshot', 'event_espresso')
2327 2327
                                                . '" />';
2328
-        $this->_template_args['preview_text'] = '<strong>' . esc_html__(
2328
+        $this->_template_args['preview_text'] = '<strong>'.esc_html__(
2329 2329
                 'Template Settings is a feature that is only available in the premium version of Event Espresso 4 which is available with a support license purchase on EventEspresso.com. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.',
2330 2330
                 'event_espresso'
2331
-            ) . '</strong>';
2331
+            ).'</strong>';
2332 2332
         $this->display_admin_caf_preview_page('template_settings_tab');
2333 2333
     }
2334 2334
 
@@ -2377,7 +2377,7 @@  discard block
 block discarded – undo
2377 2377
     {
2378 2378
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2379 2379
         $this->_search_btn_label = esc_html__('Categories', 'event_espresso');
2380
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
2380
+        $this->_admin_page_title .= ' '.$this->get_action_link_or_button(
2381 2381
                 'add_category',
2382 2382
                 'add_category',
2383 2383
                 array(),
@@ -2453,7 +2453,7 @@  discard block
 block discarded – undo
2453 2453
             'disable'                  => '',
2454 2454
             'disabled_message'         => false,
2455 2455
         );
2456
-        $template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php';
2456
+        $template = EVENTS_TEMPLATE_PATH.'event_category_details.template.php';
2457 2457
         return EEH_Template::display_template($template, $template_args, true);
2458 2458
     }
2459 2459
 
@@ -2461,8 +2461,8 @@  discard block
 block discarded – undo
2461 2461
 
2462 2462
     protected function _delete_categories()
2463 2463
     {
2464
-        $cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array)$this->_req_data['EVT_CAT_ID']
2465
-            : (array)$this->_req_data['category_id'];
2464
+        $cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array) $this->_req_data['EVT_CAT_ID']
2465
+            : (array) $this->_req_data['category_id'];
2466 2466
         foreach ($cat_ids as $cat_id) {
2467 2467
             $this->_delete_category($cat_id);
2468 2468
         }
@@ -2563,7 +2563,7 @@  discard block
 block discarded – undo
2563 2563
         $limit = ($current_page - 1) * $per_page;
2564 2564
         $where = array('taxonomy' => 'espresso_event_categories');
2565 2565
         if (isset($this->_req_data['s'])) {
2566
-            $sstr = '%' . $this->_req_data['s'] . '%';
2566
+            $sstr = '%'.$this->_req_data['s'].'%';
2567 2567
             $where['OR'] = array(
2568 2568
                 'Term.name'   => array('LIKE', $sstr),
2569 2569
                 'description' => array('LIKE', $sstr),
@@ -2572,7 +2572,7 @@  discard block
 block discarded – undo
2572 2572
         $query_params = array(
2573 2573
             $where,
2574 2574
             'order_by'   => array($orderby => $order),
2575
-            'limit'      => $limit . ',' . $per_page,
2575
+            'limit'      => $limit.','.$per_page,
2576 2576
             'force_join' => array('Term'),
2577 2577
         );
2578 2578
         $categories = $count
Please login to merge, or discard this patch.
core/EE_Config.core.php 3 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
      * @param    string         $name
492 492
      * @param    string         $config_class
493 493
      * @param    EE_Config_Base $config_obj
494
-     * @param    array          $tests_to_run
494
+     * @param    integer[]          $tests_to_run
495 495
      * @param    bool           $display_errors
496 496
      * @return    bool    TRUE on success, FALSE on fail
497 497
      */
@@ -1794,7 +1794,7 @@  discard block
 block discarded – undo
1794 1794
 
1795 1795
 
1796 1796
     /**
1797
-     * @return array
1797
+     * @return integer[]
1798 1798
      */
1799 1799
     public function get_critical_pages_array()
1800 1800
     {
@@ -1808,7 +1808,7 @@  discard block
 block discarded – undo
1808 1808
 
1809 1809
 
1810 1810
     /**
1811
-     * @return array
1811
+     * @return string[]
1812 1812
      */
1813 1813
     public function get_critical_pages_shortcodes_array()
1814 1814
     {
@@ -3088,7 +3088,7 @@  discard block
 block discarded – undo
3088 3088
      * according to max_input_vars
3089 3089
      *
3090 3090
      * @param int   $input_count the count of input vars.
3091
-     * @return array {
3091
+     * @return string {
3092 3092
      *                           An array that represents whether available space and if no available space the error
3093 3093
      *                           message.
3094 3094
      * @type bool   $has_space   whether more inputs can be added.
Please login to merge, or discard this patch.
Indentation   +3002 added lines, -3002 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if (! defined('EVENT_ESPRESSO_VERSION')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 
5 5
 
@@ -13,1566 +13,1566 @@  discard block
 block discarded – undo
13 13
 final class EE_Config
14 14
 {
15 15
 
16
-    const OPTION_NAME = 'ee_config';
17
-
18
-    const LOG_NAME = 'ee_config_log';
19
-
20
-    const LOG_LENGTH = 100;
21
-
22
-    const ADDON_OPTION_NAMES = 'ee_config_option_names';
23
-
24
-
25
-    /**
26
-     *    instance of the EE_Config object
27
-     *
28
-     * @var    EE_Config $_instance
29
-     * @access    private
30
-     */
31
-    private static $_instance;
32
-
33
-    /**
34
-     * @var boolean $_logging_enabled
35
-     */
36
-    private static $_logging_enabled = false;
37
-
38
-    /**
39
-     * An StdClass whose property names are addon slugs,
40
-     * and values are their config classes
41
-     *
42
-     * @var StdClass
43
-     */
44
-    public $addons;
45
-
46
-    /**
47
-     * @var EE_Admin_Config
48
-     */
49
-    public $admin;
50
-
51
-    /**
52
-     * @var EE_Core_Config
53
-     */
54
-    public $core;
55
-
56
-    /**
57
-     * @var EE_Currency_Config
58
-     */
59
-    public $currency;
60
-
61
-    /**
62
-     * @var EE_Organization_Config
63
-     */
64
-    public $organization;
65
-
66
-    /**
67
-     * @var EE_Registration_Config
68
-     */
69
-    public $registration;
70
-
71
-    /**
72
-     * @var EE_Template_Config
73
-     */
74
-    public $template_settings;
75
-
76
-    /**
77
-     * Holds EE environment values.
78
-     *
79
-     * @var EE_Environment_Config
80
-     */
81
-    public $environment;
82
-
83
-    /**
84
-     * settings pertaining to Google maps
85
-     *
86
-     * @var EE_Map_Config
87
-     */
88
-    public $map_settings;
89
-
90
-    /**
91
-     * settings pertaining to Taxes
92
-     *
93
-     * @var EE_Tax_Config
94
-     */
95
-    public $tax_settings;
96
-
97
-    /**
98
-     * @deprecated
99
-     * @var EE_Gateway_Config
100
-     */
101
-    public $gateway;
102
-
103
-    /**
104
-     * @var    array $_addon_option_names
105
-     * @access    private
106
-     */
107
-    private $_addon_option_names = array();
108
-
109
-    /**
110
-     * @var    array $_module_route_map
111
-     * @access    private
112
-     */
113
-    private static $_module_route_map = array();
114
-
115
-    /**
116
-     * @var    array $_module_forward_map
117
-     * @access    private
118
-     */
119
-    private static $_module_forward_map = array();
120
-
121
-    /**
122
-     * @var    array $_module_view_map
123
-     * @access    private
124
-     */
125
-    private static $_module_view_map = array();
126
-
127
-
128
-    /**
129
-     * @singleton method used to instantiate class object
130
-     * @access    public
131
-     * @return EE_Config instance
132
-     */
133
-    public static function instance()
134
-    {
135
-        // check if class object is instantiated, and instantiated properly
136
-        if (! self::$_instance instanceof EE_Config) {
137
-            self::$_instance = new self();
138
-        }
139
-        return self::$_instance;
140
-    }
141
-
142
-
143
-    /**
144
-     * Resets the config
145
-     *
146
-     * @param bool    $hard_reset    if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE
147
-     *                               (default) leaves the database alone, and merely resets the EE_Config object to
148
-     *                               reflect its state in the database
149
-     * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave
150
-     *                               $_instance as NULL. Useful in case you want to forget about the old instance on
151
-     *                               EE_Config, but might not be ready to instantiate EE_Config currently (eg if the
152
-     *                               site was put into maintenance mode)
153
-     * @return EE_Config
154
-     */
155
-    public static function reset($hard_reset = false, $reinstantiate = true)
156
-    {
157
-        if (self::$_instance instanceof EE_Config) {
158
-            if ($hard_reset) {
159
-                self::$_instance->_addon_option_names = array();
160
-                self::$_instance->_initialize_config();
161
-                self::$_instance->update_espresso_config();
162
-            }
163
-            self::$_instance->update_addon_option_names();
164
-        }
165
-        self::$_instance = null;
166
-        //we don't need to reset the static properties imo because those should
167
-        //only change when a module is added or removed. Currently we don't
168
-        //support removing a module during a request when it previously existed
169
-        if ($reinstantiate) {
170
-            return self::instance();
171
-        } else {
172
-            return null;
173
-        }
174
-    }
175
-
176
-
177
-    /**
178
-     *    class constructor
179
-     *
180
-     * @access    private
181
-     */
182
-    private function __construct()
183
-    {
184
-        do_action('AHEE__EE_Config__construct__begin', $this);
185
-        EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false);
186
-        // setup empty config classes
187
-        $this->_initialize_config();
188
-        // load existing EE site settings
189
-        $this->_load_core_config();
190
-        // confirm everything loaded correctly and set filtered defaults if not
191
-        $this->_verify_config();
192
-        //  register shortcodes and modules
193
-        add_action(
194
-            'AHEE__EE_System__register_shortcodes_modules_and_widgets',
195
-            array($this, 'register_shortcodes_and_modules'),
196
-            999
197
-        );
198
-        //  initialize shortcodes and modules
199
-        add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules'));
200
-        // register widgets
201
-        add_action('widgets_init', array($this, 'widgets_init'), 10);
202
-        // shutdown
203
-        add_action('shutdown', array($this, 'shutdown'), 10);
204
-        // construct__end hook
205
-        do_action('AHEE__EE_Config__construct__end', $this);
206
-        // hardcoded hack
207
-        $this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014';
208
-    }
209
-
210
-
211
-    /**
212
-     * @return boolean
213
-     */
214
-    public static function logging_enabled()
215
-    {
216
-        return self::$_logging_enabled;
217
-    }
218
-
219
-
220
-    /**
221
-     * use to get the current theme if needed from static context
222
-     *
223
-     * @return string current theme set.
224
-     */
225
-    public static function get_current_theme()
226
-    {
227
-        return isset(self::$_instance->template_settings->current_espresso_theme)
228
-            ? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014';
229
-    }
230
-
231
-
232
-    /**
233
-     *        _initialize_config
234
-     *
235
-     * @access private
236
-     * @return void
237
-     */
238
-    private function _initialize_config()
239
-    {
240
-        EE_Config::trim_log();
241
-        //set defaults
242
-        $this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array());
243
-        $this->addons              = new stdClass();
244
-        // set _module_route_map
245
-        EE_Config::$_module_route_map = array();
246
-        // set _module_forward_map
247
-        EE_Config::$_module_forward_map = array();
248
-        // set _module_view_map
249
-        EE_Config::$_module_view_map = array();
250
-    }
251
-
252
-
253
-    /**
254
-     *        load core plugin configuration
255
-     *
256
-     * @access private
257
-     * @return void
258
-     */
259
-    private function _load_core_config()
260
-    {
261
-        // load_core_config__start hook
262
-        do_action('AHEE__EE_Config___load_core_config__start', $this);
263
-        $espresso_config = $this->get_espresso_config();
264
-        foreach ($espresso_config as $config => $settings) {
265
-            // load_core_config__start hook
266
-            $settings = apply_filters(
267
-                'FHEE__EE_Config___load_core_config__config_settings',
268
-                $settings,
269
-                $config,
270
-                $this
271
-            );
272
-            if (is_object($settings) && property_exists($this, $config)) {
273
-                $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings);
274
-                //call configs populate method to ensure any defaults are set for empty values.
275
-                if (method_exists($settings, 'populate')) {
276
-                    $this->{$config}->populate();
277
-                }
278
-                if (method_exists($settings, 'do_hooks')) {
279
-                    $this->{$config}->do_hooks();
280
-                }
281
-            }
282
-        }
283
-        if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) {
284
-            $this->update_espresso_config();
285
-        }
286
-        // load_core_config__end hook
287
-        do_action('AHEE__EE_Config___load_core_config__end', $this);
288
-    }
289
-
290
-
291
-    /**
292
-     *    _verify_config
293
-     *
294
-     * @access    protected
295
-     * @return    void
296
-     */
297
-    protected function _verify_config()
298
-    {
299
-        $this->core              = $this->core instanceof EE_Core_Config
300
-            ? $this->core
301
-            : new EE_Core_Config();
302
-        $this->core              = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core);
303
-        $this->organization      = $this->organization instanceof EE_Organization_Config
304
-            ? $this->organization
305
-            : new EE_Organization_Config();
306
-        $this->organization      = apply_filters('FHEE__EE_Config___initialize_config__organization',
307
-            $this->organization);
308
-        $this->currency          = $this->currency instanceof EE_Currency_Config
309
-            ? $this->currency
310
-            : new EE_Currency_Config();
311
-        $this->currency          = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency);
312
-        $this->registration      = $this->registration instanceof EE_Registration_Config
313
-            ? $this->registration
314
-            : new EE_Registration_Config();
315
-        $this->registration      = apply_filters('FHEE__EE_Config___initialize_config__registration',
316
-            $this->registration);
317
-        $this->admin             = $this->admin instanceof EE_Admin_Config
318
-            ? $this->admin
319
-            : new EE_Admin_Config();
320
-        $this->admin             = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin);
321
-        $this->template_settings = $this->template_settings instanceof EE_Template_Config
322
-            ? $this->template_settings
323
-            : new EE_Template_Config();
324
-        $this->template_settings = apply_filters(
325
-            'FHEE__EE_Config___initialize_config__template_settings',
326
-            $this->template_settings
327
-        );
328
-        $this->map_settings      = $this->map_settings instanceof EE_Map_Config
329
-            ? $this->map_settings
330
-            : new EE_Map_Config();
331
-        $this->map_settings      = apply_filters('FHEE__EE_Config___initialize_config__map_settings',
332
-            $this->map_settings);
333
-        $this->environment       = $this->environment instanceof EE_Environment_Config
334
-            ? $this->environment
335
-            : new EE_Environment_Config();
336
-        $this->environment       = apply_filters('FHEE__EE_Config___initialize_config__environment',
337
-            $this->environment);
338
-        $this->tax_settings      = $this->tax_settings instanceof EE_Tax_Config
339
-            ? $this->tax_settings
340
-            : new EE_Tax_Config();
341
-        $this->tax_settings      = apply_filters('FHEE__EE_Config___initialize_config__tax_settings',
342
-            $this->tax_settings);
343
-        $this->gateway           = $this->gateway instanceof EE_Gateway_Config
344
-            ? $this->gateway
345
-            : new EE_Gateway_Config();
346
-        $this->gateway           = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway);
347
-    }
348
-
349
-
350
-    /**
351
-     *    get_espresso_config
352
-     *
353
-     * @access    public
354
-     * @return    array of espresso config stuff
355
-     */
356
-    public function get_espresso_config()
357
-    {
358
-        // grab espresso configuration
359
-        return apply_filters(
360
-            'FHEE__EE_Config__get_espresso_config__CFG',
361
-            get_option(EE_Config::OPTION_NAME, array())
362
-        );
363
-    }
364
-
365
-
366
-    /**
367
-     *    double_check_config_comparison
368
-     *
369
-     * @access    public
370
-     * @param string $option
371
-     * @param        $old_value
372
-     * @param        $value
373
-     */
374
-    public function double_check_config_comparison($option = '', $old_value, $value)
375
-    {
376
-        // make sure we're checking the ee config
377
-        if ($option === EE_Config::OPTION_NAME) {
378
-            // run a loose comparison of the old value against the new value for type and properties,
379
-            // but NOT exact instance like WP update_option does (ie: NOT type safe comparison)
380
-            if ($value != $old_value) {
381
-                // if they are NOT the same, then remove the hook,
382
-                // which means the subsequent update results will be based solely on the update query results
383
-                // the reason we do this is because, as stated above,
384
-                // WP update_option performs an exact instance comparison (===) on any update values passed to it
385
-                // this happens PRIOR to serialization and any subsequent update.
386
-                // If values are found to match their previous old value,
387
-                // then WP bails before performing any update.
388
-                // Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version
389
-                // it just pulled from the db, with the one being passed to it (which will not match).
390
-                // HOWEVER, once the object is serialized and passed off to MySQL to update,
391
-                // MySQL MAY ALSO NOT perform the update because
392
-                // the string it sees in the db looks the same as the new one it has been passed!!!
393
-                // This results in the query returning an "affected rows" value of ZERO,
394
-                // which gets returned immediately by WP update_option and looks like an error.
395
-                remove_action('update_option', array($this, 'check_config_updated'));
396
-            }
397
-        }
398
-    }
399
-
400
-
401
-    /**
402
-     *    update_espresso_config
403
-     *
404
-     * @access   public
405
-     */
406
-    protected function _reset_espresso_addon_config()
407
-    {
408
-        $this->_addon_option_names = array();
409
-        foreach ($this->addons as $addon_name => $addon_config_obj) {
410
-            $addon_config_obj = maybe_unserialize($addon_config_obj);
411
-            $config_class     = get_class($addon_config_obj);
412
-            if ($addon_config_obj instanceof $config_class && ! $addon_config_obj instanceof __PHP_Incomplete_Class) {
413
-                $this->update_config('addons', $addon_name, $addon_config_obj, false);
414
-            }
415
-            $this->addons->{$addon_name} = null;
416
-        }
417
-    }
418
-
419
-
420
-    /**
421
-     *    update_espresso_config
422
-     *
423
-     * @access   public
424
-     * @param   bool $add_success
425
-     * @param   bool $add_error
426
-     * @return   bool
427
-     */
428
-    public function update_espresso_config($add_success = false, $add_error = true)
429
-    {
430
-        // don't allow config updates during WP heartbeats
431
-        if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
432
-            return false;
433
-        }
434
-        // commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197
435
-        //$clone = clone( self::$_instance );
436
-        //self::$_instance = NULL;
437
-        do_action('AHEE__EE_Config__update_espresso_config__begin', $this);
438
-        $this->_reset_espresso_addon_config();
439
-        // hook into update_option because that happens AFTER the ( $value === $old_value ) conditional
440
-        // but BEFORE the actual update occurs
441
-        add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3);
442
-        // now update "ee_config"
443
-        $saved = update_option(EE_Config::OPTION_NAME, $this);
444
-        EE_Config::log(EE_Config::OPTION_NAME);
445
-        // if not saved... check if the hook we just added still exists;
446
-        // if it does, it means one of two things:
447
-        // 		that update_option bailed at the ( $value === $old_value ) conditional,
448
-        //		 or...
449
-        // 		the db update query returned 0 rows affected
450
-        // 		(probably because the data  value was the same from it's perspective)
451
-        // so the existence of the hook means that a negative result from update_option is NOT an error,
452
-        // but just means no update occurred, so don't display an error to the user.
453
-        // BUT... if update_option returns FALSE, AND the hook is missing,
454
-        // then it means that something truly went wrong
455
-        $saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved;
456
-        // remove our action since we don't want it in the system anymore
457
-        remove_action('update_option', array($this, 'double_check_config_comparison'), 1);
458
-        do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved);
459
-        //self::$_instance = $clone;
460
-        //unset( $clone );
461
-        // if config remains the same or was updated successfully
462
-        if ($saved) {
463
-            if ($add_success) {
464
-                EE_Error::add_success(
465
-                    __('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'),
466
-                    __FILE__,
467
-                    __FUNCTION__,
468
-                    __LINE__
469
-                );
470
-            }
471
-            return true;
472
-        } else {
473
-            if ($add_error) {
474
-                EE_Error::add_error(
475
-                    __('The Event Espresso Configuration Settings were not updated.', 'event_espresso'),
476
-                    __FILE__,
477
-                    __FUNCTION__,
478
-                    __LINE__
479
-                );
480
-            }
481
-            return false;
482
-        }
483
-    }
484
-
485
-
486
-    /**
487
-     *    _verify_config_params
488
-     *
489
-     * @access    private
490
-     * @param    string         $section
491
-     * @param    string         $name
492
-     * @param    string         $config_class
493
-     * @param    EE_Config_Base $config_obj
494
-     * @param    array          $tests_to_run
495
-     * @param    bool           $display_errors
496
-     * @return    bool    TRUE on success, FALSE on fail
497
-     */
498
-    private function _verify_config_params(
499
-        $section = '',
500
-        $name = '',
501
-        $config_class = '',
502
-        $config_obj = null,
503
-        $tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8),
504
-        $display_errors = true
505
-    ) {
506
-        try {
507
-            foreach ($tests_to_run as $test) {
508
-                switch ($test) {
509
-                    // TEST #1 : check that section was set
510
-                    case 1 :
511
-                        if (empty($section)) {
512
-                            if ($display_errors) {
513
-                                throw new EE_Error(
514
-                                    sprintf(
515
-                                        __(
516
-                                            'No configuration section has been provided while attempting to save "%s".',
517
-                                            'event_espresso'
518
-                                        ),
519
-                                        $config_class
520
-                                    )
521
-                                );
522
-                            }
523
-                            return false;
524
-                        }
525
-                        break;
526
-                    // TEST #2 : check that settings section exists
527
-                    case 2 :
528
-                        if (! isset($this->{$section})) {
529
-                            if ($display_errors) {
530
-                                throw new EE_Error(
531
-                                    sprintf(
532
-                                        __('The "%s" configuration section does not exist.', 'event_espresso'),
533
-                                        $section
534
-                                    )
535
-                                );
536
-                            }
537
-                            return false;
538
-                        }
539
-                        break;
540
-                    // TEST #3 : check that section is the proper format
541
-                    case 3 :
542
-                        if (
543
-                        ! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass)
544
-                        ) {
545
-                            if ($display_errors) {
546
-                                throw new EE_Error(
547
-                                    sprintf(
548
-                                        __(
549
-                                            'The "%s" configuration settings have not been formatted correctly.',
550
-                                            'event_espresso'
551
-                                        ),
552
-                                        $section
553
-                                    )
554
-                                );
555
-                            }
556
-                            return false;
557
-                        }
558
-                        break;
559
-                    // TEST #4 : check that config section name has been set
560
-                    case 4 :
561
-                        if (empty($name)) {
562
-                            if ($display_errors) {
563
-                                throw new EE_Error(
564
-                                    __(
565
-                                        'No name has been provided for the specific configuration section.',
566
-                                        'event_espresso'
567
-                                    )
568
-                                );
569
-                            }
570
-                            return false;
571
-                        }
572
-                        break;
573
-                    // TEST #5 : check that a config class name has been set
574
-                    case 5 :
575
-                        if (empty($config_class)) {
576
-                            if ($display_errors) {
577
-                                throw new EE_Error(
578
-                                    __(
579
-                                        'No class name has been provided for the specific configuration section.',
580
-                                        'event_espresso'
581
-                                    )
582
-                                );
583
-                            }
584
-                            return false;
585
-                        }
586
-                        break;
587
-                    // TEST #6 : verify config class is accessible
588
-                    case 6 :
589
-                        if (! class_exists($config_class)) {
590
-                            if ($display_errors) {
591
-                                throw new EE_Error(
592
-                                    sprintf(
593
-                                        __(
594
-                                            'The "%s" class does not exist. Please ensure that an autoloader has been set for it.',
595
-                                            'event_espresso'
596
-                                        ),
597
-                                        $config_class
598
-                                    )
599
-                                );
600
-                            }
601
-                            return false;
602
-                        }
603
-                        break;
604
-                    // TEST #7 : check that config has even been set
605
-                    case 7 :
606
-                        if (! isset($this->{$section}->{$name})) {
607
-                            if ($display_errors) {
608
-                                throw new EE_Error(
609
-                                    sprintf(
610
-                                        __('No configuration has been set for "%1$s->%2$s".', 'event_espresso'),
611
-                                        $section,
612
-                                        $name
613
-                                    )
614
-                                );
615
-                            }
616
-                            return false;
617
-                        } else {
618
-                            // and make sure it's not serialized
619
-                            $this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name});
620
-                        }
621
-                        break;
622
-                    // TEST #8 : check that config is the requested type
623
-                    case 8 :
624
-                        if (! $this->{$section}->{$name} instanceof $config_class) {
625
-                            if ($display_errors) {
626
-                                throw new EE_Error(
627
-                                    sprintf(
628
-                                        __(
629
-                                            'The configuration for "%1$s->%2$s" is not of the "%3$s" class.',
630
-                                            'event_espresso'
631
-                                        ),
632
-                                        $section,
633
-                                        $name,
634
-                                        $config_class
635
-                                    )
636
-                                );
637
-                            }
638
-                            return false;
639
-                        }
640
-                        break;
641
-                    // TEST #9 : verify config object
642
-                    case 9 :
643
-                        if (! $config_obj instanceof EE_Config_Base) {
644
-                            if ($display_errors) {
645
-                                throw new EE_Error(
646
-                                    sprintf(
647
-                                        __('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'),
648
-                                        print_r($config_obj, true)
649
-                                    )
650
-                                );
651
-                            }
652
-                            return false;
653
-                        }
654
-                        break;
655
-                }
656
-            }
657
-        } catch (EE_Error $e) {
658
-            $e->get_error();
659
-        }
660
-        // you have successfully run the gauntlet
661
-        return true;
662
-    }
663
-
664
-
665
-    /**
666
-     *    _generate_config_option_name
667
-     *
668
-     * @access        protected
669
-     * @param        string $section
670
-     * @param        string $name
671
-     * @return        string
672
-     */
673
-    private function _generate_config_option_name($section = '', $name = '')
674
-    {
675
-        return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name));
676
-    }
677
-
678
-
679
-    /**
680
-     *    _set_config_class
681
-     * ensures that a config class is set, either from a passed config class or one generated from the config name
682
-     *
683
-     * @access    private
684
-     * @param    string $config_class
685
-     * @param    string $name
686
-     * @return    string
687
-     */
688
-    private function _set_config_class($config_class = '', $name = '')
689
-    {
690
-        return ! empty($config_class)
691
-            ? $config_class
692
-            : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config';
693
-    }
694
-
695
-
696
-    /**
697
-     *    set_config
698
-     *
699
-     * @access    protected
700
-     * @param    string         $section
701
-     * @param    string         $name
702
-     * @param    string         $config_class
703
-     * @param    EE_Config_Base $config_obj
704
-     * @return    EE_Config_Base
705
-     */
706
-    public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null)
707
-    {
708
-        // ensure config class is set to something
709
-        $config_class = $this->_set_config_class($config_class, $name);
710
-        // run tests 1-4, 6, and 7 to verify all config params are set and valid
711
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
712
-            return null;
713
-        }
714
-        $config_option_name = $this->_generate_config_option_name($section, $name);
715
-        // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now
716
-        if (! isset($this->_addon_option_names[$config_option_name])) {
717
-            $this->_addon_option_names[$config_option_name] = $config_class;
718
-            $this->update_addon_option_names();
719
-        }
720
-        // verify the incoming config object but suppress errors
721
-        if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
722
-            $config_obj = new $config_class();
723
-        }
724
-        if (get_option($config_option_name)) {
725
-            EE_Config::log($config_option_name);
726
-            update_option($config_option_name, $config_obj);
727
-            $this->{$section}->{$name} = $config_obj;
728
-            return $this->{$section}->{$name};
729
-        } else {
730
-            // create a wp-option for this config
731
-            if (add_option($config_option_name, $config_obj, '', 'no')) {
732
-                $this->{$section}->{$name} = maybe_unserialize($config_obj);
733
-                return $this->{$section}->{$name};
734
-            } else {
735
-                EE_Error::add_error(
736
-                    sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class),
737
-                    __FILE__,
738
-                    __FUNCTION__,
739
-                    __LINE__
740
-                );
741
-                return null;
742
-            }
743
-        }
744
-    }
745
-
746
-
747
-    /**
748
-     *    update_config
749
-     * Important: the config object must ALREADY be set, otherwise this will produce an error.
750
-     *
751
-     * @access    public
752
-     * @param    string                $section
753
-     * @param    string                $name
754
-     * @param    EE_Config_Base|string $config_obj
755
-     * @param    bool                  $throw_errors
756
-     * @return    bool
757
-     */
758
-    public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true)
759
-    {
760
-        // don't allow config updates during WP heartbeats
761
-        if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
762
-            return false;
763
-        }
764
-        $config_obj = maybe_unserialize($config_obj);
765
-        // get class name of the incoming object
766
-        $config_class = get_class($config_obj);
767
-        // run tests 1-5 and 9 to verify config
768
-        if (! $this->_verify_config_params(
769
-            $section,
770
-            $name,
771
-            $config_class,
772
-            $config_obj,
773
-            array(1, 2, 3, 4, 7, 9)
774
-        )
775
-        ) {
776
-            return false;
777
-        }
778
-        $config_option_name = $this->_generate_config_option_name($section, $name);
779
-        // check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
780
-        if (! isset($this->_addon_option_names[$config_option_name])) {
781
-            // save new config to db
782
-            if ($this->set_config($section, $name, $config_class, $config_obj)) {
783
-                return true;
784
-            }
785
-        } else {
786
-            // first check if the record already exists
787
-            $existing_config = get_option($config_option_name);
788
-            $config_obj      = serialize($config_obj);
789
-            // just return if db record is already up to date (NOT type safe comparison)
790
-            if ($existing_config == $config_obj) {
791
-                $this->{$section}->{$name} = $config_obj;
792
-                return true;
793
-            } else if (update_option($config_option_name, $config_obj)) {
794
-                EE_Config::log($config_option_name);
795
-                // update wp-option for this config class
796
-                $this->{$section}->{$name} = $config_obj;
797
-                return true;
798
-            } elseif ($throw_errors) {
799
-                EE_Error::add_error(
800
-                    sprintf(
801
-                        __(
802
-                            'The "%1$s" object stored at"%2$s" was not successfully updated in the database.',
803
-                            'event_espresso'
804
-                        ),
805
-                        $config_class,
806
-                        'EE_Config->' . $section . '->' . $name
807
-                    ),
808
-                    __FILE__,
809
-                    __FUNCTION__,
810
-                    __LINE__
811
-                );
812
-            }
813
-        }
814
-        return false;
815
-    }
816
-
817
-
818
-    /**
819
-     *    get_config
820
-     *
821
-     * @access    public
822
-     * @param    string $section
823
-     * @param    string $name
824
-     * @param    string $config_class
825
-     * @return    mixed EE_Config_Base | NULL
826
-     */
827
-    public function get_config($section = '', $name = '', $config_class = '')
828
-    {
829
-        // ensure config class is set to something
830
-        $config_class = $this->_set_config_class($config_class, $name);
831
-        // run tests 1-4, 6 and 7 to verify that all params have been set
832
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
833
-            return null;
834
-        }
835
-        // now test if the requested config object exists, but suppress errors
836
-        if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) {
837
-            // config already exists, so pass it back
838
-            return $this->{$section}->{$name};
839
-        }
840
-        // load config option from db if it exists
841
-        $config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name));
842
-        // verify the newly retrieved config object, but suppress errors
843
-        if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
844
-            // config is good, so set it and pass it back
845
-            $this->{$section}->{$name} = $config_obj;
846
-            return $this->{$section}->{$name};
847
-        }
848
-        // oops! $config_obj is not already set and does not exist in the db, so create a new one
849
-        $config_obj = $this->set_config($section, $name, $config_class);
850
-        // verify the newly created config object
851
-        if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) {
852
-            return $this->{$section}->{$name};
853
-        } else {
854
-            EE_Error::add_error(
855
-                sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class),
856
-                __FILE__,
857
-                __FUNCTION__,
858
-                __LINE__
859
-            );
860
-        }
861
-        return null;
862
-    }
863
-
864
-
865
-    /**
866
-     *    get_config_option
867
-     *
868
-     * @access    public
869
-     * @param    string $config_option_name
870
-     * @return    mixed EE_Config_Base | FALSE
871
-     */
872
-    public function get_config_option($config_option_name = '')
873
-    {
874
-        // retrieve the wp-option for this config class.
875
-        $config_option = maybe_unserialize(get_option($config_option_name, array()));
876
-        if (empty($config_option)) {
877
-            EE_Config::log($config_option_name . '-NOT-FOUND');
878
-        }
879
-        return $config_option;
880
-    }
881
-
882
-
883
-    /**
884
-     * log
885
-     *
886
-     * @param string $config_option_name
887
-     */
888
-    public static function log($config_option_name = '')
889
-    {
890
-        if (EE_Config::logging_enabled() && ! empty($config_option_name)) {
891
-            $config_log = get_option(EE_Config::LOG_NAME, array());
892
-            //copy incoming $_REQUEST and sanitize it so we can save it
893
-            $_request = $_REQUEST;
894
-            array_walk_recursive($_request, 'sanitize_text_field');
895
-            $config_log[(string)microtime(true)] = array(
896
-                'config_name' => $config_option_name,
897
-                'request'     => $_request,
898
-            );
899
-            update_option(EE_Config::LOG_NAME, $config_log);
900
-        }
901
-    }
902
-
903
-
904
-    /**
905
-     * trim_log
906
-     * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH
907
-     */
908
-    public static function trim_log()
909
-    {
910
-        if (! EE_Config::logging_enabled()) {
911
-            return;
912
-        }
913
-        $config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
914
-        $log_length = count($config_log);
915
-        if ($log_length > EE_Config::LOG_LENGTH) {
916
-            ksort($config_log);
917
-            $config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true);
918
-            update_option(EE_Config::LOG_NAME, $config_log);
919
-        }
920
-    }
921
-
922
-
923
-    /**
924
-     *    get_page_for_posts
925
-     *    if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the
926
-     *    wp-option "page_for_posts", or "posts" if no page is selected
927
-     *
928
-     * @access    public
929
-     * @return    string
930
-     */
931
-    public static function get_page_for_posts()
932
-    {
933
-        $page_for_posts = get_option('page_for_posts');
934
-        if (! $page_for_posts) {
935
-            return 'posts';
936
-        }
937
-        /** @type WPDB $wpdb */
938
-        global $wpdb;
939
-        $SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d";
940
-        return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts));
941
-    }
942
-
943
-
944
-    /**
945
-     *    register_shortcodes_and_modules.
946
-     *    At this point, it's too early to tell if we're maintenance mode or not.
947
-     *    In fact, this is where we give modules a chance to let core know they exist
948
-     *    so they can help trigger maintenance mode if it's needed
949
-     *
950
-     * @access    public
951
-     * @return    void
952
-     */
953
-    public function register_shortcodes_and_modules()
954
-    {
955
-        // allow shortcodes to register with WP and to set hooks for the rest of the system
956
-        EE_Registry::instance()->shortcodes = $this->_register_shortcodes();
957
-        // allow modules to set hooks for the rest of the system
958
-        EE_Registry::instance()->modules = $this->_register_modules();
959
-    }
960
-
961
-
962
-    /**
963
-     *    initialize_shortcodes_and_modules
964
-     *    meaning they can start adding their hooks to get stuff done
965
-     *
966
-     * @access    public
967
-     * @return    void
968
-     */
969
-    public function initialize_shortcodes_and_modules()
970
-    {
971
-        // allow shortcodes to set hooks for the rest of the system
972
-        $this->_initialize_shortcodes();
973
-        // allow modules to set hooks for the rest of the system
974
-        $this->_initialize_modules();
975
-    }
976
-
977
-
978
-    /**
979
-     *    widgets_init
980
-     *
981
-     * @access private
982
-     * @return void
983
-     */
984
-    public function widgets_init()
985
-    {
986
-        //only init widgets on admin pages when not in complete maintenance, and
987
-        //on frontend when not in any maintenance mode
988
-        if (
989
-            ! EE_Maintenance_Mode::instance()->level()
990
-            || (
991
-                is_admin()
992
-                && EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance
993
-            )
994
-        ) {
995
-            // grab list of installed widgets
996
-            $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
997
-            // filter list of modules to register
998
-            $widgets_to_register = apply_filters(
999
-                'FHEE__EE_Config__register_widgets__widgets_to_register',
1000
-                $widgets_to_register
1001
-            );
1002
-            if (! empty($widgets_to_register)) {
1003
-                // cycle thru widget folders
1004
-                foreach ($widgets_to_register as $widget_path) {
1005
-                    // add to list of installed widget modules
1006
-                    EE_Config::register_ee_widget($widget_path);
1007
-                }
1008
-            }
1009
-            // filter list of installed modules
1010
-            EE_Registry::instance()->widgets = apply_filters(
1011
-                'FHEE__EE_Config__register_widgets__installed_widgets',
1012
-                EE_Registry::instance()->widgets
1013
-            );
1014
-        }
1015
-    }
1016
-
1017
-
1018
-    /**
1019
-     *    register_ee_widget - makes core aware of this widget
1020
-     *
1021
-     * @access    public
1022
-     * @param    string $widget_path - full path up to and including widget folder
1023
-     * @return    void
1024
-     */
1025
-    public static function register_ee_widget($widget_path = null)
1026
-    {
1027
-        do_action('AHEE__EE_Config__register_widget__begin', $widget_path);
1028
-        $widget_ext = '.widget.php';
1029
-        // make all separators match
1030
-        $widget_path = rtrim(str_replace('/\\', DS, $widget_path), DS);
1031
-        // does the file path INCLUDE the actual file name as part of the path ?
1032
-        if (strpos($widget_path, $widget_ext) !== false) {
1033
-            // grab and shortcode file name from directory name and break apart at dots
1034
-            $file_name = explode('.', basename($widget_path));
1035
-            // take first segment from file name pieces and remove class prefix if it exists
1036
-            $widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0];
1037
-            // sanitize shortcode directory name
1038
-            $widget = sanitize_key($widget);
1039
-            // now we need to rebuild the shortcode path
1040
-            $widget_path = explode(DS, $widget_path);
1041
-            // remove last segment
1042
-            array_pop($widget_path);
1043
-            // glue it back together
1044
-            $widget_path = implode(DS, $widget_path);
1045
-        } else {
1046
-            // grab and sanitize widget directory name
1047
-            $widget = sanitize_key(basename($widget_path));
1048
-        }
1049
-        // create classname from widget directory name
1050
-        $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1051
-        // add class prefix
1052
-        $widget_class = 'EEW_' . $widget;
1053
-        // does the widget exist ?
1054
-        if (! is_readable($widget_path . DS . $widget_class . $widget_ext)) {
1055
-            $msg = sprintf(
1056
-                __(
1057
-                    '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',
1058
-                    'event_espresso'
1059
-                ),
1060
-                $widget_class,
1061
-                $widget_path . DS . $widget_class . $widget_ext
1062
-            );
1063
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1064
-            return;
1065
-        }
1066
-        // load the widget class file
1067
-        require_once($widget_path . DS . $widget_class . $widget_ext);
1068
-        // verify that class exists
1069
-        if (! class_exists($widget_class)) {
1070
-            $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1071
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1072
-            return;
1073
-        }
1074
-        register_widget($widget_class);
1075
-        // add to array of registered widgets
1076
-        EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext;
1077
-    }
1078
-
1079
-
1080
-    /**
1081
-     *        _register_shortcodes
1082
-     *
1083
-     * @access private
1084
-     * @return array
1085
-     */
1086
-    private function _register_shortcodes()
1087
-    {
1088
-        // grab list of installed shortcodes
1089
-        $shortcodes_to_register = glob(EE_SHORTCODES . '*', GLOB_ONLYDIR);
1090
-        // filter list of modules to register
1091
-        $shortcodes_to_register = apply_filters(
1092
-            'FHEE__EE_Config__register_shortcodes__shortcodes_to_register',
1093
-            $shortcodes_to_register
1094
-        );
1095
-        if (! empty($shortcodes_to_register)) {
1096
-            // cycle thru shortcode folders
1097
-            foreach ($shortcodes_to_register as $shortcode_path) {
1098
-                // add to list of installed shortcode modules
1099
-                EE_Config::register_shortcode($shortcode_path);
1100
-            }
1101
-        }
1102
-        // filter list of installed modules
1103
-        return apply_filters(
1104
-            'FHEE__EE_Config___register_shortcodes__installed_shortcodes',
1105
-            EE_Registry::instance()->shortcodes
1106
-        );
1107
-    }
1108
-
1109
-
1110
-    /**
1111
-     *    register_shortcode - makes core aware of this shortcode
1112
-     *
1113
-     * @access    public
1114
-     * @param    string $shortcode_path - full path up to and including shortcode folder
1115
-     * @return    bool
1116
-     */
1117
-    public static function register_shortcode($shortcode_path = null)
1118
-    {
1119
-        do_action('AHEE__EE_Config__register_shortcode__begin', $shortcode_path);
1120
-        $shortcode_ext = '.shortcode.php';
1121
-        // make all separators match
1122
-        $shortcode_path = str_replace(array('\\', '/'), DS, $shortcode_path);
1123
-        // does the file path INCLUDE the actual file name as part of the path ?
1124
-        if (strpos($shortcode_path, $shortcode_ext) !== false) {
1125
-            // grab shortcode file name from directory name and break apart at dots
1126
-            $shortcode_file = explode('.', basename($shortcode_path));
1127
-            // take first segment from file name pieces and remove class prefix if it exists
1128
-            $shortcode = strpos($shortcode_file[0], 'EES_') === 0
1129
-                ? substr($shortcode_file[0], 4)
1130
-                : $shortcode_file[0];
1131
-            // sanitize shortcode directory name
1132
-            $shortcode = sanitize_key($shortcode);
1133
-            // now we need to rebuild the shortcode path
1134
-            $shortcode_path = explode(DS, $shortcode_path);
1135
-            // remove last segment
1136
-            array_pop($shortcode_path);
1137
-            // glue it back together
1138
-            $shortcode_path = implode(DS, $shortcode_path) . DS;
1139
-        } else {
1140
-            // we need to generate the filename based off of the folder name
1141
-            // grab and sanitize shortcode directory name
1142
-            $shortcode      = sanitize_key(basename($shortcode_path));
1143
-            $shortcode_path = rtrim($shortcode_path, DS) . DS;
1144
-        }
1145
-        // create classname from shortcode directory or file name
1146
-        $shortcode = str_replace(' ', '_', ucwords(str_replace('_', ' ', $shortcode)));
1147
-        // add class prefix
1148
-        $shortcode_class = 'EES_' . $shortcode;
1149
-        // does the shortcode exist ?
1150
-        if (! is_readable($shortcode_path . DS . $shortcode_class . $shortcode_ext)) {
1151
-            $msg = sprintf(
1152
-                __(
1153
-                    'The requested %s shortcode file could not be found or is not readable due to file permissions. It should be in %s',
1154
-                    'event_espresso'
1155
-                ),
1156
-                $shortcode_class,
1157
-                $shortcode_path . DS . $shortcode_class . $shortcode_ext
1158
-            );
1159
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1160
-            return false;
1161
-        }
1162
-        // load the shortcode class file
1163
-        require_once($shortcode_path . $shortcode_class . $shortcode_ext);
1164
-        // verify that class exists
1165
-        if (! class_exists($shortcode_class)) {
1166
-            $msg = sprintf(
1167
-                __('The requested %s shortcode class does not exist.', 'event_espresso'),
1168
-                $shortcode_class
1169
-            );
1170
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1171
-            return false;
1172
-        }
1173
-        $shortcode = strtoupper($shortcode);
1174
-        // add to array of registered shortcodes
1175
-        EE_Registry::instance()->shortcodes->{$shortcode} = $shortcode_path . $shortcode_class . $shortcode_ext;
1176
-        return true;
1177
-    }
1178
-
1179
-
1180
-    /**
1181
-     *        _register_modules
1182
-     *
1183
-     * @access private
1184
-     * @return array
1185
-     */
1186
-    private function _register_modules()
1187
-    {
1188
-        // grab list of installed modules
1189
-        $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1190
-        // filter list of modules to register
1191
-        $modules_to_register = apply_filters(
1192
-            'FHEE__EE_Config__register_modules__modules_to_register',
1193
-            $modules_to_register
1194
-        );
1195
-        if (! empty($modules_to_register)) {
1196
-            // loop through folders
1197
-            foreach ($modules_to_register as $module_path) {
1198
-                /**TEMPORARILY EXCLUDE gateways from modules for time being**/
1199
-                if (
1200
-                    $module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1201
-                    && $module_path !== EE_MODULES . 'gateways'
1202
-                ) {
1203
-                    // add to list of installed modules
1204
-                    EE_Config::register_module($module_path);
1205
-                }
1206
-            }
1207
-        }
1208
-        // filter list of installed modules
1209
-        return apply_filters(
1210
-            'FHEE__EE_Config___register_modules__installed_modules',
1211
-            EE_Registry::instance()->modules
1212
-        );
1213
-    }
1214
-
1215
-
1216
-    /**
1217
-     *    register_module - makes core aware of this module
1218
-     *
1219
-     * @access    public
1220
-     * @param    string $module_path - full path up to and including module folder
1221
-     * @return    bool
1222
-     */
1223
-    public static function register_module($module_path = null)
1224
-    {
1225
-        do_action('AHEE__EE_Config__register_module__begin', $module_path);
1226
-        $module_ext = '.module.php';
1227
-        // make all separators match
1228
-        $module_path = str_replace(array('\\', '/'), DS, $module_path);
1229
-        // does the file path INCLUDE the actual file name as part of the path ?
1230
-        if (strpos($module_path, $module_ext) !== false) {
1231
-            // grab and shortcode file name from directory name and break apart at dots
1232
-            $module_file = explode('.', basename($module_path));
1233
-            // now we need to rebuild the shortcode path
1234
-            $module_path = explode(DS, $module_path);
1235
-            // remove last segment
1236
-            array_pop($module_path);
1237
-            // glue it back together
1238
-            $module_path = implode(DS, $module_path) . DS;
1239
-            // take first segment from file name pieces and sanitize it
1240
-            $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1241
-            // ensure class prefix is added
1242
-            $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1243
-        } else {
1244
-            // we need to generate the filename based off of the folder name
1245
-            // grab and sanitize module name
1246
-            $module = strtolower(basename($module_path));
1247
-            $module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1248
-            // like trailingslashit()
1249
-            $module_path = rtrim($module_path, DS) . DS;
1250
-            // create classname from module directory name
1251
-            $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1252
-            // add class prefix
1253
-            $module_class = 'EED_' . $module;
1254
-        }
1255
-        // does the module exist ?
1256
-        if (! is_readable($module_path . DS . $module_class . $module_ext)) {
1257
-            $msg = sprintf(
1258
-                __(
1259
-                    'The requested %s module file could not be found or is not readable due to file permissions.',
1260
-                    'event_espresso'
1261
-                ),
1262
-                $module
1263
-            );
1264
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1265
-            return false;
1266
-        }
1267
-        // load the module class file
1268
-        require_once($module_path . $module_class . $module_ext);
1269
-        // verify that class exists
1270
-        if (! class_exists($module_class)) {
1271
-            $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1272
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1273
-            return false;
1274
-        }
1275
-        // add to array of registered modules
1276
-        EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1277
-        do_action(
1278
-            'AHEE__EE_Config__register_module__complete',
1279
-            $module_class,
1280
-            EE_Registry::instance()->modules->{$module_class}
1281
-        );
1282
-        return true;
1283
-    }
1284
-
1285
-
1286
-    /**
1287
-     *    _initialize_shortcodes
1288
-     *    allow shortcodes to set hooks for the rest of the system
1289
-     *
1290
-     * @access private
1291
-     * @return void
1292
-     */
1293
-    private function _initialize_shortcodes()
1294
-    {
1295
-        // cycle thru shortcode folders
1296
-        foreach (EE_Registry::instance()->shortcodes as $shortcode => $shortcode_path) {
1297
-            // add class prefix
1298
-            $shortcode_class = 'EES_' . $shortcode;
1299
-            // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1300
-            // which set hooks ?
1301
-            if (is_admin()) {
1302
-                // fire immediately
1303
-                call_user_func(array($shortcode_class, 'set_hooks_admin'));
1304
-            } else {
1305
-                // delay until other systems are online
1306
-                add_action(
1307
-                    'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
1308
-                    array($shortcode_class, 'set_hooks')
1309
-                );
1310
-                // convert classname to UPPERCASE and create WP shortcode.
1311
-                $shortcode_tag = strtoupper($shortcode);
1312
-                // but first check if the shortcode has already been added before assigning 'fallback_shortcode_processor'
1313
-                if (! shortcode_exists($shortcode_tag)) {
1314
-                    // NOTE: this shortcode declaration will get overridden if the shortcode is successfully detected in the post content in EE_Front_Controller->_initialize_shortcodes()
1315
-                    add_shortcode($shortcode_tag, array($shortcode_class, 'fallback_shortcode_processor'));
1316
-                }
1317
-            }
1318
-        }
1319
-    }
1320
-
1321
-
1322
-    /**
1323
-     *    _initialize_modules
1324
-     *    allow modules to set hooks for the rest of the system
1325
-     *
1326
-     * @access private
1327
-     * @return void
1328
-     */
1329
-    private function _initialize_modules()
1330
-    {
1331
-        // cycle thru shortcode folders
1332
-        foreach (EE_Registry::instance()->modules as $module_class => $module_path) {
1333
-            // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1334
-            // which set hooks ?
1335
-            if (is_admin()) {
1336
-                // fire immediately
1337
-                call_user_func(array($module_class, 'set_hooks_admin'));
1338
-            } else {
1339
-                // delay until other systems are online
1340
-                add_action(
1341
-                    'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
1342
-                    array($module_class, 'set_hooks')
1343
-                );
1344
-            }
1345
-        }
1346
-    }
1347
-
1348
-
1349
-    /**
1350
-     *    register_route - adds module method routes to route_map
1351
-     *
1352
-     * @access    public
1353
-     * @param    string $route       - "pretty" public alias for module method
1354
-     * @param    string $module      - module name (classname without EED_ prefix)
1355
-     * @param    string $method_name - the actual module method to be routed to
1356
-     * @param    string $key         - url param key indicating a route is being called
1357
-     * @return    bool
1358
-     */
1359
-    public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee')
1360
-    {
1361
-        do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1362
-        $module       = str_replace('EED_', '', $module);
1363
-        $module_class = 'EED_' . $module;
1364
-        if (! isset(EE_Registry::instance()->modules->{$module_class})) {
1365
-            $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module);
1366
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1367
-            return false;
1368
-        }
1369
-        if (empty($route)) {
1370
-            $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route);
1371
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1372
-            return false;
1373
-        }
1374
-        if (! method_exists('EED_' . $module, $method_name)) {
1375
-            $msg = sprintf(
1376
-                __('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1377
-                $route
1378
-            );
1379
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1380
-            return false;
1381
-        }
1382
-        EE_Config::$_module_route_map[$key][$route] = array('EED_' . $module, $method_name);
1383
-        return true;
1384
-    }
1385
-
1386
-
1387
-    /**
1388
-     *    get_route - get module method route
1389
-     *
1390
-     * @access    public
1391
-     * @param    string $route - "pretty" public alias for module method
1392
-     * @param    string $key   - url param key indicating a route is being called
1393
-     * @return    string
1394
-     */
1395
-    public static function get_route($route = null, $key = 'ee')
1396
-    {
1397
-        do_action('AHEE__EE_Config__get_route__begin', $route);
1398
-        $route = (string)apply_filters('FHEE__EE_Config__get_route', $route);
1399
-        if (isset(EE_Config::$_module_route_map[$key][$route])) {
1400
-            return EE_Config::$_module_route_map[$key][$route];
1401
-        }
1402
-        return null;
1403
-    }
1404
-
1405
-
1406
-    /**
1407
-     *    get_routes - get ALL module method routes
1408
-     *
1409
-     * @access    public
1410
-     * @return    array
1411
-     */
1412
-    public static function get_routes()
1413
-    {
1414
-        return EE_Config::$_module_route_map;
1415
-    }
1416
-
1417
-
1418
-    /**
1419
-     *    register_forward - allows modules to forward request to another module for further processing
1420
-     *
1421
-     * @access    public
1422
-     * @param    string       $route   - "pretty" public alias for module method
1423
-     * @param    integer      $status  - integer value corresponding  to status constant strings set in module parent
1424
-     *                                 class, allows different forwards to be served based on status
1425
-     * @param    array|string $forward - function name or array( class, method )
1426
-     * @param    string       $key     - url param key indicating a route is being called
1427
-     * @return    bool
1428
-     */
1429
-    public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee')
1430
-    {
1431
-        do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1432
-        if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1433
-            $msg = sprintf(
1434
-                __('The module route %s for this forward has not been registered.', 'event_espresso'),
1435
-                $route
1436
-            );
1437
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1438
-            return false;
1439
-        }
1440
-        if (empty($forward)) {
1441
-            $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route);
1442
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1443
-            return false;
1444
-        }
1445
-        if (is_array($forward)) {
1446
-            if (! isset($forward[1])) {
1447
-                $msg = sprintf(
1448
-                    __('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1449
-                    $route
1450
-                );
1451
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1452
-                return false;
1453
-            }
1454
-            if (! method_exists($forward[0], $forward[1])) {
1455
-                $msg = sprintf(
1456
-                    __('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1457
-                    $forward[1],
1458
-                    $route
1459
-                );
1460
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1461
-                return false;
1462
-            }
1463
-        } else if (! function_exists($forward)) {
1464
-            $msg = sprintf(
1465
-                __('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1466
-                $forward,
1467
-                $route
1468
-            );
1469
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1470
-            return false;
1471
-        }
1472
-        EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward;
1473
-        return true;
1474
-    }
1475
-
1476
-
1477
-    /**
1478
-     *    get_forward - get forwarding route
1479
-     *
1480
-     * @access    public
1481
-     * @param    string  $route  - "pretty" public alias for module method
1482
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1483
-     *                           allows different forwards to be served based on status
1484
-     * @param    string  $key    - url param key indicating a route is being called
1485
-     * @return    string
1486
-     */
1487
-    public static function get_forward($route = null, $status = 0, $key = 'ee')
1488
-    {
1489
-        do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1490
-        if (isset(EE_Config::$_module_forward_map[$key][$route][$status])) {
1491
-            return apply_filters(
1492
-                'FHEE__EE_Config__get_forward',
1493
-                EE_Config::$_module_forward_map[$key][$route][$status],
1494
-                $route,
1495
-                $status
1496
-            );
1497
-        }
1498
-        return null;
1499
-    }
1500
-
1501
-
1502
-    /**
1503
-     *    register_forward - allows modules to specify different view templates for different method routes and status
1504
-     *    results
1505
-     *
1506
-     * @access    public
1507
-     * @param    string  $route  - "pretty" public alias for module method
1508
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1509
-     *                           allows different views to be served based on status
1510
-     * @param    string  $view
1511
-     * @param    string  $key    - url param key indicating a route is being called
1512
-     * @return    bool
1513
-     */
1514
-    public static function register_view($route = null, $status = 0, $view = null, $key = 'ee')
1515
-    {
1516
-        do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1517
-        if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1518
-            $msg = sprintf(
1519
-                __('The module route %s for this view has not been registered.', 'event_espresso'),
1520
-                $route
1521
-            );
1522
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1523
-            return false;
1524
-        }
1525
-        if (! is_readable($view)) {
1526
-            $msg = sprintf(
1527
-                __(
1528
-                    'The %s view file could not be found or is not readable due to file permissions.',
1529
-                    'event_espresso'
1530
-                ),
1531
-                $view
1532
-            );
1533
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1534
-            return false;
1535
-        }
1536
-        EE_Config::$_module_view_map[$key][$route][absint($status)] = $view;
1537
-        return true;
1538
-    }
1539
-
1540
-
1541
-    /**
1542
-     *    get_view - get view for route and status
1543
-     *
1544
-     * @access    public
1545
-     * @param    string  $route  - "pretty" public alias for module method
1546
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1547
-     *                           allows different views to be served based on status
1548
-     * @param    string  $key    - url param key indicating a route is being called
1549
-     * @return    string
1550
-     */
1551
-    public static function get_view($route = null, $status = 0, $key = 'ee')
1552
-    {
1553
-        do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1554
-        if (isset(EE_Config::$_module_view_map[$key][$route][$status])) {
1555
-            return apply_filters(
1556
-                'FHEE__EE_Config__get_view',
1557
-                EE_Config::$_module_view_map[$key][$route][$status],
1558
-                $route,
1559
-                $status
1560
-            );
1561
-        }
1562
-        return null;
1563
-    }
1564
-
1565
-
1566
-    public function update_addon_option_names()
1567
-    {
1568
-        update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names);
1569
-    }
1570
-
1571
-
1572
-    public function shutdown()
1573
-    {
1574
-        $this->update_addon_option_names();
1575
-    }
16
+	const OPTION_NAME = 'ee_config';
17
+
18
+	const LOG_NAME = 'ee_config_log';
19
+
20
+	const LOG_LENGTH = 100;
21
+
22
+	const ADDON_OPTION_NAMES = 'ee_config_option_names';
23
+
24
+
25
+	/**
26
+	 *    instance of the EE_Config object
27
+	 *
28
+	 * @var    EE_Config $_instance
29
+	 * @access    private
30
+	 */
31
+	private static $_instance;
32
+
33
+	/**
34
+	 * @var boolean $_logging_enabled
35
+	 */
36
+	private static $_logging_enabled = false;
37
+
38
+	/**
39
+	 * An StdClass whose property names are addon slugs,
40
+	 * and values are their config classes
41
+	 *
42
+	 * @var StdClass
43
+	 */
44
+	public $addons;
45
+
46
+	/**
47
+	 * @var EE_Admin_Config
48
+	 */
49
+	public $admin;
50
+
51
+	/**
52
+	 * @var EE_Core_Config
53
+	 */
54
+	public $core;
55
+
56
+	/**
57
+	 * @var EE_Currency_Config
58
+	 */
59
+	public $currency;
60
+
61
+	/**
62
+	 * @var EE_Organization_Config
63
+	 */
64
+	public $organization;
65
+
66
+	/**
67
+	 * @var EE_Registration_Config
68
+	 */
69
+	public $registration;
70
+
71
+	/**
72
+	 * @var EE_Template_Config
73
+	 */
74
+	public $template_settings;
75
+
76
+	/**
77
+	 * Holds EE environment values.
78
+	 *
79
+	 * @var EE_Environment_Config
80
+	 */
81
+	public $environment;
82
+
83
+	/**
84
+	 * settings pertaining to Google maps
85
+	 *
86
+	 * @var EE_Map_Config
87
+	 */
88
+	public $map_settings;
89
+
90
+	/**
91
+	 * settings pertaining to Taxes
92
+	 *
93
+	 * @var EE_Tax_Config
94
+	 */
95
+	public $tax_settings;
96
+
97
+	/**
98
+	 * @deprecated
99
+	 * @var EE_Gateway_Config
100
+	 */
101
+	public $gateway;
102
+
103
+	/**
104
+	 * @var    array $_addon_option_names
105
+	 * @access    private
106
+	 */
107
+	private $_addon_option_names = array();
108
+
109
+	/**
110
+	 * @var    array $_module_route_map
111
+	 * @access    private
112
+	 */
113
+	private static $_module_route_map = array();
114
+
115
+	/**
116
+	 * @var    array $_module_forward_map
117
+	 * @access    private
118
+	 */
119
+	private static $_module_forward_map = array();
120
+
121
+	/**
122
+	 * @var    array $_module_view_map
123
+	 * @access    private
124
+	 */
125
+	private static $_module_view_map = array();
126
+
127
+
128
+	/**
129
+	 * @singleton method used to instantiate class object
130
+	 * @access    public
131
+	 * @return EE_Config instance
132
+	 */
133
+	public static function instance()
134
+	{
135
+		// check if class object is instantiated, and instantiated properly
136
+		if (! self::$_instance instanceof EE_Config) {
137
+			self::$_instance = new self();
138
+		}
139
+		return self::$_instance;
140
+	}
141
+
142
+
143
+	/**
144
+	 * Resets the config
145
+	 *
146
+	 * @param bool    $hard_reset    if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE
147
+	 *                               (default) leaves the database alone, and merely resets the EE_Config object to
148
+	 *                               reflect its state in the database
149
+	 * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave
150
+	 *                               $_instance as NULL. Useful in case you want to forget about the old instance on
151
+	 *                               EE_Config, but might not be ready to instantiate EE_Config currently (eg if the
152
+	 *                               site was put into maintenance mode)
153
+	 * @return EE_Config
154
+	 */
155
+	public static function reset($hard_reset = false, $reinstantiate = true)
156
+	{
157
+		if (self::$_instance instanceof EE_Config) {
158
+			if ($hard_reset) {
159
+				self::$_instance->_addon_option_names = array();
160
+				self::$_instance->_initialize_config();
161
+				self::$_instance->update_espresso_config();
162
+			}
163
+			self::$_instance->update_addon_option_names();
164
+		}
165
+		self::$_instance = null;
166
+		//we don't need to reset the static properties imo because those should
167
+		//only change when a module is added or removed. Currently we don't
168
+		//support removing a module during a request when it previously existed
169
+		if ($reinstantiate) {
170
+			return self::instance();
171
+		} else {
172
+			return null;
173
+		}
174
+	}
175
+
176
+
177
+	/**
178
+	 *    class constructor
179
+	 *
180
+	 * @access    private
181
+	 */
182
+	private function __construct()
183
+	{
184
+		do_action('AHEE__EE_Config__construct__begin', $this);
185
+		EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false);
186
+		// setup empty config classes
187
+		$this->_initialize_config();
188
+		// load existing EE site settings
189
+		$this->_load_core_config();
190
+		// confirm everything loaded correctly and set filtered defaults if not
191
+		$this->_verify_config();
192
+		//  register shortcodes and modules
193
+		add_action(
194
+			'AHEE__EE_System__register_shortcodes_modules_and_widgets',
195
+			array($this, 'register_shortcodes_and_modules'),
196
+			999
197
+		);
198
+		//  initialize shortcodes and modules
199
+		add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules'));
200
+		// register widgets
201
+		add_action('widgets_init', array($this, 'widgets_init'), 10);
202
+		// shutdown
203
+		add_action('shutdown', array($this, 'shutdown'), 10);
204
+		// construct__end hook
205
+		do_action('AHEE__EE_Config__construct__end', $this);
206
+		// hardcoded hack
207
+		$this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014';
208
+	}
209
+
210
+
211
+	/**
212
+	 * @return boolean
213
+	 */
214
+	public static function logging_enabled()
215
+	{
216
+		return self::$_logging_enabled;
217
+	}
218
+
219
+
220
+	/**
221
+	 * use to get the current theme if needed from static context
222
+	 *
223
+	 * @return string current theme set.
224
+	 */
225
+	public static function get_current_theme()
226
+	{
227
+		return isset(self::$_instance->template_settings->current_espresso_theme)
228
+			? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014';
229
+	}
230
+
231
+
232
+	/**
233
+	 *        _initialize_config
234
+	 *
235
+	 * @access private
236
+	 * @return void
237
+	 */
238
+	private function _initialize_config()
239
+	{
240
+		EE_Config::trim_log();
241
+		//set defaults
242
+		$this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array());
243
+		$this->addons              = new stdClass();
244
+		// set _module_route_map
245
+		EE_Config::$_module_route_map = array();
246
+		// set _module_forward_map
247
+		EE_Config::$_module_forward_map = array();
248
+		// set _module_view_map
249
+		EE_Config::$_module_view_map = array();
250
+	}
251
+
252
+
253
+	/**
254
+	 *        load core plugin configuration
255
+	 *
256
+	 * @access private
257
+	 * @return void
258
+	 */
259
+	private function _load_core_config()
260
+	{
261
+		// load_core_config__start hook
262
+		do_action('AHEE__EE_Config___load_core_config__start', $this);
263
+		$espresso_config = $this->get_espresso_config();
264
+		foreach ($espresso_config as $config => $settings) {
265
+			// load_core_config__start hook
266
+			$settings = apply_filters(
267
+				'FHEE__EE_Config___load_core_config__config_settings',
268
+				$settings,
269
+				$config,
270
+				$this
271
+			);
272
+			if (is_object($settings) && property_exists($this, $config)) {
273
+				$this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings);
274
+				//call configs populate method to ensure any defaults are set for empty values.
275
+				if (method_exists($settings, 'populate')) {
276
+					$this->{$config}->populate();
277
+				}
278
+				if (method_exists($settings, 'do_hooks')) {
279
+					$this->{$config}->do_hooks();
280
+				}
281
+			}
282
+		}
283
+		if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) {
284
+			$this->update_espresso_config();
285
+		}
286
+		// load_core_config__end hook
287
+		do_action('AHEE__EE_Config___load_core_config__end', $this);
288
+	}
289
+
290
+
291
+	/**
292
+	 *    _verify_config
293
+	 *
294
+	 * @access    protected
295
+	 * @return    void
296
+	 */
297
+	protected function _verify_config()
298
+	{
299
+		$this->core              = $this->core instanceof EE_Core_Config
300
+			? $this->core
301
+			: new EE_Core_Config();
302
+		$this->core              = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core);
303
+		$this->organization      = $this->organization instanceof EE_Organization_Config
304
+			? $this->organization
305
+			: new EE_Organization_Config();
306
+		$this->organization      = apply_filters('FHEE__EE_Config___initialize_config__organization',
307
+			$this->organization);
308
+		$this->currency          = $this->currency instanceof EE_Currency_Config
309
+			? $this->currency
310
+			: new EE_Currency_Config();
311
+		$this->currency          = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency);
312
+		$this->registration      = $this->registration instanceof EE_Registration_Config
313
+			? $this->registration
314
+			: new EE_Registration_Config();
315
+		$this->registration      = apply_filters('FHEE__EE_Config___initialize_config__registration',
316
+			$this->registration);
317
+		$this->admin             = $this->admin instanceof EE_Admin_Config
318
+			? $this->admin
319
+			: new EE_Admin_Config();
320
+		$this->admin             = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin);
321
+		$this->template_settings = $this->template_settings instanceof EE_Template_Config
322
+			? $this->template_settings
323
+			: new EE_Template_Config();
324
+		$this->template_settings = apply_filters(
325
+			'FHEE__EE_Config___initialize_config__template_settings',
326
+			$this->template_settings
327
+		);
328
+		$this->map_settings      = $this->map_settings instanceof EE_Map_Config
329
+			? $this->map_settings
330
+			: new EE_Map_Config();
331
+		$this->map_settings      = apply_filters('FHEE__EE_Config___initialize_config__map_settings',
332
+			$this->map_settings);
333
+		$this->environment       = $this->environment instanceof EE_Environment_Config
334
+			? $this->environment
335
+			: new EE_Environment_Config();
336
+		$this->environment       = apply_filters('FHEE__EE_Config___initialize_config__environment',
337
+			$this->environment);
338
+		$this->tax_settings      = $this->tax_settings instanceof EE_Tax_Config
339
+			? $this->tax_settings
340
+			: new EE_Tax_Config();
341
+		$this->tax_settings      = apply_filters('FHEE__EE_Config___initialize_config__tax_settings',
342
+			$this->tax_settings);
343
+		$this->gateway           = $this->gateway instanceof EE_Gateway_Config
344
+			? $this->gateway
345
+			: new EE_Gateway_Config();
346
+		$this->gateway           = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway);
347
+	}
348
+
349
+
350
+	/**
351
+	 *    get_espresso_config
352
+	 *
353
+	 * @access    public
354
+	 * @return    array of espresso config stuff
355
+	 */
356
+	public function get_espresso_config()
357
+	{
358
+		// grab espresso configuration
359
+		return apply_filters(
360
+			'FHEE__EE_Config__get_espresso_config__CFG',
361
+			get_option(EE_Config::OPTION_NAME, array())
362
+		);
363
+	}
364
+
365
+
366
+	/**
367
+	 *    double_check_config_comparison
368
+	 *
369
+	 * @access    public
370
+	 * @param string $option
371
+	 * @param        $old_value
372
+	 * @param        $value
373
+	 */
374
+	public function double_check_config_comparison($option = '', $old_value, $value)
375
+	{
376
+		// make sure we're checking the ee config
377
+		if ($option === EE_Config::OPTION_NAME) {
378
+			// run a loose comparison of the old value against the new value for type and properties,
379
+			// but NOT exact instance like WP update_option does (ie: NOT type safe comparison)
380
+			if ($value != $old_value) {
381
+				// if they are NOT the same, then remove the hook,
382
+				// which means the subsequent update results will be based solely on the update query results
383
+				// the reason we do this is because, as stated above,
384
+				// WP update_option performs an exact instance comparison (===) on any update values passed to it
385
+				// this happens PRIOR to serialization and any subsequent update.
386
+				// If values are found to match their previous old value,
387
+				// then WP bails before performing any update.
388
+				// Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version
389
+				// it just pulled from the db, with the one being passed to it (which will not match).
390
+				// HOWEVER, once the object is serialized and passed off to MySQL to update,
391
+				// MySQL MAY ALSO NOT perform the update because
392
+				// the string it sees in the db looks the same as the new one it has been passed!!!
393
+				// This results in the query returning an "affected rows" value of ZERO,
394
+				// which gets returned immediately by WP update_option and looks like an error.
395
+				remove_action('update_option', array($this, 'check_config_updated'));
396
+			}
397
+		}
398
+	}
399
+
400
+
401
+	/**
402
+	 *    update_espresso_config
403
+	 *
404
+	 * @access   public
405
+	 */
406
+	protected function _reset_espresso_addon_config()
407
+	{
408
+		$this->_addon_option_names = array();
409
+		foreach ($this->addons as $addon_name => $addon_config_obj) {
410
+			$addon_config_obj = maybe_unserialize($addon_config_obj);
411
+			$config_class     = get_class($addon_config_obj);
412
+			if ($addon_config_obj instanceof $config_class && ! $addon_config_obj instanceof __PHP_Incomplete_Class) {
413
+				$this->update_config('addons', $addon_name, $addon_config_obj, false);
414
+			}
415
+			$this->addons->{$addon_name} = null;
416
+		}
417
+	}
418
+
419
+
420
+	/**
421
+	 *    update_espresso_config
422
+	 *
423
+	 * @access   public
424
+	 * @param   bool $add_success
425
+	 * @param   bool $add_error
426
+	 * @return   bool
427
+	 */
428
+	public function update_espresso_config($add_success = false, $add_error = true)
429
+	{
430
+		// don't allow config updates during WP heartbeats
431
+		if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
432
+			return false;
433
+		}
434
+		// commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197
435
+		//$clone = clone( self::$_instance );
436
+		//self::$_instance = NULL;
437
+		do_action('AHEE__EE_Config__update_espresso_config__begin', $this);
438
+		$this->_reset_espresso_addon_config();
439
+		// hook into update_option because that happens AFTER the ( $value === $old_value ) conditional
440
+		// but BEFORE the actual update occurs
441
+		add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3);
442
+		// now update "ee_config"
443
+		$saved = update_option(EE_Config::OPTION_NAME, $this);
444
+		EE_Config::log(EE_Config::OPTION_NAME);
445
+		// if not saved... check if the hook we just added still exists;
446
+		// if it does, it means one of two things:
447
+		// 		that update_option bailed at the ( $value === $old_value ) conditional,
448
+		//		 or...
449
+		// 		the db update query returned 0 rows affected
450
+		// 		(probably because the data  value was the same from it's perspective)
451
+		// so the existence of the hook means that a negative result from update_option is NOT an error,
452
+		// but just means no update occurred, so don't display an error to the user.
453
+		// BUT... if update_option returns FALSE, AND the hook is missing,
454
+		// then it means that something truly went wrong
455
+		$saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved;
456
+		// remove our action since we don't want it in the system anymore
457
+		remove_action('update_option', array($this, 'double_check_config_comparison'), 1);
458
+		do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved);
459
+		//self::$_instance = $clone;
460
+		//unset( $clone );
461
+		// if config remains the same or was updated successfully
462
+		if ($saved) {
463
+			if ($add_success) {
464
+				EE_Error::add_success(
465
+					__('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'),
466
+					__FILE__,
467
+					__FUNCTION__,
468
+					__LINE__
469
+				);
470
+			}
471
+			return true;
472
+		} else {
473
+			if ($add_error) {
474
+				EE_Error::add_error(
475
+					__('The Event Espresso Configuration Settings were not updated.', 'event_espresso'),
476
+					__FILE__,
477
+					__FUNCTION__,
478
+					__LINE__
479
+				);
480
+			}
481
+			return false;
482
+		}
483
+	}
484
+
485
+
486
+	/**
487
+	 *    _verify_config_params
488
+	 *
489
+	 * @access    private
490
+	 * @param    string         $section
491
+	 * @param    string         $name
492
+	 * @param    string         $config_class
493
+	 * @param    EE_Config_Base $config_obj
494
+	 * @param    array          $tests_to_run
495
+	 * @param    bool           $display_errors
496
+	 * @return    bool    TRUE on success, FALSE on fail
497
+	 */
498
+	private function _verify_config_params(
499
+		$section = '',
500
+		$name = '',
501
+		$config_class = '',
502
+		$config_obj = null,
503
+		$tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8),
504
+		$display_errors = true
505
+	) {
506
+		try {
507
+			foreach ($tests_to_run as $test) {
508
+				switch ($test) {
509
+					// TEST #1 : check that section was set
510
+					case 1 :
511
+						if (empty($section)) {
512
+							if ($display_errors) {
513
+								throw new EE_Error(
514
+									sprintf(
515
+										__(
516
+											'No configuration section has been provided while attempting to save "%s".',
517
+											'event_espresso'
518
+										),
519
+										$config_class
520
+									)
521
+								);
522
+							}
523
+							return false;
524
+						}
525
+						break;
526
+					// TEST #2 : check that settings section exists
527
+					case 2 :
528
+						if (! isset($this->{$section})) {
529
+							if ($display_errors) {
530
+								throw new EE_Error(
531
+									sprintf(
532
+										__('The "%s" configuration section does not exist.', 'event_espresso'),
533
+										$section
534
+									)
535
+								);
536
+							}
537
+							return false;
538
+						}
539
+						break;
540
+					// TEST #3 : check that section is the proper format
541
+					case 3 :
542
+						if (
543
+						! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass)
544
+						) {
545
+							if ($display_errors) {
546
+								throw new EE_Error(
547
+									sprintf(
548
+										__(
549
+											'The "%s" configuration settings have not been formatted correctly.',
550
+											'event_espresso'
551
+										),
552
+										$section
553
+									)
554
+								);
555
+							}
556
+							return false;
557
+						}
558
+						break;
559
+					// TEST #4 : check that config section name has been set
560
+					case 4 :
561
+						if (empty($name)) {
562
+							if ($display_errors) {
563
+								throw new EE_Error(
564
+									__(
565
+										'No name has been provided for the specific configuration section.',
566
+										'event_espresso'
567
+									)
568
+								);
569
+							}
570
+							return false;
571
+						}
572
+						break;
573
+					// TEST #5 : check that a config class name has been set
574
+					case 5 :
575
+						if (empty($config_class)) {
576
+							if ($display_errors) {
577
+								throw new EE_Error(
578
+									__(
579
+										'No class name has been provided for the specific configuration section.',
580
+										'event_espresso'
581
+									)
582
+								);
583
+							}
584
+							return false;
585
+						}
586
+						break;
587
+					// TEST #6 : verify config class is accessible
588
+					case 6 :
589
+						if (! class_exists($config_class)) {
590
+							if ($display_errors) {
591
+								throw new EE_Error(
592
+									sprintf(
593
+										__(
594
+											'The "%s" class does not exist. Please ensure that an autoloader has been set for it.',
595
+											'event_espresso'
596
+										),
597
+										$config_class
598
+									)
599
+								);
600
+							}
601
+							return false;
602
+						}
603
+						break;
604
+					// TEST #7 : check that config has even been set
605
+					case 7 :
606
+						if (! isset($this->{$section}->{$name})) {
607
+							if ($display_errors) {
608
+								throw new EE_Error(
609
+									sprintf(
610
+										__('No configuration has been set for "%1$s->%2$s".', 'event_espresso'),
611
+										$section,
612
+										$name
613
+									)
614
+								);
615
+							}
616
+							return false;
617
+						} else {
618
+							// and make sure it's not serialized
619
+							$this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name});
620
+						}
621
+						break;
622
+					// TEST #8 : check that config is the requested type
623
+					case 8 :
624
+						if (! $this->{$section}->{$name} instanceof $config_class) {
625
+							if ($display_errors) {
626
+								throw new EE_Error(
627
+									sprintf(
628
+										__(
629
+											'The configuration for "%1$s->%2$s" is not of the "%3$s" class.',
630
+											'event_espresso'
631
+										),
632
+										$section,
633
+										$name,
634
+										$config_class
635
+									)
636
+								);
637
+							}
638
+							return false;
639
+						}
640
+						break;
641
+					// TEST #9 : verify config object
642
+					case 9 :
643
+						if (! $config_obj instanceof EE_Config_Base) {
644
+							if ($display_errors) {
645
+								throw new EE_Error(
646
+									sprintf(
647
+										__('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'),
648
+										print_r($config_obj, true)
649
+									)
650
+								);
651
+							}
652
+							return false;
653
+						}
654
+						break;
655
+				}
656
+			}
657
+		} catch (EE_Error $e) {
658
+			$e->get_error();
659
+		}
660
+		// you have successfully run the gauntlet
661
+		return true;
662
+	}
663
+
664
+
665
+	/**
666
+	 *    _generate_config_option_name
667
+	 *
668
+	 * @access        protected
669
+	 * @param        string $section
670
+	 * @param        string $name
671
+	 * @return        string
672
+	 */
673
+	private function _generate_config_option_name($section = '', $name = '')
674
+	{
675
+		return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name));
676
+	}
677
+
678
+
679
+	/**
680
+	 *    _set_config_class
681
+	 * ensures that a config class is set, either from a passed config class or one generated from the config name
682
+	 *
683
+	 * @access    private
684
+	 * @param    string $config_class
685
+	 * @param    string $name
686
+	 * @return    string
687
+	 */
688
+	private function _set_config_class($config_class = '', $name = '')
689
+	{
690
+		return ! empty($config_class)
691
+			? $config_class
692
+			: str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config';
693
+	}
694
+
695
+
696
+	/**
697
+	 *    set_config
698
+	 *
699
+	 * @access    protected
700
+	 * @param    string         $section
701
+	 * @param    string         $name
702
+	 * @param    string         $config_class
703
+	 * @param    EE_Config_Base $config_obj
704
+	 * @return    EE_Config_Base
705
+	 */
706
+	public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null)
707
+	{
708
+		// ensure config class is set to something
709
+		$config_class = $this->_set_config_class($config_class, $name);
710
+		// run tests 1-4, 6, and 7 to verify all config params are set and valid
711
+		if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
712
+			return null;
713
+		}
714
+		$config_option_name = $this->_generate_config_option_name($section, $name);
715
+		// if the config option name hasn't been added yet to the list of option names we're tracking, then do so now
716
+		if (! isset($this->_addon_option_names[$config_option_name])) {
717
+			$this->_addon_option_names[$config_option_name] = $config_class;
718
+			$this->update_addon_option_names();
719
+		}
720
+		// verify the incoming config object but suppress errors
721
+		if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
722
+			$config_obj = new $config_class();
723
+		}
724
+		if (get_option($config_option_name)) {
725
+			EE_Config::log($config_option_name);
726
+			update_option($config_option_name, $config_obj);
727
+			$this->{$section}->{$name} = $config_obj;
728
+			return $this->{$section}->{$name};
729
+		} else {
730
+			// create a wp-option for this config
731
+			if (add_option($config_option_name, $config_obj, '', 'no')) {
732
+				$this->{$section}->{$name} = maybe_unserialize($config_obj);
733
+				return $this->{$section}->{$name};
734
+			} else {
735
+				EE_Error::add_error(
736
+					sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class),
737
+					__FILE__,
738
+					__FUNCTION__,
739
+					__LINE__
740
+				);
741
+				return null;
742
+			}
743
+		}
744
+	}
745
+
746
+
747
+	/**
748
+	 *    update_config
749
+	 * Important: the config object must ALREADY be set, otherwise this will produce an error.
750
+	 *
751
+	 * @access    public
752
+	 * @param    string                $section
753
+	 * @param    string                $name
754
+	 * @param    EE_Config_Base|string $config_obj
755
+	 * @param    bool                  $throw_errors
756
+	 * @return    bool
757
+	 */
758
+	public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true)
759
+	{
760
+		// don't allow config updates during WP heartbeats
761
+		if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
762
+			return false;
763
+		}
764
+		$config_obj = maybe_unserialize($config_obj);
765
+		// get class name of the incoming object
766
+		$config_class = get_class($config_obj);
767
+		// run tests 1-5 and 9 to verify config
768
+		if (! $this->_verify_config_params(
769
+			$section,
770
+			$name,
771
+			$config_class,
772
+			$config_obj,
773
+			array(1, 2, 3, 4, 7, 9)
774
+		)
775
+		) {
776
+			return false;
777
+		}
778
+		$config_option_name = $this->_generate_config_option_name($section, $name);
779
+		// check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
780
+		if (! isset($this->_addon_option_names[$config_option_name])) {
781
+			// save new config to db
782
+			if ($this->set_config($section, $name, $config_class, $config_obj)) {
783
+				return true;
784
+			}
785
+		} else {
786
+			// first check if the record already exists
787
+			$existing_config = get_option($config_option_name);
788
+			$config_obj      = serialize($config_obj);
789
+			// just return if db record is already up to date (NOT type safe comparison)
790
+			if ($existing_config == $config_obj) {
791
+				$this->{$section}->{$name} = $config_obj;
792
+				return true;
793
+			} else if (update_option($config_option_name, $config_obj)) {
794
+				EE_Config::log($config_option_name);
795
+				// update wp-option for this config class
796
+				$this->{$section}->{$name} = $config_obj;
797
+				return true;
798
+			} elseif ($throw_errors) {
799
+				EE_Error::add_error(
800
+					sprintf(
801
+						__(
802
+							'The "%1$s" object stored at"%2$s" was not successfully updated in the database.',
803
+							'event_espresso'
804
+						),
805
+						$config_class,
806
+						'EE_Config->' . $section . '->' . $name
807
+					),
808
+					__FILE__,
809
+					__FUNCTION__,
810
+					__LINE__
811
+				);
812
+			}
813
+		}
814
+		return false;
815
+	}
816
+
817
+
818
+	/**
819
+	 *    get_config
820
+	 *
821
+	 * @access    public
822
+	 * @param    string $section
823
+	 * @param    string $name
824
+	 * @param    string $config_class
825
+	 * @return    mixed EE_Config_Base | NULL
826
+	 */
827
+	public function get_config($section = '', $name = '', $config_class = '')
828
+	{
829
+		// ensure config class is set to something
830
+		$config_class = $this->_set_config_class($config_class, $name);
831
+		// run tests 1-4, 6 and 7 to verify that all params have been set
832
+		if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
833
+			return null;
834
+		}
835
+		// now test if the requested config object exists, but suppress errors
836
+		if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) {
837
+			// config already exists, so pass it back
838
+			return $this->{$section}->{$name};
839
+		}
840
+		// load config option from db if it exists
841
+		$config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name));
842
+		// verify the newly retrieved config object, but suppress errors
843
+		if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
844
+			// config is good, so set it and pass it back
845
+			$this->{$section}->{$name} = $config_obj;
846
+			return $this->{$section}->{$name};
847
+		}
848
+		// oops! $config_obj is not already set and does not exist in the db, so create a new one
849
+		$config_obj = $this->set_config($section, $name, $config_class);
850
+		// verify the newly created config object
851
+		if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) {
852
+			return $this->{$section}->{$name};
853
+		} else {
854
+			EE_Error::add_error(
855
+				sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class),
856
+				__FILE__,
857
+				__FUNCTION__,
858
+				__LINE__
859
+			);
860
+		}
861
+		return null;
862
+	}
863
+
864
+
865
+	/**
866
+	 *    get_config_option
867
+	 *
868
+	 * @access    public
869
+	 * @param    string $config_option_name
870
+	 * @return    mixed EE_Config_Base | FALSE
871
+	 */
872
+	public function get_config_option($config_option_name = '')
873
+	{
874
+		// retrieve the wp-option for this config class.
875
+		$config_option = maybe_unserialize(get_option($config_option_name, array()));
876
+		if (empty($config_option)) {
877
+			EE_Config::log($config_option_name . '-NOT-FOUND');
878
+		}
879
+		return $config_option;
880
+	}
881
+
882
+
883
+	/**
884
+	 * log
885
+	 *
886
+	 * @param string $config_option_name
887
+	 */
888
+	public static function log($config_option_name = '')
889
+	{
890
+		if (EE_Config::logging_enabled() && ! empty($config_option_name)) {
891
+			$config_log = get_option(EE_Config::LOG_NAME, array());
892
+			//copy incoming $_REQUEST and sanitize it so we can save it
893
+			$_request = $_REQUEST;
894
+			array_walk_recursive($_request, 'sanitize_text_field');
895
+			$config_log[(string)microtime(true)] = array(
896
+				'config_name' => $config_option_name,
897
+				'request'     => $_request,
898
+			);
899
+			update_option(EE_Config::LOG_NAME, $config_log);
900
+		}
901
+	}
902
+
903
+
904
+	/**
905
+	 * trim_log
906
+	 * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH
907
+	 */
908
+	public static function trim_log()
909
+	{
910
+		if (! EE_Config::logging_enabled()) {
911
+			return;
912
+		}
913
+		$config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
914
+		$log_length = count($config_log);
915
+		if ($log_length > EE_Config::LOG_LENGTH) {
916
+			ksort($config_log);
917
+			$config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true);
918
+			update_option(EE_Config::LOG_NAME, $config_log);
919
+		}
920
+	}
921
+
922
+
923
+	/**
924
+	 *    get_page_for_posts
925
+	 *    if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the
926
+	 *    wp-option "page_for_posts", or "posts" if no page is selected
927
+	 *
928
+	 * @access    public
929
+	 * @return    string
930
+	 */
931
+	public static function get_page_for_posts()
932
+	{
933
+		$page_for_posts = get_option('page_for_posts');
934
+		if (! $page_for_posts) {
935
+			return 'posts';
936
+		}
937
+		/** @type WPDB $wpdb */
938
+		global $wpdb;
939
+		$SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d";
940
+		return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts));
941
+	}
942
+
943
+
944
+	/**
945
+	 *    register_shortcodes_and_modules.
946
+	 *    At this point, it's too early to tell if we're maintenance mode or not.
947
+	 *    In fact, this is where we give modules a chance to let core know they exist
948
+	 *    so they can help trigger maintenance mode if it's needed
949
+	 *
950
+	 * @access    public
951
+	 * @return    void
952
+	 */
953
+	public function register_shortcodes_and_modules()
954
+	{
955
+		// allow shortcodes to register with WP and to set hooks for the rest of the system
956
+		EE_Registry::instance()->shortcodes = $this->_register_shortcodes();
957
+		// allow modules to set hooks for the rest of the system
958
+		EE_Registry::instance()->modules = $this->_register_modules();
959
+	}
960
+
961
+
962
+	/**
963
+	 *    initialize_shortcodes_and_modules
964
+	 *    meaning they can start adding their hooks to get stuff done
965
+	 *
966
+	 * @access    public
967
+	 * @return    void
968
+	 */
969
+	public function initialize_shortcodes_and_modules()
970
+	{
971
+		// allow shortcodes to set hooks for the rest of the system
972
+		$this->_initialize_shortcodes();
973
+		// allow modules to set hooks for the rest of the system
974
+		$this->_initialize_modules();
975
+	}
976
+
977
+
978
+	/**
979
+	 *    widgets_init
980
+	 *
981
+	 * @access private
982
+	 * @return void
983
+	 */
984
+	public function widgets_init()
985
+	{
986
+		//only init widgets on admin pages when not in complete maintenance, and
987
+		//on frontend when not in any maintenance mode
988
+		if (
989
+			! EE_Maintenance_Mode::instance()->level()
990
+			|| (
991
+				is_admin()
992
+				&& EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance
993
+			)
994
+		) {
995
+			// grab list of installed widgets
996
+			$widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
997
+			// filter list of modules to register
998
+			$widgets_to_register = apply_filters(
999
+				'FHEE__EE_Config__register_widgets__widgets_to_register',
1000
+				$widgets_to_register
1001
+			);
1002
+			if (! empty($widgets_to_register)) {
1003
+				// cycle thru widget folders
1004
+				foreach ($widgets_to_register as $widget_path) {
1005
+					// add to list of installed widget modules
1006
+					EE_Config::register_ee_widget($widget_path);
1007
+				}
1008
+			}
1009
+			// filter list of installed modules
1010
+			EE_Registry::instance()->widgets = apply_filters(
1011
+				'FHEE__EE_Config__register_widgets__installed_widgets',
1012
+				EE_Registry::instance()->widgets
1013
+			);
1014
+		}
1015
+	}
1016
+
1017
+
1018
+	/**
1019
+	 *    register_ee_widget - makes core aware of this widget
1020
+	 *
1021
+	 * @access    public
1022
+	 * @param    string $widget_path - full path up to and including widget folder
1023
+	 * @return    void
1024
+	 */
1025
+	public static function register_ee_widget($widget_path = null)
1026
+	{
1027
+		do_action('AHEE__EE_Config__register_widget__begin', $widget_path);
1028
+		$widget_ext = '.widget.php';
1029
+		// make all separators match
1030
+		$widget_path = rtrim(str_replace('/\\', DS, $widget_path), DS);
1031
+		// does the file path INCLUDE the actual file name as part of the path ?
1032
+		if (strpos($widget_path, $widget_ext) !== false) {
1033
+			// grab and shortcode file name from directory name and break apart at dots
1034
+			$file_name = explode('.', basename($widget_path));
1035
+			// take first segment from file name pieces and remove class prefix if it exists
1036
+			$widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0];
1037
+			// sanitize shortcode directory name
1038
+			$widget = sanitize_key($widget);
1039
+			// now we need to rebuild the shortcode path
1040
+			$widget_path = explode(DS, $widget_path);
1041
+			// remove last segment
1042
+			array_pop($widget_path);
1043
+			// glue it back together
1044
+			$widget_path = implode(DS, $widget_path);
1045
+		} else {
1046
+			// grab and sanitize widget directory name
1047
+			$widget = sanitize_key(basename($widget_path));
1048
+		}
1049
+		// create classname from widget directory name
1050
+		$widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1051
+		// add class prefix
1052
+		$widget_class = 'EEW_' . $widget;
1053
+		// does the widget exist ?
1054
+		if (! is_readable($widget_path . DS . $widget_class . $widget_ext)) {
1055
+			$msg = sprintf(
1056
+				__(
1057
+					'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',
1058
+					'event_espresso'
1059
+				),
1060
+				$widget_class,
1061
+				$widget_path . DS . $widget_class . $widget_ext
1062
+			);
1063
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1064
+			return;
1065
+		}
1066
+		// load the widget class file
1067
+		require_once($widget_path . DS . $widget_class . $widget_ext);
1068
+		// verify that class exists
1069
+		if (! class_exists($widget_class)) {
1070
+			$msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1071
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1072
+			return;
1073
+		}
1074
+		register_widget($widget_class);
1075
+		// add to array of registered widgets
1076
+		EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext;
1077
+	}
1078
+
1079
+
1080
+	/**
1081
+	 *        _register_shortcodes
1082
+	 *
1083
+	 * @access private
1084
+	 * @return array
1085
+	 */
1086
+	private function _register_shortcodes()
1087
+	{
1088
+		// grab list of installed shortcodes
1089
+		$shortcodes_to_register = glob(EE_SHORTCODES . '*', GLOB_ONLYDIR);
1090
+		// filter list of modules to register
1091
+		$shortcodes_to_register = apply_filters(
1092
+			'FHEE__EE_Config__register_shortcodes__shortcodes_to_register',
1093
+			$shortcodes_to_register
1094
+		);
1095
+		if (! empty($shortcodes_to_register)) {
1096
+			// cycle thru shortcode folders
1097
+			foreach ($shortcodes_to_register as $shortcode_path) {
1098
+				// add to list of installed shortcode modules
1099
+				EE_Config::register_shortcode($shortcode_path);
1100
+			}
1101
+		}
1102
+		// filter list of installed modules
1103
+		return apply_filters(
1104
+			'FHEE__EE_Config___register_shortcodes__installed_shortcodes',
1105
+			EE_Registry::instance()->shortcodes
1106
+		);
1107
+	}
1108
+
1109
+
1110
+	/**
1111
+	 *    register_shortcode - makes core aware of this shortcode
1112
+	 *
1113
+	 * @access    public
1114
+	 * @param    string $shortcode_path - full path up to and including shortcode folder
1115
+	 * @return    bool
1116
+	 */
1117
+	public static function register_shortcode($shortcode_path = null)
1118
+	{
1119
+		do_action('AHEE__EE_Config__register_shortcode__begin', $shortcode_path);
1120
+		$shortcode_ext = '.shortcode.php';
1121
+		// make all separators match
1122
+		$shortcode_path = str_replace(array('\\', '/'), DS, $shortcode_path);
1123
+		// does the file path INCLUDE the actual file name as part of the path ?
1124
+		if (strpos($shortcode_path, $shortcode_ext) !== false) {
1125
+			// grab shortcode file name from directory name and break apart at dots
1126
+			$shortcode_file = explode('.', basename($shortcode_path));
1127
+			// take first segment from file name pieces and remove class prefix if it exists
1128
+			$shortcode = strpos($shortcode_file[0], 'EES_') === 0
1129
+				? substr($shortcode_file[0], 4)
1130
+				: $shortcode_file[0];
1131
+			// sanitize shortcode directory name
1132
+			$shortcode = sanitize_key($shortcode);
1133
+			// now we need to rebuild the shortcode path
1134
+			$shortcode_path = explode(DS, $shortcode_path);
1135
+			// remove last segment
1136
+			array_pop($shortcode_path);
1137
+			// glue it back together
1138
+			$shortcode_path = implode(DS, $shortcode_path) . DS;
1139
+		} else {
1140
+			// we need to generate the filename based off of the folder name
1141
+			// grab and sanitize shortcode directory name
1142
+			$shortcode      = sanitize_key(basename($shortcode_path));
1143
+			$shortcode_path = rtrim($shortcode_path, DS) . DS;
1144
+		}
1145
+		// create classname from shortcode directory or file name
1146
+		$shortcode = str_replace(' ', '_', ucwords(str_replace('_', ' ', $shortcode)));
1147
+		// add class prefix
1148
+		$shortcode_class = 'EES_' . $shortcode;
1149
+		// does the shortcode exist ?
1150
+		if (! is_readable($shortcode_path . DS . $shortcode_class . $shortcode_ext)) {
1151
+			$msg = sprintf(
1152
+				__(
1153
+					'The requested %s shortcode file could not be found or is not readable due to file permissions. It should be in %s',
1154
+					'event_espresso'
1155
+				),
1156
+				$shortcode_class,
1157
+				$shortcode_path . DS . $shortcode_class . $shortcode_ext
1158
+			);
1159
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1160
+			return false;
1161
+		}
1162
+		// load the shortcode class file
1163
+		require_once($shortcode_path . $shortcode_class . $shortcode_ext);
1164
+		// verify that class exists
1165
+		if (! class_exists($shortcode_class)) {
1166
+			$msg = sprintf(
1167
+				__('The requested %s shortcode class does not exist.', 'event_espresso'),
1168
+				$shortcode_class
1169
+			);
1170
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1171
+			return false;
1172
+		}
1173
+		$shortcode = strtoupper($shortcode);
1174
+		// add to array of registered shortcodes
1175
+		EE_Registry::instance()->shortcodes->{$shortcode} = $shortcode_path . $shortcode_class . $shortcode_ext;
1176
+		return true;
1177
+	}
1178
+
1179
+
1180
+	/**
1181
+	 *        _register_modules
1182
+	 *
1183
+	 * @access private
1184
+	 * @return array
1185
+	 */
1186
+	private function _register_modules()
1187
+	{
1188
+		// grab list of installed modules
1189
+		$modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1190
+		// filter list of modules to register
1191
+		$modules_to_register = apply_filters(
1192
+			'FHEE__EE_Config__register_modules__modules_to_register',
1193
+			$modules_to_register
1194
+		);
1195
+		if (! empty($modules_to_register)) {
1196
+			// loop through folders
1197
+			foreach ($modules_to_register as $module_path) {
1198
+				/**TEMPORARILY EXCLUDE gateways from modules for time being**/
1199
+				if (
1200
+					$module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1201
+					&& $module_path !== EE_MODULES . 'gateways'
1202
+				) {
1203
+					// add to list of installed modules
1204
+					EE_Config::register_module($module_path);
1205
+				}
1206
+			}
1207
+		}
1208
+		// filter list of installed modules
1209
+		return apply_filters(
1210
+			'FHEE__EE_Config___register_modules__installed_modules',
1211
+			EE_Registry::instance()->modules
1212
+		);
1213
+	}
1214
+
1215
+
1216
+	/**
1217
+	 *    register_module - makes core aware of this module
1218
+	 *
1219
+	 * @access    public
1220
+	 * @param    string $module_path - full path up to and including module folder
1221
+	 * @return    bool
1222
+	 */
1223
+	public static function register_module($module_path = null)
1224
+	{
1225
+		do_action('AHEE__EE_Config__register_module__begin', $module_path);
1226
+		$module_ext = '.module.php';
1227
+		// make all separators match
1228
+		$module_path = str_replace(array('\\', '/'), DS, $module_path);
1229
+		// does the file path INCLUDE the actual file name as part of the path ?
1230
+		if (strpos($module_path, $module_ext) !== false) {
1231
+			// grab and shortcode file name from directory name and break apart at dots
1232
+			$module_file = explode('.', basename($module_path));
1233
+			// now we need to rebuild the shortcode path
1234
+			$module_path = explode(DS, $module_path);
1235
+			// remove last segment
1236
+			array_pop($module_path);
1237
+			// glue it back together
1238
+			$module_path = implode(DS, $module_path) . DS;
1239
+			// take first segment from file name pieces and sanitize it
1240
+			$module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1241
+			// ensure class prefix is added
1242
+			$module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1243
+		} else {
1244
+			// we need to generate the filename based off of the folder name
1245
+			// grab and sanitize module name
1246
+			$module = strtolower(basename($module_path));
1247
+			$module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1248
+			// like trailingslashit()
1249
+			$module_path = rtrim($module_path, DS) . DS;
1250
+			// create classname from module directory name
1251
+			$module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1252
+			// add class prefix
1253
+			$module_class = 'EED_' . $module;
1254
+		}
1255
+		// does the module exist ?
1256
+		if (! is_readable($module_path . DS . $module_class . $module_ext)) {
1257
+			$msg = sprintf(
1258
+				__(
1259
+					'The requested %s module file could not be found or is not readable due to file permissions.',
1260
+					'event_espresso'
1261
+				),
1262
+				$module
1263
+			);
1264
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1265
+			return false;
1266
+		}
1267
+		// load the module class file
1268
+		require_once($module_path . $module_class . $module_ext);
1269
+		// verify that class exists
1270
+		if (! class_exists($module_class)) {
1271
+			$msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1272
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1273
+			return false;
1274
+		}
1275
+		// add to array of registered modules
1276
+		EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1277
+		do_action(
1278
+			'AHEE__EE_Config__register_module__complete',
1279
+			$module_class,
1280
+			EE_Registry::instance()->modules->{$module_class}
1281
+		);
1282
+		return true;
1283
+	}
1284
+
1285
+
1286
+	/**
1287
+	 *    _initialize_shortcodes
1288
+	 *    allow shortcodes to set hooks for the rest of the system
1289
+	 *
1290
+	 * @access private
1291
+	 * @return void
1292
+	 */
1293
+	private function _initialize_shortcodes()
1294
+	{
1295
+		// cycle thru shortcode folders
1296
+		foreach (EE_Registry::instance()->shortcodes as $shortcode => $shortcode_path) {
1297
+			// add class prefix
1298
+			$shortcode_class = 'EES_' . $shortcode;
1299
+			// fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1300
+			// which set hooks ?
1301
+			if (is_admin()) {
1302
+				// fire immediately
1303
+				call_user_func(array($shortcode_class, 'set_hooks_admin'));
1304
+			} else {
1305
+				// delay until other systems are online
1306
+				add_action(
1307
+					'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
1308
+					array($shortcode_class, 'set_hooks')
1309
+				);
1310
+				// convert classname to UPPERCASE and create WP shortcode.
1311
+				$shortcode_tag = strtoupper($shortcode);
1312
+				// but first check if the shortcode has already been added before assigning 'fallback_shortcode_processor'
1313
+				if (! shortcode_exists($shortcode_tag)) {
1314
+					// NOTE: this shortcode declaration will get overridden if the shortcode is successfully detected in the post content in EE_Front_Controller->_initialize_shortcodes()
1315
+					add_shortcode($shortcode_tag, array($shortcode_class, 'fallback_shortcode_processor'));
1316
+				}
1317
+			}
1318
+		}
1319
+	}
1320
+
1321
+
1322
+	/**
1323
+	 *    _initialize_modules
1324
+	 *    allow modules to set hooks for the rest of the system
1325
+	 *
1326
+	 * @access private
1327
+	 * @return void
1328
+	 */
1329
+	private function _initialize_modules()
1330
+	{
1331
+		// cycle thru shortcode folders
1332
+		foreach (EE_Registry::instance()->modules as $module_class => $module_path) {
1333
+			// fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1334
+			// which set hooks ?
1335
+			if (is_admin()) {
1336
+				// fire immediately
1337
+				call_user_func(array($module_class, 'set_hooks_admin'));
1338
+			} else {
1339
+				// delay until other systems are online
1340
+				add_action(
1341
+					'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
1342
+					array($module_class, 'set_hooks')
1343
+				);
1344
+			}
1345
+		}
1346
+	}
1347
+
1348
+
1349
+	/**
1350
+	 *    register_route - adds module method routes to route_map
1351
+	 *
1352
+	 * @access    public
1353
+	 * @param    string $route       - "pretty" public alias for module method
1354
+	 * @param    string $module      - module name (classname without EED_ prefix)
1355
+	 * @param    string $method_name - the actual module method to be routed to
1356
+	 * @param    string $key         - url param key indicating a route is being called
1357
+	 * @return    bool
1358
+	 */
1359
+	public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee')
1360
+	{
1361
+		do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1362
+		$module       = str_replace('EED_', '', $module);
1363
+		$module_class = 'EED_' . $module;
1364
+		if (! isset(EE_Registry::instance()->modules->{$module_class})) {
1365
+			$msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module);
1366
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1367
+			return false;
1368
+		}
1369
+		if (empty($route)) {
1370
+			$msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route);
1371
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1372
+			return false;
1373
+		}
1374
+		if (! method_exists('EED_' . $module, $method_name)) {
1375
+			$msg = sprintf(
1376
+				__('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1377
+				$route
1378
+			);
1379
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1380
+			return false;
1381
+		}
1382
+		EE_Config::$_module_route_map[$key][$route] = array('EED_' . $module, $method_name);
1383
+		return true;
1384
+	}
1385
+
1386
+
1387
+	/**
1388
+	 *    get_route - get module method route
1389
+	 *
1390
+	 * @access    public
1391
+	 * @param    string $route - "pretty" public alias for module method
1392
+	 * @param    string $key   - url param key indicating a route is being called
1393
+	 * @return    string
1394
+	 */
1395
+	public static function get_route($route = null, $key = 'ee')
1396
+	{
1397
+		do_action('AHEE__EE_Config__get_route__begin', $route);
1398
+		$route = (string)apply_filters('FHEE__EE_Config__get_route', $route);
1399
+		if (isset(EE_Config::$_module_route_map[$key][$route])) {
1400
+			return EE_Config::$_module_route_map[$key][$route];
1401
+		}
1402
+		return null;
1403
+	}
1404
+
1405
+
1406
+	/**
1407
+	 *    get_routes - get ALL module method routes
1408
+	 *
1409
+	 * @access    public
1410
+	 * @return    array
1411
+	 */
1412
+	public static function get_routes()
1413
+	{
1414
+		return EE_Config::$_module_route_map;
1415
+	}
1416
+
1417
+
1418
+	/**
1419
+	 *    register_forward - allows modules to forward request to another module for further processing
1420
+	 *
1421
+	 * @access    public
1422
+	 * @param    string       $route   - "pretty" public alias for module method
1423
+	 * @param    integer      $status  - integer value corresponding  to status constant strings set in module parent
1424
+	 *                                 class, allows different forwards to be served based on status
1425
+	 * @param    array|string $forward - function name or array( class, method )
1426
+	 * @param    string       $key     - url param key indicating a route is being called
1427
+	 * @return    bool
1428
+	 */
1429
+	public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee')
1430
+	{
1431
+		do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1432
+		if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1433
+			$msg = sprintf(
1434
+				__('The module route %s for this forward has not been registered.', 'event_espresso'),
1435
+				$route
1436
+			);
1437
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1438
+			return false;
1439
+		}
1440
+		if (empty($forward)) {
1441
+			$msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route);
1442
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1443
+			return false;
1444
+		}
1445
+		if (is_array($forward)) {
1446
+			if (! isset($forward[1])) {
1447
+				$msg = sprintf(
1448
+					__('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1449
+					$route
1450
+				);
1451
+				EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1452
+				return false;
1453
+			}
1454
+			if (! method_exists($forward[0], $forward[1])) {
1455
+				$msg = sprintf(
1456
+					__('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1457
+					$forward[1],
1458
+					$route
1459
+				);
1460
+				EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1461
+				return false;
1462
+			}
1463
+		} else if (! function_exists($forward)) {
1464
+			$msg = sprintf(
1465
+				__('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1466
+				$forward,
1467
+				$route
1468
+			);
1469
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1470
+			return false;
1471
+		}
1472
+		EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward;
1473
+		return true;
1474
+	}
1475
+
1476
+
1477
+	/**
1478
+	 *    get_forward - get forwarding route
1479
+	 *
1480
+	 * @access    public
1481
+	 * @param    string  $route  - "pretty" public alias for module method
1482
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1483
+	 *                           allows different forwards to be served based on status
1484
+	 * @param    string  $key    - url param key indicating a route is being called
1485
+	 * @return    string
1486
+	 */
1487
+	public static function get_forward($route = null, $status = 0, $key = 'ee')
1488
+	{
1489
+		do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1490
+		if (isset(EE_Config::$_module_forward_map[$key][$route][$status])) {
1491
+			return apply_filters(
1492
+				'FHEE__EE_Config__get_forward',
1493
+				EE_Config::$_module_forward_map[$key][$route][$status],
1494
+				$route,
1495
+				$status
1496
+			);
1497
+		}
1498
+		return null;
1499
+	}
1500
+
1501
+
1502
+	/**
1503
+	 *    register_forward - allows modules to specify different view templates for different method routes and status
1504
+	 *    results
1505
+	 *
1506
+	 * @access    public
1507
+	 * @param    string  $route  - "pretty" public alias for module method
1508
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1509
+	 *                           allows different views to be served based on status
1510
+	 * @param    string  $view
1511
+	 * @param    string  $key    - url param key indicating a route is being called
1512
+	 * @return    bool
1513
+	 */
1514
+	public static function register_view($route = null, $status = 0, $view = null, $key = 'ee')
1515
+	{
1516
+		do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1517
+		if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1518
+			$msg = sprintf(
1519
+				__('The module route %s for this view has not been registered.', 'event_espresso'),
1520
+				$route
1521
+			);
1522
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1523
+			return false;
1524
+		}
1525
+		if (! is_readable($view)) {
1526
+			$msg = sprintf(
1527
+				__(
1528
+					'The %s view file could not be found or is not readable due to file permissions.',
1529
+					'event_espresso'
1530
+				),
1531
+				$view
1532
+			);
1533
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1534
+			return false;
1535
+		}
1536
+		EE_Config::$_module_view_map[$key][$route][absint($status)] = $view;
1537
+		return true;
1538
+	}
1539
+
1540
+
1541
+	/**
1542
+	 *    get_view - get view for route and status
1543
+	 *
1544
+	 * @access    public
1545
+	 * @param    string  $route  - "pretty" public alias for module method
1546
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1547
+	 *                           allows different views to be served based on status
1548
+	 * @param    string  $key    - url param key indicating a route is being called
1549
+	 * @return    string
1550
+	 */
1551
+	public static function get_view($route = null, $status = 0, $key = 'ee')
1552
+	{
1553
+		do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1554
+		if (isset(EE_Config::$_module_view_map[$key][$route][$status])) {
1555
+			return apply_filters(
1556
+				'FHEE__EE_Config__get_view',
1557
+				EE_Config::$_module_view_map[$key][$route][$status],
1558
+				$route,
1559
+				$status
1560
+			);
1561
+		}
1562
+		return null;
1563
+	}
1564
+
1565
+
1566
+	public function update_addon_option_names()
1567
+	{
1568
+		update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names);
1569
+	}
1570
+
1571
+
1572
+	public function shutdown()
1573
+	{
1574
+		$this->update_addon_option_names();
1575
+	}
1576 1576
 
1577 1577
 
1578 1578
 }
@@ -1586,104 +1586,104 @@  discard block
 block discarded – undo
1586 1586
 class EE_Config_Base
1587 1587
 {
1588 1588
 
1589
-    /**
1590
-     * Utility function for escaping the value of a property and returning.
1591
-     *
1592
-     * @param string $property property name (checks to see if exists).
1593
-     * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1594
-     * @throws \EE_Error
1595
-     */
1596
-    public function get_pretty($property)
1597
-    {
1598
-        if (! property_exists($this, $property)) {
1599
-            throw new EE_Error(
1600
-                sprintf(
1601
-                    __(
1602
-                        '%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.',
1603
-                        'event_espresso'
1604
-                    ),
1605
-                    get_class($this),
1606
-                    $property
1607
-                )
1608
-            );
1609
-        }
1610
-        //just handling escaping of strings for now.
1611
-        if (is_string($this->{$property})) {
1612
-            return stripslashes($this->{$property});
1613
-        }
1614
-        return $this->{$property};
1615
-    }
1616
-
1617
-
1618
-    public function populate()
1619
-    {
1620
-        //grab defaults via a new instance of this class.
1621
-        $class_name = get_class($this);
1622
-        $defaults   = new $class_name;
1623
-        //loop through the properties for this class and see if they are set.  If they are NOT, then grab the
1624
-        //default from our $defaults object.
1625
-        foreach (get_object_vars($defaults) as $property => $value) {
1626
-            if ($this->{$property} === null) {
1627
-                $this->{$property} = $value;
1628
-            }
1629
-        }
1630
-        //cleanup
1631
-        unset($defaults);
1632
-    }
1633
-
1634
-
1635
-    /**
1636
-     *        @ override magic methods
1637
-     *        @ return void
1638
-     */
1589
+	/**
1590
+	 * Utility function for escaping the value of a property and returning.
1591
+	 *
1592
+	 * @param string $property property name (checks to see if exists).
1593
+	 * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1594
+	 * @throws \EE_Error
1595
+	 */
1596
+	public function get_pretty($property)
1597
+	{
1598
+		if (! property_exists($this, $property)) {
1599
+			throw new EE_Error(
1600
+				sprintf(
1601
+					__(
1602
+						'%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.',
1603
+						'event_espresso'
1604
+					),
1605
+					get_class($this),
1606
+					$property
1607
+				)
1608
+			);
1609
+		}
1610
+		//just handling escaping of strings for now.
1611
+		if (is_string($this->{$property})) {
1612
+			return stripslashes($this->{$property});
1613
+		}
1614
+		return $this->{$property};
1615
+	}
1616
+
1617
+
1618
+	public function populate()
1619
+	{
1620
+		//grab defaults via a new instance of this class.
1621
+		$class_name = get_class($this);
1622
+		$defaults   = new $class_name;
1623
+		//loop through the properties for this class and see if they are set.  If they are NOT, then grab the
1624
+		//default from our $defaults object.
1625
+		foreach (get_object_vars($defaults) as $property => $value) {
1626
+			if ($this->{$property} === null) {
1627
+				$this->{$property} = $value;
1628
+			}
1629
+		}
1630
+		//cleanup
1631
+		unset($defaults);
1632
+	}
1633
+
1634
+
1635
+	/**
1636
+	 *        @ override magic methods
1637
+	 *        @ return void
1638
+	 */
1639 1639
 //	public function __get($a) { return apply_filters('FHEE__'.get_class($this).'__get__'.$a,$this->{$a}); }
1640 1640
 //	public function __set($a,$b) { return apply_filters('FHEE__'.get_class($this).'__set__'.$a, $this->{$a} = $b ); }
1641
-    /**
1642
-     *        __isset
1643
-     *
1644
-     * @param $a
1645
-     * @return bool
1646
-     */
1647
-    public function __isset($a)
1648
-    {
1649
-        return false;
1650
-    }
1651
-
1652
-
1653
-    /**
1654
-     *        __unset
1655
-     *
1656
-     * @param $a
1657
-     * @return bool
1658
-     */
1659
-    public function __unset($a)
1660
-    {
1661
-        return false;
1662
-    }
1663
-
1664
-
1665
-    /**
1666
-     *        __clone
1667
-     */
1668
-    public function __clone()
1669
-    {
1670
-    }
1671
-
1672
-
1673
-    /**
1674
-     *        __wakeup
1675
-     */
1676
-    public function __wakeup()
1677
-    {
1678
-    }
1679
-
1680
-
1681
-    /**
1682
-     *        __destruct
1683
-     */
1684
-    public function __destruct()
1685
-    {
1686
-    }
1641
+	/**
1642
+	 *        __isset
1643
+	 *
1644
+	 * @param $a
1645
+	 * @return bool
1646
+	 */
1647
+	public function __isset($a)
1648
+	{
1649
+		return false;
1650
+	}
1651
+
1652
+
1653
+	/**
1654
+	 *        __unset
1655
+	 *
1656
+	 * @param $a
1657
+	 * @return bool
1658
+	 */
1659
+	public function __unset($a)
1660
+	{
1661
+		return false;
1662
+	}
1663
+
1664
+
1665
+	/**
1666
+	 *        __clone
1667
+	 */
1668
+	public function __clone()
1669
+	{
1670
+	}
1671
+
1672
+
1673
+	/**
1674
+	 *        __wakeup
1675
+	 */
1676
+	public function __wakeup()
1677
+	{
1678
+	}
1679
+
1680
+
1681
+	/**
1682
+	 *        __destruct
1683
+	 */
1684
+	public function __destruct()
1685
+	{
1686
+	}
1687 1687
 }
1688 1688
 
1689 1689
 
@@ -1693,288 +1693,288 @@  discard block
 block discarded – undo
1693 1693
 class EE_Core_Config extends EE_Config_Base
1694 1694
 {
1695 1695
 
1696
-    public $current_blog_id;
1697
-
1698
-    public $ee_ueip_optin;
1699
-
1700
-    public $ee_ueip_has_notified;
1701
-
1702
-    /**
1703
-     * Not to be confused with the 4 critical page variables (See
1704
-     * get_critical_pages_array()), this is just an array of wp posts that have EE
1705
-     * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode
1706
-     * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array.
1707
-     *
1708
-     * @var array
1709
-     */
1710
-    public $post_shortcodes;
1711
-
1712
-    public $module_route_map;
1713
-
1714
-    public $module_forward_map;
1715
-
1716
-    public $module_view_map;
1717
-
1718
-    /**
1719
-     * The next 4 vars are the IDs of critical EE pages.
1720
-     *
1721
-     * @var int
1722
-     */
1723
-    public $reg_page_id;
1724
-
1725
-    public $txn_page_id;
1726
-
1727
-    public $thank_you_page_id;
1728
-
1729
-    public $cancel_page_id;
1730
-
1731
-    /**
1732
-     * The next 4 vars are the URLs of critical EE pages.
1733
-     *
1734
-     * @var int
1735
-     */
1736
-    public $reg_page_url;
1737
-
1738
-    public $txn_page_url;
1739
-
1740
-    public $thank_you_page_url;
1741
-
1742
-    public $cancel_page_url;
1743
-
1744
-    /**
1745
-     * The next vars relate to the custom slugs for EE CPT routes
1746
-     */
1747
-    public $event_cpt_slug;
1748
-
1749
-
1750
-    /**
1751
-     * This caches the _ee_ueip_option in case this config is reset in the same
1752
-     * request across blog switches in a multisite context.
1753
-     * Avoids extra queries to the db for this option.
1754
-     *
1755
-     * @var bool
1756
-     */
1757
-    public static $ee_ueip_option;
1758
-
1759
-
1760
-    /**
1761
-     *    class constructor
1762
-     *
1763
-     * @access    public
1764
-     */
1765
-    public function __construct()
1766
-    {
1767
-        // set default organization settings
1768
-        $this->current_blog_id      = get_current_blog_id();
1769
-        $this->current_blog_id      = $this->current_blog_id === null ? 1 : $this->current_blog_id;
1770
-        $this->ee_ueip_optin        = $this->_get_main_ee_ueip_optin();
1771
-        $this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true;
1772
-        $this->post_shortcodes      = array();
1773
-        $this->module_route_map     = array();
1774
-        $this->module_forward_map   = array();
1775
-        $this->module_view_map      = array();
1776
-        // critical EE page IDs
1777
-        $this->reg_page_id       = 0;
1778
-        $this->txn_page_id       = 0;
1779
-        $this->thank_you_page_id = 0;
1780
-        $this->cancel_page_id    = 0;
1781
-        // critical EE page URLs
1782
-        $this->reg_page_url       = '';
1783
-        $this->txn_page_url       = '';
1784
-        $this->thank_you_page_url = '';
1785
-        $this->cancel_page_url    = '';
1786
-        //cpt slugs
1787
-        $this->event_cpt_slug = __('events', 'event_espresso');
1788
-        //ueip constant check
1789
-        if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) {
1790
-            $this->ee_ueip_optin        = false;
1791
-            $this->ee_ueip_has_notified = true;
1792
-        }
1793
-    }
1794
-
1795
-
1796
-    /**
1797
-     * @return array
1798
-     */
1799
-    public function get_critical_pages_array()
1800
-    {
1801
-        return array(
1802
-            $this->reg_page_id,
1803
-            $this->txn_page_id,
1804
-            $this->thank_you_page_id,
1805
-            $this->cancel_page_id,
1806
-        );
1807
-    }
1808
-
1809
-
1810
-    /**
1811
-     * @return array
1812
-     */
1813
-    public function get_critical_pages_shortcodes_array()
1814
-    {
1815
-        return array(
1816
-            $this->reg_page_id       => 'ESPRESSO_CHECKOUT',
1817
-            $this->txn_page_id       => 'ESPRESSO_TXN_PAGE',
1818
-            $this->thank_you_page_id => 'ESPRESSO_THANK_YOU',
1819
-            $this->cancel_page_id    => 'ESPRESSO_CANCELLED',
1820
-        );
1821
-    }
1822
-
1823
-
1824
-    /**
1825
-     *  gets/returns URL for EE reg_page
1826
-     *
1827
-     * @access    public
1828
-     * @return    string
1829
-     */
1830
-    public function reg_page_url()
1831
-    {
1832
-        if (! $this->reg_page_url) {
1833
-            $this->reg_page_url = add_query_arg(
1834
-                                      array('uts' => time()),
1835
-                                      get_permalink($this->reg_page_id)
1836
-                                  ) . '#checkout';
1837
-        }
1838
-        return $this->reg_page_url;
1839
-    }
1840
-
1841
-
1842
-    /**
1843
-     *  gets/returns URL for EE txn_page
1844
-     *
1845
-     * @param array $query_args like what gets passed to
1846
-     *                          add_query_arg() as the first argument
1847
-     * @access    public
1848
-     * @return    string
1849
-     */
1850
-    public function txn_page_url($query_args = array())
1851
-    {
1852
-        if (! $this->txn_page_url) {
1853
-            $this->txn_page_url = get_permalink($this->txn_page_id);
1854
-        }
1855
-        if ($query_args) {
1856
-            return add_query_arg($query_args, $this->txn_page_url);
1857
-        } else {
1858
-            return $this->txn_page_url;
1859
-        }
1860
-    }
1861
-
1862
-
1863
-    /**
1864
-     *  gets/returns URL for EE thank_you_page
1865
-     *
1866
-     * @param array $query_args like what gets passed to
1867
-     *                          add_query_arg() as the first argument
1868
-     * @access    public
1869
-     * @return    string
1870
-     */
1871
-    public function thank_you_page_url($query_args = array())
1872
-    {
1873
-        if (! $this->thank_you_page_url) {
1874
-            $this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1875
-        }
1876
-        if ($query_args) {
1877
-            return add_query_arg($query_args, $this->thank_you_page_url);
1878
-        } else {
1879
-            return $this->thank_you_page_url;
1880
-        }
1881
-    }
1882
-
1883
-
1884
-    /**
1885
-     *  gets/returns URL for EE cancel_page
1886
-     *
1887
-     * @access    public
1888
-     * @return    string
1889
-     */
1890
-    public function cancel_page_url()
1891
-    {
1892
-        if (! $this->cancel_page_url) {
1893
-            $this->cancel_page_url = get_permalink($this->cancel_page_id);
1894
-        }
1895
-        return $this->cancel_page_url;
1896
-    }
1897
-
1898
-
1899
-    /**
1900
-     * Resets all critical page urls to their original state.  Used primarily by the __sleep() magic method currently.
1901
-     *
1902
-     * @since 4.7.5
1903
-     */
1904
-    protected function _reset_urls()
1905
-    {
1906
-        $this->reg_page_url       = '';
1907
-        $this->txn_page_url       = '';
1908
-        $this->cancel_page_url    = '';
1909
-        $this->thank_you_page_url = '';
1910
-    }
1911
-
1912
-
1913
-    /**
1914
-     * Used to return what the optin value is set for the EE User Experience Program.
1915
-     * This accounts for multisite and this value being requested for a subsite.  In multisite, the value is set
1916
-     * on the main site only.
1917
-     *
1918
-     * @return mixed|void
1919
-     */
1920
-    protected function _get_main_ee_ueip_optin()
1921
-    {
1922
-        //if this is the main site then we can just bypass our direct query.
1923
-        if (is_main_site()) {
1924
-            return get_option('ee_ueip_optin', false);
1925
-        }
1926
-
1927
-        //is this already cached for this request?  If so use it.
1928
-        if (! empty(EE_Core_Config::$ee_ueip_option)) {
1929
-            return EE_Core_Config::$ee_ueip_option;
1930
-        }
1931
-
1932
-        global $wpdb;
1933
-        $current_network_main_site = is_multisite() ? get_current_site() : null;
1934
-        $current_main_site_id      = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1935
-        $option                    = 'ee_ueip_optin';
1936
-
1937
-        //set correct table for query
1938
-        $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1939
-
1940
-
1941
-        //rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
1942
-        //get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be
1943
-        //re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1944
-        //this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1945
-        //for the purpose of caching.
1946
-        $pre = apply_filters('pre_option_' . $option, false, $option);
1947
-        if (false !== $pre) {
1948
-            EE_Core_Config::$ee_ueip_option = $pre;
1949
-            return EE_Core_Config::$ee_ueip_option;
1950
-        }
1951
-
1952
-        $row = $wpdb->get_row($wpdb->prepare("SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1",
1953
-            $option));
1954
-        if (is_object($row)) {
1955
-            $value = $row->option_value;
1956
-        } else { //option does not exist so use default.
1957
-            return apply_filters('default_option_' . $option, false, $option);
1958
-        }
1959
-
1960
-        EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
1961
-        return EE_Core_Config::$ee_ueip_option;
1962
-    }
1963
-
1964
-
1965
-    /**
1966
-     * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values
1967
-     * on the object.
1968
-     *
1969
-     * @return array
1970
-     */
1971
-    public function __sleep()
1972
-    {
1973
-        //reset all url properties
1974
-        $this->_reset_urls();
1975
-        //return what to save to db
1976
-        return array_keys(get_object_vars($this));
1977
-    }
1696
+	public $current_blog_id;
1697
+
1698
+	public $ee_ueip_optin;
1699
+
1700
+	public $ee_ueip_has_notified;
1701
+
1702
+	/**
1703
+	 * Not to be confused with the 4 critical page variables (See
1704
+	 * get_critical_pages_array()), this is just an array of wp posts that have EE
1705
+	 * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode
1706
+	 * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array.
1707
+	 *
1708
+	 * @var array
1709
+	 */
1710
+	public $post_shortcodes;
1711
+
1712
+	public $module_route_map;
1713
+
1714
+	public $module_forward_map;
1715
+
1716
+	public $module_view_map;
1717
+
1718
+	/**
1719
+	 * The next 4 vars are the IDs of critical EE pages.
1720
+	 *
1721
+	 * @var int
1722
+	 */
1723
+	public $reg_page_id;
1724
+
1725
+	public $txn_page_id;
1726
+
1727
+	public $thank_you_page_id;
1728
+
1729
+	public $cancel_page_id;
1730
+
1731
+	/**
1732
+	 * The next 4 vars are the URLs of critical EE pages.
1733
+	 *
1734
+	 * @var int
1735
+	 */
1736
+	public $reg_page_url;
1737
+
1738
+	public $txn_page_url;
1739
+
1740
+	public $thank_you_page_url;
1741
+
1742
+	public $cancel_page_url;
1743
+
1744
+	/**
1745
+	 * The next vars relate to the custom slugs for EE CPT routes
1746
+	 */
1747
+	public $event_cpt_slug;
1748
+
1749
+
1750
+	/**
1751
+	 * This caches the _ee_ueip_option in case this config is reset in the same
1752
+	 * request across blog switches in a multisite context.
1753
+	 * Avoids extra queries to the db for this option.
1754
+	 *
1755
+	 * @var bool
1756
+	 */
1757
+	public static $ee_ueip_option;
1758
+
1759
+
1760
+	/**
1761
+	 *    class constructor
1762
+	 *
1763
+	 * @access    public
1764
+	 */
1765
+	public function __construct()
1766
+	{
1767
+		// set default organization settings
1768
+		$this->current_blog_id      = get_current_blog_id();
1769
+		$this->current_blog_id      = $this->current_blog_id === null ? 1 : $this->current_blog_id;
1770
+		$this->ee_ueip_optin        = $this->_get_main_ee_ueip_optin();
1771
+		$this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true;
1772
+		$this->post_shortcodes      = array();
1773
+		$this->module_route_map     = array();
1774
+		$this->module_forward_map   = array();
1775
+		$this->module_view_map      = array();
1776
+		// critical EE page IDs
1777
+		$this->reg_page_id       = 0;
1778
+		$this->txn_page_id       = 0;
1779
+		$this->thank_you_page_id = 0;
1780
+		$this->cancel_page_id    = 0;
1781
+		// critical EE page URLs
1782
+		$this->reg_page_url       = '';
1783
+		$this->txn_page_url       = '';
1784
+		$this->thank_you_page_url = '';
1785
+		$this->cancel_page_url    = '';
1786
+		//cpt slugs
1787
+		$this->event_cpt_slug = __('events', 'event_espresso');
1788
+		//ueip constant check
1789
+		if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) {
1790
+			$this->ee_ueip_optin        = false;
1791
+			$this->ee_ueip_has_notified = true;
1792
+		}
1793
+	}
1794
+
1795
+
1796
+	/**
1797
+	 * @return array
1798
+	 */
1799
+	public function get_critical_pages_array()
1800
+	{
1801
+		return array(
1802
+			$this->reg_page_id,
1803
+			$this->txn_page_id,
1804
+			$this->thank_you_page_id,
1805
+			$this->cancel_page_id,
1806
+		);
1807
+	}
1808
+
1809
+
1810
+	/**
1811
+	 * @return array
1812
+	 */
1813
+	public function get_critical_pages_shortcodes_array()
1814
+	{
1815
+		return array(
1816
+			$this->reg_page_id       => 'ESPRESSO_CHECKOUT',
1817
+			$this->txn_page_id       => 'ESPRESSO_TXN_PAGE',
1818
+			$this->thank_you_page_id => 'ESPRESSO_THANK_YOU',
1819
+			$this->cancel_page_id    => 'ESPRESSO_CANCELLED',
1820
+		);
1821
+	}
1822
+
1823
+
1824
+	/**
1825
+	 *  gets/returns URL for EE reg_page
1826
+	 *
1827
+	 * @access    public
1828
+	 * @return    string
1829
+	 */
1830
+	public function reg_page_url()
1831
+	{
1832
+		if (! $this->reg_page_url) {
1833
+			$this->reg_page_url = add_query_arg(
1834
+									  array('uts' => time()),
1835
+									  get_permalink($this->reg_page_id)
1836
+								  ) . '#checkout';
1837
+		}
1838
+		return $this->reg_page_url;
1839
+	}
1840
+
1841
+
1842
+	/**
1843
+	 *  gets/returns URL for EE txn_page
1844
+	 *
1845
+	 * @param array $query_args like what gets passed to
1846
+	 *                          add_query_arg() as the first argument
1847
+	 * @access    public
1848
+	 * @return    string
1849
+	 */
1850
+	public function txn_page_url($query_args = array())
1851
+	{
1852
+		if (! $this->txn_page_url) {
1853
+			$this->txn_page_url = get_permalink($this->txn_page_id);
1854
+		}
1855
+		if ($query_args) {
1856
+			return add_query_arg($query_args, $this->txn_page_url);
1857
+		} else {
1858
+			return $this->txn_page_url;
1859
+		}
1860
+	}
1861
+
1862
+
1863
+	/**
1864
+	 *  gets/returns URL for EE thank_you_page
1865
+	 *
1866
+	 * @param array $query_args like what gets passed to
1867
+	 *                          add_query_arg() as the first argument
1868
+	 * @access    public
1869
+	 * @return    string
1870
+	 */
1871
+	public function thank_you_page_url($query_args = array())
1872
+	{
1873
+		if (! $this->thank_you_page_url) {
1874
+			$this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1875
+		}
1876
+		if ($query_args) {
1877
+			return add_query_arg($query_args, $this->thank_you_page_url);
1878
+		} else {
1879
+			return $this->thank_you_page_url;
1880
+		}
1881
+	}
1882
+
1883
+
1884
+	/**
1885
+	 *  gets/returns URL for EE cancel_page
1886
+	 *
1887
+	 * @access    public
1888
+	 * @return    string
1889
+	 */
1890
+	public function cancel_page_url()
1891
+	{
1892
+		if (! $this->cancel_page_url) {
1893
+			$this->cancel_page_url = get_permalink($this->cancel_page_id);
1894
+		}
1895
+		return $this->cancel_page_url;
1896
+	}
1897
+
1898
+
1899
+	/**
1900
+	 * Resets all critical page urls to their original state.  Used primarily by the __sleep() magic method currently.
1901
+	 *
1902
+	 * @since 4.7.5
1903
+	 */
1904
+	protected function _reset_urls()
1905
+	{
1906
+		$this->reg_page_url       = '';
1907
+		$this->txn_page_url       = '';
1908
+		$this->cancel_page_url    = '';
1909
+		$this->thank_you_page_url = '';
1910
+	}
1911
+
1912
+
1913
+	/**
1914
+	 * Used to return what the optin value is set for the EE User Experience Program.
1915
+	 * This accounts for multisite and this value being requested for a subsite.  In multisite, the value is set
1916
+	 * on the main site only.
1917
+	 *
1918
+	 * @return mixed|void
1919
+	 */
1920
+	protected function _get_main_ee_ueip_optin()
1921
+	{
1922
+		//if this is the main site then we can just bypass our direct query.
1923
+		if (is_main_site()) {
1924
+			return get_option('ee_ueip_optin', false);
1925
+		}
1926
+
1927
+		//is this already cached for this request?  If so use it.
1928
+		if (! empty(EE_Core_Config::$ee_ueip_option)) {
1929
+			return EE_Core_Config::$ee_ueip_option;
1930
+		}
1931
+
1932
+		global $wpdb;
1933
+		$current_network_main_site = is_multisite() ? get_current_site() : null;
1934
+		$current_main_site_id      = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1935
+		$option                    = 'ee_ueip_optin';
1936
+
1937
+		//set correct table for query
1938
+		$table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1939
+
1940
+
1941
+		//rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
1942
+		//get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be
1943
+		//re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1944
+		//this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1945
+		//for the purpose of caching.
1946
+		$pre = apply_filters('pre_option_' . $option, false, $option);
1947
+		if (false !== $pre) {
1948
+			EE_Core_Config::$ee_ueip_option = $pre;
1949
+			return EE_Core_Config::$ee_ueip_option;
1950
+		}
1951
+
1952
+		$row = $wpdb->get_row($wpdb->prepare("SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1",
1953
+			$option));
1954
+		if (is_object($row)) {
1955
+			$value = $row->option_value;
1956
+		} else { //option does not exist so use default.
1957
+			return apply_filters('default_option_' . $option, false, $option);
1958
+		}
1959
+
1960
+		EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
1961
+		return EE_Core_Config::$ee_ueip_option;
1962
+	}
1963
+
1964
+
1965
+	/**
1966
+	 * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values
1967
+	 * on the object.
1968
+	 *
1969
+	 * @return array
1970
+	 */
1971
+	public function __sleep()
1972
+	{
1973
+		//reset all url properties
1974
+		$this->_reset_urls();
1975
+		//return what to save to db
1976
+		return array_keys(get_object_vars($this));
1977
+	}
1978 1978
 
1979 1979
 }
1980 1980
 
@@ -1985,154 +1985,154 @@  discard block
 block discarded – undo
1985 1985
 class EE_Organization_Config extends EE_Config_Base
1986 1986
 {
1987 1987
 
1988
-    /**
1989
-     * @var string $name
1990
-     * eg EE4.1
1991
-     */
1992
-    public $name;
1993
-
1994
-    /**
1995
-     * @var string $address_1
1996
-     * eg 123 Onna Road
1997
-     */
1998
-    public $address_1;
1999
-
2000
-    /**
2001
-     * @var string $address_2
2002
-     * eg PO Box 123
2003
-     */
2004
-    public $address_2;
2005
-
2006
-    /**
2007
-     * @var string $city
2008
-     * eg Inna City
2009
-     */
2010
-    public $city;
2011
-
2012
-    /**
2013
-     * @var int $STA_ID
2014
-     * eg 4
2015
-     */
2016
-    public $STA_ID;
2017
-
2018
-    /**
2019
-     * @var string $CNT_ISO
2020
-     * eg US
2021
-     */
2022
-    public $CNT_ISO;
2023
-
2024
-    /**
2025
-     * @var string $zip
2026
-     * eg 12345  or V1A 2B3
2027
-     */
2028
-    public $zip;
2029
-
2030
-    /**
2031
-     * @var string $email
2032
-     * eg [email protected]
2033
-     */
2034
-    public $email;
2035
-
2036
-
2037
-    /**
2038
-     * @var string $phone
2039
-     * eg. 111-111-1111
2040
-     */
2041
-    public $phone;
2042
-
2043
-
2044
-    /**
2045
-     * @var string $vat
2046
-     * VAT/Tax Number
2047
-     */
2048
-    public $vat;
2049
-
2050
-    /**
2051
-     * @var string $logo_url
2052
-     * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg
2053
-     */
2054
-    public $logo_url;
2055
-
2056
-
2057
-    /**
2058
-     * The below are all various properties for holding links to organization social network profiles
2059
-     *
2060
-     * @var string
2061
-     */
2062
-    /**
2063
-     * facebook (facebook.com/profile.name)
2064
-     *
2065
-     * @var string
2066
-     */
2067
-    public $facebook;
2068
-
2069
-
2070
-    /**
2071
-     * twitter (twitter.com/twitter_handle)
2072
-     *
2073
-     * @var string
2074
-     */
2075
-    public $twitter;
2076
-
2077
-
2078
-    /**
2079
-     * linkedin (linkedin.com/in/profile_name)
2080
-     *
2081
-     * @var string
2082
-     */
2083
-    public $linkedin;
2084
-
2085
-
2086
-    /**
2087
-     * pinterest (www.pinterest.com/profile_name)
2088
-     *
2089
-     * @var string
2090
-     */
2091
-    public $pinterest;
2092
-
2093
-
2094
-    /**
2095
-     * google+ (google.com/+profileName)
2096
-     *
2097
-     * @var string
2098
-     */
2099
-    public $google;
2100
-
2101
-
2102
-    /**
2103
-     * instagram (instagram.com/handle)
2104
-     *
2105
-     * @var string
2106
-     */
2107
-    public $instagram;
2108
-
2109
-
2110
-    /**
2111
-     *    class constructor
2112
-     *
2113
-     * @access    public
2114
-     */
2115
-    public function __construct()
2116
-    {
2117
-        // set default organization settings
2118
-        $this->name      = get_bloginfo('name');
2119
-        $this->address_1 = '123 Onna Road';
2120
-        $this->address_2 = 'PO Box 123';
2121
-        $this->city      = 'Inna City';
2122
-        $this->STA_ID    = 4;
2123
-        $this->CNT_ISO   = 'US';
2124
-        $this->zip       = '12345';
2125
-        $this->email     = get_bloginfo('admin_email');
2126
-        $this->phone     = '';
2127
-        $this->vat       = '123456789';
2128
-        $this->logo_url  = '';
2129
-        $this->facebook  = '';
2130
-        $this->twitter   = '';
2131
-        $this->linkedin  = '';
2132
-        $this->pinterest = '';
2133
-        $this->google    = '';
2134
-        $this->instagram = '';
2135
-    }
1988
+	/**
1989
+	 * @var string $name
1990
+	 * eg EE4.1
1991
+	 */
1992
+	public $name;
1993
+
1994
+	/**
1995
+	 * @var string $address_1
1996
+	 * eg 123 Onna Road
1997
+	 */
1998
+	public $address_1;
1999
+
2000
+	/**
2001
+	 * @var string $address_2
2002
+	 * eg PO Box 123
2003
+	 */
2004
+	public $address_2;
2005
+
2006
+	/**
2007
+	 * @var string $city
2008
+	 * eg Inna City
2009
+	 */
2010
+	public $city;
2011
+
2012
+	/**
2013
+	 * @var int $STA_ID
2014
+	 * eg 4
2015
+	 */
2016
+	public $STA_ID;
2017
+
2018
+	/**
2019
+	 * @var string $CNT_ISO
2020
+	 * eg US
2021
+	 */
2022
+	public $CNT_ISO;
2023
+
2024
+	/**
2025
+	 * @var string $zip
2026
+	 * eg 12345  or V1A 2B3
2027
+	 */
2028
+	public $zip;
2029
+
2030
+	/**
2031
+	 * @var string $email
2032
+	 * eg [email protected]
2033
+	 */
2034
+	public $email;
2035
+
2036
+
2037
+	/**
2038
+	 * @var string $phone
2039
+	 * eg. 111-111-1111
2040
+	 */
2041
+	public $phone;
2042
+
2043
+
2044
+	/**
2045
+	 * @var string $vat
2046
+	 * VAT/Tax Number
2047
+	 */
2048
+	public $vat;
2049
+
2050
+	/**
2051
+	 * @var string $logo_url
2052
+	 * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg
2053
+	 */
2054
+	public $logo_url;
2055
+
2056
+
2057
+	/**
2058
+	 * The below are all various properties for holding links to organization social network profiles
2059
+	 *
2060
+	 * @var string
2061
+	 */
2062
+	/**
2063
+	 * facebook (facebook.com/profile.name)
2064
+	 *
2065
+	 * @var string
2066
+	 */
2067
+	public $facebook;
2068
+
2069
+
2070
+	/**
2071
+	 * twitter (twitter.com/twitter_handle)
2072
+	 *
2073
+	 * @var string
2074
+	 */
2075
+	public $twitter;
2076
+
2077
+
2078
+	/**
2079
+	 * linkedin (linkedin.com/in/profile_name)
2080
+	 *
2081
+	 * @var string
2082
+	 */
2083
+	public $linkedin;
2084
+
2085
+
2086
+	/**
2087
+	 * pinterest (www.pinterest.com/profile_name)
2088
+	 *
2089
+	 * @var string
2090
+	 */
2091
+	public $pinterest;
2092
+
2093
+
2094
+	/**
2095
+	 * google+ (google.com/+profileName)
2096
+	 *
2097
+	 * @var string
2098
+	 */
2099
+	public $google;
2100
+
2101
+
2102
+	/**
2103
+	 * instagram (instagram.com/handle)
2104
+	 *
2105
+	 * @var string
2106
+	 */
2107
+	public $instagram;
2108
+
2109
+
2110
+	/**
2111
+	 *    class constructor
2112
+	 *
2113
+	 * @access    public
2114
+	 */
2115
+	public function __construct()
2116
+	{
2117
+		// set default organization settings
2118
+		$this->name      = get_bloginfo('name');
2119
+		$this->address_1 = '123 Onna Road';
2120
+		$this->address_2 = 'PO Box 123';
2121
+		$this->city      = 'Inna City';
2122
+		$this->STA_ID    = 4;
2123
+		$this->CNT_ISO   = 'US';
2124
+		$this->zip       = '12345';
2125
+		$this->email     = get_bloginfo('admin_email');
2126
+		$this->phone     = '';
2127
+		$this->vat       = '123456789';
2128
+		$this->logo_url  = '';
2129
+		$this->facebook  = '';
2130
+		$this->twitter   = '';
2131
+		$this->linkedin  = '';
2132
+		$this->pinterest = '';
2133
+		$this->google    = '';
2134
+		$this->instagram = '';
2135
+	}
2136 2136
 
2137 2137
 }
2138 2138
 
@@ -2143,115 +2143,115 @@  discard block
 block discarded – undo
2143 2143
 class EE_Currency_Config extends EE_Config_Base
2144 2144
 {
2145 2145
 
2146
-    /**
2147
-     * @var string $code
2148
-     * eg 'US'
2149
-     */
2150
-    public $code;
2151
-
2152
-    /**
2153
-     * @var string $name
2154
-     * eg 'Dollar'
2155
-     */
2156
-    public $name;
2157
-
2158
-    /**
2159
-     * plural name
2160
-     *
2161
-     * @var string $plural
2162
-     * eg 'Dollars'
2163
-     */
2164
-    public $plural;
2165
-
2166
-    /**
2167
-     * currency sign
2168
-     *
2169
-     * @var string $sign
2170
-     * eg '$'
2171
-     */
2172
-    public $sign;
2173
-
2174
-    /**
2175
-     * Whether the currency sign should come before the number or not
2176
-     *
2177
-     * @var boolean $sign_b4
2178
-     */
2179
-    public $sign_b4;
2180
-
2181
-    /**
2182
-     * How many digits should come after the decimal place
2183
-     *
2184
-     * @var int $dec_plc
2185
-     */
2186
-    public $dec_plc;
2187
-
2188
-    /**
2189
-     * Symbol to use for decimal mark
2190
-     *
2191
-     * @var string $dec_mrk
2192
-     * eg '.'
2193
-     */
2194
-    public $dec_mrk;
2195
-
2196
-    /**
2197
-     * Symbol to use for thousands
2198
-     *
2199
-     * @var string $thsnds
2200
-     * eg ','
2201
-     */
2202
-    public $thsnds;
2203
-
2204
-
2205
-    /**
2206
-     *    class constructor
2207
-     *
2208
-     * @access    public
2209
-     * @param string $CNT_ISO
2210
-     * @throws \EE_Error
2211
-     */
2212
-    public function __construct($CNT_ISO = '')
2213
-    {
2214
-        /** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */
2215
-        $table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
2216
-        // get country code from organization settings or use default
2217
-        $ORG_CNT = isset(EE_Registry::instance()->CFG->organization)
2218
-                   && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config
2219
-            ? EE_Registry::instance()->CFG->organization->CNT_ISO
2220
-            : '';
2221
-        // but override if requested
2222
-        $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT;
2223
-        // 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
2224
-        if (
2225
-            ! empty($CNT_ISO)
2226
-            && EE_Maintenance_Mode::instance()->models_can_query()
2227
-            && $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table())
2228
-        ) {
2229
-            // retrieve the country settings from the db, just in case they have been customized
2230
-            $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
2231
-            if ($country instanceof EE_Country) {
2232
-                $this->code    = $country->currency_code();    // currency code: USD, CAD, EUR
2233
-                $this->name    = $country->currency_name_single();    // Dollar
2234
-                $this->plural  = $country->currency_name_plural();    // Dollars
2235
-                $this->sign    = $country->currency_sign();            // currency sign: $
2236
-                $this->sign_b4 = $country->currency_sign_before();        // currency sign before or after: $TRUE  or  FALSE$
2237
-                $this->dec_plc = $country->currency_decimal_places();    // decimal places: 2 = 0.00  3 = 0.000
2238
-                $this->dec_mrk = $country->currency_decimal_mark();    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2239
-                $this->thsnds  = $country->currency_thousands_separator();    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2240
-            }
2241
-        }
2242
-        // fallback to hardcoded defaults, in case the above failed
2243
-        if (empty($this->code)) {
2244
-            // set default currency settings
2245
-            $this->code    = 'USD';    // currency code: USD, CAD, EUR
2246
-            $this->name    = __('Dollar', 'event_espresso');    // Dollar
2247
-            $this->plural  = __('Dollars', 'event_espresso');    // Dollars
2248
-            $this->sign    = '$';    // currency sign: $
2249
-            $this->sign_b4 = true;    // currency sign before or after: $TRUE  or  FALSE$
2250
-            $this->dec_plc = 2;    // decimal places: 2 = 0.00  3 = 0.000
2251
-            $this->dec_mrk = '.';    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2252
-            $this->thsnds  = ',';    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2253
-        }
2254
-    }
2146
+	/**
2147
+	 * @var string $code
2148
+	 * eg 'US'
2149
+	 */
2150
+	public $code;
2151
+
2152
+	/**
2153
+	 * @var string $name
2154
+	 * eg 'Dollar'
2155
+	 */
2156
+	public $name;
2157
+
2158
+	/**
2159
+	 * plural name
2160
+	 *
2161
+	 * @var string $plural
2162
+	 * eg 'Dollars'
2163
+	 */
2164
+	public $plural;
2165
+
2166
+	/**
2167
+	 * currency sign
2168
+	 *
2169
+	 * @var string $sign
2170
+	 * eg '$'
2171
+	 */
2172
+	public $sign;
2173
+
2174
+	/**
2175
+	 * Whether the currency sign should come before the number or not
2176
+	 *
2177
+	 * @var boolean $sign_b4
2178
+	 */
2179
+	public $sign_b4;
2180
+
2181
+	/**
2182
+	 * How many digits should come after the decimal place
2183
+	 *
2184
+	 * @var int $dec_plc
2185
+	 */
2186
+	public $dec_plc;
2187
+
2188
+	/**
2189
+	 * Symbol to use for decimal mark
2190
+	 *
2191
+	 * @var string $dec_mrk
2192
+	 * eg '.'
2193
+	 */
2194
+	public $dec_mrk;
2195
+
2196
+	/**
2197
+	 * Symbol to use for thousands
2198
+	 *
2199
+	 * @var string $thsnds
2200
+	 * eg ','
2201
+	 */
2202
+	public $thsnds;
2203
+
2204
+
2205
+	/**
2206
+	 *    class constructor
2207
+	 *
2208
+	 * @access    public
2209
+	 * @param string $CNT_ISO
2210
+	 * @throws \EE_Error
2211
+	 */
2212
+	public function __construct($CNT_ISO = '')
2213
+	{
2214
+		/** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */
2215
+		$table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
2216
+		// get country code from organization settings or use default
2217
+		$ORG_CNT = isset(EE_Registry::instance()->CFG->organization)
2218
+				   && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config
2219
+			? EE_Registry::instance()->CFG->organization->CNT_ISO
2220
+			: '';
2221
+		// but override if requested
2222
+		$CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT;
2223
+		// 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
2224
+		if (
2225
+			! empty($CNT_ISO)
2226
+			&& EE_Maintenance_Mode::instance()->models_can_query()
2227
+			&& $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table())
2228
+		) {
2229
+			// retrieve the country settings from the db, just in case they have been customized
2230
+			$country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
2231
+			if ($country instanceof EE_Country) {
2232
+				$this->code    = $country->currency_code();    // currency code: USD, CAD, EUR
2233
+				$this->name    = $country->currency_name_single();    // Dollar
2234
+				$this->plural  = $country->currency_name_plural();    // Dollars
2235
+				$this->sign    = $country->currency_sign();            // currency sign: $
2236
+				$this->sign_b4 = $country->currency_sign_before();        // currency sign before or after: $TRUE  or  FALSE$
2237
+				$this->dec_plc = $country->currency_decimal_places();    // decimal places: 2 = 0.00  3 = 0.000
2238
+				$this->dec_mrk = $country->currency_decimal_mark();    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2239
+				$this->thsnds  = $country->currency_thousands_separator();    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2240
+			}
2241
+		}
2242
+		// fallback to hardcoded defaults, in case the above failed
2243
+		if (empty($this->code)) {
2244
+			// set default currency settings
2245
+			$this->code    = 'USD';    // currency code: USD, CAD, EUR
2246
+			$this->name    = __('Dollar', 'event_espresso');    // Dollar
2247
+			$this->plural  = __('Dollars', 'event_espresso');    // Dollars
2248
+			$this->sign    = '$';    // currency sign: $
2249
+			$this->sign_b4 = true;    // currency sign before or after: $TRUE  or  FALSE$
2250
+			$this->dec_plc = 2;    // decimal places: 2 = 0.00  3 = 0.000
2251
+			$this->dec_mrk = '.';    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2252
+			$this->thsnds  = ',';    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2253
+		}
2254
+	}
2255 2255
 }
2256 2256
 
2257 2257
 
@@ -2261,195 +2261,195 @@  discard block
 block discarded – undo
2261 2261
 class EE_Registration_Config extends EE_Config_Base
2262 2262
 {
2263 2263
 
2264
-    /**
2265
-     * Default registration status
2266
-     *
2267
-     * @var string $default_STS_ID
2268
-     * eg 'RPP'
2269
-     */
2270
-    public $default_STS_ID;
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'
2339
-     */
2340
-    public $recaptcha_theme;
2341
-
2342
-    /**
2343
-     * ReCaptcha Type
2344
-     *
2345
-     * @var string $recaptcha_type
2346
-     *    options: 'audio', 'image'
2347
-     */
2348
-    public $recaptcha_type;
2349
-
2350
-    /**
2351
-     * ReCaptcha language
2352
-     *
2353
-     * @var string $recaptcha_language
2354
-     * eg 'en'
2355
-     */
2356
-    public $recaptcha_language;
2357
-
2358
-    /**
2359
-     * ReCaptcha public key
2360
-     *
2361
-     * @var string $recaptcha_publickey
2362
-     */
2363
-    public $recaptcha_publickey;
2364
-
2365
-    /**
2366
-     * ReCaptcha private key
2367
-     *
2368
-     * @var string $recaptcha_privatekey
2369
-     */
2370
-    public $recaptcha_privatekey;
2371
-
2372
-    /**
2373
-     * ReCaptcha width
2374
-     *
2375
-     * @var int $recaptcha_width
2376
-     * @deprecated
2377
-     */
2378
-    public $recaptcha_width;
2379
-
2380
-    /**
2381
-     * Whether or not invalid attempts to directly access the registration checkout page should be tracked.
2382
-     *
2383
-     * @var boolean $track_invalid_checkout_access
2384
-     */
2385
-    protected $track_invalid_checkout_access = true;
2386
-
2387
-
2388
-    /**
2389
-     *    class constructor
2390
-     *
2391
-     * @access    public
2392
-     */
2393
-    public function __construct()
2394
-    {
2395
-        // set default registration settings
2396
-        $this->default_STS_ID               = EEM_Registration::status_id_pending_payment;
2397
-        $this->email_validation_level       = 'wp_default';
2398
-        $this->show_pending_payment_options = true;
2399
-        $this->skip_reg_confirmation        = false;
2400
-        $this->reg_steps                    = array();
2401
-        $this->reg_confirmation_last        = false;
2402
-        $this->use_bot_trap                 = true;
2403
-        $this->use_encryption               = true;
2404
-        $this->use_captcha                  = false;
2405
-        $this->recaptcha_theme              = 'light';
2406
-        $this->recaptcha_type               = 'image';
2407
-        $this->recaptcha_language           = 'en';
2408
-        $this->recaptcha_publickey          = null;
2409
-        $this->recaptcha_privatekey         = null;
2410
-        $this->recaptcha_width              = 500;
2411
-    }
2412
-
2413
-
2414
-    /**
2415
-     * This is called by the config loader and hooks are initialized AFTER the config has been populated.
2416
-     *
2417
-     * @since 4.8.8.rc.019
2418
-     */
2419
-    public function do_hooks()
2420
-    {
2421
-        add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event'));
2422
-    }
2423
-
2424
-
2425
-    /**
2426
-     * @return void
2427
-     */
2428
-    public function set_default_reg_status_on_EEM_Event()
2429
-    {
2430
-        EEM_Event::set_default_reg_status($this->default_STS_ID);
2431
-    }
2432
-
2433
-
2434
-    /**
2435
-     * @return boolean
2436
-     */
2437
-    public function track_invalid_checkout_access()
2438
-    {
2439
-        return $this->track_invalid_checkout_access;
2440
-    }
2441
-
2442
-
2443
-    /**
2444
-     * @param boolean $track_invalid_checkout_access
2445
-     */
2446
-    public function set_track_invalid_checkout_access($track_invalid_checkout_access)
2447
-    {
2448
-        $this->track_invalid_checkout_access = filter_var(
2449
-            $track_invalid_checkout_access,
2450
-            FILTER_VALIDATE_BOOLEAN
2451
-        );
2452
-    }
2264
+	/**
2265
+	 * Default registration status
2266
+	 *
2267
+	 * @var string $default_STS_ID
2268
+	 * eg 'RPP'
2269
+	 */
2270
+	public $default_STS_ID;
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'
2339
+	 */
2340
+	public $recaptcha_theme;
2341
+
2342
+	/**
2343
+	 * ReCaptcha Type
2344
+	 *
2345
+	 * @var string $recaptcha_type
2346
+	 *    options: 'audio', 'image'
2347
+	 */
2348
+	public $recaptcha_type;
2349
+
2350
+	/**
2351
+	 * ReCaptcha language
2352
+	 *
2353
+	 * @var string $recaptcha_language
2354
+	 * eg 'en'
2355
+	 */
2356
+	public $recaptcha_language;
2357
+
2358
+	/**
2359
+	 * ReCaptcha public key
2360
+	 *
2361
+	 * @var string $recaptcha_publickey
2362
+	 */
2363
+	public $recaptcha_publickey;
2364
+
2365
+	/**
2366
+	 * ReCaptcha private key
2367
+	 *
2368
+	 * @var string $recaptcha_privatekey
2369
+	 */
2370
+	public $recaptcha_privatekey;
2371
+
2372
+	/**
2373
+	 * ReCaptcha width
2374
+	 *
2375
+	 * @var int $recaptcha_width
2376
+	 * @deprecated
2377
+	 */
2378
+	public $recaptcha_width;
2379
+
2380
+	/**
2381
+	 * Whether or not invalid attempts to directly access the registration checkout page should be tracked.
2382
+	 *
2383
+	 * @var boolean $track_invalid_checkout_access
2384
+	 */
2385
+	protected $track_invalid_checkout_access = true;
2386
+
2387
+
2388
+	/**
2389
+	 *    class constructor
2390
+	 *
2391
+	 * @access    public
2392
+	 */
2393
+	public function __construct()
2394
+	{
2395
+		// set default registration settings
2396
+		$this->default_STS_ID               = EEM_Registration::status_id_pending_payment;
2397
+		$this->email_validation_level       = 'wp_default';
2398
+		$this->show_pending_payment_options = true;
2399
+		$this->skip_reg_confirmation        = false;
2400
+		$this->reg_steps                    = array();
2401
+		$this->reg_confirmation_last        = false;
2402
+		$this->use_bot_trap                 = true;
2403
+		$this->use_encryption               = true;
2404
+		$this->use_captcha                  = false;
2405
+		$this->recaptcha_theme              = 'light';
2406
+		$this->recaptcha_type               = 'image';
2407
+		$this->recaptcha_language           = 'en';
2408
+		$this->recaptcha_publickey          = null;
2409
+		$this->recaptcha_privatekey         = null;
2410
+		$this->recaptcha_width              = 500;
2411
+	}
2412
+
2413
+
2414
+	/**
2415
+	 * This is called by the config loader and hooks are initialized AFTER the config has been populated.
2416
+	 *
2417
+	 * @since 4.8.8.rc.019
2418
+	 */
2419
+	public function do_hooks()
2420
+	{
2421
+		add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event'));
2422
+	}
2423
+
2424
+
2425
+	/**
2426
+	 * @return void
2427
+	 */
2428
+	public function set_default_reg_status_on_EEM_Event()
2429
+	{
2430
+		EEM_Event::set_default_reg_status($this->default_STS_ID);
2431
+	}
2432
+
2433
+
2434
+	/**
2435
+	 * @return boolean
2436
+	 */
2437
+	public function track_invalid_checkout_access()
2438
+	{
2439
+		return $this->track_invalid_checkout_access;
2440
+	}
2441
+
2442
+
2443
+	/**
2444
+	 * @param boolean $track_invalid_checkout_access
2445
+	 */
2446
+	public function set_track_invalid_checkout_access($track_invalid_checkout_access)
2447
+	{
2448
+		$this->track_invalid_checkout_access = filter_var(
2449
+			$track_invalid_checkout_access,
2450
+			FILTER_VALIDATE_BOOLEAN
2451
+		);
2452
+	}
2453 2453
 
2454 2454
 
2455 2455
 }
@@ -2461,154 +2461,154 @@  discard block
 block discarded – undo
2461 2461
 class EE_Admin_Config extends EE_Config_Base
2462 2462
 {
2463 2463
 
2464
-    /**
2465
-     * @var boolean $use_personnel_manager
2466
-     */
2467
-    public $use_personnel_manager;
2468
-
2469
-    /**
2470
-     * @var boolean $use_dashboard_widget
2471
-     */
2472
-    public $use_dashboard_widget;
2473
-
2474
-    /**
2475
-     * @var int $events_in_dashboard
2476
-     */
2477
-    public $events_in_dashboard;
2478
-
2479
-    /**
2480
-     * @var boolean $use_event_timezones
2481
-     */
2482
-    public $use_event_timezones;
2483
-
2484
-    /**
2485
-     * @var boolean $use_full_logging
2486
-     */
2487
-    public $use_full_logging;
2488
-
2489
-    /**
2490
-     * @var string $log_file_name
2491
-     */
2492
-    public $log_file_name;
2493
-
2494
-    /**
2495
-     * @var string $debug_file_name
2496
-     */
2497
-    public $debug_file_name;
2498
-
2499
-    /**
2500
-     * @var boolean $use_remote_logging
2501
-     */
2502
-    public $use_remote_logging;
2503
-
2504
-    /**
2505
-     * @var string $remote_logging_url
2506
-     */
2507
-    public $remote_logging_url;
2508
-
2509
-    /**
2510
-     * @var boolean $show_reg_footer
2511
-     */
2512
-    public $show_reg_footer;
2513
-
2514
-    /**
2515
-     * @var string $affiliate_id
2516
-     */
2517
-    public $affiliate_id;
2518
-
2519
-    /**
2520
-     * help tours on or off (global setting)
2521
-     *
2522
-     * @var boolean
2523
-     */
2524
-    public $help_tour_activation;
2525
-
2526
-    /**
2527
-     * adds extra layer of encoding to session data to prevent serialization errors
2528
-     * but is incompatible with some server configuration errors
2529
-     * if you get "500 internal server errors" during registration, try turning this on
2530
-     * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off
2531
-     *
2532
-     * @var boolean $encode_session_data
2533
-     */
2534
-    private $encode_session_data = false;
2535
-
2536
-
2537
-    /**
2538
-     *    class constructor
2539
-     *
2540
-     * @access    public
2541
-     */
2542
-    public function __construct()
2543
-    {
2544
-        // set default general admin settings
2545
-        $this->use_personnel_manager = true;
2546
-        $this->use_dashboard_widget  = true;
2547
-        $this->events_in_dashboard   = 30;
2548
-        $this->use_event_timezones   = false;
2549
-        $this->use_full_logging      = false;
2550
-        $this->use_remote_logging    = false;
2551
-        $this->remote_logging_url    = null;
2552
-        $this->show_reg_footer       = true;
2553
-        $this->affiliate_id          = 'default';
2554
-        $this->help_tour_activation  = true;
2555
-        $this->encode_session_data   = false;
2556
-    }
2557
-
2558
-
2559
-    /**
2560
-     * @param bool $reset
2561
-     * @return string
2562
-     */
2563
-    public function log_file_name($reset = false)
2564
-    {
2565
-        if (empty($this->log_file_name) || $reset) {
2566
-            $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2567
-            EE_Config::instance()->update_espresso_config(false, false);
2568
-        }
2569
-        return $this->log_file_name;
2570
-    }
2571
-
2572
-
2573
-    /**
2574
-     * @param bool $reset
2575
-     * @return string
2576
-     */
2577
-    public function debug_file_name($reset = false)
2578
-    {
2579
-        if (empty($this->debug_file_name) || $reset) {
2580
-            $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2581
-            EE_Config::instance()->update_espresso_config(false, false);
2582
-        }
2583
-        return $this->debug_file_name;
2584
-    }
2585
-
2586
-
2587
-    /**
2588
-     * @return string
2589
-     */
2590
-    public function affiliate_id()
2591
-    {
2592
-        return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default';
2593
-    }
2594
-
2595
-
2596
-    /**
2597
-     * @return boolean
2598
-     */
2599
-    public function encode_session_data()
2600
-    {
2601
-        return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN);
2602
-    }
2603
-
2604
-
2605
-    /**
2606
-     * @param boolean $encode_session_data
2607
-     */
2608
-    public function set_encode_session_data($encode_session_data)
2609
-    {
2610
-        $this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN);
2611
-    }
2464
+	/**
2465
+	 * @var boolean $use_personnel_manager
2466
+	 */
2467
+	public $use_personnel_manager;
2468
+
2469
+	/**
2470
+	 * @var boolean $use_dashboard_widget
2471
+	 */
2472
+	public $use_dashboard_widget;
2473
+
2474
+	/**
2475
+	 * @var int $events_in_dashboard
2476
+	 */
2477
+	public $events_in_dashboard;
2478
+
2479
+	/**
2480
+	 * @var boolean $use_event_timezones
2481
+	 */
2482
+	public $use_event_timezones;
2483
+
2484
+	/**
2485
+	 * @var boolean $use_full_logging
2486
+	 */
2487
+	public $use_full_logging;
2488
+
2489
+	/**
2490
+	 * @var string $log_file_name
2491
+	 */
2492
+	public $log_file_name;
2493
+
2494
+	/**
2495
+	 * @var string $debug_file_name
2496
+	 */
2497
+	public $debug_file_name;
2498
+
2499
+	/**
2500
+	 * @var boolean $use_remote_logging
2501
+	 */
2502
+	public $use_remote_logging;
2503
+
2504
+	/**
2505
+	 * @var string $remote_logging_url
2506
+	 */
2507
+	public $remote_logging_url;
2508
+
2509
+	/**
2510
+	 * @var boolean $show_reg_footer
2511
+	 */
2512
+	public $show_reg_footer;
2513
+
2514
+	/**
2515
+	 * @var string $affiliate_id
2516
+	 */
2517
+	public $affiliate_id;
2518
+
2519
+	/**
2520
+	 * help tours on or off (global setting)
2521
+	 *
2522
+	 * @var boolean
2523
+	 */
2524
+	public $help_tour_activation;
2525
+
2526
+	/**
2527
+	 * adds extra layer of encoding to session data to prevent serialization errors
2528
+	 * but is incompatible with some server configuration errors
2529
+	 * if you get "500 internal server errors" during registration, try turning this on
2530
+	 * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off
2531
+	 *
2532
+	 * @var boolean $encode_session_data
2533
+	 */
2534
+	private $encode_session_data = false;
2535
+
2536
+
2537
+	/**
2538
+	 *    class constructor
2539
+	 *
2540
+	 * @access    public
2541
+	 */
2542
+	public function __construct()
2543
+	{
2544
+		// set default general admin settings
2545
+		$this->use_personnel_manager = true;
2546
+		$this->use_dashboard_widget  = true;
2547
+		$this->events_in_dashboard   = 30;
2548
+		$this->use_event_timezones   = false;
2549
+		$this->use_full_logging      = false;
2550
+		$this->use_remote_logging    = false;
2551
+		$this->remote_logging_url    = null;
2552
+		$this->show_reg_footer       = true;
2553
+		$this->affiliate_id          = 'default';
2554
+		$this->help_tour_activation  = true;
2555
+		$this->encode_session_data   = false;
2556
+	}
2557
+
2558
+
2559
+	/**
2560
+	 * @param bool $reset
2561
+	 * @return string
2562
+	 */
2563
+	public function log_file_name($reset = false)
2564
+	{
2565
+		if (empty($this->log_file_name) || $reset) {
2566
+			$this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2567
+			EE_Config::instance()->update_espresso_config(false, false);
2568
+		}
2569
+		return $this->log_file_name;
2570
+	}
2571
+
2572
+
2573
+	/**
2574
+	 * @param bool $reset
2575
+	 * @return string
2576
+	 */
2577
+	public function debug_file_name($reset = false)
2578
+	{
2579
+		if (empty($this->debug_file_name) || $reset) {
2580
+			$this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2581
+			EE_Config::instance()->update_espresso_config(false, false);
2582
+		}
2583
+		return $this->debug_file_name;
2584
+	}
2585
+
2586
+
2587
+	/**
2588
+	 * @return string
2589
+	 */
2590
+	public function affiliate_id()
2591
+	{
2592
+		return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default';
2593
+	}
2594
+
2595
+
2596
+	/**
2597
+	 * @return boolean
2598
+	 */
2599
+	public function encode_session_data()
2600
+	{
2601
+		return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN);
2602
+	}
2603
+
2604
+
2605
+	/**
2606
+	 * @param boolean $encode_session_data
2607
+	 */
2608
+	public function set_encode_session_data($encode_session_data)
2609
+	{
2610
+		$this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN);
2611
+	}
2612 2612
 
2613 2613
 
2614 2614
 }
@@ -2620,70 +2620,70 @@  discard block
 block discarded – undo
2620 2620
 class EE_Template_Config extends EE_Config_Base
2621 2621
 {
2622 2622
 
2623
-    /**
2624
-     * @var boolean $enable_default_style
2625
-     */
2626
-    public $enable_default_style;
2627
-
2628
-    /**
2629
-     * @var string $custom_style_sheet
2630
-     */
2631
-    public $custom_style_sheet;
2632
-
2633
-    /**
2634
-     * @var boolean $display_address_in_regform
2635
-     */
2636
-    public $display_address_in_regform;
2637
-
2638
-    /**
2639
-     * @var int $display_description_on_multi_reg_page
2640
-     */
2641
-    public $display_description_on_multi_reg_page;
2642
-
2643
-    /**
2644
-     * @var boolean $use_custom_templates
2645
-     */
2646
-    public $use_custom_templates;
2647
-
2648
-    /**
2649
-     * @var string $current_espresso_theme
2650
-     */
2651
-    public $current_espresso_theme;
2652
-
2653
-    /**
2654
-     * @var EE_Ticket_Selector_Config $EED_Ticket_Selector
2655
-     */
2656
-    public $EED_Ticket_Selector;
2657
-
2658
-    /**
2659
-     * @var EE_Event_Single_Config $EED_Event_Single
2660
-     */
2661
-    public $EED_Event_Single;
2662
-
2663
-    /**
2664
-     * @var EE_Events_Archive_Config $EED_Events_Archive
2665
-     */
2666
-    public $EED_Events_Archive;
2667
-
2668
-
2669
-    /**
2670
-     *    class constructor
2671
-     *
2672
-     * @access    public
2673
-     */
2674
-    public function __construct()
2675
-    {
2676
-        // set default template settings
2677
-        $this->enable_default_style                  = true;
2678
-        $this->custom_style_sheet                    = null;
2679
-        $this->display_address_in_regform            = true;
2680
-        $this->display_description_on_multi_reg_page = false;
2681
-        $this->use_custom_templates                  = false;
2682
-        $this->current_espresso_theme                = 'Espresso_Arabica_2014';
2683
-        $this->EED_Event_Single                      = null;
2684
-        $this->EED_Events_Archive                    = null;
2685
-        $this->EED_Ticket_Selector                   = null;
2686
-    }
2623
+	/**
2624
+	 * @var boolean $enable_default_style
2625
+	 */
2626
+	public $enable_default_style;
2627
+
2628
+	/**
2629
+	 * @var string $custom_style_sheet
2630
+	 */
2631
+	public $custom_style_sheet;
2632
+
2633
+	/**
2634
+	 * @var boolean $display_address_in_regform
2635
+	 */
2636
+	public $display_address_in_regform;
2637
+
2638
+	/**
2639
+	 * @var int $display_description_on_multi_reg_page
2640
+	 */
2641
+	public $display_description_on_multi_reg_page;
2642
+
2643
+	/**
2644
+	 * @var boolean $use_custom_templates
2645
+	 */
2646
+	public $use_custom_templates;
2647
+
2648
+	/**
2649
+	 * @var string $current_espresso_theme
2650
+	 */
2651
+	public $current_espresso_theme;
2652
+
2653
+	/**
2654
+	 * @var EE_Ticket_Selector_Config $EED_Ticket_Selector
2655
+	 */
2656
+	public $EED_Ticket_Selector;
2657
+
2658
+	/**
2659
+	 * @var EE_Event_Single_Config $EED_Event_Single
2660
+	 */
2661
+	public $EED_Event_Single;
2662
+
2663
+	/**
2664
+	 * @var EE_Events_Archive_Config $EED_Events_Archive
2665
+	 */
2666
+	public $EED_Events_Archive;
2667
+
2668
+
2669
+	/**
2670
+	 *    class constructor
2671
+	 *
2672
+	 * @access    public
2673
+	 */
2674
+	public function __construct()
2675
+	{
2676
+		// set default template settings
2677
+		$this->enable_default_style                  = true;
2678
+		$this->custom_style_sheet                    = null;
2679
+		$this->display_address_in_regform            = true;
2680
+		$this->display_description_on_multi_reg_page = false;
2681
+		$this->use_custom_templates                  = false;
2682
+		$this->current_espresso_theme                = 'Espresso_Arabica_2014';
2683
+		$this->EED_Event_Single                      = null;
2684
+		$this->EED_Events_Archive                    = null;
2685
+		$this->EED_Ticket_Selector                   = null;
2686
+	}
2687 2687
 
2688 2688
 }
2689 2689
 
@@ -2694,114 +2694,114 @@  discard block
 block discarded – undo
2694 2694
 class EE_Map_Config extends EE_Config_Base
2695 2695
 {
2696 2696
 
2697
-    /**
2698
-     * @var boolean $use_google_maps
2699
-     */
2700
-    public $use_google_maps;
2701
-
2702
-    /**
2703
-     * @var string $api_key
2704
-     */
2705
-    public $google_map_api_key;
2706
-
2707
-    /**
2708
-     * @var int $event_details_map_width
2709
-     */
2710
-    public $event_details_map_width;
2711
-
2712
-    /**
2713
-     * @var int $event_details_map_height
2714
-     */
2715
-    public $event_details_map_height;
2716
-
2717
-    /**
2718
-     * @var int $event_details_map_zoom
2719
-     */
2720
-    public $event_details_map_zoom;
2721
-
2722
-    /**
2723
-     * @var boolean $event_details_display_nav
2724
-     */
2725
-    public $event_details_display_nav;
2726
-
2727
-    /**
2728
-     * @var boolean $event_details_nav_size
2729
-     */
2730
-    public $event_details_nav_size;
2731
-
2732
-    /**
2733
-     * @var string $event_details_control_type
2734
-     */
2735
-    public $event_details_control_type;
2736
-
2737
-    /**
2738
-     * @var string $event_details_map_align
2739
-     */
2740
-    public $event_details_map_align;
2741
-
2742
-    /**
2743
-     * @var int $event_list_map_width
2744
-     */
2745
-    public $event_list_map_width;
2746
-
2747
-    /**
2748
-     * @var int $event_list_map_height
2749
-     */
2750
-    public $event_list_map_height;
2751
-
2752
-    /**
2753
-     * @var int $event_list_map_zoom
2754
-     */
2755
-    public $event_list_map_zoom;
2756
-
2757
-    /**
2758
-     * @var boolean $event_list_display_nav
2759
-     */
2760
-    public $event_list_display_nav;
2761
-
2762
-    /**
2763
-     * @var boolean $event_list_nav_size
2764
-     */
2765
-    public $event_list_nav_size;
2766
-
2767
-    /**
2768
-     * @var string $event_list_control_type
2769
-     */
2770
-    public $event_list_control_type;
2771
-
2772
-    /**
2773
-     * @var string $event_list_map_align
2774
-     */
2775
-    public $event_list_map_align;
2776
-
2777
-
2778
-    /**
2779
-     *    class constructor
2780
-     *
2781
-     * @access    public
2782
-     */
2783
-    public function __construct()
2784
-    {
2785
-        // set default map settings
2786
-        $this->use_google_maps    = true;
2787
-        $this->google_map_api_key = '';
2788
-        // for event details pages (reg page)
2789
-        $this->event_details_map_width    = 585;            // ee_map_width_single
2790
-        $this->event_details_map_height   = 362;            // ee_map_height_single
2791
-        $this->event_details_map_zoom     = 14;            // ee_map_zoom_single
2792
-        $this->event_details_display_nav  = true;            // ee_map_nav_display_single
2793
-        $this->event_details_nav_size     = false;            // ee_map_nav_size_single
2794
-        $this->event_details_control_type = 'default';        // ee_map_type_control_single
2795
-        $this->event_details_map_align    = 'center';            // ee_map_align_single
2796
-        // for event list pages
2797
-        $this->event_list_map_width    = 300;            // ee_map_width
2798
-        $this->event_list_map_height   = 185;        // ee_map_height
2799
-        $this->event_list_map_zoom     = 12;            // ee_map_zoom
2800
-        $this->event_list_display_nav  = false;        // ee_map_nav_display
2801
-        $this->event_list_nav_size     = true;            // ee_map_nav_size
2802
-        $this->event_list_control_type = 'dropdown';        // ee_map_type_control
2803
-        $this->event_list_map_align    = 'center';            // ee_map_align
2804
-    }
2697
+	/**
2698
+	 * @var boolean $use_google_maps
2699
+	 */
2700
+	public $use_google_maps;
2701
+
2702
+	/**
2703
+	 * @var string $api_key
2704
+	 */
2705
+	public $google_map_api_key;
2706
+
2707
+	/**
2708
+	 * @var int $event_details_map_width
2709
+	 */
2710
+	public $event_details_map_width;
2711
+
2712
+	/**
2713
+	 * @var int $event_details_map_height
2714
+	 */
2715
+	public $event_details_map_height;
2716
+
2717
+	/**
2718
+	 * @var int $event_details_map_zoom
2719
+	 */
2720
+	public $event_details_map_zoom;
2721
+
2722
+	/**
2723
+	 * @var boolean $event_details_display_nav
2724
+	 */
2725
+	public $event_details_display_nav;
2726
+
2727
+	/**
2728
+	 * @var boolean $event_details_nav_size
2729
+	 */
2730
+	public $event_details_nav_size;
2731
+
2732
+	/**
2733
+	 * @var string $event_details_control_type
2734
+	 */
2735
+	public $event_details_control_type;
2736
+
2737
+	/**
2738
+	 * @var string $event_details_map_align
2739
+	 */
2740
+	public $event_details_map_align;
2741
+
2742
+	/**
2743
+	 * @var int $event_list_map_width
2744
+	 */
2745
+	public $event_list_map_width;
2746
+
2747
+	/**
2748
+	 * @var int $event_list_map_height
2749
+	 */
2750
+	public $event_list_map_height;
2751
+
2752
+	/**
2753
+	 * @var int $event_list_map_zoom
2754
+	 */
2755
+	public $event_list_map_zoom;
2756
+
2757
+	/**
2758
+	 * @var boolean $event_list_display_nav
2759
+	 */
2760
+	public $event_list_display_nav;
2761
+
2762
+	/**
2763
+	 * @var boolean $event_list_nav_size
2764
+	 */
2765
+	public $event_list_nav_size;
2766
+
2767
+	/**
2768
+	 * @var string $event_list_control_type
2769
+	 */
2770
+	public $event_list_control_type;
2771
+
2772
+	/**
2773
+	 * @var string $event_list_map_align
2774
+	 */
2775
+	public $event_list_map_align;
2776
+
2777
+
2778
+	/**
2779
+	 *    class constructor
2780
+	 *
2781
+	 * @access    public
2782
+	 */
2783
+	public function __construct()
2784
+	{
2785
+		// set default map settings
2786
+		$this->use_google_maps    = true;
2787
+		$this->google_map_api_key = '';
2788
+		// for event details pages (reg page)
2789
+		$this->event_details_map_width    = 585;            // ee_map_width_single
2790
+		$this->event_details_map_height   = 362;            // ee_map_height_single
2791
+		$this->event_details_map_zoom     = 14;            // ee_map_zoom_single
2792
+		$this->event_details_display_nav  = true;            // ee_map_nav_display_single
2793
+		$this->event_details_nav_size     = false;            // ee_map_nav_size_single
2794
+		$this->event_details_control_type = 'default';        // ee_map_type_control_single
2795
+		$this->event_details_map_align    = 'center';            // ee_map_align_single
2796
+		// for event list pages
2797
+		$this->event_list_map_width    = 300;            // ee_map_width
2798
+		$this->event_list_map_height   = 185;        // ee_map_height
2799
+		$this->event_list_map_zoom     = 12;            // ee_map_zoom
2800
+		$this->event_list_display_nav  = false;        // ee_map_nav_display
2801
+		$this->event_list_nav_size     = true;            // ee_map_nav_size
2802
+		$this->event_list_control_type = 'dropdown';        // ee_map_type_control
2803
+		$this->event_list_map_align    = 'center';            // ee_map_align
2804
+	}
2805 2805
 
2806 2806
 }
2807 2807
 
@@ -2812,46 +2812,46 @@  discard block
 block discarded – undo
2812 2812
 class EE_Events_Archive_Config extends EE_Config_Base
2813 2813
 {
2814 2814
 
2815
-    public $display_status_banner;
2815
+	public $display_status_banner;
2816 2816
 
2817
-    public $display_description;
2817
+	public $display_description;
2818 2818
 
2819
-    public $display_ticket_selector;
2819
+	public $display_ticket_selector;
2820 2820
 
2821
-    public $display_datetimes;
2821
+	public $display_datetimes;
2822 2822
 
2823
-    public $display_venue;
2823
+	public $display_venue;
2824 2824
 
2825
-    public $display_expired_events;
2825
+	public $display_expired_events;
2826 2826
 
2827
-    public $use_sortable_display_order;
2827
+	public $use_sortable_display_order;
2828 2828
 
2829
-    public $display_order_tickets;
2829
+	public $display_order_tickets;
2830 2830
 
2831
-    public $display_order_datetimes;
2831
+	public $display_order_datetimes;
2832 2832
 
2833
-    public $display_order_event;
2833
+	public $display_order_event;
2834 2834
 
2835
-    public $display_order_venue;
2835
+	public $display_order_venue;
2836 2836
 
2837 2837
 
2838
-    /**
2839
-     *    class constructor
2840
-     */
2841
-    public function __construct()
2842
-    {
2843
-        $this->display_status_banner      = 0;
2844
-        $this->display_description        = 1;
2845
-        $this->display_ticket_selector    = 0;
2846
-        $this->display_datetimes          = 1;
2847
-        $this->display_venue              = 0;
2848
-        $this->display_expired_events     = 0;
2849
-        $this->use_sortable_display_order = false;
2850
-        $this->display_order_tickets      = 100;
2851
-        $this->display_order_datetimes    = 110;
2852
-        $this->display_order_event        = 120;
2853
-        $this->display_order_venue        = 130;
2854
-    }
2838
+	/**
2839
+	 *    class constructor
2840
+	 */
2841
+	public function __construct()
2842
+	{
2843
+		$this->display_status_banner      = 0;
2844
+		$this->display_description        = 1;
2845
+		$this->display_ticket_selector    = 0;
2846
+		$this->display_datetimes          = 1;
2847
+		$this->display_venue              = 0;
2848
+		$this->display_expired_events     = 0;
2849
+		$this->use_sortable_display_order = false;
2850
+		$this->display_order_tickets      = 100;
2851
+		$this->display_order_datetimes    = 110;
2852
+		$this->display_order_event        = 120;
2853
+		$this->display_order_venue        = 130;
2854
+	}
2855 2855
 }
2856 2856
 
2857 2857
 
@@ -2861,34 +2861,34 @@  discard block
 block discarded – undo
2861 2861
 class EE_Event_Single_Config extends EE_Config_Base
2862 2862
 {
2863 2863
 
2864
-    public $display_status_banner_single;
2864
+	public $display_status_banner_single;
2865 2865
 
2866
-    public $display_venue;
2866
+	public $display_venue;
2867 2867
 
2868
-    public $use_sortable_display_order;
2868
+	public $use_sortable_display_order;
2869 2869
 
2870
-    public $display_order_tickets;
2870
+	public $display_order_tickets;
2871 2871
 
2872
-    public $display_order_datetimes;
2872
+	public $display_order_datetimes;
2873 2873
 
2874
-    public $display_order_event;
2874
+	public $display_order_event;
2875 2875
 
2876
-    public $display_order_venue;
2876
+	public $display_order_venue;
2877 2877
 
2878 2878
 
2879
-    /**
2880
-     *    class constructor
2881
-     */
2882
-    public function __construct()
2883
-    {
2884
-        $this->display_status_banner_single = 0;
2885
-        $this->display_venue                = 1;
2886
-        $this->use_sortable_display_order   = false;
2887
-        $this->display_order_tickets        = 100;
2888
-        $this->display_order_datetimes      = 110;
2889
-        $this->display_order_event          = 120;
2890
-        $this->display_order_venue          = 130;
2891
-    }
2879
+	/**
2880
+	 *    class constructor
2881
+	 */
2882
+	public function __construct()
2883
+	{
2884
+		$this->display_status_banner_single = 0;
2885
+		$this->display_venue                = 1;
2886
+		$this->use_sortable_display_order   = false;
2887
+		$this->display_order_tickets        = 100;
2888
+		$this->display_order_datetimes      = 110;
2889
+		$this->display_order_event          = 120;
2890
+		$this->display_order_venue          = 130;
2891
+	}
2892 2892
 }
2893 2893
 
2894 2894
 
@@ -2898,144 +2898,144 @@  discard block
 block discarded – undo
2898 2898
 class EE_Ticket_Selector_Config extends EE_Config_Base
2899 2899
 {
2900 2900
 
2901
-    /**
2902
-     * constant to indicate that a datetime selector should NEVER be shown for ticket selectors
2903
-     */
2904
-    const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector';
2905
-
2906
-    /**
2907
-     * constant to indicate that a datetime selector should only be shown for ticket selectors
2908
-     * when the number of datetimes for the event matches the value set for $datetime_selector_threshold
2909
-     */
2910
-    const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector';
2911
-
2912
-    /**
2913
-     * @var boolean $show_ticket_sale_columns
2914
-     */
2915
-    public $show_ticket_sale_columns;
2916
-
2917
-    /**
2918
-     * @var boolean $show_ticket_details
2919
-     */
2920
-    public $show_ticket_details;
2921
-
2922
-    /**
2923
-     * @var boolean $show_expired_tickets
2924
-     */
2925
-    public $show_expired_tickets;
2926
-
2927
-    /**
2928
-     * whether or not to display a dropdown box populated with event datetimes
2929
-     * that toggles which tickets are displayed for a ticket selector.
2930
-     * uses one of the *_DATETIME_SELECTOR constants defined above
2931
-     *
2932
-     * @var string $show_datetime_selector
2933
-     */
2934
-    private $show_datetime_selector = 'no_datetime_selector';
2935
-
2936
-    /**
2937
-     * the number of datetimes an event has to have before conditionally displaying a datetime selector
2938
-     *
2939
-     * @var int $datetime_selector_threshold
2940
-     */
2941
-    private $datetime_selector_threshold = 3;
2942
-
2943
-
2944
-    /**
2945
-     *    class constructor
2946
-     */
2947
-    public function __construct()
2948
-    {
2949
-        $this->show_ticket_sale_columns    = true;
2950
-        $this->show_ticket_details         = true;
2951
-        $this->show_expired_tickets        = true;
2952
-        $this->show_datetime_selector      = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
2953
-        $this->datetime_selector_threshold = 3;
2954
-    }
2955
-
2956
-
2957
-    /**
2958
-     * returns true if a datetime selector should be displayed
2959
-     *
2960
-     * @param array $datetimes
2961
-     * @return bool
2962
-     */
2963
-    public function showDatetimeSelector(array $datetimes)
2964
-    {
2965
-        // if the settings are NOT: don't show OR below threshold, THEN active = true
2966
-        return ! (
2967
-            $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR
2968
-            || (
2969
-                $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR
2970
-                && count($datetimes) < $this->getDatetimeSelectorThreshold()
2971
-            )
2972
-        );
2973
-    }
2974
-
2975
-
2976
-    /**
2977
-     * @return string
2978
-     */
2979
-    public function getShowDatetimeSelector()
2980
-    {
2981
-        return $this->show_datetime_selector;
2982
-    }
2983
-
2984
-
2985
-    /**
2986
-     * @param bool $keys_only
2987
-     * @return array
2988
-     */
2989
-    public function getShowDatetimeSelectorOptions($keys_only = true)
2990
-    {
2991
-        return $keys_only
2992
-            ? array(
2993
-                \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR,
2994
-                \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR,
2995
-            )
2996
-            : array(
2997
-                \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__(
2998
-                    'Do not show date & time filter', 'event_espresso'
2999
-                ),
3000
-                \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR  => esc_html__(
3001
-                    'Maybe show date & time filter', 'event_espresso'
3002
-                ),
3003
-            );
3004
-    }
3005
-
3006
-
3007
-    /**
3008
-     * @param string $show_datetime_selector
3009
-     */
3010
-    public function setShowDatetimeSelector($show_datetime_selector)
3011
-    {
3012
-        $this->show_datetime_selector = in_array(
3013
-            $show_datetime_selector,
3014
-            $this->getShowDatetimeSelectorOptions(),
3015
-            true
3016
-        )
3017
-            ? $show_datetime_selector
3018
-            : \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3019
-    }
3020
-
3021
-
3022
-    /**
3023
-     * @return int
3024
-     */
3025
-    public function getDatetimeSelectorThreshold()
3026
-    {
3027
-        return $this->datetime_selector_threshold;
3028
-    }
3029
-
3030
-
3031
-    /**
3032
-     * @param int $datetime_selector_threshold
3033
-     */
3034
-    public function setDatetimeSelectorThreshold($datetime_selector_threshold)
3035
-    {
3036
-        $datetime_selector_threshold       = absint($datetime_selector_threshold);
3037
-        $this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3;
3038
-    }
2901
+	/**
2902
+	 * constant to indicate that a datetime selector should NEVER be shown for ticket selectors
2903
+	 */
2904
+	const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector';
2905
+
2906
+	/**
2907
+	 * constant to indicate that a datetime selector should only be shown for ticket selectors
2908
+	 * when the number of datetimes for the event matches the value set for $datetime_selector_threshold
2909
+	 */
2910
+	const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector';
2911
+
2912
+	/**
2913
+	 * @var boolean $show_ticket_sale_columns
2914
+	 */
2915
+	public $show_ticket_sale_columns;
2916
+
2917
+	/**
2918
+	 * @var boolean $show_ticket_details
2919
+	 */
2920
+	public $show_ticket_details;
2921
+
2922
+	/**
2923
+	 * @var boolean $show_expired_tickets
2924
+	 */
2925
+	public $show_expired_tickets;
2926
+
2927
+	/**
2928
+	 * whether or not to display a dropdown box populated with event datetimes
2929
+	 * that toggles which tickets are displayed for a ticket selector.
2930
+	 * uses one of the *_DATETIME_SELECTOR constants defined above
2931
+	 *
2932
+	 * @var string $show_datetime_selector
2933
+	 */
2934
+	private $show_datetime_selector = 'no_datetime_selector';
2935
+
2936
+	/**
2937
+	 * the number of datetimes an event has to have before conditionally displaying a datetime selector
2938
+	 *
2939
+	 * @var int $datetime_selector_threshold
2940
+	 */
2941
+	private $datetime_selector_threshold = 3;
2942
+
2943
+
2944
+	/**
2945
+	 *    class constructor
2946
+	 */
2947
+	public function __construct()
2948
+	{
2949
+		$this->show_ticket_sale_columns    = true;
2950
+		$this->show_ticket_details         = true;
2951
+		$this->show_expired_tickets        = true;
2952
+		$this->show_datetime_selector      = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
2953
+		$this->datetime_selector_threshold = 3;
2954
+	}
2955
+
2956
+
2957
+	/**
2958
+	 * returns true if a datetime selector should be displayed
2959
+	 *
2960
+	 * @param array $datetimes
2961
+	 * @return bool
2962
+	 */
2963
+	public function showDatetimeSelector(array $datetimes)
2964
+	{
2965
+		// if the settings are NOT: don't show OR below threshold, THEN active = true
2966
+		return ! (
2967
+			$this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR
2968
+			|| (
2969
+				$this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR
2970
+				&& count($datetimes) < $this->getDatetimeSelectorThreshold()
2971
+			)
2972
+		);
2973
+	}
2974
+
2975
+
2976
+	/**
2977
+	 * @return string
2978
+	 */
2979
+	public function getShowDatetimeSelector()
2980
+	{
2981
+		return $this->show_datetime_selector;
2982
+	}
2983
+
2984
+
2985
+	/**
2986
+	 * @param bool $keys_only
2987
+	 * @return array
2988
+	 */
2989
+	public function getShowDatetimeSelectorOptions($keys_only = true)
2990
+	{
2991
+		return $keys_only
2992
+			? array(
2993
+				\EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR,
2994
+				\EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR,
2995
+			)
2996
+			: array(
2997
+				\EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__(
2998
+					'Do not show date & time filter', 'event_espresso'
2999
+				),
3000
+				\EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR  => esc_html__(
3001
+					'Maybe show date & time filter', 'event_espresso'
3002
+				),
3003
+			);
3004
+	}
3005
+
3006
+
3007
+	/**
3008
+	 * @param string $show_datetime_selector
3009
+	 */
3010
+	public function setShowDatetimeSelector($show_datetime_selector)
3011
+	{
3012
+		$this->show_datetime_selector = in_array(
3013
+			$show_datetime_selector,
3014
+			$this->getShowDatetimeSelectorOptions(),
3015
+			true
3016
+		)
3017
+			? $show_datetime_selector
3018
+			: \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3019
+	}
3020
+
3021
+
3022
+	/**
3023
+	 * @return int
3024
+	 */
3025
+	public function getDatetimeSelectorThreshold()
3026
+	{
3027
+		return $this->datetime_selector_threshold;
3028
+	}
3029
+
3030
+
3031
+	/**
3032
+	 * @param int $datetime_selector_threshold
3033
+	 */
3034
+	public function setDatetimeSelectorThreshold($datetime_selector_threshold)
3035
+	{
3036
+		$datetime_selector_threshold       = absint($datetime_selector_threshold);
3037
+		$this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3;
3038
+	}
3039 3039
 
3040 3040
 
3041 3041
 }
@@ -3051,81 +3051,81 @@  discard block
 block discarded – undo
3051 3051
 class EE_Environment_Config extends EE_Config_Base
3052 3052
 {
3053 3053
 
3054
-    /**
3055
-     * Hold any php environment variables that we want to track.
3056
-     *
3057
-     * @var stdClass;
3058
-     */
3059
-    public $php;
3060
-
3061
-
3062
-    /**
3063
-     *    constructor
3064
-     */
3065
-    public function __construct()
3066
-    {
3067
-        $this->php = new stdClass();
3068
-        $this->_set_php_values();
3069
-    }
3070
-
3071
-
3072
-    /**
3073
-     * This sets the php environment variables.
3074
-     *
3075
-     * @since 4.4.0
3076
-     * @return void
3077
-     */
3078
-    protected function _set_php_values()
3079
-    {
3080
-        $this->php->max_input_vars = ini_get('max_input_vars');
3081
-        $this->php->version        = phpversion();
3082
-    }
3083
-
3084
-
3085
-    /**
3086
-     * helper method for determining whether input_count is
3087
-     * reaching the potential maximum the server can handle
3088
-     * according to max_input_vars
3089
-     *
3090
-     * @param int   $input_count the count of input vars.
3091
-     * @return array {
3092
-     *                           An array that represents whether available space and if no available space the error
3093
-     *                           message.
3094
-     * @type bool   $has_space   whether more inputs can be added.
3095
-     * @type string $msg         Any message to be displayed.
3096
-     *                           }
3097
-     */
3098
-    public function max_input_vars_limit_check($input_count = 0)
3099
-    {
3100
-        if (! empty($this->php->max_input_vars)
3101
-            && ($input_count >= $this->php->max_input_vars)
3102
-            && (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9)
3103
-        ) {
3104
-            return sprintf(
3105
-                __(
3106
-                    '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.',
3107
-                    'event_espresso'
3108
-                ),
3109
-                '<br>',
3110
-                $input_count,
3111
-                $this->php->max_input_vars
3112
-            );
3113
-        } else {
3114
-            return '';
3115
-        }
3116
-    }
3117
-
3118
-
3119
-    /**
3120
-     * The purpose of this method is just to force rechecking php values so if they've changed, they get updated.
3121
-     *
3122
-     * @since 4.4.1
3123
-     * @return void
3124
-     */
3125
-    public function recheck_values()
3126
-    {
3127
-        $this->_set_php_values();
3128
-    }
3054
+	/**
3055
+	 * Hold any php environment variables that we want to track.
3056
+	 *
3057
+	 * @var stdClass;
3058
+	 */
3059
+	public $php;
3060
+
3061
+
3062
+	/**
3063
+	 *    constructor
3064
+	 */
3065
+	public function __construct()
3066
+	{
3067
+		$this->php = new stdClass();
3068
+		$this->_set_php_values();
3069
+	}
3070
+
3071
+
3072
+	/**
3073
+	 * This sets the php environment variables.
3074
+	 *
3075
+	 * @since 4.4.0
3076
+	 * @return void
3077
+	 */
3078
+	protected function _set_php_values()
3079
+	{
3080
+		$this->php->max_input_vars = ini_get('max_input_vars');
3081
+		$this->php->version        = phpversion();
3082
+	}
3083
+
3084
+
3085
+	/**
3086
+	 * helper method for determining whether input_count is
3087
+	 * reaching the potential maximum the server can handle
3088
+	 * according to max_input_vars
3089
+	 *
3090
+	 * @param int   $input_count the count of input vars.
3091
+	 * @return array {
3092
+	 *                           An array that represents whether available space and if no available space the error
3093
+	 *                           message.
3094
+	 * @type bool   $has_space   whether more inputs can be added.
3095
+	 * @type string $msg         Any message to be displayed.
3096
+	 *                           }
3097
+	 */
3098
+	public function max_input_vars_limit_check($input_count = 0)
3099
+	{
3100
+		if (! empty($this->php->max_input_vars)
3101
+			&& ($input_count >= $this->php->max_input_vars)
3102
+			&& (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9)
3103
+		) {
3104
+			return sprintf(
3105
+				__(
3106
+					'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.',
3107
+					'event_espresso'
3108
+				),
3109
+				'<br>',
3110
+				$input_count,
3111
+				$this->php->max_input_vars
3112
+			);
3113
+		} else {
3114
+			return '';
3115
+		}
3116
+	}
3117
+
3118
+
3119
+	/**
3120
+	 * The purpose of this method is just to force rechecking php values so if they've changed, they get updated.
3121
+	 *
3122
+	 * @since 4.4.1
3123
+	 * @return void
3124
+	 */
3125
+	public function recheck_values()
3126
+	{
3127
+		$this->_set_php_values();
3128
+	}
3129 3129
 
3130 3130
 
3131 3131
 }
@@ -3141,21 +3141,21 @@  discard block
 block discarded – undo
3141 3141
 class EE_Tax_Config extends EE_Config_Base
3142 3142
 {
3143 3143
 
3144
-    /*
3144
+	/*
3145 3145
      * flag to indicate whether or not to display ticket prices with the taxes included
3146 3146
      *
3147 3147
      * @var boolean $prices_displayed_including_taxes
3148 3148
      */
3149
-    public $prices_displayed_including_taxes;
3149
+	public $prices_displayed_including_taxes;
3150 3150
 
3151 3151
 
3152
-    /**
3153
-     *    class constructor
3154
-     */
3155
-    public function __construct()
3156
-    {
3157
-        $this->prices_displayed_including_taxes = true;
3158
-    }
3152
+	/**
3153
+	 *    class constructor
3154
+	 */
3155
+	public function __construct()
3156
+	{
3157
+		$this->prices_displayed_including_taxes = true;
3158
+	}
3159 3159
 }
3160 3160
 
3161 3161
 
@@ -3167,33 +3167,33 @@  discard block
 block discarded – undo
3167 3167
 class EE_Gateway_Config extends EE_Config_Base
3168 3168
 {
3169 3169
 
3170
-    /**
3171
-     * Array with keys that are payment gateways slugs, and values are arrays
3172
-     * with any config info the gateway wants to store
3173
-     *
3174
-     * @var array
3175
-     */
3176
-    public $payment_settings;
3177
-
3178
-    /**
3179
-     * Where keys are gateway slugs, and values are booleans indicating whether or not
3180
-     * the gateway is stored in the uploads directory
3181
-     *
3182
-     * @var array
3183
-     */
3184
-    public $active_gateways;
3185
-
3186
-
3187
-    /**
3188
-     *    class constructor
3189
-     *
3190
-     * @deprecated
3191
-     */
3192
-    public function __construct()
3193
-    {
3194
-        $this->payment_settings = array();
3195
-        $this->active_gateways  = array('Invoice' => false);
3196
-    }
3170
+	/**
3171
+	 * Array with keys that are payment gateways slugs, and values are arrays
3172
+	 * with any config info the gateway wants to store
3173
+	 *
3174
+	 * @var array
3175
+	 */
3176
+	public $payment_settings;
3177
+
3178
+	/**
3179
+	 * Where keys are gateway slugs, and values are booleans indicating whether or not
3180
+	 * the gateway is stored in the uploads directory
3181
+	 *
3182
+	 * @var array
3183
+	 */
3184
+	public $active_gateways;
3185
+
3186
+
3187
+	/**
3188
+	 *    class constructor
3189
+	 *
3190
+	 * @deprecated
3191
+	 */
3192
+	public function __construct()
3193
+	{
3194
+		$this->payment_settings = array();
3195
+		$this->active_gateways  = array('Invoice' => false);
3196
+	}
3197 3197
 }
3198 3198
 
3199 3199
 // End of file EE_Config.core.php
Please login to merge, or discard this patch.
Spacing   +124 added lines, -124 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if (! defined('EVENT_ESPRESSO_VERSION')) {
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2 2
     exit('No direct script access allowed');
3 3
 }
4 4
 
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
     public static function instance()
134 134
     {
135 135
         // check if class object is instantiated, and instantiated properly
136
-        if (! self::$_instance instanceof EE_Config) {
136
+        if ( ! self::$_instance instanceof EE_Config) {
137 137
             self::$_instance = new self();
138 138
         }
139 139
         return self::$_instance;
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
                 $this
271 271
             );
272 272
             if (is_object($settings) && property_exists($this, $config)) {
273
-                $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings);
273
+                $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__'.$config, $settings);
274 274
                 //call configs populate method to ensure any defaults are set for empty values.
275 275
                 if (method_exists($settings, 'populate')) {
276 276
                     $this->{$config}->populate();
@@ -525,7 +525,7 @@  discard block
 block discarded – undo
525 525
                         break;
526 526
                     // TEST #2 : check that settings section exists
527 527
                     case 2 :
528
-                        if (! isset($this->{$section})) {
528
+                        if ( ! isset($this->{$section})) {
529 529
                             if ($display_errors) {
530 530
                                 throw new EE_Error(
531 531
                                     sprintf(
@@ -586,7 +586,7 @@  discard block
 block discarded – undo
586 586
                         break;
587 587
                     // TEST #6 : verify config class is accessible
588 588
                     case 6 :
589
-                        if (! class_exists($config_class)) {
589
+                        if ( ! class_exists($config_class)) {
590 590
                             if ($display_errors) {
591 591
                                 throw new EE_Error(
592 592
                                     sprintf(
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
                         break;
604 604
                     // TEST #7 : check that config has even been set
605 605
                     case 7 :
606
-                        if (! isset($this->{$section}->{$name})) {
606
+                        if ( ! isset($this->{$section}->{$name})) {
607 607
                             if ($display_errors) {
608 608
                                 throw new EE_Error(
609 609
                                     sprintf(
@@ -621,7 +621,7 @@  discard block
 block discarded – undo
621 621
                         break;
622 622
                     // TEST #8 : check that config is the requested type
623 623
                     case 8 :
624
-                        if (! $this->{$section}->{$name} instanceof $config_class) {
624
+                        if ( ! $this->{$section}->{$name} instanceof $config_class) {
625 625
                             if ($display_errors) {
626 626
                                 throw new EE_Error(
627 627
                                     sprintf(
@@ -640,7 +640,7 @@  discard block
 block discarded – undo
640 640
                         break;
641 641
                     // TEST #9 : verify config object
642 642
                     case 9 :
643
-                        if (! $config_obj instanceof EE_Config_Base) {
643
+                        if ( ! $config_obj instanceof EE_Config_Base) {
644 644
                             if ($display_errors) {
645 645
                                 throw new EE_Error(
646 646
                                     sprintf(
@@ -672,7 +672,7 @@  discard block
 block discarded – undo
672 672
      */
673 673
     private function _generate_config_option_name($section = '', $name = '')
674 674
     {
675
-        return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name));
675
+        return 'ee_config-'.strtolower($section.'-'.str_replace(array('EE_', 'EED_'), '', $name));
676 676
     }
677 677
 
678 678
 
@@ -689,7 +689,7 @@  discard block
 block discarded – undo
689 689
     {
690 690
         return ! empty($config_class)
691 691
             ? $config_class
692
-            : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config';
692
+            : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))).'_Config';
693 693
     }
694 694
 
695 695
 
@@ -708,17 +708,17 @@  discard block
 block discarded – undo
708 708
         // ensure config class is set to something
709 709
         $config_class = $this->_set_config_class($config_class, $name);
710 710
         // run tests 1-4, 6, and 7 to verify all config params are set and valid
711
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
711
+        if ( ! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
712 712
             return null;
713 713
         }
714 714
         $config_option_name = $this->_generate_config_option_name($section, $name);
715 715
         // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now
716
-        if (! isset($this->_addon_option_names[$config_option_name])) {
716
+        if ( ! isset($this->_addon_option_names[$config_option_name])) {
717 717
             $this->_addon_option_names[$config_option_name] = $config_class;
718 718
             $this->update_addon_option_names();
719 719
         }
720 720
         // verify the incoming config object but suppress errors
721
-        if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
721
+        if ( ! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
722 722
             $config_obj = new $config_class();
723 723
         }
724 724
         if (get_option($config_option_name)) {
@@ -765,7 +765,7 @@  discard block
 block discarded – undo
765 765
         // get class name of the incoming object
766 766
         $config_class = get_class($config_obj);
767 767
         // run tests 1-5 and 9 to verify config
768
-        if (! $this->_verify_config_params(
768
+        if ( ! $this->_verify_config_params(
769 769
             $section,
770 770
             $name,
771 771
             $config_class,
@@ -777,7 +777,7 @@  discard block
 block discarded – undo
777 777
         }
778 778
         $config_option_name = $this->_generate_config_option_name($section, $name);
779 779
         // check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
780
-        if (! isset($this->_addon_option_names[$config_option_name])) {
780
+        if ( ! isset($this->_addon_option_names[$config_option_name])) {
781 781
             // save new config to db
782 782
             if ($this->set_config($section, $name, $config_class, $config_obj)) {
783 783
                 return true;
@@ -803,7 +803,7 @@  discard block
 block discarded – undo
803 803
                             'event_espresso'
804 804
                         ),
805 805
                         $config_class,
806
-                        'EE_Config->' . $section . '->' . $name
806
+                        'EE_Config->'.$section.'->'.$name
807 807
                     ),
808 808
                     __FILE__,
809 809
                     __FUNCTION__,
@@ -829,7 +829,7 @@  discard block
 block discarded – undo
829 829
         // ensure config class is set to something
830 830
         $config_class = $this->_set_config_class($config_class, $name);
831 831
         // run tests 1-4, 6 and 7 to verify that all params have been set
832
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
832
+        if ( ! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
833 833
             return null;
834 834
         }
835 835
         // now test if the requested config object exists, but suppress errors
@@ -874,7 +874,7 @@  discard block
 block discarded – undo
874 874
         // retrieve the wp-option for this config class.
875 875
         $config_option = maybe_unserialize(get_option($config_option_name, array()));
876 876
         if (empty($config_option)) {
877
-            EE_Config::log($config_option_name . '-NOT-FOUND');
877
+            EE_Config::log($config_option_name.'-NOT-FOUND');
878 878
         }
879 879
         return $config_option;
880 880
     }
@@ -892,7 +892,7 @@  discard block
 block discarded – undo
892 892
             //copy incoming $_REQUEST and sanitize it so we can save it
893 893
             $_request = $_REQUEST;
894 894
             array_walk_recursive($_request, 'sanitize_text_field');
895
-            $config_log[(string)microtime(true)] = array(
895
+            $config_log[(string) microtime(true)] = array(
896 896
                 'config_name' => $config_option_name,
897 897
                 'request'     => $_request,
898 898
             );
@@ -907,7 +907,7 @@  discard block
 block discarded – undo
907 907
      */
908 908
     public static function trim_log()
909 909
     {
910
-        if (! EE_Config::logging_enabled()) {
910
+        if ( ! EE_Config::logging_enabled()) {
911 911
             return;
912 912
         }
913 913
         $config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
@@ -931,7 +931,7 @@  discard block
 block discarded – undo
931 931
     public static function get_page_for_posts()
932 932
     {
933 933
         $page_for_posts = get_option('page_for_posts');
934
-        if (! $page_for_posts) {
934
+        if ( ! $page_for_posts) {
935 935
             return 'posts';
936 936
         }
937 937
         /** @type WPDB $wpdb */
@@ -993,13 +993,13 @@  discard block
 block discarded – undo
993 993
             )
994 994
         ) {
995 995
             // grab list of installed widgets
996
-            $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
996
+            $widgets_to_register = glob(EE_WIDGETS.'*', GLOB_ONLYDIR);
997 997
             // filter list of modules to register
998 998
             $widgets_to_register = apply_filters(
999 999
                 'FHEE__EE_Config__register_widgets__widgets_to_register',
1000 1000
                 $widgets_to_register
1001 1001
             );
1002
-            if (! empty($widgets_to_register)) {
1002
+            if ( ! empty($widgets_to_register)) {
1003 1003
                 // cycle thru widget folders
1004 1004
                 foreach ($widgets_to_register as $widget_path) {
1005 1005
                     // add to list of installed widget modules
@@ -1049,31 +1049,31 @@  discard block
 block discarded – undo
1049 1049
         // create classname from widget directory name
1050 1050
         $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1051 1051
         // add class prefix
1052
-        $widget_class = 'EEW_' . $widget;
1052
+        $widget_class = 'EEW_'.$widget;
1053 1053
         // does the widget exist ?
1054
-        if (! is_readable($widget_path . DS . $widget_class . $widget_ext)) {
1054
+        if ( ! is_readable($widget_path.DS.$widget_class.$widget_ext)) {
1055 1055
             $msg = sprintf(
1056 1056
                 __(
1057 1057
                     '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',
1058 1058
                     'event_espresso'
1059 1059
                 ),
1060 1060
                 $widget_class,
1061
-                $widget_path . DS . $widget_class . $widget_ext
1061
+                $widget_path.DS.$widget_class.$widget_ext
1062 1062
             );
1063
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1063
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1064 1064
             return;
1065 1065
         }
1066 1066
         // load the widget class file
1067
-        require_once($widget_path . DS . $widget_class . $widget_ext);
1067
+        require_once($widget_path.DS.$widget_class.$widget_ext);
1068 1068
         // verify that class exists
1069
-        if (! class_exists($widget_class)) {
1069
+        if ( ! class_exists($widget_class)) {
1070 1070
             $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1071
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1071
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1072 1072
             return;
1073 1073
         }
1074 1074
         register_widget($widget_class);
1075 1075
         // add to array of registered widgets
1076
-        EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext;
1076
+        EE_Registry::instance()->widgets->{$widget_class} = $widget_path.DS.$widget_class.$widget_ext;
1077 1077
     }
1078 1078
 
1079 1079
 
@@ -1086,13 +1086,13 @@  discard block
 block discarded – undo
1086 1086
     private function _register_shortcodes()
1087 1087
     {
1088 1088
         // grab list of installed shortcodes
1089
-        $shortcodes_to_register = glob(EE_SHORTCODES . '*', GLOB_ONLYDIR);
1089
+        $shortcodes_to_register = glob(EE_SHORTCODES.'*', GLOB_ONLYDIR);
1090 1090
         // filter list of modules to register
1091 1091
         $shortcodes_to_register = apply_filters(
1092 1092
             'FHEE__EE_Config__register_shortcodes__shortcodes_to_register',
1093 1093
             $shortcodes_to_register
1094 1094
         );
1095
-        if (! empty($shortcodes_to_register)) {
1095
+        if ( ! empty($shortcodes_to_register)) {
1096 1096
             // cycle thru shortcode folders
1097 1097
             foreach ($shortcodes_to_register as $shortcode_path) {
1098 1098
                 // add to list of installed shortcode modules
@@ -1135,44 +1135,44 @@  discard block
 block discarded – undo
1135 1135
             // remove last segment
1136 1136
             array_pop($shortcode_path);
1137 1137
             // glue it back together
1138
-            $shortcode_path = implode(DS, $shortcode_path) . DS;
1138
+            $shortcode_path = implode(DS, $shortcode_path).DS;
1139 1139
         } else {
1140 1140
             // we need to generate the filename based off of the folder name
1141 1141
             // grab and sanitize shortcode directory name
1142 1142
             $shortcode      = sanitize_key(basename($shortcode_path));
1143
-            $shortcode_path = rtrim($shortcode_path, DS) . DS;
1143
+            $shortcode_path = rtrim($shortcode_path, DS).DS;
1144 1144
         }
1145 1145
         // create classname from shortcode directory or file name
1146 1146
         $shortcode = str_replace(' ', '_', ucwords(str_replace('_', ' ', $shortcode)));
1147 1147
         // add class prefix
1148
-        $shortcode_class = 'EES_' . $shortcode;
1148
+        $shortcode_class = 'EES_'.$shortcode;
1149 1149
         // does the shortcode exist ?
1150
-        if (! is_readable($shortcode_path . DS . $shortcode_class . $shortcode_ext)) {
1150
+        if ( ! is_readable($shortcode_path.DS.$shortcode_class.$shortcode_ext)) {
1151 1151
             $msg = sprintf(
1152 1152
                 __(
1153 1153
                     'The requested %s shortcode file could not be found or is not readable due to file permissions. It should be in %s',
1154 1154
                     'event_espresso'
1155 1155
                 ),
1156 1156
                 $shortcode_class,
1157
-                $shortcode_path . DS . $shortcode_class . $shortcode_ext
1157
+                $shortcode_path.DS.$shortcode_class.$shortcode_ext
1158 1158
             );
1159
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1159
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1160 1160
             return false;
1161 1161
         }
1162 1162
         // load the shortcode class file
1163
-        require_once($shortcode_path . $shortcode_class . $shortcode_ext);
1163
+        require_once($shortcode_path.$shortcode_class.$shortcode_ext);
1164 1164
         // verify that class exists
1165
-        if (! class_exists($shortcode_class)) {
1165
+        if ( ! class_exists($shortcode_class)) {
1166 1166
             $msg = sprintf(
1167 1167
                 __('The requested %s shortcode class does not exist.', 'event_espresso'),
1168 1168
                 $shortcode_class
1169 1169
             );
1170
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1170
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1171 1171
             return false;
1172 1172
         }
1173 1173
         $shortcode = strtoupper($shortcode);
1174 1174
         // add to array of registered shortcodes
1175
-        EE_Registry::instance()->shortcodes->{$shortcode} = $shortcode_path . $shortcode_class . $shortcode_ext;
1175
+        EE_Registry::instance()->shortcodes->{$shortcode} = $shortcode_path.$shortcode_class.$shortcode_ext;
1176 1176
         return true;
1177 1177
     }
1178 1178
 
@@ -1186,19 +1186,19 @@  discard block
 block discarded – undo
1186 1186
     private function _register_modules()
1187 1187
     {
1188 1188
         // grab list of installed modules
1189
-        $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1189
+        $modules_to_register = glob(EE_MODULES.'*', GLOB_ONLYDIR);
1190 1190
         // filter list of modules to register
1191 1191
         $modules_to_register = apply_filters(
1192 1192
             'FHEE__EE_Config__register_modules__modules_to_register',
1193 1193
             $modules_to_register
1194 1194
         );
1195
-        if (! empty($modules_to_register)) {
1195
+        if ( ! empty($modules_to_register)) {
1196 1196
             // loop through folders
1197 1197
             foreach ($modules_to_register as $module_path) {
1198 1198
                 /**TEMPORARILY EXCLUDE gateways from modules for time being**/
1199 1199
                 if (
1200
-                    $module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1201
-                    && $module_path !== EE_MODULES . 'gateways'
1200
+                    $module_path !== EE_MODULES.'zzz-copy-this-module-template'
1201
+                    && $module_path !== EE_MODULES.'gateways'
1202 1202
                 ) {
1203 1203
                     // add to list of installed modules
1204 1204
                     EE_Config::register_module($module_path);
@@ -1235,25 +1235,25 @@  discard block
 block discarded – undo
1235 1235
             // remove last segment
1236 1236
             array_pop($module_path);
1237 1237
             // glue it back together
1238
-            $module_path = implode(DS, $module_path) . DS;
1238
+            $module_path = implode(DS, $module_path).DS;
1239 1239
             // take first segment from file name pieces and sanitize it
1240 1240
             $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1241 1241
             // ensure class prefix is added
1242
-            $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1242
+            $module_class = strpos($module, 'EED_') !== 0 ? 'EED_'.$module : $module;
1243 1243
         } else {
1244 1244
             // we need to generate the filename based off of the folder name
1245 1245
             // grab and sanitize module name
1246 1246
             $module = strtolower(basename($module_path));
1247 1247
             $module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1248 1248
             // like trailingslashit()
1249
-            $module_path = rtrim($module_path, DS) . DS;
1249
+            $module_path = rtrim($module_path, DS).DS;
1250 1250
             // create classname from module directory name
1251 1251
             $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1252 1252
             // add class prefix
1253
-            $module_class = 'EED_' . $module;
1253
+            $module_class = 'EED_'.$module;
1254 1254
         }
1255 1255
         // does the module exist ?
1256
-        if (! is_readable($module_path . DS . $module_class . $module_ext)) {
1256
+        if ( ! is_readable($module_path.DS.$module_class.$module_ext)) {
1257 1257
             $msg = sprintf(
1258 1258
                 __(
1259 1259
                     'The requested %s module file could not be found or is not readable due to file permissions.',
@@ -1261,19 +1261,19 @@  discard block
 block discarded – undo
1261 1261
                 ),
1262 1262
                 $module
1263 1263
             );
1264
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1264
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1265 1265
             return false;
1266 1266
         }
1267 1267
         // load the module class file
1268
-        require_once($module_path . $module_class . $module_ext);
1268
+        require_once($module_path.$module_class.$module_ext);
1269 1269
         // verify that class exists
1270
-        if (! class_exists($module_class)) {
1270
+        if ( ! class_exists($module_class)) {
1271 1271
             $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1272
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1272
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1273 1273
             return false;
1274 1274
         }
1275 1275
         // add to array of registered modules
1276
-        EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1276
+        EE_Registry::instance()->modules->{$module_class} = $module_path.$module_class.$module_ext;
1277 1277
         do_action(
1278 1278
             'AHEE__EE_Config__register_module__complete',
1279 1279
             $module_class,
@@ -1295,7 +1295,7 @@  discard block
 block discarded – undo
1295 1295
         // cycle thru shortcode folders
1296 1296
         foreach (EE_Registry::instance()->shortcodes as $shortcode => $shortcode_path) {
1297 1297
             // add class prefix
1298
-            $shortcode_class = 'EES_' . $shortcode;
1298
+            $shortcode_class = 'EES_'.$shortcode;
1299 1299
             // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1300 1300
             // which set hooks ?
1301 1301
             if (is_admin()) {
@@ -1310,7 +1310,7 @@  discard block
 block discarded – undo
1310 1310
                 // convert classname to UPPERCASE and create WP shortcode.
1311 1311
                 $shortcode_tag = strtoupper($shortcode);
1312 1312
                 // but first check if the shortcode has already been added before assigning 'fallback_shortcode_processor'
1313
-                if (! shortcode_exists($shortcode_tag)) {
1313
+                if ( ! shortcode_exists($shortcode_tag)) {
1314 1314
                     // NOTE: this shortcode declaration will get overridden if the shortcode is successfully detected in the post content in EE_Front_Controller->_initialize_shortcodes()
1315 1315
                     add_shortcode($shortcode_tag, array($shortcode_class, 'fallback_shortcode_processor'));
1316 1316
                 }
@@ -1360,26 +1360,26 @@  discard block
 block discarded – undo
1360 1360
     {
1361 1361
         do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1362 1362
         $module       = str_replace('EED_', '', $module);
1363
-        $module_class = 'EED_' . $module;
1364
-        if (! isset(EE_Registry::instance()->modules->{$module_class})) {
1363
+        $module_class = 'EED_'.$module;
1364
+        if ( ! isset(EE_Registry::instance()->modules->{$module_class})) {
1365 1365
             $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module);
1366
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1366
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1367 1367
             return false;
1368 1368
         }
1369 1369
         if (empty($route)) {
1370 1370
             $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route);
1371
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1371
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1372 1372
             return false;
1373 1373
         }
1374
-        if (! method_exists('EED_' . $module, $method_name)) {
1374
+        if ( ! method_exists('EED_'.$module, $method_name)) {
1375 1375
             $msg = sprintf(
1376 1376
                 __('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1377 1377
                 $route
1378 1378
             );
1379
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1379
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1380 1380
             return false;
1381 1381
         }
1382
-        EE_Config::$_module_route_map[$key][$route] = array('EED_' . $module, $method_name);
1382
+        EE_Config::$_module_route_map[$key][$route] = array('EED_'.$module, $method_name);
1383 1383
         return true;
1384 1384
     }
1385 1385
 
@@ -1395,7 +1395,7 @@  discard block
 block discarded – undo
1395 1395
     public static function get_route($route = null, $key = 'ee')
1396 1396
     {
1397 1397
         do_action('AHEE__EE_Config__get_route__begin', $route);
1398
-        $route = (string)apply_filters('FHEE__EE_Config__get_route', $route);
1398
+        $route = (string) apply_filters('FHEE__EE_Config__get_route', $route);
1399 1399
         if (isset(EE_Config::$_module_route_map[$key][$route])) {
1400 1400
             return EE_Config::$_module_route_map[$key][$route];
1401 1401
         }
@@ -1429,44 +1429,44 @@  discard block
 block discarded – undo
1429 1429
     public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee')
1430 1430
     {
1431 1431
         do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1432
-        if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1432
+        if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1433 1433
             $msg = sprintf(
1434 1434
                 __('The module route %s for this forward has not been registered.', 'event_espresso'),
1435 1435
                 $route
1436 1436
             );
1437
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1437
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1438 1438
             return false;
1439 1439
         }
1440 1440
         if (empty($forward)) {
1441 1441
             $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route);
1442
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1442
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1443 1443
             return false;
1444 1444
         }
1445 1445
         if (is_array($forward)) {
1446
-            if (! isset($forward[1])) {
1446
+            if ( ! isset($forward[1])) {
1447 1447
                 $msg = sprintf(
1448 1448
                     __('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1449 1449
                     $route
1450 1450
                 );
1451
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1451
+                EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1452 1452
                 return false;
1453 1453
             }
1454
-            if (! method_exists($forward[0], $forward[1])) {
1454
+            if ( ! method_exists($forward[0], $forward[1])) {
1455 1455
                 $msg = sprintf(
1456 1456
                     __('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1457 1457
                     $forward[1],
1458 1458
                     $route
1459 1459
                 );
1460
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1460
+                EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1461 1461
                 return false;
1462 1462
             }
1463
-        } else if (! function_exists($forward)) {
1463
+        } else if ( ! function_exists($forward)) {
1464 1464
             $msg = sprintf(
1465 1465
                 __('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1466 1466
                 $forward,
1467 1467
                 $route
1468 1468
             );
1469
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1469
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1470 1470
             return false;
1471 1471
         }
1472 1472
         EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward;
@@ -1514,15 +1514,15 @@  discard block
 block discarded – undo
1514 1514
     public static function register_view($route = null, $status = 0, $view = null, $key = 'ee')
1515 1515
     {
1516 1516
         do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1517
-        if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1517
+        if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1518 1518
             $msg = sprintf(
1519 1519
                 __('The module route %s for this view has not been registered.', 'event_espresso'),
1520 1520
                 $route
1521 1521
             );
1522
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1522
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1523 1523
             return false;
1524 1524
         }
1525
-        if (! is_readable($view)) {
1525
+        if ( ! is_readable($view)) {
1526 1526
             $msg = sprintf(
1527 1527
                 __(
1528 1528
                     'The %s view file could not be found or is not readable due to file permissions.',
@@ -1530,7 +1530,7 @@  discard block
 block discarded – undo
1530 1530
                 ),
1531 1531
                 $view
1532 1532
             );
1533
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1533
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1534 1534
             return false;
1535 1535
         }
1536 1536
         EE_Config::$_module_view_map[$key][$route][absint($status)] = $view;
@@ -1595,7 +1595,7 @@  discard block
 block discarded – undo
1595 1595
      */
1596 1596
     public function get_pretty($property)
1597 1597
     {
1598
-        if (! property_exists($this, $property)) {
1598
+        if ( ! property_exists($this, $property)) {
1599 1599
             throw new EE_Error(
1600 1600
                 sprintf(
1601 1601
                     __(
@@ -1829,11 +1829,11 @@  discard block
 block discarded – undo
1829 1829
      */
1830 1830
     public function reg_page_url()
1831 1831
     {
1832
-        if (! $this->reg_page_url) {
1832
+        if ( ! $this->reg_page_url) {
1833 1833
             $this->reg_page_url = add_query_arg(
1834 1834
                                       array('uts' => time()),
1835 1835
                                       get_permalink($this->reg_page_id)
1836
-                                  ) . '#checkout';
1836
+                                  ).'#checkout';
1837 1837
         }
1838 1838
         return $this->reg_page_url;
1839 1839
     }
@@ -1849,7 +1849,7 @@  discard block
 block discarded – undo
1849 1849
      */
1850 1850
     public function txn_page_url($query_args = array())
1851 1851
     {
1852
-        if (! $this->txn_page_url) {
1852
+        if ( ! $this->txn_page_url) {
1853 1853
             $this->txn_page_url = get_permalink($this->txn_page_id);
1854 1854
         }
1855 1855
         if ($query_args) {
@@ -1870,7 +1870,7 @@  discard block
 block discarded – undo
1870 1870
      */
1871 1871
     public function thank_you_page_url($query_args = array())
1872 1872
     {
1873
-        if (! $this->thank_you_page_url) {
1873
+        if ( ! $this->thank_you_page_url) {
1874 1874
             $this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1875 1875
         }
1876 1876
         if ($query_args) {
@@ -1889,7 +1889,7 @@  discard block
 block discarded – undo
1889 1889
      */
1890 1890
     public function cancel_page_url()
1891 1891
     {
1892
-        if (! $this->cancel_page_url) {
1892
+        if ( ! $this->cancel_page_url) {
1893 1893
             $this->cancel_page_url = get_permalink($this->cancel_page_id);
1894 1894
         }
1895 1895
         return $this->cancel_page_url;
@@ -1925,7 +1925,7 @@  discard block
 block discarded – undo
1925 1925
         }
1926 1926
 
1927 1927
         //is this already cached for this request?  If so use it.
1928
-        if (! empty(EE_Core_Config::$ee_ueip_option)) {
1928
+        if ( ! empty(EE_Core_Config::$ee_ueip_option)) {
1929 1929
             return EE_Core_Config::$ee_ueip_option;
1930 1930
         }
1931 1931
 
@@ -1935,7 +1935,7 @@  discard block
 block discarded – undo
1935 1935
         $option                    = 'ee_ueip_optin';
1936 1936
 
1937 1937
         //set correct table for query
1938
-        $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1938
+        $table_name = $wpdb->get_blog_prefix($current_main_site_id).'options';
1939 1939
 
1940 1940
 
1941 1941
         //rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
@@ -1943,7 +1943,7 @@  discard block
 block discarded – undo
1943 1943
         //re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1944 1944
         //this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1945 1945
         //for the purpose of caching.
1946
-        $pre = apply_filters('pre_option_' . $option, false, $option);
1946
+        $pre = apply_filters('pre_option_'.$option, false, $option);
1947 1947
         if (false !== $pre) {
1948 1948
             EE_Core_Config::$ee_ueip_option = $pre;
1949 1949
             return EE_Core_Config::$ee_ueip_option;
@@ -1954,10 +1954,10 @@  discard block
 block discarded – undo
1954 1954
         if (is_object($row)) {
1955 1955
             $value = $row->option_value;
1956 1956
         } else { //option does not exist so use default.
1957
-            return apply_filters('default_option_' . $option, false, $option);
1957
+            return apply_filters('default_option_'.$option, false, $option);
1958 1958
         }
1959 1959
 
1960
-        EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
1960
+        EE_Core_Config::$ee_ueip_option = apply_filters('option_'.$option, maybe_unserialize($value), $option);
1961 1961
         return EE_Core_Config::$ee_ueip_option;
1962 1962
     }
1963 1963
 
@@ -2229,27 +2229,27 @@  discard block
 block discarded – undo
2229 2229
             // retrieve the country settings from the db, just in case they have been customized
2230 2230
             $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
2231 2231
             if ($country instanceof EE_Country) {
2232
-                $this->code    = $country->currency_code();    // currency code: USD, CAD, EUR
2233
-                $this->name    = $country->currency_name_single();    // Dollar
2234
-                $this->plural  = $country->currency_name_plural();    // Dollars
2235
-                $this->sign    = $country->currency_sign();            // currency sign: $
2236
-                $this->sign_b4 = $country->currency_sign_before();        // currency sign before or after: $TRUE  or  FALSE$
2237
-                $this->dec_plc = $country->currency_decimal_places();    // decimal places: 2 = 0.00  3 = 0.000
2238
-                $this->dec_mrk = $country->currency_decimal_mark();    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2239
-                $this->thsnds  = $country->currency_thousands_separator();    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2232
+                $this->code    = $country->currency_code(); // currency code: USD, CAD, EUR
2233
+                $this->name    = $country->currency_name_single(); // Dollar
2234
+                $this->plural  = $country->currency_name_plural(); // Dollars
2235
+                $this->sign    = $country->currency_sign(); // currency sign: $
2236
+                $this->sign_b4 = $country->currency_sign_before(); // currency sign before or after: $TRUE  or  FALSE$
2237
+                $this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00  3 = 0.000
2238
+                $this->dec_mrk = $country->currency_decimal_mark(); // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2239
+                $this->thsnds  = $country->currency_thousands_separator(); // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2240 2240
             }
2241 2241
         }
2242 2242
         // fallback to hardcoded defaults, in case the above failed
2243 2243
         if (empty($this->code)) {
2244 2244
             // set default currency settings
2245
-            $this->code    = 'USD';    // currency code: USD, CAD, EUR
2246
-            $this->name    = __('Dollar', 'event_espresso');    // Dollar
2247
-            $this->plural  = __('Dollars', 'event_espresso');    // Dollars
2248
-            $this->sign    = '$';    // currency sign: $
2249
-            $this->sign_b4 = true;    // currency sign before or after: $TRUE  or  FALSE$
2250
-            $this->dec_plc = 2;    // decimal places: 2 = 0.00  3 = 0.000
2251
-            $this->dec_mrk = '.';    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2252
-            $this->thsnds  = ',';    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2245
+            $this->code    = 'USD'; // currency code: USD, CAD, EUR
2246
+            $this->name    = __('Dollar', 'event_espresso'); // Dollar
2247
+            $this->plural  = __('Dollars', 'event_espresso'); // Dollars
2248
+            $this->sign    = '$'; // currency sign: $
2249
+            $this->sign_b4 = true; // currency sign before or after: $TRUE  or  FALSE$
2250
+            $this->dec_plc = 2; // decimal places: 2 = 0.00  3 = 0.000
2251
+            $this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2252
+            $this->thsnds  = ','; // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2253 2253
         }
2254 2254
     }
2255 2255
 }
@@ -2563,7 +2563,7 @@  discard block
 block discarded – undo
2563 2563
     public function log_file_name($reset = false)
2564 2564
     {
2565 2565
         if (empty($this->log_file_name) || $reset) {
2566
-            $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2566
+            $this->log_file_name = sanitize_key('espresso_log_'.md5(uniqid('', true))).'.txt';
2567 2567
             EE_Config::instance()->update_espresso_config(false, false);
2568 2568
         }
2569 2569
         return $this->log_file_name;
@@ -2577,7 +2577,7 @@  discard block
 block discarded – undo
2577 2577
     public function debug_file_name($reset = false)
2578 2578
     {
2579 2579
         if (empty($this->debug_file_name) || $reset) {
2580
-            $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2580
+            $this->debug_file_name = sanitize_key('espresso_debug_'.md5(uniqid('', true))).'.txt';
2581 2581
             EE_Config::instance()->update_espresso_config(false, false);
2582 2582
         }
2583 2583
         return $this->debug_file_name;
@@ -2786,21 +2786,21 @@  discard block
 block discarded – undo
2786 2786
         $this->use_google_maps    = true;
2787 2787
         $this->google_map_api_key = '';
2788 2788
         // for event details pages (reg page)
2789
-        $this->event_details_map_width    = 585;            // ee_map_width_single
2790
-        $this->event_details_map_height   = 362;            // ee_map_height_single
2791
-        $this->event_details_map_zoom     = 14;            // ee_map_zoom_single
2792
-        $this->event_details_display_nav  = true;            // ee_map_nav_display_single
2793
-        $this->event_details_nav_size     = false;            // ee_map_nav_size_single
2794
-        $this->event_details_control_type = 'default';        // ee_map_type_control_single
2795
-        $this->event_details_map_align    = 'center';            // ee_map_align_single
2789
+        $this->event_details_map_width    = 585; // ee_map_width_single
2790
+        $this->event_details_map_height   = 362; // ee_map_height_single
2791
+        $this->event_details_map_zoom     = 14; // ee_map_zoom_single
2792
+        $this->event_details_display_nav  = true; // ee_map_nav_display_single
2793
+        $this->event_details_nav_size     = false; // ee_map_nav_size_single
2794
+        $this->event_details_control_type = 'default'; // ee_map_type_control_single
2795
+        $this->event_details_map_align    = 'center'; // ee_map_align_single
2796 2796
         // for event list pages
2797
-        $this->event_list_map_width    = 300;            // ee_map_width
2798
-        $this->event_list_map_height   = 185;        // ee_map_height
2799
-        $this->event_list_map_zoom     = 12;            // ee_map_zoom
2800
-        $this->event_list_display_nav  = false;        // ee_map_nav_display
2801
-        $this->event_list_nav_size     = true;            // ee_map_nav_size
2802
-        $this->event_list_control_type = 'dropdown';        // ee_map_type_control
2803
-        $this->event_list_map_align    = 'center';            // ee_map_align
2797
+        $this->event_list_map_width    = 300; // ee_map_width
2798
+        $this->event_list_map_height   = 185; // ee_map_height
2799
+        $this->event_list_map_zoom     = 12; // ee_map_zoom
2800
+        $this->event_list_display_nav  = false; // ee_map_nav_display
2801
+        $this->event_list_nav_size     = true; // ee_map_nav_size
2802
+        $this->event_list_control_type = 'dropdown'; // ee_map_type_control
2803
+        $this->event_list_map_align    = 'center'; // ee_map_align
2804 2804
     }
2805 2805
 
2806 2806
 }
@@ -3097,7 +3097,7 @@  discard block
 block discarded – undo
3097 3097
      */
3098 3098
     public function max_input_vars_limit_check($input_count = 0)
3099 3099
     {
3100
-        if (! empty($this->php->max_input_vars)
3100
+        if ( ! empty($this->php->max_input_vars)
3101 3101
             && ($input_count >= $this->php->max_input_vars)
3102 3102
             && (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9)
3103 3103
         ) {
Please login to merge, or discard this patch.
core/libraries/iframe_display/IframeEmbedButton.php 2 patches
Indentation   +276 added lines, -276 removed lines patch added patch discarded remove patch
@@ -16,282 +16,282 @@
 block discarded – undo
16 16
 {
17 17
 
18 18
 
19
-    /**
20
-     * @var string $iframe_name
21
-     */
22
-    private $iframe_name;
23
-
24
-    /**
25
-     * @var string $route_name
26
-     */
27
-    private $route_name;
28
-
29
-    /**
30
-     * @var string $slug
31
-     */
32
-    private $slug;
33
-
34
-    /**
35
-     * @var boolean $append_filterable_content
36
-     */
37
-    private $append_filterable_content;
38
-
39
-
40
-
41
-    /**
42
-     * IframeEmbedButton constructor.
43
-     *
44
-     * @param string $iframe_name i18n name for the iframe. This will be used in HTML
45
-     * @param string $route_name  the name of the registered route
46
-     * @param string $slug        URL slug used for the thing the iframe button is being embedded in.
47
-     *                            will most likely be "event" since that's the only usage atm
48
-     */
49
-    public function __construct( $iframe_name, $route_name, $slug = 'event' )
50
-    {
51
-        $this->iframe_name = $iframe_name;
52
-        $this->route_name = $route_name;
53
-        $this->slug = $slug;
54
-    }
55
-
56
-
57
-
58
-    /**
59
-     * Adds an iframe embed code button to the Event editor.
60
-     */
61
-    public function addEventEditorIframeEmbedButtonFilter()
62
-    {
63
-        // add button for iframe code to event editor.
64
-        add_filter(
65
-            'get_sample_permalink_html',
66
-            array( $this, 'appendIframeEmbedButtonToSamplePermalinkHtml' ),
67
-            10,
68
-            2
69
-        );
70
-        add_action(
71
-            'admin_enqueue_scripts',
72
-            array( $this, 'embedButtonAssets' ),
73
-            10
74
-        );
75
-    }
76
-
77
-
78
-
79
-    /**
80
-     * @param $permalink_string
81
-     * @param $id
82
-     * @return string
83
-     */
84
-    public function appendIframeEmbedButtonToSamplePermalinkHtml( $permalink_string, $id )
85
-    {
86
-        return $this->eventEditorIframeEmbedButton(
87
-            $permalink_string,
88
-            $id
89
-        );
90
-    }
91
-
92
-
93
-
94
-    /**
95
-     * iframe embed code button to the Event editor.
96
-     *
97
-     * @param string $permalink_string
98
-     * @param int    $id
99
-     * @return string
100
-     */
101
-    public function eventEditorIframeEmbedButton(
102
-        $permalink_string,
103
-        $id
104
-    ) {
105
-        //make sure this is ONLY when editing and the event id has been set.
106
-        if ( ! empty( $id ) ) {
107
-            $post = get_post( $id );
108
-            //if NOT event then let's get out.
109
-            if ( $post->post_type !== 'espresso_events' ) {
110
-                return $permalink_string;
111
-            }
112
-            $permalink_string .= $this->embedButtonHtml(
113
-                array( $this->slug => $id ),
114
-                'button-small'
115
-            );
116
-        }
117
-        return $permalink_string;
118
-    }
119
-
120
-
121
-
122
-    /**
123
-     * Adds an iframe embed code button via a WP do_action() as determined by the first parameter
124
-     *
125
-     * @param string $action name of the WP do_action() to hook into
126
-     */
127
-    public function addActionIframeEmbedButton( $action )
128
-    {
129
-        // add button for iframe code to event editor.
130
-        add_action(
131
-            $action,
132
-            array( $this, 'addActionIframeEmbedButtonCallback' ),
133
-            10, 2
134
-        );
135
-    }
136
-
137
-
138
-
139
-    /**
140
-     * @return void
141
-     */
142
-    public function addActionIframeEmbedButtonCallback()
143
-    {
144
-        echo $this->embedButtonHtml();
145
-    }
146
-
147
-
148
-
149
-    /**
150
-     * Adds an iframe embed code button via a WP apply_filters() as determined by the first parameter
151
-     *
152
-     * @param string $filter     name of the WP apply_filters() to hook into
153
-     * @param bool   $append     if true, will add iframe embed button to end of content,
154
-     *                           else if false, will add to the beginning of the content
155
-     */
156
-    public function addFilterIframeEmbedButton( $filter, $append = true )
157
-    {
158
-        $this->append_filterable_content = $append;
159
-        // add button for iframe code to event editor.
160
-        add_filter(
161
-            $filter,
162
-            array( $this, 'addFilterIframeEmbedButtonCallback' ),
163
-            10
164
-        );
165
-    }
166
-
167
-
168
-
169
-    /**
170
-     * @param array|string $filterable_content
171
-     * @return array|string
172
-     */
173
-    public function addFilterIframeEmbedButtonCallback( $filterable_content )
174
-    {
175
-        $embedButtonHtml = $this->embedButtonHtml();
176
-        if ( is_array( $filterable_content ) ) {
177
-            $filterable_content = $this->append_filterable_content
178
-                ? $filterable_content + array( $this->route_name => $embedButtonHtml )
179
-                : array( $this->route_name => $embedButtonHtml ) + $filterable_content;
180
-        } else {
181
-            $filterable_content = $this->append_filterable_content
182
-                ? $filterable_content . $embedButtonHtml
183
-                : $embedButtonHtml . $filterable_content;
184
-        }
185
-        return $filterable_content;
186
-    }
187
-
188
-
189
-
190
-    /**
191
-     * iframe_embed_html
192
-     *
193
-     * @param array  $query_args
194
-     * @param string $button_class
195
-     * @return string
196
-     */
197
-    public function embedButtonHtml( $query_args = array(), $button_class = '' )
198
-    {
199
-        // incoming args will replace the defaults listed here in the second array (union preserves first array)
200
-        $query_args = (array)$query_args + array( $this->route_name => 'iframe' );
201
-        $query_args = (array)apply_filters(
202
-            'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__embedButtonHtml__query_args',
203
-            $query_args
204
-        );
205
-        // add this route to our localized vars
206
-        $iframe_module_routes = isset( \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] )
207
-            ? \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ]
208
-            : array();
209
-        $iframe_module_routes[ $this->route_name ] = $this->route_name;
210
-        \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] = $iframe_module_routes;
211
-        $iframe_embed_html = \EEH_HTML::link(
212
-            '#',
213
-            sprintf( esc_html__( 'Embed %1$s', 'event_espresso' ), $this->iframe_name ),
214
-            sprintf(
215
-                esc_html__(
216
-                    'click here to generate code for embedding %1$s iframe into another site.',
217
-                    'event_espresso'
218
-                ),
219
-                \EEH_Inflector::add_indefinite_article( $this->iframe_name )
220
-            ),
221
-            "{$this->route_name}-iframe-embed-trigger-js",
222
-            'iframe-embed-trigger-js button ' . $button_class,
223
-            '',
224
-            ' data-iframe_embed_button="#' . $this->route_name . '-iframe-js" tabindex="-1"'
225
-        );
226
-        $iframe_embed_html .= \EEH_HTML::div( '', "{$this->route_name}-iframe-js", 'iframe-embed-wrapper-js',
227
-                                              'display:none;' );
228
-        $iframe_embed_html .= esc_html(
229
-            \EEH_HTML::div(
230
-                '<iframe src="' . add_query_arg( $query_args, site_url() ) . '" width="100%" height="100%"></iframe>',
231
-                '',
232
-                '',
233
-                'width:100%; height: 500px;'
234
-            )
235
-        );
236
-        $iframe_embed_html .= \EEH_HTML::divx();
237
-        return $iframe_embed_html;
238
-    }
239
-
240
-
241
-
242
-    /**
243
-     * enqueue iframe button js
244
-     */
245
-    public function embedButtonAssets()
246
-    {
247
-        \EE_Registry::$i18n_js_strings[ 'iframe_embed_title' ] = esc_html__(
248
-            'copy and paste the following into any other site\'s content to display this event:',
249
-            'event_espresso'
250
-        );
251
-        \EE_Registry::$i18n_js_strings[ 'iframe_embed_close_msg' ] = esc_html__(
252
-            'click anywhere outside of this window to close it.',
253
-            'event_espresso'
254
-        );
255
-        wp_register_script(
256
-            'iframe_embed_button',
257
-            plugin_dir_url( __FILE__ ) . 'iframe-embed-button.js',
258
-            array( 'ee-dialog' ),
259
-            EVENT_ESPRESSO_VERSION,
260
-            true
261
-        );
262
-        wp_enqueue_script( 'iframe_embed_button' );
263
-    }
264
-
265
-
266
-
267
-    /**
268
-     * generates embed button sections for admin pages
269
-     *
270
-     * @param array $embed_buttons
271
-     * @return string
272
-     */
273
-    public function addIframeEmbedButtonsSection( array $embed_buttons )
274
-    {
275
-        $embed_buttons = (array)apply_filters(
276
-            'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__addIframeEmbedButtonsSection__embed_buttons',
277
-            $embed_buttons
278
-        );
279
-        if ( empty($embed_buttons)) {
280
-            return '';
281
-        }
282
-        // add button for iframe code to event editor.
283
-        $html = \EEH_HTML::br( 2 );
284
-        $html .= \EEH_HTML::h3( esc_html__( 'iFrame Embed Code', 'event_espresso' ) );
285
-        $html .= \EEH_HTML::p(
286
-            esc_html__(
287
-                'Click the following button(s) to generate iframe HTML that will allow you to embed your event content within the content of other websites.',
288
-                'event_espresso'
289
-            )
290
-        );
291
-        $html .= ' &nbsp; ' . implode( ' &nbsp; ', $embed_buttons ) . ' ';
292
-        $html .= \EEH_HTML::br( 2 );
293
-        return $html;
294
-    }
19
+	/**
20
+	 * @var string $iframe_name
21
+	 */
22
+	private $iframe_name;
23
+
24
+	/**
25
+	 * @var string $route_name
26
+	 */
27
+	private $route_name;
28
+
29
+	/**
30
+	 * @var string $slug
31
+	 */
32
+	private $slug;
33
+
34
+	/**
35
+	 * @var boolean $append_filterable_content
36
+	 */
37
+	private $append_filterable_content;
38
+
39
+
40
+
41
+	/**
42
+	 * IframeEmbedButton constructor.
43
+	 *
44
+	 * @param string $iframe_name i18n name for the iframe. This will be used in HTML
45
+	 * @param string $route_name  the name of the registered route
46
+	 * @param string $slug        URL slug used for the thing the iframe button is being embedded in.
47
+	 *                            will most likely be "event" since that's the only usage atm
48
+	 */
49
+	public function __construct( $iframe_name, $route_name, $slug = 'event' )
50
+	{
51
+		$this->iframe_name = $iframe_name;
52
+		$this->route_name = $route_name;
53
+		$this->slug = $slug;
54
+	}
55
+
56
+
57
+
58
+	/**
59
+	 * Adds an iframe embed code button to the Event editor.
60
+	 */
61
+	public function addEventEditorIframeEmbedButtonFilter()
62
+	{
63
+		// add button for iframe code to event editor.
64
+		add_filter(
65
+			'get_sample_permalink_html',
66
+			array( $this, 'appendIframeEmbedButtonToSamplePermalinkHtml' ),
67
+			10,
68
+			2
69
+		);
70
+		add_action(
71
+			'admin_enqueue_scripts',
72
+			array( $this, 'embedButtonAssets' ),
73
+			10
74
+		);
75
+	}
76
+
77
+
78
+
79
+	/**
80
+	 * @param $permalink_string
81
+	 * @param $id
82
+	 * @return string
83
+	 */
84
+	public function appendIframeEmbedButtonToSamplePermalinkHtml( $permalink_string, $id )
85
+	{
86
+		return $this->eventEditorIframeEmbedButton(
87
+			$permalink_string,
88
+			$id
89
+		);
90
+	}
91
+
92
+
93
+
94
+	/**
95
+	 * iframe embed code button to the Event editor.
96
+	 *
97
+	 * @param string $permalink_string
98
+	 * @param int    $id
99
+	 * @return string
100
+	 */
101
+	public function eventEditorIframeEmbedButton(
102
+		$permalink_string,
103
+		$id
104
+	) {
105
+		//make sure this is ONLY when editing and the event id has been set.
106
+		if ( ! empty( $id ) ) {
107
+			$post = get_post( $id );
108
+			//if NOT event then let's get out.
109
+			if ( $post->post_type !== 'espresso_events' ) {
110
+				return $permalink_string;
111
+			}
112
+			$permalink_string .= $this->embedButtonHtml(
113
+				array( $this->slug => $id ),
114
+				'button-small'
115
+			);
116
+		}
117
+		return $permalink_string;
118
+	}
119
+
120
+
121
+
122
+	/**
123
+	 * Adds an iframe embed code button via a WP do_action() as determined by the first parameter
124
+	 *
125
+	 * @param string $action name of the WP do_action() to hook into
126
+	 */
127
+	public function addActionIframeEmbedButton( $action )
128
+	{
129
+		// add button for iframe code to event editor.
130
+		add_action(
131
+			$action,
132
+			array( $this, 'addActionIframeEmbedButtonCallback' ),
133
+			10, 2
134
+		);
135
+	}
136
+
137
+
138
+
139
+	/**
140
+	 * @return void
141
+	 */
142
+	public function addActionIframeEmbedButtonCallback()
143
+	{
144
+		echo $this->embedButtonHtml();
145
+	}
146
+
147
+
148
+
149
+	/**
150
+	 * Adds an iframe embed code button via a WP apply_filters() as determined by the first parameter
151
+	 *
152
+	 * @param string $filter     name of the WP apply_filters() to hook into
153
+	 * @param bool   $append     if true, will add iframe embed button to end of content,
154
+	 *                           else if false, will add to the beginning of the content
155
+	 */
156
+	public function addFilterIframeEmbedButton( $filter, $append = true )
157
+	{
158
+		$this->append_filterable_content = $append;
159
+		// add button for iframe code to event editor.
160
+		add_filter(
161
+			$filter,
162
+			array( $this, 'addFilterIframeEmbedButtonCallback' ),
163
+			10
164
+		);
165
+	}
166
+
167
+
168
+
169
+	/**
170
+	 * @param array|string $filterable_content
171
+	 * @return array|string
172
+	 */
173
+	public function addFilterIframeEmbedButtonCallback( $filterable_content )
174
+	{
175
+		$embedButtonHtml = $this->embedButtonHtml();
176
+		if ( is_array( $filterable_content ) ) {
177
+			$filterable_content = $this->append_filterable_content
178
+				? $filterable_content + array( $this->route_name => $embedButtonHtml )
179
+				: array( $this->route_name => $embedButtonHtml ) + $filterable_content;
180
+		} else {
181
+			$filterable_content = $this->append_filterable_content
182
+				? $filterable_content . $embedButtonHtml
183
+				: $embedButtonHtml . $filterable_content;
184
+		}
185
+		return $filterable_content;
186
+	}
187
+
188
+
189
+
190
+	/**
191
+	 * iframe_embed_html
192
+	 *
193
+	 * @param array  $query_args
194
+	 * @param string $button_class
195
+	 * @return string
196
+	 */
197
+	public function embedButtonHtml( $query_args = array(), $button_class = '' )
198
+	{
199
+		// incoming args will replace the defaults listed here in the second array (union preserves first array)
200
+		$query_args = (array)$query_args + array( $this->route_name => 'iframe' );
201
+		$query_args = (array)apply_filters(
202
+			'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__embedButtonHtml__query_args',
203
+			$query_args
204
+		);
205
+		// add this route to our localized vars
206
+		$iframe_module_routes = isset( \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] )
207
+			? \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ]
208
+			: array();
209
+		$iframe_module_routes[ $this->route_name ] = $this->route_name;
210
+		\EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] = $iframe_module_routes;
211
+		$iframe_embed_html = \EEH_HTML::link(
212
+			'#',
213
+			sprintf( esc_html__( 'Embed %1$s', 'event_espresso' ), $this->iframe_name ),
214
+			sprintf(
215
+				esc_html__(
216
+					'click here to generate code for embedding %1$s iframe into another site.',
217
+					'event_espresso'
218
+				),
219
+				\EEH_Inflector::add_indefinite_article( $this->iframe_name )
220
+			),
221
+			"{$this->route_name}-iframe-embed-trigger-js",
222
+			'iframe-embed-trigger-js button ' . $button_class,
223
+			'',
224
+			' data-iframe_embed_button="#' . $this->route_name . '-iframe-js" tabindex="-1"'
225
+		);
226
+		$iframe_embed_html .= \EEH_HTML::div( '', "{$this->route_name}-iframe-js", 'iframe-embed-wrapper-js',
227
+											  'display:none;' );
228
+		$iframe_embed_html .= esc_html(
229
+			\EEH_HTML::div(
230
+				'<iframe src="' . add_query_arg( $query_args, site_url() ) . '" width="100%" height="100%"></iframe>',
231
+				'',
232
+				'',
233
+				'width:100%; height: 500px;'
234
+			)
235
+		);
236
+		$iframe_embed_html .= \EEH_HTML::divx();
237
+		return $iframe_embed_html;
238
+	}
239
+
240
+
241
+
242
+	/**
243
+	 * enqueue iframe button js
244
+	 */
245
+	public function embedButtonAssets()
246
+	{
247
+		\EE_Registry::$i18n_js_strings[ 'iframe_embed_title' ] = esc_html__(
248
+			'copy and paste the following into any other site\'s content to display this event:',
249
+			'event_espresso'
250
+		);
251
+		\EE_Registry::$i18n_js_strings[ 'iframe_embed_close_msg' ] = esc_html__(
252
+			'click anywhere outside of this window to close it.',
253
+			'event_espresso'
254
+		);
255
+		wp_register_script(
256
+			'iframe_embed_button',
257
+			plugin_dir_url( __FILE__ ) . 'iframe-embed-button.js',
258
+			array( 'ee-dialog' ),
259
+			EVENT_ESPRESSO_VERSION,
260
+			true
261
+		);
262
+		wp_enqueue_script( 'iframe_embed_button' );
263
+	}
264
+
265
+
266
+
267
+	/**
268
+	 * generates embed button sections for admin pages
269
+	 *
270
+	 * @param array $embed_buttons
271
+	 * @return string
272
+	 */
273
+	public function addIframeEmbedButtonsSection( array $embed_buttons )
274
+	{
275
+		$embed_buttons = (array)apply_filters(
276
+			'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__addIframeEmbedButtonsSection__embed_buttons',
277
+			$embed_buttons
278
+		);
279
+		if ( empty($embed_buttons)) {
280
+			return '';
281
+		}
282
+		// add button for iframe code to event editor.
283
+		$html = \EEH_HTML::br( 2 );
284
+		$html .= \EEH_HTML::h3( esc_html__( 'iFrame Embed Code', 'event_espresso' ) );
285
+		$html .= \EEH_HTML::p(
286
+			esc_html__(
287
+				'Click the following button(s) to generate iframe HTML that will allow you to embed your event content within the content of other websites.',
288
+				'event_espresso'
289
+			)
290
+		);
291
+		$html .= ' &nbsp; ' . implode( ' &nbsp; ', $embed_buttons ) . ' ';
292
+		$html .= \EEH_HTML::br( 2 );
293
+		return $html;
294
+	}
295 295
 
296 296
 
297 297
 }
Please login to merge, or discard this patch.
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace EventEspresso\core\libraries\iframe_display;
3 3
 
4
-defined( 'ABSPATH' ) || exit;
4
+defined('ABSPATH') || exit;
5 5
 
6 6
 
7 7
 
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
      * @param string $slug        URL slug used for the thing the iframe button is being embedded in.
47 47
      *                            will most likely be "event" since that's the only usage atm
48 48
      */
49
-    public function __construct( $iframe_name, $route_name, $slug = 'event' )
49
+    public function __construct($iframe_name, $route_name, $slug = 'event')
50 50
     {
51 51
         $this->iframe_name = $iframe_name;
52 52
         $this->route_name = $route_name;
@@ -63,13 +63,13 @@  discard block
 block discarded – undo
63 63
         // add button for iframe code to event editor.
64 64
         add_filter(
65 65
             'get_sample_permalink_html',
66
-            array( $this, 'appendIframeEmbedButtonToSamplePermalinkHtml' ),
66
+            array($this, 'appendIframeEmbedButtonToSamplePermalinkHtml'),
67 67
             10,
68 68
             2
69 69
         );
70 70
         add_action(
71 71
             'admin_enqueue_scripts',
72
-            array( $this, 'embedButtonAssets' ),
72
+            array($this, 'embedButtonAssets'),
73 73
             10
74 74
         );
75 75
     }
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
      * @param $id
82 82
      * @return string
83 83
      */
84
-    public function appendIframeEmbedButtonToSamplePermalinkHtml( $permalink_string, $id )
84
+    public function appendIframeEmbedButtonToSamplePermalinkHtml($permalink_string, $id)
85 85
     {
86 86
         return $this->eventEditorIframeEmbedButton(
87 87
             $permalink_string,
@@ -103,14 +103,14 @@  discard block
 block discarded – undo
103 103
         $id
104 104
     ) {
105 105
         //make sure this is ONLY when editing and the event id has been set.
106
-        if ( ! empty( $id ) ) {
107
-            $post = get_post( $id );
106
+        if ( ! empty($id)) {
107
+            $post = get_post($id);
108 108
             //if NOT event then let's get out.
109
-            if ( $post->post_type !== 'espresso_events' ) {
109
+            if ($post->post_type !== 'espresso_events') {
110 110
                 return $permalink_string;
111 111
             }
112 112
             $permalink_string .= $this->embedButtonHtml(
113
-                array( $this->slug => $id ),
113
+                array($this->slug => $id),
114 114
                 'button-small'
115 115
             );
116 116
         }
@@ -124,12 +124,12 @@  discard block
 block discarded – undo
124 124
      *
125 125
      * @param string $action name of the WP do_action() to hook into
126 126
      */
127
-    public function addActionIframeEmbedButton( $action )
127
+    public function addActionIframeEmbedButton($action)
128 128
     {
129 129
         // add button for iframe code to event editor.
130 130
         add_action(
131 131
             $action,
132
-            array( $this, 'addActionIframeEmbedButtonCallback' ),
132
+            array($this, 'addActionIframeEmbedButtonCallback'),
133 133
             10, 2
134 134
         );
135 135
     }
@@ -153,13 +153,13 @@  discard block
 block discarded – undo
153 153
      * @param bool   $append     if true, will add iframe embed button to end of content,
154 154
      *                           else if false, will add to the beginning of the content
155 155
      */
156
-    public function addFilterIframeEmbedButton( $filter, $append = true )
156
+    public function addFilterIframeEmbedButton($filter, $append = true)
157 157
     {
158 158
         $this->append_filterable_content = $append;
159 159
         // add button for iframe code to event editor.
160 160
         add_filter(
161 161
             $filter,
162
-            array( $this, 'addFilterIframeEmbedButtonCallback' ),
162
+            array($this, 'addFilterIframeEmbedButtonCallback'),
163 163
             10
164 164
         );
165 165
     }
@@ -170,17 +170,17 @@  discard block
 block discarded – undo
170 170
      * @param array|string $filterable_content
171 171
      * @return array|string
172 172
      */
173
-    public function addFilterIframeEmbedButtonCallback( $filterable_content )
173
+    public function addFilterIframeEmbedButtonCallback($filterable_content)
174 174
     {
175 175
         $embedButtonHtml = $this->embedButtonHtml();
176
-        if ( is_array( $filterable_content ) ) {
176
+        if (is_array($filterable_content)) {
177 177
             $filterable_content = $this->append_filterable_content
178
-                ? $filterable_content + array( $this->route_name => $embedButtonHtml )
179
-                : array( $this->route_name => $embedButtonHtml ) + $filterable_content;
178
+                ? $filterable_content + array($this->route_name => $embedButtonHtml)
179
+                : array($this->route_name => $embedButtonHtml) + $filterable_content;
180 180
         } else {
181 181
             $filterable_content = $this->append_filterable_content
182
-                ? $filterable_content . $embedButtonHtml
183
-                : $embedButtonHtml . $filterable_content;
182
+                ? $filterable_content.$embedButtonHtml
183
+                : $embedButtonHtml.$filterable_content;
184 184
         }
185 185
         return $filterable_content;
186 186
     }
@@ -194,40 +194,40 @@  discard block
 block discarded – undo
194 194
      * @param string $button_class
195 195
      * @return string
196 196
      */
197
-    public function embedButtonHtml( $query_args = array(), $button_class = '' )
197
+    public function embedButtonHtml($query_args = array(), $button_class = '')
198 198
     {
199 199
         // incoming args will replace the defaults listed here in the second array (union preserves first array)
200
-        $query_args = (array)$query_args + array( $this->route_name => 'iframe' );
201
-        $query_args = (array)apply_filters(
200
+        $query_args = (array) $query_args + array($this->route_name => 'iframe');
201
+        $query_args = (array) apply_filters(
202 202
             'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__embedButtonHtml__query_args',
203 203
             $query_args
204 204
         );
205 205
         // add this route to our localized vars
206
-        $iframe_module_routes = isset( \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] )
207
-            ? \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ]
206
+        $iframe_module_routes = isset(\EE_Registry::$i18n_js_strings['iframe_module_routes'])
207
+            ? \EE_Registry::$i18n_js_strings['iframe_module_routes']
208 208
             : array();
209
-        $iframe_module_routes[ $this->route_name ] = $this->route_name;
210
-        \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] = $iframe_module_routes;
209
+        $iframe_module_routes[$this->route_name] = $this->route_name;
210
+        \EE_Registry::$i18n_js_strings['iframe_module_routes'] = $iframe_module_routes;
211 211
         $iframe_embed_html = \EEH_HTML::link(
212 212
             '#',
213
-            sprintf( esc_html__( 'Embed %1$s', 'event_espresso' ), $this->iframe_name ),
213
+            sprintf(esc_html__('Embed %1$s', 'event_espresso'), $this->iframe_name),
214 214
             sprintf(
215 215
                 esc_html__(
216 216
                     'click here to generate code for embedding %1$s iframe into another site.',
217 217
                     'event_espresso'
218 218
                 ),
219
-                \EEH_Inflector::add_indefinite_article( $this->iframe_name )
219
+                \EEH_Inflector::add_indefinite_article($this->iframe_name)
220 220
             ),
221 221
             "{$this->route_name}-iframe-embed-trigger-js",
222
-            'iframe-embed-trigger-js button ' . $button_class,
222
+            'iframe-embed-trigger-js button '.$button_class,
223 223
             '',
224
-            ' data-iframe_embed_button="#' . $this->route_name . '-iframe-js" tabindex="-1"'
224
+            ' data-iframe_embed_button="#'.$this->route_name.'-iframe-js" tabindex="-1"'
225 225
         );
226
-        $iframe_embed_html .= \EEH_HTML::div( '', "{$this->route_name}-iframe-js", 'iframe-embed-wrapper-js',
227
-                                              'display:none;' );
226
+        $iframe_embed_html .= \EEH_HTML::div('', "{$this->route_name}-iframe-js", 'iframe-embed-wrapper-js',
227
+                                              'display:none;');
228 228
         $iframe_embed_html .= esc_html(
229 229
             \EEH_HTML::div(
230
-                '<iframe src="' . add_query_arg( $query_args, site_url() ) . '" width="100%" height="100%"></iframe>',
230
+                '<iframe src="'.add_query_arg($query_args, site_url()).'" width="100%" height="100%"></iframe>',
231 231
                 '',
232 232
                 '',
233 233
                 'width:100%; height: 500px;'
@@ -244,22 +244,22 @@  discard block
 block discarded – undo
244 244
      */
245 245
     public function embedButtonAssets()
246 246
     {
247
-        \EE_Registry::$i18n_js_strings[ 'iframe_embed_title' ] = esc_html__(
247
+        \EE_Registry::$i18n_js_strings['iframe_embed_title'] = esc_html__(
248 248
             'copy and paste the following into any other site\'s content to display this event:',
249 249
             'event_espresso'
250 250
         );
251
-        \EE_Registry::$i18n_js_strings[ 'iframe_embed_close_msg' ] = esc_html__(
251
+        \EE_Registry::$i18n_js_strings['iframe_embed_close_msg'] = esc_html__(
252 252
             'click anywhere outside of this window to close it.',
253 253
             'event_espresso'
254 254
         );
255 255
         wp_register_script(
256 256
             'iframe_embed_button',
257
-            plugin_dir_url( __FILE__ ) . 'iframe-embed-button.js',
258
-            array( 'ee-dialog' ),
257
+            plugin_dir_url(__FILE__).'iframe-embed-button.js',
258
+            array('ee-dialog'),
259 259
             EVENT_ESPRESSO_VERSION,
260 260
             true
261 261
         );
262
-        wp_enqueue_script( 'iframe_embed_button' );
262
+        wp_enqueue_script('iframe_embed_button');
263 263
     }
264 264
 
265 265
 
@@ -270,26 +270,26 @@  discard block
 block discarded – undo
270 270
      * @param array $embed_buttons
271 271
      * @return string
272 272
      */
273
-    public function addIframeEmbedButtonsSection( array $embed_buttons )
273
+    public function addIframeEmbedButtonsSection(array $embed_buttons)
274 274
     {
275
-        $embed_buttons = (array)apply_filters(
275
+        $embed_buttons = (array) apply_filters(
276 276
             'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__addIframeEmbedButtonsSection__embed_buttons',
277 277
             $embed_buttons
278 278
         );
279
-        if ( empty($embed_buttons)) {
279
+        if (empty($embed_buttons)) {
280 280
             return '';
281 281
         }
282 282
         // add button for iframe code to event editor.
283
-        $html = \EEH_HTML::br( 2 );
284
-        $html .= \EEH_HTML::h3( esc_html__( 'iFrame Embed Code', 'event_espresso' ) );
283
+        $html = \EEH_HTML::br(2);
284
+        $html .= \EEH_HTML::h3(esc_html__('iFrame Embed Code', 'event_espresso'));
285 285
         $html .= \EEH_HTML::p(
286 286
             esc_html__(
287 287
                 'Click the following button(s) to generate iframe HTML that will allow you to embed your event content within the content of other websites.',
288 288
                 'event_espresso'
289 289
             )
290 290
         );
291
-        $html .= ' &nbsp; ' . implode( ' &nbsp; ', $embed_buttons ) . ' ';
292
-        $html .= \EEH_HTML::br( 2 );
291
+        $html .= ' &nbsp; '.implode(' &nbsp; ', $embed_buttons).' ';
292
+        $html .= \EEH_HTML::br(2);
293 293
         return $html;
294 294
     }
295 295
 
Please login to merge, or discard this patch.
core/libraries/iframe_display/EventListIframeEmbedButton.php 2 patches
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -15,21 +15,21 @@  discard block
 block discarded – undo
15 15
 class EventListIframeEmbedButton extends IframeEmbedButton
16 16
 {
17 17
 
18
-    /**
19
-     * EventListIframeEmbedButton constructor.
20
-     */
21
-    public function __construct()
22
-    {
23
-        parent::__construct(
24
-            esc_html__( 'Event List', 'event_espresso' ),
25
-            'event_list'
26
-        );
27
-    }
18
+	/**
19
+	 * EventListIframeEmbedButton constructor.
20
+	 */
21
+	public function __construct()
22
+	{
23
+		parent::__construct(
24
+			esc_html__( 'Event List', 'event_espresso' ),
25
+			'event_list'
26
+		);
27
+	}
28 28
 
29 29
 
30 30
 
31 31
 	public function addEmbedButton() {
32
-        add_filter(
32
+		add_filter(
33 33
 			'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
34 34
 			array( $this, 'addEventListIframeEmbedButtonSection' )
35 35
 		);
@@ -49,19 +49,19 @@  discard block
 block discarded – undo
49 49
 	 * @param array $after_list_table
50 50
 	 * @return array
51 51
 	 */
52
-    public function addEventListIframeEmbedButtonSection( array $after_list_table )
53
-    {
54
-        return \EEH_Array::insert_into_array(
55
-    		$after_list_table,
56
-		    array(
57
-			    'iframe_embed_buttons' => $this->addIframeEmbedButtonsSection(
58
-			        array()
59
-				    // array( 'event_list' => $this->embedButtonHtml() )
60
-			    )
61
-		    ),
62
-		    'legend'
63
-	    );
64
-    }
52
+	public function addEventListIframeEmbedButtonSection( array $after_list_table )
53
+	{
54
+		return \EEH_Array::insert_into_array(
55
+			$after_list_table,
56
+			array(
57
+				'iframe_embed_buttons' => $this->addIframeEmbedButtonsSection(
58
+					array()
59
+					// array( 'event_list' => $this->embedButtonHtml() )
60
+				)
61
+			),
62
+			'legend'
63
+		);
64
+	}
65 65
 
66 66
 
67 67
 
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace EventEspresso\core\libraries\iframe_display;
3 3
 
4
-defined( 'ABSPATH' ) || exit;
4
+defined('ABSPATH') || exit;
5 5
 
6 6
 
7 7
 
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
     public function __construct()
22 22
     {
23 23
         parent::__construct(
24
-            esc_html__( 'Event List', 'event_espresso' ),
24
+            esc_html__('Event List', 'event_espresso'),
25 25
             'event_list'
26 26
         );
27 27
     }
@@ -31,11 +31,11 @@  discard block
 block discarded – undo
31 31
 	public function addEmbedButton() {
32 32
         add_filter(
33 33
 			'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
34
-			array( $this, 'addEventListIframeEmbedButtonSection' )
34
+			array($this, 'addEventListIframeEmbedButtonSection')
35 35
 		);
36 36
 		add_action(
37 37
 			'admin_enqueue_scripts',
38
-			array( $this, 'embedButtonAssets' ),
38
+			array($this, 'embedButtonAssets'),
39 39
 			10
40 40
 		);
41 41
 	}
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	 * @param array $after_list_table
50 50
 	 * @return array
51 51
 	 */
52
-    public function addEventListIframeEmbedButtonSection( array $after_list_table )
52
+    public function addEventListIframeEmbedButtonSection(array $after_list_table)
53 53
     {
54 54
         return \EEH_Array::insert_into_array(
55 55
     		$after_list_table,
Please login to merge, or discard this patch.
core/helpers/EEH_DTT_Helper.helper.php 2 patches
Indentation   +875 added lines, -875 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if (! defined('EVENT_ESPRESSO_VERSION')) {
3
-    exit('NO direct script access allowed');
3
+	exit('NO direct script access allowed');
4 4
 }
5 5
 
6 6
 /**
@@ -26,233 +26,233 @@  discard block
 block discarded – undo
26 26
 {
27 27
 
28 28
 
29
-    /**
30
-     * return the timezone set for the WP install
31
-     *
32
-     * @return string valid timezone string for PHP DateTimeZone() class
33
-     */
34
-    public static function get_timezone()
35
-    {
36
-        return EEH_DTT_Helper::get_valid_timezone_string();
37
-    }
38
-
39
-
40
-    /**
41
-     * get_valid_timezone_string
42
-     *    ensures that a valid timezone string is returned
43
-     *
44
-     * @access protected
45
-     * @param string $timezone_string
46
-     * @return string
47
-     * @throws \EE_Error
48
-     */
49
-    public static function get_valid_timezone_string($timezone_string = '')
50
-    {
51
-        // if passed a value, then use that, else get WP option
52
-        $timezone_string = ! empty($timezone_string) ? $timezone_string : get_option('timezone_string');
53
-        // value from above exists, use that, else get timezone string from gmt_offset
54
-        $timezone_string = ! empty($timezone_string) ? $timezone_string : EEH_DTT_Helper::get_timezone_string_from_gmt_offset();
55
-        EEH_DTT_Helper::validate_timezone($timezone_string);
56
-        return $timezone_string;
57
-    }
58
-
59
-
60
-    /**
61
-     * This only purpose for this static method is to validate that the incoming timezone is a valid php timezone.
62
-     *
63
-     * @static
64
-     * @access public
65
-     * @param  string $timezone_string Timezone string to check
66
-     * @param bool    $throw_error
67
-     * @return bool
68
-     * @throws \EE_Error
69
-     */
70
-    public static function validate_timezone($timezone_string, $throw_error = true)
71
-    {
72
-        // easiest way to test a timezone string is just see if it throws an error when you try to create a DateTimeZone object with it
73
-        try {
74
-            new DateTimeZone($timezone_string);
75
-        } catch (Exception $e) {
76
-            // sometimes we take exception to exceptions
77
-            if (! $throw_error) {
78
-                return false;
79
-            }
80
-            throw new EE_Error(
81
-                sprintf(
82
-                    __('The timezone given (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used',
83
-                        'event_espresso'),
84
-                    $timezone_string,
85
-                    '<a href="http://www.php.net/manual/en/timezones.php">',
86
-                    '</a>'
87
-                )
88
-            );
89
-        }
90
-        return true;
91
-    }
92
-
93
-
94
-    /**
95
-     * _create_timezone_object_from_timezone_name
96
-     *
97
-     * @access protected
98
-     * @param string $gmt_offset
99
-     * @return string
100
-     */
101
-    public static function get_timezone_string_from_gmt_offset($gmt_offset = '')
102
-    {
103
-        $timezone_string = 'UTC';
104
-        $gmt_offset      = ! empty($gmt_offset) ? $gmt_offset : get_option('gmt_offset');
105
-        if ($gmt_offset !== '') {
106
-            // convert GMT offset to seconds
107
-            $gmt_offset = $gmt_offset * HOUR_IN_SECONDS;
108
-            // account for WP offsets that aren't valid UTC
109
-            $gmt_offset = EEH_DTT_Helper::adjust_invalid_gmt_offsets($gmt_offset);
110
-            // although we don't know the TZ abbreviation, we know the UTC offset
111
-            $timezone_string = timezone_name_from_abbr(null, $gmt_offset);
112
-        }
113
-        // better have a valid timezone string by now, but if not, sigh... loop thru  the timezone_abbreviations_list()...
114
-        $timezone_string = $timezone_string !== false
115
-            ? $timezone_string
116
-            : EEH_DTT_Helper::get_timezone_string_from_abbreviations_list($gmt_offset);
117
-        return $timezone_string;
118
-    }
119
-
120
-    /**
121
-     * Gets the site's GMT offset based on either the timezone string
122
-     * (in which case teh gmt offset will vary depending on the location's
123
-     * observance of daylight savings time) or the gmt_offset wp option
124
-     *
125
-     * @return int seconds offset
126
-     */
127
-    public static function get_site_timezone_gmt_offset()
128
-    {
129
-        $timezone_string = get_option('timezone_string');
130
-        if ($timezone_string) {
131
-            try {
132
-                $timezone = new DateTimeZone($timezone_string);
133
-                return $timezone->getOffset(new DateTime()); //in WordPress DateTime defaults to UTC
134
-            } catch (Exception $e) {
135
-            }
136
-        }
137
-        $offset = get_option('gmt_offset');
138
-        return (int)($offset * HOUR_IN_SECONDS);
139
-    }
140
-
141
-
142
-    /**
143
-     * _create_timezone_object_from_timezone_name
144
-     *
145
-     * @access public
146
-     * @param int $gmt_offset
147
-     * @return int
148
-     */
149
-    public static function adjust_invalid_gmt_offsets($gmt_offset = 0)
150
-    {
151
-        //make sure $gmt_offset is int
152
-        $gmt_offset = (int)$gmt_offset;
153
-        switch ($gmt_offset) {
154
-
155
-            //			case -30600 :
156
-            //				$gmt_offset = -28800;
157
-            //				break;
158
-
159
-            case -27000 :
160
-                $gmt_offset = -25200;
161
-                break;
162
-
163
-            case -23400 :
164
-                $gmt_offset = -21600;
165
-                break;
166
-
167
-            case -19800 :
168
-                $gmt_offset = -18000;
169
-                break;
170
-
171
-            case -9000 :
172
-                $gmt_offset = -7200;
173
-                break;
174
-
175
-            case -5400 :
176
-                $gmt_offset = -3600;
177
-                break;
178
-
179
-            case -1800 :
180
-                $gmt_offset = 0;
181
-                break;
182
-
183
-            case 1800 :
184
-                $gmt_offset = 3600;
185
-                break;
186
-
187
-            case 49500 :
188
-                $gmt_offset = 50400;
189
-                break;
190
-
191
-        }
192
-        return $gmt_offset;
193
-    }
194
-
195
-
196
-    /**
197
-     * get_timezone_string_from_abbreviations_list
198
-     *
199
-     * @access public
200
-     * @param int $gmt_offset
201
-     * @return string
202
-     * @throws \EE_Error
203
-     */
204
-    public static function get_timezone_string_from_abbreviations_list($gmt_offset = 0)
205
-    {
206
-        $abbreviations = timezone_abbreviations_list();
207
-        foreach ($abbreviations as $abbreviation) {
208
-            foreach ($abbreviation as $city) {
209
-                if ($city['offset'] === $gmt_offset && $city['dst'] === false) {
210
-                    // check if the timezone is valid but don't throw any errors if it isn't
211
-                    if (EEH_DTT_Helper::validate_timezone($city['timezone_id'], false)) {
212
-                        return $city['timezone_id'];
213
-                    }
214
-                }
215
-            }
216
-        }
217
-        throw new EE_Error(
218
-            sprintf(
219
-                __('The provided GMT offset (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used',
220
-                    'event_espresso'),
221
-                $gmt_offset,
222
-                '<a href="http://www.php.net/manual/en/timezones.php">',
223
-                '</a>'
224
-            )
225
-        );
226
-    }
227
-
228
-
229
-    /**
230
-     * @access public
231
-     * @param string $timezone_string
232
-     */
233
-    public static function timezone_select_input($timezone_string = '')
234
-    {
235
-        // get WP date time format
236
-        $datetime_format = get_option('date_format') . ' ' . get_option('time_format');
237
-        // if passed a value, then use that, else get WP option
238
-        $timezone_string = ! empty($timezone_string) ? $timezone_string : get_option('timezone_string');
239
-        // check if the timezone is valid but don't throw any errors if it isn't
240
-        $timezone_string = EEH_DTT_Helper::validate_timezone($timezone_string, false);
241
-        $gmt_offset      = get_option('gmt_offset');
242
-
243
-        $check_zone_info = true;
244
-        if (empty($timezone_string)) {
245
-            // Create a UTC+- zone if no timezone string exists
246
-            $check_zone_info = false;
247
-            if ($gmt_offset > 0) {
248
-                $timezone_string = 'UTC+' . $gmt_offset;
249
-            } elseif ($gmt_offset < 0) {
250
-                $timezone_string = 'UTC' . $gmt_offset;
251
-            } else {
252
-                $timezone_string = 'UTC';
253
-            }
254
-        }
255
-        ?>
29
+	/**
30
+	 * return the timezone set for the WP install
31
+	 *
32
+	 * @return string valid timezone string for PHP DateTimeZone() class
33
+	 */
34
+	public static function get_timezone()
35
+	{
36
+		return EEH_DTT_Helper::get_valid_timezone_string();
37
+	}
38
+
39
+
40
+	/**
41
+	 * get_valid_timezone_string
42
+	 *    ensures that a valid timezone string is returned
43
+	 *
44
+	 * @access protected
45
+	 * @param string $timezone_string
46
+	 * @return string
47
+	 * @throws \EE_Error
48
+	 */
49
+	public static function get_valid_timezone_string($timezone_string = '')
50
+	{
51
+		// if passed a value, then use that, else get WP option
52
+		$timezone_string = ! empty($timezone_string) ? $timezone_string : get_option('timezone_string');
53
+		// value from above exists, use that, else get timezone string from gmt_offset
54
+		$timezone_string = ! empty($timezone_string) ? $timezone_string : EEH_DTT_Helper::get_timezone_string_from_gmt_offset();
55
+		EEH_DTT_Helper::validate_timezone($timezone_string);
56
+		return $timezone_string;
57
+	}
58
+
59
+
60
+	/**
61
+	 * This only purpose for this static method is to validate that the incoming timezone is a valid php timezone.
62
+	 *
63
+	 * @static
64
+	 * @access public
65
+	 * @param  string $timezone_string Timezone string to check
66
+	 * @param bool    $throw_error
67
+	 * @return bool
68
+	 * @throws \EE_Error
69
+	 */
70
+	public static function validate_timezone($timezone_string, $throw_error = true)
71
+	{
72
+		// easiest way to test a timezone string is just see if it throws an error when you try to create a DateTimeZone object with it
73
+		try {
74
+			new DateTimeZone($timezone_string);
75
+		} catch (Exception $e) {
76
+			// sometimes we take exception to exceptions
77
+			if (! $throw_error) {
78
+				return false;
79
+			}
80
+			throw new EE_Error(
81
+				sprintf(
82
+					__('The timezone given (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used',
83
+						'event_espresso'),
84
+					$timezone_string,
85
+					'<a href="http://www.php.net/manual/en/timezones.php">',
86
+					'</a>'
87
+				)
88
+			);
89
+		}
90
+		return true;
91
+	}
92
+
93
+
94
+	/**
95
+	 * _create_timezone_object_from_timezone_name
96
+	 *
97
+	 * @access protected
98
+	 * @param string $gmt_offset
99
+	 * @return string
100
+	 */
101
+	public static function get_timezone_string_from_gmt_offset($gmt_offset = '')
102
+	{
103
+		$timezone_string = 'UTC';
104
+		$gmt_offset      = ! empty($gmt_offset) ? $gmt_offset : get_option('gmt_offset');
105
+		if ($gmt_offset !== '') {
106
+			// convert GMT offset to seconds
107
+			$gmt_offset = $gmt_offset * HOUR_IN_SECONDS;
108
+			// account for WP offsets that aren't valid UTC
109
+			$gmt_offset = EEH_DTT_Helper::adjust_invalid_gmt_offsets($gmt_offset);
110
+			// although we don't know the TZ abbreviation, we know the UTC offset
111
+			$timezone_string = timezone_name_from_abbr(null, $gmt_offset);
112
+		}
113
+		// better have a valid timezone string by now, but if not, sigh... loop thru  the timezone_abbreviations_list()...
114
+		$timezone_string = $timezone_string !== false
115
+			? $timezone_string
116
+			: EEH_DTT_Helper::get_timezone_string_from_abbreviations_list($gmt_offset);
117
+		return $timezone_string;
118
+	}
119
+
120
+	/**
121
+	 * Gets the site's GMT offset based on either the timezone string
122
+	 * (in which case teh gmt offset will vary depending on the location's
123
+	 * observance of daylight savings time) or the gmt_offset wp option
124
+	 *
125
+	 * @return int seconds offset
126
+	 */
127
+	public static function get_site_timezone_gmt_offset()
128
+	{
129
+		$timezone_string = get_option('timezone_string');
130
+		if ($timezone_string) {
131
+			try {
132
+				$timezone = new DateTimeZone($timezone_string);
133
+				return $timezone->getOffset(new DateTime()); //in WordPress DateTime defaults to UTC
134
+			} catch (Exception $e) {
135
+			}
136
+		}
137
+		$offset = get_option('gmt_offset');
138
+		return (int)($offset * HOUR_IN_SECONDS);
139
+	}
140
+
141
+
142
+	/**
143
+	 * _create_timezone_object_from_timezone_name
144
+	 *
145
+	 * @access public
146
+	 * @param int $gmt_offset
147
+	 * @return int
148
+	 */
149
+	public static function adjust_invalid_gmt_offsets($gmt_offset = 0)
150
+	{
151
+		//make sure $gmt_offset is int
152
+		$gmt_offset = (int)$gmt_offset;
153
+		switch ($gmt_offset) {
154
+
155
+			//			case -30600 :
156
+			//				$gmt_offset = -28800;
157
+			//				break;
158
+
159
+			case -27000 :
160
+				$gmt_offset = -25200;
161
+				break;
162
+
163
+			case -23400 :
164
+				$gmt_offset = -21600;
165
+				break;
166
+
167
+			case -19800 :
168
+				$gmt_offset = -18000;
169
+				break;
170
+
171
+			case -9000 :
172
+				$gmt_offset = -7200;
173
+				break;
174
+
175
+			case -5400 :
176
+				$gmt_offset = -3600;
177
+				break;
178
+
179
+			case -1800 :
180
+				$gmt_offset = 0;
181
+				break;
182
+
183
+			case 1800 :
184
+				$gmt_offset = 3600;
185
+				break;
186
+
187
+			case 49500 :
188
+				$gmt_offset = 50400;
189
+				break;
190
+
191
+		}
192
+		return $gmt_offset;
193
+	}
194
+
195
+
196
+	/**
197
+	 * get_timezone_string_from_abbreviations_list
198
+	 *
199
+	 * @access public
200
+	 * @param int $gmt_offset
201
+	 * @return string
202
+	 * @throws \EE_Error
203
+	 */
204
+	public static function get_timezone_string_from_abbreviations_list($gmt_offset = 0)
205
+	{
206
+		$abbreviations = timezone_abbreviations_list();
207
+		foreach ($abbreviations as $abbreviation) {
208
+			foreach ($abbreviation as $city) {
209
+				if ($city['offset'] === $gmt_offset && $city['dst'] === false) {
210
+					// check if the timezone is valid but don't throw any errors if it isn't
211
+					if (EEH_DTT_Helper::validate_timezone($city['timezone_id'], false)) {
212
+						return $city['timezone_id'];
213
+					}
214
+				}
215
+			}
216
+		}
217
+		throw new EE_Error(
218
+			sprintf(
219
+				__('The provided GMT offset (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used',
220
+					'event_espresso'),
221
+				$gmt_offset,
222
+				'<a href="http://www.php.net/manual/en/timezones.php">',
223
+				'</a>'
224
+			)
225
+		);
226
+	}
227
+
228
+
229
+	/**
230
+	 * @access public
231
+	 * @param string $timezone_string
232
+	 */
233
+	public static function timezone_select_input($timezone_string = '')
234
+	{
235
+		// get WP date time format
236
+		$datetime_format = get_option('date_format') . ' ' . get_option('time_format');
237
+		// if passed a value, then use that, else get WP option
238
+		$timezone_string = ! empty($timezone_string) ? $timezone_string : get_option('timezone_string');
239
+		// check if the timezone is valid but don't throw any errors if it isn't
240
+		$timezone_string = EEH_DTT_Helper::validate_timezone($timezone_string, false);
241
+		$gmt_offset      = get_option('gmt_offset');
242
+
243
+		$check_zone_info = true;
244
+		if (empty($timezone_string)) {
245
+			// Create a UTC+- zone if no timezone string exists
246
+			$check_zone_info = false;
247
+			if ($gmt_offset > 0) {
248
+				$timezone_string = 'UTC+' . $gmt_offset;
249
+			} elseif ($gmt_offset < 0) {
250
+				$timezone_string = 'UTC' . $gmt_offset;
251
+			} else {
252
+				$timezone_string = 'UTC';
253
+			}
254
+		}
255
+		?>
256 256
 
257 257
         <p>
258 258
             <label for="timezone_string"><?php _e('timezone'); ?></label>
@@ -265,13 +265,13 @@  discard block
 block discarded – undo
265 265
 
266 266
         <p>
267 267
         <span><?php
268
-            printf(
269
-                __('%1$sUTC%2$s time is %3$s'),
270
-                '<abbr title="Coordinated Universal Time">',
271
-                '</abbr>',
272
-                '<code>' . date_i18n($datetime_format, false, true) . '</code>'
273
-            );
274
-            ?></span>
268
+			printf(
269
+				__('%1$sUTC%2$s time is %3$s'),
270
+				'<abbr title="Coordinated Universal Time">',
271
+				'</abbr>',
272
+				'<code>' . date_i18n($datetime_format, false, true) . '</code>'
273
+			);
274
+			?></span>
275 275
         <?php if (! empty($timezone_string) || ! empty($gmt_offset)) : ?>
276 276
         <br/><span><?php printf(__('Local time is %1$s'), '<code>' . date_i18n($datetime_format) . '</code>'); ?></span>
277 277
     <?php endif; ?>
@@ -280,650 +280,650 @@  discard block
 block discarded – undo
280 280
         <br/>
281 281
         <span>
282 282
 					<?php
283
-                    // Set TZ so localtime works.
284
-                    date_default_timezone_set($timezone_string);
285
-                    $now = localtime(time(), true);
286
-                    if ($now['tm_isdst']) {
287
-                        _e('This timezone is currently in daylight saving time.');
288
-                    } else {
289
-                        _e('This timezone is currently in standard time.');
290
-                    }
291
-                    ?>
283
+					// Set TZ so localtime works.
284
+					date_default_timezone_set($timezone_string);
285
+					$now = localtime(time(), true);
286
+					if ($now['tm_isdst']) {
287
+						_e('This timezone is currently in daylight saving time.');
288
+					} else {
289
+						_e('This timezone is currently in standard time.');
290
+					}
291
+					?>
292 292
             <br/>
293 293
             <?php
294
-            if (function_exists('timezone_transitions_get')) {
295
-                $found                   = false;
296
-                $date_time_zone_selected = new DateTimeZone($timezone_string);
297
-                $tz_offset               = timezone_offset_get($date_time_zone_selected, date_create());
298
-                $right_now               = time();
299
-                $tr['isdst']             = false;
300
-                foreach (timezone_transitions_get($date_time_zone_selected) as $tr) {
301
-                    if ($tr['ts'] > $right_now) {
302
-                        $found = true;
303
-                        break;
304
-                    }
305
-                }
306
-
307
-                if ($found) {
308
-                    $message = $tr['isdst'] ?
309
-                        __(' Daylight saving time begins on: %s.') :
310
-                        __(' Standard time begins  on: %s.');
311
-                    // Add the difference between the current offset and the new offset to ts to get the correct transition time from date_i18n().
312
-                    printf($message,
313
-                        '<code >' . date_i18n($datetime_format, $tr['ts'] + ($tz_offset - $tr['offset'])) . '</code >');
314
-                } else {
315
-                    _e('This timezone does not observe daylight saving time.');
316
-                }
317
-            }
318
-            // Set back to UTC.
319
-            date_default_timezone_set('UTC');
320
-            ?>
294
+			if (function_exists('timezone_transitions_get')) {
295
+				$found                   = false;
296
+				$date_time_zone_selected = new DateTimeZone($timezone_string);
297
+				$tz_offset               = timezone_offset_get($date_time_zone_selected, date_create());
298
+				$right_now               = time();
299
+				$tr['isdst']             = false;
300
+				foreach (timezone_transitions_get($date_time_zone_selected) as $tr) {
301
+					if ($tr['ts'] > $right_now) {
302
+						$found = true;
303
+						break;
304
+					}
305
+				}
306
+
307
+				if ($found) {
308
+					$message = $tr['isdst'] ?
309
+						__(' Daylight saving time begins on: %s.') :
310
+						__(' Standard time begins  on: %s.');
311
+					// Add the difference between the current offset and the new offset to ts to get the correct transition time from date_i18n().
312
+					printf($message,
313
+						'<code >' . date_i18n($datetime_format, $tr['ts'] + ($tz_offset - $tr['offset'])) . '</code >');
314
+				} else {
315
+					_e('This timezone does not observe daylight saving time.');
316
+				}
317
+			}
318
+			// Set back to UTC.
319
+			date_default_timezone_set('UTC');
320
+			?>
321 321
 				</span></p>
322 322
         <?php
323
-    endif;
324
-    }
325
-
326
-
327
-    /**
328
-     * This method will take an incoming unix timestamp and add the offset to it for the given timezone_string.
329
-     * If no unix timestamp is given then time() is used.  If no timezone is given then the set timezone string for
330
-     * the site is used.
331
-     * This is used typically when using a Unix timestamp any core WP functions that expect their specially
332
-     * computed timestamp (i.e. date_i18n() )
333
-     *
334
-     * @param int    $unix_timestamp                  if 0, then time() will be used.
335
-     * @param string $timezone_string                 timezone_string. If empty, then the current set timezone for the
336
-     *                                                site will be used.
337
-     * @return int      $unix_timestamp with the offset applied for the given timezone.
338
-     */
339
-    public static function get_timestamp_with_offset($unix_timestamp = 0, $timezone_string = '')
340
-    {
341
-        $unix_timestamp  = $unix_timestamp === 0 ? time() : (int)$unix_timestamp;
342
-        $timezone_string = self::get_valid_timezone_string($timezone_string);
343
-        $TimeZone        = new DateTimeZone($timezone_string);
344
-
345
-        $DateTime = new DateTime('@' . $unix_timestamp, $TimeZone);
346
-        $offset   = timezone_offset_get($TimeZone, $DateTime);
347
-        return (int)$DateTime->format('U') + (int)$offset;
348
-    }
349
-
350
-
351
-    /**
352
-     *    _set_date_time_field
353
-     *    modifies EE_Base_Class EE_Datetime_Field objects
354
-     *
355
-     * @param  EE_Base_Class $obj                 EE_Base_Class object
356
-     * @param    DateTime    $DateTime            PHP DateTime object
357
-     * @param  string        $datetime_field_name the datetime fieldname to be manipulated
358
-     * @return    EE_Base_Class
359
-     */
360
-    protected static function _set_date_time_field(EE_Base_Class $obj, DateTime $DateTime, $datetime_field_name)
361
-    {
362
-        // grab current datetime format
363
-        $current_format = $obj->get_format();
364
-        // set new full timestamp format
365
-        $obj->set_date_format(EE_Datetime_Field::mysql_date_format);
366
-        $obj->set_time_format(EE_Datetime_Field::mysql_time_format);
367
-        // set the new date value using a full timestamp format so that no data is lost
368
-        $obj->set($datetime_field_name, $DateTime->format(EE_Datetime_Field::mysql_timestamp_format));
369
-        // reset datetime formats
370
-        $obj->set_date_format($current_format[0]);
371
-        $obj->set_time_format($current_format[1]);
372
-        return $obj;
373
-    }
374
-
375
-
376
-    /**
377
-     *    date_time_add
378
-     *    helper for doing simple datetime calculations on a given datetime from EE_Base_Class
379
-     *    and modifying it IN the EE_Base_Class so you don't have to do anything else.
380
-     *
381
-     * @param  EE_Base_Class $obj                 EE_Base_Class object
382
-     * @param  string        $datetime_field_name name of the EE_Datetime_Filed datatype db column to be manipulated
383
-     * @param  string        $period              what you are adding. The options are (years, months, days, hours,
384
-     *                                            minutes, seconds) defaults to years
385
-     * @param  integer       $value               what you want to increment the time by
386
-     * @return EE_Base_Class           return the EE_Base_Class object so right away you can do something with it
387
-     *                                 (chaining)
388
-     */
389
-    public static function date_time_add(EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1)
390
-    {
391
-        //get the raw UTC date.
392
-        $DateTime = $obj->get_DateTime_object($datetime_field_name);
393
-        $DateTime = EEH_DTT_Helper::calc_date($DateTime, $period, $value);
394
-        return EEH_DTT_Helper::_set_date_time_field($obj, $DateTime, $datetime_field_name);
395
-    }
396
-
397
-
398
-    /**
399
-     *    date_time_subtract
400
-     *    same as date_time_add except subtracting value instead of adding.
401
-     *
402
-     * @param \EE_Base_Class $obj
403
-     * @param  string        $datetime_field_name name of the EE_Datetime_Filed datatype db column to be manipulated
404
-     * @param string         $period
405
-     * @param int            $value
406
-     * @return \EE_Base_Class
407
-     */
408
-    public static function date_time_subtract(EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1)
409
-    {
410
-        //get the raw UTC date
411
-        $DateTime = $obj->get_DateTime_object($datetime_field_name);
412
-        $DateTime = EEH_DTT_Helper::calc_date($DateTime, $period, $value, '-');
413
-        return EEH_DTT_Helper::_set_date_time_field($obj, $DateTime, $datetime_field_name);
414
-    }
415
-
416
-
417
-    /**
418
-     * Simply takes an incoming DateTime object and does calculations on it based on the incoming parameters
419
-     *
420
-     * @param  DateTime $DateTime DateTime object
421
-     * @param  string   $period   a value to indicate what interval is being used in the calculation. The options are
422
-     *                            'years', 'months', 'days', 'hours', 'minutes', 'seconds'. Defaults to years.
423
-     * @param  integer  $value    What you want to increment the date by
424
-     * @param  string   $operand  What operand you wish to use for the calculation
425
-     * @return \DateTime return whatever type came in.
426
-     * @throws \EE_Error
427
-     */
428
-    protected static function _modify_datetime_object(DateTime $DateTime, $period = 'years', $value = 1, $operand = '+')
429
-    {
430
-        if (! $DateTime instanceof DateTime) {
431
-            throw new EE_Error(
432
-                sprintf(
433
-                    __('Expected a PHP DateTime object, but instead received %1$s', 'event_espresso'),
434
-                    print_r($DateTime, true)
435
-                )
436
-            );
437
-        }
438
-        switch ($period) {
439
-            case 'years' :
440
-                $value = 'P' . $value . 'Y';
441
-                break;
442
-            case 'months' :
443
-                $value = 'P' . $value . 'M';
444
-                break;
445
-            case 'weeks' :
446
-                $value = 'P' . $value . 'W';
447
-                break;
448
-            case 'days' :
449
-                $value = 'P' . $value . 'D';
450
-                break;
451
-            case 'hours' :
452
-                $value = 'PT' . $value . 'H';
453
-                break;
454
-            case 'minutes' :
455
-                $value = 'PT' . $value . 'M';
456
-                break;
457
-            case 'seconds' :
458
-                $value = 'PT' . $value . 'S';
459
-                break;
460
-        }
461
-        switch ($operand) {
462
-            case '+':
463
-                $DateTime->add(new DateInterval($value));
464
-                break;
465
-            case '-':
466
-                $DateTime->sub(new DateInterval($value));
467
-                break;
468
-        }
469
-        return $DateTime;
470
-    }
471
-
472
-
473
-    /**
474
-     * Simply takes an incoming Unix timestamp and does calculations on it based on the incoming parameters
475
-     *
476
-     * @param  int     $timestamp Unix timestamp
477
-     * @param  string  $period    a value to indicate what interval is being used in the calculation. The options are
478
-     *                            'years', 'months', 'days', 'hours', 'minutes', 'seconds'. Defaults to years.
479
-     * @param  integer $value     What you want to increment the date by
480
-     * @param  string  $operand   What operand you wish to use for the calculation
481
-     * @return \DateTime return whatever type came in.
482
-     * @throws \EE_Error
483
-     */
484
-    protected static function _modify_timestamp($timestamp, $period = 'years', $value = 1, $operand = '+')
485
-    {
486
-        if (! preg_match(EE_Datetime_Field::unix_timestamp_regex, $timestamp)) {
487
-            throw new EE_Error(
488
-                sprintf(
489
-                    __('Expected a Unix timestamp, but instead received %1$s', 'event_espresso'),
490
-                    print_r($timestamp, true)
491
-                )
492
-            );
493
-        }
494
-        switch ($period) {
495
-            case 'years' :
496
-                $value = YEAR_IN_SECONDS * $value;
497
-                break;
498
-            case 'months' :
499
-                $value = YEAR_IN_SECONDS / 12 * $value;
500
-                break;
501
-            case 'weeks' :
502
-                $value = WEEK_IN_SECONDS * $value;
503
-                break;
504
-            case 'days' :
505
-                $value = DAY_IN_SECONDS * $value;
506
-                break;
507
-            case 'hours' :
508
-                $value = HOUR_IN_SECONDS * $value;
509
-                break;
510
-            case 'minutes' :
511
-                $value = MINUTE_IN_SECONDS * $value;
512
-                break;
513
-        }
514
-        switch ($operand) {
515
-            case '+':
516
-                $timestamp += $value;
517
-                break;
518
-            case '-':
519
-                $timestamp -= $value;
520
-                break;
521
-        }
522
-        return $timestamp;
523
-    }
524
-
525
-
526
-    /**
527
-     * Simply takes an incoming UTC timestamp or DateTime object and does calculations on it based on the incoming
528
-     * parameters and returns the new timestamp or DateTime.
529
-     *
530
-     * @param  int | DateTime $DateTime_or_timestamp DateTime object or Unix timestamp
531
-     * @param  string         $period                a value to indicate what interval is being used in the
532
-     *                                               calculation. The options are 'years', 'months', 'days', 'hours',
533
-     *                                               'minutes', 'seconds'. Defaults to years.
534
-     * @param  integer        $value                 What you want to increment the date by
535
-     * @param  string         $operand               What operand you wish to use for the calculation
536
-     * @return mixed string|DateTime          return whatever type came in.
537
-     */
538
-    public static function calc_date($DateTime_or_timestamp, $period = 'years', $value = 1, $operand = '+')
539
-    {
540
-        if ($DateTime_or_timestamp instanceof DateTime) {
541
-            return EEH_DTT_Helper::_modify_datetime_object($DateTime_or_timestamp, $period, $value, $operand);
542
-        } else if (preg_match(EE_Datetime_Field::unix_timestamp_regex, $DateTime_or_timestamp)) {
543
-            return EEH_DTT_Helper::_modify_timestamp($DateTime_or_timestamp, $period, $value, $operand);
544
-        } else {
545
-            //error
546
-            return $DateTime_or_timestamp;
547
-        }
548
-    }
549
-
550
-
551
-    /**
552
-     * The purpose of this helper method is to receive an incoming format string in php date/time format
553
-     * and spit out the js and moment.js equivalent formats.
554
-     * Note, if no format string is given, then it is assumed the user wants what is set for WP.
555
-     * Note, js date and time formats are those used by the jquery-ui datepicker and the jquery-ui date-
556
-     * time picker.
557
-     *
558
-     * @see http://stackoverflow.com/posts/16725290/ for the code inspiration.
559
-     * @param null $date_format_string
560
-     * @param null $time_format_string
561
-     * @return array
562
-     *                array(
563
-     *                'js' => array (
564
-     *                'date' => //date format
565
-     *                'time' => //time format
566
-     *                ),
567
-     *                'moment' => //date and time format.
568
-     *                )
569
-     */
570
-    public static function convert_php_to_js_and_moment_date_formats(
571
-        $date_format_string = null,
572
-        $time_format_string = null
573
-    ) {
574
-        if ($date_format_string === null) {
575
-            $date_format_string = get_option('date_format');
576
-        }
577
-
578
-        if ($time_format_string === null) {
579
-            $time_format_string = get_option('time_format');
580
-        }
581
-
582
-        $date_format = self::_php_to_js_moment_converter($date_format_string);
583
-        $time_format = self::_php_to_js_moment_converter($time_format_string);
584
-
585
-        return array(
586
-            'js'     => array(
587
-                'date' => $date_format['js'],
588
-                'time' => $time_format['js'],
589
-            ),
590
-            'moment' => $date_format['moment'] . ' ' . $time_format['moment'],
591
-        );
592
-    }
593
-
594
-
595
-    /**
596
-     * This converts incoming format string into js and moment variations.
597
-     *
598
-     * @param string $format_string incoming php format string
599
-     * @return array js and moment formats.
600
-     */
601
-    protected static function _php_to_js_moment_converter($format_string)
602
-    {
603
-        /**
604
-         * This is a map of symbols for formats.
605
-         * The index is the php symbol, the equivalent values are in the array.
606
-         *
607
-         * @var array
608
-         */
609
-        $symbols_map      = array(
610
-            // Day
611
-            //01
612
-            'd' => array(
613
-                'js'     => 'dd',
614
-                'moment' => 'DD',
615
-            ),
616
-            //Mon
617
-            'D' => array(
618
-                'js'     => 'D',
619
-                'moment' => 'ddd',
620
-            ),
621
-            //1,2,...31
622
-            'j' => array(
623
-                'js'     => 'd',
624
-                'moment' => 'D',
625
-            ),
626
-            //Monday
627
-            'l' => array(
628
-                'js'     => 'DD',
629
-                'moment' => 'dddd',
630
-            ),
631
-            //ISO numeric representation of the day of the week (1-6)
632
-            'N' => array(
633
-                'js'     => '',
634
-                'moment' => 'E',
635
-            ),
636
-            //st,nd.rd
637
-            'S' => array(
638
-                'js'     => '',
639
-                'moment' => 'o',
640
-            ),
641
-            //numeric representation of day of week (0-6)
642
-            'w' => array(
643
-                'js'     => '',
644
-                'moment' => 'd',
645
-            ),
646
-            //day of year starting from 0 (0-365)
647
-            'z' => array(
648
-                'js'     => 'o',
649
-                'moment' => 'DDD' //note moment does not start with 0 so will need to modify by subtracting 1
650
-            ),
651
-            // Week
652
-            //ISO-8601 week number of year (weeks starting on monday)
653
-            'W' => array(
654
-                'js'     => '',
655
-                'moment' => 'w',
656
-            ),
657
-            // Month
658
-            // January...December
659
-            'F' => array(
660
-                'js'     => 'MM',
661
-                'moment' => 'MMMM',
662
-            ),
663
-            //01...12
664
-            'm' => array(
665
-                'js'     => 'mm',
666
-                'moment' => 'MM',
667
-            ),
668
-            //Jan...Dec
669
-            'M' => array(
670
-                'js'     => 'M',
671
-                'moment' => 'MMM',
672
-            ),
673
-            //1-12
674
-            'n' => array(
675
-                'js'     => 'm',
676
-                'moment' => 'M',
677
-            ),
678
-            //number of days in given month
679
-            't' => array(
680
-                'js'     => '',
681
-                'moment' => '',
682
-            ),
683
-            // Year
684
-            //whether leap year or not 1/0
685
-            'L' => array(
686
-                'js'     => '',
687
-                'moment' => '',
688
-            ),
689
-            //ISO-8601 year number
690
-            'o' => array(
691
-                'js'     => '',
692
-                'moment' => 'GGGG',
693
-            ),
694
-            //1999...2003
695
-            'Y' => array(
696
-                'js'     => 'yy',
697
-                'moment' => 'YYYY',
698
-            ),
699
-            //99...03
700
-            'y' => array(
701
-                'js'     => 'y',
702
-                'moment' => 'YY',
703
-            ),
704
-            // Time
705
-            // am/pm
706
-            'a' => array(
707
-                'js'     => 'tt',
708
-                'moment' => 'a',
709
-            ),
710
-            // AM/PM
711
-            'A' => array(
712
-                'js'     => 'TT',
713
-                'moment' => 'A',
714
-            ),
715
-            // Swatch Internet Time?!?
716
-            'B' => array(
717
-                'js'     => '',
718
-                'moment' => '',
719
-            ),
720
-            //1...12
721
-            'g' => array(
722
-                'js'     => 'h',
723
-                'moment' => 'h',
724
-            ),
725
-            //0...23
726
-            'G' => array(
727
-                'js'     => 'H',
728
-                'moment' => 'H',
729
-            ),
730
-            //01...12
731
-            'h' => array(
732
-                'js'     => 'hh',
733
-                'moment' => 'hh',
734
-            ),
735
-            //00...23
736
-            'H' => array(
737
-                'js'     => 'HH',
738
-                'moment' => 'HH',
739
-            ),
740
-            //00..59
741
-            'i' => array(
742
-                'js'     => 'mm',
743
-                'moment' => 'mm',
744
-            ),
745
-            //seconds... 00...59
746
-            's' => array(
747
-                'js'     => 'ss',
748
-                'moment' => 'ss',
749
-            ),
750
-            //microseconds
751
-            'u' => array(
752
-                'js'     => '',
753
-                'moment' => '',
754
-            ),
755
-        );
756
-        $jquery_ui_format = "";
757
-        $moment_format    = "";
758
-        $escaping         = false;
759
-        for ($i = 0; $i < strlen($format_string); $i++) {
760
-            $char = $format_string[$i];
761
-            if ($char === '\\') { // PHP date format escaping character
762
-                $i++;
763
-                if ($escaping) {
764
-                    $jquery_ui_format .= $format_string[$i];
765
-                    $moment_format .= $format_string[$i];
766
-                } else {
767
-                    $jquery_ui_format .= '\'' . $format_string[$i];
768
-                    $moment_format .= $format_string[$i];
769
-                }
770
-                $escaping = true;
771
-            } else {
772
-                if ($escaping) {
773
-                    $jquery_ui_format .= "'";
774
-                    $moment_format .= "'";
775
-                    $escaping = false;
776
-                }
777
-                if (isset($symbols_map[$char])) {
778
-                    $jquery_ui_format .= $symbols_map[$char]['js'];
779
-                    $moment_format .= $symbols_map[$char]['moment'];
780
-                } else {
781
-                    $jquery_ui_format .= $char;
782
-                    $moment_format .= $char;
783
-                }
784
-            }
785
-        }
786
-        return array('js' => $jquery_ui_format, 'moment' => $moment_format);
787
-    }
788
-
789
-
790
-    /**
791
-     * This takes an incoming format string and validates it to ensure it will work fine with PHP.
792
-     *
793
-     * @param string $format_string   Incoming format string for php date().
794
-     * @return mixed bool|array  If all is okay then TRUE is returned.  Otherwise an array of validation
795
-     *                                errors is returned.  So for client code calling, check for is_array() to
796
-     *                                indicate failed validations.
797
-     */
798
-    public static function validate_format_string($format_string)
799
-    {
800
-        $error_msg = array();
801
-        //time format checks
802
-        switch (true) {
803
-            case   strpos($format_string, 'h') !== false  :
804
-            case   strpos($format_string, 'g') !== false :
805
-                /**
806
-                 * if the time string has a lowercase 'h' which == 12 hour time format and there
807
-                 * is not any ante meridiem format ('a' or 'A').  Then throw an error because its
808
-                 * too ambiguous and PHP won't be able to figure out whether 1 = 1pm or 1am.
809
-                 */
810
-                if (strpos(strtoupper($format_string), 'A') === false) {
811
-                    $error_msg[] = __('There is a  time format for 12 hour time but no  "a" or "A" to indicate am/pm.  Without this distinction, PHP is unable to determine if a "1" for the hour value equals "1pm" or "1am".',
812
-                        'event_espresso');
813
-                }
814
-                break;
815
-
816
-        }
817
-
818
-        return empty($error_msg) ? true : $error_msg;
819
-    }
820
-
821
-
822
-    /**
823
-     *     If the the first date starts at midnight on one day, and the next date ends at midnight on the
824
-     *     very next day then this method will return true.
825
-     *    If $date_1 = 2015-12-15 00:00:00 and $date_2 = 2015-12-16 00:00:00 then this function will return true.
826
-     *    If $date_1 = 2015-12-15 03:00:00 and $date_2 = 2015-12_16 03:00:00 then this function will return false.
827
-     *    If $date_1 = 2015-12-15 00:00:00 and $date_2 = 2015-12-15 00:00:00 then this function will return true.
828
-     *
829
-     * @param mixed $date_1
830
-     * @param mixed $date_2
831
-     * @return bool
832
-     */
833
-    public static function dates_represent_one_24_hour_date($date_1, $date_2)
834
-    {
835
-
836
-        if (
837
-            (! $date_1 instanceof DateTime || ! $date_2 instanceof DateTime) ||
838
-            ($date_1->format(EE_Datetime_Field::mysql_time_format) != '00:00:00' || $date_2->format(EE_Datetime_Field::mysql_time_format) != '00:00:00')
839
-        ) {
840
-            return false;
841
-        }
842
-        return $date_2->format('U') - $date_1->format('U') == 86400 ? true : false;
843
-    }
844
-
845
-
846
-    /**
847
-     * This returns the appropriate query interval string that can be used in sql queries involving mysql Date
848
-     * Functions.
849
-     *
850
-     * @param string $timezone_string    A timezone string in a valid format to instantiate a DateTimeZone object.
851
-     * @param string $field_for_interval The Database field that is the interval is applied to in the query.
852
-     * @return string
853
-     */
854
-    public static function get_sql_query_interval_for_offset($timezone_string, $field_for_interval)
855
-    {
856
-        try {
857
-            /** need to account for timezone offset on the selects */
858
-            $DateTimeZone = new DateTimeZone($timezone_string);
859
-        } catch (Exception $e) {
860
-            $DateTimeZone = null;
861
-        }
862
-
863
-        /**
864
-         * Note get_option( 'gmt_offset') returns a value in hours, whereas DateTimeZone::getOffset returns values in seconds.
865
-         * Hence we do the calc for DateTimeZone::getOffset.
866
-         */
867
-        $offset         = $DateTimeZone instanceof DateTimeZone ? ($DateTimeZone->getOffset(new DateTime('now'))) / HOUR_IN_SECONDS : get_option('gmt_offset');
868
-        $query_interval = $offset < 0
869
-            ? 'DATE_SUB(' . $field_for_interval . ', INTERVAL ' . $offset * -1 . ' HOUR)'
870
-            : 'DATE_ADD(' . $field_for_interval . ', INTERVAL ' . $offset . ' HOUR)';
871
-        return $query_interval;
872
-    }
873
-
874
-    /**
875
-     * Retrieves the site's default timezone and returns it formatted so it's ready for display
876
-     * to users. If you want to customize how its displayed feel free to fetch the 'timezone_string'
877
-     * and 'gmt_offset' WordPress options directly; or use the filter
878
-     * FHEE__EEH_DTT_Helper__get_timezone_string_for_display
879
-     * (although note that we remove any HTML that may be added)
880
-     *
881
-     * @return string
882
-     */
883
-    public static function get_timezone_string_for_display()
884
-    {
885
-        $pretty_timezone = apply_filters('FHEE__EEH_DTT_Helper__get_timezone_string_for_display', '');
886
-        if (! empty($pretty_timezone)) {
887
-            return esc_html($pretty_timezone);
888
-        }
889
-        $timezone_string = get_option('timezone_string');
890
-        if ($timezone_string) {
891
-            static $mo_loaded = false;
892
-            // Load translations for continents and cities just like wp_timezone_choice does
893
-            if (! $mo_loaded) {
894
-                $locale = get_locale();
895
-                $mofile = WP_LANG_DIR . '/continents-cities-' . $locale . '.mo';
896
-                load_textdomain('continents-cities', $mofile);
897
-                $mo_loaded = true;
898
-            }
899
-            //well that was easy.
900
-            $parts = explode('/', $timezone_string);
901
-            //remove the continent
902
-            unset($parts[0]);
903
-            $t_parts = array();
904
-            foreach ($parts as $part) {
905
-                $t_parts[] = translate(str_replace('_', ' ', $part), 'continents-cities');
906
-            }
907
-            return implode(' - ', $t_parts);
908
-        }
909
-        //they haven't set the timezone string, so let's return a string like "UTC+1"
910
-        $gmt_offset = get_option('gmt_offset');
911
-        if (intval($gmt_offset) >= 0) {
912
-            $prefix = '+';
913
-        } else {
914
-            $prefix = '';
915
-        }
916
-        $parts = explode('.', (string)$gmt_offset);
917
-        if (count($parts) === 1) {
918
-            $parts[1] = '00';
919
-        } else {
920
-            //convert the part after the decimal, eg "5" (from x.5) or "25" (from x.25)
921
-            //to minutes, eg 30 or 15, respectively
922
-            $hour_fraction = (float)('0.' . $parts[1]);
923
-            $parts[1]      = (string)$hour_fraction * 60;
924
-        }
925
-        return sprintf(__('UTC%1$s', 'event_espresso'), $prefix . implode(':', $parts));
926
-    }
323
+	endif;
324
+	}
325
+
326
+
327
+	/**
328
+	 * This method will take an incoming unix timestamp and add the offset to it for the given timezone_string.
329
+	 * If no unix timestamp is given then time() is used.  If no timezone is given then the set timezone string for
330
+	 * the site is used.
331
+	 * This is used typically when using a Unix timestamp any core WP functions that expect their specially
332
+	 * computed timestamp (i.e. date_i18n() )
333
+	 *
334
+	 * @param int    $unix_timestamp                  if 0, then time() will be used.
335
+	 * @param string $timezone_string                 timezone_string. If empty, then the current set timezone for the
336
+	 *                                                site will be used.
337
+	 * @return int      $unix_timestamp with the offset applied for the given timezone.
338
+	 */
339
+	public static function get_timestamp_with_offset($unix_timestamp = 0, $timezone_string = '')
340
+	{
341
+		$unix_timestamp  = $unix_timestamp === 0 ? time() : (int)$unix_timestamp;
342
+		$timezone_string = self::get_valid_timezone_string($timezone_string);
343
+		$TimeZone        = new DateTimeZone($timezone_string);
344
+
345
+		$DateTime = new DateTime('@' . $unix_timestamp, $TimeZone);
346
+		$offset   = timezone_offset_get($TimeZone, $DateTime);
347
+		return (int)$DateTime->format('U') + (int)$offset;
348
+	}
349
+
350
+
351
+	/**
352
+	 *    _set_date_time_field
353
+	 *    modifies EE_Base_Class EE_Datetime_Field objects
354
+	 *
355
+	 * @param  EE_Base_Class $obj                 EE_Base_Class object
356
+	 * @param    DateTime    $DateTime            PHP DateTime object
357
+	 * @param  string        $datetime_field_name the datetime fieldname to be manipulated
358
+	 * @return    EE_Base_Class
359
+	 */
360
+	protected static function _set_date_time_field(EE_Base_Class $obj, DateTime $DateTime, $datetime_field_name)
361
+	{
362
+		// grab current datetime format
363
+		$current_format = $obj->get_format();
364
+		// set new full timestamp format
365
+		$obj->set_date_format(EE_Datetime_Field::mysql_date_format);
366
+		$obj->set_time_format(EE_Datetime_Field::mysql_time_format);
367
+		// set the new date value using a full timestamp format so that no data is lost
368
+		$obj->set($datetime_field_name, $DateTime->format(EE_Datetime_Field::mysql_timestamp_format));
369
+		// reset datetime formats
370
+		$obj->set_date_format($current_format[0]);
371
+		$obj->set_time_format($current_format[1]);
372
+		return $obj;
373
+	}
374
+
375
+
376
+	/**
377
+	 *    date_time_add
378
+	 *    helper for doing simple datetime calculations on a given datetime from EE_Base_Class
379
+	 *    and modifying it IN the EE_Base_Class so you don't have to do anything else.
380
+	 *
381
+	 * @param  EE_Base_Class $obj                 EE_Base_Class object
382
+	 * @param  string        $datetime_field_name name of the EE_Datetime_Filed datatype db column to be manipulated
383
+	 * @param  string        $period              what you are adding. The options are (years, months, days, hours,
384
+	 *                                            minutes, seconds) defaults to years
385
+	 * @param  integer       $value               what you want to increment the time by
386
+	 * @return EE_Base_Class           return the EE_Base_Class object so right away you can do something with it
387
+	 *                                 (chaining)
388
+	 */
389
+	public static function date_time_add(EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1)
390
+	{
391
+		//get the raw UTC date.
392
+		$DateTime = $obj->get_DateTime_object($datetime_field_name);
393
+		$DateTime = EEH_DTT_Helper::calc_date($DateTime, $period, $value);
394
+		return EEH_DTT_Helper::_set_date_time_field($obj, $DateTime, $datetime_field_name);
395
+	}
396
+
397
+
398
+	/**
399
+	 *    date_time_subtract
400
+	 *    same as date_time_add except subtracting value instead of adding.
401
+	 *
402
+	 * @param \EE_Base_Class $obj
403
+	 * @param  string        $datetime_field_name name of the EE_Datetime_Filed datatype db column to be manipulated
404
+	 * @param string         $period
405
+	 * @param int            $value
406
+	 * @return \EE_Base_Class
407
+	 */
408
+	public static function date_time_subtract(EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1)
409
+	{
410
+		//get the raw UTC date
411
+		$DateTime = $obj->get_DateTime_object($datetime_field_name);
412
+		$DateTime = EEH_DTT_Helper::calc_date($DateTime, $period, $value, '-');
413
+		return EEH_DTT_Helper::_set_date_time_field($obj, $DateTime, $datetime_field_name);
414
+	}
415
+
416
+
417
+	/**
418
+	 * Simply takes an incoming DateTime object and does calculations on it based on the incoming parameters
419
+	 *
420
+	 * @param  DateTime $DateTime DateTime object
421
+	 * @param  string   $period   a value to indicate what interval is being used in the calculation. The options are
422
+	 *                            'years', 'months', 'days', 'hours', 'minutes', 'seconds'. Defaults to years.
423
+	 * @param  integer  $value    What you want to increment the date by
424
+	 * @param  string   $operand  What operand you wish to use for the calculation
425
+	 * @return \DateTime return whatever type came in.
426
+	 * @throws \EE_Error
427
+	 */
428
+	protected static function _modify_datetime_object(DateTime $DateTime, $period = 'years', $value = 1, $operand = '+')
429
+	{
430
+		if (! $DateTime instanceof DateTime) {
431
+			throw new EE_Error(
432
+				sprintf(
433
+					__('Expected a PHP DateTime object, but instead received %1$s', 'event_espresso'),
434
+					print_r($DateTime, true)
435
+				)
436
+			);
437
+		}
438
+		switch ($period) {
439
+			case 'years' :
440
+				$value = 'P' . $value . 'Y';
441
+				break;
442
+			case 'months' :
443
+				$value = 'P' . $value . 'M';
444
+				break;
445
+			case 'weeks' :
446
+				$value = 'P' . $value . 'W';
447
+				break;
448
+			case 'days' :
449
+				$value = 'P' . $value . 'D';
450
+				break;
451
+			case 'hours' :
452
+				$value = 'PT' . $value . 'H';
453
+				break;
454
+			case 'minutes' :
455
+				$value = 'PT' . $value . 'M';
456
+				break;
457
+			case 'seconds' :
458
+				$value = 'PT' . $value . 'S';
459
+				break;
460
+		}
461
+		switch ($operand) {
462
+			case '+':
463
+				$DateTime->add(new DateInterval($value));
464
+				break;
465
+			case '-':
466
+				$DateTime->sub(new DateInterval($value));
467
+				break;
468
+		}
469
+		return $DateTime;
470
+	}
471
+
472
+
473
+	/**
474
+	 * Simply takes an incoming Unix timestamp and does calculations on it based on the incoming parameters
475
+	 *
476
+	 * @param  int     $timestamp Unix timestamp
477
+	 * @param  string  $period    a value to indicate what interval is being used in the calculation. The options are
478
+	 *                            'years', 'months', 'days', 'hours', 'minutes', 'seconds'. Defaults to years.
479
+	 * @param  integer $value     What you want to increment the date by
480
+	 * @param  string  $operand   What operand you wish to use for the calculation
481
+	 * @return \DateTime return whatever type came in.
482
+	 * @throws \EE_Error
483
+	 */
484
+	protected static function _modify_timestamp($timestamp, $period = 'years', $value = 1, $operand = '+')
485
+	{
486
+		if (! preg_match(EE_Datetime_Field::unix_timestamp_regex, $timestamp)) {
487
+			throw new EE_Error(
488
+				sprintf(
489
+					__('Expected a Unix timestamp, but instead received %1$s', 'event_espresso'),
490
+					print_r($timestamp, true)
491
+				)
492
+			);
493
+		}
494
+		switch ($period) {
495
+			case 'years' :
496
+				$value = YEAR_IN_SECONDS * $value;
497
+				break;
498
+			case 'months' :
499
+				$value = YEAR_IN_SECONDS / 12 * $value;
500
+				break;
501
+			case 'weeks' :
502
+				$value = WEEK_IN_SECONDS * $value;
503
+				break;
504
+			case 'days' :
505
+				$value = DAY_IN_SECONDS * $value;
506
+				break;
507
+			case 'hours' :
508
+				$value = HOUR_IN_SECONDS * $value;
509
+				break;
510
+			case 'minutes' :
511
+				$value = MINUTE_IN_SECONDS * $value;
512
+				break;
513
+		}
514
+		switch ($operand) {
515
+			case '+':
516
+				$timestamp += $value;
517
+				break;
518
+			case '-':
519
+				$timestamp -= $value;
520
+				break;
521
+		}
522
+		return $timestamp;
523
+	}
524
+
525
+
526
+	/**
527
+	 * Simply takes an incoming UTC timestamp or DateTime object and does calculations on it based on the incoming
528
+	 * parameters and returns the new timestamp or DateTime.
529
+	 *
530
+	 * @param  int | DateTime $DateTime_or_timestamp DateTime object or Unix timestamp
531
+	 * @param  string         $period                a value to indicate what interval is being used in the
532
+	 *                                               calculation. The options are 'years', 'months', 'days', 'hours',
533
+	 *                                               'minutes', 'seconds'. Defaults to years.
534
+	 * @param  integer        $value                 What you want to increment the date by
535
+	 * @param  string         $operand               What operand you wish to use for the calculation
536
+	 * @return mixed string|DateTime          return whatever type came in.
537
+	 */
538
+	public static function calc_date($DateTime_or_timestamp, $period = 'years', $value = 1, $operand = '+')
539
+	{
540
+		if ($DateTime_or_timestamp instanceof DateTime) {
541
+			return EEH_DTT_Helper::_modify_datetime_object($DateTime_or_timestamp, $period, $value, $operand);
542
+		} else if (preg_match(EE_Datetime_Field::unix_timestamp_regex, $DateTime_or_timestamp)) {
543
+			return EEH_DTT_Helper::_modify_timestamp($DateTime_or_timestamp, $period, $value, $operand);
544
+		} else {
545
+			//error
546
+			return $DateTime_or_timestamp;
547
+		}
548
+	}
549
+
550
+
551
+	/**
552
+	 * The purpose of this helper method is to receive an incoming format string in php date/time format
553
+	 * and spit out the js and moment.js equivalent formats.
554
+	 * Note, if no format string is given, then it is assumed the user wants what is set for WP.
555
+	 * Note, js date and time formats are those used by the jquery-ui datepicker and the jquery-ui date-
556
+	 * time picker.
557
+	 *
558
+	 * @see http://stackoverflow.com/posts/16725290/ for the code inspiration.
559
+	 * @param null $date_format_string
560
+	 * @param null $time_format_string
561
+	 * @return array
562
+	 *                array(
563
+	 *                'js' => array (
564
+	 *                'date' => //date format
565
+	 *                'time' => //time format
566
+	 *                ),
567
+	 *                'moment' => //date and time format.
568
+	 *                )
569
+	 */
570
+	public static function convert_php_to_js_and_moment_date_formats(
571
+		$date_format_string = null,
572
+		$time_format_string = null
573
+	) {
574
+		if ($date_format_string === null) {
575
+			$date_format_string = get_option('date_format');
576
+		}
577
+
578
+		if ($time_format_string === null) {
579
+			$time_format_string = get_option('time_format');
580
+		}
581
+
582
+		$date_format = self::_php_to_js_moment_converter($date_format_string);
583
+		$time_format = self::_php_to_js_moment_converter($time_format_string);
584
+
585
+		return array(
586
+			'js'     => array(
587
+				'date' => $date_format['js'],
588
+				'time' => $time_format['js'],
589
+			),
590
+			'moment' => $date_format['moment'] . ' ' . $time_format['moment'],
591
+		);
592
+	}
593
+
594
+
595
+	/**
596
+	 * This converts incoming format string into js and moment variations.
597
+	 *
598
+	 * @param string $format_string incoming php format string
599
+	 * @return array js and moment formats.
600
+	 */
601
+	protected static function _php_to_js_moment_converter($format_string)
602
+	{
603
+		/**
604
+		 * This is a map of symbols for formats.
605
+		 * The index is the php symbol, the equivalent values are in the array.
606
+		 *
607
+		 * @var array
608
+		 */
609
+		$symbols_map      = array(
610
+			// Day
611
+			//01
612
+			'd' => array(
613
+				'js'     => 'dd',
614
+				'moment' => 'DD',
615
+			),
616
+			//Mon
617
+			'D' => array(
618
+				'js'     => 'D',
619
+				'moment' => 'ddd',
620
+			),
621
+			//1,2,...31
622
+			'j' => array(
623
+				'js'     => 'd',
624
+				'moment' => 'D',
625
+			),
626
+			//Monday
627
+			'l' => array(
628
+				'js'     => 'DD',
629
+				'moment' => 'dddd',
630
+			),
631
+			//ISO numeric representation of the day of the week (1-6)
632
+			'N' => array(
633
+				'js'     => '',
634
+				'moment' => 'E',
635
+			),
636
+			//st,nd.rd
637
+			'S' => array(
638
+				'js'     => '',
639
+				'moment' => 'o',
640
+			),
641
+			//numeric representation of day of week (0-6)
642
+			'w' => array(
643
+				'js'     => '',
644
+				'moment' => 'd',
645
+			),
646
+			//day of year starting from 0 (0-365)
647
+			'z' => array(
648
+				'js'     => 'o',
649
+				'moment' => 'DDD' //note moment does not start with 0 so will need to modify by subtracting 1
650
+			),
651
+			// Week
652
+			//ISO-8601 week number of year (weeks starting on monday)
653
+			'W' => array(
654
+				'js'     => '',
655
+				'moment' => 'w',
656
+			),
657
+			// Month
658
+			// January...December
659
+			'F' => array(
660
+				'js'     => 'MM',
661
+				'moment' => 'MMMM',
662
+			),
663
+			//01...12
664
+			'm' => array(
665
+				'js'     => 'mm',
666
+				'moment' => 'MM',
667
+			),
668
+			//Jan...Dec
669
+			'M' => array(
670
+				'js'     => 'M',
671
+				'moment' => 'MMM',
672
+			),
673
+			//1-12
674
+			'n' => array(
675
+				'js'     => 'm',
676
+				'moment' => 'M',
677
+			),
678
+			//number of days in given month
679
+			't' => array(
680
+				'js'     => '',
681
+				'moment' => '',
682
+			),
683
+			// Year
684
+			//whether leap year or not 1/0
685
+			'L' => array(
686
+				'js'     => '',
687
+				'moment' => '',
688
+			),
689
+			//ISO-8601 year number
690
+			'o' => array(
691
+				'js'     => '',
692
+				'moment' => 'GGGG',
693
+			),
694
+			//1999...2003
695
+			'Y' => array(
696
+				'js'     => 'yy',
697
+				'moment' => 'YYYY',
698
+			),
699
+			//99...03
700
+			'y' => array(
701
+				'js'     => 'y',
702
+				'moment' => 'YY',
703
+			),
704
+			// Time
705
+			// am/pm
706
+			'a' => array(
707
+				'js'     => 'tt',
708
+				'moment' => 'a',
709
+			),
710
+			// AM/PM
711
+			'A' => array(
712
+				'js'     => 'TT',
713
+				'moment' => 'A',
714
+			),
715
+			// Swatch Internet Time?!?
716
+			'B' => array(
717
+				'js'     => '',
718
+				'moment' => '',
719
+			),
720
+			//1...12
721
+			'g' => array(
722
+				'js'     => 'h',
723
+				'moment' => 'h',
724
+			),
725
+			//0...23
726
+			'G' => array(
727
+				'js'     => 'H',
728
+				'moment' => 'H',
729
+			),
730
+			//01...12
731
+			'h' => array(
732
+				'js'     => 'hh',
733
+				'moment' => 'hh',
734
+			),
735
+			//00...23
736
+			'H' => array(
737
+				'js'     => 'HH',
738
+				'moment' => 'HH',
739
+			),
740
+			//00..59
741
+			'i' => array(
742
+				'js'     => 'mm',
743
+				'moment' => 'mm',
744
+			),
745
+			//seconds... 00...59
746
+			's' => array(
747
+				'js'     => 'ss',
748
+				'moment' => 'ss',
749
+			),
750
+			//microseconds
751
+			'u' => array(
752
+				'js'     => '',
753
+				'moment' => '',
754
+			),
755
+		);
756
+		$jquery_ui_format = "";
757
+		$moment_format    = "";
758
+		$escaping         = false;
759
+		for ($i = 0; $i < strlen($format_string); $i++) {
760
+			$char = $format_string[$i];
761
+			if ($char === '\\') { // PHP date format escaping character
762
+				$i++;
763
+				if ($escaping) {
764
+					$jquery_ui_format .= $format_string[$i];
765
+					$moment_format .= $format_string[$i];
766
+				} else {
767
+					$jquery_ui_format .= '\'' . $format_string[$i];
768
+					$moment_format .= $format_string[$i];
769
+				}
770
+				$escaping = true;
771
+			} else {
772
+				if ($escaping) {
773
+					$jquery_ui_format .= "'";
774
+					$moment_format .= "'";
775
+					$escaping = false;
776
+				}
777
+				if (isset($symbols_map[$char])) {
778
+					$jquery_ui_format .= $symbols_map[$char]['js'];
779
+					$moment_format .= $symbols_map[$char]['moment'];
780
+				} else {
781
+					$jquery_ui_format .= $char;
782
+					$moment_format .= $char;
783
+				}
784
+			}
785
+		}
786
+		return array('js' => $jquery_ui_format, 'moment' => $moment_format);
787
+	}
788
+
789
+
790
+	/**
791
+	 * This takes an incoming format string and validates it to ensure it will work fine with PHP.
792
+	 *
793
+	 * @param string $format_string   Incoming format string for php date().
794
+	 * @return mixed bool|array  If all is okay then TRUE is returned.  Otherwise an array of validation
795
+	 *                                errors is returned.  So for client code calling, check for is_array() to
796
+	 *                                indicate failed validations.
797
+	 */
798
+	public static function validate_format_string($format_string)
799
+	{
800
+		$error_msg = array();
801
+		//time format checks
802
+		switch (true) {
803
+			case   strpos($format_string, 'h') !== false  :
804
+			case   strpos($format_string, 'g') !== false :
805
+				/**
806
+				 * if the time string has a lowercase 'h' which == 12 hour time format and there
807
+				 * is not any ante meridiem format ('a' or 'A').  Then throw an error because its
808
+				 * too ambiguous and PHP won't be able to figure out whether 1 = 1pm or 1am.
809
+				 */
810
+				if (strpos(strtoupper($format_string), 'A') === false) {
811
+					$error_msg[] = __('There is a  time format for 12 hour time but no  "a" or "A" to indicate am/pm.  Without this distinction, PHP is unable to determine if a "1" for the hour value equals "1pm" or "1am".',
812
+						'event_espresso');
813
+				}
814
+				break;
815
+
816
+		}
817
+
818
+		return empty($error_msg) ? true : $error_msg;
819
+	}
820
+
821
+
822
+	/**
823
+	 *     If the the first date starts at midnight on one day, and the next date ends at midnight on the
824
+	 *     very next day then this method will return true.
825
+	 *    If $date_1 = 2015-12-15 00:00:00 and $date_2 = 2015-12-16 00:00:00 then this function will return true.
826
+	 *    If $date_1 = 2015-12-15 03:00:00 and $date_2 = 2015-12_16 03:00:00 then this function will return false.
827
+	 *    If $date_1 = 2015-12-15 00:00:00 and $date_2 = 2015-12-15 00:00:00 then this function will return true.
828
+	 *
829
+	 * @param mixed $date_1
830
+	 * @param mixed $date_2
831
+	 * @return bool
832
+	 */
833
+	public static function dates_represent_one_24_hour_date($date_1, $date_2)
834
+	{
835
+
836
+		if (
837
+			(! $date_1 instanceof DateTime || ! $date_2 instanceof DateTime) ||
838
+			($date_1->format(EE_Datetime_Field::mysql_time_format) != '00:00:00' || $date_2->format(EE_Datetime_Field::mysql_time_format) != '00:00:00')
839
+		) {
840
+			return false;
841
+		}
842
+		return $date_2->format('U') - $date_1->format('U') == 86400 ? true : false;
843
+	}
844
+
845
+
846
+	/**
847
+	 * This returns the appropriate query interval string that can be used in sql queries involving mysql Date
848
+	 * Functions.
849
+	 *
850
+	 * @param string $timezone_string    A timezone string in a valid format to instantiate a DateTimeZone object.
851
+	 * @param string $field_for_interval The Database field that is the interval is applied to in the query.
852
+	 * @return string
853
+	 */
854
+	public static function get_sql_query_interval_for_offset($timezone_string, $field_for_interval)
855
+	{
856
+		try {
857
+			/** need to account for timezone offset on the selects */
858
+			$DateTimeZone = new DateTimeZone($timezone_string);
859
+		} catch (Exception $e) {
860
+			$DateTimeZone = null;
861
+		}
862
+
863
+		/**
864
+		 * Note get_option( 'gmt_offset') returns a value in hours, whereas DateTimeZone::getOffset returns values in seconds.
865
+		 * Hence we do the calc for DateTimeZone::getOffset.
866
+		 */
867
+		$offset         = $DateTimeZone instanceof DateTimeZone ? ($DateTimeZone->getOffset(new DateTime('now'))) / HOUR_IN_SECONDS : get_option('gmt_offset');
868
+		$query_interval = $offset < 0
869
+			? 'DATE_SUB(' . $field_for_interval . ', INTERVAL ' . $offset * -1 . ' HOUR)'
870
+			: 'DATE_ADD(' . $field_for_interval . ', INTERVAL ' . $offset . ' HOUR)';
871
+		return $query_interval;
872
+	}
873
+
874
+	/**
875
+	 * Retrieves the site's default timezone and returns it formatted so it's ready for display
876
+	 * to users. If you want to customize how its displayed feel free to fetch the 'timezone_string'
877
+	 * and 'gmt_offset' WordPress options directly; or use the filter
878
+	 * FHEE__EEH_DTT_Helper__get_timezone_string_for_display
879
+	 * (although note that we remove any HTML that may be added)
880
+	 *
881
+	 * @return string
882
+	 */
883
+	public static function get_timezone_string_for_display()
884
+	{
885
+		$pretty_timezone = apply_filters('FHEE__EEH_DTT_Helper__get_timezone_string_for_display', '');
886
+		if (! empty($pretty_timezone)) {
887
+			return esc_html($pretty_timezone);
888
+		}
889
+		$timezone_string = get_option('timezone_string');
890
+		if ($timezone_string) {
891
+			static $mo_loaded = false;
892
+			// Load translations for continents and cities just like wp_timezone_choice does
893
+			if (! $mo_loaded) {
894
+				$locale = get_locale();
895
+				$mofile = WP_LANG_DIR . '/continents-cities-' . $locale . '.mo';
896
+				load_textdomain('continents-cities', $mofile);
897
+				$mo_loaded = true;
898
+			}
899
+			//well that was easy.
900
+			$parts = explode('/', $timezone_string);
901
+			//remove the continent
902
+			unset($parts[0]);
903
+			$t_parts = array();
904
+			foreach ($parts as $part) {
905
+				$t_parts[] = translate(str_replace('_', ' ', $part), 'continents-cities');
906
+			}
907
+			return implode(' - ', $t_parts);
908
+		}
909
+		//they haven't set the timezone string, so let's return a string like "UTC+1"
910
+		$gmt_offset = get_option('gmt_offset');
911
+		if (intval($gmt_offset) >= 0) {
912
+			$prefix = '+';
913
+		} else {
914
+			$prefix = '';
915
+		}
916
+		$parts = explode('.', (string)$gmt_offset);
917
+		if (count($parts) === 1) {
918
+			$parts[1] = '00';
919
+		} else {
920
+			//convert the part after the decimal, eg "5" (from x.5) or "25" (from x.25)
921
+			//to minutes, eg 30 or 15, respectively
922
+			$hour_fraction = (float)('0.' . $parts[1]);
923
+			$parts[1]      = (string)$hour_fraction * 60;
924
+		}
925
+		return sprintf(__('UTC%1$s', 'event_espresso'), $prefix . implode(':', $parts));
926
+	}
927 927
 
928 928
 
929 929
 }// end class EEH_DTT_Helper
930 930
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +37 added lines, -38 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (! defined('EVENT_ESPRESSO_VERSION')) {
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3 3
     exit('NO direct script access allowed');
4 4
 }
5 5
 
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
             new DateTimeZone($timezone_string);
75 75
         } catch (Exception $e) {
76 76
             // sometimes we take exception to exceptions
77
-            if (! $throw_error) {
77
+            if ( ! $throw_error) {
78 78
                 return false;
79 79
             }
80 80
             throw new EE_Error(
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
             }
136 136
         }
137 137
         $offset = get_option('gmt_offset');
138
-        return (int)($offset * HOUR_IN_SECONDS);
138
+        return (int) ($offset * HOUR_IN_SECONDS);
139 139
     }
140 140
 
141 141
 
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
     public static function adjust_invalid_gmt_offsets($gmt_offset = 0)
150 150
     {
151 151
         //make sure $gmt_offset is int
152
-        $gmt_offset = (int)$gmt_offset;
152
+        $gmt_offset = (int) $gmt_offset;
153 153
         switch ($gmt_offset) {
154 154
 
155 155
             //			case -30600 :
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
     public static function timezone_select_input($timezone_string = '')
234 234
     {
235 235
         // get WP date time format
236
-        $datetime_format = get_option('date_format') . ' ' . get_option('time_format');
236
+        $datetime_format = get_option('date_format').' '.get_option('time_format');
237 237
         // if passed a value, then use that, else get WP option
238 238
         $timezone_string = ! empty($timezone_string) ? $timezone_string : get_option('timezone_string');
239 239
         // check if the timezone is valid but don't throw any errors if it isn't
@@ -245,9 +245,9 @@  discard block
 block discarded – undo
245 245
             // Create a UTC+- zone if no timezone string exists
246 246
             $check_zone_info = false;
247 247
             if ($gmt_offset > 0) {
248
-                $timezone_string = 'UTC+' . $gmt_offset;
248
+                $timezone_string = 'UTC+'.$gmt_offset;
249 249
             } elseif ($gmt_offset < 0) {
250
-                $timezone_string = 'UTC' . $gmt_offset;
250
+                $timezone_string = 'UTC'.$gmt_offset;
251 251
             } else {
252 252
                 $timezone_string = 'UTC';
253 253
             }
@@ -269,11 +269,11 @@  discard block
 block discarded – undo
269 269
                 __('%1$sUTC%2$s time is %3$s'),
270 270
                 '<abbr title="Coordinated Universal Time">',
271 271
                 '</abbr>',
272
-                '<code>' . date_i18n($datetime_format, false, true) . '</code>'
272
+                '<code>'.date_i18n($datetime_format, false, true).'</code>'
273 273
             );
274 274
             ?></span>
275
-        <?php if (! empty($timezone_string) || ! empty($gmt_offset)) : ?>
276
-        <br/><span><?php printf(__('Local time is %1$s'), '<code>' . date_i18n($datetime_format) . '</code>'); ?></span>
275
+        <?php if ( ! empty($timezone_string) || ! empty($gmt_offset)) : ?>
276
+        <br/><span><?php printf(__('Local time is %1$s'), '<code>'.date_i18n($datetime_format).'</code>'); ?></span>
277 277
     <?php endif; ?>
278 278
 
279 279
         <?php if ($check_zone_info && $timezone_string) : ?>
@@ -306,11 +306,10 @@  discard block
 block discarded – undo
306 306
 
307 307
                 if ($found) {
308 308
                     $message = $tr['isdst'] ?
309
-                        __(' Daylight saving time begins on: %s.') :
310
-                        __(' Standard time begins  on: %s.');
309
+                        __(' Daylight saving time begins on: %s.') : __(' Standard time begins  on: %s.');
311 310
                     // Add the difference between the current offset and the new offset to ts to get the correct transition time from date_i18n().
312 311
                     printf($message,
313
-                        '<code >' . date_i18n($datetime_format, $tr['ts'] + ($tz_offset - $tr['offset'])) . '</code >');
312
+                        '<code >'.date_i18n($datetime_format, $tr['ts'] + ($tz_offset - $tr['offset'])).'</code >');
314 313
                 } else {
315 314
                     _e('This timezone does not observe daylight saving time.');
316 315
                 }
@@ -338,13 +337,13 @@  discard block
 block discarded – undo
338 337
      */
339 338
     public static function get_timestamp_with_offset($unix_timestamp = 0, $timezone_string = '')
340 339
     {
341
-        $unix_timestamp  = $unix_timestamp === 0 ? time() : (int)$unix_timestamp;
340
+        $unix_timestamp  = $unix_timestamp === 0 ? time() : (int) $unix_timestamp;
342 341
         $timezone_string = self::get_valid_timezone_string($timezone_string);
343 342
         $TimeZone        = new DateTimeZone($timezone_string);
344 343
 
345
-        $DateTime = new DateTime('@' . $unix_timestamp, $TimeZone);
344
+        $DateTime = new DateTime('@'.$unix_timestamp, $TimeZone);
346 345
         $offset   = timezone_offset_get($TimeZone, $DateTime);
347
-        return (int)$DateTime->format('U') + (int)$offset;
346
+        return (int) $DateTime->format('U') + (int) $offset;
348 347
     }
349 348
 
350 349
 
@@ -427,7 +426,7 @@  discard block
 block discarded – undo
427 426
      */
428 427
     protected static function _modify_datetime_object(DateTime $DateTime, $period = 'years', $value = 1, $operand = '+')
429 428
     {
430
-        if (! $DateTime instanceof DateTime) {
429
+        if ( ! $DateTime instanceof DateTime) {
431 430
             throw new EE_Error(
432 431
                 sprintf(
433 432
                     __('Expected a PHP DateTime object, but instead received %1$s', 'event_espresso'),
@@ -437,25 +436,25 @@  discard block
 block discarded – undo
437 436
         }
438 437
         switch ($period) {
439 438
             case 'years' :
440
-                $value = 'P' . $value . 'Y';
439
+                $value = 'P'.$value.'Y';
441 440
                 break;
442 441
             case 'months' :
443
-                $value = 'P' . $value . 'M';
442
+                $value = 'P'.$value.'M';
444 443
                 break;
445 444
             case 'weeks' :
446
-                $value = 'P' . $value . 'W';
445
+                $value = 'P'.$value.'W';
447 446
                 break;
448 447
             case 'days' :
449
-                $value = 'P' . $value . 'D';
448
+                $value = 'P'.$value.'D';
450 449
                 break;
451 450
             case 'hours' :
452
-                $value = 'PT' . $value . 'H';
451
+                $value = 'PT'.$value.'H';
453 452
                 break;
454 453
             case 'minutes' :
455
-                $value = 'PT' . $value . 'M';
454
+                $value = 'PT'.$value.'M';
456 455
                 break;
457 456
             case 'seconds' :
458
-                $value = 'PT' . $value . 'S';
457
+                $value = 'PT'.$value.'S';
459 458
                 break;
460 459
         }
461 460
         switch ($operand) {
@@ -483,7 +482,7 @@  discard block
 block discarded – undo
483 482
      */
484 483
     protected static function _modify_timestamp($timestamp, $period = 'years', $value = 1, $operand = '+')
485 484
     {
486
-        if (! preg_match(EE_Datetime_Field::unix_timestamp_regex, $timestamp)) {
485
+        if ( ! preg_match(EE_Datetime_Field::unix_timestamp_regex, $timestamp)) {
487 486
             throw new EE_Error(
488 487
                 sprintf(
489 488
                     __('Expected a Unix timestamp, but instead received %1$s', 'event_espresso'),
@@ -587,7 +586,7 @@  discard block
 block discarded – undo
587 586
                 'date' => $date_format['js'],
588 587
                 'time' => $time_format['js'],
589 588
             ),
590
-            'moment' => $date_format['moment'] . ' ' . $time_format['moment'],
589
+            'moment' => $date_format['moment'].' '.$time_format['moment'],
591 590
         );
592 591
     }
593 592
 
@@ -606,7 +605,7 @@  discard block
 block discarded – undo
606 605
          *
607 606
          * @var array
608 607
          */
609
-        $symbols_map      = array(
608
+        $symbols_map = array(
610 609
             // Day
611 610
             //01
612 611
             'd' => array(
@@ -764,7 +763,7 @@  discard block
 block discarded – undo
764 763
                     $jquery_ui_format .= $format_string[$i];
765 764
                     $moment_format .= $format_string[$i];
766 765
                 } else {
767
-                    $jquery_ui_format .= '\'' . $format_string[$i];
766
+                    $jquery_ui_format .= '\''.$format_string[$i];
768 767
                     $moment_format .= $format_string[$i];
769 768
                 }
770 769
                 $escaping = true;
@@ -834,7 +833,7 @@  discard block
 block discarded – undo
834 833
     {
835 834
 
836 835
         if (
837
-            (! $date_1 instanceof DateTime || ! $date_2 instanceof DateTime) ||
836
+            ( ! $date_1 instanceof DateTime || ! $date_2 instanceof DateTime) ||
838 837
             ($date_1->format(EE_Datetime_Field::mysql_time_format) != '00:00:00' || $date_2->format(EE_Datetime_Field::mysql_time_format) != '00:00:00')
839 838
         ) {
840 839
             return false;
@@ -866,8 +865,8 @@  discard block
 block discarded – undo
866 865
          */
867 866
         $offset         = $DateTimeZone instanceof DateTimeZone ? ($DateTimeZone->getOffset(new DateTime('now'))) / HOUR_IN_SECONDS : get_option('gmt_offset');
868 867
         $query_interval = $offset < 0
869
-            ? 'DATE_SUB(' . $field_for_interval . ', INTERVAL ' . $offset * -1 . ' HOUR)'
870
-            : 'DATE_ADD(' . $field_for_interval . ', INTERVAL ' . $offset . ' HOUR)';
868
+            ? 'DATE_SUB('.$field_for_interval.', INTERVAL '.$offset * -1.' HOUR)'
869
+            : 'DATE_ADD('.$field_for_interval.', INTERVAL '.$offset.' HOUR)';
871 870
         return $query_interval;
872 871
     }
873 872
 
@@ -883,16 +882,16 @@  discard block
 block discarded – undo
883 882
     public static function get_timezone_string_for_display()
884 883
     {
885 884
         $pretty_timezone = apply_filters('FHEE__EEH_DTT_Helper__get_timezone_string_for_display', '');
886
-        if (! empty($pretty_timezone)) {
885
+        if ( ! empty($pretty_timezone)) {
887 886
             return esc_html($pretty_timezone);
888 887
         }
889 888
         $timezone_string = get_option('timezone_string');
890 889
         if ($timezone_string) {
891 890
             static $mo_loaded = false;
892 891
             // Load translations for continents and cities just like wp_timezone_choice does
893
-            if (! $mo_loaded) {
892
+            if ( ! $mo_loaded) {
894 893
                 $locale = get_locale();
895
-                $mofile = WP_LANG_DIR . '/continents-cities-' . $locale . '.mo';
894
+                $mofile = WP_LANG_DIR.'/continents-cities-'.$locale.'.mo';
896 895
                 load_textdomain('continents-cities', $mofile);
897 896
                 $mo_loaded = true;
898 897
             }
@@ -913,16 +912,16 @@  discard block
 block discarded – undo
913 912
         } else {
914 913
             $prefix = '';
915 914
         }
916
-        $parts = explode('.', (string)$gmt_offset);
915
+        $parts = explode('.', (string) $gmt_offset);
917 916
         if (count($parts) === 1) {
918 917
             $parts[1] = '00';
919 918
         } else {
920 919
             //convert the part after the decimal, eg "5" (from x.5) or "25" (from x.25)
921 920
             //to minutes, eg 30 or 15, respectively
922
-            $hour_fraction = (float)('0.' . $parts[1]);
923
-            $parts[1]      = (string)$hour_fraction * 60;
921
+            $hour_fraction = (float) ('0.'.$parts[1]);
922
+            $parts[1]      = (string) $hour_fraction * 60;
924 923
         }
925
-        return sprintf(__('UTC%1$s', 'event_espresso'), $prefix . implode(':', $parts));
924
+        return sprintf(__('UTC%1$s', 'event_espresso'), $prefix.implode(':', $parts));
926 925
     }
927 926
 
928 927
 
Please login to merge, or discard this patch.
core/libraries/messages/EE_Messages_Scheduler.lib.php 2 patches
Indentation   +164 added lines, -164 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if (! defined('EVENT_ESPRESSO_VERSION')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 
5 5
 /**
@@ -13,168 +13,168 @@  discard block
 block discarded – undo
13 13
 class EE_Messages_Scheduler extends EE_Base
14 14
 {
15 15
 
16
-    /**
17
-     * Number of seconds between batch sends/generates on the cron job.
18
-     * Defaults to 5 minutes in seconds.  If you want to change this interval, you can use the native WordPress
19
-     * `cron_schedules` filter and modify the existing custom `ee_message_cron` schedule interval added.
20
-     *
21
-     * @type int
22
-     */
23
-    const message_cron_schedule = 300;
24
-
25
-    /**
26
-     * Constructor
27
-     */
28
-    public function __construct()
29
-    {
30
-        //register tasks (and make sure only registered once).
31
-        if (! has_action('FHEE__EEH_Activation__get_cron_tasks', array($this, 'register_scheduled_tasks'))) {
32
-            add_action('FHEE__EEH_Activation__get_cron_tasks', array($this, 'register_scheduled_tasks'), 10);
33
-        }
34
-
35
-        //register callbacks for scheduled events (but make sure they are set only once).
36
-        if (! has_action('AHEE__EE_Messages_Scheduler__generation',
37
-            array('EE_Messages_Scheduler', 'batch_generation'))
38
-        ) {
39
-            add_action('AHEE__EE_Messages_Scheduler__generation', array('EE_Messages_Scheduler', 'batch_generation'));
40
-            add_action('AHEE__EE_Messages_Scheduler__sending', array('EE_Messages_Scheduler', 'batch_sending'));
41
-        }
42
-
43
-        //add custom schedules
44
-        add_filter('cron_schedules', array($this, 'custom_schedules'));
45
-    }
46
-
47
-
48
-    /**
49
-     * Add custom schedules for wp_cron
50
-     *
51
-     * @param $schedules
52
-     */
53
-    public function custom_schedules($schedules)
54
-    {
55
-        $schedules['ee_message_cron'] = array(
56
-            'interval' => self::message_cron_schedule,
57
-            'display'  => __('This is the cron time interval for EE Message schedules (defaults to once every 5 minutes)',
58
-                'event_espresso'),
59
-        );
60
-        return $schedules;
61
-    }
62
-
63
-
64
-    /**
65
-     * Callback for FHEE__EEH_Activation__get_cron_tasks that is used to retrieve scheduled Cron events to add and
66
-     * remove.
67
-     *
68
-     * @param array $tasks already existing scheduled tasks
69
-     * @return array
70
-     */
71
-    public function register_scheduled_tasks($tasks)
72
-    {
73
-        $tasks['AHEE__EE_Messages_Scheduler__generation'] = 'ee_message_cron';
74
-        $tasks['AHEE__EE_Messages_Scheduler__sending']    = 'ee_message_cron';
75
-        return $tasks;
76
-    }
77
-
78
-
79
-    /**
80
-     * This initiates a non-blocking separate request to execute on a scheduled task.
81
-     * Note: The EED_Messages module has the handlers for these requests.
82
-     *
83
-     * @param string $task The task the request is being generated for.
84
-     */
85
-    public static function initiate_scheduled_non_blocking_request($task)
86
-    {
87
-        if (apply_filters('EE_Messages_Scheduler__initiate_scheduled_non_blocking_request__do_separate_request',
88
-            true)) {
89
-            $request_url  = add_query_arg(
90
-                array_merge(
91
-                    array('ee' => 'msg_cron_trigger'),
92
-                    EE_Messages_Scheduler::get_request_params($task)
93
-                ),
94
-                site_url()
95
-            );
96
-            $request_args = array(
97
-                'timeout'     => 300,
98
-                'blocking'    => (defined('DOING_CRON') && DOING_CRON) || (defined('DOING_AJAX') && DOING_AJAX) ? true : false,
99
-                'sslverify'   => false,
100
-                'redirection' => 10,
101
-            );
102
-            $response     = wp_remote_get($request_url, $request_args);
103
-            if (is_wp_error($response)) {
104
-                trigger_error($response->get_error_message());
105
-            }
106
-        } else {
107
-            EE_Messages_Scheduler::initiate_immediate_request_on_cron($task);
108
-        }
109
-    }
110
-
111
-
112
-    /**
113
-     * This returns
114
-     * the request params used for a scheduled message task request.
115
-     *
116
-     * @param string $task The task the request is for.
117
-     * @return array
118
-     */
119
-    public static function get_request_params($task)
120
-    {
121
-        //transient is used for flood control on msg_cron_trigger requests
122
-        $transient_key = 'ee_trans_' . uniqid($task);
123
-        set_transient($transient_key, 1, 5 * MINUTE_IN_SECONDS);
124
-        return array(
125
-            'type' => $task,
126
-            'key'  => $transient_key,
127
-        );
128
-    }
129
-
130
-
131
-    /**
132
-     * This is used to execute an immediate call to the run_cron task performed by EED_Messages
133
-     *
134
-     * @param string $task The task the request is being generated for.
135
-     */
136
-    public static function initiate_immediate_request_on_cron($task)
137
-    {
138
-        $request_args = EE_Messages_Scheduler::get_request_params($task);
139
-        //set those request args in the request so it gets picked up
140
-        foreach ($request_args as $request_key => $request_value) {
141
-            EE_Registry::instance()->REQ->set($request_key, $request_value);
142
-        }
143
-        EED_Messages::instance()->run_cron();
144
-    }
145
-
146
-
147
-    /**
148
-     * Callback for scheduled AHEE__EE_Messages_Scheduler__generation wp cron event
149
-     */
150
-    public static function batch_generation()
151
-    {
152
-        /**
153
-         * @see filter usage in EE_Messages_Queue::initiate_request_by_priority()
154
-         */
155
-        if (
156
-            ! apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false)
157
-            || ! EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request
158
-        ) {
159
-            EE_Messages_Scheduler::initiate_immediate_request_on_cron('generate');
160
-        }
161
-    }
162
-
163
-
164
-    /**
165
-     * Callback for scheduled AHEE__EE_Messages_Scheduler__sending
166
-     */
167
-    public static function batch_sending()
168
-    {
169
-        /**
170
-         * @see filter usage in EE_Messages_Queue::initiate_request_by_priority()
171
-         */
172
-        if (
173
-            ! apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false)
174
-            || ! EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request
175
-        ) {
176
-            EE_Messages_Scheduler::initiate_immediate_request_on_cron('send');
177
-        }
178
-    }
16
+	/**
17
+	 * Number of seconds between batch sends/generates on the cron job.
18
+	 * Defaults to 5 minutes in seconds.  If you want to change this interval, you can use the native WordPress
19
+	 * `cron_schedules` filter and modify the existing custom `ee_message_cron` schedule interval added.
20
+	 *
21
+	 * @type int
22
+	 */
23
+	const message_cron_schedule = 300;
24
+
25
+	/**
26
+	 * Constructor
27
+	 */
28
+	public function __construct()
29
+	{
30
+		//register tasks (and make sure only registered once).
31
+		if (! has_action('FHEE__EEH_Activation__get_cron_tasks', array($this, 'register_scheduled_tasks'))) {
32
+			add_action('FHEE__EEH_Activation__get_cron_tasks', array($this, 'register_scheduled_tasks'), 10);
33
+		}
34
+
35
+		//register callbacks for scheduled events (but make sure they are set only once).
36
+		if (! has_action('AHEE__EE_Messages_Scheduler__generation',
37
+			array('EE_Messages_Scheduler', 'batch_generation'))
38
+		) {
39
+			add_action('AHEE__EE_Messages_Scheduler__generation', array('EE_Messages_Scheduler', 'batch_generation'));
40
+			add_action('AHEE__EE_Messages_Scheduler__sending', array('EE_Messages_Scheduler', 'batch_sending'));
41
+		}
42
+
43
+		//add custom schedules
44
+		add_filter('cron_schedules', array($this, 'custom_schedules'));
45
+	}
46
+
47
+
48
+	/**
49
+	 * Add custom schedules for wp_cron
50
+	 *
51
+	 * @param $schedules
52
+	 */
53
+	public function custom_schedules($schedules)
54
+	{
55
+		$schedules['ee_message_cron'] = array(
56
+			'interval' => self::message_cron_schedule,
57
+			'display'  => __('This is the cron time interval for EE Message schedules (defaults to once every 5 minutes)',
58
+				'event_espresso'),
59
+		);
60
+		return $schedules;
61
+	}
62
+
63
+
64
+	/**
65
+	 * Callback for FHEE__EEH_Activation__get_cron_tasks that is used to retrieve scheduled Cron events to add and
66
+	 * remove.
67
+	 *
68
+	 * @param array $tasks already existing scheduled tasks
69
+	 * @return array
70
+	 */
71
+	public function register_scheduled_tasks($tasks)
72
+	{
73
+		$tasks['AHEE__EE_Messages_Scheduler__generation'] = 'ee_message_cron';
74
+		$tasks['AHEE__EE_Messages_Scheduler__sending']    = 'ee_message_cron';
75
+		return $tasks;
76
+	}
77
+
78
+
79
+	/**
80
+	 * This initiates a non-blocking separate request to execute on a scheduled task.
81
+	 * Note: The EED_Messages module has the handlers for these requests.
82
+	 *
83
+	 * @param string $task The task the request is being generated for.
84
+	 */
85
+	public static function initiate_scheduled_non_blocking_request($task)
86
+	{
87
+		if (apply_filters('EE_Messages_Scheduler__initiate_scheduled_non_blocking_request__do_separate_request',
88
+			true)) {
89
+			$request_url  = add_query_arg(
90
+				array_merge(
91
+					array('ee' => 'msg_cron_trigger'),
92
+					EE_Messages_Scheduler::get_request_params($task)
93
+				),
94
+				site_url()
95
+			);
96
+			$request_args = array(
97
+				'timeout'     => 300,
98
+				'blocking'    => (defined('DOING_CRON') && DOING_CRON) || (defined('DOING_AJAX') && DOING_AJAX) ? true : false,
99
+				'sslverify'   => false,
100
+				'redirection' => 10,
101
+			);
102
+			$response     = wp_remote_get($request_url, $request_args);
103
+			if (is_wp_error($response)) {
104
+				trigger_error($response->get_error_message());
105
+			}
106
+		} else {
107
+			EE_Messages_Scheduler::initiate_immediate_request_on_cron($task);
108
+		}
109
+	}
110
+
111
+
112
+	/**
113
+	 * This returns
114
+	 * the request params used for a scheduled message task request.
115
+	 *
116
+	 * @param string $task The task the request is for.
117
+	 * @return array
118
+	 */
119
+	public static function get_request_params($task)
120
+	{
121
+		//transient is used for flood control on msg_cron_trigger requests
122
+		$transient_key = 'ee_trans_' . uniqid($task);
123
+		set_transient($transient_key, 1, 5 * MINUTE_IN_SECONDS);
124
+		return array(
125
+			'type' => $task,
126
+			'key'  => $transient_key,
127
+		);
128
+	}
129
+
130
+
131
+	/**
132
+	 * This is used to execute an immediate call to the run_cron task performed by EED_Messages
133
+	 *
134
+	 * @param string $task The task the request is being generated for.
135
+	 */
136
+	public static function initiate_immediate_request_on_cron($task)
137
+	{
138
+		$request_args = EE_Messages_Scheduler::get_request_params($task);
139
+		//set those request args in the request so it gets picked up
140
+		foreach ($request_args as $request_key => $request_value) {
141
+			EE_Registry::instance()->REQ->set($request_key, $request_value);
142
+		}
143
+		EED_Messages::instance()->run_cron();
144
+	}
145
+
146
+
147
+	/**
148
+	 * Callback for scheduled AHEE__EE_Messages_Scheduler__generation wp cron event
149
+	 */
150
+	public static function batch_generation()
151
+	{
152
+		/**
153
+		 * @see filter usage in EE_Messages_Queue::initiate_request_by_priority()
154
+		 */
155
+		if (
156
+			! apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false)
157
+			|| ! EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request
158
+		) {
159
+			EE_Messages_Scheduler::initiate_immediate_request_on_cron('generate');
160
+		}
161
+	}
162
+
163
+
164
+	/**
165
+	 * Callback for scheduled AHEE__EE_Messages_Scheduler__sending
166
+	 */
167
+	public static function batch_sending()
168
+	{
169
+		/**
170
+		 * @see filter usage in EE_Messages_Queue::initiate_request_by_priority()
171
+		 */
172
+		if (
173
+			! apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false)
174
+			|| ! EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request
175
+		) {
176
+			EE_Messages_Scheduler::initiate_immediate_request_on_cron('send');
177
+		}
178
+	}
179 179
 
180 180
 } //end EE_Messages_Scheduler
181 181
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if (! defined('EVENT_ESPRESSO_VERSION')) {
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2 2
     exit('No direct script access allowed');
3 3
 }
4 4
 
@@ -28,12 +28,12 @@  discard block
 block discarded – undo
28 28
     public function __construct()
29 29
     {
30 30
         //register tasks (and make sure only registered once).
31
-        if (! has_action('FHEE__EEH_Activation__get_cron_tasks', array($this, 'register_scheduled_tasks'))) {
31
+        if ( ! has_action('FHEE__EEH_Activation__get_cron_tasks', array($this, 'register_scheduled_tasks'))) {
32 32
             add_action('FHEE__EEH_Activation__get_cron_tasks', array($this, 'register_scheduled_tasks'), 10);
33 33
         }
34 34
 
35 35
         //register callbacks for scheduled events (but make sure they are set only once).
36
-        if (! has_action('AHEE__EE_Messages_Scheduler__generation',
36
+        if ( ! has_action('AHEE__EE_Messages_Scheduler__generation',
37 37
             array('EE_Messages_Scheduler', 'batch_generation'))
38 38
         ) {
39 39
             add_action('AHEE__EE_Messages_Scheduler__generation', array('EE_Messages_Scheduler', 'batch_generation'));
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
     {
87 87
         if (apply_filters('EE_Messages_Scheduler__initiate_scheduled_non_blocking_request__do_separate_request',
88 88
             true)) {
89
-            $request_url  = add_query_arg(
89
+            $request_url = add_query_arg(
90 90
                 array_merge(
91 91
                     array('ee' => 'msg_cron_trigger'),
92 92
                     EE_Messages_Scheduler::get_request_params($task)
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
                 'sslverify'   => false,
100 100
                 'redirection' => 10,
101 101
             );
102
-            $response     = wp_remote_get($request_url, $request_args);
102
+            $response = wp_remote_get($request_url, $request_args);
103 103
             if (is_wp_error($response)) {
104 104
                 trigger_error($response->get_error_message());
105 105
             }
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
     public static function get_request_params($task)
120 120
     {
121 121
         //transient is used for flood control on msg_cron_trigger requests
122
-        $transient_key = 'ee_trans_' . uniqid($task);
122
+        $transient_key = 'ee_trans_'.uniqid($task);
123 123
         set_transient($transient_key, 1, 5 * MINUTE_IN_SECONDS);
124 124
         return array(
125 125
             'type' => $task,
Please login to merge, or discard this patch.