Completed
Branch FET-8385-datetime-ticket-selec... (957a7a)
by
unknown
79:05 queued 67:51
created
espresso.php 1 patch
Indentation   +215 added lines, -215 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('ABSPATH')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /*
5 5
   Plugin Name:		Event Espresso
@@ -40,239 +40,239 @@  discard block
 block discarded – undo
40 40
  * @since            4.0
41 41
  */
42 42
 if (function_exists('espresso_version')) {
43
-    /**
44
-     *    espresso_duplicate_plugin_error
45
-     *    displays if more than one version of EE is activated at the same time
46
-     */
47
-    function espresso_duplicate_plugin_error()
48
-    {
49
-        ?>
43
+	/**
44
+	 *    espresso_duplicate_plugin_error
45
+	 *    displays if more than one version of EE is activated at the same time
46
+	 */
47
+	function espresso_duplicate_plugin_error()
48
+	{
49
+		?>
50 50
         <div class="error">
51 51
             <p>
52 52
                 <?php echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                ); ?>
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+				); ?>
56 56
             </p>
57 57
         </div>
58 58
         <?php
59
-        espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-    }
59
+		espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+	}
61 61
 
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 } else {
64
-    define('EE_MIN_PHP_VER_REQUIRED', '5.3.9');
65
-    if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
-        /**
67
-         * espresso_minimum_php_version_error
68
-         *
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
64
+	define('EE_MIN_PHP_VER_REQUIRED', '5.3.9');
65
+	if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
+		/**
67
+		 * espresso_minimum_php_version_error
68
+		 *
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                            esc_html__(
79
-                                    'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
-                                    'event_espresso'
81
-                            ),
82
-                            EE_MIN_PHP_VER_REQUIRED,
83
-                            PHP_VERSION,
84
-                            '<br/>',
85
-                            '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+							esc_html__(
79
+									'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
+									'event_espresso'
81
+							),
82
+							EE_MIN_PHP_VER_REQUIRED,
83
+							PHP_VERSION,
84
+							'<br/>',
85
+							'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        /**
97
-         * espresso_version
98
-         * Returns the plugin version
99
-         *
100
-         * @return string
101
-         */
102
-        function espresso_version()
103
-        {
104
-            return apply_filters('FHEE__espresso__espresso_version', '4.9.22.rc.029');
105
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		/**
97
+		 * espresso_version
98
+		 * Returns the plugin version
99
+		 *
100
+		 * @return string
101
+		 */
102
+		function espresso_version()
103
+		{
104
+			return apply_filters('FHEE__espresso__espresso_version', '4.9.22.rc.029');
105
+		}
106 106
 
107
-        // define versions
108
-        define('EVENT_ESPRESSO_VERSION', espresso_version());
109
-        define('EE_MIN_WP_VER_REQUIRED', '4.1');
110
-        define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2');
111
-        define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44');
112
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
113
-        //used to be DIRECTORY_SEPARATOR, but that caused issues on windows
114
-        if ( ! defined('DS')) {
115
-            define('DS', '/');
116
-        }
117
-        if ( ! defined('PS')) {
118
-            define('PS', PATH_SEPARATOR);
119
-        }
120
-        if ( ! defined('SP')) {
121
-            define('SP', ' ');
122
-        }
123
-        if ( ! defined('EENL')) {
124
-            define('EENL', "\n");
125
-        }
126
-        define('EE_SUPPORT_EMAIL', '[email protected]');
127
-        // define the plugin directory and URL
128
-        define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE));
129
-        define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE));
130
-        define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE));
131
-        // main root folder paths
132
-        define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS);
133
-        define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS);
134
-        define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS);
135
-        define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS);
136
-        define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS);
137
-        define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS);
138
-        define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS);
139
-        define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS);
140
-        // core system paths
141
-        define('EE_ADMIN', EE_CORE . 'admin' . DS);
142
-        define('EE_CPTS', EE_CORE . 'CPTs' . DS);
143
-        define('EE_CLASSES', EE_CORE . 'db_classes' . DS);
144
-        define('EE_INTERFACES', EE_CORE . 'interfaces' . DS);
145
-        define('EE_BUSINESS', EE_CORE . 'business' . DS);
146
-        define('EE_MODELS', EE_CORE . 'db_models' . DS);
147
-        define('EE_HELPERS', EE_CORE . 'helpers' . DS);
148
-        define('EE_LIBRARIES', EE_CORE . 'libraries' . DS);
149
-        define('EE_TEMPLATES', EE_CORE . 'templates' . DS);
150
-        define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS);
151
-        define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS);
152
-        define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS);
153
-        // gateways
154
-        define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS);
155
-        define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS);
156
-        // asset URL paths
157
-        define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS);
158
-        define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS);
159
-        define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS);
160
-        define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS);
161
-        define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/');
162
-        define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/');
163
-        // define upload paths
164
-        $uploads = wp_upload_dir();
165
-        // define the uploads directory and URL
166
-        define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS);
167
-        define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS);
168
-        // define the templates directory and URL
169
-        define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS);
170
-        define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS);
171
-        // define the gateway directory and URL
172
-        define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS);
173
-        define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS);
174
-        // languages folder/path
175
-        define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS);
176
-        define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS);
177
-        //check for dompdf fonts in uploads
178
-        if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) {
179
-            define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS);
180
-        }
181
-        //ajax constants
182
-        define(
183
-                'EE_FRONT_AJAX',
184
-                isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false
185
-        );
186
-        define(
187
-                'EE_ADMIN_AJAX',
188
-                isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false
189
-        );
190
-        //just a handy constant occasionally needed for finding values representing infinity in the DB
191
-        //you're better to use this than its straight value (currently -1) in case you ever
192
-        //want to change its default value! or find when -1 means infinity
193
-        define('EE_INF_IN_DB', -1);
194
-        define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX);
195
-        define('EE_DEBUG', false);
196
-        /**
197
-         *    espresso_plugin_activation
198
-         *    adds a wp-option to indicate that EE has been activated via the WP admin plugins page
199
-         */
200
-        function espresso_plugin_activation()
201
-        {
202
-            update_option('ee_espresso_activation', true);
203
-        }
107
+		// define versions
108
+		define('EVENT_ESPRESSO_VERSION', espresso_version());
109
+		define('EE_MIN_WP_VER_REQUIRED', '4.1');
110
+		define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2');
111
+		define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44');
112
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
113
+		//used to be DIRECTORY_SEPARATOR, but that caused issues on windows
114
+		if ( ! defined('DS')) {
115
+			define('DS', '/');
116
+		}
117
+		if ( ! defined('PS')) {
118
+			define('PS', PATH_SEPARATOR);
119
+		}
120
+		if ( ! defined('SP')) {
121
+			define('SP', ' ');
122
+		}
123
+		if ( ! defined('EENL')) {
124
+			define('EENL', "\n");
125
+		}
126
+		define('EE_SUPPORT_EMAIL', '[email protected]');
127
+		// define the plugin directory and URL
128
+		define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE));
129
+		define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE));
130
+		define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE));
131
+		// main root folder paths
132
+		define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS);
133
+		define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS);
134
+		define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS);
135
+		define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS);
136
+		define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS);
137
+		define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS);
138
+		define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS);
139
+		define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS);
140
+		// core system paths
141
+		define('EE_ADMIN', EE_CORE . 'admin' . DS);
142
+		define('EE_CPTS', EE_CORE . 'CPTs' . DS);
143
+		define('EE_CLASSES', EE_CORE . 'db_classes' . DS);
144
+		define('EE_INTERFACES', EE_CORE . 'interfaces' . DS);
145
+		define('EE_BUSINESS', EE_CORE . 'business' . DS);
146
+		define('EE_MODELS', EE_CORE . 'db_models' . DS);
147
+		define('EE_HELPERS', EE_CORE . 'helpers' . DS);
148
+		define('EE_LIBRARIES', EE_CORE . 'libraries' . DS);
149
+		define('EE_TEMPLATES', EE_CORE . 'templates' . DS);
150
+		define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS);
151
+		define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS);
152
+		define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS);
153
+		// gateways
154
+		define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS);
155
+		define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS);
156
+		// asset URL paths
157
+		define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS);
158
+		define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS);
159
+		define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS);
160
+		define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS);
161
+		define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/');
162
+		define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/');
163
+		// define upload paths
164
+		$uploads = wp_upload_dir();
165
+		// define the uploads directory and URL
166
+		define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS);
167
+		define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS);
168
+		// define the templates directory and URL
169
+		define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS);
170
+		define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS);
171
+		// define the gateway directory and URL
172
+		define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS);
173
+		define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS);
174
+		// languages folder/path
175
+		define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS);
176
+		define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS);
177
+		//check for dompdf fonts in uploads
178
+		if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) {
179
+			define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS);
180
+		}
181
+		//ajax constants
182
+		define(
183
+				'EE_FRONT_AJAX',
184
+				isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false
185
+		);
186
+		define(
187
+				'EE_ADMIN_AJAX',
188
+				isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false
189
+		);
190
+		//just a handy constant occasionally needed for finding values representing infinity in the DB
191
+		//you're better to use this than its straight value (currently -1) in case you ever
192
+		//want to change its default value! or find when -1 means infinity
193
+		define('EE_INF_IN_DB', -1);
194
+		define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX);
195
+		define('EE_DEBUG', false);
196
+		/**
197
+		 *    espresso_plugin_activation
198
+		 *    adds a wp-option to indicate that EE has been activated via the WP admin plugins page
199
+		 */
200
+		function espresso_plugin_activation()
201
+		{
202
+			update_option('ee_espresso_activation', true);
203
+		}
204 204
 
205
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
206
-        /**
207
-         *    espresso_load_error_handling
208
-         *    this function loads EE's class for handling exceptions and errors
209
-         */
210
-        function espresso_load_error_handling()
211
-        {
212
-            // load debugging tools
213
-            if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
214
-                require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php');
215
-                EEH_Debug_Tools::instance();
216
-            }
217
-            // load error handling
218
-            if (is_readable(EE_CORE . 'EE_Error.core.php')) {
219
-                require_once(EE_CORE . 'EE_Error.core.php');
220
-            } else {
221
-                wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
222
-            }
223
-        }
205
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
206
+		/**
207
+		 *    espresso_load_error_handling
208
+		 *    this function loads EE's class for handling exceptions and errors
209
+		 */
210
+		function espresso_load_error_handling()
211
+		{
212
+			// load debugging tools
213
+			if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
214
+				require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php');
215
+				EEH_Debug_Tools::instance();
216
+			}
217
+			// load error handling
218
+			if (is_readable(EE_CORE . 'EE_Error.core.php')) {
219
+				require_once(EE_CORE . 'EE_Error.core.php');
220
+			} else {
221
+				wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
222
+			}
223
+		}
224 224
 
225
-        /**
226
-         *    espresso_load_required
227
-         *    given a class name and path, this function will load that file or throw an exception
228
-         *
229
-         * @param    string $classname
230
-         * @param    string $full_path_to_file
231
-         * @throws    EE_Error
232
-         */
233
-        function espresso_load_required($classname, $full_path_to_file)
234
-        {
235
-            static $error_handling_loaded = false;
236
-            if ( ! $error_handling_loaded) {
237
-                espresso_load_error_handling();
238
-                $error_handling_loaded = true;
239
-            }
240
-            if (is_readable($full_path_to_file)) {
241
-                require_once($full_path_to_file);
242
-            } else {
243
-                throw new EE_Error (
244
-                        sprintf(
245
-                                esc_html__(
246
-                                        'The %s class file could not be located or is not readable due to file permissions.',
247
-                                        'event_espresso'
248
-                                ),
249
-                                $classname
250
-                        )
251
-                );
252
-            }
253
-        }
225
+		/**
226
+		 *    espresso_load_required
227
+		 *    given a class name and path, this function will load that file or throw an exception
228
+		 *
229
+		 * @param    string $classname
230
+		 * @param    string $full_path_to_file
231
+		 * @throws    EE_Error
232
+		 */
233
+		function espresso_load_required($classname, $full_path_to_file)
234
+		{
235
+			static $error_handling_loaded = false;
236
+			if ( ! $error_handling_loaded) {
237
+				espresso_load_error_handling();
238
+				$error_handling_loaded = true;
239
+			}
240
+			if (is_readable($full_path_to_file)) {
241
+				require_once($full_path_to_file);
242
+			} else {
243
+				throw new EE_Error (
244
+						sprintf(
245
+								esc_html__(
246
+										'The %s class file could not be located or is not readable due to file permissions.',
247
+										'event_espresso'
248
+								),
249
+								$classname
250
+						)
251
+				);
252
+			}
253
+		}
254 254
 
255
-        espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php');
256
-        espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php');
257
-        espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php');
258
-        new EE_Bootstrap();
259
-    }
255
+		espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php');
256
+		espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php');
257
+		espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php');
258
+		new EE_Bootstrap();
259
+	}
260 260
 }
261 261
 if ( ! function_exists('espresso_deactivate_plugin')) {
262
-    /**
263
-     *    deactivate_plugin
264
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
265
-     *
266
-     * @access public
267
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
268
-     * @return    void
269
-     */
270
-    function espresso_deactivate_plugin($plugin_basename = '')
271
-    {
272
-        if ( ! function_exists('deactivate_plugins')) {
273
-            require_once(ABSPATH . 'wp-admin/includes/plugin.php');
274
-        }
275
-        unset($_GET['activate'], $_REQUEST['activate']);
276
-        deactivate_plugins($plugin_basename);
277
-    }
262
+	/**
263
+	 *    deactivate_plugin
264
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
265
+	 *
266
+	 * @access public
267
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
268
+	 * @return    void
269
+	 */
270
+	function espresso_deactivate_plugin($plugin_basename = '')
271
+	{
272
+		if ( ! function_exists('deactivate_plugins')) {
273
+			require_once(ABSPATH . 'wp-admin/includes/plugin.php');
274
+		}
275
+		unset($_GET['activate'], $_REQUEST['activate']);
276
+		deactivate_plugins($plugin_basename);
277
+	}
278 278
 }
Please login to merge, or discard this patch.
core/db_models/EEM_Datetime.model.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -529,7 +529,7 @@
 block discarded – undo
529 529
     /**
530 530
      * This returns an array of counts of datetimes in the database for each Datetime status that can be queried.
531 531
      *
532
-     * @param  array $stati_to_include If included you can restrict the statuses we return counts for by including the
532
+     * @param  string[] $stati_to_include If included you can restrict the statuses we return counts for by including the
533 533
      *                                 stati you want counts for as values in the array.  An empty array returns counts
534 534
      *                                 for all valid stati.
535 535
      * @param  array $query_params     If included can be used to refine the conditions for returning the count (i.e.
Please login to merge, or discard this patch.
Indentation   +576 added lines, -576 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
  * Class Datetime Model
@@ -11,581 +11,581 @@  discard block
 block discarded – undo
11 11
 class EEM_Datetime extends EEM_Soft_Delete_Base
12 12
 {
13 13
 
14
-    /**
15
-     * @var EEM_Datetime $_instance
16
-     */
17
-    protected static $_instance;
18
-
19
-
20
-
21
-    /**
22
-     *        private constructor to prevent direct creation
23
-     *
24
-     * @Constructor
25
-     * @access private
26
-     * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any
27
-     *                         incoming timezone data that gets saved).  Note this just sends the timezone info to the
28
-     *                         date time model field objects.  Default is NULL (and will be assumed using the set
29
-     *                         timezone in the 'timezone_string' wp option)
30
-     * @throws \EE_Error
31
-     */
32
-    protected function __construct($timezone)
33
-    {
34
-        $this->singular_item = __('Datetime', 'event_espresso');
35
-        $this->plural_item = __('Datetimes', 'event_espresso');
36
-        $this->_tables = array(
37
-            'Datetime' => new EE_Primary_Table('esp_datetime', 'DTT_ID'),
38
-        );
39
-        $this->_fields = array(
40
-            'Datetime' => array(
41
-                'DTT_ID'          => new EE_Primary_Key_Int_Field('DTT_ID', __('Datetime ID', 'event_espresso')),
42
-                'EVT_ID'          => new EE_Foreign_Key_Int_Field(
43
-                    'EVT_ID', __('Event ID', 'event_espresso'), false, 0, 'Event'
44
-                ),
45
-                'DTT_name'        => new EE_Plain_Text_Field(
46
-                    'DTT_name', __('Datetime Name', 'event_espresso'), false, ''
47
-                ),
48
-                'DTT_description' => new EE_Post_Content_Field(
49
-                    'DTT_description', __('Description for Datetime', 'event_espresso'), false, ''
50
-                ),
51
-                'DTT_EVT_start'   => new EE_Datetime_Field(
52
-                    'DTT_EVT_start', __('Start time/date of Event', 'event_espresso'), false, EE_Datetime_Field::now,
53
-                    $timezone
54
-                ),
55
-                'DTT_EVT_end'     => new EE_Datetime_Field(
56
-                    'DTT_EVT_end', __('End time/date of Event', 'event_espresso'), false, EE_Datetime_Field::now,
57
-                    $timezone
58
-                ),
59
-                'DTT_reg_limit'   => new EE_Infinite_Integer_Field(
60
-                    'DTT_reg_limit', __('Registration Limit for this time', 'event_espresso'), true, EE_INF),
61
-                'DTT_sold'        => new EE_Integer_Field(
62
-                    'DTT_sold', __('How many sales for this Datetime that have occurred', 'event_espresso'), true, 0
63
-                ),
64
-                'DTT_is_primary'  => new EE_Boolean_Field(
65
-                    'DTT_is_primary', __('Flag indicating datetime is primary one for event', 'event_espresso'),
66
-                    false, false
67
-                ),
68
-                'DTT_order'       => new EE_Integer_Field(
69
-                    'DTT_order', __('The order in which the Datetime is displayed', 'event_espresso'), false, 0
70
-                ),
71
-                'DTT_parent'      => new EE_Integer_Field(
72
-                    'DTT_parent', __('Indicates what DTT_ID is the parent of this DTT_ID'), true, 0
73
-                ),
74
-                'DTT_deleted'     => new EE_Trashed_Flag_Field(
75
-                    'DTT_deleted', __('Flag indicating datetime is archived', 'event_espresso'), false, false
76
-                ),
77
-            ),
78
-        );
79
-        $this->_model_relations = array(
80
-            'Ticket'  => new EE_HABTM_Relation('Datetime_Ticket'),
81
-            'Event'   => new EE_Belongs_To_Relation(),
82
-            'Checkin' => new EE_Has_Many_Relation(),
83
-        );
84
-        $this->_model_chain_to_wp_user = 'Event';
85
-        //this model is generally available for reading
86
-        $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Event_Related_Public('Event');
87
-        $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Event_Related_Protected('Event');
88
-        $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Event_Related_Protected('Event');
89
-        $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Event_Related_Protected('Event',
90
-            EEM_Base::caps_edit);
91
-        parent::__construct($timezone);
92
-    }
93
-
94
-
95
-
96
-    /**
97
-     * create new blank datetime
98
-     *
99
-     * @access public
100
-     * @return EE_Datetime[] array on success, FALSE on fail
101
-     * @throws \EE_Error
102
-     */
103
-    public function create_new_blank_datetime()
104
-    {
105
-        $blank_datetime = EE_Datetime::new_instance(
106
-            array(
107
-                'DTT_EVT_start' => $this->current_time_for_query('DTT_EVT_start', true) + MONTH_IN_SECONDS,
108
-                'DTT_EVT_end'   => $this->current_time_for_query('DTT_EVT_end', true) + MONTH_IN_SECONDS,
109
-                'DTT_order'     => 1,
110
-                'DTT_reg_limit' => EE_INF,
111
-            ),
112
-            $this->_timezone
113
-        );
114
-        $blank_datetime->set_start_time($this->convert_datetime_for_query('DTT_EVT_start', '8am', 'ga',
115
-            $this->_timezone));
116
-        $blank_datetime->set_end_time($this->convert_datetime_for_query('DTT_EVT_end', '5pm', 'ga', $this->_timezone));
117
-        return array($blank_datetime);
118
-    }
119
-
120
-
121
-
122
-    /**
123
-     * get event start date from db
124
-     *
125
-     * @access public
126
-     * @param  int $EVT_ID
127
-     * @return EE_Datetime[] array on success, FALSE on fail
128
-     * @throws \EE_Error
129
-     */
130
-    public function get_all_event_dates($EVT_ID = 0)
131
-    {
132
-        if ( ! $EVT_ID) { // on add_new_event event_id gets set to 0
133
-            return $this->create_new_blank_datetime();
134
-        }
135
-        $results = $this->get_datetimes_for_event_ordered_by_DTT_order($EVT_ID);
136
-        if (empty($results)) {
137
-            return $this->create_new_blank_datetime();
138
-        }
139
-        return $results;
140
-    }
141
-
142
-
143
-
144
-    /**
145
-     * get all datetimes attached to an event ordered by the DTT_order field
146
-     *
147
-     * @public
148
-     * @param  int    $EVT_ID     event id
149
-     * @param boolean $include_expired
150
-     * @param boolean $include_deleted
151
-     * @param  int    $limit      If included then limit the count of results by
152
-     *                            the given number
153
-     * @return EE_Datetime[]
154
-     * @throws \EE_Error
155
-     */
156
-    public function get_datetimes_for_event_ordered_by_DTT_order(
157
-        $EVT_ID,
158
-        $include_expired = true,
159
-        $include_deleted = true,
160
-        $limit = null
161
-    ) {
162
-        //sanitize EVT_ID
163
-        $EVT_ID = absint($EVT_ID);
164
-        $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object();
165
-        $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db);
166
-        $where_params = array('Event.EVT_ID' => $EVT_ID);
167
-        $query_params = ! empty($limit)
168
-            ? array(
169
-                $where_params,
170
-                'limit'                    => $limit,
171
-                'order_by'                 => array('DTT_order' => 'ASC'),
172
-                'default_where_conditions' => 'none',
173
-            )
174
-            : array(
175
-                $where_params,
176
-                'order_by'                 => array('DTT_order' => 'ASC'),
177
-                'default_where_conditions' => 'none',
178
-            );
179
-        if ( ! $include_expired) {
180
-            $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', true));
181
-        }
182
-        if ($include_deleted) {
183
-            $query_params[0]['DTT_deleted'] = array('IN', array(true, false));
184
-        }
185
-        /** @var EE_Datetime[] $result */
186
-        $result = $this->get_all($query_params);
187
-        $this->assume_values_already_prepared_by_model_object($old_assumption);
188
-        return $result;
189
-    }
190
-
191
-
192
-
193
-    /**
194
-     * Gets the datetimes for the event (with the given limit), and orders them by "importance". By importance, we mean
195
-     * that the primary datetimes are most important (DEPRECATED FOR NOW), and then the earlier datetimes are the most
196
-     * important. Maybe we'll want this to take into account datetimes that haven't already passed, but we don't yet.
197
-     *
198
-     * @param int $EVT_ID
199
-     * @param int $limit
200
-     * @return EE_Datetime[]|EE_Base_Class[]
201
-     * @throws \EE_Error
202
-     */
203
-    public function get_datetimes_for_event_ordered_by_importance($EVT_ID = 0, $limit = null)
204
-    {
205
-        return $this->get_all(
206
-            array(
207
-                array('Event.EVT_ID' => $EVT_ID),
208
-                'limit'                    => $limit,
209
-                'order_by'                 => array('DTT_EVT_start' => 'ASC'),
210
-                'default_where_conditions' => 'none',
211
-            )
212
-        );
213
-    }
214
-
215
-
216
-
217
-    /**
218
-     * @param int     $EVT_ID
219
-     * @param boolean $include_expired
220
-     * @param boolean $include_deleted
221
-     * @return EE_Datetime
222
-     * @throws \EE_Error
223
-     */
224
-    public function get_oldest_datetime_for_event($EVT_ID, $include_expired = false, $include_deleted = false)
225
-    {
226
-        $results = $this->get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired, $include_deleted, 1);
227
-        if ($results) {
228
-            return array_shift($results);
229
-        } else {
230
-            return null;
231
-        }
232
-    }
233
-
234
-
235
-
236
-    /**
237
-     * Gets the 'primary' datetime for an event.
238
-     *
239
-     * @param int  $EVT_ID
240
-     * @param bool $try_to_exclude_expired
241
-     * @param bool $try_to_exclude_deleted
242
-     * @return \EE_Datetime
243
-     * @throws \EE_Error
244
-     */
245
-    public function get_primary_datetime_for_event(
246
-        $EVT_ID,
247
-        $try_to_exclude_expired = true,
248
-        $try_to_exclude_deleted = true
249
-    ) {
250
-        if ($try_to_exclude_expired) {
251
-            $non_expired = $this->get_oldest_datetime_for_event($EVT_ID, false, false);
252
-            if ($non_expired) {
253
-                return $non_expired;
254
-            }
255
-        }
256
-        if ($try_to_exclude_deleted) {
257
-            $expired_even = $this->get_oldest_datetime_for_event($EVT_ID, true);
258
-            if ($expired_even) {
259
-                return $expired_even;
260
-            }
261
-        }
262
-        return $this->get_oldest_datetime_for_event($EVT_ID, true, true);
263
-    }
264
-
265
-
266
-
267
-    /**
268
-     * Gets ALL the datetimes for an event (including trashed ones, for now), ordered
269
-     * only by start date
270
-     *
271
-     * @param int     $EVT_ID
272
-     * @param boolean $include_expired
273
-     * @param boolean $include_deleted
274
-     * @param int     $limit
275
-     * @return EE_Datetime[]
276
-     * @throws \EE_Error
277
-     */
278
-    public function get_datetimes_for_event_ordered_by_start_time(
279
-        $EVT_ID,
280
-        $include_expired = true,
281
-        $include_deleted = true,
282
-        $limit = null
283
-    ) {
284
-        //sanitize EVT_ID
285
-        $EVT_ID = absint($EVT_ID);
286
-        $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object();
287
-        $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db);
288
-        $query_params = array(array('Event.EVT_ID' => $EVT_ID), 'order_by' => array('DTT_EVT_start' => 'asc'));
289
-        if ( ! $include_expired) {
290
-            $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', true));
291
-        }
292
-        if ($include_deleted) {
293
-            $query_params[0]['DTT_deleted'] = array('IN', array(true, false));
294
-        }
295
-        if ($limit) {
296
-            $query_params['limit'] = $limit;
297
-        }
298
-        /** @var EE_Datetime[] $result */
299
-        $result = $this->get_all($query_params);
300
-        $this->assume_values_already_prepared_by_model_object($old_assumption);
301
-        return $result;
302
-    }
303
-
304
-
305
-
306
-    /**
307
-     * Gets ALL the datetimes for an ticket (including trashed ones, for now), ordered
308
-     * only by start date
309
-     *
310
-     * @param int     $TKT_ID
311
-     * @param boolean $include_expired
312
-     * @param boolean $include_deleted
313
-     * @param int     $limit
314
-     * @return EE_Datetime[]
315
-     * @throws \EE_Error
316
-     */
317
-    public function get_datetimes_for_ticket_ordered_by_start_time(
318
-        $TKT_ID,
319
-        $include_expired = true,
320
-        $include_deleted = true,
321
-        $limit = null
322
-    ) {
323
-        //sanitize TKT_ID
324
-        $TKT_ID = absint($TKT_ID);
325
-        $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object();
326
-        $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db);
327
-        $query_params = array(array('Ticket.TKT_ID' => $TKT_ID), 'order_by' => array('DTT_EVT_start' => 'asc'));
328
-        if ( ! $include_expired) {
329
-            $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', true));
330
-        }
331
-        if ($include_deleted) {
332
-            $query_params[0]['DTT_deleted'] = array('IN', array(true, false));
333
-        }
334
-        if ($limit) {
335
-            $query_params['limit'] = $limit;
336
-        }
337
-        /** @var EE_Datetime[] $result */
338
-        $result = $this->get_all($query_params);
339
-        $this->assume_values_already_prepared_by_model_object($old_assumption);
340
-        return $result;
341
-    }
342
-
343
-
344
-
345
-    /**
346
-     * Gets all the datetimes for a ticket (including trashed ones, for now), ordered by the DTT_order for the
347
-     * datetimes.
348
-     *
349
-     * @param  int      $TKT_ID          ID of ticket to retrieve the datetimes for
350
-     * @param  boolean  $include_expired whether to include expired datetimes or not
351
-     * @param  boolean  $include_deleted whether to include trashed datetimes or not.
352
-     * @param  int|null $limit           if null, no limit, if int then limit results by
353
-     *                                   that number
354
-     * @return EE_Datetime[]
355
-     * @throws \EE_Error
356
-     */
357
-    public function get_datetimes_for_ticket_ordered_by_DTT_order(
358
-        $TKT_ID,
359
-        $include_expired = true,
360
-        $include_deleted = true,
361
-        $limit = null
362
-    ) {
363
-        //sanitize id.
364
-        $TKT_ID = absint($TKT_ID);
365
-        $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object();
366
-        $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db);
367
-        $where_params = array('Ticket.TKT_ID' => $TKT_ID);
368
-        $query_params = array($where_params, 'order_by' => array('DTT_order' => 'ASC'));
369
-        if ( ! $include_expired) {
370
-            $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', true));
371
-        }
372
-        if ($include_deleted) {
373
-            $query_params[0]['DTT_deleted'] = array('IN', array(true, false));
374
-        }
375
-        if ($limit) {
376
-            $query_params['limit'] = $limit;
377
-        }
378
-        /** @var EE_Datetime[] $result */
379
-        $result = $this->get_all($query_params);
380
-        $this->assume_values_already_prepared_by_model_object($old_assumption);
381
-        return $result;
382
-    }
383
-
384
-
385
-
386
-    /**
387
-     * Gets the most important datetime for a particular event (ie, the primary event usually. But if for some WACK
388
-     * reason it doesn't exist, we consider the earliest event the most important)
389
-     *
390
-     * @param int $EVT_ID
391
-     * @return EE_Datetime
392
-     * @throws \EE_Error
393
-     */
394
-    public function get_most_important_datetime_for_event($EVT_ID)
395
-    {
396
-        $results = $this->get_datetimes_for_event_ordered_by_importance($EVT_ID, 1);
397
-        if ($results) {
398
-            return array_shift($results);
399
-        } else {
400
-            return null;
401
-        }
402
-    }
403
-
404
-
405
-
406
-    /**
407
-     * This returns a wpdb->results        Array of all DTT month and years matching the incoming query params and
408
-     * grouped by month and year.
409
-     *
410
-     * @param  array  $where_params      Array of query_params as described in the comments for EEM_Base::get_all()
411
-     * @param  string $evt_active_status A string representing the evt active status to filter the months by.
412
-     *                                   Can be:
413
-     *                                   - '' = no filter
414
-     *                                   - upcoming = Published events with at least one upcoming datetime.
415
-     *                                   - expired = Events with all datetimes expired.
416
-     *                                   - active = Events that are published and have at least one datetime that
417
-     *                                   starts before now and ends after now.
418
-     *                                   - inactive = Events that are either not published.
419
-     * @return EE_Base_Class[]
420
-     * @throws \EE_Error
421
-     */
422
-    public function get_dtt_months_and_years($where_params, $evt_active_status = '')
423
-    {
424
-        $current_time_for_DTT_EVT_start = $this->current_time_for_query('DTT_EVT_start');
425
-        $current_time_for_DTT_EVT_end = $this->current_time_for_query('DTT_EVT_end');
426
-        switch ($evt_active_status) {
427
-            case 'upcoming' :
428
-                $where_params['Event.status'] = 'publish';
429
-                //if there are already query_params matching DTT_EVT_start then we need to modify that to add them.
430
-                if (isset($where_params['DTT_EVT_start'])) {
431
-                    $where_params['DTT_EVT_start*****'] = $where_params['DTT_EVT_start'];
432
-                }
433
-                $where_params['DTT_EVT_start'] = array('>', $current_time_for_DTT_EVT_start);
434
-                break;
435
-            case 'expired' :
436
-                if (isset($where_params['Event.status'])) {
437
-                    unset($where_params['Event.status']);
438
-                }
439
-                //get events to exclude
440
-                $exclude_query[0] = array_merge($where_params,
441
-                    array('DTT_EVT_end' => array('>', $current_time_for_DTT_EVT_end)));
442
-                //first get all events that have datetimes where its not expired.
443
-                $event_ids = $this->_get_all_wpdb_results($exclude_query, OBJECT_K, 'Datetime.EVT_ID');
444
-                $event_ids = array_keys($event_ids);
445
-                if (isset($where_params['DTT_EVT_end'])) {
446
-                    $where_params['DTT_EVT_end****'] = $where_params['DTT_EVT_end'];
447
-                }
448
-                $where_params['DTT_EVT_end'] = array('<', $current_time_for_DTT_EVT_end);
449
-                $where_params['Event.EVT_ID'] = array('NOT IN', $event_ids);
450
-                break;
451
-            case 'active' :
452
-                $where_params['Event.status'] = 'publish';
453
-                if (isset($where_params['DTT_EVT_start'])) {
454
-                    $where_params['Datetime.DTT_EVT_start******'] = $where_params['DTT_EVT_start'];
455
-                }
456
-                if (isset($where_params['Datetime.DTT_EVT_end'])) {
457
-                    $where_params['Datetime.DTT_EVT_end*****'] = $where_params['DTT_EVT_end'];
458
-                }
459
-                $where_params['DTT_EVT_start'] = array('<', $current_time_for_DTT_EVT_start);
460
-                $where_params['DTT_EVT_end'] = array('>', $current_time_for_DTT_EVT_end);
461
-                break;
462
-            case 'inactive' :
463
-                if (isset($where_params['Event.status'])) {
464
-                    unset($where_params['Event.status']);
465
-                }
466
-                if (isset($where_params['OR'])) {
467
-                    $where_params['AND']['OR'] = $where_params['OR'];
468
-                }
469
-                if (isset($where_params['DTT_EVT_end'])) {
470
-                    $where_params['AND']['DTT_EVT_end****'] = $where_params['DTT_EVT_end'];
471
-                    unset($where_params['DTT_EVT_end']);
472
-                }
473
-                if (isset($where_params['DTT_EVT_start'])) {
474
-                    $where_params['AND']['DTT_EVT_start'] = $where_params['DTT_EVT_start'];
475
-                    unset($where_params['DTT_EVT_start']);
476
-                }
477
-                $where_params['AND']['Event.status'] = array('!=', 'publish');
478
-                break;
479
-        }
480
-        $query_params[0] = $where_params;
481
-        $query_params['group_by'] = array('dtt_year', 'dtt_month');
482
-        $query_params['order_by'] = array('DTT_EVT_start' => 'DESC');
483
-        $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'DTT_EVT_start');
484
-        $columns_to_select = array(
485
-            'dtt_year'      => array('YEAR(' . $query_interval . ')', '%s'),
486
-            'dtt_month'     => array('MONTHNAME(' . $query_interval . ')', '%s'),
487
-            'dtt_month_num' => array('MONTH(' . $query_interval . ')', '%s'),
488
-        );
489
-        return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select);
490
-    }
491
-
492
-
493
-
494
-    /**
495
-     * Updates the DTT_sold attribute on each datetime (based on the registrations
496
-     * for the tickets for each datetime)
497
-     *
498
-     * @param EE_Datetime[] $datetimes
499
-     */
500
-    public function update_sold($datetimes)
501
-    {
502
-        foreach ($datetimes as $datetime) {
503
-            $datetime->update_sold();
504
-        }
505
-    }
506
-
507
-
508
-
509
-    /**
510
-     *    Gets the total number of tickets available at a particular datetime
511
-     *    (does NOT take into account the datetime's spaces available)
512
-     *
513
-     * @param int   $DTT_ID
514
-     * @param array $query_params
515
-     * @return int of tickets available. If sold out, return less than 1. If infinite, returns EE_INF,  IF there are NO
516
-     *             tickets attached to datetime then FALSE is returned.
517
-     */
518
-    public function sum_tickets_currently_available_at_datetime($DTT_ID, array $query_params = array())
519
-    {
520
-        $datetime = $this->get_one_by_ID($DTT_ID);
521
-        if ($datetime instanceof EE_Datetime) {
522
-            return $datetime->tickets_remaining($query_params);
523
-        }
524
-        return 0;
525
-    }
526
-
527
-
528
-
529
-    /**
530
-     * This returns an array of counts of datetimes in the database for each Datetime status that can be queried.
531
-     *
532
-     * @param  array $stati_to_include If included you can restrict the statuses we return counts for by including the
533
-     *                                 stati you want counts for as values in the array.  An empty array returns counts
534
-     *                                 for all valid stati.
535
-     * @param  array $query_params     If included can be used to refine the conditions for returning the count (i.e.
536
-     *                                 only for Datetimes connected to a specific event, or specific ticket.
537
-     * @return array  The value returned is an array indexed by Datetime Status and the values are the counts.  The
538
-     * @throws \EE_Error
539
-     *                                 stati used as index keys are: EE_Datetime::active EE_Datetime::upcoming EE_Datetime::expired
540
-     */
541
-    public function get_datetime_counts_by_status(array $stati_to_include = array(), array $query_params = array())
542
-    {
543
-        //only accept where conditions for this query.
544
-        $_where = isset($query_params[0]) ? $query_params[0] : array();
545
-        $status_query_args = array(
546
-            EE_Datetime::active   => array_merge(
547
-                $_where,
548
-                array('DTT_EVT_start' => array('<', time()), 'DTT_EVT_end' => array('>', time()))
549
-            ),
550
-            EE_Datetime::upcoming => array_merge(
551
-                $_where,
552
-                array('DTT_EVT_start' => array('>', time()))
553
-            ),
554
-            EE_Datetime::expired  => array_merge(
555
-                $_where,
556
-                array('DTT_EVT_end' => array('<', time()))
557
-            ),
558
-        );
559
-        if ( ! empty($stati_to_include)) {
560
-            foreach (array_keys($status_query_args) as $status) {
561
-                if ( ! in_array($status, $stati_to_include, true)) {
562
-                    unset($status_query_args[$status]);
563
-                }
564
-            }
565
-        }
566
-        //loop through and query counts for each stati.
567
-        $status_query_results = array();
568
-        foreach ($status_query_args as $status => $status_where_conditions) {
569
-            $status_query_results[$status] = EEM_Datetime::count(array($status_where_conditions), 'DTT_ID', true);
570
-        }
571
-        return $status_query_results;
572
-    }
573
-
574
-
575
-
576
-    /**
577
-     * Returns the specific count for a given Datetime status matching any given query_params.
578
-     *
579
-     * @param string $status Valid string representation for Datetime status requested. (Defaults to Active).
580
-     * @param array  $query_params
581
-     * @return int
582
-     * @throws \EE_Error
583
-     */
584
-    public function get_datetime_count_for_status($status = EE_Datetime::active, array $query_params = array())
585
-    {
586
-        $count = $this->get_datetime_counts_by_status(array($status), $query_params);
587
-        return ! empty($count[$status]) ? $count[$status] : 0;
588
-    }
14
+	/**
15
+	 * @var EEM_Datetime $_instance
16
+	 */
17
+	protected static $_instance;
18
+
19
+
20
+
21
+	/**
22
+	 *        private constructor to prevent direct creation
23
+	 *
24
+	 * @Constructor
25
+	 * @access private
26
+	 * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any
27
+	 *                         incoming timezone data that gets saved).  Note this just sends the timezone info to the
28
+	 *                         date time model field objects.  Default is NULL (and will be assumed using the set
29
+	 *                         timezone in the 'timezone_string' wp option)
30
+	 * @throws \EE_Error
31
+	 */
32
+	protected function __construct($timezone)
33
+	{
34
+		$this->singular_item = __('Datetime', 'event_espresso');
35
+		$this->plural_item = __('Datetimes', 'event_espresso');
36
+		$this->_tables = array(
37
+			'Datetime' => new EE_Primary_Table('esp_datetime', 'DTT_ID'),
38
+		);
39
+		$this->_fields = array(
40
+			'Datetime' => array(
41
+				'DTT_ID'          => new EE_Primary_Key_Int_Field('DTT_ID', __('Datetime ID', 'event_espresso')),
42
+				'EVT_ID'          => new EE_Foreign_Key_Int_Field(
43
+					'EVT_ID', __('Event ID', 'event_espresso'), false, 0, 'Event'
44
+				),
45
+				'DTT_name'        => new EE_Plain_Text_Field(
46
+					'DTT_name', __('Datetime Name', 'event_espresso'), false, ''
47
+				),
48
+				'DTT_description' => new EE_Post_Content_Field(
49
+					'DTT_description', __('Description for Datetime', 'event_espresso'), false, ''
50
+				),
51
+				'DTT_EVT_start'   => new EE_Datetime_Field(
52
+					'DTT_EVT_start', __('Start time/date of Event', 'event_espresso'), false, EE_Datetime_Field::now,
53
+					$timezone
54
+				),
55
+				'DTT_EVT_end'     => new EE_Datetime_Field(
56
+					'DTT_EVT_end', __('End time/date of Event', 'event_espresso'), false, EE_Datetime_Field::now,
57
+					$timezone
58
+				),
59
+				'DTT_reg_limit'   => new EE_Infinite_Integer_Field(
60
+					'DTT_reg_limit', __('Registration Limit for this time', 'event_espresso'), true, EE_INF),
61
+				'DTT_sold'        => new EE_Integer_Field(
62
+					'DTT_sold', __('How many sales for this Datetime that have occurred', 'event_espresso'), true, 0
63
+				),
64
+				'DTT_is_primary'  => new EE_Boolean_Field(
65
+					'DTT_is_primary', __('Flag indicating datetime is primary one for event', 'event_espresso'),
66
+					false, false
67
+				),
68
+				'DTT_order'       => new EE_Integer_Field(
69
+					'DTT_order', __('The order in which the Datetime is displayed', 'event_espresso'), false, 0
70
+				),
71
+				'DTT_parent'      => new EE_Integer_Field(
72
+					'DTT_parent', __('Indicates what DTT_ID is the parent of this DTT_ID'), true, 0
73
+				),
74
+				'DTT_deleted'     => new EE_Trashed_Flag_Field(
75
+					'DTT_deleted', __('Flag indicating datetime is archived', 'event_espresso'), false, false
76
+				),
77
+			),
78
+		);
79
+		$this->_model_relations = array(
80
+			'Ticket'  => new EE_HABTM_Relation('Datetime_Ticket'),
81
+			'Event'   => new EE_Belongs_To_Relation(),
82
+			'Checkin' => new EE_Has_Many_Relation(),
83
+		);
84
+		$this->_model_chain_to_wp_user = 'Event';
85
+		//this model is generally available for reading
86
+		$this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Event_Related_Public('Event');
87
+		$this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Event_Related_Protected('Event');
88
+		$this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Event_Related_Protected('Event');
89
+		$this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Event_Related_Protected('Event',
90
+			EEM_Base::caps_edit);
91
+		parent::__construct($timezone);
92
+	}
93
+
94
+
95
+
96
+	/**
97
+	 * create new blank datetime
98
+	 *
99
+	 * @access public
100
+	 * @return EE_Datetime[] array on success, FALSE on fail
101
+	 * @throws \EE_Error
102
+	 */
103
+	public function create_new_blank_datetime()
104
+	{
105
+		$blank_datetime = EE_Datetime::new_instance(
106
+			array(
107
+				'DTT_EVT_start' => $this->current_time_for_query('DTT_EVT_start', true) + MONTH_IN_SECONDS,
108
+				'DTT_EVT_end'   => $this->current_time_for_query('DTT_EVT_end', true) + MONTH_IN_SECONDS,
109
+				'DTT_order'     => 1,
110
+				'DTT_reg_limit' => EE_INF,
111
+			),
112
+			$this->_timezone
113
+		);
114
+		$blank_datetime->set_start_time($this->convert_datetime_for_query('DTT_EVT_start', '8am', 'ga',
115
+			$this->_timezone));
116
+		$blank_datetime->set_end_time($this->convert_datetime_for_query('DTT_EVT_end', '5pm', 'ga', $this->_timezone));
117
+		return array($blank_datetime);
118
+	}
119
+
120
+
121
+
122
+	/**
123
+	 * get event start date from db
124
+	 *
125
+	 * @access public
126
+	 * @param  int $EVT_ID
127
+	 * @return EE_Datetime[] array on success, FALSE on fail
128
+	 * @throws \EE_Error
129
+	 */
130
+	public function get_all_event_dates($EVT_ID = 0)
131
+	{
132
+		if ( ! $EVT_ID) { // on add_new_event event_id gets set to 0
133
+			return $this->create_new_blank_datetime();
134
+		}
135
+		$results = $this->get_datetimes_for_event_ordered_by_DTT_order($EVT_ID);
136
+		if (empty($results)) {
137
+			return $this->create_new_blank_datetime();
138
+		}
139
+		return $results;
140
+	}
141
+
142
+
143
+
144
+	/**
145
+	 * get all datetimes attached to an event ordered by the DTT_order field
146
+	 *
147
+	 * @public
148
+	 * @param  int    $EVT_ID     event id
149
+	 * @param boolean $include_expired
150
+	 * @param boolean $include_deleted
151
+	 * @param  int    $limit      If included then limit the count of results by
152
+	 *                            the given number
153
+	 * @return EE_Datetime[]
154
+	 * @throws \EE_Error
155
+	 */
156
+	public function get_datetimes_for_event_ordered_by_DTT_order(
157
+		$EVT_ID,
158
+		$include_expired = true,
159
+		$include_deleted = true,
160
+		$limit = null
161
+	) {
162
+		//sanitize EVT_ID
163
+		$EVT_ID = absint($EVT_ID);
164
+		$old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object();
165
+		$this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db);
166
+		$where_params = array('Event.EVT_ID' => $EVT_ID);
167
+		$query_params = ! empty($limit)
168
+			? array(
169
+				$where_params,
170
+				'limit'                    => $limit,
171
+				'order_by'                 => array('DTT_order' => 'ASC'),
172
+				'default_where_conditions' => 'none',
173
+			)
174
+			: array(
175
+				$where_params,
176
+				'order_by'                 => array('DTT_order' => 'ASC'),
177
+				'default_where_conditions' => 'none',
178
+			);
179
+		if ( ! $include_expired) {
180
+			$query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', true));
181
+		}
182
+		if ($include_deleted) {
183
+			$query_params[0]['DTT_deleted'] = array('IN', array(true, false));
184
+		}
185
+		/** @var EE_Datetime[] $result */
186
+		$result = $this->get_all($query_params);
187
+		$this->assume_values_already_prepared_by_model_object($old_assumption);
188
+		return $result;
189
+	}
190
+
191
+
192
+
193
+	/**
194
+	 * Gets the datetimes for the event (with the given limit), and orders them by "importance". By importance, we mean
195
+	 * that the primary datetimes are most important (DEPRECATED FOR NOW), and then the earlier datetimes are the most
196
+	 * important. Maybe we'll want this to take into account datetimes that haven't already passed, but we don't yet.
197
+	 *
198
+	 * @param int $EVT_ID
199
+	 * @param int $limit
200
+	 * @return EE_Datetime[]|EE_Base_Class[]
201
+	 * @throws \EE_Error
202
+	 */
203
+	public function get_datetimes_for_event_ordered_by_importance($EVT_ID = 0, $limit = null)
204
+	{
205
+		return $this->get_all(
206
+			array(
207
+				array('Event.EVT_ID' => $EVT_ID),
208
+				'limit'                    => $limit,
209
+				'order_by'                 => array('DTT_EVT_start' => 'ASC'),
210
+				'default_where_conditions' => 'none',
211
+			)
212
+		);
213
+	}
214
+
215
+
216
+
217
+	/**
218
+	 * @param int     $EVT_ID
219
+	 * @param boolean $include_expired
220
+	 * @param boolean $include_deleted
221
+	 * @return EE_Datetime
222
+	 * @throws \EE_Error
223
+	 */
224
+	public function get_oldest_datetime_for_event($EVT_ID, $include_expired = false, $include_deleted = false)
225
+	{
226
+		$results = $this->get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired, $include_deleted, 1);
227
+		if ($results) {
228
+			return array_shift($results);
229
+		} else {
230
+			return null;
231
+		}
232
+	}
233
+
234
+
235
+
236
+	/**
237
+	 * Gets the 'primary' datetime for an event.
238
+	 *
239
+	 * @param int  $EVT_ID
240
+	 * @param bool $try_to_exclude_expired
241
+	 * @param bool $try_to_exclude_deleted
242
+	 * @return \EE_Datetime
243
+	 * @throws \EE_Error
244
+	 */
245
+	public function get_primary_datetime_for_event(
246
+		$EVT_ID,
247
+		$try_to_exclude_expired = true,
248
+		$try_to_exclude_deleted = true
249
+	) {
250
+		if ($try_to_exclude_expired) {
251
+			$non_expired = $this->get_oldest_datetime_for_event($EVT_ID, false, false);
252
+			if ($non_expired) {
253
+				return $non_expired;
254
+			}
255
+		}
256
+		if ($try_to_exclude_deleted) {
257
+			$expired_even = $this->get_oldest_datetime_for_event($EVT_ID, true);
258
+			if ($expired_even) {
259
+				return $expired_even;
260
+			}
261
+		}
262
+		return $this->get_oldest_datetime_for_event($EVT_ID, true, true);
263
+	}
264
+
265
+
266
+
267
+	/**
268
+	 * Gets ALL the datetimes for an event (including trashed ones, for now), ordered
269
+	 * only by start date
270
+	 *
271
+	 * @param int     $EVT_ID
272
+	 * @param boolean $include_expired
273
+	 * @param boolean $include_deleted
274
+	 * @param int     $limit
275
+	 * @return EE_Datetime[]
276
+	 * @throws \EE_Error
277
+	 */
278
+	public function get_datetimes_for_event_ordered_by_start_time(
279
+		$EVT_ID,
280
+		$include_expired = true,
281
+		$include_deleted = true,
282
+		$limit = null
283
+	) {
284
+		//sanitize EVT_ID
285
+		$EVT_ID = absint($EVT_ID);
286
+		$old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object();
287
+		$this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db);
288
+		$query_params = array(array('Event.EVT_ID' => $EVT_ID), 'order_by' => array('DTT_EVT_start' => 'asc'));
289
+		if ( ! $include_expired) {
290
+			$query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', true));
291
+		}
292
+		if ($include_deleted) {
293
+			$query_params[0]['DTT_deleted'] = array('IN', array(true, false));
294
+		}
295
+		if ($limit) {
296
+			$query_params['limit'] = $limit;
297
+		}
298
+		/** @var EE_Datetime[] $result */
299
+		$result = $this->get_all($query_params);
300
+		$this->assume_values_already_prepared_by_model_object($old_assumption);
301
+		return $result;
302
+	}
303
+
304
+
305
+
306
+	/**
307
+	 * Gets ALL the datetimes for an ticket (including trashed ones, for now), ordered
308
+	 * only by start date
309
+	 *
310
+	 * @param int     $TKT_ID
311
+	 * @param boolean $include_expired
312
+	 * @param boolean $include_deleted
313
+	 * @param int     $limit
314
+	 * @return EE_Datetime[]
315
+	 * @throws \EE_Error
316
+	 */
317
+	public function get_datetimes_for_ticket_ordered_by_start_time(
318
+		$TKT_ID,
319
+		$include_expired = true,
320
+		$include_deleted = true,
321
+		$limit = null
322
+	) {
323
+		//sanitize TKT_ID
324
+		$TKT_ID = absint($TKT_ID);
325
+		$old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object();
326
+		$this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db);
327
+		$query_params = array(array('Ticket.TKT_ID' => $TKT_ID), 'order_by' => array('DTT_EVT_start' => 'asc'));
328
+		if ( ! $include_expired) {
329
+			$query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', true));
330
+		}
331
+		if ($include_deleted) {
332
+			$query_params[0]['DTT_deleted'] = array('IN', array(true, false));
333
+		}
334
+		if ($limit) {
335
+			$query_params['limit'] = $limit;
336
+		}
337
+		/** @var EE_Datetime[] $result */
338
+		$result = $this->get_all($query_params);
339
+		$this->assume_values_already_prepared_by_model_object($old_assumption);
340
+		return $result;
341
+	}
342
+
343
+
344
+
345
+	/**
346
+	 * Gets all the datetimes for a ticket (including trashed ones, for now), ordered by the DTT_order for the
347
+	 * datetimes.
348
+	 *
349
+	 * @param  int      $TKT_ID          ID of ticket to retrieve the datetimes for
350
+	 * @param  boolean  $include_expired whether to include expired datetimes or not
351
+	 * @param  boolean  $include_deleted whether to include trashed datetimes or not.
352
+	 * @param  int|null $limit           if null, no limit, if int then limit results by
353
+	 *                                   that number
354
+	 * @return EE_Datetime[]
355
+	 * @throws \EE_Error
356
+	 */
357
+	public function get_datetimes_for_ticket_ordered_by_DTT_order(
358
+		$TKT_ID,
359
+		$include_expired = true,
360
+		$include_deleted = true,
361
+		$limit = null
362
+	) {
363
+		//sanitize id.
364
+		$TKT_ID = absint($TKT_ID);
365
+		$old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object();
366
+		$this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db);
367
+		$where_params = array('Ticket.TKT_ID' => $TKT_ID);
368
+		$query_params = array($where_params, 'order_by' => array('DTT_order' => 'ASC'));
369
+		if ( ! $include_expired) {
370
+			$query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', true));
371
+		}
372
+		if ($include_deleted) {
373
+			$query_params[0]['DTT_deleted'] = array('IN', array(true, false));
374
+		}
375
+		if ($limit) {
376
+			$query_params['limit'] = $limit;
377
+		}
378
+		/** @var EE_Datetime[] $result */
379
+		$result = $this->get_all($query_params);
380
+		$this->assume_values_already_prepared_by_model_object($old_assumption);
381
+		return $result;
382
+	}
383
+
384
+
385
+
386
+	/**
387
+	 * Gets the most important datetime for a particular event (ie, the primary event usually. But if for some WACK
388
+	 * reason it doesn't exist, we consider the earliest event the most important)
389
+	 *
390
+	 * @param int $EVT_ID
391
+	 * @return EE_Datetime
392
+	 * @throws \EE_Error
393
+	 */
394
+	public function get_most_important_datetime_for_event($EVT_ID)
395
+	{
396
+		$results = $this->get_datetimes_for_event_ordered_by_importance($EVT_ID, 1);
397
+		if ($results) {
398
+			return array_shift($results);
399
+		} else {
400
+			return null;
401
+		}
402
+	}
403
+
404
+
405
+
406
+	/**
407
+	 * This returns a wpdb->results        Array of all DTT month and years matching the incoming query params and
408
+	 * grouped by month and year.
409
+	 *
410
+	 * @param  array  $where_params      Array of query_params as described in the comments for EEM_Base::get_all()
411
+	 * @param  string $evt_active_status A string representing the evt active status to filter the months by.
412
+	 *                                   Can be:
413
+	 *                                   - '' = no filter
414
+	 *                                   - upcoming = Published events with at least one upcoming datetime.
415
+	 *                                   - expired = Events with all datetimes expired.
416
+	 *                                   - active = Events that are published and have at least one datetime that
417
+	 *                                   starts before now and ends after now.
418
+	 *                                   - inactive = Events that are either not published.
419
+	 * @return EE_Base_Class[]
420
+	 * @throws \EE_Error
421
+	 */
422
+	public function get_dtt_months_and_years($where_params, $evt_active_status = '')
423
+	{
424
+		$current_time_for_DTT_EVT_start = $this->current_time_for_query('DTT_EVT_start');
425
+		$current_time_for_DTT_EVT_end = $this->current_time_for_query('DTT_EVT_end');
426
+		switch ($evt_active_status) {
427
+			case 'upcoming' :
428
+				$where_params['Event.status'] = 'publish';
429
+				//if there are already query_params matching DTT_EVT_start then we need to modify that to add them.
430
+				if (isset($where_params['DTT_EVT_start'])) {
431
+					$where_params['DTT_EVT_start*****'] = $where_params['DTT_EVT_start'];
432
+				}
433
+				$where_params['DTT_EVT_start'] = array('>', $current_time_for_DTT_EVT_start);
434
+				break;
435
+			case 'expired' :
436
+				if (isset($where_params['Event.status'])) {
437
+					unset($where_params['Event.status']);
438
+				}
439
+				//get events to exclude
440
+				$exclude_query[0] = array_merge($where_params,
441
+					array('DTT_EVT_end' => array('>', $current_time_for_DTT_EVT_end)));
442
+				//first get all events that have datetimes where its not expired.
443
+				$event_ids = $this->_get_all_wpdb_results($exclude_query, OBJECT_K, 'Datetime.EVT_ID');
444
+				$event_ids = array_keys($event_ids);
445
+				if (isset($where_params['DTT_EVT_end'])) {
446
+					$where_params['DTT_EVT_end****'] = $where_params['DTT_EVT_end'];
447
+				}
448
+				$where_params['DTT_EVT_end'] = array('<', $current_time_for_DTT_EVT_end);
449
+				$where_params['Event.EVT_ID'] = array('NOT IN', $event_ids);
450
+				break;
451
+			case 'active' :
452
+				$where_params['Event.status'] = 'publish';
453
+				if (isset($where_params['DTT_EVT_start'])) {
454
+					$where_params['Datetime.DTT_EVT_start******'] = $where_params['DTT_EVT_start'];
455
+				}
456
+				if (isset($where_params['Datetime.DTT_EVT_end'])) {
457
+					$where_params['Datetime.DTT_EVT_end*****'] = $where_params['DTT_EVT_end'];
458
+				}
459
+				$where_params['DTT_EVT_start'] = array('<', $current_time_for_DTT_EVT_start);
460
+				$where_params['DTT_EVT_end'] = array('>', $current_time_for_DTT_EVT_end);
461
+				break;
462
+			case 'inactive' :
463
+				if (isset($where_params['Event.status'])) {
464
+					unset($where_params['Event.status']);
465
+				}
466
+				if (isset($where_params['OR'])) {
467
+					$where_params['AND']['OR'] = $where_params['OR'];
468
+				}
469
+				if (isset($where_params['DTT_EVT_end'])) {
470
+					$where_params['AND']['DTT_EVT_end****'] = $where_params['DTT_EVT_end'];
471
+					unset($where_params['DTT_EVT_end']);
472
+				}
473
+				if (isset($where_params['DTT_EVT_start'])) {
474
+					$where_params['AND']['DTT_EVT_start'] = $where_params['DTT_EVT_start'];
475
+					unset($where_params['DTT_EVT_start']);
476
+				}
477
+				$where_params['AND']['Event.status'] = array('!=', 'publish');
478
+				break;
479
+		}
480
+		$query_params[0] = $where_params;
481
+		$query_params['group_by'] = array('dtt_year', 'dtt_month');
482
+		$query_params['order_by'] = array('DTT_EVT_start' => 'DESC');
483
+		$query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'DTT_EVT_start');
484
+		$columns_to_select = array(
485
+			'dtt_year'      => array('YEAR(' . $query_interval . ')', '%s'),
486
+			'dtt_month'     => array('MONTHNAME(' . $query_interval . ')', '%s'),
487
+			'dtt_month_num' => array('MONTH(' . $query_interval . ')', '%s'),
488
+		);
489
+		return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select);
490
+	}
491
+
492
+
493
+
494
+	/**
495
+	 * Updates the DTT_sold attribute on each datetime (based on the registrations
496
+	 * for the tickets for each datetime)
497
+	 *
498
+	 * @param EE_Datetime[] $datetimes
499
+	 */
500
+	public function update_sold($datetimes)
501
+	{
502
+		foreach ($datetimes as $datetime) {
503
+			$datetime->update_sold();
504
+		}
505
+	}
506
+
507
+
508
+
509
+	/**
510
+	 *    Gets the total number of tickets available at a particular datetime
511
+	 *    (does NOT take into account the datetime's spaces available)
512
+	 *
513
+	 * @param int   $DTT_ID
514
+	 * @param array $query_params
515
+	 * @return int of tickets available. If sold out, return less than 1. If infinite, returns EE_INF,  IF there are NO
516
+	 *             tickets attached to datetime then FALSE is returned.
517
+	 */
518
+	public function sum_tickets_currently_available_at_datetime($DTT_ID, array $query_params = array())
519
+	{
520
+		$datetime = $this->get_one_by_ID($DTT_ID);
521
+		if ($datetime instanceof EE_Datetime) {
522
+			return $datetime->tickets_remaining($query_params);
523
+		}
524
+		return 0;
525
+	}
526
+
527
+
528
+
529
+	/**
530
+	 * This returns an array of counts of datetimes in the database for each Datetime status that can be queried.
531
+	 *
532
+	 * @param  array $stati_to_include If included you can restrict the statuses we return counts for by including the
533
+	 *                                 stati you want counts for as values in the array.  An empty array returns counts
534
+	 *                                 for all valid stati.
535
+	 * @param  array $query_params     If included can be used to refine the conditions for returning the count (i.e.
536
+	 *                                 only for Datetimes connected to a specific event, or specific ticket.
537
+	 * @return array  The value returned is an array indexed by Datetime Status and the values are the counts.  The
538
+	 * @throws \EE_Error
539
+	 *                                 stati used as index keys are: EE_Datetime::active EE_Datetime::upcoming EE_Datetime::expired
540
+	 */
541
+	public function get_datetime_counts_by_status(array $stati_to_include = array(), array $query_params = array())
542
+	{
543
+		//only accept where conditions for this query.
544
+		$_where = isset($query_params[0]) ? $query_params[0] : array();
545
+		$status_query_args = array(
546
+			EE_Datetime::active   => array_merge(
547
+				$_where,
548
+				array('DTT_EVT_start' => array('<', time()), 'DTT_EVT_end' => array('>', time()))
549
+			),
550
+			EE_Datetime::upcoming => array_merge(
551
+				$_where,
552
+				array('DTT_EVT_start' => array('>', time()))
553
+			),
554
+			EE_Datetime::expired  => array_merge(
555
+				$_where,
556
+				array('DTT_EVT_end' => array('<', time()))
557
+			),
558
+		);
559
+		if ( ! empty($stati_to_include)) {
560
+			foreach (array_keys($status_query_args) as $status) {
561
+				if ( ! in_array($status, $stati_to_include, true)) {
562
+					unset($status_query_args[$status]);
563
+				}
564
+			}
565
+		}
566
+		//loop through and query counts for each stati.
567
+		$status_query_results = array();
568
+		foreach ($status_query_args as $status => $status_where_conditions) {
569
+			$status_query_results[$status] = EEM_Datetime::count(array($status_where_conditions), 'DTT_ID', true);
570
+		}
571
+		return $status_query_results;
572
+	}
573
+
574
+
575
+
576
+	/**
577
+	 * Returns the specific count for a given Datetime status matching any given query_params.
578
+	 *
579
+	 * @param string $status Valid string representation for Datetime status requested. (Defaults to Active).
580
+	 * @param array  $query_params
581
+	 * @return int
582
+	 * @throws \EE_Error
583
+	 */
584
+	public function get_datetime_count_for_status($status = EE_Datetime::active, array $query_params = array())
585
+	{
586
+		$count = $this->get_datetime_counts_by_status(array($status), $query_params);
587
+		return ! empty($count[$status]) ? $count[$status] : 0;
588
+	}
589 589
 
590 590
 
591 591
 
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -482,9 +482,9 @@
 block discarded – undo
482 482
         $query_params['order_by'] = array('DTT_EVT_start' => 'DESC');
483 483
         $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'DTT_EVT_start');
484 484
         $columns_to_select = array(
485
-            'dtt_year'      => array('YEAR(' . $query_interval . ')', '%s'),
486
-            'dtt_month'     => array('MONTHNAME(' . $query_interval . ')', '%s'),
487
-            'dtt_month_num' => array('MONTH(' . $query_interval . ')', '%s'),
485
+            'dtt_year'      => array('YEAR('.$query_interval.')', '%s'),
486
+            'dtt_month'     => array('MONTHNAME('.$query_interval.')', '%s'),
487
+            'dtt_month_num' => array('MONTH('.$query_interval.')', '%s'),
488 488
         );
489 489
         return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select);
490 490
     }
Please login to merge, or discard this patch.
public/Espresso_Arabica_2014/content-espresso_events-datetimes.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,15 +1,15 @@
 block discarded – undo
1 1
 <?php
2 2
 //echo '<br/><h6 style="color:#2EA2CC;">'. __FILE__ . ' &nbsp; <span style="font-weight:normal;color:#E76700"> Line #: ' . __LINE__ . '</span></h6>';
3 3
 
4
-if ( is_single() || ( is_archive() && espresso_display_datetimes_in_event_list() ) ) :
4
+if (is_single() || (is_archive() && espresso_display_datetimes_in_event_list())) :
5 5
 global $post;
6
-do_action( 'AHEE_event_details_before_event_date', $post );
6
+do_action('AHEE_event_details_before_event_date', $post);
7 7
 ?>
8 8
 	<div class="event-datetimes">
9
-		<?php espresso_list_of_event_dates( $post->ID );?>
9
+		<?php espresso_list_of_event_dates($post->ID); ?>
10 10
 	</div>
11 11
 	<!-- .event-datetimes -->
12 12
 <?php
13
-do_action( 'AHEE_event_details_after_event_date', $post );
13
+do_action('AHEE_event_details_after_event_date', $post);
14 14
 endif;
15 15
 ?>
16 16
\ No newline at end of file
Please login to merge, or discard this patch.
modules/ticket_selector/DatetimeSelector.php 1 patch
Indentation   +151 added lines, -151 removed lines patch added patch discarded remove patch
@@ -16,157 +16,157 @@
 block discarded – undo
16 16
 class DatetimeSelector
17 17
 {
18 18
 
19
-    /**
20
-     * @var \EE_Event $event
21
-     */
22
-    protected $event;
23
-
24
-    /**
25
-     * @var \EE_Ticket[] $tickets
26
-     */
27
-    protected $tickets;
28
-
29
-    /**
30
-     * @var \EE_Datetime[] $datetimes
31
-     */
32
-    protected $datetimes;
33
-
34
-    /**
35
-     * @var \EE_Ticket_Selector_Config $template_settings
36
-     */
37
-    protected $template_settings;
38
-
39
-    /**
40
-     * @var boolean $active
41
-     */
42
-    protected $active = false;
43
-
44
-
45
-
46
-    /**
47
-     * DatetimeSelector constructor.
48
-     *
49
-     * @param \EE_Event                  $event
50
-     * @param \EE_Ticket[]               $tickets
51
-     * @param \EE_Ticket_Selector_Config $template_settings
52
-     * @throws \EE_Error
53
-     */
54
-    public function __construct(\EE_Event $event, array $tickets, \EE_Ticket_Selector_Config $template_settings)
55
-    {
56
-        $this->event = $event;
57
-        $this->tickets = $tickets;
58
-        $this->template_settings = $template_settings;
59
-        $this->datetimes = $this->getAllDatetimesForAllTicket($tickets);
60
-        $this->active = $this->template_settings->showDatetimeSelector($this->datetimes);
61
-    }
62
-
63
-
64
-
65
-    /**
66
-     * @param \EE_Ticket[] $tickets
67
-     * @return array
68
-     * @throws \EE_Error
69
-     */
70
-    protected function getAllDatetimesForAllTicket($tickets = array())
71
-    {
72
-        $datetimes = array();
73
-        foreach ($tickets as $ticket) {
74
-            $datetimes = $this->getTicketDatetimes($ticket, $datetimes);
75
-        }
76
-        return $datetimes;
77
-    }
78
-
79
-
80
-
81
-    /**
82
-     * @param \EE_Ticket      $ticket
83
-     * @param  \EE_Datetime[] $datetimes
84
-     * @return \EE_Datetime[]
85
-     * @throws \EE_Error
86
-     */
87
-    protected function getTicketDatetimes(\EE_Ticket $ticket, $datetimes = array())
88
-    {
89
-        $ticket_datetimes = $ticket->datetimes(
90
-            array(
91
-                'order_by'                 => array(
92
-                    'DTT_order'     => 'ASC',
93
-                    'DTT_EVT_start' => 'ASC'
94
-                ),
95
-                'default_where_conditions' => 'none',
96
-            )
97
-        );
98
-        foreach ($ticket_datetimes as $ticket_datetime) {
99
-            if ( ! $ticket_datetime instanceof \EE_Datetime) {
100
-                continue;
101
-            }
102
-            $datetimes[ $ticket_datetime->ID() ] = $ticket_datetime;
103
-        }
104
-        return $datetimes;
105
-    }
106
-
107
-
108
-
109
-    /**
110
-     * @param \EE_Ticket                 $ticket
111
-     * @return string
112
-     * @throws \EE_Error
113
-     */
114
-    public function getTicketDatetimeClasses( \EE_Ticket $ticket ) {
115
-        if ( ! $this->active) {
116
-            return '';
117
-        }
118
-        $ticket_datetimes = $this->getTicketDatetimes($ticket);
119
-        $classes = '';
120
-        foreach ($this->datetimes as $datetime) {
121
-            if ( ! $datetime instanceof \EE_Datetime || ! in_array($datetime, $ticket_datetimes)) {
122
-                continue;
123
-            }
124
-            $classes .= ' ee-ticket-datetimes-' . $datetime->date_range('Y_m_d', '-');
125
-        }
126
-        $classes .= ' ee-hidden-ticket-tr';
127
-        return $classes;
128
-    }
129
-
130
-
131
-
132
-    /**
133
-     * @param string $date_format
134
-     * @return string
135
-     * @throws \EE_Error
136
-     */
137
-    public function getDatetimeSelector($date_format = 'Y-m-d') {
138
-        if ( ! $this->active) {
139
-            return '';
140
-        }
141
-        $html = \EEH_HTML::div('', '', 'datetime_selector-dv');
142
-        $html .= \EEH_HTML::label(
143
-            \EEH_HTML::span('', '', 'dashicons dashicons-calendar-alt') . esc_html__('Datetimes', 'event_espresso'),
144
-            '', 'datetime_selector-lbl'
145
-        );
146
-	    $html .= \EEH_HTML::div( '', '', 'select-wrap-dv' );
147
-	    $html .= "\n" . '<select name="datetime_selector-' . $this->event->ID() . '"';
148
-        $html .= ' id="datetime-selector-' . $this->event->ID() . '"';
149
-        $html .= ' class="ticket-selector-datetime-selector-slct"';
150
-        $html .= ' data-tkt_slctr_evt="' . $this->event->ID() . '">';
151
-        $html .= "\n"
152
-                 . '<option value="0">'
153
-                 . esc_html__('- please select a datetime -', 'event_espresso')
154
-                 . '</option>';
155
-        // offer ticket quantities from the min to the max
156
-        foreach ($this->datetimes as $datetime) {
157
-            if ( ! $datetime instanceof \EE_Datetime) {
158
-                continue;
159
-            }
160
-            $html .= "\n" . '<option value="' . $datetime->date_range('Y_m_d', '-') . '">';
161
-            $html .= $datetime->date_range($date_format);
162
-            $html .= '</option>';
163
-        }
164
-        $html .= "\n</select>";
165
-	    $html .= \EEH_HTML::divx('', 'select-wrap-dv');
166
-	    $html .= \EEH_HTML::br();
167
-        $html .= \EEH_HTML::divx('', 'datetime_selector-dv');
168
-        return $html;
169
-    }
19
+	/**
20
+	 * @var \EE_Event $event
21
+	 */
22
+	protected $event;
23
+
24
+	/**
25
+	 * @var \EE_Ticket[] $tickets
26
+	 */
27
+	protected $tickets;
28
+
29
+	/**
30
+	 * @var \EE_Datetime[] $datetimes
31
+	 */
32
+	protected $datetimes;
33
+
34
+	/**
35
+	 * @var \EE_Ticket_Selector_Config $template_settings
36
+	 */
37
+	protected $template_settings;
38
+
39
+	/**
40
+	 * @var boolean $active
41
+	 */
42
+	protected $active = false;
43
+
44
+
45
+
46
+	/**
47
+	 * DatetimeSelector constructor.
48
+	 *
49
+	 * @param \EE_Event                  $event
50
+	 * @param \EE_Ticket[]               $tickets
51
+	 * @param \EE_Ticket_Selector_Config $template_settings
52
+	 * @throws \EE_Error
53
+	 */
54
+	public function __construct(\EE_Event $event, array $tickets, \EE_Ticket_Selector_Config $template_settings)
55
+	{
56
+		$this->event = $event;
57
+		$this->tickets = $tickets;
58
+		$this->template_settings = $template_settings;
59
+		$this->datetimes = $this->getAllDatetimesForAllTicket($tickets);
60
+		$this->active = $this->template_settings->showDatetimeSelector($this->datetimes);
61
+	}
62
+
63
+
64
+
65
+	/**
66
+	 * @param \EE_Ticket[] $tickets
67
+	 * @return array
68
+	 * @throws \EE_Error
69
+	 */
70
+	protected function getAllDatetimesForAllTicket($tickets = array())
71
+	{
72
+		$datetimes = array();
73
+		foreach ($tickets as $ticket) {
74
+			$datetimes = $this->getTicketDatetimes($ticket, $datetimes);
75
+		}
76
+		return $datetimes;
77
+	}
78
+
79
+
80
+
81
+	/**
82
+	 * @param \EE_Ticket      $ticket
83
+	 * @param  \EE_Datetime[] $datetimes
84
+	 * @return \EE_Datetime[]
85
+	 * @throws \EE_Error
86
+	 */
87
+	protected function getTicketDatetimes(\EE_Ticket $ticket, $datetimes = array())
88
+	{
89
+		$ticket_datetimes = $ticket->datetimes(
90
+			array(
91
+				'order_by'                 => array(
92
+					'DTT_order'     => 'ASC',
93
+					'DTT_EVT_start' => 'ASC'
94
+				),
95
+				'default_where_conditions' => 'none',
96
+			)
97
+		);
98
+		foreach ($ticket_datetimes as $ticket_datetime) {
99
+			if ( ! $ticket_datetime instanceof \EE_Datetime) {
100
+				continue;
101
+			}
102
+			$datetimes[ $ticket_datetime->ID() ] = $ticket_datetime;
103
+		}
104
+		return $datetimes;
105
+	}
106
+
107
+
108
+
109
+	/**
110
+	 * @param \EE_Ticket                 $ticket
111
+	 * @return string
112
+	 * @throws \EE_Error
113
+	 */
114
+	public function getTicketDatetimeClasses( \EE_Ticket $ticket ) {
115
+		if ( ! $this->active) {
116
+			return '';
117
+		}
118
+		$ticket_datetimes = $this->getTicketDatetimes($ticket);
119
+		$classes = '';
120
+		foreach ($this->datetimes as $datetime) {
121
+			if ( ! $datetime instanceof \EE_Datetime || ! in_array($datetime, $ticket_datetimes)) {
122
+				continue;
123
+			}
124
+			$classes .= ' ee-ticket-datetimes-' . $datetime->date_range('Y_m_d', '-');
125
+		}
126
+		$classes .= ' ee-hidden-ticket-tr';
127
+		return $classes;
128
+	}
129
+
130
+
131
+
132
+	/**
133
+	 * @param string $date_format
134
+	 * @return string
135
+	 * @throws \EE_Error
136
+	 */
137
+	public function getDatetimeSelector($date_format = 'Y-m-d') {
138
+		if ( ! $this->active) {
139
+			return '';
140
+		}
141
+		$html = \EEH_HTML::div('', '', 'datetime_selector-dv');
142
+		$html .= \EEH_HTML::label(
143
+			\EEH_HTML::span('', '', 'dashicons dashicons-calendar-alt') . esc_html__('Datetimes', 'event_espresso'),
144
+			'', 'datetime_selector-lbl'
145
+		);
146
+		$html .= \EEH_HTML::div( '', '', 'select-wrap-dv' );
147
+		$html .= "\n" . '<select name="datetime_selector-' . $this->event->ID() . '"';
148
+		$html .= ' id="datetime-selector-' . $this->event->ID() . '"';
149
+		$html .= ' class="ticket-selector-datetime-selector-slct"';
150
+		$html .= ' data-tkt_slctr_evt="' . $this->event->ID() . '">';
151
+		$html .= "\n"
152
+				 . '<option value="0">'
153
+				 . esc_html__('- please select a datetime -', 'event_espresso')
154
+				 . '</option>';
155
+		// offer ticket quantities from the min to the max
156
+		foreach ($this->datetimes as $datetime) {
157
+			if ( ! $datetime instanceof \EE_Datetime) {
158
+				continue;
159
+			}
160
+			$html .= "\n" . '<option value="' . $datetime->date_range('Y_m_d', '-') . '">';
161
+			$html .= $datetime->date_range($date_format);
162
+			$html .= '</option>';
163
+		}
164
+		$html .= "\n</select>";
165
+		$html .= \EEH_HTML::divx('', 'select-wrap-dv');
166
+		$html .= \EEH_HTML::br();
167
+		$html .= \EEH_HTML::divx('', 'datetime_selector-dv');
168
+		return $html;
169
+	}
170 170
 
171 171
 
172 172
 
Please login to merge, or discard this patch.
core/admin/EE_Admin_Page.core.php 2 patches
Indentation   +3285 added lines, -3285 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
  * Event Espresso
@@ -28,2116 +28,2116 @@  discard block
 block discarded – undo
28 28
 {
29 29
 
30 30
 
31
-    //set in _init_page_props()
32
-    public $page_slug;
31
+	//set in _init_page_props()
32
+	public $page_slug;
33 33
 
34
-    public $page_label;
34
+	public $page_label;
35 35
 
36
-    public $page_folder;
36
+	public $page_folder;
37 37
 
38
-    //set in define_page_props()
39
-    protected $_admin_base_url;
38
+	//set in define_page_props()
39
+	protected $_admin_base_url;
40 40
 
41
-    protected $_admin_base_path;
41
+	protected $_admin_base_path;
42 42
 
43
-    protected $_admin_page_title;
43
+	protected $_admin_page_title;
44 44
 
45
-    protected $_labels;
45
+	protected $_labels;
46 46
 
47 47
 
48
-    //set early within EE_Admin_Init
49
-    protected $_wp_page_slug;
48
+	//set early within EE_Admin_Init
49
+	protected $_wp_page_slug;
50 50
 
51
-    //navtabs
52
-    protected $_nav_tabs;
51
+	//navtabs
52
+	protected $_nav_tabs;
53 53
 
54
-    protected $_default_nav_tab_name;
54
+	protected $_default_nav_tab_name;
55 55
 
56
-    //helptourstops
57
-    protected $_help_tour = array();
56
+	//helptourstops
57
+	protected $_help_tour = array();
58 58
 
59 59
 
60
-    //template variables (used by templates)
61
-    protected $_template_path;
60
+	//template variables (used by templates)
61
+	protected $_template_path;
62 62
 
63
-    protected $_column_template_path;
63
+	protected $_column_template_path;
64 64
 
65
-    /**
66
-     * @var array $_template_args
67
-     */
68
-    protected $_template_args = array();
65
+	/**
66
+	 * @var array $_template_args
67
+	 */
68
+	protected $_template_args = array();
69 69
 
70
-    /**
71
-     * this will hold the list table object for a given view.
72
-     *
73
-     * @var EE_Admin_List_Table $_list_table_object
74
-     */
75
-    protected $_list_table_object;
70
+	/**
71
+	 * this will hold the list table object for a given view.
72
+	 *
73
+	 * @var EE_Admin_List_Table $_list_table_object
74
+	 */
75
+	protected $_list_table_object;
76 76
 
77
-    //bools
78
-    protected $_is_UI_request = null; //this starts at null so we can have no header routes progress through two states.
77
+	//bools
78
+	protected $_is_UI_request = null; //this starts at null so we can have no header routes progress through two states.
79 79
 
80
-    protected $_routing;
80
+	protected $_routing;
81 81
 
82
-    //list table args
83
-    protected $_view;
82
+	//list table args
83
+	protected $_view;
84 84
 
85
-    protected $_views;
85
+	protected $_views;
86 86
 
87 87
 
88
-    //action => method pairs used for routing incoming requests
89
-    protected $_page_routes;
88
+	//action => method pairs used for routing incoming requests
89
+	protected $_page_routes;
90 90
 
91
-    protected $_page_config;
91
+	protected $_page_config;
92 92
 
93
-    //the current page route and route config
94
-    protected $_route;
93
+	//the current page route and route config
94
+	protected $_route;
95 95
 
96
-    protected $_route_config;
96
+	protected $_route_config;
97 97
 
98
-    /**
99
-     * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
100
-     * actions.
101
-     *
102
-     * @since 4.6.x
103
-     * @var array.
104
-     */
105
-    protected $_default_route_query_args;
98
+	/**
99
+	 * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
100
+	 * actions.
101
+	 *
102
+	 * @since 4.6.x
103
+	 * @var array.
104
+	 */
105
+	protected $_default_route_query_args;
106 106
 
107
-    //set via request page and action args.
108
-    protected $_current_page;
107
+	//set via request page and action args.
108
+	protected $_current_page;
109 109
 
110
-    protected $_current_view;
110
+	protected $_current_view;
111 111
 
112
-    protected $_current_page_view_url;
112
+	protected $_current_page_view_url;
113 113
 
114
-    //sanitized request action (and nonce)
115
-    /**
116
-     * @var string $_req_action
117
-     */
118
-    protected $_req_action;
114
+	//sanitized request action (and nonce)
115
+	/**
116
+	 * @var string $_req_action
117
+	 */
118
+	protected $_req_action;
119 119
 
120
-    /**
121
-     * @var string $_req_nonce
122
-     */
123
-    protected $_req_nonce;
120
+	/**
121
+	 * @var string $_req_nonce
122
+	 */
123
+	protected $_req_nonce;
124 124
 
125
-    //search related
126
-    protected $_search_btn_label;
125
+	//search related
126
+	protected $_search_btn_label;
127 127
 
128
-    protected $_search_box_callback;
128
+	protected $_search_box_callback;
129 129
 
130
-    /**
131
-     * WP Current Screen object
132
-     *
133
-     * @var WP_Screen
134
-     */
135
-    protected $_current_screen;
130
+	/**
131
+	 * WP Current Screen object
132
+	 *
133
+	 * @var WP_Screen
134
+	 */
135
+	protected $_current_screen;
136 136
 
137
-    //for holding EE_Admin_Hooks object when needed (set via set_hook_object())
138
-    protected $_hook_obj;
137
+	//for holding EE_Admin_Hooks object when needed (set via set_hook_object())
138
+	protected $_hook_obj;
139 139
 
140
-    //for holding incoming request data
141
-    protected $_req_data;
140
+	//for holding incoming request data
141
+	protected $_req_data;
142 142
 
143
-    // yes / no array for admin form fields
144
-    protected $_yes_no_values = array();
145
-
146
-    //some default things shared by all child classes
147
-    protected $_default_espresso_metaboxes;
148
-
149
-    /**
150
-     *    EE_Registry Object
151
-     *
152
-     * @var    EE_Registry
153
-     * @access    protected
154
-     */
155
-    protected $EE = null;
156
-
157
-
158
-
159
-    /**
160
-     * This is just a property that flags whether the given route is a caffeinated route or not.
161
-     *
162
-     * @var boolean
163
-     */
164
-    protected $_is_caf = false;
165
-
166
-
167
-
168
-    /**
169
-     * @Constructor
170
-     * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
171
-     * @access public
172
-     */
173
-    public function __construct($routing = true)
174
-    {
175
-        if (strpos($this->_get_dir(), 'caffeinated') !== false) {
176
-            $this->_is_caf = true;
177
-        }
178
-        $this->_yes_no_values = array(
179
-                array('id' => true, 'text' => __('Yes', 'event_espresso')),
180
-                array('id' => false, 'text' => __('No', 'event_espresso')),
181
-        );
182
-        //set the _req_data property.
183
-        $this->_req_data = array_merge($_GET, $_POST);
184
-        //routing enabled?
185
-        $this->_routing = $routing;
186
-        //set initial page props (child method)
187
-        $this->_init_page_props();
188
-        //set global defaults
189
-        $this->_set_defaults();
190
-        //set early because incoming requests could be ajax related and we need to register those hooks.
191
-        $this->_global_ajax_hooks();
192
-        $this->_ajax_hooks();
193
-        //other_page_hooks have to be early too.
194
-        $this->_do_other_page_hooks();
195
-        //This just allows us to have extending clases do something specific before the parent constructor runs _page_setup.
196
-        if (method_exists($this, '_before_page_setup')) {
197
-            $this->_before_page_setup();
198
-        }
199
-        //set up page dependencies
200
-        $this->_page_setup();
201
-    }
202
-
203
-
204
-
205
-    /**
206
-     * _init_page_props
207
-     * Child classes use to set at least the following properties:
208
-     * $page_slug.
209
-     * $page_label.
210
-     *
211
-     * @abstract
212
-     * @access protected
213
-     * @return void
214
-     */
215
-    abstract protected function _init_page_props();
216
-
217
-
218
-
219
-    /**
220
-     * _ajax_hooks
221
-     * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
222
-     * Note: within the ajax callback methods.
223
-     *
224
-     * @abstract
225
-     * @access protected
226
-     * @return void
227
-     */
228
-    abstract protected function _ajax_hooks();
229
-
230
-
231
-
232
-    /**
233
-     * _define_page_props
234
-     * child classes define page properties in here.  Must include at least:
235
-     * $_admin_base_url = base_url for all admin pages
236
-     * $_admin_page_title = default admin_page_title for admin pages
237
-     * $_labels = array of default labels for various automatically generated elements:
238
-     *    array(
239
-     *        'buttons' => array(
240
-     *            'add' => __('label for add new button'),
241
-     *            'edit' => __('label for edit button'),
242
-     *            'delete' => __('label for delete button')
243
-     *            )
244
-     *        )
245
-     *
246
-     * @abstract
247
-     * @access protected
248
-     * @return void
249
-     */
250
-    abstract protected function _define_page_props();
251
-
252
-
253
-
254
-    /**
255
-     * _set_page_routes
256
-     * child classes use this to define the page routes for all subpages handled by the class.  Page routes are assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also have a 'default'
257
-     * route. Here's the format
258
-     * $this->_page_routes = array(
259
-     *        'default' => array(
260
-     *            'func' => '_default_method_handling_route',
261
-     *            'args' => array('array','of','args'),
262
-     *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e. ajax request, backend processing)
263
-     *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a headers route after.  The string you enter here should match the defined route reference for a headers sent route.
264
-     *            'capability' => 'route_capability', //indicate a string for minimum capability required to access this route.
265
-     *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability checks).
266
-     *        ),
267
-     *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a handling method.
268
-     *        )
269
-     * )
270
-     *
271
-     * @abstract
272
-     * @access protected
273
-     * @return void
274
-     */
275
-    abstract protected function _set_page_routes();
276
-
277
-
278
-
279
-    /**
280
-     * _set_page_config
281
-     * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the array corresponds to the page_route for the loaded page.
282
-     * Format:
283
-     * $this->_page_config = array(
284
-     *        'default' => array(
285
-     *            'labels' => array(
286
-     *                'buttons' => array(
287
-     *                    'add' => __('label for adding item'),
288
-     *                    'edit' => __('label for editing item'),
289
-     *                    'delete' => __('label for deleting item')
290
-     *                ),
291
-     *                'publishbox' => __('Localized Title for Publish metabox', 'event_espresso')
292
-     *            ), //optional an array of custom labels for various automatically generated elements to use on the page. If this isn't present then the defaults will be used as set for the $this->_labels in _define_page_props() method
293
-     *            'nav' => array(
294
-     *                'label' => __('Label for Tab', 'event_espresso').
295
-     *                'url' => 'http://someurl', //automatically generated UNLESS you define
296
-     *                'css_class' => 'css-class', //automatically generated UNLESS you define
297
-     *                'order' => 10, //required to indicate tab position.
298
-     *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is displayed then add this parameter.
299
-     *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
300
-     *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load metaboxes set for eventespresso admin pages.
301
-     *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added later.  We just use
302
-     *            this flag to make sure the necessary js gets enqueued on page load.
303
-     *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
304
-     *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The array indicates the max number of columns (4) and the default number of columns on page load (2).  There is an option
305
-     *            in the "screen_options" dropdown that is setup so users can pick what columns they want to display.
306
-     *            'help_tabs' => array( //this is used for adding help tabs to a page
307
-     *                'tab_id' => array(
308
-     *                    'title' => 'tab_title',
309
-     *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting help tab content.  The fallback if it isn't present is to try a the callback.  Filename should match a file in the admin
310
-     *                    folder's "help_tabs" dir (ie.. events/help_tabs/name_of_file_containing_content.help_tab.php)
311
-     *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will attempt to use the callback which should match the name of a method in the class
312
-     *                    ),
313
-     *                'tab2_id' => array(
314
-     *                    'title' => 'tab2 title',
315
-     *                    'filename' => 'file_name_2'
316
-     *                    'callback' => 'callback_method_for_content',
317
-     *                 ),
318
-     *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the help tab area on an admin page. @link http://make.wordpress.org/core/2011/12/06/help-and-screen-api-changes-in-3-3/
319
-     *            'help_tour' => array(
320
-     *                'name_of_help_tour_class', //all help tours shoudl be a child class of EE_Help_Tour and located in a folder for this admin page named "help_tours", a file name matching the key given here
321
-     *                (name_of_help_tour_class.class.php), and class matching key given here (name_of_help_tour_class)
322
-     *            ),
323
-     *            'require_nonce' => TRUE //this is used if you want to set a route to NOT require a nonce (default is true if it isn't present).  To remove the requirement for a nonce check when this route is visited just set
324
-     *            'require_nonce' to FALSE
325
-     *            )
326
-     * )
327
-     *
328
-     * @abstract
329
-     * @access protected
330
-     * @return void
331
-     */
332
-    abstract protected function _set_page_config();
333
-
334
-
335
-
336
-
337
-
338
-    /** end sample help_tour methods **/
339
-    /**
340
-     * _add_screen_options
341
-     * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
342
-     * Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options to a particular view.
343
-     *
344
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
345
-     *         see also WP_Screen object documents...
346
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
347
-     * @abstract
348
-     * @access protected
349
-     * @return void
350
-     */
351
-    abstract protected function _add_screen_options();
352
-
353
-
354
-
355
-    /**
356
-     * _add_feature_pointers
357
-     * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
358
-     * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a particular view.
359
-     * Note: this is just a placeholder for now.  Implementation will come down the road
360
-     * See: WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be extended) also see:
361
-     *
362
-     * @link   http://eamann.com/tech/wordpress-portland/
363
-     * @abstract
364
-     * @access protected
365
-     * @return void
366
-     */
367
-    abstract protected function _add_feature_pointers();
368
-
369
-
370
-
371
-    /**
372
-     * load_scripts_styles
373
-     * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific scripts/styles
374
-     * per view by putting them in a dynamic function in this format (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
375
-     *
376
-     * @abstract
377
-     * @access public
378
-     * @return void
379
-     */
380
-    abstract public function load_scripts_styles();
381
-
382
-
383
-
384
-    /**
385
-     * admin_init
386
-     * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to all pages/views loaded by child class.
387
-     *
388
-     * @abstract
389
-     * @access public
390
-     * @return void
391
-     */
392
-    abstract public function admin_init();
393
-
394
-
395
-
396
-    /**
397
-     * admin_notices
398
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to all pages/views loaded by child class.
399
-     *
400
-     * @abstract
401
-     * @access public
402
-     * @return void
403
-     */
404
-    abstract public function admin_notices();
405
-
406
-
407
-
408
-    /**
409
-     * admin_footer_scripts
410
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method will apply to all pages/views loaded by child class.
411
-     *
412
-     * @access public
413
-     * @return void
414
-     */
415
-    abstract public function admin_footer_scripts();
416
-
417
-
418
-
419
-    /**
420
-     * admin_footer
421
-     * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will apply to all pages/views loaded by child class.
422
-     *
423
-     * @access  public
424
-     * @return void
425
-     */
426
-    public function admin_footer()
427
-    {
428
-    }
429
-
430
-
431
-
432
-    /**
433
-     * _global_ajax_hooks
434
-     * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
435
-     * Note: within the ajax callback methods.
436
-     *
437
-     * @abstract
438
-     * @access protected
439
-     * @return void
440
-     */
441
-    protected function _global_ajax_hooks()
442
-    {
443
-        //for lazy loading of metabox content
444
-        add_action('wp_ajax_espresso-ajax-content', array($this, 'ajax_metabox_content'), 10);
445
-    }
446
-
447
-
448
-
449
-    public function ajax_metabox_content()
450
-    {
451
-        $contentid = isset($this->_req_data['contentid']) ? $this->_req_data['contentid'] : '';
452
-        $url = isset($this->_req_data['contenturl']) ? $this->_req_data['contenturl'] : '';
453
-        self::cached_rss_display($contentid, $url);
454
-        wp_die();
455
-    }
456
-
457
-
458
-
459
-    /**
460
-     * _page_setup
461
-     * Makes sure any things that need to be loaded early get handled.  We also escape early here if the page requested doesn't match the object.
462
-     *
463
-     * @final
464
-     * @access protected
465
-     * @return void
466
-     */
467
-    final protected function _page_setup()
468
-    {
469
-        //requires?
470
-        //admin_init stuff - global - we're setting this REALLY early so if EE_Admin pages have to hook into other WP pages they can.  But keep in mind, not everything is available from the EE_Admin Page object at this point.
471
-        add_action('admin_init', array($this, 'admin_init_global'), 5);
472
-        //next verify if we need to load anything...
473
-        $this->_current_page = ! empty($_GET['page']) ? sanitize_key($_GET['page']) : '';
474
-        $this->page_folder = strtolower(str_replace('_Admin_Page', '', str_replace('Extend_', '', get_class($this))));
475
-        global $ee_menu_slugs;
476
-        $ee_menu_slugs = (array)$ee_menu_slugs;
477
-        if (( ! $this->_current_page || ! isset($ee_menu_slugs[$this->_current_page])) && ! defined('DOING_AJAX')) {
478
-            return false;
479
-        }
480
-        // becuz WP List tables have two duplicate select inputs for choosing bulk actions, we need to copy the action from the second to the first
481
-        if (isset($this->_req_data['action2']) && $this->_req_data['action'] == -1) {
482
-            $this->_req_data['action'] = ! empty($this->_req_data['action2']) && $this->_req_data['action2'] != -1 ? $this->_req_data['action2'] : $this->_req_data['action'];
483
-        }
484
-        // then set blank or -1 action values to 'default'
485
-        $this->_req_action = isset($this->_req_data['action']) && ! empty($this->_req_data['action']) && $this->_req_data['action'] != -1 ? sanitize_key($this->_req_data['action']) : 'default';
486
-        //if action is 'default' after the above BUT we have  'route' var set, then let's use the route as the action.  This covers cases where we're coming in from a list table that isn't on the default route.
487
-        $this->_req_action = $this->_req_action == 'default' && isset($this->_req_data['route']) ? $this->_req_data['route'] : $this->_req_action;
488
-        //however if we are doing_ajax and we've got a 'route' set then that's what the req_action will be
489
-        $this->_req_action = defined('DOING_AJAX') && isset($this->_req_data['route']) ? $this->_req_data['route'] : $this->_req_action;
490
-        $this->_current_view = $this->_req_action;
491
-        $this->_req_nonce = $this->_req_action . '_nonce';
492
-        $this->_define_page_props();
493
-        $this->_current_page_view_url = add_query_arg(array('page' => $this->_current_page, 'action' => $this->_current_view), $this->_admin_base_url);
494
-        //default things
495
-        $this->_default_espresso_metaboxes = array('_espresso_news_post_box', '_espresso_links_post_box', '_espresso_ratings_request', '_espresso_sponsors_post_box');
496
-        //set page configs
497
-        $this->_set_page_routes();
498
-        $this->_set_page_config();
499
-        //let's include any referrer data in our default_query_args for this route for "stickiness".
500
-        if (isset($this->_req_data['wp_referer'])) {
501
-            $this->_default_route_query_args['wp_referer'] = $this->_req_data['wp_referer'];
502
-        }
503
-        //for caffeinated and other extended functionality.  If there is a _extend_page_config method then let's run that to modify the all the various page configuration arrays
504
-        if (method_exists($this, '_extend_page_config')) {
505
-            $this->_extend_page_config();
506
-        }
507
-        //for CPT and other extended functionality. If there is an _extend_page_config_for_cpt then let's run that to modify all the various page configuration arrays.
508
-        if (method_exists($this, '_extend_page_config_for_cpt')) {
509
-            $this->_extend_page_config_for_cpt();
510
-        }
511
-        //filter routes and page_config so addons can add their stuff. Filtering done per class
512
-        $this->_page_routes = apply_filters('FHEE__' . get_class($this) . '__page_setup__page_routes', $this->_page_routes, $this);
513
-        $this->_page_config = apply_filters('FHEE__' . get_class($this) . '__page_setup__page_config', $this->_page_config, $this);
514
-        //if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
515
-        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
516
-            add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view), 10, 2);
517
-        }
518
-        //next route only if routing enabled
519
-        if ($this->_routing && ! defined('DOING_AJAX')) {
520
-            $this->_verify_routes();
521
-            //next let's just check user_access and kill if no access
522
-            $this->check_user_access();
523
-            if ($this->_is_UI_request) {
524
-                //admin_init stuff - global, all views for this page class, specific view
525
-                add_action('admin_init', array($this, 'admin_init'), 10);
526
-                if (method_exists($this, 'admin_init_' . $this->_current_view)) {
527
-                    add_action('admin_init', array($this, 'admin_init_' . $this->_current_view), 15);
528
-                }
529
-            } else {
530
-                //hijack regular WP loading and route admin request immediately
531
-                @ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
532
-                $this->route_admin_request();
533
-            }
534
-        }
535
-    }
536
-
537
-
538
-
539
-    /**
540
-     * Provides a way for related child admin pages to load stuff on the loaded admin page.
541
-     *
542
-     * @access private
543
-     * @return void
544
-     */
545
-    private function _do_other_page_hooks()
546
-    {
547
-        $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, array());
548
-        foreach ($registered_pages as $page) {
549
-            //now let's setup the file name and class that should be present
550
-            $classname = str_replace('.class.php', '', $page);
551
-            //autoloaders should take care of loading file
552
-            if ( ! class_exists($classname)) {
553
-                $error_msg[] = sprintf(__('Something went wrong with loading the %s admin hooks page.', 'event_espresso'), $page);
554
-                $error_msg[] = $error_msg[0]
555
-                               . "\r\n"
556
-                               . sprintf(__('There is no class in place for the %s admin hooks page.%sMake sure you have <strong>%s</strong> defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
557
-                                'event_espresso'), $page, '<br />', $classname);
558
-                throw new EE_Error(implode('||', $error_msg));
559
-            }
560
-            $a = new ReflectionClass($classname);
561
-            //notice we are passing the instance of this class to the hook object.
562
-            $hookobj[] = $a->newInstance($this);
563
-        }
564
-    }
565
-
566
-
567
-
568
-    public function load_page_dependencies()
569
-    {
570
-        try {
571
-            $this->_load_page_dependencies();
572
-        } catch (EE_Error $e) {
573
-            $e->get_error();
574
-        }
575
-    }
576
-
577
-
578
-
579
-    /**
580
-     * load_page_dependencies
581
-     * loads things specific to this page class when its loaded.  Really helps with efficiency.
582
-     *
583
-     * @access public
584
-     * @return void
585
-     */
586
-    protected function _load_page_dependencies()
587
-    {
588
-        //let's set the current_screen and screen options to override what WP set
589
-        $this->_current_screen = get_current_screen();
590
-        //load admin_notices - global, page class, and view specific
591
-        add_action('admin_notices', array($this, 'admin_notices_global'), 5);
592
-        add_action('admin_notices', array($this, 'admin_notices'), 10);
593
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
594
-            add_action('admin_notices', array($this, 'admin_notices_' . $this->_current_view), 15);
595
-        }
596
-        //load network admin_notices - global, page class, and view specific
597
-        add_action('network_admin_notices', array($this, 'network_admin_notices_global'), 5);
598
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
599
-            add_action('network_admin_notices', array($this, 'network_admin_notices_' . $this->_current_view));
600
-        }
601
-        //this will save any per_page screen options if they are present
602
-        $this->_set_per_page_screen_options();
603
-        //setup list table properties
604
-        $this->_set_list_table();
605
-        // child classes can "register" a metabox to be automatically handled via the _page_config array property.  However in some cases the metaboxes will need to be added within a route handling callback.
606
-        $this->_add_registered_meta_boxes();
607
-        $this->_add_screen_columns();
608
-        //add screen options - global, page child class, and view specific
609
-        $this->_add_global_screen_options();
610
-        $this->_add_screen_options();
611
-        if (method_exists($this, '_add_screen_options_' . $this->_current_view)) {
612
-            call_user_func(array($this, '_add_screen_options_' . $this->_current_view));
613
-        }
614
-        //add help tab(s) and tours- set via page_config and qtips.
615
-        $this->_add_help_tour();
616
-        $this->_add_help_tabs();
617
-        $this->_add_qtips();
618
-        //add feature_pointers - global, page child class, and view specific
619
-        $this->_add_feature_pointers();
620
-        $this->_add_global_feature_pointers();
621
-        if (method_exists($this, '_add_feature_pointer_' . $this->_current_view)) {
622
-            call_user_func(array($this, '_add_feature_pointer_' . $this->_current_view));
623
-        }
624
-        //enqueue scripts/styles - global, page class, and view specific
625
-        add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5);
626
-        add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10);
627
-        if (method_exists($this, 'load_scripts_styles_' . $this->_current_view)) {
628
-            add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_' . $this->_current_view), 15);
629
-        }
630
-        add_action('admin_enqueue_scripts', array($this, 'admin_footer_scripts_eei18n_js_strings'), 100);
631
-        //admin_print_footer_scripts - global, page child class, and view specific.  NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.  In most cases that's doing_it_wrong().  But adding hidden container elements etc. is a good use case. Notice the late priority we're giving these
632
-        add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_global'), 99);
633
-        add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts'), 100);
634
-        if (method_exists($this, 'admin_footer_scripts_' . $this->_current_view)) {
635
-            add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_' . $this->_current_view), 101);
636
-        }
637
-        //admin footer scripts
638
-        add_action('admin_footer', array($this, 'admin_footer_global'), 99);
639
-        add_action('admin_footer', array($this, 'admin_footer'), 100);
640
-        if (method_exists($this, 'admin_footer_' . $this->_current_view)) {
641
-            add_action('admin_footer', array($this, 'admin_footer_' . $this->_current_view), 101);
642
-        }
643
-        do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
644
-        //targeted hook
645
-        do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load__' . $this->page_slug . '__' . $this->_req_action);
646
-    }
647
-
648
-
649
-
650
-    /**
651
-     * _set_defaults
652
-     * This sets some global defaults for class properties.
653
-     */
654
-    private function _set_defaults()
655
-    {
656
-        $this->_current_screen = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = $this->_event = $this->_template_path = $this->_column_template_path = null;
657
-        $this->_nav_tabs = $this_views = $this->_page_routes = $this->_page_config = $this->_default_route_query_args = array();
658
-        $this->default_nav_tab_name = 'overview';
659
-        //init template args
660
-        $this->_template_args = array(
661
-                'admin_page_header'  => '',
662
-                'admin_page_content' => '',
663
-                'post_body_content'  => '',
664
-                'before_list_table'  => '',
665
-                'after_list_table'   => '',
666
-        );
667
-    }
668
-
669
-
670
-
671
-    /**
672
-     * route_admin_request
673
-     *
674
-     * @see    _route_admin_request()
675
-     * @access public
676
-     * @return void|exception error
677
-     */
678
-    public function route_admin_request()
679
-    {
680
-        try {
681
-            $this->_route_admin_request();
682
-        } catch (EE_Error $e) {
683
-            $e->get_error();
684
-        }
685
-    }
686
-
687
-
688
-
689
-    public function set_wp_page_slug($wp_page_slug)
690
-    {
691
-        $this->_wp_page_slug = $wp_page_slug;
692
-        //if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
693
-        if (is_network_admin()) {
694
-            $this->_wp_page_slug .= '-network';
695
-        }
696
-    }
697
-
698
-
699
-
700
-    /**
701
-     * _verify_routes
702
-     * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so we know if we need to drop out.
703
-     *
704
-     * @access protected
705
-     * @return void
706
-     */
707
-    protected function _verify_routes()
708
-    {
709
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
710
-        if ( ! $this->_current_page && ! defined('DOING_AJAX')) {
711
-            return false;
712
-        }
713
-        $this->_route = false;
714
-        $func = false;
715
-        $args = array();
716
-        // check that the page_routes array is not empty
717
-        if (empty($this->_page_routes)) {
718
-            // user error msg
719
-            $error_msg = sprintf(__('No page routes have been set for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
720
-            // developer error msg
721
-            $error_msg .= '||' . $error_msg . __(' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.', 'event_espresso');
722
-            throw new EE_Error($error_msg);
723
-        }
724
-        // and that the requested page route exists
725
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
726
-            $this->_route = $this->_page_routes[$this->_req_action];
727
-            $this->_route_config = isset($this->_page_config[$this->_req_action]) ? $this->_page_config[$this->_req_action] : array();
728
-        } else {
729
-            // user error msg
730
-            $error_msg = sprintf(__('The requested page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
731
-            // developer error msg
732
-            $error_msg .= '||' . $error_msg . sprintf(__(' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.', 'event_espresso'), $this->_req_action);
733
-            throw new EE_Error($error_msg);
734
-        }
735
-        // and that a default route exists
736
-        if ( ! array_key_exists('default', $this->_page_routes)) {
737
-            // user error msg
738
-            $error_msg = sprintf(__('A default page route has not been set for the % admin page.', 'event_espresso'), $this->_admin_page_title);
739
-            // developer error msg
740
-            $error_msg .= '||' . $error_msg . __(' Create a key in the "_page_routes" array named "default" and set its value to your default page method.', 'event_espresso');
741
-            throw new EE_Error($error_msg);
742
-        }
743
-        //first lets' catch if the UI request has EVER been set.
744
-        if ($this->_is_UI_request === null) {
745
-            //lets set if this is a UI request or not.
746
-            $this->_is_UI_request = ( ! isset($this->_req_data['noheader']) || $this->_req_data['noheader'] !== true) ? true : false;
747
-            //wait a minute... we might have a noheader in the route array
748
-            $this->_is_UI_request = is_array($this->_route) && isset($this->_route['noheader']) && $this->_route['noheader'] ? false : $this->_is_UI_request;
749
-        }
750
-        $this->_set_current_labels();
751
-    }
752
-
753
-
754
-
755
-    /**
756
-     * this method simply verifies a given route and makes sure its an actual route available for the loaded page
757
-     *
758
-     * @param  string $route the route name we're verifying
759
-     * @return mixed  (bool|Exception)      we'll throw an exception if this isn't a valid route.
760
-     */
761
-    protected function _verify_route($route)
762
-    {
763
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
764
-            return true;
765
-        } else {
766
-            // user error msg
767
-            $error_msg = sprintf(__('The given page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
768
-            // developer error msg
769
-            $error_msg .= '||' . $error_msg . sprintf(__(' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property', 'event_espresso'), $route);
770
-            throw new EE_Error($error_msg);
771
-        }
772
-    }
773
-
774
-
775
-
776
-    /**
777
-     * perform nonce verification
778
-     * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces using this method (and save retyping!)
779
-     *
780
-     * @param  string $nonce     The nonce sent
781
-     * @param  string $nonce_ref The nonce reference string (name0)
782
-     * @return mixed (bool|die)
783
-     */
784
-    protected function _verify_nonce($nonce, $nonce_ref)
785
-    {
786
-        // verify nonce against expected value
787
-        if ( ! wp_verify_nonce($nonce, $nonce_ref)) {
788
-            // these are not the droids you are looking for !!!
789
-            $msg = sprintf(__('%sNonce Fail.%s', 'event_espresso'), '<a href="http://www.youtube.com/watch?v=56_S0WeTkzs">', '</a>');
790
-            if (WP_DEBUG) {
791
-                $msg .= "\n  " . sprintf(__('In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!', 'event_espresso'), __CLASS__);
792
-            }
793
-            if ( ! defined('DOING_AJAX')) {
794
-                wp_die($msg);
795
-            } else {
796
-                EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
797
-                $this->_return_json();
798
-            }
799
-        }
800
-    }
801
-
802
-
803
-
804
-    /**
805
-     * _route_admin_request()
806
-     * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if theres are
807
-     * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
808
-     * in the page routes and then will try to load the corresponding method.
809
-     *
810
-     * @access protected
811
-     * @return void
812
-     * @throws \EE_Error
813
-     */
814
-    protected function _route_admin_request()
815
-    {
816
-        if ( ! $this->_is_UI_request) {
817
-            $this->_verify_routes();
818
-        }
819
-        $nonce_check = isset($this->_route_config['require_nonce'])
820
-            ? $this->_route_config['require_nonce']
821
-            : true;
822
-        if ($this->_req_action !== 'default' && $nonce_check) {
823
-            // set nonce from post data
824
-            $nonce = isset($this->_req_data[$this->_req_nonce])
825
-                ? sanitize_text_field($this->_req_data[$this->_req_nonce])
826
-                : '';
827
-            $this->_verify_nonce($nonce, $this->_req_nonce);
828
-        }
829
-        //set the nav_tabs array but ONLY if this is  UI_request
830
-        if ($this->_is_UI_request) {
831
-            $this->_set_nav_tabs();
832
-        }
833
-        // grab callback function
834
-        $func = is_array($this->_route) ? $this->_route['func'] : $this->_route;
835
-        // check if callback has args
836
-        $args = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : array();
837
-        $error_msg = '';
838
-        // action right before calling route
839
-        // (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
840
-        if ( ! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
841
-            do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
842
-        }
843
-        // right before calling the route, let's remove _wp_http_referer from the
844
-        // $_SERVER[REQUEST_URI] global (its now in _req_data for route processing).
845
-        $_SERVER['REQUEST_URI'] = remove_query_arg('_wp_http_referer', wp_unslash($_SERVER['REQUEST_URI']));
846
-        if ( ! empty($func)) {
847
-            if (is_array($func)) {
848
-                list($class, $method) = $func;
849
-            } else if (strpos($func, '::') !== false) {
850
-                list($class, $method) = explode('::', $func);
851
-            } else {
852
-                $class = $this;
853
-                $method = $func;
854
-            }
855
-            if ( ! (is_object($class) && $class === $this)) {
856
-                // send along this admin page object for access by addons.
857
-                $args['admin_page_object'] = $this;
858
-            }
859
-            if (
860
-                //is it a method on a class that doesn't work?
861
-                (
862
-                    method_exists($class, $method)
863
-                    && call_user_func_array(array($class, $method), $args) === false
864
-                )
865
-                || (
866
-                    //is it a standalone function that doesn't work?
867
-                    function_exists($method)
868
-                    && call_user_func_array($func, array_merge(array('admin_page_object' => $this), $args)) === false
869
-                )
870
-                || (
871
-                    //is it neither a class method NOR a standalone function?
872
-                    ! method_exists($class, $method)
873
-                    && ! function_exists($method)
874
-                )
875
-            ) {
876
-                // user error msg
877
-                $error_msg = __('An error occurred. The  requested page route could not be found.', 'event_espresso');
878
-                // developer error msg
879
-                $error_msg .= '||';
880
-                $error_msg .= sprintf(
881
-                    __(
882
-                        'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
883
-                        'event_espresso'
884
-                    ),
885
-                    $method
886
-                );
887
-            }
888
-            if ( ! empty($error_msg)) {
889
-                throw new EE_Error($error_msg);
890
-            }
891
-        }
892
-        //if we've routed and this route has a no headers route AND a sent_headers_route, then we need to reset the routing properties to the new route.
893
-        //now if UI request is FALSE and noheader is true AND we have a headers_sent_route in the route array then let's set UI_request to true because the no header route has a second func after headers have been sent.
894
-        if ($this->_is_UI_request === false
895
-            && is_array($this->_route)
896
-            && ! empty($this->_route['headers_sent_route'])
897
-        ) {
898
-            $this->_reset_routing_properties($this->_route['headers_sent_route']);
899
-        }
900
-    }
901
-
902
-
903
-
904
-    /**
905
-     * This method just allows the resetting of page properties in the case where a no headers
906
-     * route redirects to a headers route in its route config.
907
-     *
908
-     * @since   4.3.0
909
-     * @param  string $new_route New (non header) route to redirect to.
910
-     * @return   void
911
-     */
912
-    protected function _reset_routing_properties($new_route)
913
-    {
914
-        $this->_is_UI_request = true;
915
-        //now we set the current route to whatever the headers_sent_route is set at
916
-        $this->_req_data['action'] = $new_route;
917
-        //rerun page setup
918
-        $this->_page_setup();
919
-    }
920
-
921
-
922
-
923
-    /**
924
-     * _add_query_arg
925
-     * adds nonce to array of arguments then calls WP add_query_arg function
926
-     *(internally just uses EEH_URL's function with the same name)
927
-     *
928
-     * @access public
929
-     * @param array  $args
930
-     * @param string $url
931
-     * @param bool   $sticky                  if true, then the existing Request params will be appended to the generated
932
-     *                                        url in an associative array indexed by the key 'wp_referer';
933
-     *                                        Example usage:
934
-     *                                        If the current page is:
935
-     *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
936
-     *                                        &action=default&event_id=20&month_range=March%202015
937
-     *                                        &_wpnonce=5467821
938
-     *                                        and you call:
939
-     *                                        EE_Admin_Page::add_query_args_and_nonce(
940
-     *                                        array(
941
-     *                                        'action' => 'resend_something',
942
-     *                                        'page=>espresso_registrations'
943
-     *                                        ),
944
-     *                                        $some_url,
945
-     *                                        true
946
-     *                                        );
947
-     *                                        It will produce a url in this structure:
948
-     *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
949
-     *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
950
-     *                                        month_range]=March%202015
951
-     * @param   bool $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
952
-     * @return string
953
-     */
954
-    public static function add_query_args_and_nonce($args = array(), $url = false, $sticky = false, $exclude_nonce = false)
955
-    {
956
-        //if there is a _wp_http_referer include the values from the request but only if sticky = true
957
-        if ($sticky) {
958
-            $request = $_REQUEST;
959
-            unset($request['_wp_http_referer']);
960
-            unset($request['wp_referer']);
961
-            foreach ($request as $key => $value) {
962
-                //do not add nonces
963
-                if (strpos($key, 'nonce') !== false) {
964
-                    continue;
965
-                }
966
-                $args['wp_referer[' . $key . ']'] = $value;
967
-            }
968
-        }
969
-        return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
970
-    }
971
-
972
-
973
-
974
-    /**
975
-     * This returns a generated link that will load the related help tab.
976
-     *
977
-     * @param  string $help_tab_id the id for the connected help tab
978
-     * @param  string $icon_style  (optional) include css class for the style you want to use for the help icon.
979
-     * @param  string $help_text   (optional) send help text you want to use for the link if default not to be used
980
-     * @uses EEH_Template::get_help_tab_link()
981
-     * @return string              generated link
982
-     */
983
-    protected function _get_help_tab_link($help_tab_id, $icon_style = false, $help_text = false)
984
-    {
985
-        return EEH_Template::get_help_tab_link($help_tab_id, $this->page_slug, $this->_req_action, $icon_style, $help_text);
986
-    }
987
-
988
-
989
-
990
-    /**
991
-     * _add_help_tabs
992
-     * Note child classes define their help tabs within the page_config array.
993
-     *
994
-     * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
995
-     * @access protected
996
-     * @return void
997
-     */
998
-    protected function _add_help_tabs()
999
-    {
1000
-        $tour_buttons = '';
1001
-        if (isset($this->_page_config[$this->_req_action])) {
1002
-            $config = $this->_page_config[$this->_req_action];
1003
-            //is there a help tour for the current route?  if there is let's setup the tour buttons
1004
-            if (isset($this->_help_tour[$this->_req_action])) {
1005
-                $tb = array();
1006
-                $tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">';
1007
-                foreach ($this->_help_tour['tours'] as $tour) {
1008
-                    //if this is the end tour then we don't need to setup a button
1009
-                    if ($tour instanceof EE_Help_Tour_final_stop) {
1010
-                        continue;
1011
-                    }
1012
-                    $tb[] = '<button id="trigger-tour-' . $tour->get_slug() . '" class="button-primary trigger-ee-help-tour">' . $tour->get_label() . '</button>';
1013
-                }
1014
-                $tour_buttons .= implode('<br />', $tb);
1015
-                $tour_buttons .= '</div></div>';
1016
-            }
1017
-            // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1018
-            if (is_array($config) && isset($config['help_sidebar'])) {
1019
-                //check that the callback given is valid
1020
-                if ( ! method_exists($this, $config['help_sidebar'])) {
1021
-                    throw new EE_Error(sprintf(__('The _page_config array has a callback set for the "help_sidebar" option.  However the callback given (%s) is not a valid callback.  Doublecheck the spelling and make sure this method exists for the class %s',
1022
-                            'event_espresso'), $config['help_sidebar'], get_class($this)));
1023
-                }
1024
-                $content = apply_filters('FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar', call_user_func(array($this, $config['help_sidebar'])));
1025
-                $content .= $tour_buttons; //add help tour buttons.
1026
-                //do we have any help tours setup?  Cause if we do we want to add the buttons
1027
-                $this->_current_screen->set_help_sidebar($content);
1028
-            }
1029
-            //if we DON'T have config help sidebar and there ARE toure buttons then we'll just add the tour buttons to the sidebar.
1030
-            if ( ! isset($config['help_sidebar']) && ! empty($tour_buttons)) {
1031
-                $this->_current_screen->set_help_sidebar($tour_buttons);
1032
-            }
1033
-            //handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1034
-            if ( ! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1035
-                $_ht['id'] = $this->page_slug;
1036
-                $_ht['title'] = __('Help Tours', 'event_espresso');
1037
-                $_ht['content'] = '<p>' . __('The buttons to the right allow you to start/restart any help tours available for this page', 'event_espresso') . '</p>';
1038
-                $this->_current_screen->add_help_tab($_ht);
1039
-            }/**/
1040
-            if ( ! isset($config['help_tabs'])) {
1041
-                return;
1042
-            } //no help tabs for this route
1043
-            foreach ((array)$config['help_tabs'] as $tab_id => $cfg) {
1044
-                //we're here so there ARE help tabs!
1045
-                //make sure we've got what we need
1046
-                if ( ! isset($cfg['title'])) {
1047
-                    throw new EE_Error(__('The _page_config array is not set up properly for help tabs.  It is missing a title', 'event_espresso'));
1048
-                }
1049
-                if ( ! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1050
-                    throw new EE_Error(__('The _page_config array is not setup properly for help tabs. It is missing a either a filename reference, or a callback reference or a content reference so there is no way to know the content for the help tab',
1051
-                            'event_espresso'));
1052
-                }
1053
-                //first priority goes to content.
1054
-                if ( ! empty($cfg['content'])) {
1055
-                    $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1056
-                    //second priority goes to filename
1057
-                } else if ( ! empty($cfg['filename'])) {
1058
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1059
-                    //it's possible that the file is located on decaf route (and above sets up for caf route, if this is the case then lets check decaf route too)
1060
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tabs/' . $cfg['filename'] . '.help_tab.php' : $file_path;
1061
-                    //if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1062
-                    if ( ! is_readable($file_path) && ! isset($cfg['callback'])) {
1063
-                        EE_Error::add_error(sprintf(__('The filename given for the help tab %s is not a valid file and there is no other configuration for the tab content.  Please check that the string you set for the help tab on this route (%s) is the correct spelling.  The file should be in %s',
1064
-                                'event_espresso'), $tab_id, key($config), $file_path), __FILE__, __FUNCTION__, __LINE__);
1065
-                        return;
1066
-                    }
1067
-                    $template_args['admin_page_obj'] = $this;
1068
-                    $content = EEH_Template::display_template($file_path, $template_args, true);
1069
-                } else {
1070
-                    $content = '';
1071
-                }
1072
-                //check if callback is valid
1073
-                if (empty($content) && ( ! isset($cfg['callback']) || ! method_exists($this, $cfg['callback']))) {
1074
-                    EE_Error::add_error(sprintf(__('The callback given for a %s help tab on this page does not content OR a corresponding method for generating the content.  Check the spelling or make sure the method is present.',
1075
-                            'event_espresso'), $cfg['title']), __FILE__, __FUNCTION__, __LINE__);
1076
-                    return;
1077
-                }
1078
-                //setup config array for help tab method
1079
-                $id = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1080
-                $_ht = array(
1081
-                        'id'       => $id,
1082
-                        'title'    => $cfg['title'],
1083
-                        'callback' => isset($cfg['callback']) && empty($content) ? array($this, $cfg['callback']) : null,
1084
-                        'content'  => $content,
1085
-                );
1086
-                $this->_current_screen->add_help_tab($_ht);
1087
-            }
1088
-        }
1089
-    }
1090
-
1091
-
1092
-
1093
-    /**
1094
-     * This basically checks loaded $_page_config property to see if there are any help_tours defined.  "help_tours" is an array with properties for setting up usage of the joyride plugin
1095
-     *
1096
-     * @link   http://zurb.com/playground/jquery-joyride-feature-tour-plugin
1097
-     * @see    instructions regarding the format and construction of the "help_tour" array element is found in the _set_page_config() comments
1098
-     * @access protected
1099
-     * @return void
1100
-     */
1101
-    protected function _add_help_tour()
1102
-    {
1103
-        $tours = array();
1104
-        $this->_help_tour = array();
1105
-        //exit early if help tours are turned off globally
1106
-        if ( ! EE_Registry::instance()->CFG->admin->help_tour_activation || (defined('EE_DISABLE_HELP_TOURS') && EE_DISABLE_HELP_TOURS)) {
1107
-            return;
1108
-        }
1109
-        //loop through _page_config to find any help_tour defined
1110
-        foreach ($this->_page_config as $route => $config) {
1111
-            //we're only going to set things up for this route
1112
-            if ($route !== $this->_req_action) {
1113
-                continue;
1114
-            }
1115
-            if (isset($config['help_tour'])) {
1116
-                foreach ($config['help_tour'] as $tour) {
1117
-                    $file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1118
-                    //let's see if we can get that file... if not its possible this is a decaf route not set in caffienated so lets try and get the caffeinated equivalent
1119
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tours/' . $tour . '.class.php' : $file_path;
1120
-                    //if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1121
-                    if ( ! is_readable($file_path)) {
1122
-                        EE_Error::add_error(sprintf(__('The file path given for the help tour (%s) is not a valid path.  Please check that the string you set for the help tour on this route (%s) is the correct spelling', 'event_espresso'),
1123
-                                $file_path, $tour), __FILE__, __FUNCTION__, __LINE__);
1124
-                        return;
1125
-                    }
1126
-                    require_once $file_path;
1127
-                    if ( ! class_exists($tour)) {
1128
-                        $error_msg[] = sprintf(__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'), $tour);
1129
-                        $error_msg[] = $error_msg[0] . "\r\n" . sprintf(__('There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.',
1130
-                                        'event_espresso'), $tour, '<br />', $tour, $this->_req_action, get_class($this));
1131
-                        throw new EE_Error(implode('||', $error_msg));
1132
-                    }
1133
-                    $a = new ReflectionClass($tour);
1134
-                    $tour_obj = $a->newInstance($this->_is_caf);
1135
-                    $tours[] = $tour_obj;
1136
-                    $this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($tour_obj);
1137
-                }
1138
-                //let's inject the end tour stop element common to all pages... this will only get seen once per machine.
1139
-                $end_stop_tour = new EE_Help_Tour_final_stop($this->_is_caf);
1140
-                $tours[] = $end_stop_tour;
1141
-                $this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($end_stop_tour);
1142
-            }
1143
-        }
1144
-        if ( ! empty($tours)) {
1145
-            $this->_help_tour['tours'] = $tours;
1146
-        }
1147
-        //thats it!  Now that the $_help_tours property is set (or not) the scripts and html should be taken care of automatically.
1148
-    }
1149
-
1150
-
1151
-
1152
-    /**
1153
-     * This simply sets up any qtips that have been defined in the page config
1154
-     *
1155
-     * @access protected
1156
-     * @return void
1157
-     */
1158
-    protected function _add_qtips()
1159
-    {
1160
-        if (isset($this->_route_config['qtips'])) {
1161
-            $qtips = (array)$this->_route_config['qtips'];
1162
-            //load qtip loader
1163
-            $path = array(
1164
-                    $this->_get_dir() . '/qtips/',
1165
-                    EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1166
-            );
1167
-            EEH_Qtip_Loader::instance()->register($qtips, $path);
1168
-        }
1169
-    }
1170
-
1171
-
1172
-
1173
-    /**
1174
-     * _set_nav_tabs
1175
-     * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you wish to add additional tabs or modify accordingly.
1176
-     *
1177
-     * @access protected
1178
-     * @return void
1179
-     */
1180
-    protected function _set_nav_tabs()
1181
-    {
1182
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1183
-        $i = 0;
1184
-        foreach ($this->_page_config as $slug => $config) {
1185
-            if ( ! is_array($config) || (is_array($config) && (isset($config['nav']) && ! $config['nav']) || ! isset($config['nav']))) {
1186
-                continue;
1187
-            } //no nav tab for this config
1188
-            //check for persistent flag
1189
-            if (isset($config['nav']['persistent']) && ! $config['nav']['persistent'] && $slug !== $this->_req_action) {
1190
-                continue;
1191
-            } //nav tab is only to appear when route requested.
1192
-            if ( ! $this->check_user_access($slug, true)) {
1193
-                continue;
1194
-            } //no nav tab becasue current user does not have access.
1195
-            $css_class = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1196
-            $this->_nav_tabs[$slug] = array(
1197
-                    'url'       => isset($config['nav']['url']) ? $config['nav']['url'] : self::add_query_args_and_nonce(array('action' => $slug), $this->_admin_base_url),
1198
-                    'link_text' => isset($config['nav']['label']) ? $config['nav']['label'] : ucwords(str_replace('_', ' ', $slug)),
1199
-                    'css_class' => $this->_req_action == $slug ? $css_class . 'nav-tab-active' : $css_class,
1200
-                    'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1201
-            );
1202
-            $i++;
1203
-        }
1204
-        //if $this->_nav_tabs is empty then lets set the default
1205
-        if (empty($this->_nav_tabs)) {
1206
-            $this->_nav_tabs[$this->default_nav_tab_name] = array(
1207
-                    'url'       => $this->admin_base_url,
1208
-                    'link_text' => ucwords(str_replace('_', ' ', $this->default_nav_tab_name)),
1209
-                    'css_class' => 'nav-tab-active',
1210
-                    'order'     => 10,
1211
-            );
1212
-        }
1213
-        //now let's sort the tabs according to order
1214
-        usort($this->_nav_tabs, array($this, '_sort_nav_tabs'));
1215
-    }
1216
-
1217
-
1218
-
1219
-    /**
1220
-     * _set_current_labels
1221
-     * This method modifies the _labels property with any optional specific labels indicated in the _page_routes property array
1222
-     *
1223
-     * @access private
1224
-     * @return void
1225
-     */
1226
-    private function _set_current_labels()
1227
-    {
1228
-        if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1229
-            foreach ($this->_route_config['labels'] as $label => $text) {
1230
-                if (is_array($text)) {
1231
-                    foreach ($text as $sublabel => $subtext) {
1232
-                        $this->_labels[$label][$sublabel] = $subtext;
1233
-                    }
1234
-                } else {
1235
-                    $this->_labels[$label] = $text;
1236
-                }
1237
-            }
1238
-        }
1239
-    }
1240
-
1241
-
1242
-
1243
-    /**
1244
-     *        verifies user access for this admin page
1245
-     *
1246
-     * @param string $route_to_check if present then the capability for the route matching this string is checked.
1247
-     * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just return false if verify fail.
1248
-     * @return        BOOL|wp_die()
1249
-     */
1250
-    public function check_user_access($route_to_check = '', $verify_only = false)
1251
-    {
1252
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1253
-        $route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1254
-        $capability = ! empty($route_to_check) && isset($this->_page_routes[$route_to_check]) && is_array($this->_page_routes[$route_to_check]) && ! empty($this->_page_routes[$route_to_check]['capability'])
1255
-                ? $this->_page_routes[$route_to_check]['capability'] : null;
1256
-        if (empty($capability) && empty($route_to_check)) {
1257
-            $capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options' : $this->_route['capability'];
1258
-        } else {
1259
-            $capability = empty($capability) ? 'manage_options' : $capability;
1260
-        }
1261
-        $id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1262
-        if (( ! function_exists('is_admin') || ! EE_Registry::instance()->CAP->current_user_can($capability, $this->page_slug . '_' . $route_to_check, $id)) && ! defined('DOING_AJAX')) {
1263
-            if ($verify_only) {
1264
-                return false;
1265
-            } else {
1266
-                if ( is_user_logged_in() ) {
1267
-                    wp_die(__('You do not have access to this route.', 'event_espresso'));
1268
-                } else {
1269
-                    return false;
1270
-                }
1271
-            }
1272
-        }
1273
-        return true;
1274
-    }
1275
-
1276
-
1277
-
1278
-    /**
1279
-     * admin_init_global
1280
-     * This runs all the code that we want executed within the WP admin_init hook.
1281
-     * This method executes for ALL EE Admin pages.
1282
-     *
1283
-     * @access public
1284
-     * @return void
1285
-     */
1286
-    public function admin_init_global()
1287
-    {
1288
-    }
1289
-
1290
-
1291
-
1292
-    /**
1293
-     * wp_loaded_global
1294
-     * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an EE_Admin page and will execute on every EE Admin Page load
1295
-     *
1296
-     * @access public
1297
-     * @return void
1298
-     */
1299
-    public function wp_loaded()
1300
-    {
1301
-    }
1302
-
1303
-
1304
-
1305
-    /**
1306
-     * admin_notices
1307
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on ALL EE_Admin pages.
1308
-     *
1309
-     * @access public
1310
-     * @return void
1311
-     */
1312
-    public function admin_notices_global()
1313
-    {
1314
-        $this->_display_no_javascript_warning();
1315
-        $this->_display_espresso_notices();
1316
-    }
1317
-
1318
-
1319
-
1320
-    public function network_admin_notices_global()
1321
-    {
1322
-        $this->_display_no_javascript_warning();
1323
-        $this->_display_espresso_notices();
1324
-    }
1325
-
1326
-
1327
-
1328
-    /**
1329
-     * admin_footer_scripts_global
1330
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method will apply on ALL EE_Admin pages.
1331
-     *
1332
-     * @access public
1333
-     * @return void
1334
-     */
1335
-    public function admin_footer_scripts_global()
1336
-    {
1337
-        $this->_add_admin_page_ajax_loading_img();
1338
-        $this->_add_admin_page_overlay();
1339
-        //if metaboxes are present we need to add the nonce field
1340
-        if ((isset($this->_route_config['metaboxes']) || (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes']) || isset($this->_route_config['list_table']))) {
1341
-            wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1342
-            wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1343
-        }
1344
-    }
1345
-
1346
-
1347
-
1348
-    /**
1349
-     * admin_footer_global
1350
-     * Anything triggered by the wp 'admin_footer' wp hook should be put in here. This particluar method will apply on ALL EE_Admin Pages.
1351
-     *
1352
-     * @access  public
1353
-     * @return  void
1354
-     */
1355
-    public function admin_footer_global()
1356
-    {
1357
-        //dialog container for dialog helper
1358
-        $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n";
1359
-        $d_cont .= '<div class="ee-notices"></div>';
1360
-        $d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>';
1361
-        $d_cont .= '</div>';
1362
-        echo $d_cont;
1363
-        //help tour stuff?
1364
-        if (isset($this->_help_tour[$this->_req_action])) {
1365
-            echo implode('<br />', $this->_help_tour[$this->_req_action]);
1366
-        }
1367
-        //current set timezone for timezone js
1368
-        echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>';
1369
-    }
1370
-
1371
-
1372
-
1373
-    /**
1374
-     * This function sees if there is a method for help popup content existing for the given route.  If there is then we'll use the retrieved array to output the content using the template.
1375
-     * For child classes:
1376
-     * If you want to have help popups then in your templates or your content you set "triggers" for the content using the "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method for
1377
-     * the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content for the
1378
-     * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1379
-     *    'help_trigger_id' => array(
1380
-     *        'title' => __('localized title for popup', 'event_espresso'),
1381
-     *        'content' => __('localized content for popup', 'event_espresso')
1382
-     *    )
1383
-     * );
1384
-     * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1385
-     *
1386
-     * @access protected
1387
-     * @return string content
1388
-     */
1389
-    protected function _set_help_popup_content($help_array = array(), $display = false)
1390
-    {
1391
-        $content = '';
1392
-        $help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1393
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php';
1394
-        //loop through the array and setup content
1395
-        foreach ($help_array as $trigger => $help) {
1396
-            //make sure the array is setup properly
1397
-            if ( ! isset($help['title']) || ! isset($help['content'])) {
1398
-                throw new EE_Error(__('Does not look like the popup content array has been setup correctly.  Might want to double check that.  Read the comments for the _get_help_popup_content method found in "EE_Admin_Page" class',
1399
-                        'event_espresso'));
1400
-            }
1401
-            //we're good so let'd setup the template vars and then assign parsed template content to our content.
1402
-            $template_args = array(
1403
-                    'help_popup_id'      => $trigger,
1404
-                    'help_popup_title'   => $help['title'],
1405
-                    'help_popup_content' => $help['content'],
1406
-            );
1407
-            $content .= EEH_Template::display_template($template_path, $template_args, true);
1408
-        }
1409
-        if ($display) {
1410
-            echo $content;
1411
-        } else {
1412
-            return $content;
1413
-        }
1414
-    }
1415
-
1416
-
1417
-
1418
-    /**
1419
-     * All this does is retrive the help content array if set by the EE_Admin_Page child
1420
-     *
1421
-     * @access private
1422
-     * @return array properly formatted array for help popup content
1423
-     */
1424
-    private function _get_help_content()
1425
-    {
1426
-        //what is the method we're looking for?
1427
-        $method_name = '_help_popup_content_' . $this->_req_action;
1428
-        //if method doesn't exist let's get out.
1429
-        if ( ! method_exists($this, $method_name)) {
1430
-            return array();
1431
-        }
1432
-        //k we're good to go let's retrieve the help array
1433
-        $help_array = call_user_func(array($this, $method_name));
1434
-        //make sure we've got an array!
1435
-        if ( ! is_array($help_array)) {
1436
-            throw new EE_Error(__('Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.', 'event_espresso'));
1437
-        }
1438
-        return $help_array;
1439
-    }
1440
-
1441
-
1442
-
1443
-    /**
1444
-     * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1445
-     * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1446
-     * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1447
-     *
1448
-     * @access protected
1449
-     * @param string  $trigger_id reference for retrieving the trigger content for the popup
1450
-     * @param boolean $display    if false then we return the trigger string
1451
-     * @param array   $dimensions an array of dimensions for the box (array(h,w))
1452
-     * @return string
1453
-     */
1454
-    protected function _set_help_trigger($trigger_id, $display = true, $dimensions = array('400', '640'))
1455
-    {
1456
-        if (defined('DOING_AJAX')) {
1457
-            return;
1458
-        }
1459
-        //let's check and see if there is any content set for this popup.  If there isn't then we'll include a default title and content so that developers know something needs to be corrected
1460
-        $help_array = $this->_get_help_content();
1461
-        $help_content = '';
1462
-        if (empty($help_array) || ! isset($help_array[$trigger_id])) {
1463
-            $help_array[$trigger_id] = array(
1464
-                    'title'   => __('Missing Content', 'event_espresso'),
1465
-                    'content' => __('A trigger has been set that doesn\'t have any corresponding content. Make sure you have set the help content. (see the "_set_help_popup_content" method in the EE_Admin_Page for instructions.)',
1466
-                            'event_espresso'),
1467
-            );
1468
-            $help_content = $this->_set_help_popup_content($help_array, false);
1469
-        }
1470
-        //let's setup the trigger
1471
-        $content = '<a class="ee-dialog" href="?height=' . $dimensions[0] . '&width=' . $dimensions[1] . '&inlineId=' . $trigger_id . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1472
-        $content = $content . $help_content;
1473
-        if ($display) {
1474
-            echo $content;
1475
-        } else {
1476
-            return $content;
1477
-        }
1478
-    }
1479
-
1480
-
1481
-
1482
-    /**
1483
-     * _add_global_screen_options
1484
-     * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1485
-     * This particular method will add_screen_options on ALL EE_Admin Pages
1486
-     *
1487
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1488
-     *         see also WP_Screen object documents...
1489
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1490
-     * @abstract
1491
-     * @access private
1492
-     * @return void
1493
-     */
1494
-    private function _add_global_screen_options()
1495
-    {
1496
-    }
1497
-
1498
-
1499
-
1500
-    /**
1501
-     * _add_global_feature_pointers
1502
-     * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1503
-     * This particular method will implement feature pointers for ALL EE_Admin pages.
1504
-     * Note: this is just a placeholder for now.  Implementation will come down the road
1505
-     *
1506
-     * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be extended) also see:
1507
-     * @link   http://eamann.com/tech/wordpress-portland/
1508
-     * @abstract
1509
-     * @access protected
1510
-     * @return void
1511
-     */
1512
-    private function _add_global_feature_pointers()
1513
-    {
1514
-    }
1515
-
1516
-
1517
-
1518
-    /**
1519
-     * load_global_scripts_styles
1520
-     * The scripts and styles enqueued in here will be loaded on every EE Admin page
1521
-     *
1522
-     * @return void
1523
-     */
1524
-    public function load_global_scripts_styles()
1525
-    {
1526
-        /** STYLES **/
1527
-        // add debugging styles
1528
-        if (WP_DEBUG) {
1529
-            add_action('admin_head', array($this, 'add_xdebug_style'));
1530
-        }
1531
-        //register all styles
1532
-        wp_register_style('espresso-ui-theme', EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION);
1533
-        wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
1534
-        //helpers styles
1535
-        wp_register_style('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css', array(), EVENT_ESPRESSO_VERSION);
1536
-        //enqueue global styles
1537
-        wp_enqueue_style('ee-admin-css');
1538
-        /** SCRIPTS **/
1539
-        //register all scripts
1540
-        wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1541
-        wp_register_script('ee-dialog', EE_ADMIN_URL . 'assets/ee-dialog-helper.js', array('jquery', 'jquery-ui-draggable'), EVENT_ESPRESSO_VERSION, true);
1542
-        wp_register_script('ee_admin_js', EE_ADMIN_URL . 'assets/ee-admin-page.js', array('espresso_core', 'ee-parse-uri', 'ee-dialog'), EVENT_ESPRESSO_VERSION, true);
1543
-        wp_register_script('jquery-ui-timepicker-addon', EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), EVENT_ESPRESSO_VERSION, true);
1544
-        // register jQuery Validate - see /includes/functions/wp_hooks.php
1545
-        add_filter('FHEE_load_jquery_validate', '__return_true');
1546
-        add_filter('FHEE_load_joyride', '__return_true');
1547
-        //script for sorting tables
1548
-        wp_register_script('espresso_ajax_table_sorting', EE_ADMIN_URL . "assets/espresso_ajax_table_sorting.js", array('ee_admin_js', 'jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true);
1549
-        //script for parsing uri's
1550
-        wp_register_script('ee-parse-uri', EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js', array(), EVENT_ESPRESSO_VERSION, true);
1551
-        //and parsing associative serialized form elements
1552
-        wp_register_script('ee-serialize-full-array', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1553
-        //helpers scripts
1554
-        wp_register_script('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1555
-        wp_register_script('ee-moment-core', EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js', array(), EVENT_ESPRESSO_VERSION, true);
1556
-        wp_register_script('ee-moment', EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js', array('ee-moment-core'), EVENT_ESPRESSO_VERSION, true);
1557
-        wp_register_script('ee-datepicker', EE_ADMIN_URL . 'assets/ee-datepicker.js', array('jquery-ui-timepicker-addon', 'ee-moment'), EVENT_ESPRESSO_VERSION, true);
1558
-        //google charts
1559
-        wp_register_script('google-charts', 'https://www.gstatic.com/charts/loader.js', array(), EVENT_ESPRESSO_VERSION, false);
1560
-        //enqueue global scripts
1561
-        //taking care of metaboxes
1562
-        if ((isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes'])) && empty($this->_cpt_route)) {
1563
-            wp_enqueue_script('dashboard');
1564
-        }
1565
-        //enqueue thickbox for ee help popups.  default is to enqueue unless its explicitly set to false since we're assuming all EE pages will have popups
1566
-        if ( ! isset($this->_route_config['has_help_popups']) || (isset($this->_route_config['has_help_popups']) && $this->_route_config['has_help_popups'])) {
1567
-            wp_enqueue_script('ee_admin_js');
1568
-            wp_enqueue_style('ee-admin-css');
1569
-        }
1570
-        //localize script for ajax lazy loading
1571
-        $lazy_loader_container_ids = apply_filters('FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers', array('espresso_news_post_box_content'));
1572
-        wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
1573
-        /**
1574
-         * help tour stuff
1575
-         */
1576
-        if ( ! empty($this->_help_tour)) {
1577
-            //register the js for kicking things off
1578
-            wp_enqueue_script('ee-help-tour', EE_ADMIN_URL . 'assets/ee-help-tour.js', array('jquery-joyride'), EVENT_ESPRESSO_VERSION, true);
1579
-            //setup tours for the js tour object
1580
-            foreach ($this->_help_tour['tours'] as $tour) {
1581
-                $tours[] = array(
1582
-                        'id'      => $tour->get_slug(),
1583
-                        'options' => $tour->get_options(),
1584
-                );
1585
-            }
1586
-            wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours));
1587
-            //admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour
1588
-        }
1589
-    }
1590
-
1591
-
1592
-
1593
-    /**
1594
-     *        admin_footer_scripts_eei18n_js_strings
1595
-     *
1596
-     * @access        public
1597
-     * @return        void
1598
-     */
1599
-    public function admin_footer_scripts_eei18n_js_strings()
1600
-    {
1601
-        EE_Registry::$i18n_js_strings['ajax_url'] = WP_AJAX_URL;
1602
-        EE_Registry::$i18n_js_strings['confirm_delete'] = __('Are you absolutely sure you want to delete this item?\nThis action will delete ALL DATA associated with this item!!!\nThis can NOT be undone!!!', 'event_espresso');
1603
-        EE_Registry::$i18n_js_strings['January'] = __('January', 'event_espresso');
1604
-        EE_Registry::$i18n_js_strings['February'] = __('February', 'event_espresso');
1605
-        EE_Registry::$i18n_js_strings['March'] = __('March', 'event_espresso');
1606
-        EE_Registry::$i18n_js_strings['April'] = __('April', 'event_espresso');
1607
-        EE_Registry::$i18n_js_strings['May'] = __('May', 'event_espresso');
1608
-        EE_Registry::$i18n_js_strings['June'] = __('June', 'event_espresso');
1609
-        EE_Registry::$i18n_js_strings['July'] = __('July', 'event_espresso');
1610
-        EE_Registry::$i18n_js_strings['August'] = __('August', 'event_espresso');
1611
-        EE_Registry::$i18n_js_strings['September'] = __('September', 'event_espresso');
1612
-        EE_Registry::$i18n_js_strings['October'] = __('October', 'event_espresso');
1613
-        EE_Registry::$i18n_js_strings['November'] = __('November', 'event_espresso');
1614
-        EE_Registry::$i18n_js_strings['December'] = __('December', 'event_espresso');
1615
-        EE_Registry::$i18n_js_strings['Jan'] = __('Jan', 'event_espresso');
1616
-        EE_Registry::$i18n_js_strings['Feb'] = __('Feb', 'event_espresso');
1617
-        EE_Registry::$i18n_js_strings['Mar'] = __('Mar', 'event_espresso');
1618
-        EE_Registry::$i18n_js_strings['Apr'] = __('Apr', 'event_espresso');
1619
-        EE_Registry::$i18n_js_strings['May'] = __('May', 'event_espresso');
1620
-        EE_Registry::$i18n_js_strings['Jun'] = __('Jun', 'event_espresso');
1621
-        EE_Registry::$i18n_js_strings['Jul'] = __('Jul', 'event_espresso');
1622
-        EE_Registry::$i18n_js_strings['Aug'] = __('Aug', 'event_espresso');
1623
-        EE_Registry::$i18n_js_strings['Sep'] = __('Sep', 'event_espresso');
1624
-        EE_Registry::$i18n_js_strings['Oct'] = __('Oct', 'event_espresso');
1625
-        EE_Registry::$i18n_js_strings['Nov'] = __('Nov', 'event_espresso');
1626
-        EE_Registry::$i18n_js_strings['Dec'] = __('Dec', 'event_espresso');
1627
-        EE_Registry::$i18n_js_strings['Sunday'] = __('Sunday', 'event_espresso');
1628
-        EE_Registry::$i18n_js_strings['Monday'] = __('Monday', 'event_espresso');
1629
-        EE_Registry::$i18n_js_strings['Tuesday'] = __('Tuesday', 'event_espresso');
1630
-        EE_Registry::$i18n_js_strings['Wednesday'] = __('Wednesday', 'event_espresso');
1631
-        EE_Registry::$i18n_js_strings['Thursday'] = __('Thursday', 'event_espresso');
1632
-        EE_Registry::$i18n_js_strings['Friday'] = __('Friday', 'event_espresso');
1633
-        EE_Registry::$i18n_js_strings['Saturday'] = __('Saturday', 'event_espresso');
1634
-        EE_Registry::$i18n_js_strings['Sun'] = __('Sun', 'event_espresso');
1635
-        EE_Registry::$i18n_js_strings['Mon'] = __('Mon', 'event_espresso');
1636
-        EE_Registry::$i18n_js_strings['Tue'] = __('Tue', 'event_espresso');
1637
-        EE_Registry::$i18n_js_strings['Wed'] = __('Wed', 'event_espresso');
1638
-        EE_Registry::$i18n_js_strings['Thu'] = __('Thu', 'event_espresso');
1639
-        EE_Registry::$i18n_js_strings['Fri'] = __('Fri', 'event_espresso');
1640
-        EE_Registry::$i18n_js_strings['Sat'] = __('Sat', 'event_espresso');
1641
-        //setting on espresso_core instead of ee_admin_js because espresso_core is enqueued by the maintenance
1642
-        //admin page when in maintenance mode and ee_admin_js is not loaded then.  This works everywhere else because
1643
-        //espresso_core is listed as a dependency of ee_admin_js.
1644
-        wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings);
1645
-    }
1646
-
1647
-
1648
-
1649
-    /**
1650
-     *        load enhanced xdebug styles for ppl with failing eyesight
1651
-     *
1652
-     * @access        public
1653
-     * @return        void
1654
-     */
1655
-    public function add_xdebug_style()
1656
-    {
1657
-        echo '<style>.xdebug-error { font-size:1.5em; }</style>';
1658
-    }
1659
-
1660
-
1661
-    /************************/
1662
-    /** LIST TABLE METHODS **/
1663
-    /************************/
1664
-    /**
1665
-     * this sets up the list table if the current view requires it.
1666
-     *
1667
-     * @access protected
1668
-     * @return void
1669
-     */
1670
-    protected function _set_list_table()
1671
-    {
1672
-        //first is this a list_table view?
1673
-        if ( ! isset($this->_route_config['list_table'])) {
1674
-            return;
1675
-        } //not a list_table view so get out.
1676
-        //list table functions are per view specific (because some admin pages might have more than one listtable!)
1677
-        if (call_user_func(array($this, '_set_list_table_views_' . $this->_req_action)) === false) {
1678
-            //user error msg
1679
-            $error_msg = __('An error occurred. The requested list table views could not be found.', 'event_espresso');
1680
-            //developer error msg
1681
-            $error_msg .= '||' . sprintf(__('List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.', 'event_espresso'),
1682
-                            $this->_req_action, '_set_list_table_views_' . $this->_req_action);
1683
-            throw new EE_Error($error_msg);
1684
-        }
1685
-        //let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
1686
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action, $this->_views);
1687
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
1688
-        $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
1689
-        $this->_set_list_table_view();
1690
-        $this->_set_list_table_object();
1691
-    }
1692
-
1693
-
1694
-
1695
-    /**
1696
-     *        set current view for List Table
1697
-     *
1698
-     * @access public
1699
-     * @return array
1700
-     */
1701
-    protected function _set_list_table_view()
1702
-    {
1703
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1704
-        // looking at active items or dumpster diving ?
1705
-        if ( ! isset($this->_req_data['status']) || ! array_key_exists($this->_req_data['status'], $this->_views)) {
1706
-            $this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
1707
-        } else {
1708
-            $this->_view = sanitize_key($this->_req_data['status']);
1709
-        }
1710
-    }
1711
-
1712
-
1713
-
1714
-    /**
1715
-     * _set_list_table_object
1716
-     * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
1717
-     *
1718
-     * @throws \EE_Error
1719
-     */
1720
-    protected function _set_list_table_object()
1721
-    {
1722
-        if (isset($this->_route_config['list_table'])) {
1723
-            if ( ! class_exists($this->_route_config['list_table'])) {
1724
-                throw new EE_Error(
1725
-                        sprintf(
1726
-                                __(
1727
-                                        'The %s class defined for the list table does not exist.  Please check the spelling of the class ref in the $_page_config property on %s.',
1728
-                                        'event_espresso'
1729
-                                ),
1730
-                                $this->_route_config['list_table'],
1731
-                                get_class($this)
1732
-                        )
1733
-                );
1734
-            }
1735
-            $list_table = $this->_route_config['list_table'];
1736
-            $this->_list_table_object = new $list_table($this);
1737
-        }
1738
-    }
1739
-
1740
-
1741
-
1742
-    /**
1743
-     * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
1744
-     *
1745
-     * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
1746
-     *                                                    urls.  The array should be indexed by the view it is being
1747
-     *                                                    added to.
1748
-     * @return array
1749
-     */
1750
-    public function get_list_table_view_RLs($extra_query_args = array())
1751
-    {
1752
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1753
-        if (empty($this->_views)) {
1754
-            $this->_views = array();
1755
-        }
1756
-        // cycle thru views
1757
-        foreach ($this->_views as $key => $view) {
1758
-            $query_args = array();
1759
-            // check for current view
1760
-            $this->_views[$key]['class'] = $this->_view == $view['slug'] ? 'current' : '';
1761
-            $query_args['action'] = $this->_req_action;
1762
-            $query_args[$this->_req_action . '_nonce'] = wp_create_nonce($query_args['action'] . '_nonce');
1763
-            $query_args['status'] = $view['slug'];
1764
-            //merge any other arguments sent in.
1765
-            if (isset($extra_query_args[$view['slug']])) {
1766
-                $query_args = array_merge($query_args, $extra_query_args[$view['slug']]);
1767
-            }
1768
-            $this->_views[$key]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
1769
-        }
1770
-        return $this->_views;
1771
-    }
1772
-
1773
-
1774
-
1775
-    /**
1776
-     * _entries_per_page_dropdown
1777
-     * generates a drop down box for selecting the number of visiable rows in an admin page list table
1778
-     *
1779
-     * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how WP does it.
1780
-     * @access protected
1781
-     * @param int $max_entries total number of rows in the table
1782
-     * @return string
1783
-     */
1784
-    protected function _entries_per_page_dropdown($max_entries = false)
1785
-    {
1786
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1787
-        $values = array(10, 25, 50, 100);
1788
-        $per_page = ( ! empty($this->_req_data['per_page'])) ? absint($this->_req_data['per_page']) : 10;
1789
-        if ($max_entries) {
1790
-            $values[] = $max_entries;
1791
-            sort($values);
1792
-        }
1793
-        $entries_per_page_dropdown = '
143
+	// yes / no array for admin form fields
144
+	protected $_yes_no_values = array();
145
+
146
+	//some default things shared by all child classes
147
+	protected $_default_espresso_metaboxes;
148
+
149
+	/**
150
+	 *    EE_Registry Object
151
+	 *
152
+	 * @var    EE_Registry
153
+	 * @access    protected
154
+	 */
155
+	protected $EE = null;
156
+
157
+
158
+
159
+	/**
160
+	 * This is just a property that flags whether the given route is a caffeinated route or not.
161
+	 *
162
+	 * @var boolean
163
+	 */
164
+	protected $_is_caf = false;
165
+
166
+
167
+
168
+	/**
169
+	 * @Constructor
170
+	 * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
171
+	 * @access public
172
+	 */
173
+	public function __construct($routing = true)
174
+	{
175
+		if (strpos($this->_get_dir(), 'caffeinated') !== false) {
176
+			$this->_is_caf = true;
177
+		}
178
+		$this->_yes_no_values = array(
179
+				array('id' => true, 'text' => __('Yes', 'event_espresso')),
180
+				array('id' => false, 'text' => __('No', 'event_espresso')),
181
+		);
182
+		//set the _req_data property.
183
+		$this->_req_data = array_merge($_GET, $_POST);
184
+		//routing enabled?
185
+		$this->_routing = $routing;
186
+		//set initial page props (child method)
187
+		$this->_init_page_props();
188
+		//set global defaults
189
+		$this->_set_defaults();
190
+		//set early because incoming requests could be ajax related and we need to register those hooks.
191
+		$this->_global_ajax_hooks();
192
+		$this->_ajax_hooks();
193
+		//other_page_hooks have to be early too.
194
+		$this->_do_other_page_hooks();
195
+		//This just allows us to have extending clases do something specific before the parent constructor runs _page_setup.
196
+		if (method_exists($this, '_before_page_setup')) {
197
+			$this->_before_page_setup();
198
+		}
199
+		//set up page dependencies
200
+		$this->_page_setup();
201
+	}
202
+
203
+
204
+
205
+	/**
206
+	 * _init_page_props
207
+	 * Child classes use to set at least the following properties:
208
+	 * $page_slug.
209
+	 * $page_label.
210
+	 *
211
+	 * @abstract
212
+	 * @access protected
213
+	 * @return void
214
+	 */
215
+	abstract protected function _init_page_props();
216
+
217
+
218
+
219
+	/**
220
+	 * _ajax_hooks
221
+	 * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
222
+	 * Note: within the ajax callback methods.
223
+	 *
224
+	 * @abstract
225
+	 * @access protected
226
+	 * @return void
227
+	 */
228
+	abstract protected function _ajax_hooks();
229
+
230
+
231
+
232
+	/**
233
+	 * _define_page_props
234
+	 * child classes define page properties in here.  Must include at least:
235
+	 * $_admin_base_url = base_url for all admin pages
236
+	 * $_admin_page_title = default admin_page_title for admin pages
237
+	 * $_labels = array of default labels for various automatically generated elements:
238
+	 *    array(
239
+	 *        'buttons' => array(
240
+	 *            'add' => __('label for add new button'),
241
+	 *            'edit' => __('label for edit button'),
242
+	 *            'delete' => __('label for delete button')
243
+	 *            )
244
+	 *        )
245
+	 *
246
+	 * @abstract
247
+	 * @access protected
248
+	 * @return void
249
+	 */
250
+	abstract protected function _define_page_props();
251
+
252
+
253
+
254
+	/**
255
+	 * _set_page_routes
256
+	 * child classes use this to define the page routes for all subpages handled by the class.  Page routes are assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also have a 'default'
257
+	 * route. Here's the format
258
+	 * $this->_page_routes = array(
259
+	 *        'default' => array(
260
+	 *            'func' => '_default_method_handling_route',
261
+	 *            'args' => array('array','of','args'),
262
+	 *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e. ajax request, backend processing)
263
+	 *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a headers route after.  The string you enter here should match the defined route reference for a headers sent route.
264
+	 *            'capability' => 'route_capability', //indicate a string for minimum capability required to access this route.
265
+	 *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability checks).
266
+	 *        ),
267
+	 *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a handling method.
268
+	 *        )
269
+	 * )
270
+	 *
271
+	 * @abstract
272
+	 * @access protected
273
+	 * @return void
274
+	 */
275
+	abstract protected function _set_page_routes();
276
+
277
+
278
+
279
+	/**
280
+	 * _set_page_config
281
+	 * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the array corresponds to the page_route for the loaded page.
282
+	 * Format:
283
+	 * $this->_page_config = array(
284
+	 *        'default' => array(
285
+	 *            'labels' => array(
286
+	 *                'buttons' => array(
287
+	 *                    'add' => __('label for adding item'),
288
+	 *                    'edit' => __('label for editing item'),
289
+	 *                    'delete' => __('label for deleting item')
290
+	 *                ),
291
+	 *                'publishbox' => __('Localized Title for Publish metabox', 'event_espresso')
292
+	 *            ), //optional an array of custom labels for various automatically generated elements to use on the page. If this isn't present then the defaults will be used as set for the $this->_labels in _define_page_props() method
293
+	 *            'nav' => array(
294
+	 *                'label' => __('Label for Tab', 'event_espresso').
295
+	 *                'url' => 'http://someurl', //automatically generated UNLESS you define
296
+	 *                'css_class' => 'css-class', //automatically generated UNLESS you define
297
+	 *                'order' => 10, //required to indicate tab position.
298
+	 *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is displayed then add this parameter.
299
+	 *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
300
+	 *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load metaboxes set for eventespresso admin pages.
301
+	 *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added later.  We just use
302
+	 *            this flag to make sure the necessary js gets enqueued on page load.
303
+	 *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
304
+	 *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The array indicates the max number of columns (4) and the default number of columns on page load (2).  There is an option
305
+	 *            in the "screen_options" dropdown that is setup so users can pick what columns they want to display.
306
+	 *            'help_tabs' => array( //this is used for adding help tabs to a page
307
+	 *                'tab_id' => array(
308
+	 *                    'title' => 'tab_title',
309
+	 *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting help tab content.  The fallback if it isn't present is to try a the callback.  Filename should match a file in the admin
310
+	 *                    folder's "help_tabs" dir (ie.. events/help_tabs/name_of_file_containing_content.help_tab.php)
311
+	 *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will attempt to use the callback which should match the name of a method in the class
312
+	 *                    ),
313
+	 *                'tab2_id' => array(
314
+	 *                    'title' => 'tab2 title',
315
+	 *                    'filename' => 'file_name_2'
316
+	 *                    'callback' => 'callback_method_for_content',
317
+	 *                 ),
318
+	 *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the help tab area on an admin page. @link http://make.wordpress.org/core/2011/12/06/help-and-screen-api-changes-in-3-3/
319
+	 *            'help_tour' => array(
320
+	 *                'name_of_help_tour_class', //all help tours shoudl be a child class of EE_Help_Tour and located in a folder for this admin page named "help_tours", a file name matching the key given here
321
+	 *                (name_of_help_tour_class.class.php), and class matching key given here (name_of_help_tour_class)
322
+	 *            ),
323
+	 *            'require_nonce' => TRUE //this is used if you want to set a route to NOT require a nonce (default is true if it isn't present).  To remove the requirement for a nonce check when this route is visited just set
324
+	 *            'require_nonce' to FALSE
325
+	 *            )
326
+	 * )
327
+	 *
328
+	 * @abstract
329
+	 * @access protected
330
+	 * @return void
331
+	 */
332
+	abstract protected function _set_page_config();
333
+
334
+
335
+
336
+
337
+
338
+	/** end sample help_tour methods **/
339
+	/**
340
+	 * _add_screen_options
341
+	 * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
342
+	 * Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options to a particular view.
343
+	 *
344
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
345
+	 *         see also WP_Screen object documents...
346
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
347
+	 * @abstract
348
+	 * @access protected
349
+	 * @return void
350
+	 */
351
+	abstract protected function _add_screen_options();
352
+
353
+
354
+
355
+	/**
356
+	 * _add_feature_pointers
357
+	 * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
358
+	 * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a particular view.
359
+	 * Note: this is just a placeholder for now.  Implementation will come down the road
360
+	 * See: WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be extended) also see:
361
+	 *
362
+	 * @link   http://eamann.com/tech/wordpress-portland/
363
+	 * @abstract
364
+	 * @access protected
365
+	 * @return void
366
+	 */
367
+	abstract protected function _add_feature_pointers();
368
+
369
+
370
+
371
+	/**
372
+	 * load_scripts_styles
373
+	 * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific scripts/styles
374
+	 * per view by putting them in a dynamic function in this format (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
375
+	 *
376
+	 * @abstract
377
+	 * @access public
378
+	 * @return void
379
+	 */
380
+	abstract public function load_scripts_styles();
381
+
382
+
383
+
384
+	/**
385
+	 * admin_init
386
+	 * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to all pages/views loaded by child class.
387
+	 *
388
+	 * @abstract
389
+	 * @access public
390
+	 * @return void
391
+	 */
392
+	abstract public function admin_init();
393
+
394
+
395
+
396
+	/**
397
+	 * admin_notices
398
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to all pages/views loaded by child class.
399
+	 *
400
+	 * @abstract
401
+	 * @access public
402
+	 * @return void
403
+	 */
404
+	abstract public function admin_notices();
405
+
406
+
407
+
408
+	/**
409
+	 * admin_footer_scripts
410
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method will apply to all pages/views loaded by child class.
411
+	 *
412
+	 * @access public
413
+	 * @return void
414
+	 */
415
+	abstract public function admin_footer_scripts();
416
+
417
+
418
+
419
+	/**
420
+	 * admin_footer
421
+	 * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will apply to all pages/views loaded by child class.
422
+	 *
423
+	 * @access  public
424
+	 * @return void
425
+	 */
426
+	public function admin_footer()
427
+	{
428
+	}
429
+
430
+
431
+
432
+	/**
433
+	 * _global_ajax_hooks
434
+	 * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
435
+	 * Note: within the ajax callback methods.
436
+	 *
437
+	 * @abstract
438
+	 * @access protected
439
+	 * @return void
440
+	 */
441
+	protected function _global_ajax_hooks()
442
+	{
443
+		//for lazy loading of metabox content
444
+		add_action('wp_ajax_espresso-ajax-content', array($this, 'ajax_metabox_content'), 10);
445
+	}
446
+
447
+
448
+
449
+	public function ajax_metabox_content()
450
+	{
451
+		$contentid = isset($this->_req_data['contentid']) ? $this->_req_data['contentid'] : '';
452
+		$url = isset($this->_req_data['contenturl']) ? $this->_req_data['contenturl'] : '';
453
+		self::cached_rss_display($contentid, $url);
454
+		wp_die();
455
+	}
456
+
457
+
458
+
459
+	/**
460
+	 * _page_setup
461
+	 * Makes sure any things that need to be loaded early get handled.  We also escape early here if the page requested doesn't match the object.
462
+	 *
463
+	 * @final
464
+	 * @access protected
465
+	 * @return void
466
+	 */
467
+	final protected function _page_setup()
468
+	{
469
+		//requires?
470
+		//admin_init stuff - global - we're setting this REALLY early so if EE_Admin pages have to hook into other WP pages they can.  But keep in mind, not everything is available from the EE_Admin Page object at this point.
471
+		add_action('admin_init', array($this, 'admin_init_global'), 5);
472
+		//next verify if we need to load anything...
473
+		$this->_current_page = ! empty($_GET['page']) ? sanitize_key($_GET['page']) : '';
474
+		$this->page_folder = strtolower(str_replace('_Admin_Page', '', str_replace('Extend_', '', get_class($this))));
475
+		global $ee_menu_slugs;
476
+		$ee_menu_slugs = (array)$ee_menu_slugs;
477
+		if (( ! $this->_current_page || ! isset($ee_menu_slugs[$this->_current_page])) && ! defined('DOING_AJAX')) {
478
+			return false;
479
+		}
480
+		// becuz WP List tables have two duplicate select inputs for choosing bulk actions, we need to copy the action from the second to the first
481
+		if (isset($this->_req_data['action2']) && $this->_req_data['action'] == -1) {
482
+			$this->_req_data['action'] = ! empty($this->_req_data['action2']) && $this->_req_data['action2'] != -1 ? $this->_req_data['action2'] : $this->_req_data['action'];
483
+		}
484
+		// then set blank or -1 action values to 'default'
485
+		$this->_req_action = isset($this->_req_data['action']) && ! empty($this->_req_data['action']) && $this->_req_data['action'] != -1 ? sanitize_key($this->_req_data['action']) : 'default';
486
+		//if action is 'default' after the above BUT we have  'route' var set, then let's use the route as the action.  This covers cases where we're coming in from a list table that isn't on the default route.
487
+		$this->_req_action = $this->_req_action == 'default' && isset($this->_req_data['route']) ? $this->_req_data['route'] : $this->_req_action;
488
+		//however if we are doing_ajax and we've got a 'route' set then that's what the req_action will be
489
+		$this->_req_action = defined('DOING_AJAX') && isset($this->_req_data['route']) ? $this->_req_data['route'] : $this->_req_action;
490
+		$this->_current_view = $this->_req_action;
491
+		$this->_req_nonce = $this->_req_action . '_nonce';
492
+		$this->_define_page_props();
493
+		$this->_current_page_view_url = add_query_arg(array('page' => $this->_current_page, 'action' => $this->_current_view), $this->_admin_base_url);
494
+		//default things
495
+		$this->_default_espresso_metaboxes = array('_espresso_news_post_box', '_espresso_links_post_box', '_espresso_ratings_request', '_espresso_sponsors_post_box');
496
+		//set page configs
497
+		$this->_set_page_routes();
498
+		$this->_set_page_config();
499
+		//let's include any referrer data in our default_query_args for this route for "stickiness".
500
+		if (isset($this->_req_data['wp_referer'])) {
501
+			$this->_default_route_query_args['wp_referer'] = $this->_req_data['wp_referer'];
502
+		}
503
+		//for caffeinated and other extended functionality.  If there is a _extend_page_config method then let's run that to modify the all the various page configuration arrays
504
+		if (method_exists($this, '_extend_page_config')) {
505
+			$this->_extend_page_config();
506
+		}
507
+		//for CPT and other extended functionality. If there is an _extend_page_config_for_cpt then let's run that to modify all the various page configuration arrays.
508
+		if (method_exists($this, '_extend_page_config_for_cpt')) {
509
+			$this->_extend_page_config_for_cpt();
510
+		}
511
+		//filter routes and page_config so addons can add their stuff. Filtering done per class
512
+		$this->_page_routes = apply_filters('FHEE__' . get_class($this) . '__page_setup__page_routes', $this->_page_routes, $this);
513
+		$this->_page_config = apply_filters('FHEE__' . get_class($this) . '__page_setup__page_config', $this->_page_config, $this);
514
+		//if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
515
+		if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
516
+			add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view), 10, 2);
517
+		}
518
+		//next route only if routing enabled
519
+		if ($this->_routing && ! defined('DOING_AJAX')) {
520
+			$this->_verify_routes();
521
+			//next let's just check user_access and kill if no access
522
+			$this->check_user_access();
523
+			if ($this->_is_UI_request) {
524
+				//admin_init stuff - global, all views for this page class, specific view
525
+				add_action('admin_init', array($this, 'admin_init'), 10);
526
+				if (method_exists($this, 'admin_init_' . $this->_current_view)) {
527
+					add_action('admin_init', array($this, 'admin_init_' . $this->_current_view), 15);
528
+				}
529
+			} else {
530
+				//hijack regular WP loading and route admin request immediately
531
+				@ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
532
+				$this->route_admin_request();
533
+			}
534
+		}
535
+	}
536
+
537
+
538
+
539
+	/**
540
+	 * Provides a way for related child admin pages to load stuff on the loaded admin page.
541
+	 *
542
+	 * @access private
543
+	 * @return void
544
+	 */
545
+	private function _do_other_page_hooks()
546
+	{
547
+		$registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, array());
548
+		foreach ($registered_pages as $page) {
549
+			//now let's setup the file name and class that should be present
550
+			$classname = str_replace('.class.php', '', $page);
551
+			//autoloaders should take care of loading file
552
+			if ( ! class_exists($classname)) {
553
+				$error_msg[] = sprintf(__('Something went wrong with loading the %s admin hooks page.', 'event_espresso'), $page);
554
+				$error_msg[] = $error_msg[0]
555
+							   . "\r\n"
556
+							   . sprintf(__('There is no class in place for the %s admin hooks page.%sMake sure you have <strong>%s</strong> defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
557
+								'event_espresso'), $page, '<br />', $classname);
558
+				throw new EE_Error(implode('||', $error_msg));
559
+			}
560
+			$a = new ReflectionClass($classname);
561
+			//notice we are passing the instance of this class to the hook object.
562
+			$hookobj[] = $a->newInstance($this);
563
+		}
564
+	}
565
+
566
+
567
+
568
+	public function load_page_dependencies()
569
+	{
570
+		try {
571
+			$this->_load_page_dependencies();
572
+		} catch (EE_Error $e) {
573
+			$e->get_error();
574
+		}
575
+	}
576
+
577
+
578
+
579
+	/**
580
+	 * load_page_dependencies
581
+	 * loads things specific to this page class when its loaded.  Really helps with efficiency.
582
+	 *
583
+	 * @access public
584
+	 * @return void
585
+	 */
586
+	protected function _load_page_dependencies()
587
+	{
588
+		//let's set the current_screen and screen options to override what WP set
589
+		$this->_current_screen = get_current_screen();
590
+		//load admin_notices - global, page class, and view specific
591
+		add_action('admin_notices', array($this, 'admin_notices_global'), 5);
592
+		add_action('admin_notices', array($this, 'admin_notices'), 10);
593
+		if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
594
+			add_action('admin_notices', array($this, 'admin_notices_' . $this->_current_view), 15);
595
+		}
596
+		//load network admin_notices - global, page class, and view specific
597
+		add_action('network_admin_notices', array($this, 'network_admin_notices_global'), 5);
598
+		if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
599
+			add_action('network_admin_notices', array($this, 'network_admin_notices_' . $this->_current_view));
600
+		}
601
+		//this will save any per_page screen options if they are present
602
+		$this->_set_per_page_screen_options();
603
+		//setup list table properties
604
+		$this->_set_list_table();
605
+		// child classes can "register" a metabox to be automatically handled via the _page_config array property.  However in some cases the metaboxes will need to be added within a route handling callback.
606
+		$this->_add_registered_meta_boxes();
607
+		$this->_add_screen_columns();
608
+		//add screen options - global, page child class, and view specific
609
+		$this->_add_global_screen_options();
610
+		$this->_add_screen_options();
611
+		if (method_exists($this, '_add_screen_options_' . $this->_current_view)) {
612
+			call_user_func(array($this, '_add_screen_options_' . $this->_current_view));
613
+		}
614
+		//add help tab(s) and tours- set via page_config and qtips.
615
+		$this->_add_help_tour();
616
+		$this->_add_help_tabs();
617
+		$this->_add_qtips();
618
+		//add feature_pointers - global, page child class, and view specific
619
+		$this->_add_feature_pointers();
620
+		$this->_add_global_feature_pointers();
621
+		if (method_exists($this, '_add_feature_pointer_' . $this->_current_view)) {
622
+			call_user_func(array($this, '_add_feature_pointer_' . $this->_current_view));
623
+		}
624
+		//enqueue scripts/styles - global, page class, and view specific
625
+		add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5);
626
+		add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10);
627
+		if (method_exists($this, 'load_scripts_styles_' . $this->_current_view)) {
628
+			add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_' . $this->_current_view), 15);
629
+		}
630
+		add_action('admin_enqueue_scripts', array($this, 'admin_footer_scripts_eei18n_js_strings'), 100);
631
+		//admin_print_footer_scripts - global, page child class, and view specific.  NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.  In most cases that's doing_it_wrong().  But adding hidden container elements etc. is a good use case. Notice the late priority we're giving these
632
+		add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_global'), 99);
633
+		add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts'), 100);
634
+		if (method_exists($this, 'admin_footer_scripts_' . $this->_current_view)) {
635
+			add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_' . $this->_current_view), 101);
636
+		}
637
+		//admin footer scripts
638
+		add_action('admin_footer', array($this, 'admin_footer_global'), 99);
639
+		add_action('admin_footer', array($this, 'admin_footer'), 100);
640
+		if (method_exists($this, 'admin_footer_' . $this->_current_view)) {
641
+			add_action('admin_footer', array($this, 'admin_footer_' . $this->_current_view), 101);
642
+		}
643
+		do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
644
+		//targeted hook
645
+		do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load__' . $this->page_slug . '__' . $this->_req_action);
646
+	}
647
+
648
+
649
+
650
+	/**
651
+	 * _set_defaults
652
+	 * This sets some global defaults for class properties.
653
+	 */
654
+	private function _set_defaults()
655
+	{
656
+		$this->_current_screen = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = $this->_event = $this->_template_path = $this->_column_template_path = null;
657
+		$this->_nav_tabs = $this_views = $this->_page_routes = $this->_page_config = $this->_default_route_query_args = array();
658
+		$this->default_nav_tab_name = 'overview';
659
+		//init template args
660
+		$this->_template_args = array(
661
+				'admin_page_header'  => '',
662
+				'admin_page_content' => '',
663
+				'post_body_content'  => '',
664
+				'before_list_table'  => '',
665
+				'after_list_table'   => '',
666
+		);
667
+	}
668
+
669
+
670
+
671
+	/**
672
+	 * route_admin_request
673
+	 *
674
+	 * @see    _route_admin_request()
675
+	 * @access public
676
+	 * @return void|exception error
677
+	 */
678
+	public function route_admin_request()
679
+	{
680
+		try {
681
+			$this->_route_admin_request();
682
+		} catch (EE_Error $e) {
683
+			$e->get_error();
684
+		}
685
+	}
686
+
687
+
688
+
689
+	public function set_wp_page_slug($wp_page_slug)
690
+	{
691
+		$this->_wp_page_slug = $wp_page_slug;
692
+		//if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
693
+		if (is_network_admin()) {
694
+			$this->_wp_page_slug .= '-network';
695
+		}
696
+	}
697
+
698
+
699
+
700
+	/**
701
+	 * _verify_routes
702
+	 * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so we know if we need to drop out.
703
+	 *
704
+	 * @access protected
705
+	 * @return void
706
+	 */
707
+	protected function _verify_routes()
708
+	{
709
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
710
+		if ( ! $this->_current_page && ! defined('DOING_AJAX')) {
711
+			return false;
712
+		}
713
+		$this->_route = false;
714
+		$func = false;
715
+		$args = array();
716
+		// check that the page_routes array is not empty
717
+		if (empty($this->_page_routes)) {
718
+			// user error msg
719
+			$error_msg = sprintf(__('No page routes have been set for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
720
+			// developer error msg
721
+			$error_msg .= '||' . $error_msg . __(' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.', 'event_espresso');
722
+			throw new EE_Error($error_msg);
723
+		}
724
+		// and that the requested page route exists
725
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
726
+			$this->_route = $this->_page_routes[$this->_req_action];
727
+			$this->_route_config = isset($this->_page_config[$this->_req_action]) ? $this->_page_config[$this->_req_action] : array();
728
+		} else {
729
+			// user error msg
730
+			$error_msg = sprintf(__('The requested page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
731
+			// developer error msg
732
+			$error_msg .= '||' . $error_msg . sprintf(__(' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.', 'event_espresso'), $this->_req_action);
733
+			throw new EE_Error($error_msg);
734
+		}
735
+		// and that a default route exists
736
+		if ( ! array_key_exists('default', $this->_page_routes)) {
737
+			// user error msg
738
+			$error_msg = sprintf(__('A default page route has not been set for the % admin page.', 'event_espresso'), $this->_admin_page_title);
739
+			// developer error msg
740
+			$error_msg .= '||' . $error_msg . __(' Create a key in the "_page_routes" array named "default" and set its value to your default page method.', 'event_espresso');
741
+			throw new EE_Error($error_msg);
742
+		}
743
+		//first lets' catch if the UI request has EVER been set.
744
+		if ($this->_is_UI_request === null) {
745
+			//lets set if this is a UI request or not.
746
+			$this->_is_UI_request = ( ! isset($this->_req_data['noheader']) || $this->_req_data['noheader'] !== true) ? true : false;
747
+			//wait a minute... we might have a noheader in the route array
748
+			$this->_is_UI_request = is_array($this->_route) && isset($this->_route['noheader']) && $this->_route['noheader'] ? false : $this->_is_UI_request;
749
+		}
750
+		$this->_set_current_labels();
751
+	}
752
+
753
+
754
+
755
+	/**
756
+	 * this method simply verifies a given route and makes sure its an actual route available for the loaded page
757
+	 *
758
+	 * @param  string $route the route name we're verifying
759
+	 * @return mixed  (bool|Exception)      we'll throw an exception if this isn't a valid route.
760
+	 */
761
+	protected function _verify_route($route)
762
+	{
763
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
764
+			return true;
765
+		} else {
766
+			// user error msg
767
+			$error_msg = sprintf(__('The given page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
768
+			// developer error msg
769
+			$error_msg .= '||' . $error_msg . sprintf(__(' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property', 'event_espresso'), $route);
770
+			throw new EE_Error($error_msg);
771
+		}
772
+	}
773
+
774
+
775
+
776
+	/**
777
+	 * perform nonce verification
778
+	 * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces using this method (and save retyping!)
779
+	 *
780
+	 * @param  string $nonce     The nonce sent
781
+	 * @param  string $nonce_ref The nonce reference string (name0)
782
+	 * @return mixed (bool|die)
783
+	 */
784
+	protected function _verify_nonce($nonce, $nonce_ref)
785
+	{
786
+		// verify nonce against expected value
787
+		if ( ! wp_verify_nonce($nonce, $nonce_ref)) {
788
+			// these are not the droids you are looking for !!!
789
+			$msg = sprintf(__('%sNonce Fail.%s', 'event_espresso'), '<a href="http://www.youtube.com/watch?v=56_S0WeTkzs">', '</a>');
790
+			if (WP_DEBUG) {
791
+				$msg .= "\n  " . sprintf(__('In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!', 'event_espresso'), __CLASS__);
792
+			}
793
+			if ( ! defined('DOING_AJAX')) {
794
+				wp_die($msg);
795
+			} else {
796
+				EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
797
+				$this->_return_json();
798
+			}
799
+		}
800
+	}
801
+
802
+
803
+
804
+	/**
805
+	 * _route_admin_request()
806
+	 * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if theres are
807
+	 * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
808
+	 * in the page routes and then will try to load the corresponding method.
809
+	 *
810
+	 * @access protected
811
+	 * @return void
812
+	 * @throws \EE_Error
813
+	 */
814
+	protected function _route_admin_request()
815
+	{
816
+		if ( ! $this->_is_UI_request) {
817
+			$this->_verify_routes();
818
+		}
819
+		$nonce_check = isset($this->_route_config['require_nonce'])
820
+			? $this->_route_config['require_nonce']
821
+			: true;
822
+		if ($this->_req_action !== 'default' && $nonce_check) {
823
+			// set nonce from post data
824
+			$nonce = isset($this->_req_data[$this->_req_nonce])
825
+				? sanitize_text_field($this->_req_data[$this->_req_nonce])
826
+				: '';
827
+			$this->_verify_nonce($nonce, $this->_req_nonce);
828
+		}
829
+		//set the nav_tabs array but ONLY if this is  UI_request
830
+		if ($this->_is_UI_request) {
831
+			$this->_set_nav_tabs();
832
+		}
833
+		// grab callback function
834
+		$func = is_array($this->_route) ? $this->_route['func'] : $this->_route;
835
+		// check if callback has args
836
+		$args = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : array();
837
+		$error_msg = '';
838
+		// action right before calling route
839
+		// (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
840
+		if ( ! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
841
+			do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
842
+		}
843
+		// right before calling the route, let's remove _wp_http_referer from the
844
+		// $_SERVER[REQUEST_URI] global (its now in _req_data for route processing).
845
+		$_SERVER['REQUEST_URI'] = remove_query_arg('_wp_http_referer', wp_unslash($_SERVER['REQUEST_URI']));
846
+		if ( ! empty($func)) {
847
+			if (is_array($func)) {
848
+				list($class, $method) = $func;
849
+			} else if (strpos($func, '::') !== false) {
850
+				list($class, $method) = explode('::', $func);
851
+			} else {
852
+				$class = $this;
853
+				$method = $func;
854
+			}
855
+			if ( ! (is_object($class) && $class === $this)) {
856
+				// send along this admin page object for access by addons.
857
+				$args['admin_page_object'] = $this;
858
+			}
859
+			if (
860
+				//is it a method on a class that doesn't work?
861
+				(
862
+					method_exists($class, $method)
863
+					&& call_user_func_array(array($class, $method), $args) === false
864
+				)
865
+				|| (
866
+					//is it a standalone function that doesn't work?
867
+					function_exists($method)
868
+					&& call_user_func_array($func, array_merge(array('admin_page_object' => $this), $args)) === false
869
+				)
870
+				|| (
871
+					//is it neither a class method NOR a standalone function?
872
+					! method_exists($class, $method)
873
+					&& ! function_exists($method)
874
+				)
875
+			) {
876
+				// user error msg
877
+				$error_msg = __('An error occurred. The  requested page route could not be found.', 'event_espresso');
878
+				// developer error msg
879
+				$error_msg .= '||';
880
+				$error_msg .= sprintf(
881
+					__(
882
+						'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
883
+						'event_espresso'
884
+					),
885
+					$method
886
+				);
887
+			}
888
+			if ( ! empty($error_msg)) {
889
+				throw new EE_Error($error_msg);
890
+			}
891
+		}
892
+		//if we've routed and this route has a no headers route AND a sent_headers_route, then we need to reset the routing properties to the new route.
893
+		//now if UI request is FALSE and noheader is true AND we have a headers_sent_route in the route array then let's set UI_request to true because the no header route has a second func after headers have been sent.
894
+		if ($this->_is_UI_request === false
895
+			&& is_array($this->_route)
896
+			&& ! empty($this->_route['headers_sent_route'])
897
+		) {
898
+			$this->_reset_routing_properties($this->_route['headers_sent_route']);
899
+		}
900
+	}
901
+
902
+
903
+
904
+	/**
905
+	 * This method just allows the resetting of page properties in the case where a no headers
906
+	 * route redirects to a headers route in its route config.
907
+	 *
908
+	 * @since   4.3.0
909
+	 * @param  string $new_route New (non header) route to redirect to.
910
+	 * @return   void
911
+	 */
912
+	protected function _reset_routing_properties($new_route)
913
+	{
914
+		$this->_is_UI_request = true;
915
+		//now we set the current route to whatever the headers_sent_route is set at
916
+		$this->_req_data['action'] = $new_route;
917
+		//rerun page setup
918
+		$this->_page_setup();
919
+	}
920
+
921
+
922
+
923
+	/**
924
+	 * _add_query_arg
925
+	 * adds nonce to array of arguments then calls WP add_query_arg function
926
+	 *(internally just uses EEH_URL's function with the same name)
927
+	 *
928
+	 * @access public
929
+	 * @param array  $args
930
+	 * @param string $url
931
+	 * @param bool   $sticky                  if true, then the existing Request params will be appended to the generated
932
+	 *                                        url in an associative array indexed by the key 'wp_referer';
933
+	 *                                        Example usage:
934
+	 *                                        If the current page is:
935
+	 *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
936
+	 *                                        &action=default&event_id=20&month_range=March%202015
937
+	 *                                        &_wpnonce=5467821
938
+	 *                                        and you call:
939
+	 *                                        EE_Admin_Page::add_query_args_and_nonce(
940
+	 *                                        array(
941
+	 *                                        'action' => 'resend_something',
942
+	 *                                        'page=>espresso_registrations'
943
+	 *                                        ),
944
+	 *                                        $some_url,
945
+	 *                                        true
946
+	 *                                        );
947
+	 *                                        It will produce a url in this structure:
948
+	 *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
949
+	 *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
950
+	 *                                        month_range]=March%202015
951
+	 * @param   bool $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
952
+	 * @return string
953
+	 */
954
+	public static function add_query_args_and_nonce($args = array(), $url = false, $sticky = false, $exclude_nonce = false)
955
+	{
956
+		//if there is a _wp_http_referer include the values from the request but only if sticky = true
957
+		if ($sticky) {
958
+			$request = $_REQUEST;
959
+			unset($request['_wp_http_referer']);
960
+			unset($request['wp_referer']);
961
+			foreach ($request as $key => $value) {
962
+				//do not add nonces
963
+				if (strpos($key, 'nonce') !== false) {
964
+					continue;
965
+				}
966
+				$args['wp_referer[' . $key . ']'] = $value;
967
+			}
968
+		}
969
+		return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
970
+	}
971
+
972
+
973
+
974
+	/**
975
+	 * This returns a generated link that will load the related help tab.
976
+	 *
977
+	 * @param  string $help_tab_id the id for the connected help tab
978
+	 * @param  string $icon_style  (optional) include css class for the style you want to use for the help icon.
979
+	 * @param  string $help_text   (optional) send help text you want to use for the link if default not to be used
980
+	 * @uses EEH_Template::get_help_tab_link()
981
+	 * @return string              generated link
982
+	 */
983
+	protected function _get_help_tab_link($help_tab_id, $icon_style = false, $help_text = false)
984
+	{
985
+		return EEH_Template::get_help_tab_link($help_tab_id, $this->page_slug, $this->_req_action, $icon_style, $help_text);
986
+	}
987
+
988
+
989
+
990
+	/**
991
+	 * _add_help_tabs
992
+	 * Note child classes define their help tabs within the page_config array.
993
+	 *
994
+	 * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
995
+	 * @access protected
996
+	 * @return void
997
+	 */
998
+	protected function _add_help_tabs()
999
+	{
1000
+		$tour_buttons = '';
1001
+		if (isset($this->_page_config[$this->_req_action])) {
1002
+			$config = $this->_page_config[$this->_req_action];
1003
+			//is there a help tour for the current route?  if there is let's setup the tour buttons
1004
+			if (isset($this->_help_tour[$this->_req_action])) {
1005
+				$tb = array();
1006
+				$tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">';
1007
+				foreach ($this->_help_tour['tours'] as $tour) {
1008
+					//if this is the end tour then we don't need to setup a button
1009
+					if ($tour instanceof EE_Help_Tour_final_stop) {
1010
+						continue;
1011
+					}
1012
+					$tb[] = '<button id="trigger-tour-' . $tour->get_slug() . '" class="button-primary trigger-ee-help-tour">' . $tour->get_label() . '</button>';
1013
+				}
1014
+				$tour_buttons .= implode('<br />', $tb);
1015
+				$tour_buttons .= '</div></div>';
1016
+			}
1017
+			// let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1018
+			if (is_array($config) && isset($config['help_sidebar'])) {
1019
+				//check that the callback given is valid
1020
+				if ( ! method_exists($this, $config['help_sidebar'])) {
1021
+					throw new EE_Error(sprintf(__('The _page_config array has a callback set for the "help_sidebar" option.  However the callback given (%s) is not a valid callback.  Doublecheck the spelling and make sure this method exists for the class %s',
1022
+							'event_espresso'), $config['help_sidebar'], get_class($this)));
1023
+				}
1024
+				$content = apply_filters('FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar', call_user_func(array($this, $config['help_sidebar'])));
1025
+				$content .= $tour_buttons; //add help tour buttons.
1026
+				//do we have any help tours setup?  Cause if we do we want to add the buttons
1027
+				$this->_current_screen->set_help_sidebar($content);
1028
+			}
1029
+			//if we DON'T have config help sidebar and there ARE toure buttons then we'll just add the tour buttons to the sidebar.
1030
+			if ( ! isset($config['help_sidebar']) && ! empty($tour_buttons)) {
1031
+				$this->_current_screen->set_help_sidebar($tour_buttons);
1032
+			}
1033
+			//handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1034
+			if ( ! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1035
+				$_ht['id'] = $this->page_slug;
1036
+				$_ht['title'] = __('Help Tours', 'event_espresso');
1037
+				$_ht['content'] = '<p>' . __('The buttons to the right allow you to start/restart any help tours available for this page', 'event_espresso') . '</p>';
1038
+				$this->_current_screen->add_help_tab($_ht);
1039
+			}/**/
1040
+			if ( ! isset($config['help_tabs'])) {
1041
+				return;
1042
+			} //no help tabs for this route
1043
+			foreach ((array)$config['help_tabs'] as $tab_id => $cfg) {
1044
+				//we're here so there ARE help tabs!
1045
+				//make sure we've got what we need
1046
+				if ( ! isset($cfg['title'])) {
1047
+					throw new EE_Error(__('The _page_config array is not set up properly for help tabs.  It is missing a title', 'event_espresso'));
1048
+				}
1049
+				if ( ! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1050
+					throw new EE_Error(__('The _page_config array is not setup properly for help tabs. It is missing a either a filename reference, or a callback reference or a content reference so there is no way to know the content for the help tab',
1051
+							'event_espresso'));
1052
+				}
1053
+				//first priority goes to content.
1054
+				if ( ! empty($cfg['content'])) {
1055
+					$content = ! empty($cfg['content']) ? $cfg['content'] : null;
1056
+					//second priority goes to filename
1057
+				} else if ( ! empty($cfg['filename'])) {
1058
+					$file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1059
+					//it's possible that the file is located on decaf route (and above sets up for caf route, if this is the case then lets check decaf route too)
1060
+					$file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tabs/' . $cfg['filename'] . '.help_tab.php' : $file_path;
1061
+					//if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1062
+					if ( ! is_readable($file_path) && ! isset($cfg['callback'])) {
1063
+						EE_Error::add_error(sprintf(__('The filename given for the help tab %s is not a valid file and there is no other configuration for the tab content.  Please check that the string you set for the help tab on this route (%s) is the correct spelling.  The file should be in %s',
1064
+								'event_espresso'), $tab_id, key($config), $file_path), __FILE__, __FUNCTION__, __LINE__);
1065
+						return;
1066
+					}
1067
+					$template_args['admin_page_obj'] = $this;
1068
+					$content = EEH_Template::display_template($file_path, $template_args, true);
1069
+				} else {
1070
+					$content = '';
1071
+				}
1072
+				//check if callback is valid
1073
+				if (empty($content) && ( ! isset($cfg['callback']) || ! method_exists($this, $cfg['callback']))) {
1074
+					EE_Error::add_error(sprintf(__('The callback given for a %s help tab on this page does not content OR a corresponding method for generating the content.  Check the spelling or make sure the method is present.',
1075
+							'event_espresso'), $cfg['title']), __FILE__, __FUNCTION__, __LINE__);
1076
+					return;
1077
+				}
1078
+				//setup config array for help tab method
1079
+				$id = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1080
+				$_ht = array(
1081
+						'id'       => $id,
1082
+						'title'    => $cfg['title'],
1083
+						'callback' => isset($cfg['callback']) && empty($content) ? array($this, $cfg['callback']) : null,
1084
+						'content'  => $content,
1085
+				);
1086
+				$this->_current_screen->add_help_tab($_ht);
1087
+			}
1088
+		}
1089
+	}
1090
+
1091
+
1092
+
1093
+	/**
1094
+	 * This basically checks loaded $_page_config property to see if there are any help_tours defined.  "help_tours" is an array with properties for setting up usage of the joyride plugin
1095
+	 *
1096
+	 * @link   http://zurb.com/playground/jquery-joyride-feature-tour-plugin
1097
+	 * @see    instructions regarding the format and construction of the "help_tour" array element is found in the _set_page_config() comments
1098
+	 * @access protected
1099
+	 * @return void
1100
+	 */
1101
+	protected function _add_help_tour()
1102
+	{
1103
+		$tours = array();
1104
+		$this->_help_tour = array();
1105
+		//exit early if help tours are turned off globally
1106
+		if ( ! EE_Registry::instance()->CFG->admin->help_tour_activation || (defined('EE_DISABLE_HELP_TOURS') && EE_DISABLE_HELP_TOURS)) {
1107
+			return;
1108
+		}
1109
+		//loop through _page_config to find any help_tour defined
1110
+		foreach ($this->_page_config as $route => $config) {
1111
+			//we're only going to set things up for this route
1112
+			if ($route !== $this->_req_action) {
1113
+				continue;
1114
+			}
1115
+			if (isset($config['help_tour'])) {
1116
+				foreach ($config['help_tour'] as $tour) {
1117
+					$file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1118
+					//let's see if we can get that file... if not its possible this is a decaf route not set in caffienated so lets try and get the caffeinated equivalent
1119
+					$file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tours/' . $tour . '.class.php' : $file_path;
1120
+					//if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1121
+					if ( ! is_readable($file_path)) {
1122
+						EE_Error::add_error(sprintf(__('The file path given for the help tour (%s) is not a valid path.  Please check that the string you set for the help tour on this route (%s) is the correct spelling', 'event_espresso'),
1123
+								$file_path, $tour), __FILE__, __FUNCTION__, __LINE__);
1124
+						return;
1125
+					}
1126
+					require_once $file_path;
1127
+					if ( ! class_exists($tour)) {
1128
+						$error_msg[] = sprintf(__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'), $tour);
1129
+						$error_msg[] = $error_msg[0] . "\r\n" . sprintf(__('There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.',
1130
+										'event_espresso'), $tour, '<br />', $tour, $this->_req_action, get_class($this));
1131
+						throw new EE_Error(implode('||', $error_msg));
1132
+					}
1133
+					$a = new ReflectionClass($tour);
1134
+					$tour_obj = $a->newInstance($this->_is_caf);
1135
+					$tours[] = $tour_obj;
1136
+					$this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($tour_obj);
1137
+				}
1138
+				//let's inject the end tour stop element common to all pages... this will only get seen once per machine.
1139
+				$end_stop_tour = new EE_Help_Tour_final_stop($this->_is_caf);
1140
+				$tours[] = $end_stop_tour;
1141
+				$this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($end_stop_tour);
1142
+			}
1143
+		}
1144
+		if ( ! empty($tours)) {
1145
+			$this->_help_tour['tours'] = $tours;
1146
+		}
1147
+		//thats it!  Now that the $_help_tours property is set (or not) the scripts and html should be taken care of automatically.
1148
+	}
1149
+
1150
+
1151
+
1152
+	/**
1153
+	 * This simply sets up any qtips that have been defined in the page config
1154
+	 *
1155
+	 * @access protected
1156
+	 * @return void
1157
+	 */
1158
+	protected function _add_qtips()
1159
+	{
1160
+		if (isset($this->_route_config['qtips'])) {
1161
+			$qtips = (array)$this->_route_config['qtips'];
1162
+			//load qtip loader
1163
+			$path = array(
1164
+					$this->_get_dir() . '/qtips/',
1165
+					EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1166
+			);
1167
+			EEH_Qtip_Loader::instance()->register($qtips, $path);
1168
+		}
1169
+	}
1170
+
1171
+
1172
+
1173
+	/**
1174
+	 * _set_nav_tabs
1175
+	 * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you wish to add additional tabs or modify accordingly.
1176
+	 *
1177
+	 * @access protected
1178
+	 * @return void
1179
+	 */
1180
+	protected function _set_nav_tabs()
1181
+	{
1182
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1183
+		$i = 0;
1184
+		foreach ($this->_page_config as $slug => $config) {
1185
+			if ( ! is_array($config) || (is_array($config) && (isset($config['nav']) && ! $config['nav']) || ! isset($config['nav']))) {
1186
+				continue;
1187
+			} //no nav tab for this config
1188
+			//check for persistent flag
1189
+			if (isset($config['nav']['persistent']) && ! $config['nav']['persistent'] && $slug !== $this->_req_action) {
1190
+				continue;
1191
+			} //nav tab is only to appear when route requested.
1192
+			if ( ! $this->check_user_access($slug, true)) {
1193
+				continue;
1194
+			} //no nav tab becasue current user does not have access.
1195
+			$css_class = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1196
+			$this->_nav_tabs[$slug] = array(
1197
+					'url'       => isset($config['nav']['url']) ? $config['nav']['url'] : self::add_query_args_and_nonce(array('action' => $slug), $this->_admin_base_url),
1198
+					'link_text' => isset($config['nav']['label']) ? $config['nav']['label'] : ucwords(str_replace('_', ' ', $slug)),
1199
+					'css_class' => $this->_req_action == $slug ? $css_class . 'nav-tab-active' : $css_class,
1200
+					'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1201
+			);
1202
+			$i++;
1203
+		}
1204
+		//if $this->_nav_tabs is empty then lets set the default
1205
+		if (empty($this->_nav_tabs)) {
1206
+			$this->_nav_tabs[$this->default_nav_tab_name] = array(
1207
+					'url'       => $this->admin_base_url,
1208
+					'link_text' => ucwords(str_replace('_', ' ', $this->default_nav_tab_name)),
1209
+					'css_class' => 'nav-tab-active',
1210
+					'order'     => 10,
1211
+			);
1212
+		}
1213
+		//now let's sort the tabs according to order
1214
+		usort($this->_nav_tabs, array($this, '_sort_nav_tabs'));
1215
+	}
1216
+
1217
+
1218
+
1219
+	/**
1220
+	 * _set_current_labels
1221
+	 * This method modifies the _labels property with any optional specific labels indicated in the _page_routes property array
1222
+	 *
1223
+	 * @access private
1224
+	 * @return void
1225
+	 */
1226
+	private function _set_current_labels()
1227
+	{
1228
+		if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1229
+			foreach ($this->_route_config['labels'] as $label => $text) {
1230
+				if (is_array($text)) {
1231
+					foreach ($text as $sublabel => $subtext) {
1232
+						$this->_labels[$label][$sublabel] = $subtext;
1233
+					}
1234
+				} else {
1235
+					$this->_labels[$label] = $text;
1236
+				}
1237
+			}
1238
+		}
1239
+	}
1240
+
1241
+
1242
+
1243
+	/**
1244
+	 *        verifies user access for this admin page
1245
+	 *
1246
+	 * @param string $route_to_check if present then the capability for the route matching this string is checked.
1247
+	 * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just return false if verify fail.
1248
+	 * @return        BOOL|wp_die()
1249
+	 */
1250
+	public function check_user_access($route_to_check = '', $verify_only = false)
1251
+	{
1252
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1253
+		$route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1254
+		$capability = ! empty($route_to_check) && isset($this->_page_routes[$route_to_check]) && is_array($this->_page_routes[$route_to_check]) && ! empty($this->_page_routes[$route_to_check]['capability'])
1255
+				? $this->_page_routes[$route_to_check]['capability'] : null;
1256
+		if (empty($capability) && empty($route_to_check)) {
1257
+			$capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options' : $this->_route['capability'];
1258
+		} else {
1259
+			$capability = empty($capability) ? 'manage_options' : $capability;
1260
+		}
1261
+		$id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1262
+		if (( ! function_exists('is_admin') || ! EE_Registry::instance()->CAP->current_user_can($capability, $this->page_slug . '_' . $route_to_check, $id)) && ! defined('DOING_AJAX')) {
1263
+			if ($verify_only) {
1264
+				return false;
1265
+			} else {
1266
+				if ( is_user_logged_in() ) {
1267
+					wp_die(__('You do not have access to this route.', 'event_espresso'));
1268
+				} else {
1269
+					return false;
1270
+				}
1271
+			}
1272
+		}
1273
+		return true;
1274
+	}
1275
+
1276
+
1277
+
1278
+	/**
1279
+	 * admin_init_global
1280
+	 * This runs all the code that we want executed within the WP admin_init hook.
1281
+	 * This method executes for ALL EE Admin pages.
1282
+	 *
1283
+	 * @access public
1284
+	 * @return void
1285
+	 */
1286
+	public function admin_init_global()
1287
+	{
1288
+	}
1289
+
1290
+
1291
+
1292
+	/**
1293
+	 * wp_loaded_global
1294
+	 * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an EE_Admin page and will execute on every EE Admin Page load
1295
+	 *
1296
+	 * @access public
1297
+	 * @return void
1298
+	 */
1299
+	public function wp_loaded()
1300
+	{
1301
+	}
1302
+
1303
+
1304
+
1305
+	/**
1306
+	 * admin_notices
1307
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on ALL EE_Admin pages.
1308
+	 *
1309
+	 * @access public
1310
+	 * @return void
1311
+	 */
1312
+	public function admin_notices_global()
1313
+	{
1314
+		$this->_display_no_javascript_warning();
1315
+		$this->_display_espresso_notices();
1316
+	}
1317
+
1318
+
1319
+
1320
+	public function network_admin_notices_global()
1321
+	{
1322
+		$this->_display_no_javascript_warning();
1323
+		$this->_display_espresso_notices();
1324
+	}
1325
+
1326
+
1327
+
1328
+	/**
1329
+	 * admin_footer_scripts_global
1330
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method will apply on ALL EE_Admin pages.
1331
+	 *
1332
+	 * @access public
1333
+	 * @return void
1334
+	 */
1335
+	public function admin_footer_scripts_global()
1336
+	{
1337
+		$this->_add_admin_page_ajax_loading_img();
1338
+		$this->_add_admin_page_overlay();
1339
+		//if metaboxes are present we need to add the nonce field
1340
+		if ((isset($this->_route_config['metaboxes']) || (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes']) || isset($this->_route_config['list_table']))) {
1341
+			wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1342
+			wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1343
+		}
1344
+	}
1345
+
1346
+
1347
+
1348
+	/**
1349
+	 * admin_footer_global
1350
+	 * Anything triggered by the wp 'admin_footer' wp hook should be put in here. This particluar method will apply on ALL EE_Admin Pages.
1351
+	 *
1352
+	 * @access  public
1353
+	 * @return  void
1354
+	 */
1355
+	public function admin_footer_global()
1356
+	{
1357
+		//dialog container for dialog helper
1358
+		$d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n";
1359
+		$d_cont .= '<div class="ee-notices"></div>';
1360
+		$d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>';
1361
+		$d_cont .= '</div>';
1362
+		echo $d_cont;
1363
+		//help tour stuff?
1364
+		if (isset($this->_help_tour[$this->_req_action])) {
1365
+			echo implode('<br />', $this->_help_tour[$this->_req_action]);
1366
+		}
1367
+		//current set timezone for timezone js
1368
+		echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>';
1369
+	}
1370
+
1371
+
1372
+
1373
+	/**
1374
+	 * This function sees if there is a method for help popup content existing for the given route.  If there is then we'll use the retrieved array to output the content using the template.
1375
+	 * For child classes:
1376
+	 * If you want to have help popups then in your templates or your content you set "triggers" for the content using the "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method for
1377
+	 * the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content for the
1378
+	 * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1379
+	 *    'help_trigger_id' => array(
1380
+	 *        'title' => __('localized title for popup', 'event_espresso'),
1381
+	 *        'content' => __('localized content for popup', 'event_espresso')
1382
+	 *    )
1383
+	 * );
1384
+	 * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1385
+	 *
1386
+	 * @access protected
1387
+	 * @return string content
1388
+	 */
1389
+	protected function _set_help_popup_content($help_array = array(), $display = false)
1390
+	{
1391
+		$content = '';
1392
+		$help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1393
+		$template_path = EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php';
1394
+		//loop through the array and setup content
1395
+		foreach ($help_array as $trigger => $help) {
1396
+			//make sure the array is setup properly
1397
+			if ( ! isset($help['title']) || ! isset($help['content'])) {
1398
+				throw new EE_Error(__('Does not look like the popup content array has been setup correctly.  Might want to double check that.  Read the comments for the _get_help_popup_content method found in "EE_Admin_Page" class',
1399
+						'event_espresso'));
1400
+			}
1401
+			//we're good so let'd setup the template vars and then assign parsed template content to our content.
1402
+			$template_args = array(
1403
+					'help_popup_id'      => $trigger,
1404
+					'help_popup_title'   => $help['title'],
1405
+					'help_popup_content' => $help['content'],
1406
+			);
1407
+			$content .= EEH_Template::display_template($template_path, $template_args, true);
1408
+		}
1409
+		if ($display) {
1410
+			echo $content;
1411
+		} else {
1412
+			return $content;
1413
+		}
1414
+	}
1415
+
1416
+
1417
+
1418
+	/**
1419
+	 * All this does is retrive the help content array if set by the EE_Admin_Page child
1420
+	 *
1421
+	 * @access private
1422
+	 * @return array properly formatted array for help popup content
1423
+	 */
1424
+	private function _get_help_content()
1425
+	{
1426
+		//what is the method we're looking for?
1427
+		$method_name = '_help_popup_content_' . $this->_req_action;
1428
+		//if method doesn't exist let's get out.
1429
+		if ( ! method_exists($this, $method_name)) {
1430
+			return array();
1431
+		}
1432
+		//k we're good to go let's retrieve the help array
1433
+		$help_array = call_user_func(array($this, $method_name));
1434
+		//make sure we've got an array!
1435
+		if ( ! is_array($help_array)) {
1436
+			throw new EE_Error(__('Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.', 'event_espresso'));
1437
+		}
1438
+		return $help_array;
1439
+	}
1440
+
1441
+
1442
+
1443
+	/**
1444
+	 * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1445
+	 * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1446
+	 * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1447
+	 *
1448
+	 * @access protected
1449
+	 * @param string  $trigger_id reference for retrieving the trigger content for the popup
1450
+	 * @param boolean $display    if false then we return the trigger string
1451
+	 * @param array   $dimensions an array of dimensions for the box (array(h,w))
1452
+	 * @return string
1453
+	 */
1454
+	protected function _set_help_trigger($trigger_id, $display = true, $dimensions = array('400', '640'))
1455
+	{
1456
+		if (defined('DOING_AJAX')) {
1457
+			return;
1458
+		}
1459
+		//let's check and see if there is any content set for this popup.  If there isn't then we'll include a default title and content so that developers know something needs to be corrected
1460
+		$help_array = $this->_get_help_content();
1461
+		$help_content = '';
1462
+		if (empty($help_array) || ! isset($help_array[$trigger_id])) {
1463
+			$help_array[$trigger_id] = array(
1464
+					'title'   => __('Missing Content', 'event_espresso'),
1465
+					'content' => __('A trigger has been set that doesn\'t have any corresponding content. Make sure you have set the help content. (see the "_set_help_popup_content" method in the EE_Admin_Page for instructions.)',
1466
+							'event_espresso'),
1467
+			);
1468
+			$help_content = $this->_set_help_popup_content($help_array, false);
1469
+		}
1470
+		//let's setup the trigger
1471
+		$content = '<a class="ee-dialog" href="?height=' . $dimensions[0] . '&width=' . $dimensions[1] . '&inlineId=' . $trigger_id . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1472
+		$content = $content . $help_content;
1473
+		if ($display) {
1474
+			echo $content;
1475
+		} else {
1476
+			return $content;
1477
+		}
1478
+	}
1479
+
1480
+
1481
+
1482
+	/**
1483
+	 * _add_global_screen_options
1484
+	 * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1485
+	 * This particular method will add_screen_options on ALL EE_Admin Pages
1486
+	 *
1487
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1488
+	 *         see also WP_Screen object documents...
1489
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1490
+	 * @abstract
1491
+	 * @access private
1492
+	 * @return void
1493
+	 */
1494
+	private function _add_global_screen_options()
1495
+	{
1496
+	}
1497
+
1498
+
1499
+
1500
+	/**
1501
+	 * _add_global_feature_pointers
1502
+	 * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1503
+	 * This particular method will implement feature pointers for ALL EE_Admin pages.
1504
+	 * Note: this is just a placeholder for now.  Implementation will come down the road
1505
+	 *
1506
+	 * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be extended) also see:
1507
+	 * @link   http://eamann.com/tech/wordpress-portland/
1508
+	 * @abstract
1509
+	 * @access protected
1510
+	 * @return void
1511
+	 */
1512
+	private function _add_global_feature_pointers()
1513
+	{
1514
+	}
1515
+
1516
+
1517
+
1518
+	/**
1519
+	 * load_global_scripts_styles
1520
+	 * The scripts and styles enqueued in here will be loaded on every EE Admin page
1521
+	 *
1522
+	 * @return void
1523
+	 */
1524
+	public function load_global_scripts_styles()
1525
+	{
1526
+		/** STYLES **/
1527
+		// add debugging styles
1528
+		if (WP_DEBUG) {
1529
+			add_action('admin_head', array($this, 'add_xdebug_style'));
1530
+		}
1531
+		//register all styles
1532
+		wp_register_style('espresso-ui-theme', EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION);
1533
+		wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
1534
+		//helpers styles
1535
+		wp_register_style('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css', array(), EVENT_ESPRESSO_VERSION);
1536
+		//enqueue global styles
1537
+		wp_enqueue_style('ee-admin-css');
1538
+		/** SCRIPTS **/
1539
+		//register all scripts
1540
+		wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1541
+		wp_register_script('ee-dialog', EE_ADMIN_URL . 'assets/ee-dialog-helper.js', array('jquery', 'jquery-ui-draggable'), EVENT_ESPRESSO_VERSION, true);
1542
+		wp_register_script('ee_admin_js', EE_ADMIN_URL . 'assets/ee-admin-page.js', array('espresso_core', 'ee-parse-uri', 'ee-dialog'), EVENT_ESPRESSO_VERSION, true);
1543
+		wp_register_script('jquery-ui-timepicker-addon', EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), EVENT_ESPRESSO_VERSION, true);
1544
+		// register jQuery Validate - see /includes/functions/wp_hooks.php
1545
+		add_filter('FHEE_load_jquery_validate', '__return_true');
1546
+		add_filter('FHEE_load_joyride', '__return_true');
1547
+		//script for sorting tables
1548
+		wp_register_script('espresso_ajax_table_sorting', EE_ADMIN_URL . "assets/espresso_ajax_table_sorting.js", array('ee_admin_js', 'jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true);
1549
+		//script for parsing uri's
1550
+		wp_register_script('ee-parse-uri', EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js', array(), EVENT_ESPRESSO_VERSION, true);
1551
+		//and parsing associative serialized form elements
1552
+		wp_register_script('ee-serialize-full-array', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1553
+		//helpers scripts
1554
+		wp_register_script('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1555
+		wp_register_script('ee-moment-core', EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js', array(), EVENT_ESPRESSO_VERSION, true);
1556
+		wp_register_script('ee-moment', EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js', array('ee-moment-core'), EVENT_ESPRESSO_VERSION, true);
1557
+		wp_register_script('ee-datepicker', EE_ADMIN_URL . 'assets/ee-datepicker.js', array('jquery-ui-timepicker-addon', 'ee-moment'), EVENT_ESPRESSO_VERSION, true);
1558
+		//google charts
1559
+		wp_register_script('google-charts', 'https://www.gstatic.com/charts/loader.js', array(), EVENT_ESPRESSO_VERSION, false);
1560
+		//enqueue global scripts
1561
+		//taking care of metaboxes
1562
+		if ((isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes'])) && empty($this->_cpt_route)) {
1563
+			wp_enqueue_script('dashboard');
1564
+		}
1565
+		//enqueue thickbox for ee help popups.  default is to enqueue unless its explicitly set to false since we're assuming all EE pages will have popups
1566
+		if ( ! isset($this->_route_config['has_help_popups']) || (isset($this->_route_config['has_help_popups']) && $this->_route_config['has_help_popups'])) {
1567
+			wp_enqueue_script('ee_admin_js');
1568
+			wp_enqueue_style('ee-admin-css');
1569
+		}
1570
+		//localize script for ajax lazy loading
1571
+		$lazy_loader_container_ids = apply_filters('FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers', array('espresso_news_post_box_content'));
1572
+		wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
1573
+		/**
1574
+		 * help tour stuff
1575
+		 */
1576
+		if ( ! empty($this->_help_tour)) {
1577
+			//register the js for kicking things off
1578
+			wp_enqueue_script('ee-help-tour', EE_ADMIN_URL . 'assets/ee-help-tour.js', array('jquery-joyride'), EVENT_ESPRESSO_VERSION, true);
1579
+			//setup tours for the js tour object
1580
+			foreach ($this->_help_tour['tours'] as $tour) {
1581
+				$tours[] = array(
1582
+						'id'      => $tour->get_slug(),
1583
+						'options' => $tour->get_options(),
1584
+				);
1585
+			}
1586
+			wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours));
1587
+			//admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour
1588
+		}
1589
+	}
1590
+
1591
+
1592
+
1593
+	/**
1594
+	 *        admin_footer_scripts_eei18n_js_strings
1595
+	 *
1596
+	 * @access        public
1597
+	 * @return        void
1598
+	 */
1599
+	public function admin_footer_scripts_eei18n_js_strings()
1600
+	{
1601
+		EE_Registry::$i18n_js_strings['ajax_url'] = WP_AJAX_URL;
1602
+		EE_Registry::$i18n_js_strings['confirm_delete'] = __('Are you absolutely sure you want to delete this item?\nThis action will delete ALL DATA associated with this item!!!\nThis can NOT be undone!!!', 'event_espresso');
1603
+		EE_Registry::$i18n_js_strings['January'] = __('January', 'event_espresso');
1604
+		EE_Registry::$i18n_js_strings['February'] = __('February', 'event_espresso');
1605
+		EE_Registry::$i18n_js_strings['March'] = __('March', 'event_espresso');
1606
+		EE_Registry::$i18n_js_strings['April'] = __('April', 'event_espresso');
1607
+		EE_Registry::$i18n_js_strings['May'] = __('May', 'event_espresso');
1608
+		EE_Registry::$i18n_js_strings['June'] = __('June', 'event_espresso');
1609
+		EE_Registry::$i18n_js_strings['July'] = __('July', 'event_espresso');
1610
+		EE_Registry::$i18n_js_strings['August'] = __('August', 'event_espresso');
1611
+		EE_Registry::$i18n_js_strings['September'] = __('September', 'event_espresso');
1612
+		EE_Registry::$i18n_js_strings['October'] = __('October', 'event_espresso');
1613
+		EE_Registry::$i18n_js_strings['November'] = __('November', 'event_espresso');
1614
+		EE_Registry::$i18n_js_strings['December'] = __('December', 'event_espresso');
1615
+		EE_Registry::$i18n_js_strings['Jan'] = __('Jan', 'event_espresso');
1616
+		EE_Registry::$i18n_js_strings['Feb'] = __('Feb', 'event_espresso');
1617
+		EE_Registry::$i18n_js_strings['Mar'] = __('Mar', 'event_espresso');
1618
+		EE_Registry::$i18n_js_strings['Apr'] = __('Apr', 'event_espresso');
1619
+		EE_Registry::$i18n_js_strings['May'] = __('May', 'event_espresso');
1620
+		EE_Registry::$i18n_js_strings['Jun'] = __('Jun', 'event_espresso');
1621
+		EE_Registry::$i18n_js_strings['Jul'] = __('Jul', 'event_espresso');
1622
+		EE_Registry::$i18n_js_strings['Aug'] = __('Aug', 'event_espresso');
1623
+		EE_Registry::$i18n_js_strings['Sep'] = __('Sep', 'event_espresso');
1624
+		EE_Registry::$i18n_js_strings['Oct'] = __('Oct', 'event_espresso');
1625
+		EE_Registry::$i18n_js_strings['Nov'] = __('Nov', 'event_espresso');
1626
+		EE_Registry::$i18n_js_strings['Dec'] = __('Dec', 'event_espresso');
1627
+		EE_Registry::$i18n_js_strings['Sunday'] = __('Sunday', 'event_espresso');
1628
+		EE_Registry::$i18n_js_strings['Monday'] = __('Monday', 'event_espresso');
1629
+		EE_Registry::$i18n_js_strings['Tuesday'] = __('Tuesday', 'event_espresso');
1630
+		EE_Registry::$i18n_js_strings['Wednesday'] = __('Wednesday', 'event_espresso');
1631
+		EE_Registry::$i18n_js_strings['Thursday'] = __('Thursday', 'event_espresso');
1632
+		EE_Registry::$i18n_js_strings['Friday'] = __('Friday', 'event_espresso');
1633
+		EE_Registry::$i18n_js_strings['Saturday'] = __('Saturday', 'event_espresso');
1634
+		EE_Registry::$i18n_js_strings['Sun'] = __('Sun', 'event_espresso');
1635
+		EE_Registry::$i18n_js_strings['Mon'] = __('Mon', 'event_espresso');
1636
+		EE_Registry::$i18n_js_strings['Tue'] = __('Tue', 'event_espresso');
1637
+		EE_Registry::$i18n_js_strings['Wed'] = __('Wed', 'event_espresso');
1638
+		EE_Registry::$i18n_js_strings['Thu'] = __('Thu', 'event_espresso');
1639
+		EE_Registry::$i18n_js_strings['Fri'] = __('Fri', 'event_espresso');
1640
+		EE_Registry::$i18n_js_strings['Sat'] = __('Sat', 'event_espresso');
1641
+		//setting on espresso_core instead of ee_admin_js because espresso_core is enqueued by the maintenance
1642
+		//admin page when in maintenance mode and ee_admin_js is not loaded then.  This works everywhere else because
1643
+		//espresso_core is listed as a dependency of ee_admin_js.
1644
+		wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings);
1645
+	}
1646
+
1647
+
1648
+
1649
+	/**
1650
+	 *        load enhanced xdebug styles for ppl with failing eyesight
1651
+	 *
1652
+	 * @access        public
1653
+	 * @return        void
1654
+	 */
1655
+	public function add_xdebug_style()
1656
+	{
1657
+		echo '<style>.xdebug-error { font-size:1.5em; }</style>';
1658
+	}
1659
+
1660
+
1661
+	/************************/
1662
+	/** LIST TABLE METHODS **/
1663
+	/************************/
1664
+	/**
1665
+	 * this sets up the list table if the current view requires it.
1666
+	 *
1667
+	 * @access protected
1668
+	 * @return void
1669
+	 */
1670
+	protected function _set_list_table()
1671
+	{
1672
+		//first is this a list_table view?
1673
+		if ( ! isset($this->_route_config['list_table'])) {
1674
+			return;
1675
+		} //not a list_table view so get out.
1676
+		//list table functions are per view specific (because some admin pages might have more than one listtable!)
1677
+		if (call_user_func(array($this, '_set_list_table_views_' . $this->_req_action)) === false) {
1678
+			//user error msg
1679
+			$error_msg = __('An error occurred. The requested list table views could not be found.', 'event_espresso');
1680
+			//developer error msg
1681
+			$error_msg .= '||' . sprintf(__('List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.', 'event_espresso'),
1682
+							$this->_req_action, '_set_list_table_views_' . $this->_req_action);
1683
+			throw new EE_Error($error_msg);
1684
+		}
1685
+		//let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
1686
+		$this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action, $this->_views);
1687
+		$this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
1688
+		$this->_views = apply_filters('FHEE_list_table_views', $this->_views);
1689
+		$this->_set_list_table_view();
1690
+		$this->_set_list_table_object();
1691
+	}
1692
+
1693
+
1694
+
1695
+	/**
1696
+	 *        set current view for List Table
1697
+	 *
1698
+	 * @access public
1699
+	 * @return array
1700
+	 */
1701
+	protected function _set_list_table_view()
1702
+	{
1703
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1704
+		// looking at active items or dumpster diving ?
1705
+		if ( ! isset($this->_req_data['status']) || ! array_key_exists($this->_req_data['status'], $this->_views)) {
1706
+			$this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
1707
+		} else {
1708
+			$this->_view = sanitize_key($this->_req_data['status']);
1709
+		}
1710
+	}
1711
+
1712
+
1713
+
1714
+	/**
1715
+	 * _set_list_table_object
1716
+	 * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
1717
+	 *
1718
+	 * @throws \EE_Error
1719
+	 */
1720
+	protected function _set_list_table_object()
1721
+	{
1722
+		if (isset($this->_route_config['list_table'])) {
1723
+			if ( ! class_exists($this->_route_config['list_table'])) {
1724
+				throw new EE_Error(
1725
+						sprintf(
1726
+								__(
1727
+										'The %s class defined for the list table does not exist.  Please check the spelling of the class ref in the $_page_config property on %s.',
1728
+										'event_espresso'
1729
+								),
1730
+								$this->_route_config['list_table'],
1731
+								get_class($this)
1732
+						)
1733
+				);
1734
+			}
1735
+			$list_table = $this->_route_config['list_table'];
1736
+			$this->_list_table_object = new $list_table($this);
1737
+		}
1738
+	}
1739
+
1740
+
1741
+
1742
+	/**
1743
+	 * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
1744
+	 *
1745
+	 * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
1746
+	 *                                                    urls.  The array should be indexed by the view it is being
1747
+	 *                                                    added to.
1748
+	 * @return array
1749
+	 */
1750
+	public function get_list_table_view_RLs($extra_query_args = array())
1751
+	{
1752
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1753
+		if (empty($this->_views)) {
1754
+			$this->_views = array();
1755
+		}
1756
+		// cycle thru views
1757
+		foreach ($this->_views as $key => $view) {
1758
+			$query_args = array();
1759
+			// check for current view
1760
+			$this->_views[$key]['class'] = $this->_view == $view['slug'] ? 'current' : '';
1761
+			$query_args['action'] = $this->_req_action;
1762
+			$query_args[$this->_req_action . '_nonce'] = wp_create_nonce($query_args['action'] . '_nonce');
1763
+			$query_args['status'] = $view['slug'];
1764
+			//merge any other arguments sent in.
1765
+			if (isset($extra_query_args[$view['slug']])) {
1766
+				$query_args = array_merge($query_args, $extra_query_args[$view['slug']]);
1767
+			}
1768
+			$this->_views[$key]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
1769
+		}
1770
+		return $this->_views;
1771
+	}
1772
+
1773
+
1774
+
1775
+	/**
1776
+	 * _entries_per_page_dropdown
1777
+	 * generates a drop down box for selecting the number of visiable rows in an admin page list table
1778
+	 *
1779
+	 * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how WP does it.
1780
+	 * @access protected
1781
+	 * @param int $max_entries total number of rows in the table
1782
+	 * @return string
1783
+	 */
1784
+	protected function _entries_per_page_dropdown($max_entries = false)
1785
+	{
1786
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1787
+		$values = array(10, 25, 50, 100);
1788
+		$per_page = ( ! empty($this->_req_data['per_page'])) ? absint($this->_req_data['per_page']) : 10;
1789
+		if ($max_entries) {
1790
+			$values[] = $max_entries;
1791
+			sort($values);
1792
+		}
1793
+		$entries_per_page_dropdown = '
1794 1794
 			<div id="entries-per-page-dv" class="alignleft actions">
1795 1795
 				<label class="hide-if-no-js">
1796 1796
 					Show
1797 1797
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
1798
-        foreach ($values as $value) {
1799
-            if ($value < $max_entries) {
1800
-                $selected = $value == $per_page ? ' selected="' . $per_page . '"' : '';
1801
-                $entries_per_page_dropdown .= '
1798
+		foreach ($values as $value) {
1799
+			if ($value < $max_entries) {
1800
+				$selected = $value == $per_page ? ' selected="' . $per_page . '"' : '';
1801
+				$entries_per_page_dropdown .= '
1802 1802
 						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
1803
-            }
1804
-        }
1805
-        $selected = $max_entries == $per_page ? ' selected="' . $per_page . '"' : '';
1806
-        $entries_per_page_dropdown .= '
1803
+			}
1804
+		}
1805
+		$selected = $max_entries == $per_page ? ' selected="' . $per_page . '"' : '';
1806
+		$entries_per_page_dropdown .= '
1807 1807
 						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
1808
-        $entries_per_page_dropdown .= '
1808
+		$entries_per_page_dropdown .= '
1809 1809
 					</select>
1810 1810
 					entries
1811 1811
 				</label>
1812 1812
 				<input id="entries-per-page-btn" class="button-secondary" type="submit" value="Go" >
1813 1813
 			</div>
1814 1814
 		';
1815
-        return $entries_per_page_dropdown;
1816
-    }
1817
-
1818
-
1819
-
1820
-    /**
1821
-     *        _set_search_attributes
1822
-     *
1823
-     * @access        protected
1824
-     * @return        void
1825
-     */
1826
-    public function _set_search_attributes()
1827
-    {
1828
-        $this->_template_args['search']['btn_label'] = sprintf(__('Search %s', 'event_espresso'), empty($this->_search_btn_label) ? $this->page_label : $this->_search_btn_label);
1829
-        $this->_template_args['search']['callback'] = 'search_' . $this->page_slug;
1830
-    }
1831
-
1832
-    /*** END LIST TABLE METHODS **/
1833
-    /*****************************/
1834
-    /**
1835
-     *        _add_registered_metaboxes
1836
-     *        this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
1837
-     *
1838
-     * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
1839
-     * @access private
1840
-     * @return void
1841
-     */
1842
-    private function _add_registered_meta_boxes()
1843
-    {
1844
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1845
-        //we only add meta boxes if the page_route calls for it
1846
-        if (is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
1847
-            && is_array(
1848
-                    $this->_route_config['metaboxes']
1849
-            )
1850
-        ) {
1851
-            // this simply loops through the callbacks provided
1852
-            // and checks if there is a corresponding callback registered by the child
1853
-            // if there is then we go ahead and process the metabox loader.
1854
-            foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
1855
-                // first check for Closures
1856
-                if ($metabox_callback instanceof Closure) {
1857
-                    $result = $metabox_callback();
1858
-                } else if (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
1859
-                    $result = call_user_func(array($metabox_callback[0], $metabox_callback[1]));
1860
-                } else {
1861
-                    $result = call_user_func(array($this, &$metabox_callback));
1862
-                }
1863
-                if ($result === false) {
1864
-                    // user error msg
1865
-                    $error_msg = __('An error occurred. The  requested metabox could not be found.', 'event_espresso');
1866
-                    // developer error msg
1867
-                    $error_msg .= '||' . sprintf(
1868
-                                    __(
1869
-                                            'The metabox with the string "%s" could not be called. Check that the spelling for method names and actions in the "_page_config[\'metaboxes\']" array are all correct.',
1870
-                                            'event_espresso'
1871
-                                    ),
1872
-                                    $metabox_callback
1873
-                            );
1874
-                    throw new EE_Error($error_msg);
1875
-                }
1876
-            }
1877
-        }
1878
-    }
1879
-
1880
-
1881
-
1882
-    /**
1883
-     * _add_screen_columns
1884
-     * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as the dynamic column template and we'll setup the column options for the page.
1885
-     *
1886
-     * @access private
1887
-     * @return void
1888
-     */
1889
-    private function _add_screen_columns()
1890
-    {
1891
-        if (
1892
-                is_array($this->_route_config)
1893
-                && isset($this->_route_config['columns'])
1894
-                && is_array($this->_route_config['columns'])
1895
-                && count($this->_route_config['columns']) === 2
1896
-        ) {
1897
-            add_screen_option('layout_columns', array('max' => (int)$this->_route_config['columns'][0], 'default' => (int)$this->_route_config['columns'][1]));
1898
-            $this->_template_args['num_columns'] = $this->_route_config['columns'][0];
1899
-            $screen_id = $this->_current_screen->id;
1900
-            $screen_columns = (int)get_user_option("screen_layout_$screen_id");
1901
-            $total_columns = ! empty($screen_columns) ? $screen_columns : $this->_route_config['columns'][1];
1902
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
1903
-            $this->_template_args['current_page'] = $this->_wp_page_slug;
1904
-            $this->_template_args['screen'] = $this->_current_screen;
1905
-            $this->_column_template_path = EE_ADMIN_TEMPLATE . 'admin_details_metabox_column_wrapper.template.php';
1906
-            //finally if we don't have has_metaboxes set in the route config let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
1907
-            $this->_route_config['has_metaboxes'] = true;
1908
-        }
1909
-    }
1910
-
1911
-
1912
-
1913
-    /**********************************/
1914
-    /** GLOBALLY AVAILABLE METABOXES **/
1915
-    /**
1916
-     * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply referencing the callback in the _page_config array property.  This way you can be very specific about what pages these get
1917
-     * loaded on.
1918
-     */
1919
-    private function _espresso_news_post_box()
1920
-    {
1921
-        $news_box_title = apply_filters('FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title', __('New @ Event Espresso', 'event_espresso'));
1922
-        add_meta_box('espresso_news_post_box', $news_box_title, array(
1923
-                $this,
1924
-                'espresso_news_post_box',
1925
-        ), $this->_wp_page_slug, 'side');
1926
-    }
1927
-
1928
-
1929
-
1930
-    /**
1931
-     * Code for setting up espresso ratings request metabox.
1932
-     */
1933
-    protected function _espresso_ratings_request()
1934
-    {
1935
-        if ( ! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
1936
-            return '';
1937
-        }
1938
-        $ratings_box_title = apply_filters('FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title', __('Keep Event Espresso Decaf Free', 'event_espresso'));
1939
-        add_meta_box('espresso_ratings_request', $ratings_box_title, array(
1940
-                $this,
1941
-                'espresso_ratings_request',
1942
-        ), $this->_wp_page_slug, 'side');
1943
-    }
1944
-
1945
-
1946
-
1947
-    /**
1948
-     * Code for setting up espresso ratings request metabox content.
1949
-     */
1950
-    public function espresso_ratings_request()
1951
-    {
1952
-        $template_path = EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php';
1953
-        EEH_Template::display_template($template_path, array());
1954
-    }
1955
-
1956
-
1957
-
1958
-    public static function cached_rss_display($rss_id, $url)
1959
-    {
1960
-        $loading = '<p class="widget-loading hide-if-no-js">' . __('Loading&#8230;') . '</p><p class="hide-if-js">' . __('This widget requires JavaScript.') . '</p>';
1961
-        $doing_ajax = (defined('DOING_AJAX') && DOING_AJAX);
1962
-        $pre = '<div class="espresso-rss-display">' . "\n\t";
1963
-        $pre .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>';
1964
-        $post = '</div>' . "\n";
1965
-        $cache_key = 'ee_rss_' . md5($rss_id);
1966
-        if (false != ($output = get_transient($cache_key))) {
1967
-            echo $pre . $output . $post;
1968
-            return true;
1969
-        }
1970
-        if ( ! $doing_ajax) {
1971
-            echo $pre . $loading . $post;
1972
-            return false;
1973
-        }
1974
-        ob_start();
1975
-        wp_widget_rss_output($url, array('show_date' => 0, 'items' => 5));
1976
-        set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
1977
-        return true;
1978
-    }
1979
-
1980
-
1981
-
1982
-    public function espresso_news_post_box()
1983
-    {
1984
-        ?>
1815
+		return $entries_per_page_dropdown;
1816
+	}
1817
+
1818
+
1819
+
1820
+	/**
1821
+	 *        _set_search_attributes
1822
+	 *
1823
+	 * @access        protected
1824
+	 * @return        void
1825
+	 */
1826
+	public function _set_search_attributes()
1827
+	{
1828
+		$this->_template_args['search']['btn_label'] = sprintf(__('Search %s', 'event_espresso'), empty($this->_search_btn_label) ? $this->page_label : $this->_search_btn_label);
1829
+		$this->_template_args['search']['callback'] = 'search_' . $this->page_slug;
1830
+	}
1831
+
1832
+	/*** END LIST TABLE METHODS **/
1833
+	/*****************************/
1834
+	/**
1835
+	 *        _add_registered_metaboxes
1836
+	 *        this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
1837
+	 *
1838
+	 * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
1839
+	 * @access private
1840
+	 * @return void
1841
+	 */
1842
+	private function _add_registered_meta_boxes()
1843
+	{
1844
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1845
+		//we only add meta boxes if the page_route calls for it
1846
+		if (is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
1847
+			&& is_array(
1848
+					$this->_route_config['metaboxes']
1849
+			)
1850
+		) {
1851
+			// this simply loops through the callbacks provided
1852
+			// and checks if there is a corresponding callback registered by the child
1853
+			// if there is then we go ahead and process the metabox loader.
1854
+			foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
1855
+				// first check for Closures
1856
+				if ($metabox_callback instanceof Closure) {
1857
+					$result = $metabox_callback();
1858
+				} else if (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
1859
+					$result = call_user_func(array($metabox_callback[0], $metabox_callback[1]));
1860
+				} else {
1861
+					$result = call_user_func(array($this, &$metabox_callback));
1862
+				}
1863
+				if ($result === false) {
1864
+					// user error msg
1865
+					$error_msg = __('An error occurred. The  requested metabox could not be found.', 'event_espresso');
1866
+					// developer error msg
1867
+					$error_msg .= '||' . sprintf(
1868
+									__(
1869
+											'The metabox with the string "%s" could not be called. Check that the spelling for method names and actions in the "_page_config[\'metaboxes\']" array are all correct.',
1870
+											'event_espresso'
1871
+									),
1872
+									$metabox_callback
1873
+							);
1874
+					throw new EE_Error($error_msg);
1875
+				}
1876
+			}
1877
+		}
1878
+	}
1879
+
1880
+
1881
+
1882
+	/**
1883
+	 * _add_screen_columns
1884
+	 * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as the dynamic column template and we'll setup the column options for the page.
1885
+	 *
1886
+	 * @access private
1887
+	 * @return void
1888
+	 */
1889
+	private function _add_screen_columns()
1890
+	{
1891
+		if (
1892
+				is_array($this->_route_config)
1893
+				&& isset($this->_route_config['columns'])
1894
+				&& is_array($this->_route_config['columns'])
1895
+				&& count($this->_route_config['columns']) === 2
1896
+		) {
1897
+			add_screen_option('layout_columns', array('max' => (int)$this->_route_config['columns'][0], 'default' => (int)$this->_route_config['columns'][1]));
1898
+			$this->_template_args['num_columns'] = $this->_route_config['columns'][0];
1899
+			$screen_id = $this->_current_screen->id;
1900
+			$screen_columns = (int)get_user_option("screen_layout_$screen_id");
1901
+			$total_columns = ! empty($screen_columns) ? $screen_columns : $this->_route_config['columns'][1];
1902
+			$this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
1903
+			$this->_template_args['current_page'] = $this->_wp_page_slug;
1904
+			$this->_template_args['screen'] = $this->_current_screen;
1905
+			$this->_column_template_path = EE_ADMIN_TEMPLATE . 'admin_details_metabox_column_wrapper.template.php';
1906
+			//finally if we don't have has_metaboxes set in the route config let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
1907
+			$this->_route_config['has_metaboxes'] = true;
1908
+		}
1909
+	}
1910
+
1911
+
1912
+
1913
+	/**********************************/
1914
+	/** GLOBALLY AVAILABLE METABOXES **/
1915
+	/**
1916
+	 * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply referencing the callback in the _page_config array property.  This way you can be very specific about what pages these get
1917
+	 * loaded on.
1918
+	 */
1919
+	private function _espresso_news_post_box()
1920
+	{
1921
+		$news_box_title = apply_filters('FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title', __('New @ Event Espresso', 'event_espresso'));
1922
+		add_meta_box('espresso_news_post_box', $news_box_title, array(
1923
+				$this,
1924
+				'espresso_news_post_box',
1925
+		), $this->_wp_page_slug, 'side');
1926
+	}
1927
+
1928
+
1929
+
1930
+	/**
1931
+	 * Code for setting up espresso ratings request metabox.
1932
+	 */
1933
+	protected function _espresso_ratings_request()
1934
+	{
1935
+		if ( ! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
1936
+			return '';
1937
+		}
1938
+		$ratings_box_title = apply_filters('FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title', __('Keep Event Espresso Decaf Free', 'event_espresso'));
1939
+		add_meta_box('espresso_ratings_request', $ratings_box_title, array(
1940
+				$this,
1941
+				'espresso_ratings_request',
1942
+		), $this->_wp_page_slug, 'side');
1943
+	}
1944
+
1945
+
1946
+
1947
+	/**
1948
+	 * Code for setting up espresso ratings request metabox content.
1949
+	 */
1950
+	public function espresso_ratings_request()
1951
+	{
1952
+		$template_path = EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php';
1953
+		EEH_Template::display_template($template_path, array());
1954
+	}
1955
+
1956
+
1957
+
1958
+	public static function cached_rss_display($rss_id, $url)
1959
+	{
1960
+		$loading = '<p class="widget-loading hide-if-no-js">' . __('Loading&#8230;') . '</p><p class="hide-if-js">' . __('This widget requires JavaScript.') . '</p>';
1961
+		$doing_ajax = (defined('DOING_AJAX') && DOING_AJAX);
1962
+		$pre = '<div class="espresso-rss-display">' . "\n\t";
1963
+		$pre .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>';
1964
+		$post = '</div>' . "\n";
1965
+		$cache_key = 'ee_rss_' . md5($rss_id);
1966
+		if (false != ($output = get_transient($cache_key))) {
1967
+			echo $pre . $output . $post;
1968
+			return true;
1969
+		}
1970
+		if ( ! $doing_ajax) {
1971
+			echo $pre . $loading . $post;
1972
+			return false;
1973
+		}
1974
+		ob_start();
1975
+		wp_widget_rss_output($url, array('show_date' => 0, 'items' => 5));
1976
+		set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
1977
+		return true;
1978
+	}
1979
+
1980
+
1981
+
1982
+	public function espresso_news_post_box()
1983
+	{
1984
+		?>
1985 1985
         <div class="padding">
1986 1986
             <div id="espresso_news_post_box_content" class="infolinks">
1987 1987
                 <?php
1988
-                // Get RSS Feed(s)
1989
-                $feed_url = apply_filters('FHEE__EE_Admin_Page__espresso_news_post_box__feed_url', 'http://eventespresso.com/feed/');
1990
-                $url = urlencode($feed_url);
1991
-                self::cached_rss_display('espresso_news_post_box_content', $url);
1992
-                ?>
1988
+				// Get RSS Feed(s)
1989
+				$feed_url = apply_filters('FHEE__EE_Admin_Page__espresso_news_post_box__feed_url', 'http://eventespresso.com/feed/');
1990
+				$url = urlencode($feed_url);
1991
+				self::cached_rss_display('espresso_news_post_box_content', $url);
1992
+				?>
1993 1993
             </div>
1994 1994
             <?php do_action('AHEE__EE_Admin_Page__espresso_news_post_box__after_content'); ?>
1995 1995
         </div>
1996 1996
         <?php
1997
-    }
1998
-
1999
-
2000
-
2001
-    private function _espresso_links_post_box()
2002
-    {
2003
-        //Hiding until we actually have content to put in here...
2004
-        //add_meta_box('espresso_links_post_box', __('Helpful Plugin Links', 'event_espresso'), array( $this, 'espresso_links_post_box'), $this->_wp_page_slug, 'side');
2005
-    }
2006
-
2007
-
2008
-
2009
-    public function espresso_links_post_box()
2010
-    {
2011
-        //Hiding until we actually have content to put in here...
2012
-        //$templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php';
2013
-        //EEH_Template::display_template( $templatepath );
2014
-    }
2015
-
2016
-
2017
-
2018
-    protected function _espresso_sponsors_post_box()
2019
-    {
2020
-        $show_sponsors = apply_filters('FHEE_show_sponsors_meta_box', true);
2021
-        if ($show_sponsors) {
2022
-            add_meta_box('espresso_sponsors_post_box', __('Event Espresso Highlights', 'event_espresso'), array($this, 'espresso_sponsors_post_box'), $this->_wp_page_slug, 'side');
2023
-        }
2024
-    }
2025
-
2026
-
2027
-
2028
-    public function espresso_sponsors_post_box()
2029
-    {
2030
-        $templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php';
2031
-        EEH_Template::display_template($templatepath);
2032
-    }
2033
-
2034
-
2035
-
2036
-    private function _publish_post_box()
2037
-    {
2038
-        $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2039
-        //if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array then we'll use that for the metabox label.  Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2040
-        if ( ! empty($this->_labels['publishbox'])) {
2041
-            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][$this->_req_action] : $this->_labels['publishbox'];
2042
-        } else {
2043
-            $box_label = __('Publish', 'event_espresso');
2044
-        }
2045
-        $box_label = apply_filters('FHEE__EE_Admin_Page___publish_post_box__box_label', $box_label, $this->_req_action, $this);
2046
-        add_meta_box($meta_box_ref, $box_label, array($this, 'editor_overview'), $this->_current_screen->id, 'side', 'high');
2047
-    }
2048
-
2049
-
2050
-
2051
-    public function editor_overview()
2052
-    {
2053
-        //if we have extra content set let's add it in if not make sure its empty
2054
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content']) ? $this->_template_args['publish_box_extra_content'] : '';
2055
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php';
2056
-        echo EEH_Template::display_template($template_path, $this->_template_args, true);
2057
-    }
2058
-
2059
-
2060
-    /** end of globally available metaboxes section **/
2061
-    /*************************************************/
2062
-    /**
2063
-     * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2064
-     * protected method.
2065
-     *
2066
-     * @see   $this->_set_publish_post_box_vars for param details
2067
-     * @since 4.6.0
2068
-     */
2069
-    public function set_publish_post_box_vars($name = null, $id = false, $delete = false, $save_close_redirect_URL = null, $both_btns = true)
2070
-    {
2071
-        $this->_set_publish_post_box_vars($name, $id, $delete, $save_close_redirect_URL, $both_btns);
2072
-    }
2073
-
2074
-
2075
-
2076
-    /**
2077
-     * Sets the _template_args arguments used by the _publish_post_box shortcut
2078
-     * Note: currently there is no validation for this.  However if you want the delete button, the
2079
-     * save, and save and close buttons to work properly, then you will want to include a
2080
-     * values for the name and id arguments.
2081
-     *
2082
-     * @todo  Add in validation for name/id arguments.
2083
-     * @param    string  $name                    key used for the action ID (i.e. event_id)
2084
-     * @param    int     $id                      id attached to the item published
2085
-     * @param    string  $delete                  page route callback for the delete action
2086
-     * @param    string  $save_close_redirect_URL custom URL to redirect to after Save & Close has been completed
2087
-     * @param    boolean $both_btns               whether to display BOTH the "Save & Close" and "Save" buttons or just the Save button
2088
-     * @throws \EE_Error
2089
-     */
2090
-    protected function _set_publish_post_box_vars(
2091
-            $name = '',
2092
-            $id = 0,
2093
-            $delete = '',
2094
-            $save_close_redirect_URL = '',
2095
-            $both_btns = true
2096
-    ) {
2097
-        // if Save & Close, use a custom redirect URL or default to the main page?
2098
-        $save_close_redirect_URL = ! empty($save_close_redirect_URL) ? $save_close_redirect_URL : $this->_admin_base_url;
2099
-        // create the Save & Close and Save buttons
2100
-        $this->_set_save_buttons($both_btns, array(), array(), $save_close_redirect_URL);
2101
-        //if we have extra content set let's add it in if not make sure its empty
2102
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content']) ? $this->_template_args['publish_box_extra_content'] : '';
2103
-        if ($delete && ! empty($id)) {
2104
-            //make sure we have a default if just true is sent.
2105
-            $delete = ! empty($delete) ? $delete : 'delete';
2106
-            $delete_link_args = array($name => $id);
2107
-            $delete = $this->get_action_link_or_button(
2108
-                    $delete,
2109
-                    $delete,
2110
-                    $delete_link_args,
2111
-                    'submitdelete deletion',
2112
-                    '',
2113
-                    false
2114
-            );
2115
-        }
2116
-        $this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2117
-        if ( ! empty($name) && ! empty($id)) {
2118
-            $hidden_field_arr[$name] = array(
2119
-                    'type'  => 'hidden',
2120
-                    'value' => $id,
2121
-            );
2122
-            $hf = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2123
-        } else {
2124
-            $hf = '';
2125
-        }
2126
-        // add hidden field
2127
-        $this->_template_args['publish_hidden_fields'] = ! empty($hf) ? $hf[$name]['field'] : $hf;
2128
-    }
2129
-
2130
-
2131
-
2132
-    /**
2133
-     *        displays an error message to ppl who have javascript disabled
2134
-     *
2135
-     * @access        private
2136
-     * @return        string
2137
-     */
2138
-    private function _display_no_javascript_warning()
2139
-    {
2140
-        ?>
1997
+	}
1998
+
1999
+
2000
+
2001
+	private function _espresso_links_post_box()
2002
+	{
2003
+		//Hiding until we actually have content to put in here...
2004
+		//add_meta_box('espresso_links_post_box', __('Helpful Plugin Links', 'event_espresso'), array( $this, 'espresso_links_post_box'), $this->_wp_page_slug, 'side');
2005
+	}
2006
+
2007
+
2008
+
2009
+	public function espresso_links_post_box()
2010
+	{
2011
+		//Hiding until we actually have content to put in here...
2012
+		//$templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php';
2013
+		//EEH_Template::display_template( $templatepath );
2014
+	}
2015
+
2016
+
2017
+
2018
+	protected function _espresso_sponsors_post_box()
2019
+	{
2020
+		$show_sponsors = apply_filters('FHEE_show_sponsors_meta_box', true);
2021
+		if ($show_sponsors) {
2022
+			add_meta_box('espresso_sponsors_post_box', __('Event Espresso Highlights', 'event_espresso'), array($this, 'espresso_sponsors_post_box'), $this->_wp_page_slug, 'side');
2023
+		}
2024
+	}
2025
+
2026
+
2027
+
2028
+	public function espresso_sponsors_post_box()
2029
+	{
2030
+		$templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php';
2031
+		EEH_Template::display_template($templatepath);
2032
+	}
2033
+
2034
+
2035
+
2036
+	private function _publish_post_box()
2037
+	{
2038
+		$meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2039
+		//if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array then we'll use that for the metabox label.  Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2040
+		if ( ! empty($this->_labels['publishbox'])) {
2041
+			$box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][$this->_req_action] : $this->_labels['publishbox'];
2042
+		} else {
2043
+			$box_label = __('Publish', 'event_espresso');
2044
+		}
2045
+		$box_label = apply_filters('FHEE__EE_Admin_Page___publish_post_box__box_label', $box_label, $this->_req_action, $this);
2046
+		add_meta_box($meta_box_ref, $box_label, array($this, 'editor_overview'), $this->_current_screen->id, 'side', 'high');
2047
+	}
2048
+
2049
+
2050
+
2051
+	public function editor_overview()
2052
+	{
2053
+		//if we have extra content set let's add it in if not make sure its empty
2054
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content']) ? $this->_template_args['publish_box_extra_content'] : '';
2055
+		$template_path = EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php';
2056
+		echo EEH_Template::display_template($template_path, $this->_template_args, true);
2057
+	}
2058
+
2059
+
2060
+	/** end of globally available metaboxes section **/
2061
+	/*************************************************/
2062
+	/**
2063
+	 * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2064
+	 * protected method.
2065
+	 *
2066
+	 * @see   $this->_set_publish_post_box_vars for param details
2067
+	 * @since 4.6.0
2068
+	 */
2069
+	public function set_publish_post_box_vars($name = null, $id = false, $delete = false, $save_close_redirect_URL = null, $both_btns = true)
2070
+	{
2071
+		$this->_set_publish_post_box_vars($name, $id, $delete, $save_close_redirect_URL, $both_btns);
2072
+	}
2073
+
2074
+
2075
+
2076
+	/**
2077
+	 * Sets the _template_args arguments used by the _publish_post_box shortcut
2078
+	 * Note: currently there is no validation for this.  However if you want the delete button, the
2079
+	 * save, and save and close buttons to work properly, then you will want to include a
2080
+	 * values for the name and id arguments.
2081
+	 *
2082
+	 * @todo  Add in validation for name/id arguments.
2083
+	 * @param    string  $name                    key used for the action ID (i.e. event_id)
2084
+	 * @param    int     $id                      id attached to the item published
2085
+	 * @param    string  $delete                  page route callback for the delete action
2086
+	 * @param    string  $save_close_redirect_URL custom URL to redirect to after Save & Close has been completed
2087
+	 * @param    boolean $both_btns               whether to display BOTH the "Save & Close" and "Save" buttons or just the Save button
2088
+	 * @throws \EE_Error
2089
+	 */
2090
+	protected function _set_publish_post_box_vars(
2091
+			$name = '',
2092
+			$id = 0,
2093
+			$delete = '',
2094
+			$save_close_redirect_URL = '',
2095
+			$both_btns = true
2096
+	) {
2097
+		// if Save & Close, use a custom redirect URL or default to the main page?
2098
+		$save_close_redirect_URL = ! empty($save_close_redirect_URL) ? $save_close_redirect_URL : $this->_admin_base_url;
2099
+		// create the Save & Close and Save buttons
2100
+		$this->_set_save_buttons($both_btns, array(), array(), $save_close_redirect_URL);
2101
+		//if we have extra content set let's add it in if not make sure its empty
2102
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content']) ? $this->_template_args['publish_box_extra_content'] : '';
2103
+		if ($delete && ! empty($id)) {
2104
+			//make sure we have a default if just true is sent.
2105
+			$delete = ! empty($delete) ? $delete : 'delete';
2106
+			$delete_link_args = array($name => $id);
2107
+			$delete = $this->get_action_link_or_button(
2108
+					$delete,
2109
+					$delete,
2110
+					$delete_link_args,
2111
+					'submitdelete deletion',
2112
+					'',
2113
+					false
2114
+			);
2115
+		}
2116
+		$this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2117
+		if ( ! empty($name) && ! empty($id)) {
2118
+			$hidden_field_arr[$name] = array(
2119
+					'type'  => 'hidden',
2120
+					'value' => $id,
2121
+			);
2122
+			$hf = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2123
+		} else {
2124
+			$hf = '';
2125
+		}
2126
+		// add hidden field
2127
+		$this->_template_args['publish_hidden_fields'] = ! empty($hf) ? $hf[$name]['field'] : $hf;
2128
+	}
2129
+
2130
+
2131
+
2132
+	/**
2133
+	 *        displays an error message to ppl who have javascript disabled
2134
+	 *
2135
+	 * @access        private
2136
+	 * @return        string
2137
+	 */
2138
+	private function _display_no_javascript_warning()
2139
+	{
2140
+		?>
2141 2141
         <noscript>
2142 2142
             <div id="no-js-message" class="error">
2143 2143
                 <p style="font-size:1.3em;">
@@ -2147,1251 +2147,1251 @@  discard block
 block discarded – undo
2147 2147
             </div>
2148 2148
         </noscript>
2149 2149
         <?php
2150
-    }
2150
+	}
2151 2151
 
2152 2152
 
2153 2153
 
2154
-    /**
2155
-     *        displays espresso success and/or error notices
2156
-     *
2157
-     * @access        private
2158
-     * @return        string
2159
-     */
2160
-    private function _display_espresso_notices()
2161
-    {
2162
-        $notices = $this->_get_transient(true);
2163
-        echo stripslashes($notices);
2164
-    }
2154
+	/**
2155
+	 *        displays espresso success and/or error notices
2156
+	 *
2157
+	 * @access        private
2158
+	 * @return        string
2159
+	 */
2160
+	private function _display_espresso_notices()
2161
+	{
2162
+		$notices = $this->_get_transient(true);
2163
+		echo stripslashes($notices);
2164
+	}
2165 2165
 
2166 2166
 
2167 2167
 
2168
-    /**
2169
-     *        spinny things pacify the masses
2170
-     *
2171
-     * @access private
2172
-     * @return string
2173
-     */
2174
-    protected function _add_admin_page_ajax_loading_img()
2175
-    {
2176
-        ?>
2168
+	/**
2169
+	 *        spinny things pacify the masses
2170
+	 *
2171
+	 * @access private
2172
+	 * @return string
2173
+	 */
2174
+	protected function _add_admin_page_ajax_loading_img()
2175
+	{
2176
+		?>
2177 2177
         <div id="espresso-ajax-loading" class="ajax-loading-grey">
2178 2178
             <span class="ee-spinner ee-spin"></span><span class="hidden"><?php _e('loading...', 'event_espresso'); ?></span>
2179 2179
         </div>
2180 2180
         <?php
2181
-    }
2181
+	}
2182 2182
 
2183 2183
 
2184 2184
 
2185
-    /**
2186
-     *        add admin page overlay for modal boxes
2187
-     *
2188
-     * @access private
2189
-     * @return string
2190
-     */
2191
-    protected function _add_admin_page_overlay()
2192
-    {
2193
-        ?>
2185
+	/**
2186
+	 *        add admin page overlay for modal boxes
2187
+	 *
2188
+	 * @access private
2189
+	 * @return string
2190
+	 */
2191
+	protected function _add_admin_page_overlay()
2192
+	{
2193
+		?>
2194 2194
         <div id="espresso-admin-page-overlay-dv" class=""></div>
2195 2195
         <?php
2196
-    }
2197
-
2198
-
2199
-
2200
-    /**
2201
-     * facade for add_meta_box
2202
-     *
2203
-     * @param string  $action        where the metabox get's displayed
2204
-     * @param string  $title         Title of Metabox (output in metabox header)
2205
-     * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback instead of the one created in here.
2206
-     * @param array   $callback_args an array of args supplied for the metabox
2207
-     * @param string  $column        what metabox column
2208
-     * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2209
-     * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function created but just set our own callback for wp's add_meta_box.
2210
-     */
2211
-    public function _add_admin_page_meta_box($action, $title, $callback, $callback_args, $column = 'normal', $priority = 'high', $create_func = true)
2212
-    {
2213
-        do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2214
-        //if we have empty callback args and we want to automatically create the metabox callback then we need to make sure the callback args are generated.
2215
-        if (empty($callback_args) && $create_func) {
2216
-            $callback_args = array(
2217
-                    'template_path' => $this->_template_path,
2218
-                    'template_args' => $this->_template_args,
2219
-            );
2220
-        }
2221
-        //if $create_func is true (default) then we automatically create the function for displaying the actual meta box.  If false then we take the $callback reference passed through and use it instead (so callers can define their own callback function/method if they wish)
2222
-        $call_back_func = $create_func ? create_function('$post, $metabox',
2223
-                'do_action( "AHEE_log", __FILE__, __FUNCTION__, ""); echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );') : $callback;
2224
-        add_meta_box(str_replace('_', '-', $action) . '-mbox', $title, $call_back_func, $this->_wp_page_slug, $column, $priority, $callback_args);
2225
-    }
2226
-
2227
-
2228
-
2229
-    /**
2230
-     * generates HTML wrapper for and admin details page that contains metaboxes in columns
2231
-     *
2232
-     * @return [type] [description]
2233
-     */
2234
-    public function display_admin_page_with_metabox_columns()
2235
-    {
2236
-        $this->_template_args['post_body_content'] = $this->_template_args['admin_page_content'];
2237
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_column_template_path, $this->_template_args, true);
2238
-        //the final wrapper
2239
-        $this->admin_page_wrapper();
2240
-    }
2241
-
2242
-
2243
-
2244
-    /**
2245
-     *        generates  HTML wrapper for an admin details page
2246
-     *
2247
-     * @access public
2248
-     * @return void
2249
-     */
2250
-    public function display_admin_page_with_sidebar()
2251
-    {
2252
-        $this->_display_admin_page(true);
2253
-    }
2254
-
2255
-
2256
-
2257
-    /**
2258
-     *        generates  HTML wrapper for an admin details page (except no sidebar)
2259
-     *
2260
-     * @access public
2261
-     * @return void
2262
-     */
2263
-    public function display_admin_page_with_no_sidebar()
2264
-    {
2265
-        $this->_display_admin_page();
2266
-    }
2267
-
2268
-
2269
-
2270
-    /**
2271
-     * generates HTML wrapper for an EE about admin page (no sidebar)
2272
-     *
2273
-     * @access public
2274
-     * @return void
2275
-     */
2276
-    public function display_about_admin_page()
2277
-    {
2278
-        $this->_display_admin_page(false, true);
2279
-    }
2280
-
2281
-
2282
-
2283
-    /**
2284
-     * display_admin_page
2285
-     * contains the code for actually displaying an admin page
2286
-     *
2287
-     * @access private
2288
-     * @param  boolean $sidebar true with sidebar, false without
2289
-     * @param  boolean $about   use the about admin wrapper instead of the default.
2290
-     * @return void
2291
-     */
2292
-    private function _display_admin_page($sidebar = false, $about = false)
2293
-    {
2294
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2295
-        //custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2296
-        do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2297
-        // set current wp page slug - looks like: event-espresso_page_event_categories
2298
-        // keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2299
-        $this->_template_args['current_page'] = $this->_wp_page_slug;
2300
-        $this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2301
-                ? 'poststuff'
2302
-                : 'espresso-default-admin';
2303
-        $template_path = $sidebar
2304
-                ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2305
-                : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2306
-        if (defined('DOING_AJAX') && DOING_AJAX) {
2307
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2308
-        }
2309
-        $template_path = ! empty($this->_column_template_path) ? $this->_column_template_path : $template_path;
2310
-        $this->_template_args['post_body_content'] = isset($this->_template_args['admin_page_content']) ? $this->_template_args['admin_page_content'] : '';
2311
-        $this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content']) ? $this->_template_args['before_admin_page_content'] : '';
2312
-        $this->_template_args['after_admin_page_content'] = isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content'] : '';
2313
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, true);
2314
-        // the final template wrapper
2315
-        $this->admin_page_wrapper($about);
2316
-    }
2317
-
2318
-
2319
-
2320
-    /**
2321
-     * This is used to display caf preview pages.
2322
-     *
2323
-     * @since 4.3.2
2324
-     * @param string $utm_campaign_source what is the key used for google analytics link
2325
-     * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2326
-     * @return void
2327
-     * @throws \EE_Error
2328
-     */
2329
-    public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2330
-    {
2331
-        //let's generate a default preview action button if there isn't one already present.
2332
-        $this->_labels['buttons']['buy_now'] = __('Upgrade Now', 'event_espresso');
2333
-        $buy_now_url = add_query_arg(
2334
-                array(
2335
-                        'ee_ver'       => 'ee4',
2336
-                        'utm_source'   => 'ee4_plugin_admin',
2337
-                        'utm_medium'   => 'link',
2338
-                        'utm_campaign' => $utm_campaign_source,
2339
-                        'utm_content'  => 'buy_now_button',
2340
-                ),
2341
-                'http://eventespresso.com/pricing/'
2342
-        );
2343
-        $this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2344
-                ? $this->get_action_link_or_button(
2345
-                        '',
2346
-                        'buy_now',
2347
-                        array(),
2348
-                        'button-primary button-large',
2349
-                        $buy_now_url,
2350
-                        true
2351
-                )
2352
-                : $this->_template_args['preview_action_button'];
2353
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php';
2354
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2355
-                $template_path,
2356
-                $this->_template_args,
2357
-                true
2358
-        );
2359
-        $this->_display_admin_page($display_sidebar);
2360
-    }
2361
-
2362
-
2363
-
2364
-    /**
2365
-     * display_admin_list_table_page_with_sidebar
2366
-     * generates HTML wrapper for an admin_page with list_table
2367
-     *
2368
-     * @access public
2369
-     * @return void
2370
-     */
2371
-    public function display_admin_list_table_page_with_sidebar()
2372
-    {
2373
-        $this->_display_admin_list_table_page(true);
2374
-    }
2375
-
2376
-
2377
-
2378
-    /**
2379
-     * display_admin_list_table_page_with_no_sidebar
2380
-     * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2381
-     *
2382
-     * @access public
2383
-     * @return void
2384
-     */
2385
-    public function display_admin_list_table_page_with_no_sidebar()
2386
-    {
2387
-        $this->_display_admin_list_table_page();
2388
-    }
2389
-
2390
-
2391
-
2392
-    /**
2393
-     * generates html wrapper for an admin_list_table page
2394
-     *
2395
-     * @access private
2396
-     * @param boolean $sidebar whether to display with sidebar or not.
2397
-     * @return void
2398
-     */
2399
-    private function _display_admin_list_table_page($sidebar = false)
2400
-    {
2401
-        //setup search attributes
2402
-        $this->_set_search_attributes();
2403
-        $this->_template_args['current_page'] = $this->_wp_page_slug;
2404
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2405
-        $this->_template_args['table_url'] = defined('DOING_AJAX')
2406
-                ? add_query_arg(array('noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url)
2407
-                : add_query_arg(array('route' => $this->_req_action), $this->_admin_base_url);
2408
-        $this->_template_args['list_table'] = $this->_list_table_object;
2409
-        $this->_template_args['current_route'] = $this->_req_action;
2410
-        $this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2411
-        $ajax_sorting_callback = $this->_list_table_object->get_ajax_sorting_callback();
2412
-        if ( ! empty($ajax_sorting_callback)) {
2413
-            $sortable_list_table_form_fields = wp_nonce_field(
2414
-                    $ajax_sorting_callback . '_nonce',
2415
-                    $ajax_sorting_callback . '_nonce',
2416
-                    false,
2417
-                    false
2418
-            );
2419
-            //			$reorder_action = 'espresso_' . $ajax_sorting_callback . '_nonce';
2420
-            //			$sortable_list_table_form_fields = wp_nonce_field( $reorder_action, 'ajax_table_sort_nonce', FALSE, FALSE );
2421
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="' . $this->page_slug . '" />';
2422
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="' . $ajax_sorting_callback . '" />';
2423
-        } else {
2424
-            $sortable_list_table_form_fields = '';
2425
-        }
2426
-        $this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
2427
-        $hidden_form_fields = isset($this->_template_args['list_table_hidden_fields']) ? $this->_template_args['list_table_hidden_fields'] : '';
2428
-        $nonce_ref = $this->_req_action . '_nonce';
2429
-        $hidden_form_fields .= '<input type="hidden" name="' . $nonce_ref . '" value="' . wp_create_nonce($nonce_ref) . '">';
2430
-        $this->_template_args['list_table_hidden_fields'] = $hidden_form_fields;
2431
-        //display message about search results?
2432
-        $this->_template_args['before_list_table'] .= ! empty($this->_req_data['s'])
2433
-                ? '<p class="ee-search-results">' . sprintf(
2434
-                        __('Displaying search results for the search string: <strong><em>%s</em></strong>',
2435
-                                'event_espresso'),
2436
-                        trim($this->_req_data['s'], '%')
2437
-                ) . '</p>'
2438
-                : '';
2439
-        // filter before_list_table template arg
2440
-        $this->_template_args['before_list_table'] = implode(
2441
-                " \n",
2442
-                (array)apply_filters(
2443
-                        'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
2444
-                        (array)$this->_template_args['before_list_table'],
2445
-                        $this->page_slug,
2446
-                        $this->_req_data,
2447
-                        $this->_req_action
2448
-                )
2449
-        );
2450
-        // filter after_list_table template arg
2451
-        $this->_template_args['after_list_table'] = implode(
2452
-                " \n",
2453
-                (array)apply_filters(
2454
-                        'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
2455
-                        (array)$this->_template_args['after_list_table'],
2456
-                        $this->page_slug,
2457
-                        $this->_req_data,
2458
-                        $this->_req_action
2459
-                )
2460
-        );
2461
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2462
-                $template_path,
2463
-                $this->_template_args,
2464
-                true
2465
-        );
2466
-        // the final template wrapper
2467
-        if ($sidebar) {
2468
-            $this->display_admin_page_with_sidebar();
2469
-        } else {
2470
-            $this->display_admin_page_with_no_sidebar();
2471
-        }
2472
-    }
2473
-
2474
-
2475
-
2476
-    /**
2477
-     * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the html string for the legend.
2478
-     * $items are expected in an array in the following format:
2479
-     * $legend_items = array(
2480
-     *        'item_id' => array(
2481
-     *            'icon' => 'http://url_to_icon_being_described.png',
2482
-     *            'desc' => __('localized description of item');
2483
-     *        )
2484
-     * );
2485
-     *
2486
-     * @param  array $items see above for format of array
2487
-     * @return string        html string of legend
2488
-     */
2489
-    protected function _display_legend($items)
2490
-    {
2491
-        $this->_template_args['items'] = apply_filters('FHEE__EE_Admin_Page___display_legend__items', (array)$items, $this);
2492
-        $legend_template = EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php';
2493
-        return EEH_Template::display_template($legend_template, $this->_template_args, true);
2494
-    }
2495
-
2496
-
2497
-
2498
-    /**
2499
-     * this is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
2500
-     *
2501
-     * @param bool $sticky_notices Used to indicate whether you want to ensure notices are added to a transient instead of displayed.
2502
-     *                             The returned json object is created from an array in the following format:
2503
-     *                             array(
2504
-     *                             'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
2505
-     *                             'success' => FALSE, //(default FALSE) - contains any special success message.
2506
-     *                             'notices' => '', // - contains any EE_Error formatted notices
2507
-     *                             'content' => 'string can be html', //this is a string of formatted content (can be html)
2508
-     *                             'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js. We're also going to include the template args with every package (so js can pick out any
2509
-     *                             specific template args that might be included in here)
2510
-     *                             )
2511
-     *                             The json object is populated by whatever is set in the $_template_args property.
2512
-     * @return void
2513
-     */
2514
-    protected function _return_json($sticky_notices = false)
2515
-    {
2516
-        //make sure any EE_Error notices have been handled.
2517
-        $this->_process_notices(array(), true, $sticky_notices);
2518
-        $data = isset($this->_template_args['data']) ? $this->_template_args['data'] : array();
2519
-        unset($this->_template_args['data']);
2520
-        $json = array(
2521
-                'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
2522
-                'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
2523
-                'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
2524
-                'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
2525
-                'notices'   => EE_Error::get_notices(),
2526
-                'content'   => isset($this->_template_args['admin_page_content']) ? $this->_template_args['admin_page_content'] : '',
2527
-                'data'      => array_merge($data, array('template_args' => $this->_template_args)),
2528
-                'isEEajax'  => true //special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
2529
-        );
2530
-        // make sure there are no php errors or headers_sent.  Then we can set correct json header.
2531
-        if (null === error_get_last() || ! headers_sent()) {
2532
-            header('Content-Type: application/json; charset=UTF-8');
2533
-        }
2534
-        if (function_exists('wp_json_encode')) {
2535
-            echo wp_json_encode($json);
2536
-        } else {
2537
-            echo json_encode($json);
2538
-        }
2539
-        exit();
2540
-    }
2541
-
2542
-
2543
-
2544
-    /**
2545
-     * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
2546
-     *
2547
-     * @return void
2548
-     * @throws EE_Error
2549
-     */
2550
-    public function return_json()
2551
-    {
2552
-        if (defined('DOING_AJAX') && DOING_AJAX) {
2553
-            $this->_return_json();
2554
-        } else {
2555
-            throw new EE_Error(sprintf(__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'), __FUNCTION__));
2556
-        }
2557
-    }
2558
-
2559
-
2560
-
2561
-    /**
2562
-     * This provides a way for child hook classes to send along themselves by reference so methods/properties within them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
2563
-     *
2564
-     * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
2565
-     * @access   public
2566
-     */
2567
-    public function set_hook_object(EE_Admin_Hooks $hook_obj)
2568
-    {
2569
-        $this->_hook_obj = $hook_obj;
2570
-    }
2571
-
2572
-
2573
-
2574
-    /**
2575
-     *        generates  HTML wrapper with Tabbed nav for an admin page
2576
-     *
2577
-     * @access public
2578
-     * @param  boolean $about whether to use the special about page wrapper or default.
2579
-     * @return void
2580
-     */
2581
-    public function admin_page_wrapper($about = false)
2582
-    {
2583
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2584
-        $this->_nav_tabs = $this->_get_main_nav_tabs();
2585
-        $this->_template_args['nav_tabs'] = $this->_nav_tabs;
2586
-        $this->_template_args['admin_page_title'] = $this->_admin_page_title;
2587
-        $this->_template_args['before_admin_page_content'] = apply_filters('FHEE_before_admin_page_content' . $this->_current_page . $this->_current_view,
2588
-                isset($this->_template_args['before_admin_page_content']) ? $this->_template_args['before_admin_page_content'] : '');
2589
-        $this->_template_args['after_admin_page_content'] = apply_filters('FHEE_after_admin_page_content' . $this->_current_page . $this->_current_view,
2590
-                isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content'] : '');
2591
-        $this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content();
2592
-        // load settings page wrapper template
2593
-        $template_path = ! defined('DOING_AJAX') ? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php' : EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php';
2594
-        //about page?
2595
-        $template_path = $about ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php' : $template_path;
2596
-        if (defined('DOING_AJAX')) {
2597
-            $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, true);
2598
-            $this->_return_json();
2599
-        } else {
2600
-            EEH_Template::display_template($template_path, $this->_template_args);
2601
-        }
2602
-    }
2603
-
2604
-
2605
-
2606
-    /**
2607
-     * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
2608
-     *
2609
-     * @return string html
2610
-     */
2611
-    protected function _get_main_nav_tabs()
2612
-    {
2613
-        //let's generate the html using the EEH_Tabbed_Content helper.  We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute (rather than setting in the page_routes array)
2614
-        return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
2615
-    }
2616
-
2617
-
2618
-
2619
-    /**
2620
-     *        sort nav tabs
2621
-     *
2622
-     * @access public
2623
-     * @param $a
2624
-     * @param $b
2625
-     * @return int
2626
-     */
2627
-    private function _sort_nav_tabs($a, $b)
2628
-    {
2629
-        if ($a['order'] == $b['order']) {
2630
-            return 0;
2631
-        }
2632
-        return ($a['order'] < $b['order']) ? -1 : 1;
2633
-    }
2634
-
2635
-
2636
-
2637
-    /**
2638
-     *    generates HTML for the forms used on admin pages
2639
-     *
2640
-     * @access protected
2641
-     * @param    array $input_vars - array of input field details
2642
-     * @param string   $generator  (options are 'string' or 'array', basically use this to indicate which generator to use)
2643
-     * @return string
2644
-     * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
2645
-     * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
2646
-     */
2647
-    protected function _generate_admin_form_fields($input_vars = array(), $generator = 'string', $id = false)
2648
-    {
2649
-        $content = $generator == 'string' ? EEH_Form_Fields::get_form_fields($input_vars, $id) : EEH_Form_Fields::get_form_fields_array($input_vars);
2650
-        return $content;
2651
-    }
2652
-
2653
-
2654
-
2655
-    /**
2656
-     * generates the "Save" and "Save & Close" buttons for edit forms
2657
-     *
2658
-     * @access protected
2659
-     * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save & Close" button.
2660
-     * @param array            $text     if included, generator will use the given text for the buttons ( array([0] => 'Save', [1] => 'save & close')
2661
-     * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e. via the "name" value in the button).  We can also use this to just dump default actions by submitting some other value.
2662
-     * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it will use the $referrer string. IF null, then we don't do ANYTHING on save and close (normal form handling).
2663
-     */
2664
-    protected function _set_save_buttons($both = true, $text = array(), $actions = array(), $referrer = null)
2665
-    {
2666
-        //make sure $text and $actions are in an array
2667
-        $text = (array)$text;
2668
-        $actions = (array)$actions;
2669
-        $referrer_url = empty($referrer) ? '' : $referrer;
2670
-        $referrer_url = ! $referrer ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $_SERVER['REQUEST_URI'] . '" />'
2671
-                : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $referrer . '" />';
2672
-        $button_text = ! empty($text) ? $text : array(__('Save', 'event_espresso'), __('Save and Close', 'event_espresso'));
2673
-        $default_names = array('save', 'save_and_close');
2674
-        //add in a hidden index for the current page (so save and close redirects properly)
2675
-        $this->_template_args['save_buttons'] = $referrer_url;
2676
-        foreach ($button_text as $key => $button) {
2677
-            $ref = $default_names[$key];
2678
-            $id = $this->_current_view . '_' . $ref;
2679
-            $name = ! empty($actions) ? $actions[$key] : $ref;
2680
-            $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary ' . $ref . '" value="' . $button . '" name="' . $name . '" id="' . $id . '" />';
2681
-            if ( ! $both) {
2682
-                break;
2683
-            }
2684
-        }
2685
-    }
2686
-
2687
-
2688
-
2689
-    /**
2690
-     * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
2691
-     *
2692
-     * @see   $this->_set_add_edit_form_tags() for details on params
2693
-     * @since 4.6.0
2694
-     * @param string $route
2695
-     * @param array  $additional_hidden_fields
2696
-     */
2697
-    public function set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
2698
-    {
2699
-        $this->_set_add_edit_form_tags($route, $additional_hidden_fields);
2700
-    }
2701
-
2702
-
2703
-
2704
-    /**
2705
-     * set form open and close tags on add/edit pages.
2706
-     *
2707
-     * @access protected
2708
-     * @param string $route                    the route you want the form to direct to
2709
-     * @param array  $additional_hidden_fields any additional hidden fields required in the form header
2710
-     * @return void
2711
-     */
2712
-    protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
2713
-    {
2714
-        if (empty($route)) {
2715
-            $user_msg = __('An error occurred. No action was set for this page\'s form.', 'event_espresso');
2716
-            $dev_msg = $user_msg . "\n" . sprintf(__('The $route argument is required for the %s->%s method.', 'event_espresso'), __FUNCTION__, __CLASS__);
2717
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
2718
-        }
2719
-        // open form
2720
-        $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="' . $this->_admin_base_url . '" id="' . $route . '_event_form" >';
2721
-        // add nonce
2722
-        $nonce = wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
2723
-        //		$nonce = wp_nonce_field( $route . '_nonce', '_wpnonce', FALSE, FALSE );
2724
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
2725
-        // add REQUIRED form action
2726
-        $hidden_fields = array(
2727
-                'action' => array('type' => 'hidden', 'value' => $route),
2728
-        );
2729
-        // merge arrays
2730
-        $hidden_fields = is_array($additional_hidden_fields) ? array_merge($hidden_fields, $additional_hidden_fields) : $hidden_fields;
2731
-        // generate form fields
2732
-        $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
2733
-        // add fields to form
2734
-        foreach ((array)$form_fields as $field_name => $form_field) {
2735
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
2736
-        }
2737
-        // close form
2738
-        $this->_template_args['after_admin_page_content'] = '</form>';
2739
-    }
2740
-
2741
-
2742
-
2743
-    /**
2744
-     * Public Wrapper for _redirect_after_action() method since its
2745
-     * discovered it would be useful for external code to have access.
2746
-     *
2747
-     * @see   EE_Admin_Page::_redirect_after_action() for params.
2748
-     * @since 4.5.0
2749
-     */
2750
-    public function redirect_after_action($success = false, $what = 'item', $action_desc = 'processed', $query_args = array(), $override_overwrite = false)
2751
-    {
2752
-        $this->_redirect_after_action($success, $what, $action_desc, $query_args, $override_overwrite);
2753
-    }
2754
-
2755
-
2756
-
2757
-    /**
2758
-     *    _redirect_after_action
2759
-     *
2760
-     * @param int    $success            - whether success was for two or more records, or just one, or none
2761
-     * @param string $what               - what the action was performed on
2762
-     * @param string $action_desc        - what was done ie: updated, deleted, etc
2763
-     * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin action is completed
2764
-     * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to override this so that they show.
2765
-     * @access protected
2766
-     * @return void
2767
-     */
2768
-    protected function _redirect_after_action($success = 0, $what = 'item', $action_desc = 'processed', $query_args = array(), $override_overwrite = false)
2769
-    {
2770
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2771
-        //class name for actions/filters.
2772
-        $classname = get_class($this);
2773
-        //set redirect url. Note if there is a "page" index in the $query_args then we go with vanilla admin.php route, otherwise we go with whatever is set as the _admin_base_url
2774
-        $redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
2775
-        $notices = EE_Error::get_notices(false);
2776
-        // overwrite default success messages //BUT ONLY if overwrite not overridden
2777
-        if ( ! $override_overwrite || ! empty($notices['errors'])) {
2778
-            EE_Error::overwrite_success();
2779
-        }
2780
-        if ( ! empty($what) && ! empty($action_desc)) {
2781
-            // how many records affected ? more than one record ? or just one ?
2782
-            if ($success > 1 && empty($notices['errors'])) {
2783
-                // set plural msg
2784
-                EE_Error::add_success(
2785
-                        sprintf(
2786
-                                __('The "%s" have been successfully %s.', 'event_espresso'),
2787
-                                $what,
2788
-                                $action_desc
2789
-                        ),
2790
-                        __FILE__, __FUNCTION__, __LINE__
2791
-                );
2792
-            } else if ($success == 1 && empty($notices['errors'])) {
2793
-                // set singular msg
2794
-                EE_Error::add_success(
2795
-                        sprintf(
2796
-                                __('The "%s" has been successfully %s.', 'event_espresso'),
2797
-                                $what,
2798
-                                $action_desc
2799
-                        ),
2800
-                        __FILE__, __FUNCTION__, __LINE__
2801
-                );
2802
-            }
2803
-        }
2804
-        // check that $query_args isn't something crazy
2805
-        if ( ! is_array($query_args)) {
2806
-            $query_args = array();
2807
-        }
2808
-        /**
2809
-         * Allow injecting actions before the query_args are modified for possible different
2810
-         * redirections on save and close actions
2811
-         *
2812
-         * @since 4.2.0
2813
-         * @param array $query_args       The original query_args array coming into the
2814
-         *                                method.
2815
-         */
2816
-        do_action('AHEE__' . $classname . '___redirect_after_action__before_redirect_modification_' . $this->_req_action, $query_args);
2817
-        //calculate where we're going (if we have a "save and close" button pushed)
2818
-        if (isset($this->_req_data['save_and_close']) && isset($this->_req_data['save_and_close_referrer'])) {
2819
-            // even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
2820
-            $parsed_url = parse_url($this->_req_data['save_and_close_referrer']);
2821
-            // regenerate query args array from referrer URL
2822
-            parse_str($parsed_url['query'], $query_args);
2823
-            // correct page and action will be in the query args now
2824
-            $redirect_url = admin_url('admin.php');
2825
-        }
2826
-        //merge any default query_args set in _default_route_query_args property
2827
-        if ( ! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
2828
-            $args_to_merge = array();
2829
-            foreach ($this->_default_route_query_args as $query_param => $query_value) {
2830
-                //is there a wp_referer array in our _default_route_query_args property?
2831
-                if ($query_param == 'wp_referer') {
2832
-                    $query_value = (array)$query_value;
2833
-                    foreach ($query_value as $reference => $value) {
2834
-                        if (strpos($reference, 'nonce') !== false) {
2835
-                            continue;
2836
-                        }
2837
-                        //finally we will override any arguments in the referer with
2838
-                        //what might be set on the _default_route_query_args array.
2839
-                        if (isset($this->_default_route_query_args[$reference])) {
2840
-                            $args_to_merge[$reference] = urlencode($this->_default_route_query_args[$reference]);
2841
-                        } else {
2842
-                            $args_to_merge[$reference] = urlencode($value);
2843
-                        }
2844
-                    }
2845
-                    continue;
2846
-                }
2847
-                $args_to_merge[$query_param] = $query_value;
2848
-            }
2849
-            //now let's merge these arguments but override with what was specifically sent in to the
2850
-            //redirect.
2851
-            $query_args = array_merge($args_to_merge, $query_args);
2852
-        }
2853
-        $this->_process_notices($query_args);
2854
-        // generate redirect url
2855
-        // if redirecting to anything other than the main page, add a nonce
2856
-        if (isset($query_args['action'])) {
2857
-            // manually generate wp_nonce and merge that with the query vars becuz the wp_nonce_url function wrecks havoc on some vars
2858
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
2859
-        }
2860
-        //we're adding some hooks and filters in here for processing any things just before redirects (example: an admin page has done an insert or update and we want to run something after that).
2861
-        do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
2862
-        $redirect_url = apply_filters('FHEE_redirect_' . $classname . $this->_req_action, self::add_query_args_and_nonce($query_args, $redirect_url), $query_args);
2863
-        // check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
2864
-        if (defined('DOING_AJAX')) {
2865
-            $default_data = array(
2866
-                    'close'        => true,
2867
-                    'redirect_url' => $redirect_url,
2868
-                    'where'        => 'main',
2869
-                    'what'         => 'append',
2870
-            );
2871
-            $this->_template_args['success'] = $success;
2872
-            $this->_template_args['data'] = ! empty($this->_template_args['data']) ? array_merge($default_data, $this->_template_args['data']) : $default_data;
2873
-            $this->_return_json();
2874
-        }
2875
-        wp_safe_redirect($redirect_url);
2876
-        exit();
2877
-    }
2878
-
2879
-
2880
-
2881
-    /**
2882
-     * process any notices before redirecting (or returning ajax request)
2883
-     * This method sets the $this->_template_args['notices'] attribute;
2884
-     *
2885
-     * @param  array $query_args        any query args that need to be used for notice transient ('action')
2886
-     * @param bool   $skip_route_verify This is typically used when we are processing notices REALLY early and page_routes haven't been defined yet.
2887
-     * @param bool   $sticky_notices    This is used to flag that regardless of whether this is doing_ajax or not, we still save a transient for the notice.
2888
-     * @return void
2889
-     */
2890
-    protected function _process_notices($query_args = array(), $skip_route_verify = false, $sticky_notices = true)
2891
-    {
2892
-        //first let's set individual error properties if doing_ajax and the properties aren't already set.
2893
-        if (defined('DOING_AJAX') && DOING_AJAX) {
2894
-            $notices = EE_Error::get_notices(false);
2895
-            if (empty($this->_template_args['success'])) {
2896
-                $this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
2897
-            }
2898
-            if (empty($this->_template_args['errors'])) {
2899
-                $this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
2900
-            }
2901
-            if (empty($this->_template_args['attention'])) {
2902
-                $this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
2903
-            }
2904
-        }
2905
-        $this->_template_args['notices'] = EE_Error::get_notices();
2906
-        //IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
2907
-        if ( ! defined('DOING_AJAX') || $sticky_notices) {
2908
-            $route = isset($query_args['action']) ? $query_args['action'] : 'default';
2909
-            $this->_add_transient($route, $this->_template_args['notices'], true, $skip_route_verify);
2910
-        }
2911
-    }
2912
-
2913
-
2914
-
2915
-    /**
2916
-     * get_action_link_or_button
2917
-     * returns the button html for adding, editing, or deleting an item (depending on given type)
2918
-     *
2919
-     * @param string $action        use this to indicate which action the url is generated with.
2920
-     * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key) property.
2921
-     * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
2922
-     * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
2923
-     * @param string $base_url      If this is not provided
2924
-     *                              the _admin_base_url will be used as the default for the button base_url.
2925
-     *                              Otherwise this value will be used.
2926
-     * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
2927
-     * @return string
2928
-     * @throws \EE_Error
2929
-     */
2930
-    public function get_action_link_or_button(
2931
-            $action,
2932
-            $type = 'add',
2933
-            $extra_request = array(),
2934
-            $class = 'button-primary',
2935
-            $base_url = '',
2936
-            $exclude_nonce = false
2937
-    ) {
2938
-        //first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
2939
-        if (empty($base_url) && ! isset($this->_page_routes[$action])) {
2940
-            throw new EE_Error(
2941
-                    sprintf(
2942
-                            __(
2943
-                                    'There is no page route for given action for the button.  This action was given: %s',
2944
-                                    'event_espresso'
2945
-                            ),
2946
-                            $action
2947
-                    )
2948
-            );
2949
-        }
2950
-        if ( ! isset($this->_labels['buttons'][$type])) {
2951
-            throw new EE_Error(
2952
-                    sprintf(
2953
-                            __(
2954
-                                    'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
2955
-                                    'event_espresso'
2956
-                            ),
2957
-                            $type
2958
-                    )
2959
-            );
2960
-        }
2961
-        //finally check user access for this button.
2962
-        $has_access = $this->check_user_access($action, true);
2963
-        if ( ! $has_access) {
2964
-            return '';
2965
-        }
2966
-        $_base_url = ! $base_url ? $this->_admin_base_url : $base_url;
2967
-        $query_args = array(
2968
-                'action' => $action,
2969
-        );
2970
-        //merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
2971
-        if ( ! empty($extra_request)) {
2972
-            $query_args = array_merge($extra_request, $query_args);
2973
-        }
2974
-        $url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
2975
-        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][$type], $class);
2976
-    }
2977
-
2978
-
2979
-
2980
-    /**
2981
-     * _per_page_screen_option
2982
-     * Utility function for adding in a per_page_option in the screen_options_dropdown.
2983
-     *
2984
-     * @return void
2985
-     */
2986
-    protected function _per_page_screen_option()
2987
-    {
2988
-        $option = 'per_page';
2989
-        $args = array(
2990
-                'label'   => $this->_admin_page_title,
2991
-                'default' => 10,
2992
-                'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
2993
-        );
2994
-        //ONLY add the screen option if the user has access to it.
2995
-        if ($this->check_user_access($this->_current_view, true)) {
2996
-            add_screen_option($option, $args);
2997
-        }
2998
-    }
2999
-
3000
-
3001
-
3002
-    /**
3003
-     * set_per_page_screen_option
3004
-     * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3005
-     * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than admin_menu.
3006
-     *
3007
-     * @access private
3008
-     * @return void
3009
-     */
3010
-    private function _set_per_page_screen_options()
3011
-    {
3012
-        if (isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options'])) {
3013
-            check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3014
-            if ( ! $user = wp_get_current_user()) {
3015
-                return;
3016
-            }
3017
-            $option = $_POST['wp_screen_options']['option'];
3018
-            $value = $_POST['wp_screen_options']['value'];
3019
-            if ($option != sanitize_key($option)) {
3020
-                return;
3021
-            }
3022
-            $map_option = $option;
3023
-            $option = str_replace('-', '_', $option);
3024
-            switch ($map_option) {
3025
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3026
-                    $value = (int)$value;
3027
-                    if ($value < 1 || $value > 999) {
3028
-                        return;
3029
-                    }
3030
-                    break;
3031
-                default:
3032
-                    $value = apply_filters('FHEE__EE_Admin_Page___set_per_page_screen_options__value', false, $option, $value);
3033
-                    if (false === $value) {
3034
-                        return;
3035
-                    }
3036
-                    break;
3037
-            }
3038
-            update_user_meta($user->ID, $option, $value);
3039
-            wp_safe_redirect(remove_query_arg(array('pagenum', 'apage', 'paged'), wp_get_referer()));
3040
-            exit;
3041
-        }
3042
-    }
3043
-
3044
-
3045
-
3046
-    /**
3047
-     * This just allows for setting the $_template_args property if it needs to be set outside the object
3048
-     *
3049
-     * @param array $data array that will be assigned to template args.
3050
-     */
3051
-    public function set_template_args($data)
3052
-    {
3053
-        $this->_template_args = array_merge($this->_template_args, (array)$data);
3054
-    }
3055
-
3056
-
3057
-
3058
-    /**
3059
-     * This makes available the WP transient system for temporarily moving data between routes
3060
-     *
3061
-     * @access protected
3062
-     * @param string $route             the route that should receive the transient
3063
-     * @param array  $data              the data that gets sent
3064
-     * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a normal route transient.
3065
-     * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used when we are adding a transient before page_routes have been defined.
3066
-     * @return void
3067
-     */
3068
-    protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3069
-    {
3070
-        $user_id = get_current_user_id();
3071
-        if ( ! $skip_route_verify) {
3072
-            $this->_verify_route($route);
3073
-        }
3074
-        //now let's set the string for what kind of transient we're setting
3075
-        $transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id;
3076
-        $data = $notices ? array('notices' => $data) : $data;
3077
-        //is there already a transient for this route?  If there is then let's ADD to that transient
3078
-        $existing = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient);
3079
-        if ($existing) {
3080
-            $data = array_merge((array)$data, (array)$existing);
3081
-        }
3082
-        if (is_multisite() && is_network_admin()) {
3083
-            set_site_transient($transient, $data, 8);
3084
-        } else {
3085
-            set_transient($transient, $data, 8);
3086
-        }
3087
-    }
3088
-
3089
-
3090
-
3091
-    /**
3092
-     * this retrieves the temporary transient that has been set for moving data between routes.
3093
-     *
3094
-     * @param bool $notices true we get notices transient. False we just return normal route transient
3095
-     * @return mixed data
3096
-     */
3097
-    protected function _get_transient($notices = false, $route = false)
3098
-    {
3099
-        $user_id = get_current_user_id();
3100
-        $route = ! $route ? $this->_req_action : $route;
3101
-        $transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id;
3102
-        $data = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient);
3103
-        //delete transient after retrieval (just in case it hasn't expired);
3104
-        if (is_multisite() && is_network_admin()) {
3105
-            delete_site_transient($transient);
3106
-        } else {
3107
-            delete_transient($transient);
3108
-        }
3109
-        return $notices && isset($data['notices']) ? $data['notices'] : $data;
3110
-    }
3111
-
3112
-
3113
-
3114
-    /**
3115
-     * The purpose of this method is just to run garbage collection on any EE transients that might have expired but would not be called later.
3116
-     * This will be assigned to run on a specific EE Admin page. (place the method in the default route callback on the EE_Admin page you want it run.)
3117
-     *
3118
-     * @return void
3119
-     */
3120
-    protected function _transient_garbage_collection()
3121
-    {
3122
-        global $wpdb;
3123
-        //retrieve all existing transients
3124
-        $query = "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3125
-        if ($results = $wpdb->get_results($query)) {
3126
-            foreach ($results as $result) {
3127
-                $transient = str_replace('_transient_', '', $result->option_name);
3128
-                get_transient($transient);
3129
-                if (is_multisite() && is_network_admin()) {
3130
-                    get_site_transient($transient);
3131
-                }
3132
-            }
3133
-        }
3134
-    }
3135
-
3136
-
3137
-
3138
-    /**
3139
-     * get_view
3140
-     *
3141
-     * @access public
3142
-     * @return string content of _view property
3143
-     */
3144
-    public function get_view()
3145
-    {
3146
-        return $this->_view;
3147
-    }
3148
-
3149
-
3150
-
3151
-    /**
3152
-     * getter for the protected $_views property
3153
-     *
3154
-     * @return array
3155
-     */
3156
-    public function get_views()
3157
-    {
3158
-        return $this->_views;
3159
-    }
3160
-
3161
-
3162
-
3163
-    /**
3164
-     * get_current_page
3165
-     *
3166
-     * @access public
3167
-     * @return string _current_page property value
3168
-     */
3169
-    public function get_current_page()
3170
-    {
3171
-        return $this->_current_page;
3172
-    }
3173
-
3174
-
3175
-
3176
-    /**
3177
-     * get_current_view
3178
-     *
3179
-     * @access public
3180
-     * @return string _current_view property value
3181
-     */
3182
-    public function get_current_view()
3183
-    {
3184
-        return $this->_current_view;
3185
-    }
3186
-
3187
-
3188
-
3189
-    /**
3190
-     * get_current_screen
3191
-     *
3192
-     * @access public
3193
-     * @return object The current WP_Screen object
3194
-     */
3195
-    public function get_current_screen()
3196
-    {
3197
-        return $this->_current_screen;
3198
-    }
3199
-
3200
-
3201
-
3202
-    /**
3203
-     * get_current_page_view_url
3204
-     *
3205
-     * @access public
3206
-     * @return string This returns the url for the current_page_view.
3207
-     */
3208
-    public function get_current_page_view_url()
3209
-    {
3210
-        return $this->_current_page_view_url;
3211
-    }
3212
-
3213
-
3214
-
3215
-    /**
3216
-     * just returns the _req_data property
3217
-     *
3218
-     * @return array
3219
-     */
3220
-    public function get_request_data()
3221
-    {
3222
-        return $this->_req_data;
3223
-    }
3224
-
3225
-
3226
-
3227
-    /**
3228
-     * returns the _req_data protected property
3229
-     *
3230
-     * @return string
3231
-     */
3232
-    public function get_req_action()
3233
-    {
3234
-        return $this->_req_action;
3235
-    }
3236
-
3237
-
3238
-
3239
-    /**
3240
-     * @return bool  value of $_is_caf property
3241
-     */
3242
-    public function is_caf()
3243
-    {
3244
-        return $this->_is_caf;
3245
-    }
3246
-
3247
-
3248
-
3249
-    /**
3250
-     * @return mixed
3251
-     */
3252
-    public function default_espresso_metaboxes()
3253
-    {
3254
-        return $this->_default_espresso_metaboxes;
3255
-    }
3256
-
3257
-
3258
-
3259
-    /**
3260
-     * @return mixed
3261
-     */
3262
-    public function admin_base_url()
3263
-    {
3264
-        return $this->_admin_base_url;
3265
-    }
3266
-
3267
-
3268
-
3269
-    /**
3270
-     * @return mixed
3271
-     */
3272
-    public function wp_page_slug()
3273
-    {
3274
-        return $this->_wp_page_slug;
3275
-    }
3276
-
3277
-
3278
-
3279
-    /**
3280
-     * updates  espresso configuration settings
3281
-     *
3282
-     * @access    protected
3283
-     * @param string                   $tab
3284
-     * @param EE_Config_Base|EE_Config $config
3285
-     * @param string                   $file file where error occurred
3286
-     * @param string                   $func function  where error occurred
3287
-     * @param string                   $line line no where error occurred
3288
-     * @return boolean
3289
-     */
3290
-    protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
3291
-    {
3292
-        //remove any options that are NOT going to be saved with the config settings.
3293
-        if (isset($config->core->ee_ueip_optin)) {
3294
-            $config->core->ee_ueip_has_notified = true;
3295
-            // TODO: remove the following two lines and make sure values are migrated from 3.1
3296
-            update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
3297
-            update_option('ee_ueip_has_notified', true);
3298
-        }
3299
-        // and save it (note we're also doing the network save here)
3300
-        $net_saved = is_main_site() ? EE_Network_Config::instance()->update_config(false, false) : true;
3301
-        $config_saved = EE_Config::instance()->update_espresso_config(false, false);
3302
-        if ($config_saved && $net_saved) {
3303
-            EE_Error::add_success(sprintf(__('"%s" have been successfully updated.', 'event_espresso'), $tab));
3304
-            return true;
3305
-        } else {
3306
-            EE_Error::add_error(sprintf(__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
3307
-            return false;
3308
-        }
3309
-    }
3310
-
3311
-
3312
-
3313
-    /**
3314
-     * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
3315
-     *
3316
-     * @return array
3317
-     */
3318
-    public function get_yes_no_values()
3319
-    {
3320
-        return $this->_yes_no_values;
3321
-    }
3322
-
3323
-
3324
-
3325
-    protected function _get_dir()
3326
-    {
3327
-        $reflector = new ReflectionClass(get_class($this));
3328
-        return dirname($reflector->getFileName());
3329
-    }
3330
-
3331
-
3332
-
3333
-    /**
3334
-     * A helper for getting a "next link".
3335
-     *
3336
-     * @param string $url   The url to link to
3337
-     * @param string $class The class to use.
3338
-     * @return string
3339
-     */
3340
-    protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
3341
-    {
3342
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3343
-    }
3344
-
3345
-
3346
-
3347
-    /**
3348
-     * A helper for getting a "previous link".
3349
-     *
3350
-     * @param string $url   The url to link to
3351
-     * @param string $class The class to use.
3352
-     * @return string
3353
-     */
3354
-    protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
3355
-    {
3356
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3357
-    }
3358
-
3359
-
3360
-
3361
-
3362
-
3363
-
3364
-
3365
-    //below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
3366
-    /**
3367
-     * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller knows that the _REG_ID isn't in the req_data array but CAN obtain it, the caller should ADD the _REG_ID to the _req_data
3368
-     * array.
3369
-     *
3370
-     * @return bool success/fail
3371
-     */
3372
-    protected function _process_resend_registration()
3373
-    {
3374
-        $this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
3375
-        do_action('AHEE__EE_Admin_Page___process_resend_registration', $this->_template_args['success'], $this->_req_data);
3376
-        return $this->_template_args['success'];
3377
-    }
3378
-
3379
-
3380
-
3381
-    /**
3382
-     * This automatically processes any payment message notifications when manual payment has been applied.
3383
-     *
3384
-     * @access protected
3385
-     * @param \EE_Payment $payment
3386
-     * @return bool success/fail
3387
-     */
3388
-    protected function _process_payment_notification(EE_Payment $payment)
3389
-    {
3390
-        add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
3391
-        do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
3392
-        $this->_template_args['success'] = apply_filters('FHEE__EE_Admin_Page___process_admin_payment_notification__success', false, $payment);
3393
-        return $this->_template_args['success'];
3394
-    }
2196
+	}
2197
+
2198
+
2199
+
2200
+	/**
2201
+	 * facade for add_meta_box
2202
+	 *
2203
+	 * @param string  $action        where the metabox get's displayed
2204
+	 * @param string  $title         Title of Metabox (output in metabox header)
2205
+	 * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback instead of the one created in here.
2206
+	 * @param array   $callback_args an array of args supplied for the metabox
2207
+	 * @param string  $column        what metabox column
2208
+	 * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2209
+	 * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function created but just set our own callback for wp's add_meta_box.
2210
+	 */
2211
+	public function _add_admin_page_meta_box($action, $title, $callback, $callback_args, $column = 'normal', $priority = 'high', $create_func = true)
2212
+	{
2213
+		do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2214
+		//if we have empty callback args and we want to automatically create the metabox callback then we need to make sure the callback args are generated.
2215
+		if (empty($callback_args) && $create_func) {
2216
+			$callback_args = array(
2217
+					'template_path' => $this->_template_path,
2218
+					'template_args' => $this->_template_args,
2219
+			);
2220
+		}
2221
+		//if $create_func is true (default) then we automatically create the function for displaying the actual meta box.  If false then we take the $callback reference passed through and use it instead (so callers can define their own callback function/method if they wish)
2222
+		$call_back_func = $create_func ? create_function('$post, $metabox',
2223
+				'do_action( "AHEE_log", __FILE__, __FUNCTION__, ""); echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );') : $callback;
2224
+		add_meta_box(str_replace('_', '-', $action) . '-mbox', $title, $call_back_func, $this->_wp_page_slug, $column, $priority, $callback_args);
2225
+	}
2226
+
2227
+
2228
+
2229
+	/**
2230
+	 * generates HTML wrapper for and admin details page that contains metaboxes in columns
2231
+	 *
2232
+	 * @return [type] [description]
2233
+	 */
2234
+	public function display_admin_page_with_metabox_columns()
2235
+	{
2236
+		$this->_template_args['post_body_content'] = $this->_template_args['admin_page_content'];
2237
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_column_template_path, $this->_template_args, true);
2238
+		//the final wrapper
2239
+		$this->admin_page_wrapper();
2240
+	}
2241
+
2242
+
2243
+
2244
+	/**
2245
+	 *        generates  HTML wrapper for an admin details page
2246
+	 *
2247
+	 * @access public
2248
+	 * @return void
2249
+	 */
2250
+	public function display_admin_page_with_sidebar()
2251
+	{
2252
+		$this->_display_admin_page(true);
2253
+	}
2254
+
2255
+
2256
+
2257
+	/**
2258
+	 *        generates  HTML wrapper for an admin details page (except no sidebar)
2259
+	 *
2260
+	 * @access public
2261
+	 * @return void
2262
+	 */
2263
+	public function display_admin_page_with_no_sidebar()
2264
+	{
2265
+		$this->_display_admin_page();
2266
+	}
2267
+
2268
+
2269
+
2270
+	/**
2271
+	 * generates HTML wrapper for an EE about admin page (no sidebar)
2272
+	 *
2273
+	 * @access public
2274
+	 * @return void
2275
+	 */
2276
+	public function display_about_admin_page()
2277
+	{
2278
+		$this->_display_admin_page(false, true);
2279
+	}
2280
+
2281
+
2282
+
2283
+	/**
2284
+	 * display_admin_page
2285
+	 * contains the code for actually displaying an admin page
2286
+	 *
2287
+	 * @access private
2288
+	 * @param  boolean $sidebar true with sidebar, false without
2289
+	 * @param  boolean $about   use the about admin wrapper instead of the default.
2290
+	 * @return void
2291
+	 */
2292
+	private function _display_admin_page($sidebar = false, $about = false)
2293
+	{
2294
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2295
+		//custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2296
+		do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2297
+		// set current wp page slug - looks like: event-espresso_page_event_categories
2298
+		// keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2299
+		$this->_template_args['current_page'] = $this->_wp_page_slug;
2300
+		$this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2301
+				? 'poststuff'
2302
+				: 'espresso-default-admin';
2303
+		$template_path = $sidebar
2304
+				? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2305
+				: EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2306
+		if (defined('DOING_AJAX') && DOING_AJAX) {
2307
+			$template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2308
+		}
2309
+		$template_path = ! empty($this->_column_template_path) ? $this->_column_template_path : $template_path;
2310
+		$this->_template_args['post_body_content'] = isset($this->_template_args['admin_page_content']) ? $this->_template_args['admin_page_content'] : '';
2311
+		$this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content']) ? $this->_template_args['before_admin_page_content'] : '';
2312
+		$this->_template_args['after_admin_page_content'] = isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content'] : '';
2313
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, true);
2314
+		// the final template wrapper
2315
+		$this->admin_page_wrapper($about);
2316
+	}
2317
+
2318
+
2319
+
2320
+	/**
2321
+	 * This is used to display caf preview pages.
2322
+	 *
2323
+	 * @since 4.3.2
2324
+	 * @param string $utm_campaign_source what is the key used for google analytics link
2325
+	 * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2326
+	 * @return void
2327
+	 * @throws \EE_Error
2328
+	 */
2329
+	public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2330
+	{
2331
+		//let's generate a default preview action button if there isn't one already present.
2332
+		$this->_labels['buttons']['buy_now'] = __('Upgrade Now', 'event_espresso');
2333
+		$buy_now_url = add_query_arg(
2334
+				array(
2335
+						'ee_ver'       => 'ee4',
2336
+						'utm_source'   => 'ee4_plugin_admin',
2337
+						'utm_medium'   => 'link',
2338
+						'utm_campaign' => $utm_campaign_source,
2339
+						'utm_content'  => 'buy_now_button',
2340
+				),
2341
+				'http://eventespresso.com/pricing/'
2342
+		);
2343
+		$this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2344
+				? $this->get_action_link_or_button(
2345
+						'',
2346
+						'buy_now',
2347
+						array(),
2348
+						'button-primary button-large',
2349
+						$buy_now_url,
2350
+						true
2351
+				)
2352
+				: $this->_template_args['preview_action_button'];
2353
+		$template_path = EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php';
2354
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2355
+				$template_path,
2356
+				$this->_template_args,
2357
+				true
2358
+		);
2359
+		$this->_display_admin_page($display_sidebar);
2360
+	}
2361
+
2362
+
2363
+
2364
+	/**
2365
+	 * display_admin_list_table_page_with_sidebar
2366
+	 * generates HTML wrapper for an admin_page with list_table
2367
+	 *
2368
+	 * @access public
2369
+	 * @return void
2370
+	 */
2371
+	public function display_admin_list_table_page_with_sidebar()
2372
+	{
2373
+		$this->_display_admin_list_table_page(true);
2374
+	}
2375
+
2376
+
2377
+
2378
+	/**
2379
+	 * display_admin_list_table_page_with_no_sidebar
2380
+	 * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2381
+	 *
2382
+	 * @access public
2383
+	 * @return void
2384
+	 */
2385
+	public function display_admin_list_table_page_with_no_sidebar()
2386
+	{
2387
+		$this->_display_admin_list_table_page();
2388
+	}
2389
+
2390
+
2391
+
2392
+	/**
2393
+	 * generates html wrapper for an admin_list_table page
2394
+	 *
2395
+	 * @access private
2396
+	 * @param boolean $sidebar whether to display with sidebar or not.
2397
+	 * @return void
2398
+	 */
2399
+	private function _display_admin_list_table_page($sidebar = false)
2400
+	{
2401
+		//setup search attributes
2402
+		$this->_set_search_attributes();
2403
+		$this->_template_args['current_page'] = $this->_wp_page_slug;
2404
+		$template_path = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2405
+		$this->_template_args['table_url'] = defined('DOING_AJAX')
2406
+				? add_query_arg(array('noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url)
2407
+				: add_query_arg(array('route' => $this->_req_action), $this->_admin_base_url);
2408
+		$this->_template_args['list_table'] = $this->_list_table_object;
2409
+		$this->_template_args['current_route'] = $this->_req_action;
2410
+		$this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2411
+		$ajax_sorting_callback = $this->_list_table_object->get_ajax_sorting_callback();
2412
+		if ( ! empty($ajax_sorting_callback)) {
2413
+			$sortable_list_table_form_fields = wp_nonce_field(
2414
+					$ajax_sorting_callback . '_nonce',
2415
+					$ajax_sorting_callback . '_nonce',
2416
+					false,
2417
+					false
2418
+			);
2419
+			//			$reorder_action = 'espresso_' . $ajax_sorting_callback . '_nonce';
2420
+			//			$sortable_list_table_form_fields = wp_nonce_field( $reorder_action, 'ajax_table_sort_nonce', FALSE, FALSE );
2421
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="' . $this->page_slug . '" />';
2422
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="' . $ajax_sorting_callback . '" />';
2423
+		} else {
2424
+			$sortable_list_table_form_fields = '';
2425
+		}
2426
+		$this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
2427
+		$hidden_form_fields = isset($this->_template_args['list_table_hidden_fields']) ? $this->_template_args['list_table_hidden_fields'] : '';
2428
+		$nonce_ref = $this->_req_action . '_nonce';
2429
+		$hidden_form_fields .= '<input type="hidden" name="' . $nonce_ref . '" value="' . wp_create_nonce($nonce_ref) . '">';
2430
+		$this->_template_args['list_table_hidden_fields'] = $hidden_form_fields;
2431
+		//display message about search results?
2432
+		$this->_template_args['before_list_table'] .= ! empty($this->_req_data['s'])
2433
+				? '<p class="ee-search-results">' . sprintf(
2434
+						__('Displaying search results for the search string: <strong><em>%s</em></strong>',
2435
+								'event_espresso'),
2436
+						trim($this->_req_data['s'], '%')
2437
+				) . '</p>'
2438
+				: '';
2439
+		// filter before_list_table template arg
2440
+		$this->_template_args['before_list_table'] = implode(
2441
+				" \n",
2442
+				(array)apply_filters(
2443
+						'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
2444
+						(array)$this->_template_args['before_list_table'],
2445
+						$this->page_slug,
2446
+						$this->_req_data,
2447
+						$this->_req_action
2448
+				)
2449
+		);
2450
+		// filter after_list_table template arg
2451
+		$this->_template_args['after_list_table'] = implode(
2452
+				" \n",
2453
+				(array)apply_filters(
2454
+						'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
2455
+						(array)$this->_template_args['after_list_table'],
2456
+						$this->page_slug,
2457
+						$this->_req_data,
2458
+						$this->_req_action
2459
+				)
2460
+		);
2461
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2462
+				$template_path,
2463
+				$this->_template_args,
2464
+				true
2465
+		);
2466
+		// the final template wrapper
2467
+		if ($sidebar) {
2468
+			$this->display_admin_page_with_sidebar();
2469
+		} else {
2470
+			$this->display_admin_page_with_no_sidebar();
2471
+		}
2472
+	}
2473
+
2474
+
2475
+
2476
+	/**
2477
+	 * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the html string for the legend.
2478
+	 * $items are expected in an array in the following format:
2479
+	 * $legend_items = array(
2480
+	 *        'item_id' => array(
2481
+	 *            'icon' => 'http://url_to_icon_being_described.png',
2482
+	 *            'desc' => __('localized description of item');
2483
+	 *        )
2484
+	 * );
2485
+	 *
2486
+	 * @param  array $items see above for format of array
2487
+	 * @return string        html string of legend
2488
+	 */
2489
+	protected function _display_legend($items)
2490
+	{
2491
+		$this->_template_args['items'] = apply_filters('FHEE__EE_Admin_Page___display_legend__items', (array)$items, $this);
2492
+		$legend_template = EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php';
2493
+		return EEH_Template::display_template($legend_template, $this->_template_args, true);
2494
+	}
2495
+
2496
+
2497
+
2498
+	/**
2499
+	 * this is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
2500
+	 *
2501
+	 * @param bool $sticky_notices Used to indicate whether you want to ensure notices are added to a transient instead of displayed.
2502
+	 *                             The returned json object is created from an array in the following format:
2503
+	 *                             array(
2504
+	 *                             'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
2505
+	 *                             'success' => FALSE, //(default FALSE) - contains any special success message.
2506
+	 *                             'notices' => '', // - contains any EE_Error formatted notices
2507
+	 *                             'content' => 'string can be html', //this is a string of formatted content (can be html)
2508
+	 *                             'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js. We're also going to include the template args with every package (so js can pick out any
2509
+	 *                             specific template args that might be included in here)
2510
+	 *                             )
2511
+	 *                             The json object is populated by whatever is set in the $_template_args property.
2512
+	 * @return void
2513
+	 */
2514
+	protected function _return_json($sticky_notices = false)
2515
+	{
2516
+		//make sure any EE_Error notices have been handled.
2517
+		$this->_process_notices(array(), true, $sticky_notices);
2518
+		$data = isset($this->_template_args['data']) ? $this->_template_args['data'] : array();
2519
+		unset($this->_template_args['data']);
2520
+		$json = array(
2521
+				'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
2522
+				'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
2523
+				'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
2524
+				'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
2525
+				'notices'   => EE_Error::get_notices(),
2526
+				'content'   => isset($this->_template_args['admin_page_content']) ? $this->_template_args['admin_page_content'] : '',
2527
+				'data'      => array_merge($data, array('template_args' => $this->_template_args)),
2528
+				'isEEajax'  => true //special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
2529
+		);
2530
+		// make sure there are no php errors or headers_sent.  Then we can set correct json header.
2531
+		if (null === error_get_last() || ! headers_sent()) {
2532
+			header('Content-Type: application/json; charset=UTF-8');
2533
+		}
2534
+		if (function_exists('wp_json_encode')) {
2535
+			echo wp_json_encode($json);
2536
+		} else {
2537
+			echo json_encode($json);
2538
+		}
2539
+		exit();
2540
+	}
2541
+
2542
+
2543
+
2544
+	/**
2545
+	 * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
2546
+	 *
2547
+	 * @return void
2548
+	 * @throws EE_Error
2549
+	 */
2550
+	public function return_json()
2551
+	{
2552
+		if (defined('DOING_AJAX') && DOING_AJAX) {
2553
+			$this->_return_json();
2554
+		} else {
2555
+			throw new EE_Error(sprintf(__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'), __FUNCTION__));
2556
+		}
2557
+	}
2558
+
2559
+
2560
+
2561
+	/**
2562
+	 * This provides a way for child hook classes to send along themselves by reference so methods/properties within them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
2563
+	 *
2564
+	 * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
2565
+	 * @access   public
2566
+	 */
2567
+	public function set_hook_object(EE_Admin_Hooks $hook_obj)
2568
+	{
2569
+		$this->_hook_obj = $hook_obj;
2570
+	}
2571
+
2572
+
2573
+
2574
+	/**
2575
+	 *        generates  HTML wrapper with Tabbed nav for an admin page
2576
+	 *
2577
+	 * @access public
2578
+	 * @param  boolean $about whether to use the special about page wrapper or default.
2579
+	 * @return void
2580
+	 */
2581
+	public function admin_page_wrapper($about = false)
2582
+	{
2583
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2584
+		$this->_nav_tabs = $this->_get_main_nav_tabs();
2585
+		$this->_template_args['nav_tabs'] = $this->_nav_tabs;
2586
+		$this->_template_args['admin_page_title'] = $this->_admin_page_title;
2587
+		$this->_template_args['before_admin_page_content'] = apply_filters('FHEE_before_admin_page_content' . $this->_current_page . $this->_current_view,
2588
+				isset($this->_template_args['before_admin_page_content']) ? $this->_template_args['before_admin_page_content'] : '');
2589
+		$this->_template_args['after_admin_page_content'] = apply_filters('FHEE_after_admin_page_content' . $this->_current_page . $this->_current_view,
2590
+				isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content'] : '');
2591
+		$this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content();
2592
+		// load settings page wrapper template
2593
+		$template_path = ! defined('DOING_AJAX') ? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php' : EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php';
2594
+		//about page?
2595
+		$template_path = $about ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php' : $template_path;
2596
+		if (defined('DOING_AJAX')) {
2597
+			$this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, true);
2598
+			$this->_return_json();
2599
+		} else {
2600
+			EEH_Template::display_template($template_path, $this->_template_args);
2601
+		}
2602
+	}
2603
+
2604
+
2605
+
2606
+	/**
2607
+	 * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
2608
+	 *
2609
+	 * @return string html
2610
+	 */
2611
+	protected function _get_main_nav_tabs()
2612
+	{
2613
+		//let's generate the html using the EEH_Tabbed_Content helper.  We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute (rather than setting in the page_routes array)
2614
+		return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
2615
+	}
2616
+
2617
+
2618
+
2619
+	/**
2620
+	 *        sort nav tabs
2621
+	 *
2622
+	 * @access public
2623
+	 * @param $a
2624
+	 * @param $b
2625
+	 * @return int
2626
+	 */
2627
+	private function _sort_nav_tabs($a, $b)
2628
+	{
2629
+		if ($a['order'] == $b['order']) {
2630
+			return 0;
2631
+		}
2632
+		return ($a['order'] < $b['order']) ? -1 : 1;
2633
+	}
2634
+
2635
+
2636
+
2637
+	/**
2638
+	 *    generates HTML for the forms used on admin pages
2639
+	 *
2640
+	 * @access protected
2641
+	 * @param    array $input_vars - array of input field details
2642
+	 * @param string   $generator  (options are 'string' or 'array', basically use this to indicate which generator to use)
2643
+	 * @return string
2644
+	 * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
2645
+	 * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
2646
+	 */
2647
+	protected function _generate_admin_form_fields($input_vars = array(), $generator = 'string', $id = false)
2648
+	{
2649
+		$content = $generator == 'string' ? EEH_Form_Fields::get_form_fields($input_vars, $id) : EEH_Form_Fields::get_form_fields_array($input_vars);
2650
+		return $content;
2651
+	}
2652
+
2653
+
2654
+
2655
+	/**
2656
+	 * generates the "Save" and "Save & Close" buttons for edit forms
2657
+	 *
2658
+	 * @access protected
2659
+	 * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save & Close" button.
2660
+	 * @param array            $text     if included, generator will use the given text for the buttons ( array([0] => 'Save', [1] => 'save & close')
2661
+	 * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e. via the "name" value in the button).  We can also use this to just dump default actions by submitting some other value.
2662
+	 * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it will use the $referrer string. IF null, then we don't do ANYTHING on save and close (normal form handling).
2663
+	 */
2664
+	protected function _set_save_buttons($both = true, $text = array(), $actions = array(), $referrer = null)
2665
+	{
2666
+		//make sure $text and $actions are in an array
2667
+		$text = (array)$text;
2668
+		$actions = (array)$actions;
2669
+		$referrer_url = empty($referrer) ? '' : $referrer;
2670
+		$referrer_url = ! $referrer ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $_SERVER['REQUEST_URI'] . '" />'
2671
+				: '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $referrer . '" />';
2672
+		$button_text = ! empty($text) ? $text : array(__('Save', 'event_espresso'), __('Save and Close', 'event_espresso'));
2673
+		$default_names = array('save', 'save_and_close');
2674
+		//add in a hidden index for the current page (so save and close redirects properly)
2675
+		$this->_template_args['save_buttons'] = $referrer_url;
2676
+		foreach ($button_text as $key => $button) {
2677
+			$ref = $default_names[$key];
2678
+			$id = $this->_current_view . '_' . $ref;
2679
+			$name = ! empty($actions) ? $actions[$key] : $ref;
2680
+			$this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary ' . $ref . '" value="' . $button . '" name="' . $name . '" id="' . $id . '" />';
2681
+			if ( ! $both) {
2682
+				break;
2683
+			}
2684
+		}
2685
+	}
2686
+
2687
+
2688
+
2689
+	/**
2690
+	 * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
2691
+	 *
2692
+	 * @see   $this->_set_add_edit_form_tags() for details on params
2693
+	 * @since 4.6.0
2694
+	 * @param string $route
2695
+	 * @param array  $additional_hidden_fields
2696
+	 */
2697
+	public function set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
2698
+	{
2699
+		$this->_set_add_edit_form_tags($route, $additional_hidden_fields);
2700
+	}
2701
+
2702
+
2703
+
2704
+	/**
2705
+	 * set form open and close tags on add/edit pages.
2706
+	 *
2707
+	 * @access protected
2708
+	 * @param string $route                    the route you want the form to direct to
2709
+	 * @param array  $additional_hidden_fields any additional hidden fields required in the form header
2710
+	 * @return void
2711
+	 */
2712
+	protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
2713
+	{
2714
+		if (empty($route)) {
2715
+			$user_msg = __('An error occurred. No action was set for this page\'s form.', 'event_espresso');
2716
+			$dev_msg = $user_msg . "\n" . sprintf(__('The $route argument is required for the %s->%s method.', 'event_espresso'), __FUNCTION__, __CLASS__);
2717
+			EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
2718
+		}
2719
+		// open form
2720
+		$this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="' . $this->_admin_base_url . '" id="' . $route . '_event_form" >';
2721
+		// add nonce
2722
+		$nonce = wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
2723
+		//		$nonce = wp_nonce_field( $route . '_nonce', '_wpnonce', FALSE, FALSE );
2724
+		$this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
2725
+		// add REQUIRED form action
2726
+		$hidden_fields = array(
2727
+				'action' => array('type' => 'hidden', 'value' => $route),
2728
+		);
2729
+		// merge arrays
2730
+		$hidden_fields = is_array($additional_hidden_fields) ? array_merge($hidden_fields, $additional_hidden_fields) : $hidden_fields;
2731
+		// generate form fields
2732
+		$form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
2733
+		// add fields to form
2734
+		foreach ((array)$form_fields as $field_name => $form_field) {
2735
+			$this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
2736
+		}
2737
+		// close form
2738
+		$this->_template_args['after_admin_page_content'] = '</form>';
2739
+	}
2740
+
2741
+
2742
+
2743
+	/**
2744
+	 * Public Wrapper for _redirect_after_action() method since its
2745
+	 * discovered it would be useful for external code to have access.
2746
+	 *
2747
+	 * @see   EE_Admin_Page::_redirect_after_action() for params.
2748
+	 * @since 4.5.0
2749
+	 */
2750
+	public function redirect_after_action($success = false, $what = 'item', $action_desc = 'processed', $query_args = array(), $override_overwrite = false)
2751
+	{
2752
+		$this->_redirect_after_action($success, $what, $action_desc, $query_args, $override_overwrite);
2753
+	}
2754
+
2755
+
2756
+
2757
+	/**
2758
+	 *    _redirect_after_action
2759
+	 *
2760
+	 * @param int    $success            - whether success was for two or more records, or just one, or none
2761
+	 * @param string $what               - what the action was performed on
2762
+	 * @param string $action_desc        - what was done ie: updated, deleted, etc
2763
+	 * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin action is completed
2764
+	 * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to override this so that they show.
2765
+	 * @access protected
2766
+	 * @return void
2767
+	 */
2768
+	protected function _redirect_after_action($success = 0, $what = 'item', $action_desc = 'processed', $query_args = array(), $override_overwrite = false)
2769
+	{
2770
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2771
+		//class name for actions/filters.
2772
+		$classname = get_class($this);
2773
+		//set redirect url. Note if there is a "page" index in the $query_args then we go with vanilla admin.php route, otherwise we go with whatever is set as the _admin_base_url
2774
+		$redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
2775
+		$notices = EE_Error::get_notices(false);
2776
+		// overwrite default success messages //BUT ONLY if overwrite not overridden
2777
+		if ( ! $override_overwrite || ! empty($notices['errors'])) {
2778
+			EE_Error::overwrite_success();
2779
+		}
2780
+		if ( ! empty($what) && ! empty($action_desc)) {
2781
+			// how many records affected ? more than one record ? or just one ?
2782
+			if ($success > 1 && empty($notices['errors'])) {
2783
+				// set plural msg
2784
+				EE_Error::add_success(
2785
+						sprintf(
2786
+								__('The "%s" have been successfully %s.', 'event_espresso'),
2787
+								$what,
2788
+								$action_desc
2789
+						),
2790
+						__FILE__, __FUNCTION__, __LINE__
2791
+				);
2792
+			} else if ($success == 1 && empty($notices['errors'])) {
2793
+				// set singular msg
2794
+				EE_Error::add_success(
2795
+						sprintf(
2796
+								__('The "%s" has been successfully %s.', 'event_espresso'),
2797
+								$what,
2798
+								$action_desc
2799
+						),
2800
+						__FILE__, __FUNCTION__, __LINE__
2801
+				);
2802
+			}
2803
+		}
2804
+		// check that $query_args isn't something crazy
2805
+		if ( ! is_array($query_args)) {
2806
+			$query_args = array();
2807
+		}
2808
+		/**
2809
+		 * Allow injecting actions before the query_args are modified for possible different
2810
+		 * redirections on save and close actions
2811
+		 *
2812
+		 * @since 4.2.0
2813
+		 * @param array $query_args       The original query_args array coming into the
2814
+		 *                                method.
2815
+		 */
2816
+		do_action('AHEE__' . $classname . '___redirect_after_action__before_redirect_modification_' . $this->_req_action, $query_args);
2817
+		//calculate where we're going (if we have a "save and close" button pushed)
2818
+		if (isset($this->_req_data['save_and_close']) && isset($this->_req_data['save_and_close_referrer'])) {
2819
+			// even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
2820
+			$parsed_url = parse_url($this->_req_data['save_and_close_referrer']);
2821
+			// regenerate query args array from referrer URL
2822
+			parse_str($parsed_url['query'], $query_args);
2823
+			// correct page and action will be in the query args now
2824
+			$redirect_url = admin_url('admin.php');
2825
+		}
2826
+		//merge any default query_args set in _default_route_query_args property
2827
+		if ( ! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
2828
+			$args_to_merge = array();
2829
+			foreach ($this->_default_route_query_args as $query_param => $query_value) {
2830
+				//is there a wp_referer array in our _default_route_query_args property?
2831
+				if ($query_param == 'wp_referer') {
2832
+					$query_value = (array)$query_value;
2833
+					foreach ($query_value as $reference => $value) {
2834
+						if (strpos($reference, 'nonce') !== false) {
2835
+							continue;
2836
+						}
2837
+						//finally we will override any arguments in the referer with
2838
+						//what might be set on the _default_route_query_args array.
2839
+						if (isset($this->_default_route_query_args[$reference])) {
2840
+							$args_to_merge[$reference] = urlencode($this->_default_route_query_args[$reference]);
2841
+						} else {
2842
+							$args_to_merge[$reference] = urlencode($value);
2843
+						}
2844
+					}
2845
+					continue;
2846
+				}
2847
+				$args_to_merge[$query_param] = $query_value;
2848
+			}
2849
+			//now let's merge these arguments but override with what was specifically sent in to the
2850
+			//redirect.
2851
+			$query_args = array_merge($args_to_merge, $query_args);
2852
+		}
2853
+		$this->_process_notices($query_args);
2854
+		// generate redirect url
2855
+		// if redirecting to anything other than the main page, add a nonce
2856
+		if (isset($query_args['action'])) {
2857
+			// manually generate wp_nonce and merge that with the query vars becuz the wp_nonce_url function wrecks havoc on some vars
2858
+			$query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
2859
+		}
2860
+		//we're adding some hooks and filters in here for processing any things just before redirects (example: an admin page has done an insert or update and we want to run something after that).
2861
+		do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
2862
+		$redirect_url = apply_filters('FHEE_redirect_' . $classname . $this->_req_action, self::add_query_args_and_nonce($query_args, $redirect_url), $query_args);
2863
+		// check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
2864
+		if (defined('DOING_AJAX')) {
2865
+			$default_data = array(
2866
+					'close'        => true,
2867
+					'redirect_url' => $redirect_url,
2868
+					'where'        => 'main',
2869
+					'what'         => 'append',
2870
+			);
2871
+			$this->_template_args['success'] = $success;
2872
+			$this->_template_args['data'] = ! empty($this->_template_args['data']) ? array_merge($default_data, $this->_template_args['data']) : $default_data;
2873
+			$this->_return_json();
2874
+		}
2875
+		wp_safe_redirect($redirect_url);
2876
+		exit();
2877
+	}
2878
+
2879
+
2880
+
2881
+	/**
2882
+	 * process any notices before redirecting (or returning ajax request)
2883
+	 * This method sets the $this->_template_args['notices'] attribute;
2884
+	 *
2885
+	 * @param  array $query_args        any query args that need to be used for notice transient ('action')
2886
+	 * @param bool   $skip_route_verify This is typically used when we are processing notices REALLY early and page_routes haven't been defined yet.
2887
+	 * @param bool   $sticky_notices    This is used to flag that regardless of whether this is doing_ajax or not, we still save a transient for the notice.
2888
+	 * @return void
2889
+	 */
2890
+	protected function _process_notices($query_args = array(), $skip_route_verify = false, $sticky_notices = true)
2891
+	{
2892
+		//first let's set individual error properties if doing_ajax and the properties aren't already set.
2893
+		if (defined('DOING_AJAX') && DOING_AJAX) {
2894
+			$notices = EE_Error::get_notices(false);
2895
+			if (empty($this->_template_args['success'])) {
2896
+				$this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
2897
+			}
2898
+			if (empty($this->_template_args['errors'])) {
2899
+				$this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
2900
+			}
2901
+			if (empty($this->_template_args['attention'])) {
2902
+				$this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
2903
+			}
2904
+		}
2905
+		$this->_template_args['notices'] = EE_Error::get_notices();
2906
+		//IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
2907
+		if ( ! defined('DOING_AJAX') || $sticky_notices) {
2908
+			$route = isset($query_args['action']) ? $query_args['action'] : 'default';
2909
+			$this->_add_transient($route, $this->_template_args['notices'], true, $skip_route_verify);
2910
+		}
2911
+	}
2912
+
2913
+
2914
+
2915
+	/**
2916
+	 * get_action_link_or_button
2917
+	 * returns the button html for adding, editing, or deleting an item (depending on given type)
2918
+	 *
2919
+	 * @param string $action        use this to indicate which action the url is generated with.
2920
+	 * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key) property.
2921
+	 * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
2922
+	 * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
2923
+	 * @param string $base_url      If this is not provided
2924
+	 *                              the _admin_base_url will be used as the default for the button base_url.
2925
+	 *                              Otherwise this value will be used.
2926
+	 * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
2927
+	 * @return string
2928
+	 * @throws \EE_Error
2929
+	 */
2930
+	public function get_action_link_or_button(
2931
+			$action,
2932
+			$type = 'add',
2933
+			$extra_request = array(),
2934
+			$class = 'button-primary',
2935
+			$base_url = '',
2936
+			$exclude_nonce = false
2937
+	) {
2938
+		//first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
2939
+		if (empty($base_url) && ! isset($this->_page_routes[$action])) {
2940
+			throw new EE_Error(
2941
+					sprintf(
2942
+							__(
2943
+									'There is no page route for given action for the button.  This action was given: %s',
2944
+									'event_espresso'
2945
+							),
2946
+							$action
2947
+					)
2948
+			);
2949
+		}
2950
+		if ( ! isset($this->_labels['buttons'][$type])) {
2951
+			throw new EE_Error(
2952
+					sprintf(
2953
+							__(
2954
+									'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
2955
+									'event_espresso'
2956
+							),
2957
+							$type
2958
+					)
2959
+			);
2960
+		}
2961
+		//finally check user access for this button.
2962
+		$has_access = $this->check_user_access($action, true);
2963
+		if ( ! $has_access) {
2964
+			return '';
2965
+		}
2966
+		$_base_url = ! $base_url ? $this->_admin_base_url : $base_url;
2967
+		$query_args = array(
2968
+				'action' => $action,
2969
+		);
2970
+		//merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
2971
+		if ( ! empty($extra_request)) {
2972
+			$query_args = array_merge($extra_request, $query_args);
2973
+		}
2974
+		$url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
2975
+		return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][$type], $class);
2976
+	}
2977
+
2978
+
2979
+
2980
+	/**
2981
+	 * _per_page_screen_option
2982
+	 * Utility function for adding in a per_page_option in the screen_options_dropdown.
2983
+	 *
2984
+	 * @return void
2985
+	 */
2986
+	protected function _per_page_screen_option()
2987
+	{
2988
+		$option = 'per_page';
2989
+		$args = array(
2990
+				'label'   => $this->_admin_page_title,
2991
+				'default' => 10,
2992
+				'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
2993
+		);
2994
+		//ONLY add the screen option if the user has access to it.
2995
+		if ($this->check_user_access($this->_current_view, true)) {
2996
+			add_screen_option($option, $args);
2997
+		}
2998
+	}
2999
+
3000
+
3001
+
3002
+	/**
3003
+	 * set_per_page_screen_option
3004
+	 * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3005
+	 * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than admin_menu.
3006
+	 *
3007
+	 * @access private
3008
+	 * @return void
3009
+	 */
3010
+	private function _set_per_page_screen_options()
3011
+	{
3012
+		if (isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options'])) {
3013
+			check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3014
+			if ( ! $user = wp_get_current_user()) {
3015
+				return;
3016
+			}
3017
+			$option = $_POST['wp_screen_options']['option'];
3018
+			$value = $_POST['wp_screen_options']['value'];
3019
+			if ($option != sanitize_key($option)) {
3020
+				return;
3021
+			}
3022
+			$map_option = $option;
3023
+			$option = str_replace('-', '_', $option);
3024
+			switch ($map_option) {
3025
+				case $this->_current_page . '_' . $this->_current_view . '_per_page':
3026
+					$value = (int)$value;
3027
+					if ($value < 1 || $value > 999) {
3028
+						return;
3029
+					}
3030
+					break;
3031
+				default:
3032
+					$value = apply_filters('FHEE__EE_Admin_Page___set_per_page_screen_options__value', false, $option, $value);
3033
+					if (false === $value) {
3034
+						return;
3035
+					}
3036
+					break;
3037
+			}
3038
+			update_user_meta($user->ID, $option, $value);
3039
+			wp_safe_redirect(remove_query_arg(array('pagenum', 'apage', 'paged'), wp_get_referer()));
3040
+			exit;
3041
+		}
3042
+	}
3043
+
3044
+
3045
+
3046
+	/**
3047
+	 * This just allows for setting the $_template_args property if it needs to be set outside the object
3048
+	 *
3049
+	 * @param array $data array that will be assigned to template args.
3050
+	 */
3051
+	public function set_template_args($data)
3052
+	{
3053
+		$this->_template_args = array_merge($this->_template_args, (array)$data);
3054
+	}
3055
+
3056
+
3057
+
3058
+	/**
3059
+	 * This makes available the WP transient system for temporarily moving data between routes
3060
+	 *
3061
+	 * @access protected
3062
+	 * @param string $route             the route that should receive the transient
3063
+	 * @param array  $data              the data that gets sent
3064
+	 * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a normal route transient.
3065
+	 * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used when we are adding a transient before page_routes have been defined.
3066
+	 * @return void
3067
+	 */
3068
+	protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3069
+	{
3070
+		$user_id = get_current_user_id();
3071
+		if ( ! $skip_route_verify) {
3072
+			$this->_verify_route($route);
3073
+		}
3074
+		//now let's set the string for what kind of transient we're setting
3075
+		$transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id;
3076
+		$data = $notices ? array('notices' => $data) : $data;
3077
+		//is there already a transient for this route?  If there is then let's ADD to that transient
3078
+		$existing = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient);
3079
+		if ($existing) {
3080
+			$data = array_merge((array)$data, (array)$existing);
3081
+		}
3082
+		if (is_multisite() && is_network_admin()) {
3083
+			set_site_transient($transient, $data, 8);
3084
+		} else {
3085
+			set_transient($transient, $data, 8);
3086
+		}
3087
+	}
3088
+
3089
+
3090
+
3091
+	/**
3092
+	 * this retrieves the temporary transient that has been set for moving data between routes.
3093
+	 *
3094
+	 * @param bool $notices true we get notices transient. False we just return normal route transient
3095
+	 * @return mixed data
3096
+	 */
3097
+	protected function _get_transient($notices = false, $route = false)
3098
+	{
3099
+		$user_id = get_current_user_id();
3100
+		$route = ! $route ? $this->_req_action : $route;
3101
+		$transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id;
3102
+		$data = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient);
3103
+		//delete transient after retrieval (just in case it hasn't expired);
3104
+		if (is_multisite() && is_network_admin()) {
3105
+			delete_site_transient($transient);
3106
+		} else {
3107
+			delete_transient($transient);
3108
+		}
3109
+		return $notices && isset($data['notices']) ? $data['notices'] : $data;
3110
+	}
3111
+
3112
+
3113
+
3114
+	/**
3115
+	 * The purpose of this method is just to run garbage collection on any EE transients that might have expired but would not be called later.
3116
+	 * This will be assigned to run on a specific EE Admin page. (place the method in the default route callback on the EE_Admin page you want it run.)
3117
+	 *
3118
+	 * @return void
3119
+	 */
3120
+	protected function _transient_garbage_collection()
3121
+	{
3122
+		global $wpdb;
3123
+		//retrieve all existing transients
3124
+		$query = "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3125
+		if ($results = $wpdb->get_results($query)) {
3126
+			foreach ($results as $result) {
3127
+				$transient = str_replace('_transient_', '', $result->option_name);
3128
+				get_transient($transient);
3129
+				if (is_multisite() && is_network_admin()) {
3130
+					get_site_transient($transient);
3131
+				}
3132
+			}
3133
+		}
3134
+	}
3135
+
3136
+
3137
+
3138
+	/**
3139
+	 * get_view
3140
+	 *
3141
+	 * @access public
3142
+	 * @return string content of _view property
3143
+	 */
3144
+	public function get_view()
3145
+	{
3146
+		return $this->_view;
3147
+	}
3148
+
3149
+
3150
+
3151
+	/**
3152
+	 * getter for the protected $_views property
3153
+	 *
3154
+	 * @return array
3155
+	 */
3156
+	public function get_views()
3157
+	{
3158
+		return $this->_views;
3159
+	}
3160
+
3161
+
3162
+
3163
+	/**
3164
+	 * get_current_page
3165
+	 *
3166
+	 * @access public
3167
+	 * @return string _current_page property value
3168
+	 */
3169
+	public function get_current_page()
3170
+	{
3171
+		return $this->_current_page;
3172
+	}
3173
+
3174
+
3175
+
3176
+	/**
3177
+	 * get_current_view
3178
+	 *
3179
+	 * @access public
3180
+	 * @return string _current_view property value
3181
+	 */
3182
+	public function get_current_view()
3183
+	{
3184
+		return $this->_current_view;
3185
+	}
3186
+
3187
+
3188
+
3189
+	/**
3190
+	 * get_current_screen
3191
+	 *
3192
+	 * @access public
3193
+	 * @return object The current WP_Screen object
3194
+	 */
3195
+	public function get_current_screen()
3196
+	{
3197
+		return $this->_current_screen;
3198
+	}
3199
+
3200
+
3201
+
3202
+	/**
3203
+	 * get_current_page_view_url
3204
+	 *
3205
+	 * @access public
3206
+	 * @return string This returns the url for the current_page_view.
3207
+	 */
3208
+	public function get_current_page_view_url()
3209
+	{
3210
+		return $this->_current_page_view_url;
3211
+	}
3212
+
3213
+
3214
+
3215
+	/**
3216
+	 * just returns the _req_data property
3217
+	 *
3218
+	 * @return array
3219
+	 */
3220
+	public function get_request_data()
3221
+	{
3222
+		return $this->_req_data;
3223
+	}
3224
+
3225
+
3226
+
3227
+	/**
3228
+	 * returns the _req_data protected property
3229
+	 *
3230
+	 * @return string
3231
+	 */
3232
+	public function get_req_action()
3233
+	{
3234
+		return $this->_req_action;
3235
+	}
3236
+
3237
+
3238
+
3239
+	/**
3240
+	 * @return bool  value of $_is_caf property
3241
+	 */
3242
+	public function is_caf()
3243
+	{
3244
+		return $this->_is_caf;
3245
+	}
3246
+
3247
+
3248
+
3249
+	/**
3250
+	 * @return mixed
3251
+	 */
3252
+	public function default_espresso_metaboxes()
3253
+	{
3254
+		return $this->_default_espresso_metaboxes;
3255
+	}
3256
+
3257
+
3258
+
3259
+	/**
3260
+	 * @return mixed
3261
+	 */
3262
+	public function admin_base_url()
3263
+	{
3264
+		return $this->_admin_base_url;
3265
+	}
3266
+
3267
+
3268
+
3269
+	/**
3270
+	 * @return mixed
3271
+	 */
3272
+	public function wp_page_slug()
3273
+	{
3274
+		return $this->_wp_page_slug;
3275
+	}
3276
+
3277
+
3278
+
3279
+	/**
3280
+	 * updates  espresso configuration settings
3281
+	 *
3282
+	 * @access    protected
3283
+	 * @param string                   $tab
3284
+	 * @param EE_Config_Base|EE_Config $config
3285
+	 * @param string                   $file file where error occurred
3286
+	 * @param string                   $func function  where error occurred
3287
+	 * @param string                   $line line no where error occurred
3288
+	 * @return boolean
3289
+	 */
3290
+	protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
3291
+	{
3292
+		//remove any options that are NOT going to be saved with the config settings.
3293
+		if (isset($config->core->ee_ueip_optin)) {
3294
+			$config->core->ee_ueip_has_notified = true;
3295
+			// TODO: remove the following two lines and make sure values are migrated from 3.1
3296
+			update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
3297
+			update_option('ee_ueip_has_notified', true);
3298
+		}
3299
+		// and save it (note we're also doing the network save here)
3300
+		$net_saved = is_main_site() ? EE_Network_Config::instance()->update_config(false, false) : true;
3301
+		$config_saved = EE_Config::instance()->update_espresso_config(false, false);
3302
+		if ($config_saved && $net_saved) {
3303
+			EE_Error::add_success(sprintf(__('"%s" have been successfully updated.', 'event_espresso'), $tab));
3304
+			return true;
3305
+		} else {
3306
+			EE_Error::add_error(sprintf(__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
3307
+			return false;
3308
+		}
3309
+	}
3310
+
3311
+
3312
+
3313
+	/**
3314
+	 * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
3315
+	 *
3316
+	 * @return array
3317
+	 */
3318
+	public function get_yes_no_values()
3319
+	{
3320
+		return $this->_yes_no_values;
3321
+	}
3322
+
3323
+
3324
+
3325
+	protected function _get_dir()
3326
+	{
3327
+		$reflector = new ReflectionClass(get_class($this));
3328
+		return dirname($reflector->getFileName());
3329
+	}
3330
+
3331
+
3332
+
3333
+	/**
3334
+	 * A helper for getting a "next link".
3335
+	 *
3336
+	 * @param string $url   The url to link to
3337
+	 * @param string $class The class to use.
3338
+	 * @return string
3339
+	 */
3340
+	protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
3341
+	{
3342
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
3343
+	}
3344
+
3345
+
3346
+
3347
+	/**
3348
+	 * A helper for getting a "previous link".
3349
+	 *
3350
+	 * @param string $url   The url to link to
3351
+	 * @param string $class The class to use.
3352
+	 * @return string
3353
+	 */
3354
+	protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
3355
+	{
3356
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
3357
+	}
3358
+
3359
+
3360
+
3361
+
3362
+
3363
+
3364
+
3365
+	//below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
3366
+	/**
3367
+	 * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller knows that the _REG_ID isn't in the req_data array but CAN obtain it, the caller should ADD the _REG_ID to the _req_data
3368
+	 * array.
3369
+	 *
3370
+	 * @return bool success/fail
3371
+	 */
3372
+	protected function _process_resend_registration()
3373
+	{
3374
+		$this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
3375
+		do_action('AHEE__EE_Admin_Page___process_resend_registration', $this->_template_args['success'], $this->_req_data);
3376
+		return $this->_template_args['success'];
3377
+	}
3378
+
3379
+
3380
+
3381
+	/**
3382
+	 * This automatically processes any payment message notifications when manual payment has been applied.
3383
+	 *
3384
+	 * @access protected
3385
+	 * @param \EE_Payment $payment
3386
+	 * @return bool success/fail
3387
+	 */
3388
+	protected function _process_payment_notification(EE_Payment $payment)
3389
+	{
3390
+		add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
3391
+		do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
3392
+		$this->_template_args['success'] = apply_filters('FHEE__EE_Admin_Page___process_admin_payment_notification__success', false, $payment);
3393
+		return $this->_template_args['success'];
3394
+	}
3395 3395
 
3396 3396
 
3397 3397
 }
Please login to merge, or discard this patch.
Spacing   +146 added lines, -146 removed lines patch added patch discarded remove patch
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
         $this->_current_page = ! empty($_GET['page']) ? sanitize_key($_GET['page']) : '';
474 474
         $this->page_folder = strtolower(str_replace('_Admin_Page', '', str_replace('Extend_', '', get_class($this))));
475 475
         global $ee_menu_slugs;
476
-        $ee_menu_slugs = (array)$ee_menu_slugs;
476
+        $ee_menu_slugs = (array) $ee_menu_slugs;
477 477
         if (( ! $this->_current_page || ! isset($ee_menu_slugs[$this->_current_page])) && ! defined('DOING_AJAX')) {
478 478
             return false;
479 479
         }
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
         //however if we are doing_ajax and we've got a 'route' set then that's what the req_action will be
489 489
         $this->_req_action = defined('DOING_AJAX') && isset($this->_req_data['route']) ? $this->_req_data['route'] : $this->_req_action;
490 490
         $this->_current_view = $this->_req_action;
491
-        $this->_req_nonce = $this->_req_action . '_nonce';
491
+        $this->_req_nonce = $this->_req_action.'_nonce';
492 492
         $this->_define_page_props();
493 493
         $this->_current_page_view_url = add_query_arg(array('page' => $this->_current_page, 'action' => $this->_current_view), $this->_admin_base_url);
494 494
         //default things
@@ -509,11 +509,11 @@  discard block
 block discarded – undo
509 509
             $this->_extend_page_config_for_cpt();
510 510
         }
511 511
         //filter routes and page_config so addons can add their stuff. Filtering done per class
512
-        $this->_page_routes = apply_filters('FHEE__' . get_class($this) . '__page_setup__page_routes', $this->_page_routes, $this);
513
-        $this->_page_config = apply_filters('FHEE__' . get_class($this) . '__page_setup__page_config', $this->_page_config, $this);
512
+        $this->_page_routes = apply_filters('FHEE__'.get_class($this).'__page_setup__page_routes', $this->_page_routes, $this);
513
+        $this->_page_config = apply_filters('FHEE__'.get_class($this).'__page_setup__page_config', $this->_page_config, $this);
514 514
         //if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
515
-        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
516
-            add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view), 10, 2);
515
+        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view)) {
516
+            add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view), 10, 2);
517 517
         }
518 518
         //next route only if routing enabled
519 519
         if ($this->_routing && ! defined('DOING_AJAX')) {
@@ -523,8 +523,8 @@  discard block
 block discarded – undo
523 523
             if ($this->_is_UI_request) {
524 524
                 //admin_init stuff - global, all views for this page class, specific view
525 525
                 add_action('admin_init', array($this, 'admin_init'), 10);
526
-                if (method_exists($this, 'admin_init_' . $this->_current_view)) {
527
-                    add_action('admin_init', array($this, 'admin_init_' . $this->_current_view), 15);
526
+                if (method_exists($this, 'admin_init_'.$this->_current_view)) {
527
+                    add_action('admin_init', array($this, 'admin_init_'.$this->_current_view), 15);
528 528
                 }
529 529
             } else {
530 530
                 //hijack regular WP loading and route admin request immediately
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
      */
545 545
     private function _do_other_page_hooks()
546 546
     {
547
-        $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, array());
547
+        $registered_pages = apply_filters('FHEE_do_other_page_hooks_'.$this->page_slug, array());
548 548
         foreach ($registered_pages as $page) {
549 549
             //now let's setup the file name and class that should be present
550 550
             $classname = str_replace('.class.php', '', $page);
@@ -590,13 +590,13 @@  discard block
 block discarded – undo
590 590
         //load admin_notices - global, page class, and view specific
591 591
         add_action('admin_notices', array($this, 'admin_notices_global'), 5);
592 592
         add_action('admin_notices', array($this, 'admin_notices'), 10);
593
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
594
-            add_action('admin_notices', array($this, 'admin_notices_' . $this->_current_view), 15);
593
+        if (method_exists($this, 'admin_notices_'.$this->_current_view)) {
594
+            add_action('admin_notices', array($this, 'admin_notices_'.$this->_current_view), 15);
595 595
         }
596 596
         //load network admin_notices - global, page class, and view specific
597 597
         add_action('network_admin_notices', array($this, 'network_admin_notices_global'), 5);
598
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
599
-            add_action('network_admin_notices', array($this, 'network_admin_notices_' . $this->_current_view));
598
+        if (method_exists($this, 'network_admin_notices_'.$this->_current_view)) {
599
+            add_action('network_admin_notices', array($this, 'network_admin_notices_'.$this->_current_view));
600 600
         }
601 601
         //this will save any per_page screen options if they are present
602 602
         $this->_set_per_page_screen_options();
@@ -608,8 +608,8 @@  discard block
 block discarded – undo
608 608
         //add screen options - global, page child class, and view specific
609 609
         $this->_add_global_screen_options();
610 610
         $this->_add_screen_options();
611
-        if (method_exists($this, '_add_screen_options_' . $this->_current_view)) {
612
-            call_user_func(array($this, '_add_screen_options_' . $this->_current_view));
611
+        if (method_exists($this, '_add_screen_options_'.$this->_current_view)) {
612
+            call_user_func(array($this, '_add_screen_options_'.$this->_current_view));
613 613
         }
614 614
         //add help tab(s) and tours- set via page_config and qtips.
615 615
         $this->_add_help_tour();
@@ -618,31 +618,31 @@  discard block
 block discarded – undo
618 618
         //add feature_pointers - global, page child class, and view specific
619 619
         $this->_add_feature_pointers();
620 620
         $this->_add_global_feature_pointers();
621
-        if (method_exists($this, '_add_feature_pointer_' . $this->_current_view)) {
622
-            call_user_func(array($this, '_add_feature_pointer_' . $this->_current_view));
621
+        if (method_exists($this, '_add_feature_pointer_'.$this->_current_view)) {
622
+            call_user_func(array($this, '_add_feature_pointer_'.$this->_current_view));
623 623
         }
624 624
         //enqueue scripts/styles - global, page class, and view specific
625 625
         add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5);
626 626
         add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10);
627
-        if (method_exists($this, 'load_scripts_styles_' . $this->_current_view)) {
628
-            add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_' . $this->_current_view), 15);
627
+        if (method_exists($this, 'load_scripts_styles_'.$this->_current_view)) {
628
+            add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_'.$this->_current_view), 15);
629 629
         }
630 630
         add_action('admin_enqueue_scripts', array($this, 'admin_footer_scripts_eei18n_js_strings'), 100);
631 631
         //admin_print_footer_scripts - global, page child class, and view specific.  NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.  In most cases that's doing_it_wrong().  But adding hidden container elements etc. is a good use case. Notice the late priority we're giving these
632 632
         add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_global'), 99);
633 633
         add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts'), 100);
634
-        if (method_exists($this, 'admin_footer_scripts_' . $this->_current_view)) {
635
-            add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_' . $this->_current_view), 101);
634
+        if (method_exists($this, 'admin_footer_scripts_'.$this->_current_view)) {
635
+            add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_'.$this->_current_view), 101);
636 636
         }
637 637
         //admin footer scripts
638 638
         add_action('admin_footer', array($this, 'admin_footer_global'), 99);
639 639
         add_action('admin_footer', array($this, 'admin_footer'), 100);
640
-        if (method_exists($this, 'admin_footer_' . $this->_current_view)) {
641
-            add_action('admin_footer', array($this, 'admin_footer_' . $this->_current_view), 101);
640
+        if (method_exists($this, 'admin_footer_'.$this->_current_view)) {
641
+            add_action('admin_footer', array($this, 'admin_footer_'.$this->_current_view), 101);
642 642
         }
643 643
         do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
644 644
         //targeted hook
645
-        do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load__' . $this->page_slug . '__' . $this->_req_action);
645
+        do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load__'.$this->page_slug.'__'.$this->_req_action);
646 646
     }
647 647
 
648 648
 
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
             // user error msg
719 719
             $error_msg = sprintf(__('No page routes have been set for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
720 720
             // developer error msg
721
-            $error_msg .= '||' . $error_msg . __(' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.', 'event_espresso');
721
+            $error_msg .= '||'.$error_msg.__(' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.', 'event_espresso');
722 722
             throw new EE_Error($error_msg);
723 723
         }
724 724
         // and that the requested page route exists
@@ -729,7 +729,7 @@  discard block
 block discarded – undo
729 729
             // user error msg
730 730
             $error_msg = sprintf(__('The requested page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
731 731
             // developer error msg
732
-            $error_msg .= '||' . $error_msg . sprintf(__(' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.', 'event_espresso'), $this->_req_action);
732
+            $error_msg .= '||'.$error_msg.sprintf(__(' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.', 'event_espresso'), $this->_req_action);
733 733
             throw new EE_Error($error_msg);
734 734
         }
735 735
         // and that a default route exists
@@ -737,7 +737,7 @@  discard block
 block discarded – undo
737 737
             // user error msg
738 738
             $error_msg = sprintf(__('A default page route has not been set for the % admin page.', 'event_espresso'), $this->_admin_page_title);
739 739
             // developer error msg
740
-            $error_msg .= '||' . $error_msg . __(' Create a key in the "_page_routes" array named "default" and set its value to your default page method.', 'event_espresso');
740
+            $error_msg .= '||'.$error_msg.__(' Create a key in the "_page_routes" array named "default" and set its value to your default page method.', 'event_espresso');
741 741
             throw new EE_Error($error_msg);
742 742
         }
743 743
         //first lets' catch if the UI request has EVER been set.
@@ -766,7 +766,7 @@  discard block
 block discarded – undo
766 766
             // user error msg
767 767
             $error_msg = sprintf(__('The given page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
768 768
             // developer error msg
769
-            $error_msg .= '||' . $error_msg . sprintf(__(' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property', 'event_espresso'), $route);
769
+            $error_msg .= '||'.$error_msg.sprintf(__(' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property', 'event_espresso'), $route);
770 770
             throw new EE_Error($error_msg);
771 771
         }
772 772
     }
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
             // these are not the droids you are looking for !!!
789 789
             $msg = sprintf(__('%sNonce Fail.%s', 'event_espresso'), '<a href="http://www.youtube.com/watch?v=56_S0WeTkzs">', '</a>');
790 790
             if (WP_DEBUG) {
791
-                $msg .= "\n  " . sprintf(__('In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!', 'event_espresso'), __CLASS__);
791
+                $msg .= "\n  ".sprintf(__('In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!', 'event_espresso'), __CLASS__);
792 792
             }
793 793
             if ( ! defined('DOING_AJAX')) {
794 794
                 wp_die($msg);
@@ -963,7 +963,7 @@  discard block
 block discarded – undo
963 963
                 if (strpos($key, 'nonce') !== false) {
964 964
                     continue;
965 965
                 }
966
-                $args['wp_referer[' . $key . ']'] = $value;
966
+                $args['wp_referer['.$key.']'] = $value;
967 967
             }
968 968
         }
969 969
         return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
@@ -1009,7 +1009,7 @@  discard block
 block discarded – undo
1009 1009
                     if ($tour instanceof EE_Help_Tour_final_stop) {
1010 1010
                         continue;
1011 1011
                     }
1012
-                    $tb[] = '<button id="trigger-tour-' . $tour->get_slug() . '" class="button-primary trigger-ee-help-tour">' . $tour->get_label() . '</button>';
1012
+                    $tb[] = '<button id="trigger-tour-'.$tour->get_slug().'" class="button-primary trigger-ee-help-tour">'.$tour->get_label().'</button>';
1013 1013
                 }
1014 1014
                 $tour_buttons .= implode('<br />', $tb);
1015 1015
                 $tour_buttons .= '</div></div>';
@@ -1021,7 +1021,7 @@  discard block
 block discarded – undo
1021 1021
                     throw new EE_Error(sprintf(__('The _page_config array has a callback set for the "help_sidebar" option.  However the callback given (%s) is not a valid callback.  Doublecheck the spelling and make sure this method exists for the class %s',
1022 1022
                             'event_espresso'), $config['help_sidebar'], get_class($this)));
1023 1023
                 }
1024
-                $content = apply_filters('FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar', call_user_func(array($this, $config['help_sidebar'])));
1024
+                $content = apply_filters('FHEE__'.get_class($this).'__add_help_tabs__help_sidebar', call_user_func(array($this, $config['help_sidebar'])));
1025 1025
                 $content .= $tour_buttons; //add help tour buttons.
1026 1026
                 //do we have any help tours setup?  Cause if we do we want to add the buttons
1027 1027
                 $this->_current_screen->set_help_sidebar($content);
@@ -1034,13 +1034,13 @@  discard block
 block discarded – undo
1034 1034
             if ( ! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1035 1035
                 $_ht['id'] = $this->page_slug;
1036 1036
                 $_ht['title'] = __('Help Tours', 'event_espresso');
1037
-                $_ht['content'] = '<p>' . __('The buttons to the right allow you to start/restart any help tours available for this page', 'event_espresso') . '</p>';
1037
+                $_ht['content'] = '<p>'.__('The buttons to the right allow you to start/restart any help tours available for this page', 'event_espresso').'</p>';
1038 1038
                 $this->_current_screen->add_help_tab($_ht);
1039 1039
             }/**/
1040 1040
             if ( ! isset($config['help_tabs'])) {
1041 1041
                 return;
1042 1042
             } //no help tabs for this route
1043
-            foreach ((array)$config['help_tabs'] as $tab_id => $cfg) {
1043
+            foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1044 1044
                 //we're here so there ARE help tabs!
1045 1045
                 //make sure we've got what we need
1046 1046
                 if ( ! isset($cfg['title'])) {
@@ -1055,9 +1055,9 @@  discard block
 block discarded – undo
1055 1055
                     $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1056 1056
                     //second priority goes to filename
1057 1057
                 } else if ( ! empty($cfg['filename'])) {
1058
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1058
+                    $file_path = $this->_get_dir().'/help_tabs/'.$cfg['filename'].'.help_tab.php';
1059 1059
                     //it's possible that the file is located on decaf route (and above sets up for caf route, if this is the case then lets check decaf route too)
1060
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tabs/' . $cfg['filename'] . '.help_tab.php' : $file_path;
1060
+                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES.basename($this->_get_dir()).'/help_tabs/'.$cfg['filename'].'.help_tab.php' : $file_path;
1061 1061
                     //if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1062 1062
                     if ( ! is_readable($file_path) && ! isset($cfg['callback'])) {
1063 1063
                         EE_Error::add_error(sprintf(__('The filename given for the help tab %s is not a valid file and there is no other configuration for the tab content.  Please check that the string you set for the help tab on this route (%s) is the correct spelling.  The file should be in %s',
@@ -1076,7 +1076,7 @@  discard block
 block discarded – undo
1076 1076
                     return;
1077 1077
                 }
1078 1078
                 //setup config array for help tab method
1079
-                $id = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1079
+                $id = $this->page_slug.'-'.$this->_req_action.'-'.$tab_id;
1080 1080
                 $_ht = array(
1081 1081
                         'id'       => $id,
1082 1082
                         'title'    => $cfg['title'],
@@ -1114,9 +1114,9 @@  discard block
 block discarded – undo
1114 1114
             }
1115 1115
             if (isset($config['help_tour'])) {
1116 1116
                 foreach ($config['help_tour'] as $tour) {
1117
-                    $file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1117
+                    $file_path = $this->_get_dir().'/help_tours/'.$tour.'.class.php';
1118 1118
                     //let's see if we can get that file... if not its possible this is a decaf route not set in caffienated so lets try and get the caffeinated equivalent
1119
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tours/' . $tour . '.class.php' : $file_path;
1119
+                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES.basename($this->_get_dir()).'/help_tours/'.$tour.'.class.php' : $file_path;
1120 1120
                     //if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1121 1121
                     if ( ! is_readable($file_path)) {
1122 1122
                         EE_Error::add_error(sprintf(__('The file path given for the help tour (%s) is not a valid path.  Please check that the string you set for the help tour on this route (%s) is the correct spelling', 'event_espresso'),
@@ -1126,7 +1126,7 @@  discard block
 block discarded – undo
1126 1126
                     require_once $file_path;
1127 1127
                     if ( ! class_exists($tour)) {
1128 1128
                         $error_msg[] = sprintf(__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'), $tour);
1129
-                        $error_msg[] = $error_msg[0] . "\r\n" . sprintf(__('There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.',
1129
+                        $error_msg[] = $error_msg[0]."\r\n".sprintf(__('There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.',
1130 1130
                                         'event_espresso'), $tour, '<br />', $tour, $this->_req_action, get_class($this));
1131 1131
                         throw new EE_Error(implode('||', $error_msg));
1132 1132
                     }
@@ -1158,11 +1158,11 @@  discard block
 block discarded – undo
1158 1158
     protected function _add_qtips()
1159 1159
     {
1160 1160
         if (isset($this->_route_config['qtips'])) {
1161
-            $qtips = (array)$this->_route_config['qtips'];
1161
+            $qtips = (array) $this->_route_config['qtips'];
1162 1162
             //load qtip loader
1163 1163
             $path = array(
1164
-                    $this->_get_dir() . '/qtips/',
1165
-                    EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1164
+                    $this->_get_dir().'/qtips/',
1165
+                    EE_ADMIN_PAGES.basename($this->_get_dir()).'/qtips/',
1166 1166
             );
1167 1167
             EEH_Qtip_Loader::instance()->register($qtips, $path);
1168 1168
         }
@@ -1192,11 +1192,11 @@  discard block
 block discarded – undo
1192 1192
             if ( ! $this->check_user_access($slug, true)) {
1193 1193
                 continue;
1194 1194
             } //no nav tab becasue current user does not have access.
1195
-            $css_class = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1195
+            $css_class = isset($config['css_class']) ? $config['css_class'].' ' : '';
1196 1196
             $this->_nav_tabs[$slug] = array(
1197 1197
                     'url'       => isset($config['nav']['url']) ? $config['nav']['url'] : self::add_query_args_and_nonce(array('action' => $slug), $this->_admin_base_url),
1198 1198
                     'link_text' => isset($config['nav']['label']) ? $config['nav']['label'] : ucwords(str_replace('_', ' ', $slug)),
1199
-                    'css_class' => $this->_req_action == $slug ? $css_class . 'nav-tab-active' : $css_class,
1199
+                    'css_class' => $this->_req_action == $slug ? $css_class.'nav-tab-active' : $css_class,
1200 1200
                     'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1201 1201
             );
1202 1202
             $i++;
@@ -1259,11 +1259,11 @@  discard block
 block discarded – undo
1259 1259
             $capability = empty($capability) ? 'manage_options' : $capability;
1260 1260
         }
1261 1261
         $id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1262
-        if (( ! function_exists('is_admin') || ! EE_Registry::instance()->CAP->current_user_can($capability, $this->page_slug . '_' . $route_to_check, $id)) && ! defined('DOING_AJAX')) {
1262
+        if (( ! function_exists('is_admin') || ! EE_Registry::instance()->CAP->current_user_can($capability, $this->page_slug.'_'.$route_to_check, $id)) && ! defined('DOING_AJAX')) {
1263 1263
             if ($verify_only) {
1264 1264
                 return false;
1265 1265
             } else {
1266
-                if ( is_user_logged_in() ) {
1266
+                if (is_user_logged_in()) {
1267 1267
                     wp_die(__('You do not have access to this route.', 'event_espresso'));
1268 1268
                 } else {
1269 1269
                     return false;
@@ -1355,7 +1355,7 @@  discard block
 block discarded – undo
1355 1355
     public function admin_footer_global()
1356 1356
     {
1357 1357
         //dialog container for dialog helper
1358
-        $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n";
1358
+        $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">'."\n";
1359 1359
         $d_cont .= '<div class="ee-notices"></div>';
1360 1360
         $d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>';
1361 1361
         $d_cont .= '</div>';
@@ -1365,7 +1365,7 @@  discard block
 block discarded – undo
1365 1365
             echo implode('<br />', $this->_help_tour[$this->_req_action]);
1366 1366
         }
1367 1367
         //current set timezone for timezone js
1368
-        echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>';
1368
+        echo '<span id="current_timezone" class="hidden">'.EEH_DTT_Helper::get_timezone().'</span>';
1369 1369
     }
1370 1370
 
1371 1371
 
@@ -1390,7 +1390,7 @@  discard block
 block discarded – undo
1390 1390
     {
1391 1391
         $content = '';
1392 1392
         $help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1393
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php';
1393
+        $template_path = EE_ADMIN_TEMPLATE.'admin_help_popup.template.php';
1394 1394
         //loop through the array and setup content
1395 1395
         foreach ($help_array as $trigger => $help) {
1396 1396
             //make sure the array is setup properly
@@ -1424,7 +1424,7 @@  discard block
 block discarded – undo
1424 1424
     private function _get_help_content()
1425 1425
     {
1426 1426
         //what is the method we're looking for?
1427
-        $method_name = '_help_popup_content_' . $this->_req_action;
1427
+        $method_name = '_help_popup_content_'.$this->_req_action;
1428 1428
         //if method doesn't exist let's get out.
1429 1429
         if ( ! method_exists($this, $method_name)) {
1430 1430
             return array();
@@ -1468,8 +1468,8 @@  discard block
 block discarded – undo
1468 1468
             $help_content = $this->_set_help_popup_content($help_array, false);
1469 1469
         }
1470 1470
         //let's setup the trigger
1471
-        $content = '<a class="ee-dialog" href="?height=' . $dimensions[0] . '&width=' . $dimensions[1] . '&inlineId=' . $trigger_id . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1472
-        $content = $content . $help_content;
1471
+        $content = '<a class="ee-dialog" href="?height='.$dimensions[0].'&width='.$dimensions[1].'&inlineId='.$trigger_id.'" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1472
+        $content = $content.$help_content;
1473 1473
         if ($display) {
1474 1474
             echo $content;
1475 1475
         } else {
@@ -1529,32 +1529,32 @@  discard block
 block discarded – undo
1529 1529
             add_action('admin_head', array($this, 'add_xdebug_style'));
1530 1530
         }
1531 1531
         //register all styles
1532
-        wp_register_style('espresso-ui-theme', EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION);
1533
-        wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
1532
+        wp_register_style('espresso-ui-theme', EE_GLOBAL_ASSETS_URL.'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION);
1533
+        wp_register_style('ee-admin-css', EE_ADMIN_URL.'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
1534 1534
         //helpers styles
1535
-        wp_register_style('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css', array(), EVENT_ESPRESSO_VERSION);
1535
+        wp_register_style('ee-text-links', EE_PLUGIN_DIR_URL.'core/helpers/assets/ee_text_list_helper.css', array(), EVENT_ESPRESSO_VERSION);
1536 1536
         //enqueue global styles
1537 1537
         wp_enqueue_style('ee-admin-css');
1538 1538
         /** SCRIPTS **/
1539 1539
         //register all scripts
1540
-        wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1541
-        wp_register_script('ee-dialog', EE_ADMIN_URL . 'assets/ee-dialog-helper.js', array('jquery', 'jquery-ui-draggable'), EVENT_ESPRESSO_VERSION, true);
1542
-        wp_register_script('ee_admin_js', EE_ADMIN_URL . 'assets/ee-admin-page.js', array('espresso_core', 'ee-parse-uri', 'ee-dialog'), EVENT_ESPRESSO_VERSION, true);
1543
-        wp_register_script('jquery-ui-timepicker-addon', EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), EVENT_ESPRESSO_VERSION, true);
1540
+        wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1541
+        wp_register_script('ee-dialog', EE_ADMIN_URL.'assets/ee-dialog-helper.js', array('jquery', 'jquery-ui-draggable'), EVENT_ESPRESSO_VERSION, true);
1542
+        wp_register_script('ee_admin_js', EE_ADMIN_URL.'assets/ee-admin-page.js', array('espresso_core', 'ee-parse-uri', 'ee-dialog'), EVENT_ESPRESSO_VERSION, true);
1543
+        wp_register_script('jquery-ui-timepicker-addon', EE_GLOBAL_ASSETS_URL.'scripts/jquery-ui-timepicker-addon.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), EVENT_ESPRESSO_VERSION, true);
1544 1544
         // register jQuery Validate - see /includes/functions/wp_hooks.php
1545 1545
         add_filter('FHEE_load_jquery_validate', '__return_true');
1546 1546
         add_filter('FHEE_load_joyride', '__return_true');
1547 1547
         //script for sorting tables
1548
-        wp_register_script('espresso_ajax_table_sorting', EE_ADMIN_URL . "assets/espresso_ajax_table_sorting.js", array('ee_admin_js', 'jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true);
1548
+        wp_register_script('espresso_ajax_table_sorting', EE_ADMIN_URL."assets/espresso_ajax_table_sorting.js", array('ee_admin_js', 'jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true);
1549 1549
         //script for parsing uri's
1550
-        wp_register_script('ee-parse-uri', EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js', array(), EVENT_ESPRESSO_VERSION, true);
1550
+        wp_register_script('ee-parse-uri', EE_GLOBAL_ASSETS_URL.'scripts/parseuri.js', array(), EVENT_ESPRESSO_VERSION, true);
1551 1551
         //and parsing associative serialized form elements
1552
-        wp_register_script('ee-serialize-full-array', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1552
+        wp_register_script('ee-serialize-full-array', EE_GLOBAL_ASSETS_URL.'scripts/jquery.serializefullarray.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1553 1553
         //helpers scripts
1554
-        wp_register_script('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1555
-        wp_register_script('ee-moment-core', EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js', array(), EVENT_ESPRESSO_VERSION, true);
1556
-        wp_register_script('ee-moment', EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js', array('ee-moment-core'), EVENT_ESPRESSO_VERSION, true);
1557
-        wp_register_script('ee-datepicker', EE_ADMIN_URL . 'assets/ee-datepicker.js', array('jquery-ui-timepicker-addon', 'ee-moment'), EVENT_ESPRESSO_VERSION, true);
1554
+        wp_register_script('ee-text-links', EE_PLUGIN_DIR_URL.'core/helpers/assets/ee_text_list_helper.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1555
+        wp_register_script('ee-moment-core', EE_THIRD_PARTY_URL.'moment/moment-with-locales.min.js', array(), EVENT_ESPRESSO_VERSION, true);
1556
+        wp_register_script('ee-moment', EE_THIRD_PARTY_URL.'moment/moment-timezone-with-data.min.js', array('ee-moment-core'), EVENT_ESPRESSO_VERSION, true);
1557
+        wp_register_script('ee-datepicker', EE_ADMIN_URL.'assets/ee-datepicker.js', array('jquery-ui-timepicker-addon', 'ee-moment'), EVENT_ESPRESSO_VERSION, true);
1558 1558
         //google charts
1559 1559
         wp_register_script('google-charts', 'https://www.gstatic.com/charts/loader.js', array(), EVENT_ESPRESSO_VERSION, false);
1560 1560
         //enqueue global scripts
@@ -1575,7 +1575,7 @@  discard block
 block discarded – undo
1575 1575
          */
1576 1576
         if ( ! empty($this->_help_tour)) {
1577 1577
             //register the js for kicking things off
1578
-            wp_enqueue_script('ee-help-tour', EE_ADMIN_URL . 'assets/ee-help-tour.js', array('jquery-joyride'), EVENT_ESPRESSO_VERSION, true);
1578
+            wp_enqueue_script('ee-help-tour', EE_ADMIN_URL.'assets/ee-help-tour.js', array('jquery-joyride'), EVENT_ESPRESSO_VERSION, true);
1579 1579
             //setup tours for the js tour object
1580 1580
             foreach ($this->_help_tour['tours'] as $tour) {
1581 1581
                 $tours[] = array(
@@ -1674,17 +1674,17 @@  discard block
 block discarded – undo
1674 1674
             return;
1675 1675
         } //not a list_table view so get out.
1676 1676
         //list table functions are per view specific (because some admin pages might have more than one listtable!)
1677
-        if (call_user_func(array($this, '_set_list_table_views_' . $this->_req_action)) === false) {
1677
+        if (call_user_func(array($this, '_set_list_table_views_'.$this->_req_action)) === false) {
1678 1678
             //user error msg
1679 1679
             $error_msg = __('An error occurred. The requested list table views could not be found.', 'event_espresso');
1680 1680
             //developer error msg
1681
-            $error_msg .= '||' . sprintf(__('List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.', 'event_espresso'),
1682
-                            $this->_req_action, '_set_list_table_views_' . $this->_req_action);
1681
+            $error_msg .= '||'.sprintf(__('List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.', 'event_espresso'),
1682
+                            $this->_req_action, '_set_list_table_views_'.$this->_req_action);
1683 1683
             throw new EE_Error($error_msg);
1684 1684
         }
1685 1685
         //let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
1686
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action, $this->_views);
1687
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
1686
+        $this->_views = apply_filters('FHEE_list_table_views_'.$this->page_slug.'_'.$this->_req_action, $this->_views);
1687
+        $this->_views = apply_filters('FHEE_list_table_views_'.$this->page_slug, $this->_views);
1688 1688
         $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
1689 1689
         $this->_set_list_table_view();
1690 1690
         $this->_set_list_table_object();
@@ -1759,7 +1759,7 @@  discard block
 block discarded – undo
1759 1759
             // check for current view
1760 1760
             $this->_views[$key]['class'] = $this->_view == $view['slug'] ? 'current' : '';
1761 1761
             $query_args['action'] = $this->_req_action;
1762
-            $query_args[$this->_req_action . '_nonce'] = wp_create_nonce($query_args['action'] . '_nonce');
1762
+            $query_args[$this->_req_action.'_nonce'] = wp_create_nonce($query_args['action'].'_nonce');
1763 1763
             $query_args['status'] = $view['slug'];
1764 1764
             //merge any other arguments sent in.
1765 1765
             if (isset($extra_query_args[$view['slug']])) {
@@ -1797,14 +1797,14 @@  discard block
 block discarded – undo
1797 1797
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
1798 1798
         foreach ($values as $value) {
1799 1799
             if ($value < $max_entries) {
1800
-                $selected = $value == $per_page ? ' selected="' . $per_page . '"' : '';
1800
+                $selected = $value == $per_page ? ' selected="'.$per_page.'"' : '';
1801 1801
                 $entries_per_page_dropdown .= '
1802
-						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
1802
+						<option value="' . $value.'"'.$selected.'>'.$value.'&nbsp;&nbsp;</option>';
1803 1803
             }
1804 1804
         }
1805
-        $selected = $max_entries == $per_page ? ' selected="' . $per_page . '"' : '';
1805
+        $selected = $max_entries == $per_page ? ' selected="'.$per_page.'"' : '';
1806 1806
         $entries_per_page_dropdown .= '
1807
-						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
1807
+						<option value="' . $max_entries.'"'.$selected.'>All&nbsp;&nbsp;</option>';
1808 1808
         $entries_per_page_dropdown .= '
1809 1809
 					</select>
1810 1810
 					entries
@@ -1826,7 +1826,7 @@  discard block
 block discarded – undo
1826 1826
     public function _set_search_attributes()
1827 1827
     {
1828 1828
         $this->_template_args['search']['btn_label'] = sprintf(__('Search %s', 'event_espresso'), empty($this->_search_btn_label) ? $this->page_label : $this->_search_btn_label);
1829
-        $this->_template_args['search']['callback'] = 'search_' . $this->page_slug;
1829
+        $this->_template_args['search']['callback'] = 'search_'.$this->page_slug;
1830 1830
     }
1831 1831
 
1832 1832
     /*** END LIST TABLE METHODS **/
@@ -1864,7 +1864,7 @@  discard block
 block discarded – undo
1864 1864
                     // user error msg
1865 1865
                     $error_msg = __('An error occurred. The  requested metabox could not be found.', 'event_espresso');
1866 1866
                     // developer error msg
1867
-                    $error_msg .= '||' . sprintf(
1867
+                    $error_msg .= '||'.sprintf(
1868 1868
                                     __(
1869 1869
                                             'The metabox with the string "%s" could not be called. Check that the spelling for method names and actions in the "_page_config[\'metaboxes\']" array are all correct.',
1870 1870
                                             'event_espresso'
@@ -1894,15 +1894,15 @@  discard block
 block discarded – undo
1894 1894
                 && is_array($this->_route_config['columns'])
1895 1895
                 && count($this->_route_config['columns']) === 2
1896 1896
         ) {
1897
-            add_screen_option('layout_columns', array('max' => (int)$this->_route_config['columns'][0], 'default' => (int)$this->_route_config['columns'][1]));
1897
+            add_screen_option('layout_columns', array('max' => (int) $this->_route_config['columns'][0], 'default' => (int) $this->_route_config['columns'][1]));
1898 1898
             $this->_template_args['num_columns'] = $this->_route_config['columns'][0];
1899 1899
             $screen_id = $this->_current_screen->id;
1900
-            $screen_columns = (int)get_user_option("screen_layout_$screen_id");
1900
+            $screen_columns = (int) get_user_option("screen_layout_$screen_id");
1901 1901
             $total_columns = ! empty($screen_columns) ? $screen_columns : $this->_route_config['columns'][1];
1902
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
1902
+            $this->_template_args['current_screen_widget_class'] = 'columns-'.$total_columns;
1903 1903
             $this->_template_args['current_page'] = $this->_wp_page_slug;
1904 1904
             $this->_template_args['screen'] = $this->_current_screen;
1905
-            $this->_column_template_path = EE_ADMIN_TEMPLATE . 'admin_details_metabox_column_wrapper.template.php';
1905
+            $this->_column_template_path = EE_ADMIN_TEMPLATE.'admin_details_metabox_column_wrapper.template.php';
1906 1906
             //finally if we don't have has_metaboxes set in the route config let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
1907 1907
             $this->_route_config['has_metaboxes'] = true;
1908 1908
         }
@@ -1949,7 +1949,7 @@  discard block
 block discarded – undo
1949 1949
      */
1950 1950
     public function espresso_ratings_request()
1951 1951
     {
1952
-        $template_path = EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php';
1952
+        $template_path = EE_ADMIN_TEMPLATE.'espresso_ratings_request_content.template.php';
1953 1953
         EEH_Template::display_template($template_path, array());
1954 1954
     }
1955 1955
 
@@ -1957,18 +1957,18 @@  discard block
 block discarded – undo
1957 1957
 
1958 1958
     public static function cached_rss_display($rss_id, $url)
1959 1959
     {
1960
-        $loading = '<p class="widget-loading hide-if-no-js">' . __('Loading&#8230;') . '</p><p class="hide-if-js">' . __('This widget requires JavaScript.') . '</p>';
1960
+        $loading = '<p class="widget-loading hide-if-no-js">'.__('Loading&#8230;').'</p><p class="hide-if-js">'.__('This widget requires JavaScript.').'</p>';
1961 1961
         $doing_ajax = (defined('DOING_AJAX') && DOING_AJAX);
1962
-        $pre = '<div class="espresso-rss-display">' . "\n\t";
1963
-        $pre .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>';
1964
-        $post = '</div>' . "\n";
1965
-        $cache_key = 'ee_rss_' . md5($rss_id);
1962
+        $pre = '<div class="espresso-rss-display">'."\n\t";
1963
+        $pre .= '<span id="'.$rss_id.'_url" class="hidden">'.$url.'</span>';
1964
+        $post = '</div>'."\n";
1965
+        $cache_key = 'ee_rss_'.md5($rss_id);
1966 1966
         if (false != ($output = get_transient($cache_key))) {
1967
-            echo $pre . $output . $post;
1967
+            echo $pre.$output.$post;
1968 1968
             return true;
1969 1969
         }
1970 1970
         if ( ! $doing_ajax) {
1971
-            echo $pre . $loading . $post;
1971
+            echo $pre.$loading.$post;
1972 1972
             return false;
1973 1973
         }
1974 1974
         ob_start();
@@ -2027,7 +2027,7 @@  discard block
 block discarded – undo
2027 2027
 
2028 2028
     public function espresso_sponsors_post_box()
2029 2029
     {
2030
-        $templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php';
2030
+        $templatepath = EE_ADMIN_TEMPLATE.'admin_general_metabox_contents_espresso_sponsors.template.php';
2031 2031
         EEH_Template::display_template($templatepath);
2032 2032
     }
2033 2033
 
@@ -2035,7 +2035,7 @@  discard block
 block discarded – undo
2035 2035
 
2036 2036
     private function _publish_post_box()
2037 2037
     {
2038
-        $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2038
+        $meta_box_ref = 'espresso_'.$this->page_slug.'_editor_overview';
2039 2039
         //if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array then we'll use that for the metabox label.  Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2040 2040
         if ( ! empty($this->_labels['publishbox'])) {
2041 2041
             $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][$this->_req_action] : $this->_labels['publishbox'];
@@ -2052,7 +2052,7 @@  discard block
 block discarded – undo
2052 2052
     {
2053 2053
         //if we have extra content set let's add it in if not make sure its empty
2054 2054
         $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content']) ? $this->_template_args['publish_box_extra_content'] : '';
2055
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php';
2055
+        $template_path = EE_ADMIN_TEMPLATE.'admin_details_publish_metabox.template.php';
2056 2056
         echo EEH_Template::display_template($template_path, $this->_template_args, true);
2057 2057
     }
2058 2058
 
@@ -2221,7 +2221,7 @@  discard block
 block discarded – undo
2221 2221
         //if $create_func is true (default) then we automatically create the function for displaying the actual meta box.  If false then we take the $callback reference passed through and use it instead (so callers can define their own callback function/method if they wish)
2222 2222
         $call_back_func = $create_func ? create_function('$post, $metabox',
2223 2223
                 'do_action( "AHEE_log", __FILE__, __FUNCTION__, ""); echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );') : $callback;
2224
-        add_meta_box(str_replace('_', '-', $action) . '-mbox', $title, $call_back_func, $this->_wp_page_slug, $column, $priority, $callback_args);
2224
+        add_meta_box(str_replace('_', '-', $action).'-mbox', $title, $call_back_func, $this->_wp_page_slug, $column, $priority, $callback_args);
2225 2225
     }
2226 2226
 
2227 2227
 
@@ -2301,10 +2301,10 @@  discard block
 block discarded – undo
2301 2301
                 ? 'poststuff'
2302 2302
                 : 'espresso-default-admin';
2303 2303
         $template_path = $sidebar
2304
-                ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2305
-                : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2304
+                ? EE_ADMIN_TEMPLATE.'admin_details_wrapper.template.php'
2305
+                : EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar.template.php';
2306 2306
         if (defined('DOING_AJAX') && DOING_AJAX) {
2307
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2307
+            $template_path = EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar_ajax.template.php';
2308 2308
         }
2309 2309
         $template_path = ! empty($this->_column_template_path) ? $this->_column_template_path : $template_path;
2310 2310
         $this->_template_args['post_body_content'] = isset($this->_template_args['admin_page_content']) ? $this->_template_args['admin_page_content'] : '';
@@ -2350,7 +2350,7 @@  discard block
 block discarded – undo
2350 2350
                         true
2351 2351
                 )
2352 2352
                 : $this->_template_args['preview_action_button'];
2353
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php';
2353
+        $template_path = EE_ADMIN_TEMPLATE.'admin_caf_full_page_preview.template.php';
2354 2354
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2355 2355
                 $template_path,
2356 2356
                 $this->_template_args,
@@ -2401,7 +2401,7 @@  discard block
 block discarded – undo
2401 2401
         //setup search attributes
2402 2402
         $this->_set_search_attributes();
2403 2403
         $this->_template_args['current_page'] = $this->_wp_page_slug;
2404
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2404
+        $template_path = EE_ADMIN_TEMPLATE.'admin_list_wrapper.template.php';
2405 2405
         $this->_template_args['table_url'] = defined('DOING_AJAX')
2406 2406
                 ? add_query_arg(array('noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url)
2407 2407
                 : add_query_arg(array('route' => $this->_req_action), $this->_admin_base_url);
@@ -2411,37 +2411,37 @@  discard block
 block discarded – undo
2411 2411
         $ajax_sorting_callback = $this->_list_table_object->get_ajax_sorting_callback();
2412 2412
         if ( ! empty($ajax_sorting_callback)) {
2413 2413
             $sortable_list_table_form_fields = wp_nonce_field(
2414
-                    $ajax_sorting_callback . '_nonce',
2415
-                    $ajax_sorting_callback . '_nonce',
2414
+                    $ajax_sorting_callback.'_nonce',
2415
+                    $ajax_sorting_callback.'_nonce',
2416 2416
                     false,
2417 2417
                     false
2418 2418
             );
2419 2419
             //			$reorder_action = 'espresso_' . $ajax_sorting_callback . '_nonce';
2420 2420
             //			$sortable_list_table_form_fields = wp_nonce_field( $reorder_action, 'ajax_table_sort_nonce', FALSE, FALSE );
2421
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="' . $this->page_slug . '" />';
2422
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="' . $ajax_sorting_callback . '" />';
2421
+            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'.$this->page_slug.'" />';
2422
+            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'.$ajax_sorting_callback.'" />';
2423 2423
         } else {
2424 2424
             $sortable_list_table_form_fields = '';
2425 2425
         }
2426 2426
         $this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
2427 2427
         $hidden_form_fields = isset($this->_template_args['list_table_hidden_fields']) ? $this->_template_args['list_table_hidden_fields'] : '';
2428
-        $nonce_ref = $this->_req_action . '_nonce';
2429
-        $hidden_form_fields .= '<input type="hidden" name="' . $nonce_ref . '" value="' . wp_create_nonce($nonce_ref) . '">';
2428
+        $nonce_ref = $this->_req_action.'_nonce';
2429
+        $hidden_form_fields .= '<input type="hidden" name="'.$nonce_ref.'" value="'.wp_create_nonce($nonce_ref).'">';
2430 2430
         $this->_template_args['list_table_hidden_fields'] = $hidden_form_fields;
2431 2431
         //display message about search results?
2432 2432
         $this->_template_args['before_list_table'] .= ! empty($this->_req_data['s'])
2433
-                ? '<p class="ee-search-results">' . sprintf(
2433
+                ? '<p class="ee-search-results">'.sprintf(
2434 2434
                         __('Displaying search results for the search string: <strong><em>%s</em></strong>',
2435 2435
                                 'event_espresso'),
2436 2436
                         trim($this->_req_data['s'], '%')
2437
-                ) . '</p>'
2437
+                ).'</p>'
2438 2438
                 : '';
2439 2439
         // filter before_list_table template arg
2440 2440
         $this->_template_args['before_list_table'] = implode(
2441 2441
                 " \n",
2442
-                (array)apply_filters(
2442
+                (array) apply_filters(
2443 2443
                         'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
2444
-                        (array)$this->_template_args['before_list_table'],
2444
+                        (array) $this->_template_args['before_list_table'],
2445 2445
                         $this->page_slug,
2446 2446
                         $this->_req_data,
2447 2447
                         $this->_req_action
@@ -2450,9 +2450,9 @@  discard block
 block discarded – undo
2450 2450
         // filter after_list_table template arg
2451 2451
         $this->_template_args['after_list_table'] = implode(
2452 2452
                 " \n",
2453
-                (array)apply_filters(
2453
+                (array) apply_filters(
2454 2454
                         'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
2455
-                        (array)$this->_template_args['after_list_table'],
2455
+                        (array) $this->_template_args['after_list_table'],
2456 2456
                         $this->page_slug,
2457 2457
                         $this->_req_data,
2458 2458
                         $this->_req_action
@@ -2488,8 +2488,8 @@  discard block
 block discarded – undo
2488 2488
      */
2489 2489
     protected function _display_legend($items)
2490 2490
     {
2491
-        $this->_template_args['items'] = apply_filters('FHEE__EE_Admin_Page___display_legend__items', (array)$items, $this);
2492
-        $legend_template = EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php';
2491
+        $this->_template_args['items'] = apply_filters('FHEE__EE_Admin_Page___display_legend__items', (array) $items, $this);
2492
+        $legend_template = EE_ADMIN_TEMPLATE.'admin_details_legend.template.php';
2493 2493
         return EEH_Template::display_template($legend_template, $this->_template_args, true);
2494 2494
     }
2495 2495
 
@@ -2584,15 +2584,15 @@  discard block
 block discarded – undo
2584 2584
         $this->_nav_tabs = $this->_get_main_nav_tabs();
2585 2585
         $this->_template_args['nav_tabs'] = $this->_nav_tabs;
2586 2586
         $this->_template_args['admin_page_title'] = $this->_admin_page_title;
2587
-        $this->_template_args['before_admin_page_content'] = apply_filters('FHEE_before_admin_page_content' . $this->_current_page . $this->_current_view,
2587
+        $this->_template_args['before_admin_page_content'] = apply_filters('FHEE_before_admin_page_content'.$this->_current_page.$this->_current_view,
2588 2588
                 isset($this->_template_args['before_admin_page_content']) ? $this->_template_args['before_admin_page_content'] : '');
2589
-        $this->_template_args['after_admin_page_content'] = apply_filters('FHEE_after_admin_page_content' . $this->_current_page . $this->_current_view,
2589
+        $this->_template_args['after_admin_page_content'] = apply_filters('FHEE_after_admin_page_content'.$this->_current_page.$this->_current_view,
2590 2590
                 isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content'] : '');
2591 2591
         $this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content();
2592 2592
         // load settings page wrapper template
2593
-        $template_path = ! defined('DOING_AJAX') ? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php' : EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php';
2593
+        $template_path = ! defined('DOING_AJAX') ? EE_ADMIN_TEMPLATE.'admin_wrapper.template.php' : EE_ADMIN_TEMPLATE.'admin_wrapper_ajax.template.php';
2594 2594
         //about page?
2595
-        $template_path = $about ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php' : $template_path;
2595
+        $template_path = $about ? EE_ADMIN_TEMPLATE.'about_admin_wrapper.template.php' : $template_path;
2596 2596
         if (defined('DOING_AJAX')) {
2597 2597
             $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, true);
2598 2598
             $this->_return_json();
@@ -2664,20 +2664,20 @@  discard block
 block discarded – undo
2664 2664
     protected function _set_save_buttons($both = true, $text = array(), $actions = array(), $referrer = null)
2665 2665
     {
2666 2666
         //make sure $text and $actions are in an array
2667
-        $text = (array)$text;
2668
-        $actions = (array)$actions;
2667
+        $text = (array) $text;
2668
+        $actions = (array) $actions;
2669 2669
         $referrer_url = empty($referrer) ? '' : $referrer;
2670
-        $referrer_url = ! $referrer ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $_SERVER['REQUEST_URI'] . '" />'
2671
-                : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $referrer . '" />';
2670
+        $referrer_url = ! $referrer ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'.$_SERVER['REQUEST_URI'].'" />'
2671
+                : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'.$referrer.'" />';
2672 2672
         $button_text = ! empty($text) ? $text : array(__('Save', 'event_espresso'), __('Save and Close', 'event_espresso'));
2673 2673
         $default_names = array('save', 'save_and_close');
2674 2674
         //add in a hidden index for the current page (so save and close redirects properly)
2675 2675
         $this->_template_args['save_buttons'] = $referrer_url;
2676 2676
         foreach ($button_text as $key => $button) {
2677 2677
             $ref = $default_names[$key];
2678
-            $id = $this->_current_view . '_' . $ref;
2678
+            $id = $this->_current_view.'_'.$ref;
2679 2679
             $name = ! empty($actions) ? $actions[$key] : $ref;
2680
-            $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary ' . $ref . '" value="' . $button . '" name="' . $name . '" id="' . $id . '" />';
2680
+            $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary '.$ref.'" value="'.$button.'" name="'.$name.'" id="'.$id.'" />';
2681 2681
             if ( ! $both) {
2682 2682
                 break;
2683 2683
             }
@@ -2713,15 +2713,15 @@  discard block
 block discarded – undo
2713 2713
     {
2714 2714
         if (empty($route)) {
2715 2715
             $user_msg = __('An error occurred. No action was set for this page\'s form.', 'event_espresso');
2716
-            $dev_msg = $user_msg . "\n" . sprintf(__('The $route argument is required for the %s->%s method.', 'event_espresso'), __FUNCTION__, __CLASS__);
2717
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
2716
+            $dev_msg = $user_msg."\n".sprintf(__('The $route argument is required for the %s->%s method.', 'event_espresso'), __FUNCTION__, __CLASS__);
2717
+            EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__);
2718 2718
         }
2719 2719
         // open form
2720
-        $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="' . $this->_admin_base_url . '" id="' . $route . '_event_form" >';
2720
+        $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'.$this->_admin_base_url.'" id="'.$route.'_event_form" >';
2721 2721
         // add nonce
2722
-        $nonce = wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
2722
+        $nonce = wp_nonce_field($route.'_nonce', $route.'_nonce', false, false);
2723 2723
         //		$nonce = wp_nonce_field( $route . '_nonce', '_wpnonce', FALSE, FALSE );
2724
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
2724
+        $this->_template_args['before_admin_page_content'] .= "\n\t".$nonce;
2725 2725
         // add REQUIRED form action
2726 2726
         $hidden_fields = array(
2727 2727
                 'action' => array('type' => 'hidden', 'value' => $route),
@@ -2731,8 +2731,8 @@  discard block
 block discarded – undo
2731 2731
         // generate form fields
2732 2732
         $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
2733 2733
         // add fields to form
2734
-        foreach ((array)$form_fields as $field_name => $form_field) {
2735
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
2734
+        foreach ((array) $form_fields as $field_name => $form_field) {
2735
+            $this->_template_args['before_admin_page_content'] .= "\n\t".$form_field['field'];
2736 2736
         }
2737 2737
         // close form
2738 2738
         $this->_template_args['after_admin_page_content'] = '</form>';
@@ -2813,7 +2813,7 @@  discard block
 block discarded – undo
2813 2813
          * @param array $query_args       The original query_args array coming into the
2814 2814
          *                                method.
2815 2815
          */
2816
-        do_action('AHEE__' . $classname . '___redirect_after_action__before_redirect_modification_' . $this->_req_action, $query_args);
2816
+        do_action('AHEE__'.$classname.'___redirect_after_action__before_redirect_modification_'.$this->_req_action, $query_args);
2817 2817
         //calculate where we're going (if we have a "save and close" button pushed)
2818 2818
         if (isset($this->_req_data['save_and_close']) && isset($this->_req_data['save_and_close_referrer'])) {
2819 2819
             // even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
@@ -2829,7 +2829,7 @@  discard block
 block discarded – undo
2829 2829
             foreach ($this->_default_route_query_args as $query_param => $query_value) {
2830 2830
                 //is there a wp_referer array in our _default_route_query_args property?
2831 2831
                 if ($query_param == 'wp_referer') {
2832
-                    $query_value = (array)$query_value;
2832
+                    $query_value = (array) $query_value;
2833 2833
                     foreach ($query_value as $reference => $value) {
2834 2834
                         if (strpos($reference, 'nonce') !== false) {
2835 2835
                             continue;
@@ -2855,11 +2855,11 @@  discard block
 block discarded – undo
2855 2855
         // if redirecting to anything other than the main page, add a nonce
2856 2856
         if (isset($query_args['action'])) {
2857 2857
             // manually generate wp_nonce and merge that with the query vars becuz the wp_nonce_url function wrecks havoc on some vars
2858
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
2858
+            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'].'_nonce');
2859 2859
         }
2860 2860
         //we're adding some hooks and filters in here for processing any things just before redirects (example: an admin page has done an insert or update and we want to run something after that).
2861
-        do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
2862
-        $redirect_url = apply_filters('FHEE_redirect_' . $classname . $this->_req_action, self::add_query_args_and_nonce($query_args, $redirect_url), $query_args);
2861
+        do_action('AHEE_redirect_'.$classname.$this->_req_action, $query_args);
2862
+        $redirect_url = apply_filters('FHEE_redirect_'.$classname.$this->_req_action, self::add_query_args_and_nonce($query_args, $redirect_url), $query_args);
2863 2863
         // check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
2864 2864
         if (defined('DOING_AJAX')) {
2865 2865
             $default_data = array(
@@ -2989,7 +2989,7 @@  discard block
 block discarded – undo
2989 2989
         $args = array(
2990 2990
                 'label'   => $this->_admin_page_title,
2991 2991
                 'default' => 10,
2992
-                'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
2992
+                'option'  => $this->_current_page.'_'.$this->_current_view.'_per_page',
2993 2993
         );
2994 2994
         //ONLY add the screen option if the user has access to it.
2995 2995
         if ($this->check_user_access($this->_current_view, true)) {
@@ -3022,8 +3022,8 @@  discard block
 block discarded – undo
3022 3022
             $map_option = $option;
3023 3023
             $option = str_replace('-', '_', $option);
3024 3024
             switch ($map_option) {
3025
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3026
-                    $value = (int)$value;
3025
+                case $this->_current_page.'_'.$this->_current_view.'_per_page':
3026
+                    $value = (int) $value;
3027 3027
                     if ($value < 1 || $value > 999) {
3028 3028
                         return;
3029 3029
                     }
@@ -3050,7 +3050,7 @@  discard block
 block discarded – undo
3050 3050
      */
3051 3051
     public function set_template_args($data)
3052 3052
     {
3053
-        $this->_template_args = array_merge($this->_template_args, (array)$data);
3053
+        $this->_template_args = array_merge($this->_template_args, (array) $data);
3054 3054
     }
3055 3055
 
3056 3056
 
@@ -3072,12 +3072,12 @@  discard block
 block discarded – undo
3072 3072
             $this->_verify_route($route);
3073 3073
         }
3074 3074
         //now let's set the string for what kind of transient we're setting
3075
-        $transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id;
3075
+        $transient = $notices ? 'ee_rte_n_tx_'.$route.'_'.$user_id : 'rte_tx_'.$route.'_'.$user_id;
3076 3076
         $data = $notices ? array('notices' => $data) : $data;
3077 3077
         //is there already a transient for this route?  If there is then let's ADD to that transient
3078 3078
         $existing = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient);
3079 3079
         if ($existing) {
3080
-            $data = array_merge((array)$data, (array)$existing);
3080
+            $data = array_merge((array) $data, (array) $existing);
3081 3081
         }
3082 3082
         if (is_multisite() && is_network_admin()) {
3083 3083
             set_site_transient($transient, $data, 8);
@@ -3098,7 +3098,7 @@  discard block
 block discarded – undo
3098 3098
     {
3099 3099
         $user_id = get_current_user_id();
3100 3100
         $route = ! $route ? $this->_req_action : $route;
3101
-        $transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id;
3101
+        $transient = $notices ? 'ee_rte_n_tx_'.$route.'_'.$user_id : 'rte_tx_'.$route.'_'.$user_id;
3102 3102
         $data = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient);
3103 3103
         //delete transient after retrieval (just in case it hasn't expired);
3104 3104
         if (is_multisite() && is_network_admin()) {
@@ -3339,7 +3339,7 @@  discard block
 block discarded – undo
3339 3339
      */
3340 3340
     protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
3341 3341
     {
3342
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3342
+        return '<a class="'.$class.'" href="'.$url.'"></a>';
3343 3343
     }
3344 3344
 
3345 3345
 
@@ -3353,7 +3353,7 @@  discard block
 block discarded – undo
3353 3353
      */
3354 3354
     protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
3355 3355
     {
3356
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3356
+        return '<a class="'.$class.'" href="'.$url.'"></a>';
3357 3357
     }
3358 3358
 
3359 3359
 
Please login to merge, or discard this patch.
core/db_classes/EE_Event.class.php 2 patches
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -138,25 +138,25 @@
 block discarded – undo
138 138
 
139 139
 
140 140
 
141
-    /**
142
-     * Gets all the datetimes for this event, ordered by the DTT_order on the datetime.
143
-     * @darren, we should probably UNSET timezone on the EEM_Datetime model
144
-     * after running our query, so that this timezone isn't set for EVERY query
145
-     * on EEM_Datetime for the rest of the request, no?
146
-     *
147
-     * @param boolean $show_expired whether or not to include expired events
148
-     * @param boolean $show_deleted whether or not to include deleted events
149
-     * @param null    $limit
150
-     * @return \EE_Datetime[]
151
-     * @throws \EE_Error
152
-     */
141
+	/**
142
+	 * Gets all the datetimes for this event, ordered by the DTT_order on the datetime.
143
+	 * @darren, we should probably UNSET timezone on the EEM_Datetime model
144
+	 * after running our query, so that this timezone isn't set for EVERY query
145
+	 * on EEM_Datetime for the rest of the request, no?
146
+	 *
147
+	 * @param boolean $show_expired whether or not to include expired events
148
+	 * @param boolean $show_deleted whether or not to include deleted events
149
+	 * @param null    $limit
150
+	 * @return \EE_Datetime[]
151
+	 * @throws \EE_Error
152
+	 */
153 153
 	public function datetimes_ordered( $show_expired = true, $show_deleted = false, $limit = null ) {
154 154
 		return EEM_Datetime::instance( $this->_timezone )->get_datetimes_for_event_ordered_by_DTT_order(
155
-		    $this->ID(),
156
-            $show_expired,
157
-            $show_deleted,
158
-            $limit
159
-        );
155
+			$this->ID(),
156
+			$show_expired,
157
+			$show_deleted,
158
+			$limit
159
+		);
160 160
 	}
161 161
 
162 162
 
Please login to merge, or discard this patch.
Spacing   +216 added lines, -216 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
2
-	exit( 'No direct script access allowed' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 
5 5
 /**
@@ -35,9 +35,9 @@  discard block
 block discarded – undo
35 35
 	 *                             		    date_format and the second value is the time format
36 36
 	 * @return EE_Event
37 37
 	 */
38
-	public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) {
39
-		$has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats );
40
-		return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats );
38
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) {
39
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
40
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
41 41
 	}
42 42
 
43 43
 
@@ -48,8 +48,8 @@  discard block
 block discarded – undo
48 48
 	 *                          		the website will be used.
49 49
 	 * @return EE_Event
50 50
 	 */
51
-	public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) {
52
-		return new self( $props_n_values, TRUE, $timezone );
51
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null) {
52
+		return new self($props_n_values, TRUE, $timezone);
53 53
 	}
54 54
 
55 55
 
@@ -61,13 +61,13 @@  discard block
 block discarded – undo
61 61
 	 * @param mixed  $field_value
62 62
 	 * @param bool   $use_default
63 63
 	 */
64
-	public function set( $field_name, $field_value, $use_default = false ) {
65
-		switch ( $field_name ) {
64
+	public function set($field_name, $field_value, $use_default = false) {
65
+		switch ($field_name) {
66 66
 			case 'status' :
67
-				$this->set_status( $field_value, $use_default );
67
+				$this->set_status($field_value, $use_default);
68 68
 				break;
69 69
 			default :
70
-				parent::set( $field_name, $field_value, $use_default );
70
+				parent::set($field_name, $field_value, $use_default);
71 71
 		}
72 72
 	}
73 73
 
@@ -86,29 +86,29 @@  discard block
 block discarded – undo
86 86
 	 * @return bool|void
87 87
 	 * @throws \EE_Error
88 88
 	 */
89
-	public function set_status( $new_status = null, $use_default = false ) {
89
+	public function set_status($new_status = null, $use_default = false) {
90 90
 		// get current Event status
91 91
 		$old_status = $this->status();
92 92
 		// if status has changed
93
-		if ( $old_status != $new_status ) {
93
+		if ($old_status != $new_status) {
94 94
 			// TO sold_out
95
-			if ( $new_status == EEM_Event::sold_out ) {
95
+			if ($new_status == EEM_Event::sold_out) {
96 96
 				// save the previous event status so that we can revert if the event is no longer sold out
97
-				$this->add_post_meta( '_previous_event_status', $old_status );
98
-				do_action( 'AHEE__EE_Event__set_status__to_sold_out', $this, $old_status, $new_status );
97
+				$this->add_post_meta('_previous_event_status', $old_status);
98
+				do_action('AHEE__EE_Event__set_status__to_sold_out', $this, $old_status, $new_status);
99 99
 				// OR FROM  sold_out
100
-			} else if ( $old_status == EEM_Event::sold_out ) {
101
-				$this->delete_post_meta( '_previous_event_status' );
102
-				do_action( 'AHEE__EE_Event__set_status__from_sold_out', $this, $old_status, $new_status );
100
+			} else if ($old_status == EEM_Event::sold_out) {
101
+				$this->delete_post_meta('_previous_event_status');
102
+				do_action('AHEE__EE_Event__set_status__from_sold_out', $this, $old_status, $new_status);
103 103
 			}
104 104
 			// update status
105
-			parent::set( 'status', $new_status, $use_default );
106
-			do_action( 'AHEE__EE_Event__set_status__after_update', $this );
105
+			parent::set('status', $new_status, $use_default);
106
+			do_action('AHEE__EE_Event__set_status__after_update', $this);
107 107
 			return true;
108 108
 		} else {
109 109
 			// even though the old value matches the new value, it's still good to
110 110
 			// allow the parent set method to have a say
111
-			parent::set( 'status', $new_status, $use_default );
111
+			parent::set('status', $new_status, $use_default);
112 112
 			return true;
113 113
 		}
114 114
 	}
@@ -121,8 +121,8 @@  discard block
 block discarded – undo
121 121
 	 * @param array $query_params like EEM_Base::get_all
122 122
 	 * @return EE_Datetime[]
123 123
 	 */
124
-	public function datetimes( $query_params = array() ) {
125
-		return $this->get_many_related( 'Datetime', $query_params );
124
+	public function datetimes($query_params = array()) {
125
+		return $this->get_many_related('Datetime', $query_params);
126 126
 	}
127 127
 
128 128
 
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 	 * @return EE_Datetime[]
134 134
 	 */
135 135
 	public function datetimes_in_chronological_order() {
136
-		return $this->get_many_related( 'Datetime', array( 'order_by' => array( 'DTT_EVT_start' => 'ASC' ) ) );
136
+		return $this->get_many_related('Datetime', array('order_by' => array('DTT_EVT_start' => 'ASC')));
137 137
 	}
138 138
 
139 139
 
@@ -150,8 +150,8 @@  discard block
 block discarded – undo
150 150
      * @return \EE_Datetime[]
151 151
      * @throws \EE_Error
152 152
      */
153
-	public function datetimes_ordered( $show_expired = true, $show_deleted = false, $limit = null ) {
154
-		return EEM_Datetime::instance( $this->_timezone )->get_datetimes_for_event_ordered_by_DTT_order(
153
+	public function datetimes_ordered($show_expired = true, $show_deleted = false, $limit = null) {
154
+		return EEM_Datetime::instance($this->_timezone)->get_datetimes_for_event_ordered_by_DTT_order(
155 155
 		    $this->ID(),
156 156
             $show_expired,
157 157
             $show_deleted,
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 	 * @return EE_Datetime
167 167
 	 */
168 168
 	public function first_datetime() {
169
-		return $this->get_first_related( 'Datetime' );
169
+		return $this->get_first_related('Datetime');
170 170
 	}
171 171
 
172 172
 
@@ -177,11 +177,11 @@  discard block
 block discarded – undo
177 177
 	 * @param bool $try_to_exclude_deleted
178 178
 	 * @return EE_Datetime
179 179
 	 */
180
-	public function primary_datetime( $try_to_exclude_expired = TRUE, $try_to_exclude_deleted = TRUE ) {
181
-		if ( !empty ( $this->_Primary_Datetime ) ) {
180
+	public function primary_datetime($try_to_exclude_expired = TRUE, $try_to_exclude_deleted = TRUE) {
181
+		if ( ! empty ($this->_Primary_Datetime)) {
182 182
 			return $this->_Primary_Datetime;
183 183
 		}
184
-		$this->_Primary_Datetime = EEM_Datetime::instance( $this->_timezone )->get_primary_datetime_for_event( $this->ID(), $try_to_exclude_expired, $try_to_exclude_deleted );
184
+		$this->_Primary_Datetime = EEM_Datetime::instance($this->_timezone)->get_primary_datetime_for_event($this->ID(), $try_to_exclude_expired, $try_to_exclude_deleted);
185 185
 		return $this->_Primary_Datetime;
186 186
 	}
187 187
 
@@ -192,30 +192,30 @@  discard block
 block discarded – undo
192 192
 	 * @param array $query_params like EEM_Base::get_all
193 193
 	 * @return EE_Ticket[]
194 194
 	 */
195
-	public function tickets( $query_params = array() ) {
195
+	public function tickets($query_params = array()) {
196 196
 		//first get all datetimes
197 197
 		$datetimes = $this->datetimes_ordered();
198
-		if ( ! $datetimes ) {
198
+		if ( ! $datetimes) {
199 199
 			return array();
200 200
 		}
201 201
 
202 202
 		$datetime_ids = array();
203
-		foreach ( $datetimes as $datetime ) {
203
+		foreach ($datetimes as $datetime) {
204 204
 			$datetime_ids[] = $datetime->ID();
205 205
 		}
206 206
 
207
-		$where_params = array( 'Datetime.DTT_ID' => array( 'IN', $datetime_ids ) );
207
+		$where_params = array('Datetime.DTT_ID' => array('IN', $datetime_ids));
208 208
 
209 209
 		//if incoming $query_params has where conditions let's merge but not override existing.
210
-		if ( is_array( $query_params ) && isset( $query_params[0]) ) {
211
-			$where_params = array_merge( $query_params[0], $where_params );
212
-			unset( $query_params[0] );
210
+		if (is_array($query_params) && isset($query_params[0])) {
211
+			$where_params = array_merge($query_params[0], $where_params);
212
+			unset($query_params[0]);
213 213
 		}
214 214
 
215 215
 		//now add $where_params to $query_params
216 216
 		$query_params[0] = $where_params;
217 217
 
218
-		return EEM_Ticket::instance()->get_all( $query_params );
218
+		return EEM_Ticket::instance()->get_all($query_params);
219 219
 	}
220 220
 
221 221
 
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 	 * @return bool
225 225
 	 */
226 226
 	public function additional_limit() {
227
-		return $this->get( 'EVT_additional_limit' );
227
+		return $this->get('EVT_additional_limit');
228 228
 	}
229 229
 
230 230
 
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 	 * @return bool
234 234
 	 */
235 235
 	public function allow_overflow() {
236
-		return $this->get( 'EVT_allow_overflow' );
236
+		return $this->get('EVT_allow_overflow');
237 237
 	}
238 238
 
239 239
 
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 	 * @return bool
243 243
 	 */
244 244
 	public function created() {
245
-		return $this->get( 'EVT_created' );
245
+		return $this->get('EVT_created');
246 246
 	}
247 247
 
248 248
 
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 	 * @return bool
252 252
 	 */
253 253
 	public function description() {
254
-		return $this->get( 'EVT_desc' );
254
+		return $this->get('EVT_desc');
255 255
 	}
256 256
 
257 257
 
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 	 * @return string of html
262 262
 	 */
263 263
 	public function description_filtered() {
264
-		return $this->get_pretty( 'EVT_desc' );
264
+		return $this->get_pretty('EVT_desc');
265 265
 	}
266 266
 
267 267
 
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 	 * @return bool
271 271
 	 */
272 272
 	public function display_description() {
273
-		return $this->get( 'EVT_display_desc' );
273
+		return $this->get('EVT_display_desc');
274 274
 	}
275 275
 
276 276
 
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 	 * @return bool
280 280
 	 */
281 281
 	public function display_ticket_selector() {
282
-		return (bool)$this->get( 'EVT_display_ticket_selector' );
282
+		return (bool) $this->get('EVT_display_ticket_selector');
283 283
 	}
284 284
 
285 285
 
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 	 * @return bool
289 289
 	 */
290 290
 	public function external_url() {
291
-		return $this->get( 'EVT_external_URL' );
291
+		return $this->get('EVT_external_URL');
292 292
 	}
293 293
 
294 294
 
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 	 * @return bool
298 298
 	 */
299 299
 	public function member_only() {
300
-		return $this->get( 'EVT_member_only' );
300
+		return $this->get('EVT_member_only');
301 301
 	}
302 302
 
303 303
 
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
 	 * @return bool
307 307
 	 */
308 308
 	public function phone() {
309
-		return $this->get( 'EVT_phone' );
309
+		return $this->get('EVT_phone');
310 310
 	}
311 311
 
312 312
 
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 	 * @return bool
316 316
 	 */
317 317
 	public function modified() {
318
-		return $this->get( 'EVT_modified' );
318
+		return $this->get('EVT_modified');
319 319
 	}
320 320
 
321 321
 
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 	 * @return bool
325 325
 	 */
326 326
 	public function name() {
327
-		return $this->get( 'EVT_name' );
327
+		return $this->get('EVT_name');
328 328
 	}
329 329
 
330 330
 
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 	 * @return bool
334 334
 	 */
335 335
 	public function order() {
336
-		return $this->get( 'EVT_order' );
336
+		return $this->get('EVT_order');
337 337
 	}
338 338
 
339 339
 
@@ -342,8 +342,8 @@  discard block
 block discarded – undo
342 342
 	 * @return bool|string
343 343
 	 */
344 344
 	public function default_registration_status() {
345
-		$event_default_registration_status = $this->get( 'EVT_default_registration_status' );
346
-		return !empty( $event_default_registration_status ) ? $event_default_registration_status : EE_Registry::instance()->CFG->registration->default_STS_ID;
345
+		$event_default_registration_status = $this->get('EVT_default_registration_status');
346
+		return ! empty($event_default_registration_status) ? $event_default_registration_status : EE_Registry::instance()->CFG->registration->default_STS_ID;
347 347
 	}
348 348
 
349 349
 
@@ -354,14 +354,14 @@  discard block
 block discarded – undo
354 354
 	 * @param bool $not_full_desc
355 355
 	 * @return bool|string
356 356
 	 */
357
-	public function short_description( $num_words = 55, $more = NULL, $not_full_desc = FALSE ) {
358
-		$short_desc = $this->get( 'EVT_short_desc' );
359
-		if ( !empty( $short_desc ) || $not_full_desc ) {
357
+	public function short_description($num_words = 55, $more = NULL, $not_full_desc = FALSE) {
358
+		$short_desc = $this->get('EVT_short_desc');
359
+		if ( ! empty($short_desc) || $not_full_desc) {
360 360
 			return $short_desc;
361 361
 		}
362 362
 		else {
363
-			$full_desc = $this->get( 'EVT_desc' );
364
-			return wp_trim_words( $full_desc, $num_words, $more );
363
+			$full_desc = $this->get('EVT_desc');
364
+			return wp_trim_words($full_desc, $num_words, $more);
365 365
 		}
366 366
 	}
367 367
 
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 	 * @return bool
372 372
 	 */
373 373
 	public function slug() {
374
-		return $this->get( 'EVT_slug' );
374
+		return $this->get('EVT_slug');
375 375
 	}
376 376
 
377 377
 
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
 	 * @return bool
381 381
 	 */
382 382
 	public function timezone_string() {
383
-		return $this->get( 'EVT_timezone_string' );
383
+		return $this->get('EVT_timezone_string');
384 384
 	}
385 385
 
386 386
 
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
 	 * @return bool
390 390
 	 */
391 391
 	public function visible_on() {
392
-		return $this->get( 'EVT_visible_on' );
392
+		return $this->get('EVT_visible_on');
393 393
 	}
394 394
 
395 395
 
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
 	 * @return int
399 399
 	 */
400 400
 	public function wp_user() {
401
-		return $this->get( 'EVT_wp_user' );
401
+		return $this->get('EVT_wp_user');
402 402
 	}
403 403
 
404 404
 
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
 	 * @return bool
408 408
 	 */
409 409
 	public function donations() {
410
-		return $this->get( 'EVT_donations' );
410
+		return $this->get('EVT_donations');
411 411
 	}
412 412
 
413 413
 
@@ -415,8 +415,8 @@  discard block
 block discarded – undo
415 415
 	/**
416 416
 	 * @param $limit
417 417
 	 */
418
-	public function set_additional_limit( $limit ) {
419
-		$this->set( 'EVT_additional_limit', $limit );
418
+	public function set_additional_limit($limit) {
419
+		$this->set('EVT_additional_limit', $limit);
420 420
 	}
421 421
 
422 422
 
@@ -424,8 +424,8 @@  discard block
 block discarded – undo
424 424
 	/**
425 425
 	 * @param $created
426 426
 	 */
427
-	public function set_created( $created ) {
428
-		$this->set( 'EVT_created', $created );
427
+	public function set_created($created) {
428
+		$this->set('EVT_created', $created);
429 429
 	}
430 430
 
431 431
 
@@ -433,8 +433,8 @@  discard block
 block discarded – undo
433 433
 	/**
434 434
 	 * @param $desc
435 435
 	 */
436
-	public function set_description( $desc ) {
437
-		$this->set( 'EVT_desc', $desc );
436
+	public function set_description($desc) {
437
+		$this->set('EVT_desc', $desc);
438 438
 	}
439 439
 
440 440
 
@@ -442,8 +442,8 @@  discard block
 block discarded – undo
442 442
 	/**
443 443
 	 * @param $display_desc
444 444
 	 */
445
-	public function set_display_description( $display_desc ) {
446
-		$this->set( 'EVT_display_desc', $display_desc );
445
+	public function set_display_description($display_desc) {
446
+		$this->set('EVT_display_desc', $display_desc);
447 447
 	}
448 448
 
449 449
 
@@ -451,8 +451,8 @@  discard block
 block discarded – undo
451 451
 	/**
452 452
 	 * @param $display_ticket_selector
453 453
 	 */
454
-	public function set_display_ticket_selector( $display_ticket_selector ) {
455
-		$this->set( 'EVT_display_ticket_selector', $display_ticket_selector );
454
+	public function set_display_ticket_selector($display_ticket_selector) {
455
+		$this->set('EVT_display_ticket_selector', $display_ticket_selector);
456 456
 	}
457 457
 
458 458
 
@@ -460,8 +460,8 @@  discard block
 block discarded – undo
460 460
 	/**
461 461
 	 * @param $external_url
462 462
 	 */
463
-	public function set_external_url( $external_url ) {
464
-		$this->set( 'EVT_external_URL', $external_url );
463
+	public function set_external_url($external_url) {
464
+		$this->set('EVT_external_URL', $external_url);
465 465
 	}
466 466
 
467 467
 
@@ -469,8 +469,8 @@  discard block
 block discarded – undo
469 469
 	/**
470 470
 	 * @param $member_only
471 471
 	 */
472
-	public function set_member_only( $member_only ) {
473
-		$this->set( 'EVT_member_only', $member_only );
472
+	public function set_member_only($member_only) {
473
+		$this->set('EVT_member_only', $member_only);
474 474
 	}
475 475
 
476 476
 
@@ -478,8 +478,8 @@  discard block
 block discarded – undo
478 478
 	/**
479 479
 	 * @param $event_phone
480 480
 	 */
481
-	public function set_event_phone( $event_phone ) {
482
-		$this->set( 'EVT_phone', $event_phone );
481
+	public function set_event_phone($event_phone) {
482
+		$this->set('EVT_phone', $event_phone);
483 483
 	}
484 484
 
485 485
 
@@ -487,8 +487,8 @@  discard block
 block discarded – undo
487 487
 	/**
488 488
 	 * @param $modified
489 489
 	 */
490
-	public function set_modified( $modified ) {
491
-		$this->set( 'EVT_modified', $modified );
490
+	public function set_modified($modified) {
491
+		$this->set('EVT_modified', $modified);
492 492
 	}
493 493
 
494 494
 
@@ -496,8 +496,8 @@  discard block
 block discarded – undo
496 496
 	/**
497 497
 	 * @param $name
498 498
 	 */
499
-	public function set_name( $name ) {
500
-		$this->set( 'EVT_name', $name );
499
+	public function set_name($name) {
500
+		$this->set('EVT_name', $name);
501 501
 	}
502 502
 
503 503
 
@@ -505,8 +505,8 @@  discard block
 block discarded – undo
505 505
 	/**
506 506
 	 * @param $order
507 507
 	 */
508
-	public function set_order( $order ) {
509
-		$this->set( 'EVT_order', $order );
508
+	public function set_order($order) {
509
+		$this->set('EVT_order', $order);
510 510
 	}
511 511
 
512 512
 
@@ -514,8 +514,8 @@  discard block
 block discarded – undo
514 514
 	/**
515 515
 	 * @param $short_desc
516 516
 	 */
517
-	public function set_short_description( $short_desc ) {
518
-		$this->set( 'EVT_short_desc', $short_desc );
517
+	public function set_short_description($short_desc) {
518
+		$this->set('EVT_short_desc', $short_desc);
519 519
 	}
520 520
 
521 521
 
@@ -523,8 +523,8 @@  discard block
 block discarded – undo
523 523
 	/**
524 524
 	 * @param $slug
525 525
 	 */
526
-	public function set_slug( $slug ) {
527
-		$this->set( 'EVT_slug', $slug );
526
+	public function set_slug($slug) {
527
+		$this->set('EVT_slug', $slug);
528 528
 	}
529 529
 
530 530
 
@@ -532,8 +532,8 @@  discard block
 block discarded – undo
532 532
 	/**
533 533
 	 * @param $timezone_string
534 534
 	 */
535
-	public function set_timezone_string( $timezone_string ) {
536
-		$this->set( 'EVT_timezone_string', $timezone_string );
535
+	public function set_timezone_string($timezone_string) {
536
+		$this->set('EVT_timezone_string', $timezone_string);
537 537
 	}
538 538
 
539 539
 
@@ -541,8 +541,8 @@  discard block
 block discarded – undo
541 541
 	/**
542 542
 	 * @param $visible_on
543 543
 	 */
544
-	public function set_visible_on( $visible_on ) {
545
-		$this->set( 'EVT_visible_on', $visible_on );
544
+	public function set_visible_on($visible_on) {
545
+		$this->set('EVT_visible_on', $visible_on);
546 546
 	}
547 547
 
548 548
 
@@ -550,8 +550,8 @@  discard block
 block discarded – undo
550 550
 	/**
551 551
 	 * @param $wp_user
552 552
 	 */
553
-	public function set_wp_user( $wp_user ) {
554
-		$this->set( 'EVT_wp_user', $wp_user );
553
+	public function set_wp_user($wp_user) {
554
+		$this->set('EVT_wp_user', $wp_user);
555 555
 	}
556 556
 
557 557
 
@@ -559,8 +559,8 @@  discard block
 block discarded – undo
559 559
 	/**
560 560
 	 * @param $default_registration_status
561 561
 	 */
562
-	public function set_default_registration_status( $default_registration_status ) {
563
-		$this->set( 'EVT_default_registration_status', $default_registration_status );
562
+	public function set_default_registration_status($default_registration_status) {
563
+		$this->set('EVT_default_registration_status', $default_registration_status);
564 564
 	}
565 565
 
566 566
 
@@ -568,8 +568,8 @@  discard block
 block discarded – undo
568 568
 	/**
569 569
 	 * @param $donations
570 570
 	 */
571
-	public function set_donations( $donations ) {
572
-		$this->set( 'EVT_donations', $donations );
571
+	public function set_donations($donations) {
572
+		$this->set('EVT_donations', $donations);
573 573
 	}
574 574
 
575 575
 
@@ -579,8 +579,8 @@  discard block
 block discarded – undo
579 579
 	 * @param EE_Venue /int $venue_id_or_obj
580 580
 	 * @return EE_Venue
581 581
 	 */
582
-	public function add_venue( $venue_id_or_obj ) {
583
-		return $this->_add_relation_to( $venue_id_or_obj, 'Venue' );
582
+	public function add_venue($venue_id_or_obj) {
583
+		return $this->_add_relation_to($venue_id_or_obj, 'Venue');
584 584
 	}
585 585
 
586 586
 
@@ -590,8 +590,8 @@  discard block
 block discarded – undo
590 590
 	 * @param EE_Venue /int $venue_id_or_obj
591 591
 	 * @return EE_Venue
592 592
 	 */
593
-	public function remove_venue( $venue_id_or_obj ) {
594
-		return $this->_remove_relation_to( $venue_id_or_obj, 'Venue' );
593
+	public function remove_venue($venue_id_or_obj) {
594
+		return $this->_remove_relation_to($venue_id_or_obj, 'Venue');
595 595
 	}
596 596
 
597 597
 
@@ -601,8 +601,8 @@  discard block
 block discarded – undo
601 601
 	 * @param array $query_params like EEM_Base::get_all's $query_params
602 602
 	 * @return EE_Venue[]
603 603
 	 */
604
-	public function venues( $query_params = array() ) {
605
-		return $this->get_many_related( 'Venue', $query_params );
604
+	public function venues($query_params = array()) {
605
+		return $this->get_many_related('Venue', $query_params);
606 606
 	}
607 607
 
608 608
 
@@ -614,7 +614,7 @@  discard block
 block discarded – undo
614 614
 	 */
615 615
 	private function _has_ID_and_is_published() {
616 616
 		// first check if event id is present and not NULL, then check if this event is published (or any of the equivalent "published" statuses)
617
-		return ( $this->ID() && $this->ID() !== NULL && ( $this->status() == 'publish' || $this->status() == EEM_Event::sold_out || $this->status() == EEM_Event::postponed || $this->status() == EEM_Event::cancelled ) ) ? TRUE : FALSE;
617
+		return ($this->ID() && $this->ID() !== NULL && ($this->status() == 'publish' || $this->status() == EEM_Event::sold_out || $this->status() == EEM_Event::postponed || $this->status() == EEM_Event::cancelled)) ? TRUE : FALSE;
618 618
 	}
619 619
 
620 620
 
@@ -626,21 +626,21 @@  discard block
 block discarded – undo
626 626
 	 */
627 627
 	public function is_upcoming() {
628 628
 		// check if event id is present and if this event is published
629
-		if ( $this->is_inactive() ) {
629
+		if ($this->is_inactive()) {
630 630
 			return FALSE;
631 631
 		}
632 632
 		// set initial value
633 633
 		$upcoming = FALSE;
634 634
 		//next let's get all datetimes and loop through them
635 635
 		$datetimes = $this->datetimes_in_chronological_order();
636
-		foreach ( $datetimes as $datetime ) {
637
-			if ( $datetime instanceof EE_Datetime ) {
636
+		foreach ($datetimes as $datetime) {
637
+			if ($datetime instanceof EE_Datetime) {
638 638
 				//if this dtt is expired then we continue cause one of the other datetimes might be upcoming.
639
-				if ( $datetime->is_expired() ) {
639
+				if ($datetime->is_expired()) {
640 640
 					continue;
641 641
 				}
642 642
 				//if this dtt is active then we return false.
643
-				if ( $datetime->is_active() ) {
643
+				if ($datetime->is_active()) {
644 644
 					return FALSE;
645 645
 				}
646 646
 				//otherwise let's check upcoming status
@@ -657,21 +657,21 @@  discard block
 block discarded – undo
657 657
 	 */
658 658
 	public function is_active() {
659 659
 		// check if event id is present and if this event is published
660
-		if ( $this->is_inactive() ) {
660
+		if ($this->is_inactive()) {
661 661
 			return FALSE;
662 662
 		}
663 663
 		// set initial value
664 664
 		$active = FALSE;
665 665
 		//next let's get all datetimes and loop through them
666 666
 		$datetimes = $this->datetimes_in_chronological_order();
667
-		foreach ( $datetimes as $datetime ) {
668
-			if ( $datetime instanceof EE_Datetime ) {
667
+		foreach ($datetimes as $datetime) {
668
+			if ($datetime instanceof EE_Datetime) {
669 669
 				//if this dtt is expired then we continue cause one of the other datetimes might be active.
670
-				if ( $datetime->is_expired() ) {
670
+				if ($datetime->is_expired()) {
671 671
 					continue;
672 672
 				}
673 673
 				//if this dtt is upcoming then we return false.
674
-				if ( $datetime->is_upcoming() ) {
674
+				if ($datetime->is_upcoming()) {
675 675
 					return FALSE;
676 676
 				}
677 677
 				//otherwise let's check active status
@@ -688,17 +688,17 @@  discard block
 block discarded – undo
688 688
 	 */
689 689
 	public function is_expired() {
690 690
 		// check if event id is present and if this event is published
691
-		if ( $this->is_inactive() ) {
691
+		if ($this->is_inactive()) {
692 692
 			return FALSE;
693 693
 		}
694 694
 		// set initial value
695 695
 		$expired = FALSE;
696 696
 		//first let's get all datetimes and loop through them
697 697
 		$datetimes = $this->datetimes_in_chronological_order();
698
-		foreach ( $datetimes as $datetime ) {
699
-			if ( $datetime instanceof EE_Datetime ) {
698
+		foreach ($datetimes as $datetime) {
699
+			if ($datetime instanceof EE_Datetime) {
700 700
 				//if this dtt is upcoming or active then we return false.
701
-				if ( $datetime->is_upcoming() || $datetime->is_active() ) {
701
+				if ($datetime->is_upcoming() || $datetime->is_active()) {
702 702
 					return FALSE;
703 703
 				}
704 704
 				//otherwise let's check active status
@@ -715,7 +715,7 @@  discard block
 block discarded – undo
715 715
 	 */
716 716
 	public function is_inactive() {
717 717
 		// check if event id is present and if this event is published
718
-		if ( $this->_has_ID_and_is_published() ) {
718
+		if ($this->_has_ID_and_is_published()) {
719 719
 			return FALSE;
720 720
 		}
721 721
 		return TRUE;
@@ -733,37 +733,37 @@  discard block
 block discarded – undo
733 733
 	 */
734 734
 	public function perform_sold_out_status_check() {
735 735
 		// get all unexpired untrashed tickets
736
-		$tickets = $this->tickets( array(
736
+		$tickets = $this->tickets(array(
737 737
 			array(
738
-				'TKT_end_date'   => array( '>=', EEM_Ticket::instance()->current_time_for_query( 'TKT_end_date' ) ),
738
+				'TKT_end_date'   => array('>=', EEM_Ticket::instance()->current_time_for_query('TKT_end_date')),
739 739
 				'TKT_deleted'    => false
740 740
 			)
741 741
 		));
742 742
 		// if all the tickets are just expired, then don't update the event status to sold out
743
-		if ( empty( $tickets )) {
743
+		if (empty($tickets)) {
744 744
 			return true;
745 745
 		}
746 746
 		// set initial value
747 747
 		$spaces_remaining = 0;
748
-		foreach( $tickets as $ticket ) {
749
-			if ( $ticket instanceof EE_Ticket ) {
750
-				$spaces_remaining += $ticket->qty( 'saleable' );
748
+		foreach ($tickets as $ticket) {
749
+			if ($ticket instanceof EE_Ticket) {
750
+				$spaces_remaining += $ticket->qty('saleable');
751 751
 			}
752 752
 		}
753
-		if ( $spaces_remaining === 0 ) {
754
-			$this->set_status( EEM_Event::sold_out );
755
-			if ( !is_admin() || ( is_admin() && defined( 'DOING_AJAX' ) ) ) {
753
+		if ($spaces_remaining === 0) {
754
+			$this->set_status(EEM_Event::sold_out);
755
+			if ( ! is_admin() || (is_admin() && defined('DOING_AJAX'))) {
756 756
 				$this->save();
757 757
 			}
758 758
 			$sold_out = TRUE;
759 759
 		} else {
760 760
 			$sold_out = FALSE;
761 761
 			// was event previously marked as sold out ?
762
-			if ( $this->status() == EEM_Event::sold_out ) {
762
+			if ($this->status() == EEM_Event::sold_out) {
763 763
 				// revert status to previous value, if it was set
764
-				$previous_event_status = $this->get_post_meta( '_previous_event_status', true );
765
-				if ( $previous_event_status ) {
766
-					$this->set_status( $previous_event_status );
764
+				$previous_event_status = $this->get_post_meta('_previous_event_status', true);
765
+				if ($previous_event_status) {
766
+					$this->set_status($previous_event_status);
767 767
 				}
768 768
 			}
769 769
 		}
@@ -787,15 +787,15 @@  discard block
 block discarded – undo
787 787
 	 */
788 788
 	public function spaces_remaining_for_sale() {
789 789
 		//first get total available spaces including consideration for tickets that have already sold.
790
-		$spaces_available = $this->total_available_spaces( true );
790
+		$spaces_available = $this->total_available_spaces(true);
791 791
 
792 792
 		//if total available = 0, then exit right away because that means everything is expired.
793
-		if ( $spaces_available === 0 ) {
793
+		if ($spaces_available === 0) {
794 794
 			return 0;
795 795
 		}
796 796
 
797 797
 		//subtract total approved registrations from spaces available to get how many are remaining.
798
-		$spots_taken = EEM_Registration::instance()->count( array( array( 'EVT_ID' => $this->ID(), 'STS_ID' => EEM_Registration::status_id_approved ) ), 'REG_ID', true );
798
+		$spots_taken = EEM_Registration::instance()->count(array(array('EVT_ID' => $this->ID(), 'STS_ID' => EEM_Registration::status_id_approved)), 'REG_ID', true);
799 799
 		$spaces_remaining = $spaces_available - $spots_taken;
800 800
 
801 801
 		return $spaces_remaining > 0 ? $spaces_remaining : 0;
@@ -828,29 +828,29 @@  discard block
 block discarded – undo
828 828
 	 *
829 829
 	 * @return  int|float  (Note: if EE_INF is returned its considered a float by PHP)
830 830
 	 */
831
-	public function total_available_spaces( $current_total_available = false ) {
831
+	public function total_available_spaces($current_total_available = false) {
832 832
 		$spaces_available = 0;
833 833
 
834 834
 		//first get all tickets on the event and include expired tickets
835
-		$tickets = $this->tickets( array( 'default_where_conditions' => 'none' ) );
835
+		$tickets = $this->tickets(array('default_where_conditions' => 'none'));
836 836
 		$ticket_sums = array();
837 837
 		$datetime_limits = array();
838 838
 
839 839
 		//loop through tickets and normalize them
840
-		foreach ( $tickets as $ticket ) {
841
-			$datetimes = $ticket->datetimes( array( 'order_by' => array( 'DTT_reg_limit' => 'ASC' ) ) );
840
+		foreach ($tickets as $ticket) {
841
+			$datetimes = $ticket->datetimes(array('order_by' => array('DTT_reg_limit' => 'ASC')));
842 842
 
843
-			if ( empty( $datetimes ) ) {
843
+			if (empty($datetimes)) {
844 844
 				continue;
845 845
 			}
846 846
 
847 847
 			//first datetime should be the lowest datetime
848
-			$least_datetime = reset( $datetimes );
848
+			$least_datetime = reset($datetimes);
849 849
 
850 850
 			//lets reset the ticket quantity to be the lower of either the lowest datetime reg limit or the ticket quantity
851 851
 			//IF datetimes sold (and we're not doing current live total available, then use spaces remaining for datetime, not reg_limit.
852
-			if ( $current_total_available ) {
853
-				if ( $ticket->is_remaining() ) {
852
+			if ($current_total_available) {
853
+				if ($ticket->is_remaining()) {
854 854
 					$remaining = $ticket->remaining();
855 855
 				} else {
856 856
 					$spaces_available += $ticket->sold();
@@ -858,23 +858,23 @@  discard block
 block discarded – undo
858 858
 					continue;
859 859
 				}
860 860
 			} else {
861
-				$remaining = min( $ticket->qty(), $least_datetime->reg_limit() );
861
+				$remaining = min($ticket->qty(), $least_datetime->reg_limit());
862 862
 			}
863 863
 
864 864
 			//if $ticket_limit == infinity then let's drop out right away and just return that because any infinity amount trumps all other "available" amounts.
865
-			if ( $remaining === EE_INF ) {
865
+			if ($remaining === EE_INF) {
866 866
 				return EE_INF;
867 867
 			}
868 868
 
869 869
 			//multiply normalized $tkt quantity by the number of datetimes on the ticket as the "sum"
870 870
 			//also include the sum of all the datetime reg limits on the ticket for breaking ties.
871
-			$ticket_sums[$ticket->ID()]['sum'] = $remaining * count( $datetimes );
871
+			$ticket_sums[$ticket->ID()]['sum'] = $remaining * count($datetimes);
872 872
 			$ticket_sums[$ticket->ID()]['datetime_sums'] = 0;
873
-			foreach ( $datetimes as $datetime ) {
874
-				if ( $datetime->reg_limit() === EE_INF ) {
873
+			foreach ($datetimes as $datetime) {
874
+				if ($datetime->reg_limit() === EE_INF) {
875 875
 					$ticket_sums[$ticket->ID()]['datetime_sums'] = EE_INF;
876 876
 				} else {
877
-					$ticket_sums[ $ticket->ID() ]['datetime_sums'] += $current_total_available ? $datetime->spaces_remaining() : $datetime->reg_limit();
877
+					$ticket_sums[$ticket->ID()]['datetime_sums'] += $current_total_available ? $datetime->spaces_remaining() : $datetime->reg_limit();
878 878
 				}
879 879
 				$datetime_limits[$datetime->ID()] = $current_total_available ? $datetime->spaces_remaining() : $datetime->reg_limit();
880 880
 			}
@@ -885,74 +885,74 @@  discard block
 block discarded – undo
885 885
 		//ticket quantity by the number of datetimes on the ticket).  For tie-breakers, then the next sort is based on the
886 886
 		//ticket with the greatest sum of all remaining datetime->spaces_remaining() ( or $datetime->reg_limit() if not
887 887
 		//$current_total_available ) for the datetimes on the ticket.
888
-		usort( $ticket_sums, function( $a, $b ) {
889
-			if ( $a['sum'] == $b['sum'] ) {
890
-				if ( $a['datetime_sums'] == $b['datetime_sums'] ) {
888
+		usort($ticket_sums, function($a, $b) {
889
+			if ($a['sum'] == $b['sum']) {
890
+				if ($a['datetime_sums'] == $b['datetime_sums']) {
891 891
 					return 0;
892 892
 				}
893 893
 
894 894
 				return $a['datetime_sums'] < $b['datetime_sums'] ? 1 : -1;
895 895
 			}
896
-			return ( $a['sum'] < $b['sum'] ) ? -1 : 1;
896
+			return ($a['sum'] < $b['sum']) ? -1 : 1;
897 897
 		});
898 898
 
899 899
 		//now let's loop through the sorted tickets and simulate sellouts
900
-		foreach ( $ticket_sums as $ticket_info ) {
901
-			if ( $ticket_info['ticket'] instanceof EE_Ticket ) {
900
+		foreach ($ticket_sums as $ticket_info) {
901
+			if ($ticket_info['ticket'] instanceof EE_Ticket) {
902 902
 
903
-				$datetimes = $ticket_info['ticket']->datetimes( array( 'order_by' => array( 'DTT_reg_limit' => 'ASC' ) ) );
903
+				$datetimes = $ticket_info['ticket']->datetimes(array('order_by' => array('DTT_reg_limit' => 'ASC')));
904 904
 				//need to sort these $datetimes by remaining (only if $current_total_available)
905 905
 				//setup datetimes for simulation
906 906
 				$ticket_datetimes_remaining = array();
907
-				foreach( $datetimes as $datetime ) {
907
+				foreach ($datetimes as $datetime) {
908 908
 					$ticket_datetimes_remaining[$datetime->ID()]['rem'] = $datetime_limits[$datetime->ID()];
909 909
 					$ticket_datetimes_remaining[$datetime->ID()]['datetime'] = $datetime;
910 910
 				}
911
-				usort( $ticket_datetimes_remaining, function( $a, $b ) {
912
-					if ( $a['rem'] == $b['rem'] ) {
911
+				usort($ticket_datetimes_remaining, function($a, $b) {
912
+					if ($a['rem'] == $b['rem']) {
913 913
 						return 0;
914 914
 					}
915
-					return ( $a['rem'] < $b['rem'] ) ? -1 : 1;
915
+					return ($a['rem'] < $b['rem']) ? -1 : 1;
916 916
 				});
917 917
 
918 918
 
919 919
 				//get the remaining on the first datetime (which should be the one with the least remaining) and that is
920 920
 				//what we add to the spaces_available running total.  Then we need to decrease the remaining on our datetime tracker.
921
-				$lowest_datetime = reset( $ticket_datetimes_remaining );
921
+				$lowest_datetime = reset($ticket_datetimes_remaining);
922 922
 
923 923
 				//need to get the lower of; what the remaining is on the lowest datetime, and the remaining on the ticket.
924 924
 				// If this ends up being 0 (because of previous tickets in our simulation selling out), then it has already
925 925
 				// been tracked on $spaces available and this ticket is now sold out for the simulation, so we can continue
926 926
 				// to the next ticket.
927
-				if ( $current_total_available ) {
928
-					$remaining = min( $lowest_datetime['rem'], $ticket_info['ticket']->remaining() );
927
+				if ($current_total_available) {
928
+					$remaining = min($lowest_datetime['rem'], $ticket_info['ticket']->remaining());
929 929
 				} else {
930
-					$remaining = min( $lowest_datetime['rem'], $ticket_info['ticket']->qty() );
930
+					$remaining = min($lowest_datetime['rem'], $ticket_info['ticket']->qty());
931 931
 				}
932 932
 
933 933
 				//if $remaining is infinite that means that all datetimes on this ticket are infinite but we've made it here because all
934 934
 				//tickets have a quantity.  So we don't have to track datetimes, we can just use ticket quantities for total
935 935
 				//available.
936
-				if ( $remaining === EE_INF ) {
936
+				if ($remaining === EE_INF) {
937 937
 					$spaces_available += $ticket_info['ticket']->qty();
938 938
 					continue;
939 939
 				}
940 940
 
941 941
 				//if ticket has sold amounts then we also need to add that (but only if doing live counts)
942
-				if ( $current_total_available ) {
942
+				if ($current_total_available) {
943 943
 					$spaces_available += $ticket_info['ticket']->sold();
944 944
 				}
945 945
 
946
-				if ( $remaining <= 0 ) {
946
+				if ($remaining <= 0) {
947 947
 					continue;
948 948
 				} else {
949 949
 					$spaces_available += $remaining;
950 950
 				}
951 951
 
952 952
 				//loop through the datetimes and sell them out!
953
-				foreach ( $ticket_datetimes_remaining as $datetime_info ) {
954
-					if ( $datetime_info['datetime'] instanceof EE_Datetime ) {
955
-						$datetime_limits[ $datetime_info['datetime']->ID() ] += - $remaining;
953
+				foreach ($ticket_datetimes_remaining as $datetime_info) {
954
+					if ($datetime_info['datetime'] instanceof EE_Datetime) {
955
+						$datetime_limits[$datetime_info['datetime']->ID()] += - $remaining;
956 956
 					}
957 957
 				}
958 958
 			}
@@ -968,8 +968,8 @@  discard block
 block discarded – undo
968 968
 	 * @param  bool $actual whether or not to perform calculations to not only figure the actual status but also to flip the status if necessary to sold out If false, we just check the existing status of the event
969 969
 	 * @return boolean
970 970
 	 */
971
-	public function is_sold_out( $actual = FALSE ) {
972
-		if ( ! $actual ) {
971
+	public function is_sold_out($actual = FALSE) {
972
+		if ( ! $actual) {
973 973
 			return $this->status() == EEM_Event::sold_out;
974 974
 		}
975 975
 		else {
@@ -1014,30 +1014,30 @@  discard block
 block discarded – undo
1014 1014
 	 *
1015 1015
 	 * @return bool | string - based on EE_Datetime active constants or FALSE if error.
1016 1016
 	 */
1017
-	public function get_active_status( $reset = false ) {
1017
+	public function get_active_status($reset = false) {
1018 1018
 		// if the active status has already been set, then just use that value (unless we are resetting it)
1019
-		if ( ! empty( $this->_active_status ) && ! $reset ) {
1019
+		if ( ! empty($this->_active_status) && ! $reset) {
1020 1020
 			return $this->_active_status;
1021 1021
 		}
1022 1022
 		//first check if event id is present on this object
1023
-		if ( ! $this->ID() ) {
1023
+		if ( ! $this->ID()) {
1024 1024
 			return false;
1025 1025
 		}
1026 1026
 
1027
-		$where_params_for_event  = array( array( 'EVT_ID' => $this->ID() ) );
1027
+		$where_params_for_event = array(array('EVT_ID' => $this->ID()));
1028 1028
 
1029 1029
 		//if event is published:
1030
-		if ( $this->status() === 'publish' ) {
1030
+		if ($this->status() === 'publish') {
1031 1031
 			//active?
1032
-			if ( EEM_Datetime::instance()->get_datetime_count_for_status( EE_Datetime::active, $where_params_for_event ) > 0 ) {
1032
+			if (EEM_Datetime::instance()->get_datetime_count_for_status(EE_Datetime::active, $where_params_for_event) > 0) {
1033 1033
 				$this->_active_status = EE_Datetime::active;
1034 1034
 			} else {
1035 1035
 				//upcoming?
1036
-				if ( EEM_Datetime::instance()->get_datetime_count_for_status( EE_Datetime::upcoming, $where_params_for_event  ) > 0 ) {
1036
+				if (EEM_Datetime::instance()->get_datetime_count_for_status(EE_Datetime::upcoming, $where_params_for_event) > 0) {
1037 1037
 					$this->_active_status = EE_Datetime::upcoming;
1038 1038
 				} else {
1039 1039
 					//expired?
1040
-					if ( EEM_Datetime::instance()->get_datetime_count_for_status( EE_Datetime::expired, $where_params_for_event  ) > 0 ) {
1040
+					if (EEM_Datetime::instance()->get_datetime_count_for_status(EE_Datetime::expired, $where_params_for_event) > 0) {
1041 1041
 						$this->_active_status = EE_Datetime::expired;
1042 1042
 					} else {
1043 1043
 						//it would be odd if things make it this far because it basically means there are no datetime's
@@ -1048,7 +1048,7 @@  discard block
 block discarded – undo
1048 1048
 			}
1049 1049
 		} else {
1050 1050
 			//the event is not published, so let's just set it's active status according to its' post status
1051
-			switch ( $this->status() ) {
1051
+			switch ($this->status()) {
1052 1052
 				case EEM_Event::sold_out :
1053 1053
 					$this->_active_status = EE_Datetime::sold_out;
1054 1054
 					break;
@@ -1074,10 +1074,10 @@  discard block
 block discarded – undo
1074 1074
 	 * @param boolean $echo     whether to return (FALSE), or echo out the result (TRUE)
1075 1075
 	 * @return mixed void|string
1076 1076
 	 */
1077
-	public function pretty_active_status( $echo = TRUE ) {
1077
+	public function pretty_active_status($echo = TRUE) {
1078 1078
 		$active_status = $this->get_active_status();
1079
-		$status = '<span class="ee-status event-active-status-' . $active_status . '">' . EEH_Template::pretty_status( $active_status, FALSE, 'sentence' ) . '</span>';
1080
-		if ( $echo ) {
1079
+		$status = '<span class="ee-status event-active-status-'.$active_status.'">'.EEH_Template::pretty_status($active_status, FALSE, 'sentence').'</span>';
1080
+		if ($echo) {
1081 1081
 			echo $status;
1082 1082
 			return '';
1083 1083
 		}
@@ -1091,12 +1091,12 @@  discard block
 block discarded – undo
1091 1091
 	 */
1092 1092
 	public function get_number_of_tickets_sold() {
1093 1093
 		$tkt_sold = 0;
1094
-		if ( !$this->ID() ) {
1094
+		if ( ! $this->ID()) {
1095 1095
 			return 0;
1096 1096
 		}
1097 1097
 		$datetimes = $this->datetimes();
1098
-		foreach ( $datetimes as $datetime ) {
1099
-			if ( $datetime instanceof EE_Datetime ) {
1098
+		foreach ($datetimes as $datetime) {
1099
+			if ($datetime instanceof EE_Datetime) {
1100 1100
 				$tkt_sold += $datetime->sold();
1101 1101
 			}
1102 1102
 		}
@@ -1111,7 +1111,7 @@  discard block
 block discarded – undo
1111 1111
 	 * @return int
1112 1112
 	 */
1113 1113
 	public function get_count_of_all_registrations() {
1114
-		return EEM_Event::instance()->count_related( $this, 'Registration' );
1114
+		return EEM_Event::instance()->count_related($this, 'Registration');
1115 1115
 	}
1116 1116
 
1117 1117
 
@@ -1121,9 +1121,9 @@  discard block
 block discarded – undo
1121 1121
 	 * @return EE_Ticket
1122 1122
 	 */
1123 1123
 	public function get_ticket_with_earliest_start_time() {
1124
-		$where[ 'Datetime.EVT_ID' ] = $this->ID();
1125
-		$query_params = array( $where, 'order_by' => array( 'TKT_start_date' => 'ASC' ) );
1126
-		return EE_Registry::instance()->load_model( 'Ticket' )->get_one( $query_params );
1124
+		$where['Datetime.EVT_ID'] = $this->ID();
1125
+		$query_params = array($where, 'order_by' => array('TKT_start_date' => 'ASC'));
1126
+		return EE_Registry::instance()->load_model('Ticket')->get_one($query_params);
1127 1127
 	}
1128 1128
 
1129 1129
 
@@ -1133,9 +1133,9 @@  discard block
 block discarded – undo
1133 1133
 	 * @return EE_Ticket
1134 1134
 	 */
1135 1135
 	public function get_ticket_with_latest_end_time() {
1136
-		$where[ 'Datetime.EVT_ID' ] = $this->ID();
1137
-		$query_params = array( $where, 'order_by' => array( 'TKT_end_date' => 'DESC' ) );
1138
-		return EE_Registry::instance()->load_model( 'Ticket' )->get_one( $query_params );
1136
+		$where['Datetime.EVT_ID'] = $this->ID();
1137
+		$query_params = array($where, 'order_by' => array('TKT_end_date' => 'DESC'));
1138
+		return EE_Registry::instance()->load_model('Ticket')->get_one($query_params);
1139 1139
 	}
1140 1140
 
1141 1141
 
@@ -1147,11 +1147,11 @@  discard block
 block discarded – undo
1147 1147
 	public function tickets_on_sale() {
1148 1148
 		$earliest_ticket = $this->get_ticket_with_earliest_start_time();
1149 1149
 		$latest_ticket = $this->get_ticket_with_latest_end_time();
1150
-		if ( !$latest_ticket instanceof EE_Ticket && !$earliest_ticket instanceof EE_Ticket ) {
1150
+		if ( ! $latest_ticket instanceof EE_Ticket && ! $earliest_ticket instanceof EE_Ticket) {
1151 1151
 			return FALSE;
1152 1152
 		}
1153 1153
 		//check on sale for these two tickets.
1154
-		if ( $latest_ticket->is_on_sale() || $earliest_ticket->is_on_sale() ) {
1154
+		if ($latest_ticket->is_on_sale() || $earliest_ticket->is_on_sale()) {
1155 1155
 			return TRUE;
1156 1156
 		}
1157 1157
 		return FALSE;
@@ -1165,7 +1165,7 @@  discard block
 block discarded – undo
1165 1165
 	 * @return string
1166 1166
 	 */
1167 1167
 	public function get_permalink() {
1168
-		if ( $this->external_url() ) {
1168
+		if ($this->external_url()) {
1169 1169
 			return $this->external_url();
1170 1170
 		}
1171 1171
 		else {
@@ -1180,10 +1180,10 @@  discard block
 block discarded – undo
1180 1180
 	 * @param array $query_params like EEM_Base::get_all
1181 1181
 	 * @return EE_Term
1182 1182
 	 */
1183
-	public function first_event_category( $query_params = array() ) {
1184
-		$query_params[ 0 ][ 'Term_Taxonomy.taxonomy' ] = 'espresso_event_categories';
1185
-		$query_params[ 0 ][ 'Term_Taxonomy.Event.EVT_ID' ] = $this->ID();
1186
-		return EEM_Term::instance()->get_one( $query_params );
1183
+	public function first_event_category($query_params = array()) {
1184
+		$query_params[0]['Term_Taxonomy.taxonomy'] = 'espresso_event_categories';
1185
+		$query_params[0]['Term_Taxonomy.Event.EVT_ID'] = $this->ID();
1186
+		return EEM_Term::instance()->get_one($query_params);
1187 1187
 	}
1188 1188
 
1189 1189
 
@@ -1193,10 +1193,10 @@  discard block
 block discarded – undo
1193 1193
 	 * @param array $query_params
1194 1194
 	 * @return EE_Term[]
1195 1195
 	 */
1196
-	public function get_all_event_categories( $query_params = array() ) {
1197
-		$query_params[ 0 ][ 'Term_Taxonomy.taxonomy' ] = 'espresso_event_categories';
1198
-		$query_params[ 0 ][ 'Term_Taxonomy.Event.EVT_ID' ] = $this->ID();
1199
-		return EEM_Term::instance()->get_all( $query_params );
1196
+	public function get_all_event_categories($query_params = array()) {
1197
+		$query_params[0]['Term_Taxonomy.taxonomy'] = 'espresso_event_categories';
1198
+		$query_params[0]['Term_Taxonomy.Event.EVT_ID'] = $this->ID();
1199
+		return EEM_Term::instance()->get_all($query_params);
1200 1200
 	}
1201 1201
 
1202 1202
 	/**
@@ -1204,8 +1204,8 @@  discard block
 block discarded – undo
1204 1204
 	 * @param array $query_params @see EEM_Base::get_all
1205 1205
 	 * @return EE_Question_Group[]
1206 1206
 	 */
1207
-	public function question_groups($query_params = array()){
1208
-		$query_params = ! empty( $query_params ) ? $query_params : array( 'order_by' => array( 'QSG_order' => 'ASC' ));
1207
+	public function question_groups($query_params = array()) {
1208
+		$query_params = ! empty($query_params) ? $query_params : array('order_by' => array('QSG_order' => 'ASC'));
1209 1209
 		return $this->get_many_related('Question_Group', $query_params);
1210 1210
 	}
1211 1211
 
@@ -1244,12 +1244,12 @@  discard block
 block discarded – undo
1244 1244
 	 * @return string
1245 1245
 	 */
1246 1246
 	public function get_admin_edit_link() {
1247
-		return EEH_URL::add_query_args_and_nonce( array(
1247
+		return EEH_URL::add_query_args_and_nonce(array(
1248 1248
 			'page' => 'espresso_events',
1249 1249
 			'action' => 'edit',
1250 1250
 			'post' => $this->ID()
1251 1251
 			),
1252
-			admin_url( 'admin.php' )
1252
+			admin_url('admin.php')
1253 1253
 		);
1254 1254
 	}
1255 1255
 
@@ -1261,11 +1261,11 @@  discard block
 block discarded – undo
1261 1261
 	 * @return string
1262 1262
 	 */
1263 1263
 	public function get_admin_settings_link() {
1264
-		return EEH_URL::add_query_args_and_nonce( array(
1264
+		return EEH_URL::add_query_args_and_nonce(array(
1265 1265
 			'page' => 'espresso_events',
1266 1266
 			'action' => 'default_event_settings'
1267 1267
 			),
1268
-			admin_url( 'admin.php' )
1268
+			admin_url('admin.php')
1269 1269
 		);
1270 1270
 	}
1271 1271
 
@@ -1280,11 +1280,11 @@  discard block
 block discarded – undo
1280 1280
 	 */
1281 1281
 	public function get_admin_overview_link() {
1282 1282
 
1283
-		return EEH_URL::add_query_args_and_nonce( array(
1283
+		return EEH_URL::add_query_args_and_nonce(array(
1284 1284
 			'page' => 'espresso_events',
1285 1285
 			'action' => 'default'
1286 1286
 		),
1287
-			admin_url( 'admin.php' )
1287
+			admin_url('admin.php')
1288 1288
 		);
1289 1289
 	}
1290 1290
 
Please login to merge, or discard this patch.