Completed
Branch FET-10768-extract-admin-bar (bf1399)
by
unknown
150:47 queued 140:15
created
espresso.php 1 patch
Indentation   +219 added lines, -219 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,243 +40,243 @@  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.46.rc.040');
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.46.rc.040');
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
-        // for older WP versions
197
-        if ( ! defined('MONTH_IN_SECONDS')) {
198
-            define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30);
199
-        }
200
-        /**
201
-         *    espresso_plugin_activation
202
-         *    adds a wp-option to indicate that EE has been activated via the WP admin plugins page
203
-         */
204
-        function espresso_plugin_activation()
205
-        {
206
-            update_option('ee_espresso_activation', true);
207
-        }
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
+		// for older WP versions
197
+		if ( ! defined('MONTH_IN_SECONDS')) {
198
+			define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30);
199
+		}
200
+		/**
201
+		 *    espresso_plugin_activation
202
+		 *    adds a wp-option to indicate that EE has been activated via the WP admin plugins page
203
+		 */
204
+		function espresso_plugin_activation()
205
+		{
206
+			update_option('ee_espresso_activation', true);
207
+		}
208 208
 
209
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
210
-        /**
211
-         *    espresso_load_error_handling
212
-         *    this function loads EE's class for handling exceptions and errors
213
-         */
214
-        function espresso_load_error_handling()
215
-        {
216
-            // load debugging tools
217
-            if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
218
-                require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php');
219
-                EEH_Debug_Tools::instance();
220
-            }
221
-            // load error handling
222
-            if (is_readable(EE_CORE . 'EE_Error.core.php')) {
223
-                require_once(EE_CORE . 'EE_Error.core.php');
224
-            } else {
225
-                wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
226
-            }
227
-        }
209
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
210
+		/**
211
+		 *    espresso_load_error_handling
212
+		 *    this function loads EE's class for handling exceptions and errors
213
+		 */
214
+		function espresso_load_error_handling()
215
+		{
216
+			// load debugging tools
217
+			if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
218
+				require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php');
219
+				EEH_Debug_Tools::instance();
220
+			}
221
+			// load error handling
222
+			if (is_readable(EE_CORE . 'EE_Error.core.php')) {
223
+				require_once(EE_CORE . 'EE_Error.core.php');
224
+			} else {
225
+				wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
226
+			}
227
+		}
228 228
 
229
-        /**
230
-         *    espresso_load_required
231
-         *    given a class name and path, this function will load that file or throw an exception
232
-         *
233
-         * @param    string $classname
234
-         * @param    string $full_path_to_file
235
-         * @throws    EE_Error
236
-         */
237
-        function espresso_load_required($classname, $full_path_to_file)
238
-        {
239
-            static $error_handling_loaded = false;
240
-            if ( ! $error_handling_loaded) {
241
-                espresso_load_error_handling();
242
-                $error_handling_loaded = true;
243
-            }
244
-            if (is_readable($full_path_to_file)) {
245
-                require_once($full_path_to_file);
246
-            } else {
247
-                throw new EE_Error (
248
-                        sprintf(
249
-                                esc_html__(
250
-                                        'The %s class file could not be located or is not readable due to file permissions.',
251
-                                        'event_espresso'
252
-                                ),
253
-                                $classname
254
-                        )
255
-                );
256
-            }
257
-        }
229
+		/**
230
+		 *    espresso_load_required
231
+		 *    given a class name and path, this function will load that file or throw an exception
232
+		 *
233
+		 * @param    string $classname
234
+		 * @param    string $full_path_to_file
235
+		 * @throws    EE_Error
236
+		 */
237
+		function espresso_load_required($classname, $full_path_to_file)
238
+		{
239
+			static $error_handling_loaded = false;
240
+			if ( ! $error_handling_loaded) {
241
+				espresso_load_error_handling();
242
+				$error_handling_loaded = true;
243
+			}
244
+			if (is_readable($full_path_to_file)) {
245
+				require_once($full_path_to_file);
246
+			} else {
247
+				throw new EE_Error (
248
+						sprintf(
249
+								esc_html__(
250
+										'The %s class file could not be located or is not readable due to file permissions.',
251
+										'event_espresso'
252
+								),
253
+								$classname
254
+						)
255
+				);
256
+			}
257
+		}
258 258
 
259
-        espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php');
260
-        espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php');
261
-        espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php');
262
-        new EE_Bootstrap();
263
-    }
259
+		espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php');
260
+		espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php');
261
+		espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php');
262
+		new EE_Bootstrap();
263
+	}
264 264
 }
265 265
 if ( ! function_exists('espresso_deactivate_plugin')) {
266
-    /**
267
-     *    deactivate_plugin
268
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
269
-     *
270
-     * @access public
271
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
272
-     * @return    void
273
-     */
274
-    function espresso_deactivate_plugin($plugin_basename = '')
275
-    {
276
-        if ( ! function_exists('deactivate_plugins')) {
277
-            require_once(ABSPATH . 'wp-admin/includes/plugin.php');
278
-        }
279
-        unset($_GET['activate'], $_REQUEST['activate']);
280
-        deactivate_plugins($plugin_basename);
281
-    }
266
+	/**
267
+	 *    deactivate_plugin
268
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
269
+	 *
270
+	 * @access public
271
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
272
+	 * @return    void
273
+	 */
274
+	function espresso_deactivate_plugin($plugin_basename = '')
275
+	{
276
+		if ( ! function_exists('deactivate_plugins')) {
277
+			require_once(ABSPATH . 'wp-admin/includes/plugin.php');
278
+		}
279
+		unset($_GET['activate'], $_REQUEST['activate']);
280
+		deactivate_plugins($plugin_basename);
281
+	}
282 282
 }
283 283
\ No newline at end of file
Please login to merge, or discard this patch.
core/domain/services/admin/AdminToolBar.php 1 patch
Indentation   +799 added lines, -799 removed lines patch added patch discarded remove patch
@@ -22,804 +22,804 @@
 block discarded – undo
22 22
 class AdminToolBar
23 23
 {
24 24
 
25
-    /**
26
-     * @var WP_Admin_Bar $admin_bar
27
-     */
28
-    private $admin_bar;
29
-
30
-    /**
31
-     * @var EE_Capabilities $capabilities
32
-     */
33
-    private $capabilities;
34
-
35
-    /**
36
-     * @var string $events_admin_url
37
-     */
38
-    private $events_admin_url;
39
-
40
-    /**
41
-     * @var string $menu_class
42
-     */
43
-    private $menu_class = 'espresso_menu_item_class';
44
-
45
-    /**
46
-     * @var string $reg_admin_url
47
-     */
48
-    private $reg_admin_url;
49
-
50
-
51
-
52
-    /**
53
-     * AdminToolBar constructor.
54
-     *
55
-     * @param EE_Capabilities $capabilities
56
-     */
57
-    public function __construct(EE_Capabilities $capabilities)
58
-    {
59
-        $this->capabilities = $capabilities;
60
-        add_action('admin_bar_menu', array($this, 'espressoToolbarItems'), 100);
61
-        $this->enqueueAssets();
62
-    }
63
-
64
-
65
-
66
-    /**
67
-     *    espresso_toolbar_items
68
-     *
69
-     * @access public
70
-     * @param  WP_Admin_Bar $admin_bar
71
-     * @return void
72
-     */
73
-    public function espressoToolbarItems(WP_Admin_Bar $admin_bar)
74
-    {
75
-        // if its an AJAX request, or user is NOT an admin, or in full M-Mode
76
-        if (
77
-            defined('DOING_AJAX')
78
-            || ! $this->capabilities->current_user_can('ee_read_ee', 'ee_admin_bar_menu_top_level')
79
-            || EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance
80
-        ) {
81
-            return;
82
-        }
83
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
84
-        $this->admin_bar = $admin_bar;
85
-        //we don't use the constants EVENTS_ADMIN_URL or REG_ADMIN_URL
86
-        //because they're only defined in each of their respective constructors
87
-        //and this might be a frontend request, in which case they aren't available
88
-        $this->events_admin_url = admin_url('admin.php?page=espresso_events');
89
-        $this->reg_admin_url = admin_url('admin.php?page=espresso_registrations');
90
-        // now let's add all of the menu items
91
-        $this->addTopLevelMenu();
92
-        $this->addEventsSubMenu();
93
-        $this->addEventsAddEditHeader();
94
-        $this->addEventsAddNew();
95
-        $this->addEventsEditCurrentEvent();
96
-        $this->addEventsViewHeader();
97
-        $this->addEventsViewAll();
98
-        $this->addEventsViewToday();
99
-        $this->addEventsViewThisMonth();
100
-        $this->addRegistrationSubMenu();
101
-        $this->addRegistrationOverviewToday();
102
-        $this->addRegistrationOverviewTodayApproved();
103
-        $this->addRegistrationOverviewTodayPendingPayment();
104
-        $this->addRegistrationOverviewTodayNotApproved();
105
-        $this->addRegistrationOverviewTodayCancelled();
106
-        $this->addRegistrationOverviewThisMonth();
107
-        $this->addRegistrationOverviewThisMonthApproved();
108
-        $this->addRegistrationOverviewThisMonthPending();
109
-        $this->addRegistrationOverviewThisMonthNotApproved();
110
-        $this->addRegistrationOverviewThisMonthCancelled();
111
-        $this->addExtensionsAndServices();
112
-    }
113
-
114
-
115
-
116
-    /**
117
-     * @return void
118
-     */
119
-    private function enqueueAssets()
120
-    {
121
-        wp_register_style(
122
-            'espresso-admin-toolbar',
123
-            EE_GLOBAL_ASSETS_URL . 'css/espresso-admin-toolbar.css',
124
-            array('dashicons'),
125
-            EVENT_ESPRESSO_VERSION
126
-        );
127
-        wp_enqueue_style('espresso-admin-toolbar');
128
-    }
129
-
130
-
131
-
132
-    /**
133
-     * @return void
134
-     */
135
-    private function addTopLevelMenu()
136
-    {
137
-        $this->admin_bar->add_menu(
138
-            array(
139
-                'id'    => 'espresso-toolbar',
140
-                'title' => '<span class="ee-icon ee-icon-ee-cup-thick ee-icon-size-20"></span><span class="ab-label">'
141
-                    . esc_html_x('Event Espresso', 'admin bar menu group label', 'event_espresso')
142
-                    . '</span>',
143
-                'href'  => $this->events_admin_url,
144
-                'meta'  => array(
145
-                    'title' => esc_html__('Event Espresso', 'event_espresso'),
146
-                    'class' => $this->menu_class . 'first',
147
-                ),
148
-            )
149
-        );
150
-    }
151
-
152
-
153
-
154
-    /**
155
-     * @return void
156
-     */
157
-    private function addEventsSubMenu()
158
-    {
159
-        if (
160
-            $this->capabilities->current_user_can(
161
-                'ee_read_events',
162
-                'ee_admin_bar_menu_espresso-toolbar-events'
163
-            )
164
-        ) {
165
-            $this->admin_bar->add_menu(
166
-                array(
167
-                    'id'     => 'espresso-toolbar-events',
168
-                    'parent' => 'espresso-toolbar',
169
-                    'title'  => '<span class="ee-toolbar-icon"></span>'
170
-                                . esc_html__('Events', 'event_espresso'),
171
-                    'href'   => $this->events_admin_url,
172
-                    'meta'   => array(
173
-                        'title'  => esc_html__('Events', 'event_espresso'),
174
-                        'target' => '',
175
-                        'class'  => $this->menu_class,
176
-                    ),
177
-                )
178
-            );
179
-        }
180
-    }
181
-
182
-
183
-
184
-    /**
185
-     * @return void
186
-     */
187
-    private function addEventsAddEditHeader()
188
-    {
189
-        if (
190
-        $this->capabilities->current_user_can(
191
-            'ee_read_events',
192
-            'ee_admin_bar_menu_espresso-toolbar-events-view'
193
-        )
194
-        ) {
195
-            $this->admin_bar->add_menu(
196
-                array(
197
-                    'id'     => 'espresso-toolbar-events-add-edit',
198
-                    'parent' => 'espresso-toolbar-events',
199
-                    'title'  => esc_html__('Add / Edit', 'event_espresso'),
200
-                    'href'   => '',
201
-                )
202
-            );
203
-        }
204
-    }
205
-
206
-
207
-
208
-    /**
209
-     * @return void
210
-     */
211
-    private function addEventsAddNew()
212
-    {
213
-        if (
214
-            $this->capabilities->current_user_can(
215
-                'ee_edit_events',
216
-                'ee_admin_bar_menu_espresso-toolbar-events-new'
217
-            )
218
-        ) {
219
-            $this->admin_bar->add_menu(
220
-                array(
221
-                    'id'     => 'espresso-toolbar-events-new',
222
-                    'parent' => 'espresso-toolbar-events',
223
-                    'title'  => '<span class="ee-toolbar-icon"></span>'
224
-                                . esc_html__('Add New', 'event_espresso'),
225
-                    'href'   => EEH_URL::add_query_args_and_nonce(
226
-                        array('action' => 'create_new'),
227
-                        $this->events_admin_url
228
-                    ),
229
-                    'meta'   => array(
230
-                        'title'  => esc_html__('Add New', 'event_espresso'),
231
-                        'target' => '',
232
-                        'class'  => $this->menu_class,
233
-                    ),
234
-                )
235
-            );
236
-        }
237
-    }
238
-
239
-
240
-
241
-    /**
242
-     * @return void
243
-     */
244
-    private function addEventsEditCurrentEvent()
245
-    {
246
-        if (is_single() && (get_post_type() === 'espresso_events')) {
247
-            //Current post
248
-            global $post;
249
-            if (
250
-                $this->capabilities->current_user_can(
251
-                    'ee_edit_event',
252
-                    'ee_admin_bar_menu_espresso-toolbar-events-edit', $post->ID
253
-                )
254
-            ) {
255
-                $this->admin_bar->add_menu(
256
-                    array(
257
-                        'id'     => 'espresso-toolbar-events-edit',
258
-                        'parent' => 'espresso-toolbar-events',
259
-                        'title'  => '<span class="ee-toolbar-icon"></span>'
260
-                                    . esc_html__('Edit Event', 'event_espresso'),
261
-                        'href'   => EEH_URL::add_query_args_and_nonce(
262
-                            array(
263
-                                'action' => 'edit',
264
-                                'post' => $post->ID
265
-                            ),
266
-                            $this->events_admin_url
267
-                        ),
268
-                        'meta'   => array(
269
-                            'title'  => esc_html__('Edit Event', 'event_espresso'),
270
-                            'target' => '',
271
-                            'class'  => $this->menu_class,
272
-                        ),
273
-                    )
274
-                );
275
-            }
276
-        }
277
-    }
278
-
279
-
280
-
281
-    /**
282
-     * @return void
283
-     */
284
-    private function addEventsViewHeader()
285
-    {
286
-        if (
287
-            $this->capabilities->current_user_can(
288
-                'ee_read_events',
289
-                'ee_admin_bar_menu_espresso-toolbar-events-view'
290
-            )
291
-        ) {
292
-            $this->admin_bar->add_menu(
293
-                array(
294
-                    'id'     => 'espresso-toolbar-events-view',
295
-                    'parent' => 'espresso-toolbar-events',
296
-                    'title'  => esc_html__('View', 'event_espresso'),
297
-                    'href'   => '',
298
-                )
299
-            );
300
-        }
301
-    }
302
-
303
-
304
-
305
-    /**
306
-     * @return void
307
-     */
308
-    private function addEventsViewAll()
309
-    {
310
-        if (
311
-            $this->capabilities->current_user_can(
312
-                'ee_read_events',
313
-                'ee_admin_bar_menu_espresso-toolbar-events-all'
314
-            )
315
-        ) {
316
-            $this->admin_bar->add_menu(
317
-                array(
318
-                    'id'     => 'espresso-toolbar-events-all',
319
-                    'parent' => 'espresso-toolbar-events',
320
-                    'title'  => '<span class="ee-toolbar-icon"></span>'
321
-                                . esc_html__('All', 'event_espresso'),
322
-                    'href'   => $this->events_admin_url,
323
-                    'meta'   => array(
324
-                        'title'  => esc_html__('All', 'event_espresso'),
325
-                        'target' => '',
326
-                        'class'  => $this->menu_class,
327
-                    ),
328
-                )
329
-            );
330
-        }
331
-    }
332
-
333
-
334
-
335
-    /**
336
-     * @return void
337
-     */
338
-    private function addEventsViewToday()
339
-    {
340
-        if (
341
-            $this->capabilities->current_user_can(
342
-                'ee_read_events',
343
-                'ee_admin_bar_menu_espresso-toolbar-events-today'
344
-            )
345
-        ) {
346
-            $this->admin_bar->add_menu(
347
-                array(
348
-                    'id'     => 'espresso-toolbar-events-today',
349
-                    'parent' => 'espresso-toolbar-events',
350
-                    'title'  => '<span class="ee-toolbar-icon"></span>'
351
-                                . esc_html__('Today', 'event_espresso'),
352
-                    'href'   => EEH_URL::add_query_args_and_nonce(
353
-                        array(
354
-                            'action' => 'default',
355
-                            'status' => 'today'
356
-                        ),
357
-                        $this->events_admin_url
358
-                    ),
359
-                    'meta'   => array(
360
-                        'title'  => esc_html__('Today', 'event_espresso'),
361
-                        'target' => '',
362
-                        'class'  => $this->menu_class,
363
-                    ),
364
-                )
365
-            );
366
-        }
367
-    }
368
-
369
-
370
-
371
-    /**
372
-     * @return void
373
-     */
374
-    private function addEventsViewThisMonth()
375
-    {
376
-        if (
377
-            $this->capabilities->current_user_can(
378
-                'ee_read_events',
379
-                'ee_admin_bar_menu_espresso-toolbar-events-month'
380
-            )
381
-        ) {
382
-            $this->admin_bar->add_menu(
383
-                array(
384
-                    'id'     => 'espresso-toolbar-events-month',
385
-                    'parent' => 'espresso-toolbar-events',
386
-                    'title'  => '<span class="ee-toolbar-icon"></span>'
387
-                                . esc_html__('This Month', 'event_espresso'),
388
-                    'href'   => EEH_URL::add_query_args_and_nonce(
389
-                        array(
390
-                            'action' => 'default',
391
-                            'status' => 'month'
392
-                        ),
393
-                        $this->events_admin_url
394
-                    ),
395
-                    'meta'   => array(
396
-                        'title'  => esc_html__('This Month', 'event_espresso'),
397
-                        'target' => '',
398
-                        'class'  => $this->menu_class,
399
-                    ),
400
-                )
401
-            );
402
-        }
403
-    }
404
-
405
-
406
-
407
-    /**
408
-     * @return void
409
-     */
410
-    private function addRegistrationSubMenu()
411
-    {
412
-        if (
413
-            $this->capabilities->current_user_can(
414
-                'ee_read_registrations',
415
-                'ee_admin_bar_menu_espresso-toolbar-registrations'
416
-            )
417
-        ) {
418
-            $this->admin_bar->add_menu(
419
-                array(
420
-                    'id'     => 'espresso-toolbar-registrations',
421
-                    'parent' => 'espresso-toolbar',
422
-                    'title'  => '<span class="ee-toolbar-icon"></span>'
423
-                                . esc_html__('Registrations', 'event_espresso'),
424
-                    'href'   => $this->reg_admin_url,
425
-                    'meta'   => array(
426
-                        'title'  => esc_html__('Registrations', 'event_espresso'),
427
-                        'target' => '',
428
-                        'class'  => $this->menu_class,
429
-                    ),
430
-                )
431
-            );
432
-        }
433
-    }
434
-
435
-
436
-
437
-    /**
438
-     * @return void
439
-     */
440
-    private function addRegistrationOverviewToday()
441
-    {
442
-        if (
443
-            $this->capabilities->current_user_can(
444
-                'ee_read_registrations',
445
-                'ee_admin_bar_menu_espresso-toolbar-registrations-today'
446
-            )
447
-        ) {
448
-            $this->admin_bar->add_menu(
449
-                array(
450
-                    'id'     => 'espresso-toolbar-registrations-today',
451
-                    'parent' => 'espresso-toolbar-registrations',
452
-                    'title'  => esc_html__('Today', 'event_espresso'),
453
-                    'href'   => '',
454
-                    'meta'   => array(
455
-                        'title'  => esc_html__('Today', 'event_espresso'),
456
-                        'target' => '',
457
-                        'class'  => $this->menu_class,
458
-                    ),
459
-                )
460
-            );
461
-        }
462
-    }
463
-
464
-
465
-
466
-    /**
467
-     * @return void
468
-     */
469
-    private function addRegistrationOverviewTodayApproved()
470
-    {
471
-        if (
472
-            $this->capabilities->current_user_can(
473
-                'ee_read_registrations',
474
-                'ee_admin_bar_menu_espresso-toolbar-registrations-today-approved'
475
-            )
476
-        ) {
477
-            $this->admin_bar->add_menu(
478
-                array(
479
-                    'id'     => 'espresso-toolbar-registrations-today-approved',
480
-                    'parent' => 'espresso-toolbar-registrations',
481
-                    'title'  => '<span class="ee-toolbar-icon"></span>'
482
-                                . esc_html__('Approved', 'event_espresso'),
483
-                    'href'   => EEH_URL::add_query_args_and_nonce(
484
-                        array(
485
-                            'action'      => 'default',
486
-                            'status'      => 'today',
487
-                            '_reg_status' => EEM_Registration::status_id_approved,
488
-                        ),
489
-                        $this->reg_admin_url
490
-                    ),
491
-                    'meta'   => array(
492
-                        'title'  => esc_html__('Approved', 'event_espresso'),
493
-                        'target' => '',
494
-                        'class'  => $this->menu_class . ' ee-toolbar-icon-approved',
495
-                    ),
496
-                )
497
-            );
498
-        }
499
-    }
500
-
501
-
502
-
503
-    /**
504
-     * @return void
505
-     */
506
-    private function addRegistrationOverviewTodayPendingPayment()
507
-    {
508
-        if (
509
-            $this->capabilities->current_user_can(
510
-                'ee_read_registrations',
511
-                'ee_admin_bar_menu_espresso-toolbar-registrations-today-pending'
512
-            )
513
-        ) {
514
-            $this->admin_bar->add_menu(
515
-                array(
516
-                    'id'     => 'espresso-toolbar-registrations-today-pending',
517
-                    'parent' => 'espresso-toolbar-registrations',
518
-                    'title'  => '<span class="ee-toolbar-icon"></span>'
519
-                                . esc_html__('Pending', 'event_espresso'),
520
-                    'href'   => EEH_URL::add_query_args_and_nonce(
521
-                        array(
522
-                            'action'     => 'default',
523
-                            'status'     => 'today',
524
-                            '_reg_status' => EEM_Registration::status_id_pending_payment,
525
-                        ),
526
-                        $this->reg_admin_url
527
-                    ),
528
-                    'meta'   => array(
529
-                        'title'  => esc_html__('Pending Payment', 'event_espresso'),
530
-                        'target' => '',
531
-                        'class'  => $this->menu_class . ' ee-toolbar-icon-pending',
532
-                    ),
533
-                )
534
-            );
535
-        }
536
-    }
537
-
538
-
539
-
540
-    /**
541
-     * @return void
542
-     */
543
-    private function addRegistrationOverviewTodayNotApproved()
544
-    {
545
-        if (
546
-            $this->capabilities->current_user_can(
547
-                'ee_read_registrations',
548
-                'ee_admin_bar_menu_espresso-toolbar-registrations-today-not-approved'
549
-            )
550
-        ) {
551
-            $this->admin_bar->add_menu(
552
-                array(
553
-                    'id'     => 'espresso-toolbar-registrations-today-not-approved',
554
-                    'parent' => 'espresso-toolbar-registrations',
555
-                    'title'  => '<span class="ee-toolbar-icon"></span>'
556
-                                . esc_html__('Not Approved', 'event_espresso'),
557
-                    'href'   => EEH_URL::add_query_args_and_nonce(
558
-                        array(
559
-                            'action'      => 'default',
560
-                            'status'      => 'today',
561
-                            '_reg_status' => EEM_Registration::status_id_not_approved,
562
-                        ),
563
-                        $this->reg_admin_url
564
-                    ),
565
-                    'meta'   => array(
566
-                        'title'  => esc_html__('Not Approved', 'event_espresso'),
567
-                        'target' => '',
568
-                        'class'  => $this->menu_class . ' ee-toolbar-icon-not-approved',
569
-                    ),
570
-                )
571
-            );
572
-        }
573
-    }
574
-
575
-
576
-
577
-    /**
578
-     * @return void
579
-     */
580
-    private function addRegistrationOverviewTodayCancelled()
581
-    {
582
-        if (
583
-            $this->capabilities->current_user_can(
584
-                'ee_read_registrations',
585
-                'ee_admin_bar_menu_espresso-toolbar-registrations-today-cancelled'
586
-            )
587
-        ) {
588
-            $this->admin_bar->add_menu(
589
-                array(
590
-                    'id'     => 'espresso-toolbar-registrations-today-cancelled',
591
-                    'parent' => 'espresso-toolbar-registrations',
592
-                    'title'  => '<span class="ee-toolbar-icon"></span>'
593
-                                . esc_html__('Cancelled', 'event_espresso'),
594
-                    'href'   => EEH_URL::add_query_args_and_nonce(
595
-                        array(
596
-                            'action'      => 'default',
597
-                            'status'      => 'today',
598
-                            '_reg_status' => EEM_Registration::status_id_cancelled,
599
-                        ),
600
-                        $this->reg_admin_url
601
-                    ),
602
-                    'meta'   => array(
603
-                        'title'  => esc_html__('Cancelled', 'event_espresso'),
604
-                        'target' => '',
605
-                        'class'  => $this->menu_class . ' ee-toolbar-icon-cancelled',
606
-                    ),
607
-                )
608
-            );
609
-        }
610
-    }
611
-
612
-
613
-
614
-    /**
615
-     * @return void
616
-     */
617
-    private function addRegistrationOverviewThisMonth()
618
-    {
619
-        if (
620
-            $this->capabilities->current_user_can(
621
-                'ee_read_registrations',
622
-                'ee_admin_bar_menu_espresso-toolbar-registrations-month'
623
-            )
624
-        ) {
625
-            $this->admin_bar->add_menu(
626
-                array(
627
-                    'id'     => 'espresso-toolbar-registrations-month',
628
-                    'parent' => 'espresso-toolbar-registrations',
629
-                    'title'  => esc_html__('This Month', 'event_espresso'),
630
-                    'href'   => '', //EEH_URL::add_query_args_and_nonce(
631
-                    //     array(
632
-                    //         'action' => 'default',
633
-                    //         'status' => 'month'
634
-                    //     ),
635
-                    //     $this->reg_admin_url
636
-                    // ),
637
-                    'meta'   => array(
638
-                        'title'  => esc_html__('This Month', 'event_espresso'),
639
-                        'target' => '',
640
-                        'class'  => $this->menu_class,
641
-                    ),
642
-                )
643
-            );
644
-        }
645
-    }
646
-
647
-
648
-
649
-    /**
650
-     * @return void
651
-     */
652
-    private function addRegistrationOverviewThisMonthApproved()
653
-    {
654
-        if (
655
-            $this->capabilities->current_user_can(
656
-                'ee_read_registrations',
657
-                'ee_admin_bar_menu_espresso-toolbar-registrations-month-approved'
658
-            )
659
-        ) {
660
-            $this->admin_bar->add_menu(
661
-                array(
662
-                    'id'     => 'espresso-toolbar-registrations-month-approved',
663
-                    'parent' => 'espresso-toolbar-registrations',
664
-                    'title'  => '<span class="ee-toolbar-icon"></span>'
665
-                                . esc_html__('Approved', 'event_espresso'),
666
-                    'href'   => EEH_URL::add_query_args_and_nonce(
667
-                        array(
668
-                            'action'      => 'default',
669
-                            'status'      => 'month',
670
-                            '_reg_status' => EEM_Registration::status_id_approved,
671
-                        ),
672
-                        $this->reg_admin_url
673
-                    ),
674
-                    'meta'   => array(
675
-                        'title'  => esc_html__('Approved', 'event_espresso'),
676
-                        'target' => '',
677
-                        'class'  => $this->menu_class . ' ee-toolbar-icon-approved',
678
-                    ),
679
-                )
680
-            );
681
-        }
682
-    }
683
-
684
-
685
-
686
-    /**
687
-     * @return void
688
-     */
689
-    private function addRegistrationOverviewThisMonthPending()
690
-    {
691
-        if (
692
-            $this->capabilities->current_user_can(
693
-                'ee_read_registrations',
694
-                'ee_admin_bar_menu_espresso-toolbar-registrations-month-pending'
695
-            )
696
-        ) {
697
-            $this->admin_bar->add_menu(
698
-                array(
699
-                    'id'     => 'espresso-toolbar-registrations-month-pending',
700
-                    'parent' => 'espresso-toolbar-registrations',
701
-                    'title'  => '<span class="ee-toolbar-icon"></span>'
702
-                                . esc_html__('Pending', 'event_espresso'),
703
-                    'href'   => EEH_URL::add_query_args_and_nonce(
704
-                        array(
705
-                            'action'      => 'default',
706
-                            'status'      => 'month',
707
-                            '_reg_status' => EEM_Registration::status_id_pending_payment,
708
-                        ),
709
-                        $this->reg_admin_url
710
-                    ),
711
-                    'meta'   => array(
712
-                        'title'  => esc_html__('Pending', 'event_espresso'),
713
-                        'target' => '',
714
-                        'class'  => $this->menu_class . ' ee-toolbar-icon-pending',
715
-                    ),
716
-                )
717
-            );
718
-        }
719
-    }
720
-
721
-
722
-
723
-    /**
724
-     * @return void
725
-     */
726
-    private function addRegistrationOverviewThisMonthNotApproved()
727
-    {
728
-        if (
729
-            $this->capabilities->current_user_can(
730
-                'ee_read_registrations',
731
-                'ee_admin_bar_menu_espresso-toolbar-registrations-month-not-approved'
732
-            )
733
-        ) {
734
-            $this->admin_bar->add_menu(
735
-                array(
736
-                    'id'     => 'espresso-toolbar-registrations-month-not-approved',
737
-                    'parent' => 'espresso-toolbar-registrations',
738
-                    'title'  => '<span class="ee-toolbar-icon"></span>'
739
-                                . esc_html__('Not Approved', 'event_espresso'),
740
-                    'href'   => EEH_URL::add_query_args_and_nonce(
741
-                        array(
742
-                            'action'      => 'default',
743
-                            'status'      => 'month',
744
-                            '_reg_status' => EEM_Registration::status_id_not_approved,
745
-                        ),
746
-                        $this->reg_admin_url
747
-                    ),
748
-                    'meta'   => array(
749
-                        'title'  => esc_html__('Not Approved', 'event_espresso'),
750
-                        'target' => '',
751
-                        'class'  => $this->menu_class . ' ee-toolbar-icon-not-approved',
752
-                    ),
753
-                )
754
-            );
755
-        }
756
-    }
757
-
758
-
759
-
760
-    /**
761
-     * @return void
762
-     */
763
-    private function addRegistrationOverviewThisMonthCancelled()
764
-    {
765
-        if (
766
-            $this->capabilities->current_user_can(
767
-                'ee_read_registrations',
768
-                'ee_admin_bar_menu_espresso-toolbar-registrations-month-cancelled'
769
-            )
770
-        ) {
771
-            $this->admin_bar->add_menu(
772
-                array(
773
-                    'id'     => 'espresso-toolbar-registrations-month-cancelled',
774
-                    'parent' => 'espresso-toolbar-registrations',
775
-                    'title'  => '<span class="ee-toolbar-icon"></span>'
776
-                                . esc_html__('Cancelled', 'event_espresso'),
777
-                    'href'   => EEH_URL::add_query_args_and_nonce(
778
-                        array(
779
-                            'action'      => 'default',
780
-                            'status'      => 'month',
781
-                            '_reg_status' => EEM_Registration::status_id_cancelled,
782
-                        ),
783
-                        $this->reg_admin_url
784
-                    ),
785
-                    'meta'   => array(
786
-                        'title'  => esc_html__('Cancelled', 'event_espresso'),
787
-                        'target' => '',
788
-                        'class'  => $this->menu_class . ' ee-toolbar-icon-cancelled',
789
-                    ),
790
-                )
791
-            );
792
-        }
793
-    }
794
-
795
-
796
-
797
-    /**
798
-     * @return void
799
-     */
800
-    private function addExtensionsAndServices()
801
-    {
802
-        if (
803
-            $this->capabilities->current_user_can(
804
-                'ee_read_ee',
805
-                'ee_admin_bar_menu_espresso-toolbar-extensions-and-services'
806
-            )
807
-        ) {
808
-            $this->admin_bar->add_menu(
809
-                array(
810
-                    'id'     => 'espresso-toolbar-extensions-and-services',
811
-                    'parent' => 'espresso-toolbar',
812
-                    'title'  => '<span class="ee-toolbar-icon"></span>'
813
-                                . esc_html__('Extensions & Services', 'event_espresso'),
814
-                    'href'   => admin_url('admin.php?page=espresso_packages'),
815
-                    'meta'   => array(
816
-                        'title'  => esc_html__('Extensions & Services', 'event_espresso'),
817
-                        'target' => '',
818
-                        'class'  => $this->menu_class,
819
-                    ),
820
-                )
821
-            );
822
-        }
823
-    }
25
+	/**
26
+	 * @var WP_Admin_Bar $admin_bar
27
+	 */
28
+	private $admin_bar;
29
+
30
+	/**
31
+	 * @var EE_Capabilities $capabilities
32
+	 */
33
+	private $capabilities;
34
+
35
+	/**
36
+	 * @var string $events_admin_url
37
+	 */
38
+	private $events_admin_url;
39
+
40
+	/**
41
+	 * @var string $menu_class
42
+	 */
43
+	private $menu_class = 'espresso_menu_item_class';
44
+
45
+	/**
46
+	 * @var string $reg_admin_url
47
+	 */
48
+	private $reg_admin_url;
49
+
50
+
51
+
52
+	/**
53
+	 * AdminToolBar constructor.
54
+	 *
55
+	 * @param EE_Capabilities $capabilities
56
+	 */
57
+	public function __construct(EE_Capabilities $capabilities)
58
+	{
59
+		$this->capabilities = $capabilities;
60
+		add_action('admin_bar_menu', array($this, 'espressoToolbarItems'), 100);
61
+		$this->enqueueAssets();
62
+	}
63
+
64
+
65
+
66
+	/**
67
+	 *    espresso_toolbar_items
68
+	 *
69
+	 * @access public
70
+	 * @param  WP_Admin_Bar $admin_bar
71
+	 * @return void
72
+	 */
73
+	public function espressoToolbarItems(WP_Admin_Bar $admin_bar)
74
+	{
75
+		// if its an AJAX request, or user is NOT an admin, or in full M-Mode
76
+		if (
77
+			defined('DOING_AJAX')
78
+			|| ! $this->capabilities->current_user_can('ee_read_ee', 'ee_admin_bar_menu_top_level')
79
+			|| EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance
80
+		) {
81
+			return;
82
+		}
83
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
84
+		$this->admin_bar = $admin_bar;
85
+		//we don't use the constants EVENTS_ADMIN_URL or REG_ADMIN_URL
86
+		//because they're only defined in each of their respective constructors
87
+		//and this might be a frontend request, in which case they aren't available
88
+		$this->events_admin_url = admin_url('admin.php?page=espresso_events');
89
+		$this->reg_admin_url = admin_url('admin.php?page=espresso_registrations');
90
+		// now let's add all of the menu items
91
+		$this->addTopLevelMenu();
92
+		$this->addEventsSubMenu();
93
+		$this->addEventsAddEditHeader();
94
+		$this->addEventsAddNew();
95
+		$this->addEventsEditCurrentEvent();
96
+		$this->addEventsViewHeader();
97
+		$this->addEventsViewAll();
98
+		$this->addEventsViewToday();
99
+		$this->addEventsViewThisMonth();
100
+		$this->addRegistrationSubMenu();
101
+		$this->addRegistrationOverviewToday();
102
+		$this->addRegistrationOverviewTodayApproved();
103
+		$this->addRegistrationOverviewTodayPendingPayment();
104
+		$this->addRegistrationOverviewTodayNotApproved();
105
+		$this->addRegistrationOverviewTodayCancelled();
106
+		$this->addRegistrationOverviewThisMonth();
107
+		$this->addRegistrationOverviewThisMonthApproved();
108
+		$this->addRegistrationOverviewThisMonthPending();
109
+		$this->addRegistrationOverviewThisMonthNotApproved();
110
+		$this->addRegistrationOverviewThisMonthCancelled();
111
+		$this->addExtensionsAndServices();
112
+	}
113
+
114
+
115
+
116
+	/**
117
+	 * @return void
118
+	 */
119
+	private function enqueueAssets()
120
+	{
121
+		wp_register_style(
122
+			'espresso-admin-toolbar',
123
+			EE_GLOBAL_ASSETS_URL . 'css/espresso-admin-toolbar.css',
124
+			array('dashicons'),
125
+			EVENT_ESPRESSO_VERSION
126
+		);
127
+		wp_enqueue_style('espresso-admin-toolbar');
128
+	}
129
+
130
+
131
+
132
+	/**
133
+	 * @return void
134
+	 */
135
+	private function addTopLevelMenu()
136
+	{
137
+		$this->admin_bar->add_menu(
138
+			array(
139
+				'id'    => 'espresso-toolbar',
140
+				'title' => '<span class="ee-icon ee-icon-ee-cup-thick ee-icon-size-20"></span><span class="ab-label">'
141
+					. esc_html_x('Event Espresso', 'admin bar menu group label', 'event_espresso')
142
+					. '</span>',
143
+				'href'  => $this->events_admin_url,
144
+				'meta'  => array(
145
+					'title' => esc_html__('Event Espresso', 'event_espresso'),
146
+					'class' => $this->menu_class . 'first',
147
+				),
148
+			)
149
+		);
150
+	}
151
+
152
+
153
+
154
+	/**
155
+	 * @return void
156
+	 */
157
+	private function addEventsSubMenu()
158
+	{
159
+		if (
160
+			$this->capabilities->current_user_can(
161
+				'ee_read_events',
162
+				'ee_admin_bar_menu_espresso-toolbar-events'
163
+			)
164
+		) {
165
+			$this->admin_bar->add_menu(
166
+				array(
167
+					'id'     => 'espresso-toolbar-events',
168
+					'parent' => 'espresso-toolbar',
169
+					'title'  => '<span class="ee-toolbar-icon"></span>'
170
+								. esc_html__('Events', 'event_espresso'),
171
+					'href'   => $this->events_admin_url,
172
+					'meta'   => array(
173
+						'title'  => esc_html__('Events', 'event_espresso'),
174
+						'target' => '',
175
+						'class'  => $this->menu_class,
176
+					),
177
+				)
178
+			);
179
+		}
180
+	}
181
+
182
+
183
+
184
+	/**
185
+	 * @return void
186
+	 */
187
+	private function addEventsAddEditHeader()
188
+	{
189
+		if (
190
+		$this->capabilities->current_user_can(
191
+			'ee_read_events',
192
+			'ee_admin_bar_menu_espresso-toolbar-events-view'
193
+		)
194
+		) {
195
+			$this->admin_bar->add_menu(
196
+				array(
197
+					'id'     => 'espresso-toolbar-events-add-edit',
198
+					'parent' => 'espresso-toolbar-events',
199
+					'title'  => esc_html__('Add / Edit', 'event_espresso'),
200
+					'href'   => '',
201
+				)
202
+			);
203
+		}
204
+	}
205
+
206
+
207
+
208
+	/**
209
+	 * @return void
210
+	 */
211
+	private function addEventsAddNew()
212
+	{
213
+		if (
214
+			$this->capabilities->current_user_can(
215
+				'ee_edit_events',
216
+				'ee_admin_bar_menu_espresso-toolbar-events-new'
217
+			)
218
+		) {
219
+			$this->admin_bar->add_menu(
220
+				array(
221
+					'id'     => 'espresso-toolbar-events-new',
222
+					'parent' => 'espresso-toolbar-events',
223
+					'title'  => '<span class="ee-toolbar-icon"></span>'
224
+								. esc_html__('Add New', 'event_espresso'),
225
+					'href'   => EEH_URL::add_query_args_and_nonce(
226
+						array('action' => 'create_new'),
227
+						$this->events_admin_url
228
+					),
229
+					'meta'   => array(
230
+						'title'  => esc_html__('Add New', 'event_espresso'),
231
+						'target' => '',
232
+						'class'  => $this->menu_class,
233
+					),
234
+				)
235
+			);
236
+		}
237
+	}
238
+
239
+
240
+
241
+	/**
242
+	 * @return void
243
+	 */
244
+	private function addEventsEditCurrentEvent()
245
+	{
246
+		if (is_single() && (get_post_type() === 'espresso_events')) {
247
+			//Current post
248
+			global $post;
249
+			if (
250
+				$this->capabilities->current_user_can(
251
+					'ee_edit_event',
252
+					'ee_admin_bar_menu_espresso-toolbar-events-edit', $post->ID
253
+				)
254
+			) {
255
+				$this->admin_bar->add_menu(
256
+					array(
257
+						'id'     => 'espresso-toolbar-events-edit',
258
+						'parent' => 'espresso-toolbar-events',
259
+						'title'  => '<span class="ee-toolbar-icon"></span>'
260
+									. esc_html__('Edit Event', 'event_espresso'),
261
+						'href'   => EEH_URL::add_query_args_and_nonce(
262
+							array(
263
+								'action' => 'edit',
264
+								'post' => $post->ID
265
+							),
266
+							$this->events_admin_url
267
+						),
268
+						'meta'   => array(
269
+							'title'  => esc_html__('Edit Event', 'event_espresso'),
270
+							'target' => '',
271
+							'class'  => $this->menu_class,
272
+						),
273
+					)
274
+				);
275
+			}
276
+		}
277
+	}
278
+
279
+
280
+
281
+	/**
282
+	 * @return void
283
+	 */
284
+	private function addEventsViewHeader()
285
+	{
286
+		if (
287
+			$this->capabilities->current_user_can(
288
+				'ee_read_events',
289
+				'ee_admin_bar_menu_espresso-toolbar-events-view'
290
+			)
291
+		) {
292
+			$this->admin_bar->add_menu(
293
+				array(
294
+					'id'     => 'espresso-toolbar-events-view',
295
+					'parent' => 'espresso-toolbar-events',
296
+					'title'  => esc_html__('View', 'event_espresso'),
297
+					'href'   => '',
298
+				)
299
+			);
300
+		}
301
+	}
302
+
303
+
304
+
305
+	/**
306
+	 * @return void
307
+	 */
308
+	private function addEventsViewAll()
309
+	{
310
+		if (
311
+			$this->capabilities->current_user_can(
312
+				'ee_read_events',
313
+				'ee_admin_bar_menu_espresso-toolbar-events-all'
314
+			)
315
+		) {
316
+			$this->admin_bar->add_menu(
317
+				array(
318
+					'id'     => 'espresso-toolbar-events-all',
319
+					'parent' => 'espresso-toolbar-events',
320
+					'title'  => '<span class="ee-toolbar-icon"></span>'
321
+								. esc_html__('All', 'event_espresso'),
322
+					'href'   => $this->events_admin_url,
323
+					'meta'   => array(
324
+						'title'  => esc_html__('All', 'event_espresso'),
325
+						'target' => '',
326
+						'class'  => $this->menu_class,
327
+					),
328
+				)
329
+			);
330
+		}
331
+	}
332
+
333
+
334
+
335
+	/**
336
+	 * @return void
337
+	 */
338
+	private function addEventsViewToday()
339
+	{
340
+		if (
341
+			$this->capabilities->current_user_can(
342
+				'ee_read_events',
343
+				'ee_admin_bar_menu_espresso-toolbar-events-today'
344
+			)
345
+		) {
346
+			$this->admin_bar->add_menu(
347
+				array(
348
+					'id'     => 'espresso-toolbar-events-today',
349
+					'parent' => 'espresso-toolbar-events',
350
+					'title'  => '<span class="ee-toolbar-icon"></span>'
351
+								. esc_html__('Today', 'event_espresso'),
352
+					'href'   => EEH_URL::add_query_args_and_nonce(
353
+						array(
354
+							'action' => 'default',
355
+							'status' => 'today'
356
+						),
357
+						$this->events_admin_url
358
+					),
359
+					'meta'   => array(
360
+						'title'  => esc_html__('Today', 'event_espresso'),
361
+						'target' => '',
362
+						'class'  => $this->menu_class,
363
+					),
364
+				)
365
+			);
366
+		}
367
+	}
368
+
369
+
370
+
371
+	/**
372
+	 * @return void
373
+	 */
374
+	private function addEventsViewThisMonth()
375
+	{
376
+		if (
377
+			$this->capabilities->current_user_can(
378
+				'ee_read_events',
379
+				'ee_admin_bar_menu_espresso-toolbar-events-month'
380
+			)
381
+		) {
382
+			$this->admin_bar->add_menu(
383
+				array(
384
+					'id'     => 'espresso-toolbar-events-month',
385
+					'parent' => 'espresso-toolbar-events',
386
+					'title'  => '<span class="ee-toolbar-icon"></span>'
387
+								. esc_html__('This Month', 'event_espresso'),
388
+					'href'   => EEH_URL::add_query_args_and_nonce(
389
+						array(
390
+							'action' => 'default',
391
+							'status' => 'month'
392
+						),
393
+						$this->events_admin_url
394
+					),
395
+					'meta'   => array(
396
+						'title'  => esc_html__('This Month', 'event_espresso'),
397
+						'target' => '',
398
+						'class'  => $this->menu_class,
399
+					),
400
+				)
401
+			);
402
+		}
403
+	}
404
+
405
+
406
+
407
+	/**
408
+	 * @return void
409
+	 */
410
+	private function addRegistrationSubMenu()
411
+	{
412
+		if (
413
+			$this->capabilities->current_user_can(
414
+				'ee_read_registrations',
415
+				'ee_admin_bar_menu_espresso-toolbar-registrations'
416
+			)
417
+		) {
418
+			$this->admin_bar->add_menu(
419
+				array(
420
+					'id'     => 'espresso-toolbar-registrations',
421
+					'parent' => 'espresso-toolbar',
422
+					'title'  => '<span class="ee-toolbar-icon"></span>'
423
+								. esc_html__('Registrations', 'event_espresso'),
424
+					'href'   => $this->reg_admin_url,
425
+					'meta'   => array(
426
+						'title'  => esc_html__('Registrations', 'event_espresso'),
427
+						'target' => '',
428
+						'class'  => $this->menu_class,
429
+					),
430
+				)
431
+			);
432
+		}
433
+	}
434
+
435
+
436
+
437
+	/**
438
+	 * @return void
439
+	 */
440
+	private function addRegistrationOverviewToday()
441
+	{
442
+		if (
443
+			$this->capabilities->current_user_can(
444
+				'ee_read_registrations',
445
+				'ee_admin_bar_menu_espresso-toolbar-registrations-today'
446
+			)
447
+		) {
448
+			$this->admin_bar->add_menu(
449
+				array(
450
+					'id'     => 'espresso-toolbar-registrations-today',
451
+					'parent' => 'espresso-toolbar-registrations',
452
+					'title'  => esc_html__('Today', 'event_espresso'),
453
+					'href'   => '',
454
+					'meta'   => array(
455
+						'title'  => esc_html__('Today', 'event_espresso'),
456
+						'target' => '',
457
+						'class'  => $this->menu_class,
458
+					),
459
+				)
460
+			);
461
+		}
462
+	}
463
+
464
+
465
+
466
+	/**
467
+	 * @return void
468
+	 */
469
+	private function addRegistrationOverviewTodayApproved()
470
+	{
471
+		if (
472
+			$this->capabilities->current_user_can(
473
+				'ee_read_registrations',
474
+				'ee_admin_bar_menu_espresso-toolbar-registrations-today-approved'
475
+			)
476
+		) {
477
+			$this->admin_bar->add_menu(
478
+				array(
479
+					'id'     => 'espresso-toolbar-registrations-today-approved',
480
+					'parent' => 'espresso-toolbar-registrations',
481
+					'title'  => '<span class="ee-toolbar-icon"></span>'
482
+								. esc_html__('Approved', 'event_espresso'),
483
+					'href'   => EEH_URL::add_query_args_and_nonce(
484
+						array(
485
+							'action'      => 'default',
486
+							'status'      => 'today',
487
+							'_reg_status' => EEM_Registration::status_id_approved,
488
+						),
489
+						$this->reg_admin_url
490
+					),
491
+					'meta'   => array(
492
+						'title'  => esc_html__('Approved', 'event_espresso'),
493
+						'target' => '',
494
+						'class'  => $this->menu_class . ' ee-toolbar-icon-approved',
495
+					),
496
+				)
497
+			);
498
+		}
499
+	}
500
+
501
+
502
+
503
+	/**
504
+	 * @return void
505
+	 */
506
+	private function addRegistrationOverviewTodayPendingPayment()
507
+	{
508
+		if (
509
+			$this->capabilities->current_user_can(
510
+				'ee_read_registrations',
511
+				'ee_admin_bar_menu_espresso-toolbar-registrations-today-pending'
512
+			)
513
+		) {
514
+			$this->admin_bar->add_menu(
515
+				array(
516
+					'id'     => 'espresso-toolbar-registrations-today-pending',
517
+					'parent' => 'espresso-toolbar-registrations',
518
+					'title'  => '<span class="ee-toolbar-icon"></span>'
519
+								. esc_html__('Pending', 'event_espresso'),
520
+					'href'   => EEH_URL::add_query_args_and_nonce(
521
+						array(
522
+							'action'     => 'default',
523
+							'status'     => 'today',
524
+							'_reg_status' => EEM_Registration::status_id_pending_payment,
525
+						),
526
+						$this->reg_admin_url
527
+					),
528
+					'meta'   => array(
529
+						'title'  => esc_html__('Pending Payment', 'event_espresso'),
530
+						'target' => '',
531
+						'class'  => $this->menu_class . ' ee-toolbar-icon-pending',
532
+					),
533
+				)
534
+			);
535
+		}
536
+	}
537
+
538
+
539
+
540
+	/**
541
+	 * @return void
542
+	 */
543
+	private function addRegistrationOverviewTodayNotApproved()
544
+	{
545
+		if (
546
+			$this->capabilities->current_user_can(
547
+				'ee_read_registrations',
548
+				'ee_admin_bar_menu_espresso-toolbar-registrations-today-not-approved'
549
+			)
550
+		) {
551
+			$this->admin_bar->add_menu(
552
+				array(
553
+					'id'     => 'espresso-toolbar-registrations-today-not-approved',
554
+					'parent' => 'espresso-toolbar-registrations',
555
+					'title'  => '<span class="ee-toolbar-icon"></span>'
556
+								. esc_html__('Not Approved', 'event_espresso'),
557
+					'href'   => EEH_URL::add_query_args_and_nonce(
558
+						array(
559
+							'action'      => 'default',
560
+							'status'      => 'today',
561
+							'_reg_status' => EEM_Registration::status_id_not_approved,
562
+						),
563
+						$this->reg_admin_url
564
+					),
565
+					'meta'   => array(
566
+						'title'  => esc_html__('Not Approved', 'event_espresso'),
567
+						'target' => '',
568
+						'class'  => $this->menu_class . ' ee-toolbar-icon-not-approved',
569
+					),
570
+				)
571
+			);
572
+		}
573
+	}
574
+
575
+
576
+
577
+	/**
578
+	 * @return void
579
+	 */
580
+	private function addRegistrationOverviewTodayCancelled()
581
+	{
582
+		if (
583
+			$this->capabilities->current_user_can(
584
+				'ee_read_registrations',
585
+				'ee_admin_bar_menu_espresso-toolbar-registrations-today-cancelled'
586
+			)
587
+		) {
588
+			$this->admin_bar->add_menu(
589
+				array(
590
+					'id'     => 'espresso-toolbar-registrations-today-cancelled',
591
+					'parent' => 'espresso-toolbar-registrations',
592
+					'title'  => '<span class="ee-toolbar-icon"></span>'
593
+								. esc_html__('Cancelled', 'event_espresso'),
594
+					'href'   => EEH_URL::add_query_args_and_nonce(
595
+						array(
596
+							'action'      => 'default',
597
+							'status'      => 'today',
598
+							'_reg_status' => EEM_Registration::status_id_cancelled,
599
+						),
600
+						$this->reg_admin_url
601
+					),
602
+					'meta'   => array(
603
+						'title'  => esc_html__('Cancelled', 'event_espresso'),
604
+						'target' => '',
605
+						'class'  => $this->menu_class . ' ee-toolbar-icon-cancelled',
606
+					),
607
+				)
608
+			);
609
+		}
610
+	}
611
+
612
+
613
+
614
+	/**
615
+	 * @return void
616
+	 */
617
+	private function addRegistrationOverviewThisMonth()
618
+	{
619
+		if (
620
+			$this->capabilities->current_user_can(
621
+				'ee_read_registrations',
622
+				'ee_admin_bar_menu_espresso-toolbar-registrations-month'
623
+			)
624
+		) {
625
+			$this->admin_bar->add_menu(
626
+				array(
627
+					'id'     => 'espresso-toolbar-registrations-month',
628
+					'parent' => 'espresso-toolbar-registrations',
629
+					'title'  => esc_html__('This Month', 'event_espresso'),
630
+					'href'   => '', //EEH_URL::add_query_args_and_nonce(
631
+					//     array(
632
+					//         'action' => 'default',
633
+					//         'status' => 'month'
634
+					//     ),
635
+					//     $this->reg_admin_url
636
+					// ),
637
+					'meta'   => array(
638
+						'title'  => esc_html__('This Month', 'event_espresso'),
639
+						'target' => '',
640
+						'class'  => $this->menu_class,
641
+					),
642
+				)
643
+			);
644
+		}
645
+	}
646
+
647
+
648
+
649
+	/**
650
+	 * @return void
651
+	 */
652
+	private function addRegistrationOverviewThisMonthApproved()
653
+	{
654
+		if (
655
+			$this->capabilities->current_user_can(
656
+				'ee_read_registrations',
657
+				'ee_admin_bar_menu_espresso-toolbar-registrations-month-approved'
658
+			)
659
+		) {
660
+			$this->admin_bar->add_menu(
661
+				array(
662
+					'id'     => 'espresso-toolbar-registrations-month-approved',
663
+					'parent' => 'espresso-toolbar-registrations',
664
+					'title'  => '<span class="ee-toolbar-icon"></span>'
665
+								. esc_html__('Approved', 'event_espresso'),
666
+					'href'   => EEH_URL::add_query_args_and_nonce(
667
+						array(
668
+							'action'      => 'default',
669
+							'status'      => 'month',
670
+							'_reg_status' => EEM_Registration::status_id_approved,
671
+						),
672
+						$this->reg_admin_url
673
+					),
674
+					'meta'   => array(
675
+						'title'  => esc_html__('Approved', 'event_espresso'),
676
+						'target' => '',
677
+						'class'  => $this->menu_class . ' ee-toolbar-icon-approved',
678
+					),
679
+				)
680
+			);
681
+		}
682
+	}
683
+
684
+
685
+
686
+	/**
687
+	 * @return void
688
+	 */
689
+	private function addRegistrationOverviewThisMonthPending()
690
+	{
691
+		if (
692
+			$this->capabilities->current_user_can(
693
+				'ee_read_registrations',
694
+				'ee_admin_bar_menu_espresso-toolbar-registrations-month-pending'
695
+			)
696
+		) {
697
+			$this->admin_bar->add_menu(
698
+				array(
699
+					'id'     => 'espresso-toolbar-registrations-month-pending',
700
+					'parent' => 'espresso-toolbar-registrations',
701
+					'title'  => '<span class="ee-toolbar-icon"></span>'
702
+								. esc_html__('Pending', 'event_espresso'),
703
+					'href'   => EEH_URL::add_query_args_and_nonce(
704
+						array(
705
+							'action'      => 'default',
706
+							'status'      => 'month',
707
+							'_reg_status' => EEM_Registration::status_id_pending_payment,
708
+						),
709
+						$this->reg_admin_url
710
+					),
711
+					'meta'   => array(
712
+						'title'  => esc_html__('Pending', 'event_espresso'),
713
+						'target' => '',
714
+						'class'  => $this->menu_class . ' ee-toolbar-icon-pending',
715
+					),
716
+				)
717
+			);
718
+		}
719
+	}
720
+
721
+
722
+
723
+	/**
724
+	 * @return void
725
+	 */
726
+	private function addRegistrationOverviewThisMonthNotApproved()
727
+	{
728
+		if (
729
+			$this->capabilities->current_user_can(
730
+				'ee_read_registrations',
731
+				'ee_admin_bar_menu_espresso-toolbar-registrations-month-not-approved'
732
+			)
733
+		) {
734
+			$this->admin_bar->add_menu(
735
+				array(
736
+					'id'     => 'espresso-toolbar-registrations-month-not-approved',
737
+					'parent' => 'espresso-toolbar-registrations',
738
+					'title'  => '<span class="ee-toolbar-icon"></span>'
739
+								. esc_html__('Not Approved', 'event_espresso'),
740
+					'href'   => EEH_URL::add_query_args_and_nonce(
741
+						array(
742
+							'action'      => 'default',
743
+							'status'      => 'month',
744
+							'_reg_status' => EEM_Registration::status_id_not_approved,
745
+						),
746
+						$this->reg_admin_url
747
+					),
748
+					'meta'   => array(
749
+						'title'  => esc_html__('Not Approved', 'event_espresso'),
750
+						'target' => '',
751
+						'class'  => $this->menu_class . ' ee-toolbar-icon-not-approved',
752
+					),
753
+				)
754
+			);
755
+		}
756
+	}
757
+
758
+
759
+
760
+	/**
761
+	 * @return void
762
+	 */
763
+	private function addRegistrationOverviewThisMonthCancelled()
764
+	{
765
+		if (
766
+			$this->capabilities->current_user_can(
767
+				'ee_read_registrations',
768
+				'ee_admin_bar_menu_espresso-toolbar-registrations-month-cancelled'
769
+			)
770
+		) {
771
+			$this->admin_bar->add_menu(
772
+				array(
773
+					'id'     => 'espresso-toolbar-registrations-month-cancelled',
774
+					'parent' => 'espresso-toolbar-registrations',
775
+					'title'  => '<span class="ee-toolbar-icon"></span>'
776
+								. esc_html__('Cancelled', 'event_espresso'),
777
+					'href'   => EEH_URL::add_query_args_and_nonce(
778
+						array(
779
+							'action'      => 'default',
780
+							'status'      => 'month',
781
+							'_reg_status' => EEM_Registration::status_id_cancelled,
782
+						),
783
+						$this->reg_admin_url
784
+					),
785
+					'meta'   => array(
786
+						'title'  => esc_html__('Cancelled', 'event_espresso'),
787
+						'target' => '',
788
+						'class'  => $this->menu_class . ' ee-toolbar-icon-cancelled',
789
+					),
790
+				)
791
+			);
792
+		}
793
+	}
794
+
795
+
796
+
797
+	/**
798
+	 * @return void
799
+	 */
800
+	private function addExtensionsAndServices()
801
+	{
802
+		if (
803
+			$this->capabilities->current_user_can(
804
+				'ee_read_ee',
805
+				'ee_admin_bar_menu_espresso-toolbar-extensions-and-services'
806
+			)
807
+		) {
808
+			$this->admin_bar->add_menu(
809
+				array(
810
+					'id'     => 'espresso-toolbar-extensions-and-services',
811
+					'parent' => 'espresso-toolbar',
812
+					'title'  => '<span class="ee-toolbar-icon"></span>'
813
+								. esc_html__('Extensions & Services', 'event_espresso'),
814
+					'href'   => admin_url('admin.php?page=espresso_packages'),
815
+					'meta'   => array(
816
+						'title'  => esc_html__('Extensions & Services', 'event_espresso'),
817
+						'target' => '',
818
+						'class'  => $this->menu_class,
819
+					),
820
+				)
821
+			);
822
+		}
823
+	}
824 824
 
825 825
 }
Please login to merge, or discard this patch.