Completed
Branch master (24c3eb)
by
unknown
34:49 queued 28:57
created
core/domain/services/cron/jobs/ExpiredTransactionCheck.php 1 patch
Indentation   +219 added lines, -219 removed lines patch added patch discarded remove patch
@@ -17,251 +17,251 @@
 block discarded – undo
17 17
 
18 18
 class ExpiredTransactionCheck extends CronJob
19 19
 {
20
-    private ?PaymentProcessor $payment_processor = null;
20
+	private ?PaymentProcessor $payment_processor = null;
21 21
 
22
-    private ?EE_Transaction_Processor $transaction_processor = null;
22
+	private ?EE_Transaction_Processor $transaction_processor = null;
23 23
 
24
-    /**
25
-     * array of TXN IDs
26
-     *
27
-     * @var array
28
-     */
29
-    protected array $expired_transactions = [];
24
+	/**
25
+	 * array of TXN IDs
26
+	 *
27
+	 * @var array
28
+	 */
29
+	protected array $expired_transactions = [];
30 30
 
31 31
 
32
-    private function loadTransactionProcessor()
33
-    {
34
-        $this->transaction_processor = $this->loader->getShared(EE_Transaction_Processor::class);
35
-    }
32
+	private function loadTransactionProcessor()
33
+	{
34
+		$this->transaction_processor = $this->loader->getShared(EE_Transaction_Processor::class);
35
+	}
36 36
 
37 37
 
38
-    private function loadPaymentProcessor()
39
-    {
40
-        $this->payment_processor = $this->loader->getShared(PaymentProcessor::class);
41
-    }
38
+	private function loadPaymentProcessor()
39
+	{
40
+		$this->payment_processor = $this->loader->getShared(PaymentProcessor::class);
41
+	}
42 42
 
43 43
 
44
-    public function setHooks(): void
45
-    {
46
-        add_action(
47
-            'AHEE__EE_Cron_Tasks__expired_transaction_check',
48
-            [$this, 'expiredTransactionCheck']
49
-        );
50
-    }
44
+	public function setHooks(): void
45
+	{
46
+		add_action(
47
+			'AHEE__EE_Cron_Tasks__expired_transaction_check',
48
+			[$this, 'expiredTransactionCheck']
49
+		);
50
+	}
51 51
 
52 52
 
53
-    /**
54
-     * schedule_expired_transaction_check
55
-     * sets a wp_schedule_single_event() for following up on TXNs after their session has expired
56
-     *
57
-     * @param int $timestamp
58
-     * @param int $TXN_ID
59
-     */
60
-    public static function scheduleExpiredTransactionCheck(
61
-        int $timestamp,
62
-        int $TXN_ID
63
-    ): void {
64
-        // validate $TXN_ID and $timestamp
65
-        $TXN_ID    = absint($TXN_ID);
66
-        $timestamp = absint($timestamp);
67
-        if ($TXN_ID && $timestamp) {
68
-            wp_schedule_single_event(
69
-                $timestamp,
70
-                'AHEE__EE_Cron_Tasks__expired_transaction_check',
71
-                [$TXN_ID]
72
-            );
73
-        }
74
-    }
53
+	/**
54
+	 * schedule_expired_transaction_check
55
+	 * sets a wp_schedule_single_event() for following up on TXNs after their session has expired
56
+	 *
57
+	 * @param int $timestamp
58
+	 * @param int $TXN_ID
59
+	 */
60
+	public static function scheduleExpiredTransactionCheck(
61
+		int $timestamp,
62
+		int $TXN_ID
63
+	): void {
64
+		// validate $TXN_ID and $timestamp
65
+		$TXN_ID    = absint($TXN_ID);
66
+		$timestamp = absint($timestamp);
67
+		if ($TXN_ID && $timestamp) {
68
+			wp_schedule_single_event(
69
+				$timestamp,
70
+				'AHEE__EE_Cron_Tasks__expired_transaction_check',
71
+				[$TXN_ID]
72
+			);
73
+		}
74
+	}
75 75
 
76 76
 
77
-    /**
78
-     * this is the callback for the action hook:
79
-     * 'AHEE__EE_Cron_Tasks__transaction_session_expiration_check'
80
-     * which is utilized by wp_schedule_single_event()
81
-     * in \EED_Single_Page_Checkout::_initialize_transaction().
82
-     * The passed TXN_ID gets added to an array, and then the
83
-     * process_expired_transactions() function is hooked into
84
-     * 'AHEE__EE_System__core_loaded_and_ready' which will actually handle the
85
-     * processing of any failed transactions, because doing so now would be
86
-     * too early and the required resources may not be available
87
-     *
88
-     * @param int $TXN_ID
89
-     */
90
-    public function expiredTransactionCheck(int $TXN_ID = 0): void
91
-    {
92
-        if (absint($TXN_ID)) {
93
-            $this->expired_transactions[ $TXN_ID ] = $TXN_ID;
94
-            add_action(
95
-                'shutdown',
96
-                [$this, 'processExpiredTransactions'],
97
-                5
98
-            );
99
-        }
100
-    }
77
+	/**
78
+	 * this is the callback for the action hook:
79
+	 * 'AHEE__EE_Cron_Tasks__transaction_session_expiration_check'
80
+	 * which is utilized by wp_schedule_single_event()
81
+	 * in \EED_Single_Page_Checkout::_initialize_transaction().
82
+	 * The passed TXN_ID gets added to an array, and then the
83
+	 * process_expired_transactions() function is hooked into
84
+	 * 'AHEE__EE_System__core_loaded_and_ready' which will actually handle the
85
+	 * processing of any failed transactions, because doing so now would be
86
+	 * too early and the required resources may not be available
87
+	 *
88
+	 * @param int $TXN_ID
89
+	 */
90
+	public function expiredTransactionCheck(int $TXN_ID = 0): void
91
+	{
92
+		if (absint($TXN_ID)) {
93
+			$this->expired_transactions[ $TXN_ID ] = $TXN_ID;
94
+			add_action(
95
+				'shutdown',
96
+				[$this, 'processExpiredTransactions'],
97
+				5
98
+			);
99
+		}
100
+	}
101 101
 
102 102
 
103
-    /**
104
-     * loops through the $this->expired_transactions array and processes any failed TXNs
105
-     *
106
-     * @throws EE_Error
107
-     * @throws ReflectionException
108
-     * @throws DomainException
109
-     * @throws RuntimeException
110
-     */
111
-    public function processExpiredTransactions(): void
112
-    {
113
-        if (
114
-            // are there any TXNs that need cleaning up ?
115
-            empty($this->expired_transactions)
116
-            // reschedule the cron if we can't hit the db right now
117
-            || CronUtilities::rescheduleCronForTransactions(
118
-                [ExpiredTransactionCheck::class, 'scheduleExpiredTransactionCheck'],
119
-                $this->expired_transactions
120
-            )
121
-        ) {
122
-            return;
123
-        }
124
-        $this->loadTransactionProcessor();
125
-        // set revisit flag for txn processor
126
-        $this->transaction_processor->set_revisit();
127
-        foreach ($this->expired_transactions as $TXN_ID) {
128
-            $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
129
-            // verify transaction and whether it is failed or not
130
-            if ($transaction instanceof EE_Transaction) {
131
-                switch ($transaction->status_ID()) {
132
-                    case EEM_Transaction::complete_status_code:
133
-                        $this->processCompletedTransaction($transaction);
134
-                        break;
103
+	/**
104
+	 * loops through the $this->expired_transactions array and processes any failed TXNs
105
+	 *
106
+	 * @throws EE_Error
107
+	 * @throws ReflectionException
108
+	 * @throws DomainException
109
+	 * @throws RuntimeException
110
+	 */
111
+	public function processExpiredTransactions(): void
112
+	{
113
+		if (
114
+			// are there any TXNs that need cleaning up ?
115
+			empty($this->expired_transactions)
116
+			// reschedule the cron if we can't hit the db right now
117
+			|| CronUtilities::rescheduleCronForTransactions(
118
+				[ExpiredTransactionCheck::class, 'scheduleExpiredTransactionCheck'],
119
+				$this->expired_transactions
120
+			)
121
+		) {
122
+			return;
123
+		}
124
+		$this->loadTransactionProcessor();
125
+		// set revisit flag for txn processor
126
+		$this->transaction_processor->set_revisit();
127
+		foreach ($this->expired_transactions as $TXN_ID) {
128
+			$transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
129
+			// verify transaction and whether it is failed or not
130
+			if ($transaction instanceof EE_Transaction) {
131
+				switch ($transaction->status_ID()) {
132
+					case EEM_Transaction::complete_status_code:
133
+						$this->processCompletedTransaction($transaction);
134
+						break;
135 135
 
136
-                    case EEM_Transaction::overpaid_status_code:
137
-                        $this->processOverpaidTransaction($transaction);
138
-                        break;
136
+					case EEM_Transaction::overpaid_status_code:
137
+						$this->processOverpaidTransaction($transaction);
138
+						break;
139 139
 
140
-                    case EEM_Transaction::incomplete_status_code:
141
-                        $this->processIncompletedTransaction($transaction);
142
-                        break;
140
+					case EEM_Transaction::incomplete_status_code:
141
+						$this->processIncompletedTransaction($transaction);
142
+						break;
143 143
 
144
-                    case EEM_Transaction::abandoned_status_code:
145
-                        $this->processAbandonedTransaction($transaction);
146
-                        break;
144
+					case EEM_Transaction::abandoned_status_code:
145
+						$this->processAbandonedTransaction($transaction);
146
+						break;
147 147
 
148
-                    case EEM_Transaction::failed_status_code:
149
-                        $this->processFailedTransaction($transaction);
150
-                        break;
151
-                }
152
-            }
153
-            unset($this->expired_transactions[ $TXN_ID ]);
154
-        }
155
-    }
148
+					case EEM_Transaction::failed_status_code:
149
+						$this->processFailedTransaction($transaction);
150
+						break;
151
+				}
152
+			}
153
+			unset($this->expired_transactions[ $TXN_ID ]);
154
+		}
155
+	}
156 156
 
157 157
 
158
-    /**
159
-     * @param EE_Transaction $transaction
160
-     * @return void
161
-     * @throws EE_Error
162
-     * @throws ReflectionException
163
-     */
164
-    private function processCompletedTransaction(EE_Transaction $transaction)
165
-    {
166
-        // Don't update the transaction/registrations if the Primary Registration is Not Approved.
167
-        $primary_registration = $transaction->primary_registration();
168
-        if (
169
-            $primary_registration instanceof EE_Registration
170
-            && $primary_registration->status_ID() !== RegStatus::AWAITING_REVIEW
171
-        ) {
172
-            $this->transaction_processor->update_transaction_and_registrations_after_checkout_or_payment(
173
-                $transaction,
174
-                $transaction->last_payment()
175
-            );
176
-            do_action(
177
-                'AHEE__EE_Cron_Tasks__process_expired_transactions__completed_transaction',
178
-                $transaction
179
-            );
180
-        }
181
-    }
158
+	/**
159
+	 * @param EE_Transaction $transaction
160
+	 * @return void
161
+	 * @throws EE_Error
162
+	 * @throws ReflectionException
163
+	 */
164
+	private function processCompletedTransaction(EE_Transaction $transaction)
165
+	{
166
+		// Don't update the transaction/registrations if the Primary Registration is Not Approved.
167
+		$primary_registration = $transaction->primary_registration();
168
+		if (
169
+			$primary_registration instanceof EE_Registration
170
+			&& $primary_registration->status_ID() !== RegStatus::AWAITING_REVIEW
171
+		) {
172
+			$this->transaction_processor->update_transaction_and_registrations_after_checkout_or_payment(
173
+				$transaction,
174
+				$transaction->last_payment()
175
+			);
176
+			do_action(
177
+				'AHEE__EE_Cron_Tasks__process_expired_transactions__completed_transaction',
178
+				$transaction
179
+			);
180
+		}
181
+	}
182 182
 
183 183
 
184
-    /**
185
-     * @param EE_Transaction $transaction
186
-     * @return void
187
-     */
188
-    private function processOverpaidTransaction(EE_Transaction $transaction)
189
-    {
190
-        do_action(
191
-            'AHEE__EE_Cron_Tasks__process_expired_transactions__overpaid_transaction',
192
-            $transaction
193
-        );
194
-    }
184
+	/**
185
+	 * @param EE_Transaction $transaction
186
+	 * @return void
187
+	 */
188
+	private function processOverpaidTransaction(EE_Transaction $transaction)
189
+	{
190
+		do_action(
191
+			'AHEE__EE_Cron_Tasks__process_expired_transactions__overpaid_transaction',
192
+			$transaction
193
+		);
194
+	}
195 195
 
196 196
 
197
-    /**
198
-     * @param EE_Transaction $transaction
199
-     * @return void
200
-     */
201
-    private function processIncompletedTransaction(EE_Transaction $transaction)
202
-    {
203
-        do_action(
204
-            'AHEE__EE_Cron_Tasks__process_expired_transactions__incomplete_transaction',
205
-            $transaction
206
-        );
207
-        // todo : move business logic into EE_Transaction_Processor for finalizing abandoned transactions
208
-    }
197
+	/**
198
+	 * @param EE_Transaction $transaction
199
+	 * @return void
200
+	 */
201
+	private function processIncompletedTransaction(EE_Transaction $transaction)
202
+	{
203
+		do_action(
204
+			'AHEE__EE_Cron_Tasks__process_expired_transactions__incomplete_transaction',
205
+			$transaction
206
+		);
207
+		// todo : move business logic into EE_Transaction_Processor for finalizing abandoned transactions
208
+	}
209 209
 
210 210
 
211
-    /**
212
-     * @param EE_Transaction $transaction
213
-     * @return void
214
-     * @throws EE_Error
215
-     * @throws ReflectionException
216
-     */
217
-    private function processAbandonedTransaction(EE_Transaction $transaction)
218
-    {
219
-        // run hook before updating transaction, primarily so
220
-        // EED_Ticket_Sales_Monitor::process_abandoned_transactions() can release reserved tickets
221
-        do_action(
222
-            'AHEE__EE_Cron_Tasks__process_expired_transactions__abandoned_transaction',
223
-            $transaction
224
-        );
225
-        // don't finalize the TXN if it has already been completed
226
-        if ($transaction->all_reg_steps_completed() !== true) {
227
-            $this->loadPaymentProcessor();
228
-            // let's simulate an IPN here which will trigger any notifications that need to go out
229
-            $this->payment_processor->updateTransactionBasedOnPayment(
230
-                $transaction,
231
-                $transaction->last_payment(),
232
-                true,
233
-                true
234
-            );
235
-        }
236
-    }
211
+	/**
212
+	 * @param EE_Transaction $transaction
213
+	 * @return void
214
+	 * @throws EE_Error
215
+	 * @throws ReflectionException
216
+	 */
217
+	private function processAbandonedTransaction(EE_Transaction $transaction)
218
+	{
219
+		// run hook before updating transaction, primarily so
220
+		// EED_Ticket_Sales_Monitor::process_abandoned_transactions() can release reserved tickets
221
+		do_action(
222
+			'AHEE__EE_Cron_Tasks__process_expired_transactions__abandoned_transaction',
223
+			$transaction
224
+		);
225
+		// don't finalize the TXN if it has already been completed
226
+		if ($transaction->all_reg_steps_completed() !== true) {
227
+			$this->loadPaymentProcessor();
228
+			// let's simulate an IPN here which will trigger any notifications that need to go out
229
+			$this->payment_processor->updateTransactionBasedOnPayment(
230
+				$transaction,
231
+				$transaction->last_payment(),
232
+				true,
233
+				true
234
+			);
235
+		}
236
+	}
237 237
 
238 238
 
239
-    /**
240
-     * @param EE_Transaction $transaction
241
-     * @return void
242
-     */
243
-    private function processFailedTransaction(EE_Transaction $transaction)
244
-    {
245
-        do_action(
246
-            'AHEE__EE_Cron_Tasks__process_expired_transactions__failed_transaction',
247
-            $transaction
248
-        );
249
-        // todo :
250
-        // perform garbage collection here and remove clean_out_junk_transactions()
251
-        // $registrations = $transaction->registrations();
252
-        // if (! empty($registrations)) {
253
-        //     foreach ($registrations as $registration) {
254
-        //         if ($registration instanceof EE_Registration) {
255
-        //             $delete_registration = true;
256
-        //             if ($registration->attendee() instanceof EE_Attendee) {
257
-        //                 $delete_registration = false;
258
-        //             }
259
-        //             if ($delete_registration) {
260
-        //                 $registration->delete_permanently();
261
-        //                 $registration->delete_related_permanently();
262
-        //             }
263
-        //         }
264
-        //     }
265
-        // }
266
-    }
239
+	/**
240
+	 * @param EE_Transaction $transaction
241
+	 * @return void
242
+	 */
243
+	private function processFailedTransaction(EE_Transaction $transaction)
244
+	{
245
+		do_action(
246
+			'AHEE__EE_Cron_Tasks__process_expired_transactions__failed_transaction',
247
+			$transaction
248
+		);
249
+		// todo :
250
+		// perform garbage collection here and remove clean_out_junk_transactions()
251
+		// $registrations = $transaction->registrations();
252
+		// if (! empty($registrations)) {
253
+		//     foreach ($registrations as $registration) {
254
+		//         if ($registration instanceof EE_Registration) {
255
+		//             $delete_registration = true;
256
+		//             if ($registration->attendee() instanceof EE_Attendee) {
257
+		//                 $delete_registration = false;
258
+		//             }
259
+		//             if ($delete_registration) {
260
+		//                 $registration->delete_permanently();
261
+		//                 $registration->delete_related_permanently();
262
+		//             }
263
+		//         }
264
+		//     }
265
+		// }
266
+	}
267 267
 }
Please login to merge, or discard this patch.
core/domain/services/capabilities/FeatureFlagsConfig.php 2 patches
Indentation   +167 added lines, -167 removed lines patch added patch discarded remove patch
@@ -17,171 +17,171 @@
 block discarded – undo
17 17
  */
18 18
 class FeatureFlagsConfig extends JsonDataWordpressOption
19 19
 {
20
-    /**
21
-     * WP option name for saving the Feature Flags configuration
22
-     */
23
-    private const OPTION_NAME = 'ee_feature_flags';
24
-
25
-    /**
26
-     * use FeatureFlag::USE_EVENT_EDITOR_BULK_EDIT instead
27
-     * this hasn't been deleted because it's used in the REM add-on
28
-     *
29
-     * @deprecated 5.0.18.p
30
-     */
31
-    public const  USE_EVENT_EDITOR_BULK_EDIT = FeatureFlag::USE_EVENT_EDITOR_BULK_EDIT;
32
-
33
-    private static array $removed = [
34
-        FeatureFlag::USE_ADVANCED_EVENT_EDITOR,
35
-    ];
36
-
37
-
38
-
39
-    protected Domain $domain;
40
-
41
-    private ?stdClass $feature_flags = null;
42
-
43
-
44
-    public function __construct(Domain $domain, JsonDataHandler $json_data_handler)
45
-    {
46
-        $this->domain = $domain;
47
-        parent::__construct($json_data_handler, FeatureFlagsConfig::OPTION_NAME, $this->getDefaultFeatureFlagOptions());
48
-    }
49
-
50
-
51
-    /**
52
-     * see the FeatureFlag::USE_* constants for descriptions of each feature flag and their default values
53
-     *
54
-     * @return stdClass
55
-     */
56
-    public function getDefaultFeatureFlagOptions(): stdClass
57
-    {
58
-        return (object) [
59
-            FeatureFlag::USE_DATETIME_STATUS_CONTROLS  => false,
60
-            FeatureFlag::USE_DEFAULT_TICKET_MANAGER    => true,
61
-            FeatureFlag::USE_EDD_PLUGIN_LICENSING      => defined('EE_USE_EDD_PLUGIN_LICENSING')
62
-                                                            && EE_USE_EDD_PLUGIN_LICENSING,
63
-            FeatureFlag::USE_EVENT_DESCRIPTION_RTE     => false,
64
-            FeatureFlag::USE_EVENT_EDITOR_BULK_EDIT    => $this->domain->isCaffeinated()
65
-                                                            && ! $this->domain->isMultiSite(),
66
-            FeatureFlag::USE_EXPERIMENTAL_RTE          => false,
67
-            FeatureFlag::USE_PAYMENT_PROCESSOR_FEES    => true,
68
-            FeatureFlag::USE_REG_FORM_BUILDER          => false,
69
-            FeatureFlag::USE_REG_FORM_TICKET_QUESTIONS => false,
70
-            FeatureFlag::USE_REG_OPTIONS_META_BOX      => false,
71
-            FeatureFlag::USE_SPCO_FORM_REFACTOR        => false,
72
-        ];
73
-    }
74
-
75
-
76
-    /**
77
-     * feature flags that absolutely must be enabled/disabled based on hard-coded conditions
78
-     *
79
-     * @return stdClass
80
-     * @since 5.0.20.p
81
-     */
82
-    public function getOverrides(): stdClass
83
-    {
84
-        $overrides = [];
85
-        if (defined('EE_USE_EDD_PLUGIN_LICENSING')) {
86
-            $overrides[ FeatureFlag::USE_EDD_PLUGIN_LICENSING ] = EE_USE_EDD_PLUGIN_LICENSING;
87
-        }
88
-        return (object) $overrides;
89
-    }
90
-
91
-
92
-    /**
93
-     * @return stdClass
94
-     */
95
-    public function getFeatureFlags(): stdClass
96
-    {
97
-        if ($this->feature_flags) {
98
-            return $this->feature_flags;
99
-        }
100
-        $default_options     = $this->getDefaultFeatureFlagOptions();
101
-        $this->feature_flags = $this->getAll();
102
-        $overrides           = $this->getOverrides();
103
-        // ensure that all feature flags are set
104
-        foreach ($default_options as $key => $value) {
105
-            // if the feature flag is not set, use the default value
106
-            if (! isset($this->feature_flags->$key)) {
107
-                $this->feature_flags->$key = $value;
108
-            }
109
-            // ensure that all overrides are set
110
-            if (isset($overrides->$key)) {
111
-                $this->feature_flags->$key = $overrides->$key;
112
-            }
113
-        }
114
-        return $this->feature_flags;
115
-    }
116
-
117
-
118
-    public function saveFeatureFlagsConfig(?stdClass $feature_flags = null): int
119
-    {
120
-        $feature_flags = $feature_flags ?? $this->feature_flags;
121
-        foreach (FeatureFlagsConfig::$removed as $feature_flag) {
122
-            unset($feature_flags->{$feature_flag});
123
-        }
124
-        $this->feature_flags = $feature_flags;
125
-        return $this->updateOption($feature_flags);
126
-    }
127
-
128
-
129
-    /**
130
-     * enables a feature flag, ex:
131
-     * $this->enableFeatureFlag(FeatureFlag::USE_ADVANCED_EVENT_EDITOR);
132
-     *
133
-     * @param string $feature_flag the feature flag to enable. One of the FeatureFlag::USE_* constants
134
-     * @param bool   $add_if_missing
135
-     * @param bool   $save
136
-     * @return int
137
-     */
138
-    public function enableFeatureFlag(string $feature_flag, bool $add_if_missing = false, bool $save = true): int
139
-    {
140
-        if (! $this->feature_flags) {
141
-            $this->getFeatureFlags();
142
-        }
143
-        if (! property_exists($this->feature_flags, $feature_flag) && ! $add_if_missing) {
144
-            return WordPressOption::UPDATE_ERROR;
145
-        }
146
-        $this->feature_flags->{$feature_flag} = true;
147
-        // if feature flag is the advanced event editor bulk edit options
148
-        // then only enabled if the site is Caffeinated and not MultiSite
149
-        if ($feature_flag === FeatureFlag::USE_EVENT_EDITOR_BULK_EDIT) {
150
-            $this->feature_flags->{$feature_flag} = $this->domain->isCaffeinated() && ! $this->domain->isMultiSite();
151
-        }
152
-        if ($save) {
153
-            return $this->saveFeatureFlagsConfig($this->feature_flags);
154
-        }
155
-        return WordPressOption::UPDATE_NONE;
156
-    }
157
-
158
-
159
-    /**
160
-     * disables a feature flag, ex:
161
-     * $this->disableFeatureFlag(FeatureFlag::USE_ADVANCED_EVENT_EDITOR);
162
-     *
163
-     * @param string $feature_flag the feature flag to disable. One of the FeatureFlag::USE_* constants
164
-     * @param bool   $save
165
-     * @return int
166
-     */
167
-    public function disableFeatureFlag(string $feature_flag, bool $save = true): int
168
-    {
169
-        if (! $this->feature_flags) {
170
-            $this->getFeatureFlags();
171
-        }
172
-        if (! property_exists($this->feature_flags, $feature_flag)) {
173
-            return WordPressOption::UPDATE_ERROR;
174
-        }
175
-        $this->feature_flags->{$feature_flag} = false;
176
-        if ($save) {
177
-            return $this->saveFeatureFlagsConfig($this->feature_flags);
178
-        }
179
-        return WordPressOption::UPDATE_NONE;
180
-    }
181
-
182
-
183
-    public function getFeatureFlagsFormOptions(): ?array
184
-    {
185
-        return FeatureFlag::getFormOptions();
186
-    }
20
+	/**
21
+	 * WP option name for saving the Feature Flags configuration
22
+	 */
23
+	private const OPTION_NAME = 'ee_feature_flags';
24
+
25
+	/**
26
+	 * use FeatureFlag::USE_EVENT_EDITOR_BULK_EDIT instead
27
+	 * this hasn't been deleted because it's used in the REM add-on
28
+	 *
29
+	 * @deprecated 5.0.18.p
30
+	 */
31
+	public const  USE_EVENT_EDITOR_BULK_EDIT = FeatureFlag::USE_EVENT_EDITOR_BULK_EDIT;
32
+
33
+	private static array $removed = [
34
+		FeatureFlag::USE_ADVANCED_EVENT_EDITOR,
35
+	];
36
+
37
+
38
+
39
+	protected Domain $domain;
40
+
41
+	private ?stdClass $feature_flags = null;
42
+
43
+
44
+	public function __construct(Domain $domain, JsonDataHandler $json_data_handler)
45
+	{
46
+		$this->domain = $domain;
47
+		parent::__construct($json_data_handler, FeatureFlagsConfig::OPTION_NAME, $this->getDefaultFeatureFlagOptions());
48
+	}
49
+
50
+
51
+	/**
52
+	 * see the FeatureFlag::USE_* constants for descriptions of each feature flag and their default values
53
+	 *
54
+	 * @return stdClass
55
+	 */
56
+	public function getDefaultFeatureFlagOptions(): stdClass
57
+	{
58
+		return (object) [
59
+			FeatureFlag::USE_DATETIME_STATUS_CONTROLS  => false,
60
+			FeatureFlag::USE_DEFAULT_TICKET_MANAGER    => true,
61
+			FeatureFlag::USE_EDD_PLUGIN_LICENSING      => defined('EE_USE_EDD_PLUGIN_LICENSING')
62
+															&& EE_USE_EDD_PLUGIN_LICENSING,
63
+			FeatureFlag::USE_EVENT_DESCRIPTION_RTE     => false,
64
+			FeatureFlag::USE_EVENT_EDITOR_BULK_EDIT    => $this->domain->isCaffeinated()
65
+															&& ! $this->domain->isMultiSite(),
66
+			FeatureFlag::USE_EXPERIMENTAL_RTE          => false,
67
+			FeatureFlag::USE_PAYMENT_PROCESSOR_FEES    => true,
68
+			FeatureFlag::USE_REG_FORM_BUILDER          => false,
69
+			FeatureFlag::USE_REG_FORM_TICKET_QUESTIONS => false,
70
+			FeatureFlag::USE_REG_OPTIONS_META_BOX      => false,
71
+			FeatureFlag::USE_SPCO_FORM_REFACTOR        => false,
72
+		];
73
+	}
74
+
75
+
76
+	/**
77
+	 * feature flags that absolutely must be enabled/disabled based on hard-coded conditions
78
+	 *
79
+	 * @return stdClass
80
+	 * @since 5.0.20.p
81
+	 */
82
+	public function getOverrides(): stdClass
83
+	{
84
+		$overrides = [];
85
+		if (defined('EE_USE_EDD_PLUGIN_LICENSING')) {
86
+			$overrides[ FeatureFlag::USE_EDD_PLUGIN_LICENSING ] = EE_USE_EDD_PLUGIN_LICENSING;
87
+		}
88
+		return (object) $overrides;
89
+	}
90
+
91
+
92
+	/**
93
+	 * @return stdClass
94
+	 */
95
+	public function getFeatureFlags(): stdClass
96
+	{
97
+		if ($this->feature_flags) {
98
+			return $this->feature_flags;
99
+		}
100
+		$default_options     = $this->getDefaultFeatureFlagOptions();
101
+		$this->feature_flags = $this->getAll();
102
+		$overrides           = $this->getOverrides();
103
+		// ensure that all feature flags are set
104
+		foreach ($default_options as $key => $value) {
105
+			// if the feature flag is not set, use the default value
106
+			if (! isset($this->feature_flags->$key)) {
107
+				$this->feature_flags->$key = $value;
108
+			}
109
+			// ensure that all overrides are set
110
+			if (isset($overrides->$key)) {
111
+				$this->feature_flags->$key = $overrides->$key;
112
+			}
113
+		}
114
+		return $this->feature_flags;
115
+	}
116
+
117
+
118
+	public function saveFeatureFlagsConfig(?stdClass $feature_flags = null): int
119
+	{
120
+		$feature_flags = $feature_flags ?? $this->feature_flags;
121
+		foreach (FeatureFlagsConfig::$removed as $feature_flag) {
122
+			unset($feature_flags->{$feature_flag});
123
+		}
124
+		$this->feature_flags = $feature_flags;
125
+		return $this->updateOption($feature_flags);
126
+	}
127
+
128
+
129
+	/**
130
+	 * enables a feature flag, ex:
131
+	 * $this->enableFeatureFlag(FeatureFlag::USE_ADVANCED_EVENT_EDITOR);
132
+	 *
133
+	 * @param string $feature_flag the feature flag to enable. One of the FeatureFlag::USE_* constants
134
+	 * @param bool   $add_if_missing
135
+	 * @param bool   $save
136
+	 * @return int
137
+	 */
138
+	public function enableFeatureFlag(string $feature_flag, bool $add_if_missing = false, bool $save = true): int
139
+	{
140
+		if (! $this->feature_flags) {
141
+			$this->getFeatureFlags();
142
+		}
143
+		if (! property_exists($this->feature_flags, $feature_flag) && ! $add_if_missing) {
144
+			return WordPressOption::UPDATE_ERROR;
145
+		}
146
+		$this->feature_flags->{$feature_flag} = true;
147
+		// if feature flag is the advanced event editor bulk edit options
148
+		// then only enabled if the site is Caffeinated and not MultiSite
149
+		if ($feature_flag === FeatureFlag::USE_EVENT_EDITOR_BULK_EDIT) {
150
+			$this->feature_flags->{$feature_flag} = $this->domain->isCaffeinated() && ! $this->domain->isMultiSite();
151
+		}
152
+		if ($save) {
153
+			return $this->saveFeatureFlagsConfig($this->feature_flags);
154
+		}
155
+		return WordPressOption::UPDATE_NONE;
156
+	}
157
+
158
+
159
+	/**
160
+	 * disables a feature flag, ex:
161
+	 * $this->disableFeatureFlag(FeatureFlag::USE_ADVANCED_EVENT_EDITOR);
162
+	 *
163
+	 * @param string $feature_flag the feature flag to disable. One of the FeatureFlag::USE_* constants
164
+	 * @param bool   $save
165
+	 * @return int
166
+	 */
167
+	public function disableFeatureFlag(string $feature_flag, bool $save = true): int
168
+	{
169
+		if (! $this->feature_flags) {
170
+			$this->getFeatureFlags();
171
+		}
172
+		if (! property_exists($this->feature_flags, $feature_flag)) {
173
+			return WordPressOption::UPDATE_ERROR;
174
+		}
175
+		$this->feature_flags->{$feature_flag} = false;
176
+		if ($save) {
177
+			return $this->saveFeatureFlagsConfig($this->feature_flags);
178
+		}
179
+		return WordPressOption::UPDATE_NONE;
180
+	}
181
+
182
+
183
+	public function getFeatureFlagsFormOptions(): ?array
184
+	{
185
+		return FeatureFlag::getFormOptions();
186
+	}
187 187
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
     {
84 84
         $overrides = [];
85 85
         if (defined('EE_USE_EDD_PLUGIN_LICENSING')) {
86
-            $overrides[ FeatureFlag::USE_EDD_PLUGIN_LICENSING ] = EE_USE_EDD_PLUGIN_LICENSING;
86
+            $overrides[FeatureFlag::USE_EDD_PLUGIN_LICENSING] = EE_USE_EDD_PLUGIN_LICENSING;
87 87
         }
88 88
         return (object) $overrides;
89 89
     }
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
         // ensure that all feature flags are set
104 104
         foreach ($default_options as $key => $value) {
105 105
             // if the feature flag is not set, use the default value
106
-            if (! isset($this->feature_flags->$key)) {
106
+            if ( ! isset($this->feature_flags->$key)) {
107 107
                 $this->feature_flags->$key = $value;
108 108
             }
109 109
             // ensure that all overrides are set
@@ -137,10 +137,10 @@  discard block
 block discarded – undo
137 137
      */
138 138
     public function enableFeatureFlag(string $feature_flag, bool $add_if_missing = false, bool $save = true): int
139 139
     {
140
-        if (! $this->feature_flags) {
140
+        if ( ! $this->feature_flags) {
141 141
             $this->getFeatureFlags();
142 142
         }
143
-        if (! property_exists($this->feature_flags, $feature_flag) && ! $add_if_missing) {
143
+        if ( ! property_exists($this->feature_flags, $feature_flag) && ! $add_if_missing) {
144 144
             return WordPressOption::UPDATE_ERROR;
145 145
         }
146 146
         $this->feature_flags->{$feature_flag} = true;
@@ -166,10 +166,10 @@  discard block
 block discarded – undo
166 166
      */
167 167
     public function disableFeatureFlag(string $feature_flag, bool $save = true): int
168 168
     {
169
-        if (! $this->feature_flags) {
169
+        if ( ! $this->feature_flags) {
170 170
             $this->getFeatureFlags();
171 171
         }
172
-        if (! property_exists($this->feature_flags, $feature_flag)) {
172
+        if ( ! property_exists($this->feature_flags, $feature_flag)) {
173 173
             return WordPressOption::UPDATE_ERROR;
174 174
         }
175 175
         $this->feature_flags->{$feature_flag} = false;
Please login to merge, or discard this patch.
core/domain/services/capabilities/FeatureFlags.php 1 patch
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -13,66 +13,66 @@
 block discarded – undo
13 13
  */
14 14
 class FeatureFlags
15 15
 {
16
-    private CapabilitiesChecker $capabilities_checker;
16
+	private CapabilitiesChecker $capabilities_checker;
17 17
 
18
-    protected FeatureFlagsConfig $option;
18
+	protected FeatureFlagsConfig $option;
19 19
 
20
-    /**
21
-     * array of key value pairs where the key is the feature flag in question
22
-     * and the value is either a boolean or a CapCheck object defining the required permissions
23
-     * example:
24
-     *       [
25
-     *          'use_bulk_edit' => true,
26
-     *          'use_death_ray' => new CapCheck( 'ee-death-ray-cap', 'context-desc' )
27
-     *      ]
28
-     * array is filterable via FHEE__EventEspresso_core_domain_services_capabilities_FeatureFlags
29
-     *
30
-     * @var boolean[]|CapCheck[]
31
-     */
32
-    private $feature_flags;
20
+	/**
21
+	 * array of key value pairs where the key is the feature flag in question
22
+	 * and the value is either a boolean or a CapCheck object defining the required permissions
23
+	 * example:
24
+	 *       [
25
+	 *          'use_bulk_edit' => true,
26
+	 *          'use_death_ray' => new CapCheck( 'ee-death-ray-cap', 'context-desc' )
27
+	 *      ]
28
+	 * array is filterable via FHEE__EventEspresso_core_domain_services_capabilities_FeatureFlags
29
+	 *
30
+	 * @var boolean[]|CapCheck[]
31
+	 */
32
+	private $feature_flags;
33 33
 
34 34
 
35
-    /**
36
-     * FeatureFlags constructor.
37
-     *
38
-     * @param CapabilitiesChecker $capabilities_checker
39
-     * @param FeatureFlagsConfig  $option
40
-     */
41
-    public function __construct(CapabilitiesChecker $capabilities_checker, FeatureFlagsConfig $option)
42
-    {
43
-        $this->capabilities_checker = $capabilities_checker;
44
-        $this->option = $option;
45
-        $this->feature_flags = apply_filters(
46
-            'FHEE__EventEspresso_core_domain_services_capabilities_FeatureFlags',
47
-            $this->option->getFeatureFlags()
48
-        );
49
-    }
35
+	/**
36
+	 * FeatureFlags constructor.
37
+	 *
38
+	 * @param CapabilitiesChecker $capabilities_checker
39
+	 * @param FeatureFlagsConfig  $option
40
+	 */
41
+	public function __construct(CapabilitiesChecker $capabilities_checker, FeatureFlagsConfig $option)
42
+	{
43
+		$this->capabilities_checker = $capabilities_checker;
44
+		$this->option = $option;
45
+		$this->feature_flags = apply_filters(
46
+			'FHEE__EventEspresso_core_domain_services_capabilities_FeatureFlags',
47
+			$this->option->getFeatureFlags()
48
+		);
49
+	}
50 50
 
51 51
 
52
-    /**
53
-     * @param string $feature
54
-     * @return bool
55
-     */
56
-    public function allowed(string $feature): bool
57
-    {
58
-        $flag = $this->feature_flags->{$feature} ?? false;
59
-        try {
60
-            return $flag instanceof CapCheck
61
-                ? $this->capabilities_checker->processCapCheck($flag)
62
-                : filter_var($flag, FILTER_VALIDATE_BOOLEAN);
63
-        } catch (InsufficientPermissionsException $e) {
64
-            // eat the exception
65
-        }
66
-        return false;
67
-    }
52
+	/**
53
+	 * @param string $feature
54
+	 * @return bool
55
+	 */
56
+	public function allowed(string $feature): bool
57
+	{
58
+		$flag = $this->feature_flags->{$feature} ?? false;
59
+		try {
60
+			return $flag instanceof CapCheck
61
+				? $this->capabilities_checker->processCapCheck($flag)
62
+				: filter_var($flag, FILTER_VALIDATE_BOOLEAN);
63
+		} catch (InsufficientPermissionsException $e) {
64
+			// eat the exception
65
+		}
66
+		return false;
67
+	}
68 68
 
69 69
 
70
-    /**
71
-     * @return array
72
-     */
73
-    public function getAllowedFeatures(): array
74
-    {
75
-        $allowed = array_filter((array) $this->feature_flags, [$this, 'allowed'], ARRAY_FILTER_USE_KEY);
76
-        return array_keys($allowed);
77
-    }
70
+	/**
71
+	 * @return array
72
+	 */
73
+	public function getAllowedFeatures(): array
74
+	{
75
+		$allowed = array_filter((array) $this->feature_flags, [$this, 'allowed'], ARRAY_FILTER_USE_KEY);
76
+		return array_keys($allowed);
77
+	}
78 78
 }
Please login to merge, or discard this patch.
core/domain/services/capabilities/FeatureFlag.php 1 patch
Indentation   +194 added lines, -194 removed lines patch added patch discarded remove patch
@@ -10,211 +10,211 @@
 block discarded – undo
10 10
  */
11 11
 class FeatureFlag
12 12
 {
13
-    /**
14
-     * Whether to use the New Event Editor (EDTR) or continue using the legacy Event Editor
15
-     * deafult: Enabled for Caffeinated sites, disabled for Decaf or Multisite installs
16
-     */
17
-    public const  USE_ADVANCED_EVENT_EDITOR = 'ee_advanced_event_editor';
13
+	/**
14
+	 * Whether to use the New Event Editor (EDTR) or continue using the legacy Event Editor
15
+	 * deafult: Enabled for Caffeinated sites, disabled for Decaf or Multisite installs
16
+	 */
17
+	public const  USE_ADVANCED_EVENT_EDITOR = 'ee_advanced_event_editor';
18 18
 
19
-    /**
20
-     * Whether to enable the Bulk Edit feature in the Advanced Event Editor (EDTR)
21
-     * default: Enabled for Caffeinated sites, disabled for Decaf or Multisite installs
22
-     */
23
-    public const  USE_EVENT_EDITOR_BULK_EDIT = 'ee_event_editor_bulk_edit';
19
+	/**
20
+	 * Whether to enable the Bulk Edit feature in the Advanced Event Editor (EDTR)
21
+	 * default: Enabled for Caffeinated sites, disabled for Decaf or Multisite installs
22
+	 */
23
+	public const  USE_EVENT_EDITOR_BULK_EDIT = 'ee_event_editor_bulk_edit';
24 24
 
25
-    /**
26
-     * Whether to enable the new Default Ticket Manager in the EDTR
27
-     * default: Enabled
28
-     */
29
-    public const  USE_DEFAULT_TICKET_MANAGER = 'use_default_ticket_manager';
25
+	/**
26
+	 * Whether to enable the new Default Ticket Manager in the EDTR
27
+	 * default: Enabled
28
+	 */
29
+	public const  USE_DEFAULT_TICKET_MANAGER = 'use_default_ticket_manager';
30 30
 
31
-    /**
32
-     * Whether to enable the Rich Text Editor for the Event Description field in the EDTR or use tinymce
33
-     * default: Disabled
34
-     */
35
-    public const  USE_EVENT_DESCRIPTION_RTE = 'use_event_description_rte';
31
+	/**
32
+	 * Whether to enable the Rich Text Editor for the Event Description field in the EDTR or use tinymce
33
+	 * default: Disabled
34
+	 */
35
+	public const  USE_EVENT_DESCRIPTION_RTE = 'use_event_description_rte';
36 36
 
37
-    /**
38
-     * Whether to enable the Rich Text Editor for all other RTE fields in the EDTR
39
-     * default: Disabled
40
-     */
41
-    public const  USE_EXPERIMENTAL_RTE = 'use_experimental_rte';
37
+	/**
38
+	 * Whether to enable the Rich Text Editor for all other RTE fields in the EDTR
39
+	 * default: Disabled
40
+	 */
41
+	public const  USE_EXPERIMENTAL_RTE = 'use_experimental_rte';
42 42
 
43
-    /**
44
-     * Whether to enable the new Registration Form Builder in the EDTR
45
-     * or continue using the legacy Question Groups and Registration Form admin pages
46
-     * default: Disabled
47
-     */
48
-    public const  USE_REG_FORM_BUILDER = 'use_reg_form_builder';
43
+	/**
44
+	 * Whether to enable the new Registration Form Builder in the EDTR
45
+	 * or continue using the legacy Question Groups and Registration Form admin pages
46
+	 * default: Disabled
47
+	 */
48
+	public const  USE_REG_FORM_BUILDER = 'use_reg_form_builder';
49 49
 
50
-    /**
51
-     * Whether to enable the new Registration Options meta box in the EDTR
52
-     * or continue using the legacy Event Registration Options
53
-     * default: Disabled
54
-     */
55
-    public const  USE_REG_OPTIONS_META_BOX = 'use_reg_options_meta_box';
50
+	/**
51
+	 * Whether to enable the new Registration Options meta box in the EDTR
52
+	 * or continue using the legacy Event Registration Options
53
+	 * default: Disabled
54
+	 */
55
+	public const  USE_REG_OPTIONS_META_BOX = 'use_reg_options_meta_box';
56 56
 
57
-    /**
58
-     * Whether to enable the new Single Page Checkout form refactor changes
59
-     * default: Disabled
60
-     *
61
-     * @since 5.0.18.p
62
-     */
63
-    public const  USE_SPCO_FORM_REFACTOR = 'use_spco_form_refactor';
57
+	/**
58
+	 * Whether to enable the new Single Page Checkout form refactor changes
59
+	 * default: Disabled
60
+	 *
61
+	 * @since 5.0.18.p
62
+	 */
63
+	public const  USE_SPCO_FORM_REFACTOR = 'use_spco_form_refactor';
64 64
 
65
-    /**
66
-     * Whether to enable the new Reg Form Ticket Questions functionality
67
-     * default: Disabled
68
-     */
69
-    public const  USE_REG_FORM_TICKET_QUESTIONS = 'use_reg_form_ticket_questions';
65
+	/**
66
+	 * Whether to enable the new Reg Form Ticket Questions functionality
67
+	 * default: Disabled
68
+	 */
69
+	public const  USE_REG_FORM_TICKET_QUESTIONS = 'use_reg_form_ticket_questions';
70 70
 
71
-    /**
72
-     * Whether to use the EDD Plugin Licensing system to manage licenses for the EE plugins
73
-     * default: Disabled
74
-     */
75
-    public const USE_EDD_PLUGIN_LICENSING = 'use_edd_plugin_licensing';
71
+	/**
72
+	 * Whether to use the EDD Plugin Licensing system to manage licenses for the EE plugins
73
+	 * default: Disabled
74
+	 */
75
+	public const USE_EDD_PLUGIN_LICENSING = 'use_edd_plugin_licensing';
76 76
 
77
-    /**
78
-     * Whether to use the new Datetime Status Controls in the EDTR
79
-     * default: Disabled
80
-     */
81
-    public const USE_DATETIME_STATUS_CONTROLS = 'use_datetime_status_controls';
77
+	/**
78
+	 * Whether to use the new Datetime Status Controls in the EDTR
79
+	 * default: Disabled
80
+	 */
81
+	public const USE_DATETIME_STATUS_CONTROLS = 'use_datetime_status_controls';
82 82
 
83
-    /**
84
-     * Whether to apply Gateway Partner fees to transactions
85
-     * default: Disabled
86
-     */
87
-    public const USE_PAYMENT_PROCESSOR_FEES = 'use_payment_processor_fees';
83
+	/**
84
+	 * Whether to apply Gateway Partner fees to transactions
85
+	 * default: Disabled
86
+	 */
87
+	public const USE_PAYMENT_PROCESSOR_FEES = 'use_payment_processor_fees';
88 88
 
89 89
 
90
-    public static function getFormOptions(): array
91
-    {
92
-        return [
93
-            FeatureFlag::USE_EVENT_EDITOR_BULK_EDIT    => [
94
-                'name'            => esc_html__('Event Editor Bulk Edit', 'event_espresso'),
95
-                'html_label_text' => esc_html__('Use Event Editor Bulk Edit', 'event_espresso'),
96
-                'help_text'       => sprintf(
97
-                    esc_html__(
98
-                        'Whether to enable the Bulk Edit feature in the Advanced Event Editor (EDTR).%1$s%2$sPLEASE NOTE: Bulk Editing is ALWAYS enabled if the Recurring Events Manager add-on is active.%3$s%1$s default: Enabled for Caffeinated sites, disabled for Decaf or Multisite installs',
99
-                        'event_espresso'
100
-                    ),
101
-                    '<br/>',
102
-                    '<strong>',
103
-                    '</strong>'
104
-                ),
105
-                'overridden'      => false,
106
-                'overridden_by'   => '',
107
-            ],
108
-            FeatureFlag::USE_DEFAULT_TICKET_MANAGER    => [
109
-                'name'            => esc_html__('Default Ticket Manager', 'event_espresso'),
110
-                'html_label_text' => esc_html__('Use Default Ticket Manager', 'event_espresso'),
111
-                'help_text'       => esc_html__(
112
-                    'Whether to enable the new Default Ticket Manager in the EDTR. default: Enabled',
113
-                    'event_espresso'
114
-                ),
115
-                'overridden'      => false,
116
-                'overridden_by'   => '',
117
-            ],
118
-            FeatureFlag::USE_EVENT_DESCRIPTION_RTE     => [
119
-                'name'            => esc_html__('Event Description RTE', 'event_espresso'),
120
-                'html_label_text' => esc_html__('Use Rich Text Editor for Event Description', 'event_espresso'),
121
-                'help_text'       => esc_html__(
122
-                    'Whether to enable the Rich Text Editor for the Event Description field in the EDTR or use tinymce. default: Disabled',
123
-                    'event_espresso'
124
-                ),
125
-                'overridden'      => false,
126
-                'overridden_by'   => '',
127
-            ],
128
-            FeatureFlag::USE_EXPERIMENTAL_RTE          => [
129
-                'name'            => esc_html__('Rich Text Editor', 'event_espresso'),
130
-                'html_label_text' => esc_html__('Use Rich Text Editor for other RTE fields', 'event_espresso'),
131
-                'help_text'       => esc_html__(
132
-                    'Whether to enable the Rich Text Editor for all other RTE fields in the EDTR. default: Disabled',
133
-                    'event_espresso'
134
-                ),
135
-                'overridden'      => false,
136
-                'overridden_by'   => '',
137
-            ],
138
-            FeatureFlag::USE_REG_FORM_BUILDER          => [
139
-                'name'            => esc_html__('Registration Form Builder', 'event_espresso'),
140
-                'html_label_text' => esc_html__('Use Registration Form Builder', 'event_espresso'),
141
-                'help_text'       => esc_html__(
142
-                    'Whether to enable the new Registration Form Builder in the EDTR or continue using the legacy Question Groups and Registration Form admin pages. default: Disabled',
143
-                    'event_espresso'
144
-                ),
145
-                'overridden'      => false,
146
-                'overridden_by'   => '',
147
-            ],
148
-            FeatureFlag::USE_REG_OPTIONS_META_BOX      => [
149
-                'name'            => esc_html__('Registration Options', 'event_espresso'),
150
-                'html_label_text' => esc_html__('Use Registration Options', 'event_espresso'),
151
-                'help_text'       => esc_html__(
152
-                    'Whether to enable the new Registration Options meta box in the EDTR or continue using the legacy Event Registration Options. default: Disabled',
153
-                    'event_espresso'
154
-                ),
155
-                'overridden'      => false,
156
-                'overridden_by'   => '',
157
-            ],
158
-            FeatureFlag::USE_SPCO_FORM_REFACTOR        => [
159
-                'name'            => esc_html__('SPCO Form Refactor', 'event_espresso'),
160
-                'html_label_text' => esc_html__('Use SPCO Form Refactor', 'event_espresso'),
161
-                'help_text'       => esc_html__(
162
-                    'Whether to enable the new Single Page Checkout form refactor changes or continue using the legacy Single Page Checkout form. default: Disabled',
163
-                    'event_espresso'
164
-                ),
165
-                'overridden'      => false,
166
-                'overridden_by'   => '',
167
-            ],
168
-            FeatureFlag::USE_REG_FORM_TICKET_QUESTIONS => [
169
-                'name'            => esc_html__('Reg Form Ticket Questions', 'event_espresso'),
170
-                'html_label_text' => esc_html__('Use Reg Form Ticket Questions', 'event_espresso'),
171
-                'help_text'       => esc_html__(
172
-                    'Whether to enable the new Reg Form Ticket Questions functionality. default: Disabled',
173
-                    'event_espresso'
174
-                ),
175
-                'overridden'      => false,
176
-                'overridden_by'   => '',
177
-            ],
178
-            FeatureFlag::USE_EDD_PLUGIN_LICENSING      => [
179
-                'name'            => esc_html__('EDD Plugin Licensing', 'event_espresso'),
180
-                'html_label_text' => esc_html__('Use EDD Plugin Licensing', 'event_espresso'),
181
-                'help_text'       => esc_html__(
182
-                    'Whether to use the EDD Plugin Licensing system to manage licenses for the EE plugins. default: Disabled',
183
-                    'event_espresso'
184
-                ),
185
-                'overridden'      => defined('EE_USE_EDD_PLUGIN_LICENSING'),
186
-                'overridden_by'   => defined('EE_USE_EDD_PLUGIN_LICENSING')
187
-                    ? sprintf(
188
-                        esc_html__(
189
-                            '%1$sCurrently overriden by the %2$s constant in wp-config.php%3$s',
190
-                            'event_espresso'
191
-                        ),
192
-                        '<br><span class="ee-status--warning">',
193
-                        'EE_USE_EDD_PLUGIN_LICENSING',
194
-                        '</span>'
195
-                    )
196
-                    : '',
197
-            ],
198
-            FeatureFlag::USE_DATETIME_STATUS_CONTROLS  => [
199
-                'name'            => esc_html__('Datetime Status Controls', 'event_espresso'),
200
-                'html_label_text' => esc_html__('Use Datetime Status Controls', 'event_espresso'),
201
-                'help_text'       => esc_html__(
202
-                    'Whether to use the new Datetime Status Controls in the EDTR. default: Disabled',
203
-                    'event_espresso'
204
-                ),
205
-                'overridden'      => false,
206
-                'overridden_by'   => '',
207
-            ],
208
-            FeatureFlag::USE_PAYMENT_PROCESSOR_FEES    => [
209
-                'name'            => esc_html__('Gateway Partner Fees', 'event_espresso'),
210
-                'html_label_text' => esc_html__('Apply Payment Processor Fees', 'event_espresso'),
211
-                'help_text'       => esc_html__(
212
-                    'Whether to apply Gateway Partner fees to transactions. default: Disabled',
213
-                    'event_espresso'
214
-                ),
215
-                'overridden'      => false,
216
-                'overridden_by'   => '',
217
-            ],
218
-        ];
219
-    }
90
+	public static function getFormOptions(): array
91
+	{
92
+		return [
93
+			FeatureFlag::USE_EVENT_EDITOR_BULK_EDIT    => [
94
+				'name'            => esc_html__('Event Editor Bulk Edit', 'event_espresso'),
95
+				'html_label_text' => esc_html__('Use Event Editor Bulk Edit', 'event_espresso'),
96
+				'help_text'       => sprintf(
97
+					esc_html__(
98
+						'Whether to enable the Bulk Edit feature in the Advanced Event Editor (EDTR).%1$s%2$sPLEASE NOTE: Bulk Editing is ALWAYS enabled if the Recurring Events Manager add-on is active.%3$s%1$s default: Enabled for Caffeinated sites, disabled for Decaf or Multisite installs',
99
+						'event_espresso'
100
+					),
101
+					'<br/>',
102
+					'<strong>',
103
+					'</strong>'
104
+				),
105
+				'overridden'      => false,
106
+				'overridden_by'   => '',
107
+			],
108
+			FeatureFlag::USE_DEFAULT_TICKET_MANAGER    => [
109
+				'name'            => esc_html__('Default Ticket Manager', 'event_espresso'),
110
+				'html_label_text' => esc_html__('Use Default Ticket Manager', 'event_espresso'),
111
+				'help_text'       => esc_html__(
112
+					'Whether to enable the new Default Ticket Manager in the EDTR. default: Enabled',
113
+					'event_espresso'
114
+				),
115
+				'overridden'      => false,
116
+				'overridden_by'   => '',
117
+			],
118
+			FeatureFlag::USE_EVENT_DESCRIPTION_RTE     => [
119
+				'name'            => esc_html__('Event Description RTE', 'event_espresso'),
120
+				'html_label_text' => esc_html__('Use Rich Text Editor for Event Description', 'event_espresso'),
121
+				'help_text'       => esc_html__(
122
+					'Whether to enable the Rich Text Editor for the Event Description field in the EDTR or use tinymce. default: Disabled',
123
+					'event_espresso'
124
+				),
125
+				'overridden'      => false,
126
+				'overridden_by'   => '',
127
+			],
128
+			FeatureFlag::USE_EXPERIMENTAL_RTE          => [
129
+				'name'            => esc_html__('Rich Text Editor', 'event_espresso'),
130
+				'html_label_text' => esc_html__('Use Rich Text Editor for other RTE fields', 'event_espresso'),
131
+				'help_text'       => esc_html__(
132
+					'Whether to enable the Rich Text Editor for all other RTE fields in the EDTR. default: Disabled',
133
+					'event_espresso'
134
+				),
135
+				'overridden'      => false,
136
+				'overridden_by'   => '',
137
+			],
138
+			FeatureFlag::USE_REG_FORM_BUILDER          => [
139
+				'name'            => esc_html__('Registration Form Builder', 'event_espresso'),
140
+				'html_label_text' => esc_html__('Use Registration Form Builder', 'event_espresso'),
141
+				'help_text'       => esc_html__(
142
+					'Whether to enable the new Registration Form Builder in the EDTR or continue using the legacy Question Groups and Registration Form admin pages. default: Disabled',
143
+					'event_espresso'
144
+				),
145
+				'overridden'      => false,
146
+				'overridden_by'   => '',
147
+			],
148
+			FeatureFlag::USE_REG_OPTIONS_META_BOX      => [
149
+				'name'            => esc_html__('Registration Options', 'event_espresso'),
150
+				'html_label_text' => esc_html__('Use Registration Options', 'event_espresso'),
151
+				'help_text'       => esc_html__(
152
+					'Whether to enable the new Registration Options meta box in the EDTR or continue using the legacy Event Registration Options. default: Disabled',
153
+					'event_espresso'
154
+				),
155
+				'overridden'      => false,
156
+				'overridden_by'   => '',
157
+			],
158
+			FeatureFlag::USE_SPCO_FORM_REFACTOR        => [
159
+				'name'            => esc_html__('SPCO Form Refactor', 'event_espresso'),
160
+				'html_label_text' => esc_html__('Use SPCO Form Refactor', 'event_espresso'),
161
+				'help_text'       => esc_html__(
162
+					'Whether to enable the new Single Page Checkout form refactor changes or continue using the legacy Single Page Checkout form. default: Disabled',
163
+					'event_espresso'
164
+				),
165
+				'overridden'      => false,
166
+				'overridden_by'   => '',
167
+			],
168
+			FeatureFlag::USE_REG_FORM_TICKET_QUESTIONS => [
169
+				'name'            => esc_html__('Reg Form Ticket Questions', 'event_espresso'),
170
+				'html_label_text' => esc_html__('Use Reg Form Ticket Questions', 'event_espresso'),
171
+				'help_text'       => esc_html__(
172
+					'Whether to enable the new Reg Form Ticket Questions functionality. default: Disabled',
173
+					'event_espresso'
174
+				),
175
+				'overridden'      => false,
176
+				'overridden_by'   => '',
177
+			],
178
+			FeatureFlag::USE_EDD_PLUGIN_LICENSING      => [
179
+				'name'            => esc_html__('EDD Plugin Licensing', 'event_espresso'),
180
+				'html_label_text' => esc_html__('Use EDD Plugin Licensing', 'event_espresso'),
181
+				'help_text'       => esc_html__(
182
+					'Whether to use the EDD Plugin Licensing system to manage licenses for the EE plugins. default: Disabled',
183
+					'event_espresso'
184
+				),
185
+				'overridden'      => defined('EE_USE_EDD_PLUGIN_LICENSING'),
186
+				'overridden_by'   => defined('EE_USE_EDD_PLUGIN_LICENSING')
187
+					? sprintf(
188
+						esc_html__(
189
+							'%1$sCurrently overriden by the %2$s constant in wp-config.php%3$s',
190
+							'event_espresso'
191
+						),
192
+						'<br><span class="ee-status--warning">',
193
+						'EE_USE_EDD_PLUGIN_LICENSING',
194
+						'</span>'
195
+					)
196
+					: '',
197
+			],
198
+			FeatureFlag::USE_DATETIME_STATUS_CONTROLS  => [
199
+				'name'            => esc_html__('Datetime Status Controls', 'event_espresso'),
200
+				'html_label_text' => esc_html__('Use Datetime Status Controls', 'event_espresso'),
201
+				'help_text'       => esc_html__(
202
+					'Whether to use the new Datetime Status Controls in the EDTR. default: Disabled',
203
+					'event_espresso'
204
+				),
205
+				'overridden'      => false,
206
+				'overridden_by'   => '',
207
+			],
208
+			FeatureFlag::USE_PAYMENT_PROCESSOR_FEES    => [
209
+				'name'            => esc_html__('Gateway Partner Fees', 'event_espresso'),
210
+				'html_label_text' => esc_html__('Apply Payment Processor Fees', 'event_espresso'),
211
+				'help_text'       => esc_html__(
212
+					'Whether to apply Gateway Partner fees to transactions. default: Disabled',
213
+					'event_espresso'
214
+				),
215
+				'overridden'      => false,
216
+				'overridden_by'   => '',
217
+			],
218
+		];
219
+	}
220 220
 }
Please login to merge, or discard this patch.
core/domain/services/graphql/resolvers/FieldResolverV2.php 2 patches
Indentation   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -10,88 +10,88 @@
 block discarded – undo
10 10
 
11 11
 class FieldResolverV2 extends ResolverBase
12 12
 {
13
-    /**
14
-     * @var GraphQLFieldInterface[]
15
-     */
16
-    protected array $fields;
17
-
18
-    use StatelessResolver;
19
-
20
-    /**
21
-     * @param GraphQLFieldInterface[] $fields
22
-     */
23
-    public function __construct(array $fields)
24
-    {
25
-        $this->fields = $this->fieldsToArray($fields);
26
-    }
27
-
28
-    /**
29
-     * @param GraphQLFieldInterface[] $fields
30
-     */
31
-    protected function fieldsToArray(array $fields): array
32
-    {
33
-        $array = [];
34
-        foreach ($fields as $f) {
35
-            $array[ $f->name() ] = $f;
36
-        }
37
-        return $array;
38
-    }
39
-
40
-    public function resolve(
41
-        $source,
42
-        array $args,
43
-        AppContext $context,
44
-        ResolveInfo $info
45
-    ) {
46
-        $field = $this->findField($info);
47
-
48
-        if (! $field || ! $field->shouldResolve()) {
49
-            return null;
50
-        }
51
-
52
-        if ($field->hasInternalResolver()) {
53
-            return $field->resolve($source, $args, $context, $info);
54
-        }
55
-
56
-        if (! ($source instanceof EE_Base_Class)) {
57
-            return null;
58
-        }
59
-
60
-        if (! is_null($field->key())) {
61
-            return $field->mayBeFormatValue($source->{$field->key()}(), $source);
62
-        }
63
-
64
-        switch ($field->name()) {
65
-            case 'id':
66
-                return $this->resolveId($source);
67
-            case 'cacheId':
68
-                return $this->resolveCacheId($source);
69
-            case 'parent':
70
-                return $this->resolveParent($source);
71
-            case 'event':
72
-                return $this->resolveEvent($source, $context);
73
-            case 'wpUser':
74
-            case 'manager':
75
-                return $this->resolveWpUser($source, $context);
76
-            case 'userId';
77
-                return $this->resolveUserId($source);
78
-            case 'state':
79
-                return $this->resolveState($source);
80
-            case 'country':
81
-                return $this->resolveCountry($source);
82
-        }
83
-
84
-        return null;
85
-    }
86
-
87
-    protected function findField(ResolveInfo $info)
88
-    {
89
-        $key = $info->fieldName;
90
-
91
-        if (! isset($this->fields[ $key ])) {
92
-            return false;
93
-        }
94
-
95
-        return $this->fields[ $key ];
96
-    }
13
+	/**
14
+	 * @var GraphQLFieldInterface[]
15
+	 */
16
+	protected array $fields;
17
+
18
+	use StatelessResolver;
19
+
20
+	/**
21
+	 * @param GraphQLFieldInterface[] $fields
22
+	 */
23
+	public function __construct(array $fields)
24
+	{
25
+		$this->fields = $this->fieldsToArray($fields);
26
+	}
27
+
28
+	/**
29
+	 * @param GraphQLFieldInterface[] $fields
30
+	 */
31
+	protected function fieldsToArray(array $fields): array
32
+	{
33
+		$array = [];
34
+		foreach ($fields as $f) {
35
+			$array[ $f->name() ] = $f;
36
+		}
37
+		return $array;
38
+	}
39
+
40
+	public function resolve(
41
+		$source,
42
+		array $args,
43
+		AppContext $context,
44
+		ResolveInfo $info
45
+	) {
46
+		$field = $this->findField($info);
47
+
48
+		if (! $field || ! $field->shouldResolve()) {
49
+			return null;
50
+		}
51
+
52
+		if ($field->hasInternalResolver()) {
53
+			return $field->resolve($source, $args, $context, $info);
54
+		}
55
+
56
+		if (! ($source instanceof EE_Base_Class)) {
57
+			return null;
58
+		}
59
+
60
+		if (! is_null($field->key())) {
61
+			return $field->mayBeFormatValue($source->{$field->key()}(), $source);
62
+		}
63
+
64
+		switch ($field->name()) {
65
+			case 'id':
66
+				return $this->resolveId($source);
67
+			case 'cacheId':
68
+				return $this->resolveCacheId($source);
69
+			case 'parent':
70
+				return $this->resolveParent($source);
71
+			case 'event':
72
+				return $this->resolveEvent($source, $context);
73
+			case 'wpUser':
74
+			case 'manager':
75
+				return $this->resolveWpUser($source, $context);
76
+			case 'userId';
77
+				return $this->resolveUserId($source);
78
+			case 'state':
79
+				return $this->resolveState($source);
80
+			case 'country':
81
+				return $this->resolveCountry($source);
82
+		}
83
+
84
+		return null;
85
+	}
86
+
87
+	protected function findField(ResolveInfo $info)
88
+	{
89
+		$key = $info->fieldName;
90
+
91
+		if (! isset($this->fields[ $key ])) {
92
+			return false;
93
+		}
94
+
95
+		return $this->fields[ $key ];
96
+	}
97 97
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
     {
33 33
         $array = [];
34 34
         foreach ($fields as $f) {
35
-            $array[ $f->name() ] = $f;
35
+            $array[$f->name()] = $f;
36 36
         }
37 37
         return $array;
38 38
     }
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
     ) {
46 46
         $field = $this->findField($info);
47 47
 
48
-        if (! $field || ! $field->shouldResolve()) {
48
+        if ( ! $field || ! $field->shouldResolve()) {
49 49
             return null;
50 50
         }
51 51
 
@@ -53,11 +53,11 @@  discard block
 block discarded – undo
53 53
             return $field->resolve($source, $args, $context, $info);
54 54
         }
55 55
 
56
-        if (! ($source instanceof EE_Base_Class)) {
56
+        if ( ! ($source instanceof EE_Base_Class)) {
57 57
             return null;
58 58
         }
59 59
 
60
-        if (! is_null($field->key())) {
60
+        if ( ! is_null($field->key())) {
61 61
             return $field->mayBeFormatValue($source->{$field->key()}(), $source);
62 62
         }
63 63
 
@@ -88,10 +88,10 @@  discard block
 block discarded – undo
88 88
     {
89 89
         $key = $info->fieldName;
90 90
 
91
-        if (! isset($this->fields[ $key ])) {
91
+        if ( ! isset($this->fields[$key])) {
92 92
             return false;
93 93
         }
94 94
 
95
-        return $this->fields[ $key ];
95
+        return $this->fields[$key];
96 96
     }
97 97
 }
Please login to merge, or discard this patch.
core/domain/services/graphql/resolvers/StatelessResolver.php 2 patches
Indentation   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -17,107 +17,107 @@
 block discarded – undo
17 17
 
18 18
 trait StatelessResolver
19 19
 {
20
-    protected function resolveId(EE_Base_Class $source): string
21
-    {
22
-        if (method_exists($source, 'UUID') && is_callable([$source, 'UUID'])) {
23
-            return $source->UUID();
24
-        }
25
-
26
-        return Relay::toGlobalId($source->get_model()->item_name(), $source->ID());
27
-    }
28
-
29
-    protected function resolveCacheId(EE_Base_Class $source): string
30
-    {
31
-        $item_name = $source->get_model()->item_name();
32
-        $id = $source->ID();
33
-        // Since cacheId does not need to be globally unique
34
-        // $uniqid is sufficient, still adding the model name and ID
35
-        // may be we need/use them in future.
36
-        return uniqid("{$item_name}:{$id}:", true);
37
-    }
38
-
39
-    protected function resolveParent(EE_Base_Class $source): ?EE_Base_Class
40
-    {
41
-        return $source->get_model()->get_one_by_ID($source->parent());
42
-    }
43
-
44
-    protected function resolveEvent(EE_Base_Class $source, AppContext $context): ?Deferred
45
-    {
46
-        switch (true) {
47
-            case $source instanceof EE_Datetime:
48
-                $event = $source->event();
49
-                break;
50
-            case $source instanceof EE_Venue:
51
-            case $source instanceof EE_Ticket:
52
-                $event = $source->get_related_event();
53
-                break;
54
-            default:
55
-                $event = null;
56
-                break;
57
-        }
58
-
59
-        if (! ($event instanceof EE_Event)) {
20
+	protected function resolveId(EE_Base_Class $source): string
21
+	{
22
+		if (method_exists($source, 'UUID') && is_callable([$source, 'UUID'])) {
23
+			return $source->UUID();
24
+		}
25
+
26
+		return Relay::toGlobalId($source->get_model()->item_name(), $source->ID());
27
+	}
28
+
29
+	protected function resolveCacheId(EE_Base_Class $source): string
30
+	{
31
+		$item_name = $source->get_model()->item_name();
32
+		$id = $source->ID();
33
+		// Since cacheId does not need to be globally unique
34
+		// $uniqid is sufficient, still adding the model name and ID
35
+		// may be we need/use them in future.
36
+		return uniqid("{$item_name}:{$id}:", true);
37
+	}
38
+
39
+	protected function resolveParent(EE_Base_Class $source): ?EE_Base_Class
40
+	{
41
+		return $source->get_model()->get_one_by_ID($source->parent());
42
+	}
43
+
44
+	protected function resolveEvent(EE_Base_Class $source, AppContext $context): ?Deferred
45
+	{
46
+		switch (true) {
47
+			case $source instanceof EE_Datetime:
48
+				$event = $source->event();
49
+				break;
50
+			case $source instanceof EE_Venue:
51
+			case $source instanceof EE_Ticket:
52
+				$event = $source->get_related_event();
53
+				break;
54
+			default:
55
+				$event = null;
56
+				break;
57
+		}
58
+
59
+		if (! ($event instanceof EE_Event)) {
60 60
 return null;
61
-        }
61
+		}
62 62
 
63
-        return $context->get_loader('post')->load_deferred($event->ID());
64
-    }
63
+		return $context->get_loader('post')->load_deferred($event->ID());
64
+	}
65 65
 
66
-    protected function resolveWpUser(EE_Base_Class $source, AppContext $context): ?Deferred
67
-    {
68
-        $user_id = $source->wp_user();
66
+	protected function resolveWpUser(EE_Base_Class $source, AppContext $context): ?Deferred
67
+	{
68
+		$user_id = $source->wp_user();
69 69
 
70
-        if (! $user_id) {
71
-            return null;
72
-        }
70
+		if (! $user_id) {
71
+			return null;
72
+		}
73 73
 
74
-        return $context->get_loader('user')->load_deferred($user_id);
75
-    }
74
+		return $context->get_loader('user')->load_deferred($user_id);
75
+	}
76 76
 
77
-    protected function resolveUserId($source): ?string
78
-    {
79
-        $user_id = $source->wp_user();
77
+	protected function resolveUserId($source): ?string
78
+	{
79
+		$user_id = $source->wp_user();
80 80
 
81
-        if (! $user_id) {
82
-            return null;
83
-        }
81
+		if (! $user_id) {
82
+			return null;
83
+		}
84 84
 
85
-        return Relay::toGlobalId('user', $user_id);
86
-    }
85
+		return Relay::toGlobalId('user', $user_id);
86
+	}
87 87
 
88
-    protected function resolveState($source): ?EE_Base_Class
89
-    {
90
-        $state_id = null;
88
+	protected function resolveState($source): ?EE_Base_Class
89
+	{
90
+		$state_id = null;
91 91
 
92
-        if ($source instanceof EE_Attendee || $source instanceof EE_Venue) {
93
-            $state_id = $source->state_ID();
94
-        }
92
+		if ($source instanceof EE_Attendee || $source instanceof EE_Venue) {
93
+			$state_id = $source->state_ID();
94
+		}
95 95
 
96
-        if (! $state_id) {
97
-            return null;
98
-        }
96
+		if (! $state_id) {
97
+			return null;
98
+		}
99 99
 
100
-        return EEM_State::instance()->get_one_by_ID($state_id);
101
-    }
100
+		return EEM_State::instance()->get_one_by_ID($state_id);
101
+	}
102 102
 
103
-    protected function resolveCountry(EE_Base_Class $source): ?EE_Base_Class
104
-    {
105
-        $country_iso = null;
103
+	protected function resolveCountry(EE_Base_Class $source): ?EE_Base_Class
104
+	{
105
+		$country_iso = null;
106 106
 
107
-        switch (true) {
108
-            case $source instanceof EE_State:
109
-                $country_iso = $source->country_iso();
110
-                break;
111
-            case $source instanceof EE_Attendee:
112
-            case $source instanceof EE_Venue:
113
-                $country_iso = $source->country_ID();
114
-                break;
115
-        }
107
+		switch (true) {
108
+			case $source instanceof EE_State:
109
+				$country_iso = $source->country_iso();
110
+				break;
111
+			case $source instanceof EE_Attendee:
112
+			case $source instanceof EE_Venue:
113
+				$country_iso = $source->country_ID();
114
+				break;
115
+		}
116 116
 
117
-        if (! $country_iso) {
118
-            return null;
119
-        }
117
+		if (! $country_iso) {
118
+			return null;
119
+		}
120 120
 
121
-        return EEM_Country::instance()->get_one_by_ID($country_iso);
122
-    }
121
+		return EEM_Country::instance()->get_one_by_ID($country_iso);
122
+	}
123 123
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
                 break;
57 57
         }
58 58
 
59
-        if (! ($event instanceof EE_Event)) {
59
+        if ( ! ($event instanceof EE_Event)) {
60 60
 return null;
61 61
         }
62 62
 
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
     {
68 68
         $user_id = $source->wp_user();
69 69
 
70
-        if (! $user_id) {
70
+        if ( ! $user_id) {
71 71
             return null;
72 72
         }
73 73
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
     {
79 79
         $user_id = $source->wp_user();
80 80
 
81
-        if (! $user_id) {
81
+        if ( ! $user_id) {
82 82
             return null;
83 83
         }
84 84
 
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
             $state_id = $source->state_ID();
94 94
         }
95 95
 
96
-        if (! $state_id) {
96
+        if ( ! $state_id) {
97 97
             return null;
98 98
         }
99 99
 
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
                 break;
115 115
         }
116 116
 
117
-        if (! $country_iso) {
117
+        if ( ! $country_iso) {
118 118
             return null;
119 119
         }
120 120
 
Please login to merge, or discard this patch.
core/domain/services/wp_queries/EventListQuery.php 2 patches
Indentation   +179 added lines, -179 removed lines patch added patch discarded remove patch
@@ -16,183 +16,183 @@
 block discarded – undo
16 16
  */
17 17
 class EventListQuery extends WP_Query
18 18
 {
19
-    private ?string $title = '';
20
-
21
-    private int $limit = 10;
22
-
23
-    private ?string $css_class = '';
24
-
25
-    private bool $show_expired = false;
26
-
27
-    private ?string $month = '';
28
-
29
-    private ?string $category_slug = '';
30
-
31
-    /**
32
-     * @var array|string|null
33
-     */
34
-    private $order_by = [];
35
-
36
-    private ?string $sort = '';
37
-
38
-    private bool $show_title = true;
39
-
40
-
41
-    /**
42
-     * EE_Event_List_Query Constructor     *
43
-     *
44
-     * @param array $args
45
-     */
46
-    public function __construct($args = [])
47
-    {
48
-        $args = $this->parseArgs((array) $args);
49
-        $this->setupEventQueryHelper();
50
-        $this->setupFilters();
51
-        $args = $this->getQueryArgs($args);
52
-        // run the query
53
-        parent::__construct($args);
54
-    }
55
-
56
-
57
-    /**
58
-     * @param array $args
59
-     * @return array
60
-     */
61
-    private function parseArgs(array $args): array
62
-    {
63
-        // incoming args could be a mix of WP query args + EE shortcode args
64
-        foreach ($args as $property => $value) {
65
-            // if the arg is a property of this class, then it's an EE shortcode arg
66
-            if (property_exists($this, $property) && ! property_exists('WP_Query', $property)) {
67
-                // get the property type
68
-                $type = gettype($this->{$property});
69
-                // set the property value
70
-                switch ($type) {
71
-                    case 'integer':
72
-                        $this->{$property} = absint($value);
73
-                        break;
74
-                    case 'boolean':
75
-                        $this->{$property} = filter_var($value, FILTER_VALIDATE_BOOLEAN);
76
-                        break;
77
-                    case 'string':
78
-                        $this->{$property} = sanitize_text_field($value);
79
-                        break;
80
-                    default:
81
-                        $this->{$property} = $value;
82
-                        break;
83
-                }
84
-                // then remove it from the array of args that will later be passed to WP_Query()
85
-                unset($args[ $property ]);
86
-            }
87
-        }
88
-        return $args;
89
-    }
90
-
91
-
92
-    private function setupEventQueryHelper()
93
-    {
94
-        // add query filters
95
-        EEH_Event_Query::add_query_filters();
96
-        // set params that will get used by the filters
97
-        EEH_Event_Query::set_query_params(
98
-            $this->month,
99
-            $this->category_slug,
100
-            $this->show_expired,
101
-            $this->order_by,
102
-            $this->sort
103
-        );
104
-    }
105
-
106
-
107
-    private function setupFilters()
108
-    {
109
-        // first off, let's remove any filters from previous queries
110
-        remove_filter(
111
-            'FHEE__archive_espresso_events_template__show_header',
112
-            [$this, 'show_event_list_title']
113
-        );
114
-        remove_filter(
115
-            'FHEE__archive_espresso_events_template__upcoming_events_h1',
116
-            [$this, 'event_list_title']
117
-        );
118
-        remove_all_filters('FHEE__content_espresso_events__event_class');
119
-        // Event List Title ?
120
-        add_filter(
121
-            'FHEE__archive_espresso_events_template__show_header',
122
-            [$this, 'show_event_list_title']
123
-        );
124
-        add_filter(
125
-            'FHEE__archive_espresso_events_template__upcoming_events_h1',
126
-            [$this, 'event_list_title']
127
-        );
128
-        // add the css class
129
-        add_filter(
130
-            'FHEE__content_espresso_events__event_class',
131
-            [$this, 'event_list_css']
132
-        );
133
-    }
134
-
135
-
136
-    private function getQueryArgs(array $args): array
137
-    {
138
-        // the current "page" we are viewing
139
-        $paged = max(1, get_query_var('paged'));
140
-        // Force these args
141
-        return array_merge(
142
-            $args,
143
-            [
144
-                'post_type'              => EspressoPostType::EVENTS,
145
-                'posts_per_page'         => $this->limit,
146
-                'update_post_term_cache' => false,
147
-                'update_post_meta_cache' => false,
148
-                'paged'                  => $paged,
149
-                'offset'                 => ($paged - 1) * $this->limit,
150
-            ]
151
-        );
152
-    }
153
-
154
-    // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
155
-
156
-
157
-    /**
158
-     * show_event_list_title
159
-     *
160
-     * @return boolean
161
-     */
162
-    public function show_event_list_title(): bool
163
-    {
164
-        return filter_var($this->show_title, FILTER_VALIDATE_BOOLEAN);
165
-    }
166
-
167
-
168
-    /**
169
-     * callback for FHEE__archive_espresso_events_template__upcoming_events_h1 filter
170
-     *
171
-     * @param string $event_list_title
172
-     * @return    string
173
-     */
174
-    public function event_list_title(string $event_list_title = ''): string
175
-    {
176
-        if (! empty($this->title)) {
177
-            return $this->title;
178
-        }
179
-        return $event_list_title;
180
-    }
181
-
182
-
183
-    /**
184
-     * callback for FHEE__content_espresso_events__event_class filter
185
-     *
186
-     * @param string $event_list_css
187
-     * @return string
188
-     */
189
-    public function event_list_css(string $event_list_css = ''): string
190
-    {
191
-        $event_list_css .= ! empty($event_list_css) ? ' ' : '';
192
-        $event_list_css .= ! empty($this->css_class) ? $this->css_class : '';
193
-        $event_list_css .= ! empty($event_list_css) ? ' ' : '';
194
-        $event_list_css .= ! empty($this->category_slug) ? $this->category_slug : '';
195
-        return $event_list_css;
196
-    }
197
-    // phpcs:enable
19
+	private ?string $title = '';
20
+
21
+	private int $limit = 10;
22
+
23
+	private ?string $css_class = '';
24
+
25
+	private bool $show_expired = false;
26
+
27
+	private ?string $month = '';
28
+
29
+	private ?string $category_slug = '';
30
+
31
+	/**
32
+	 * @var array|string|null
33
+	 */
34
+	private $order_by = [];
35
+
36
+	private ?string $sort = '';
37
+
38
+	private bool $show_title = true;
39
+
40
+
41
+	/**
42
+	 * EE_Event_List_Query Constructor     *
43
+	 *
44
+	 * @param array $args
45
+	 */
46
+	public function __construct($args = [])
47
+	{
48
+		$args = $this->parseArgs((array) $args);
49
+		$this->setupEventQueryHelper();
50
+		$this->setupFilters();
51
+		$args = $this->getQueryArgs($args);
52
+		// run the query
53
+		parent::__construct($args);
54
+	}
55
+
56
+
57
+	/**
58
+	 * @param array $args
59
+	 * @return array
60
+	 */
61
+	private function parseArgs(array $args): array
62
+	{
63
+		// incoming args could be a mix of WP query args + EE shortcode args
64
+		foreach ($args as $property => $value) {
65
+			// if the arg is a property of this class, then it's an EE shortcode arg
66
+			if (property_exists($this, $property) && ! property_exists('WP_Query', $property)) {
67
+				// get the property type
68
+				$type = gettype($this->{$property});
69
+				// set the property value
70
+				switch ($type) {
71
+					case 'integer':
72
+						$this->{$property} = absint($value);
73
+						break;
74
+					case 'boolean':
75
+						$this->{$property} = filter_var($value, FILTER_VALIDATE_BOOLEAN);
76
+						break;
77
+					case 'string':
78
+						$this->{$property} = sanitize_text_field($value);
79
+						break;
80
+					default:
81
+						$this->{$property} = $value;
82
+						break;
83
+				}
84
+				// then remove it from the array of args that will later be passed to WP_Query()
85
+				unset($args[ $property ]);
86
+			}
87
+		}
88
+		return $args;
89
+	}
90
+
91
+
92
+	private function setupEventQueryHelper()
93
+	{
94
+		// add query filters
95
+		EEH_Event_Query::add_query_filters();
96
+		// set params that will get used by the filters
97
+		EEH_Event_Query::set_query_params(
98
+			$this->month,
99
+			$this->category_slug,
100
+			$this->show_expired,
101
+			$this->order_by,
102
+			$this->sort
103
+		);
104
+	}
105
+
106
+
107
+	private function setupFilters()
108
+	{
109
+		// first off, let's remove any filters from previous queries
110
+		remove_filter(
111
+			'FHEE__archive_espresso_events_template__show_header',
112
+			[$this, 'show_event_list_title']
113
+		);
114
+		remove_filter(
115
+			'FHEE__archive_espresso_events_template__upcoming_events_h1',
116
+			[$this, 'event_list_title']
117
+		);
118
+		remove_all_filters('FHEE__content_espresso_events__event_class');
119
+		// Event List Title ?
120
+		add_filter(
121
+			'FHEE__archive_espresso_events_template__show_header',
122
+			[$this, 'show_event_list_title']
123
+		);
124
+		add_filter(
125
+			'FHEE__archive_espresso_events_template__upcoming_events_h1',
126
+			[$this, 'event_list_title']
127
+		);
128
+		// add the css class
129
+		add_filter(
130
+			'FHEE__content_espresso_events__event_class',
131
+			[$this, 'event_list_css']
132
+		);
133
+	}
134
+
135
+
136
+	private function getQueryArgs(array $args): array
137
+	{
138
+		// the current "page" we are viewing
139
+		$paged = max(1, get_query_var('paged'));
140
+		// Force these args
141
+		return array_merge(
142
+			$args,
143
+			[
144
+				'post_type'              => EspressoPostType::EVENTS,
145
+				'posts_per_page'         => $this->limit,
146
+				'update_post_term_cache' => false,
147
+				'update_post_meta_cache' => false,
148
+				'paged'                  => $paged,
149
+				'offset'                 => ($paged - 1) * $this->limit,
150
+			]
151
+		);
152
+	}
153
+
154
+	// phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
155
+
156
+
157
+	/**
158
+	 * show_event_list_title
159
+	 *
160
+	 * @return boolean
161
+	 */
162
+	public function show_event_list_title(): bool
163
+	{
164
+		return filter_var($this->show_title, FILTER_VALIDATE_BOOLEAN);
165
+	}
166
+
167
+
168
+	/**
169
+	 * callback for FHEE__archive_espresso_events_template__upcoming_events_h1 filter
170
+	 *
171
+	 * @param string $event_list_title
172
+	 * @return    string
173
+	 */
174
+	public function event_list_title(string $event_list_title = ''): string
175
+	{
176
+		if (! empty($this->title)) {
177
+			return $this->title;
178
+		}
179
+		return $event_list_title;
180
+	}
181
+
182
+
183
+	/**
184
+	 * callback for FHEE__content_espresso_events__event_class filter
185
+	 *
186
+	 * @param string $event_list_css
187
+	 * @return string
188
+	 */
189
+	public function event_list_css(string $event_list_css = ''): string
190
+	{
191
+		$event_list_css .= ! empty($event_list_css) ? ' ' : '';
192
+		$event_list_css .= ! empty($this->css_class) ? $this->css_class : '';
193
+		$event_list_css .= ! empty($event_list_css) ? ' ' : '';
194
+		$event_list_css .= ! empty($this->category_slug) ? $this->category_slug : '';
195
+		return $event_list_css;
196
+	}
197
+	// phpcs:enable
198 198
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
                         break;
83 83
                 }
84 84
                 // then remove it from the array of args that will later be passed to WP_Query()
85
-                unset($args[ $property ]);
85
+                unset($args[$property]);
86 86
             }
87 87
         }
88 88
         return $args;
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
      */
174 174
     public function event_list_title(string $event_list_title = ''): string
175 175
     {
176
-        if (! empty($this->title)) {
176
+        if ( ! empty($this->title)) {
177 177
             return $this->title;
178 178
         }
179 179
         return $event_list_title;
Please login to merge, or discard this patch.
core/domain/services/validation/email/EmailValidationService.php 1 patch
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -15,59 +15,59 @@
 block discarded – undo
15 15
  */
16 16
 class EmailValidationService implements EmailValidatorInterface
17 17
 {
18
-    protected EE_Registration_Config $registration_config;
18
+	protected EE_Registration_Config $registration_config;
19 19
 
20
-    protected LoaderInterface $loader;
20
+	protected LoaderInterface $loader;
21 21
 
22 22
 
23
-    /**
24
-     * EmailValidationService constructor.
25
-     * Accepts an \EE_Config as an argument.
26
-     *
27
-     * @param EE_Registration_Config $config
28
-     * @param LoaderInterface        $loader
29
-     */
30
-    public function __construct(EE_Registration_Config $config, LoaderInterface $loader)
31
-    {
32
-        $this->registration_config = $config;
33
-        $this->loader              = $loader;
34
-    }
23
+	/**
24
+	 * EmailValidationService constructor.
25
+	 * Accepts an \EE_Config as an argument.
26
+	 *
27
+	 * @param EE_Registration_Config $config
28
+	 * @param LoaderInterface        $loader
29
+	 */
30
+	public function __construct(EE_Registration_Config $config, LoaderInterface $loader)
31
+	{
32
+		$this->registration_config = $config;
33
+		$this->loader              = $loader;
34
+	}
35 35
 
36 36
 
37
-    /**
38
-     * Validates the email address. If it's invalid, an EmailValidationException
39
-     * is thrown that describes why its invalid.
40
-     *
41
-     * @param string $email_address
42
-     * @return boolean
43
-     * @throws EmailValidationException
44
-     */
45
-    public function validate(string $email_address): bool
46
-    {
47
-        // pick the correct validator according to the config
48
-        switch ($this->registration_config->email_validation_level) {
49
-            case 'basic':
50
-                $validator = $this->loader->getShared(
51
-                    'EventEspresso\core\domain\services\validation\email\strategies\Basic'
52
-                );
53
-                break;
54
-            case 'i18n':
55
-                $validator = $this->loader->getShared(
56
-                    'EventEspresso\core\domain\services\validation\email\strategies\International'
57
-                );
58
-                break;
59
-            case 'i18n_dns':
60
-                $validator = $this->loader->getShared(
61
-                    'EventEspresso\core\domain\services\validation\email\strategies\InternationalDNS'
62
-                );
63
-                break;
64
-            case 'wp_default':
65
-            default:
66
-                $validator = $this->loader->getShared(
67
-                    'EventEspresso\core\domain\services\validation\email\strategies\WordPress'
68
-                );
69
-                break;
70
-        }
71
-        return $validator->validate($email_address);
72
-    }
37
+	/**
38
+	 * Validates the email address. If it's invalid, an EmailValidationException
39
+	 * is thrown that describes why its invalid.
40
+	 *
41
+	 * @param string $email_address
42
+	 * @return boolean
43
+	 * @throws EmailValidationException
44
+	 */
45
+	public function validate(string $email_address): bool
46
+	{
47
+		// pick the correct validator according to the config
48
+		switch ($this->registration_config->email_validation_level) {
49
+			case 'basic':
50
+				$validator = $this->loader->getShared(
51
+					'EventEspresso\core\domain\services\validation\email\strategies\Basic'
52
+				);
53
+				break;
54
+			case 'i18n':
55
+				$validator = $this->loader->getShared(
56
+					'EventEspresso\core\domain\services\validation\email\strategies\International'
57
+				);
58
+				break;
59
+			case 'i18n_dns':
60
+				$validator = $this->loader->getShared(
61
+					'EventEspresso\core\domain\services\validation\email\strategies\InternationalDNS'
62
+				);
63
+				break;
64
+			case 'wp_default':
65
+			default:
66
+				$validator = $this->loader->getShared(
67
+					'EventEspresso\core\domain\services\validation\email\strategies\WordPress'
68
+				);
69
+				break;
70
+		}
71
+		return $validator->validate($email_address);
72
+	}
73 73
 }
Please login to merge, or discard this patch.
core/domain/services/admin/AdminToolBar.php 2 patches
Indentation   +821 added lines, -821 removed lines patch added patch discarded remove patch
@@ -20,825 +20,825 @@
 block discarded – undo
20 20
  */
21 21
 class AdminToolBar
22 22
 {
23
-    private ?WP_Admin_Bar $admin_bar        = null;
24
-
25
-    private EE_Capabilities $capabilities;
26
-
27
-    private string $events_admin_url = '';
28
-
29
-    private string $menu_class       = 'espresso_menu_item_class';
30
-
31
-    private string $reg_admin_url    = '';
32
-
33
-
34
-    /**
35
-     * AdminToolBar constructor.
36
-     *
37
-     * @param EE_Capabilities $capabilities
38
-     */
39
-    public function __construct(EE_Capabilities $capabilities)
40
-    {
41
-        $this->capabilities = $capabilities;
42
-        add_action('admin_bar_menu', [$this, 'espressoToolbarItems'], 100);
43
-        $this->enqueueAssets();
44
-    }
45
-
46
-
47
-    /**
48
-     *    espresso_toolbar_items
49
-     *
50
-     * @access public
51
-     * @param WP_Admin_Bar $admin_bar
52
-     * @return void
53
-     */
54
-    public function espressoToolbarItems(WP_Admin_Bar $admin_bar)
55
-    {
56
-        // if it's an AJAX request, or user is NOT an admin, or in full M-Mode
57
-        if (
58
-            (defined('DOING_AJAX') && DOING_AJAX)
59
-            || ! $this->capabilities->current_user_can('ee_read_ee', 'ee_admin_bar_menu_top_level')
60
-            || MaintenanceStatus::isFullSite()
61
-        ) {
62
-            return;
63
-        }
64
-        $this->admin_bar = $admin_bar;
65
-        // we don't use the constants EVENTS_ADMIN_URL or REG_ADMIN_URL
66
-        // because they're only defined in each of their respective constructors
67
-        // and this might be a frontend request, in which case they aren't available
68
-        $this->events_admin_url = admin_url('admin.php?page=espresso_events');
69
-        $this->reg_admin_url    = admin_url('admin.php?page=espresso_registrations');
70
-        // now let's add all the menu items
71
-        $this->addTopLevelMenu();
72
-        $this->addEventsSubMenu();
73
-        $this->addEventsAddEditHeader();
74
-        $this->addEventsAddNew();
75
-        $this->addEventsEditCurrentEvent();
76
-        $this->addEventsViewHeader();
77
-        $this->addEventsViewAll();
78
-        $this->addEventsViewToday();
79
-        $this->addEventsViewThisMonth();
80
-        $this->addRegistrationSubMenu();
81
-        $this->addRegistrationOverviewToday();
82
-        $this->addRegistrationOverviewTodayApproved();
83
-        $this->addRegistrationOverviewTodayPendingPayment();
84
-        $this->addRegistrationOverviewTodayNotApproved();
85
-        $this->addRegistrationOverviewTodayCancelled();
86
-        $this->addRegistrationOverviewThisMonth();
87
-        $this->addRegistrationOverviewThisMonthApproved();
88
-        $this->addRegistrationOverviewThisMonthPending();
89
-        $this->addRegistrationOverviewThisMonthNotApproved();
90
-        $this->addRegistrationOverviewThisMonthCancelled();
91
-        $this->addExtensionsAndServices();
92
-        $this->addFontSizeSubMenu();
93
-    }
94
-
95
-
96
-    /**
97
-     * @return void
98
-     */
99
-    private function enqueueAssets()
100
-    {
101
-        wp_register_style(
102
-            'espresso-admin-toolbar',
103
-            EE_GLOBAL_ASSETS_URL . 'css/espresso-admin-toolbar.css',
104
-            ['dashicons'],
105
-            EVENT_ESPRESSO_VERSION
106
-        );
107
-        wp_enqueue_style('espresso-admin-toolbar');
108
-    }
109
-
110
-
111
-    /**
112
-     * @return void
113
-     */
114
-    private function addTopLevelMenu()
115
-    {
116
-        $this->admin_bar->add_menu(
117
-            [
118
-                'id'    => 'espresso-toolbar',
119
-                'title' => '<span class="ab-icon ee-icon ee-icon-ee-cup-thick ee-icon-size-20"></span><span class="ab-label">'
120
-                           . esc_html_x('Event Espresso', 'admin bar menu group label', 'event_espresso')
121
-                           . '</span>',
122
-                'href'  => $this->events_admin_url,
123
-                'meta'  => [
124
-                    'title' => esc_html__('Event Espresso', 'event_espresso'),
125
-                    'class' => $this->menu_class . 'first',
126
-                ],
127
-            ]
128
-        );
129
-    }
130
-
131
-
132
-    /**
133
-     * @return void
134
-     */
135
-    private function addEventsSubMenu()
136
-    {
137
-        if (
138
-            $this->capabilities->current_user_can(
139
-                'ee_read_events',
140
-                'ee_admin_bar_menu_espresso-toolbar-events'
141
-            )
142
-        ) {
143
-            $this->admin_bar->add_menu(
144
-                [
145
-                    'id'     => 'espresso-toolbar-events',
146
-                    'parent' => 'espresso-toolbar',
147
-                    'title'  => '<span class="ee-toolbar-icon"></span>'
148
-                                . esc_html__('Events', 'event_espresso'),
149
-                    'href'   => $this->events_admin_url,
150
-                    'meta'   => [
151
-                        'title'  => esc_html__('Events', 'event_espresso'),
152
-                        'target' => '',
153
-                        'class'  => $this->menu_class,
154
-                    ],
155
-                ]
156
-            );
157
-        }
158
-    }
159
-
160
-
161
-    /**
162
-     * @return void
163
-     */
164
-    private function addEventsAddEditHeader()
165
-    {
166
-        if (
167
-            $this->capabilities->current_user_can(
168
-                'ee_read_events',
169
-                'ee_admin_bar_menu_espresso-toolbar-events-view'
170
-            )
171
-        ) {
172
-            $this->admin_bar->add_menu(
173
-                [
174
-                    'id'     => 'espresso-toolbar-events-add-edit',
175
-                    'parent' => 'espresso-toolbar-events',
176
-                    'title'  => esc_html__('Add / Edit', 'event_espresso'),
177
-                    'href'   => '',
178
-                ]
179
-            );
180
-        }
181
-    }
182
-
183
-
184
-    /**
185
-     * @return void
186
-     */
187
-    private function addEventsAddNew()
188
-    {
189
-        if (
190
-            $this->capabilities->current_user_can(
191
-                'ee_edit_events',
192
-                'ee_admin_bar_menu_espresso-toolbar-events-new'
193
-            )
194
-        ) {
195
-            $this->admin_bar->add_menu(
196
-                [
197
-                    'id'     => 'espresso-toolbar-events-new',
198
-                    'parent' => 'espresso-toolbar-events',
199
-                    'title'  => '<span class="ee-toolbar-icon"></span>'
200
-                                . esc_html__('Add New', 'event_espresso'),
201
-                    'href'   => EEH_URL::add_query_args_and_nonce(
202
-                        ['action' => 'create_new'],
203
-                        $this->events_admin_url
204
-                    ),
205
-                    'meta'   => [
206
-                        'title'  => esc_html__('Add New', 'event_espresso'),
207
-                        'target' => '',
208
-                        'class'  => $this->menu_class,
209
-                    ],
210
-                ]
211
-            );
212
-        }
213
-    }
214
-
215
-
216
-    /**
217
-     * @return void
218
-     */
219
-    private function addEventsEditCurrentEvent()
220
-    {
221
-        if (is_single() && (get_post_type() === EspressoPostType::EVENTS)) {
222
-            // Current post
223
-            global $post;
224
-            if (
225
-                $this->capabilities->current_user_can(
226
-                    'ee_edit_event',
227
-                    'ee_admin_bar_menu_espresso-toolbar-events-edit',
228
-                    $post->ID
229
-                )
230
-            ) {
231
-                $this->admin_bar->add_menu(
232
-                    [
233
-                        'id'     => 'espresso-toolbar-events-edit',
234
-                        'parent' => 'espresso-toolbar-events',
235
-                        'title'  => '<span class="ee-toolbar-icon"></span>'
236
-                                    . esc_html__('Edit Event', 'event_espresso'),
237
-                        'href'   => EEH_URL::add_query_args_and_nonce(
238
-                            [
239
-                                'action' => 'edit',
240
-                                'post'   => $post->ID,
241
-                            ],
242
-                            $this->events_admin_url
243
-                        ),
244
-                        'meta'   => [
245
-                            'title'  => esc_html__('Edit Event', 'event_espresso'),
246
-                            'target' => '',
247
-                            'class'  => $this->menu_class,
248
-                        ],
249
-                    ]
250
-                );
251
-            }
252
-        }
253
-    }
254
-
255
-
256
-    /**
257
-     * @return void
258
-     */
259
-    private function addEventsViewHeader()
260
-    {
261
-        if (
262
-            $this->capabilities->current_user_can(
263
-                'ee_read_events',
264
-                'ee_admin_bar_menu_espresso-toolbar-events-view'
265
-            )
266
-        ) {
267
-            $this->admin_bar->add_menu(
268
-                [
269
-                    'id'     => 'espresso-toolbar-events-view',
270
-                    'parent' => 'espresso-toolbar-events',
271
-                    'title'  => esc_html__('View', 'event_espresso'),
272
-                    'href'   => '',
273
-                ]
274
-            );
275
-        }
276
-    }
277
-
278
-
279
-    /**
280
-     * @return void
281
-     */
282
-    private function addEventsViewAll()
283
-    {
284
-        if (
285
-            $this->capabilities->current_user_can(
286
-                'ee_read_events',
287
-                'ee_admin_bar_menu_espresso-toolbar-events-all'
288
-            )
289
-        ) {
290
-            $this->admin_bar->add_menu(
291
-                [
292
-                    'id'     => 'espresso-toolbar-events-all',
293
-                    'parent' => 'espresso-toolbar-events',
294
-                    'title'  => '<span class="ee-toolbar-icon"></span>'
295
-                                . esc_html__('All', 'event_espresso'),
296
-                    'href'   => $this->events_admin_url,
297
-                    'meta'   => [
298
-                        'title'  => esc_html__('All', 'event_espresso'),
299
-                        'target' => '',
300
-                        'class'  => $this->menu_class,
301
-                    ],
302
-                ]
303
-            );
304
-        }
305
-    }
306
-
307
-
308
-    /**
309
-     * @return void
310
-     */
311
-    private function addEventsViewToday()
312
-    {
313
-        if (
314
-            $this->capabilities->current_user_can(
315
-                'ee_read_events',
316
-                'ee_admin_bar_menu_espresso-toolbar-events-today'
317
-            )
318
-        ) {
319
-            $this->admin_bar->add_menu(
320
-                [
321
-                    'id'     => 'espresso-toolbar-events-today',
322
-                    'parent' => 'espresso-toolbar-events',
323
-                    'title'  => '<span class="ee-toolbar-icon"></span>'
324
-                                . esc_html__('Today', 'event_espresso'),
325
-                    'href'   => EEH_URL::add_query_args_and_nonce(
326
-                        [
327
-                            'action' => 'default',
328
-                            'status' => 'today',
329
-                        ],
330
-                        $this->events_admin_url
331
-                    ),
332
-                    'meta'   => [
333
-                        'title'  => esc_html__('Today', 'event_espresso'),
334
-                        'target' => '',
335
-                        'class'  => $this->menu_class,
336
-                    ],
337
-                ]
338
-            );
339
-        }
340
-    }
341
-
342
-
343
-    /**
344
-     * @return void
345
-     */
346
-    private function addEventsViewThisMonth()
347
-    {
348
-        if (
349
-            $this->capabilities->current_user_can(
350
-                'ee_read_events',
351
-                'ee_admin_bar_menu_espresso-toolbar-events-month'
352
-            )
353
-        ) {
354
-            $this->admin_bar->add_menu(
355
-                [
356
-                    'id'     => 'espresso-toolbar-events-month',
357
-                    'parent' => 'espresso-toolbar-events',
358
-                    'title'  => '<span class="ee-toolbar-icon"></span>'
359
-                                . esc_html__('This Month', 'event_espresso'),
360
-                    'href'   => EEH_URL::add_query_args_and_nonce(
361
-                        [
362
-                            'action' => 'default',
363
-                            'status' => 'month',
364
-                        ],
365
-                        $this->events_admin_url
366
-                    ),
367
-                    'meta'   => [
368
-                        'title'  => esc_html__('This Month', 'event_espresso'),
369
-                        'target' => '',
370
-                        'class'  => $this->menu_class,
371
-                    ],
372
-                ]
373
-            );
374
-        }
375
-    }
376
-
377
-
378
-    /**
379
-     * @return void
380
-     */
381
-    private function addRegistrationSubMenu()
382
-    {
383
-        if (
384
-            $this->capabilities->current_user_can(
385
-                'ee_read_registrations',
386
-                'ee_admin_bar_menu_espresso-toolbar-registrations'
387
-            )
388
-        ) {
389
-            $this->admin_bar->add_menu(
390
-                [
391
-                    'id'     => 'espresso-toolbar-registrations',
392
-                    'parent' => 'espresso-toolbar',
393
-                    'title'  => '<span class="ee-toolbar-icon"></span>'
394
-                                . esc_html__('Registrations', 'event_espresso'),
395
-                    'href'   => $this->reg_admin_url,
396
-                    'meta'   => [
397
-                        'title'  => esc_html__('Registrations', 'event_espresso'),
398
-                        'target' => '',
399
-                        'class'  => $this->menu_class,
400
-                    ],
401
-                ]
402
-            );
403
-        }
404
-    }
405
-
406
-
407
-    /**
408
-     * @return void
409
-     */
410
-    private function addRegistrationOverviewToday()
411
-    {
412
-        if (
413
-            $this->capabilities->current_user_can(
414
-                'ee_read_registrations',
415
-                'ee_admin_bar_menu_espresso-toolbar-registrations-today'
416
-            )
417
-        ) {
418
-            $this->admin_bar->add_menu(
419
-                [
420
-                    'id'     => 'espresso-toolbar-registrations-today',
421
-                    'parent' => 'espresso-toolbar-registrations',
422
-                    'title'  => esc_html__('Today', 'event_espresso'),
423
-                    'href'   => '',
424
-                    'meta'   => [
425
-                        'title'  => esc_html__('Today', 'event_espresso'),
426
-                        'target' => '',
427
-                        'class'  => $this->menu_class,
428
-                    ],
429
-                ]
430
-            );
431
-        }
432
-    }
433
-
434
-
435
-    /**
436
-     * @return void
437
-     */
438
-    private function addRegistrationOverviewTodayApproved()
439
-    {
440
-        if (
441
-            $this->capabilities->current_user_can(
442
-                'ee_read_registrations',
443
-                'ee_admin_bar_menu_espresso-toolbar-registrations-today-approved'
444
-            )
445
-        ) {
446
-            $this->admin_bar->add_menu(
447
-                [
448
-                    'id'     => 'espresso-toolbar-registrations-today-approved',
449
-                    'parent' => 'espresso-toolbar-registrations',
450
-                    'title'  => '<span class="ee-toolbar-icon"></span>'
451
-                                . esc_html__('Approved', 'event_espresso'),
452
-                    'href'   => EEH_URL::add_query_args_and_nonce(
453
-                        [
454
-                            'action'      => 'default',
455
-                            'status'      => 'today',
456
-                            '_reg_status' => RegStatus::APPROVED,
457
-                        ],
458
-                        $this->reg_admin_url
459
-                    ),
460
-                    'meta'   => [
461
-                        'title'  => esc_html__('Approved', 'event_espresso'),
462
-                        'target' => '',
463
-                        'class'  => $this->menu_class . ' ee-toolbar-icon-approved',
464
-                    ],
465
-                ]
466
-            );
467
-        }
468
-    }
469
-
470
-
471
-    /**
472
-     * @return void
473
-     */
474
-    private function addRegistrationOverviewTodayPendingPayment()
475
-    {
476
-        if (
477
-            $this->capabilities->current_user_can(
478
-                'ee_read_registrations',
479
-                'ee_admin_bar_menu_espresso-toolbar-registrations-today-pending'
480
-            )
481
-        ) {
482
-            $this->admin_bar->add_menu(
483
-                [
484
-                    'id'     => 'espresso-toolbar-registrations-today-pending',
485
-                    'parent' => 'espresso-toolbar-registrations',
486
-                    'title'  => '<span class="ee-toolbar-icon"></span>'
487
-                                . esc_html__('Pending', 'event_espresso'),
488
-                    'href'   => EEH_URL::add_query_args_and_nonce(
489
-                        [
490
-                            'action'      => 'default',
491
-                            'status'      => 'today',
492
-                            '_reg_status' => RegStatus::PENDING_PAYMENT,
493
-                        ],
494
-                        $this->reg_admin_url
495
-                    ),
496
-                    'meta'   => [
497
-                        'title'  => esc_html__('Pending Payment', 'event_espresso'),
498
-                        'target' => '',
499
-                        'class'  => $this->menu_class . ' ee-toolbar-icon-pending',
500
-                    ],
501
-                ]
502
-            );
503
-        }
504
-    }
505
-
506
-
507
-    /**
508
-     * @return void
509
-     */
510
-    private function addRegistrationOverviewTodayNotApproved()
511
-    {
512
-        if (
513
-            $this->capabilities->current_user_can(
514
-                'ee_read_registrations',
515
-                'ee_admin_bar_menu_espresso-toolbar-registrations-today-not-approved'
516
-            )
517
-        ) {
518
-            $this->admin_bar->add_menu(
519
-                [
520
-                    'id'     => 'espresso-toolbar-registrations-today-not-approved',
521
-                    'parent' => 'espresso-toolbar-registrations',
522
-                    'title'  => '<span class="ee-toolbar-icon"></span>'
523
-                                . esc_html__('Not Approved / Awaiting Review', 'event_espresso'),
524
-                    'href'   => EEH_URL::add_query_args_and_nonce(
525
-                        [
526
-                            'action'      => 'default',
527
-                            'status'      => 'today',
528
-                            '_reg_status' => RegStatus::AWAITING_REVIEW,
529
-                        ],
530
-                        $this->reg_admin_url
531
-                    ),
532
-                    'meta'   => [
533
-                        'title'  => esc_html__('Not Approved / Awaiting Review', 'event_espresso'),
534
-                        'target' => '',
535
-                        'class'  => $this->menu_class . ' ee-toolbar-icon-not-approved',
536
-                    ],
537
-                ]
538
-            );
539
-        }
540
-    }
541
-
542
-
543
-    /**
544
-     * @return void
545
-     */
546
-    private function addRegistrationOverviewTodayCancelled()
547
-    {
548
-        if (
549
-            $this->capabilities->current_user_can(
550
-                'ee_read_registrations',
551
-                'ee_admin_bar_menu_espresso-toolbar-registrations-today-cancelled'
552
-            )
553
-        ) {
554
-            $this->admin_bar->add_menu(
555
-                [
556
-                    'id'     => 'espresso-toolbar-registrations-today-cancelled',
557
-                    'parent' => 'espresso-toolbar-registrations',
558
-                    'title'  => '<span class="ee-toolbar-icon"></span>'
559
-                                . esc_html__('Cancelled', 'event_espresso'),
560
-                    'href'   => EEH_URL::add_query_args_and_nonce(
561
-                        [
562
-                            'action'      => 'default',
563
-                            'status'      => 'today',
564
-                            '_reg_status' => RegStatus::CANCELLED,
565
-                        ],
566
-                        $this->reg_admin_url
567
-                    ),
568
-                    'meta'   => [
569
-                        'title'  => esc_html__('Cancelled', 'event_espresso'),
570
-                        'target' => '',
571
-                        'class'  => $this->menu_class . ' ee-toolbar-icon-cancelled',
572
-                    ],
573
-                ]
574
-            );
575
-        }
576
-    }
577
-
578
-
579
-    /**
580
-     * @return void
581
-     */
582
-    private function addRegistrationOverviewThisMonth()
583
-    {
584
-        if (
585
-            $this->capabilities->current_user_can(
586
-                'ee_read_registrations',
587
-                'ee_admin_bar_menu_espresso-toolbar-registrations-month'
588
-            )
589
-        ) {
590
-            $this->admin_bar->add_menu(
591
-                [
592
-                    'id'     => 'espresso-toolbar-registrations-month',
593
-                    'parent' => 'espresso-toolbar-registrations',
594
-                    'title'  => esc_html__('This Month', 'event_espresso'),
595
-                    'href'   => '', // EEH_URL::add_query_args_and_nonce(
596
-                    //     array(
597
-                    //         'action' => 'default',
598
-                    //         'status' => 'month'
599
-                    //     ),
600
-                    //     $this->reg_admin_url
601
-                    // ),
602
-                    'meta'   => [
603
-                        'title'  => esc_html__('This Month', 'event_espresso'),
604
-                        'target' => '',
605
-                        'class'  => $this->menu_class,
606
-                    ],
607
-                ]
608
-            );
609
-        }
610
-    }
611
-
612
-
613
-    /**
614
-     * @return void
615
-     */
616
-    private function addRegistrationOverviewThisMonthApproved()
617
-    {
618
-        if (
619
-            $this->capabilities->current_user_can(
620
-                'ee_read_registrations',
621
-                'ee_admin_bar_menu_espresso-toolbar-registrations-month-approved'
622
-            )
623
-        ) {
624
-            $this->admin_bar->add_menu(
625
-                [
626
-                    'id'     => 'espresso-toolbar-registrations-month-approved',
627
-                    'parent' => 'espresso-toolbar-registrations',
628
-                    'title'  => '<span class="ee-toolbar-icon"></span>'
629
-                                . esc_html__('Approved', 'event_espresso'),
630
-                    'href'   => EEH_URL::add_query_args_and_nonce(
631
-                        [
632
-                            'action'      => 'default',
633
-                            'status'      => 'month',
634
-                            '_reg_status' => RegStatus::APPROVED,
635
-                        ],
636
-                        $this->reg_admin_url
637
-                    ),
638
-                    'meta'   => [
639
-                        'title'  => esc_html__('Approved', 'event_espresso'),
640
-                        'target' => '',
641
-                        'class'  => $this->menu_class . ' ee-toolbar-icon-approved',
642
-                    ],
643
-                ]
644
-            );
645
-        }
646
-    }
647
-
648
-
649
-    /**
650
-     * @return void
651
-     */
652
-    private function addRegistrationOverviewThisMonthPending()
653
-    {
654
-        if (
655
-            $this->capabilities->current_user_can(
656
-                'ee_read_registrations',
657
-                'ee_admin_bar_menu_espresso-toolbar-registrations-month-pending'
658
-            )
659
-        ) {
660
-            $this->admin_bar->add_menu(
661
-                [
662
-                    'id'     => 'espresso-toolbar-registrations-month-pending',
663
-                    'parent' => 'espresso-toolbar-registrations',
664
-                    'title'  => '<span class="ee-toolbar-icon"></span>'
665
-                                . esc_html__('Pending', 'event_espresso'),
666
-                    'href'   => EEH_URL::add_query_args_and_nonce(
667
-                        [
668
-                            'action'      => 'default',
669
-                            'status'      => 'month',
670
-                            '_reg_status' => RegStatus::PENDING_PAYMENT,
671
-                        ],
672
-                        $this->reg_admin_url
673
-                    ),
674
-                    'meta'   => [
675
-                        'title'  => esc_html__('Pending', 'event_espresso'),
676
-                        'target' => '',
677
-                        'class'  => $this->menu_class . ' ee-toolbar-icon-pending',
678
-                    ],
679
-                ]
680
-            );
681
-        }
682
-    }
683
-
684
-
685
-    /**
686
-     * @return void
687
-     */
688
-    private function addRegistrationOverviewThisMonthNotApproved()
689
-    {
690
-        if (
691
-            $this->capabilities->current_user_can(
692
-                'ee_read_registrations',
693
-                'ee_admin_bar_menu_espresso-toolbar-registrations-month-not-approved'
694
-            )
695
-        ) {
696
-            $this->admin_bar->add_menu(
697
-                [
698
-                    'id'     => 'espresso-toolbar-registrations-month-not-approved',
699
-                    'parent' => 'espresso-toolbar-registrations',
700
-                    'title'  => '<span class="ee-toolbar-icon"></span>'
701
-                                . esc_html__('Not Approved / Awaiting Review', 'event_espresso'),
702
-                    'href'   => EEH_URL::add_query_args_and_nonce(
703
-                        [
704
-                            'action'      => 'default',
705
-                            'status'      => 'month',
706
-                            '_reg_status' => RegStatus::AWAITING_REVIEW,
707
-                        ],
708
-                        $this->reg_admin_url
709
-                    ),
710
-                    'meta'   => [
711
-                        'title'  => esc_html__('Not Approved / Awaiting Review', 'event_espresso'),
712
-                        'target' => '',
713
-                        'class'  => $this->menu_class . ' ee-toolbar-icon-not-approved',
714
-                    ],
715
-                ]
716
-            );
717
-        }
718
-    }
719
-
720
-
721
-    /**
722
-     * @return void
723
-     */
724
-    private function addRegistrationOverviewThisMonthCancelled()
725
-    {
726
-        if (
727
-            $this->capabilities->current_user_can(
728
-                'ee_read_registrations',
729
-                'ee_admin_bar_menu_espresso-toolbar-registrations-month-cancelled'
730
-            )
731
-        ) {
732
-            $this->admin_bar->add_menu(
733
-                [
734
-                    'id'     => 'espresso-toolbar-registrations-month-cancelled',
735
-                    'parent' => 'espresso-toolbar-registrations',
736
-                    'title'  => '<span class="ee-toolbar-icon"></span>'
737
-                                . esc_html__('Cancelled', 'event_espresso'),
738
-                    'href'   => EEH_URL::add_query_args_and_nonce(
739
-                        [
740
-                            'action'      => 'default',
741
-                            'status'      => 'month',
742
-                            '_reg_status' => RegStatus::CANCELLED,
743
-                        ],
744
-                        $this->reg_admin_url
745
-                    ),
746
-                    'meta'   => [
747
-                        'title'  => esc_html__('Cancelled', 'event_espresso'),
748
-                        'target' => '',
749
-                        'class'  => $this->menu_class . ' ee-toolbar-icon-cancelled',
750
-                    ],
751
-                ]
752
-            );
753
-        }
754
-    }
755
-
756
-
757
-    /**
758
-     * @return void
759
-     */
760
-    private function addExtensionsAndServices()
761
-    {
762
-        if (
763
-            $this->capabilities->current_user_can(
764
-                'ee_read_ee',
765
-                'ee_admin_bar_menu_espresso-toolbar-extensions-and-services'
766
-            )
767
-        ) {
768
-            $this->admin_bar->add_menu(
769
-                [
770
-                    'id'     => 'espresso-toolbar-extensions-and-services',
771
-                    'parent' => 'espresso-toolbar',
772
-                    'title'  => '<span class="ee-toolbar-icon"></span>'
773
-                                . esc_html__('Extensions & Services', 'event_espresso'),
774
-                    'href'   => admin_url('admin.php?page=espresso_packages'),
775
-                    'meta'   => [
776
-                        'title'  => esc_html__('Extensions & Services', 'event_espresso'),
777
-                        'target' => '',
778
-                        'class'  => $this->menu_class,
779
-                    ],
780
-                ]
781
-            );
782
-        }
783
-    }
784
-
785
-
786
-    /**
787
-     * @return void
788
-     */
789
-    private function addFontSizeSubMenu()
790
-    {
791
-        if (! is_admin()) {
792
-            return;
793
-        }
794
-        $this->admin_bar->add_menu(
795
-            [
796
-                'id'     => 'espresso-toolbar-font-size',
797
-                'parent' => 'espresso-toolbar',
798
-                'title'  => '<span class="ee-toolbar-icon"></span>'
799
-                            . esc_html__('Set Font Size', 'event_espresso'),
800
-                'href'   => '',
801
-                'meta'   => [
802
-                    'title'  => esc_html__('Set Font Size', 'event_espresso'),
803
-                    'target' => '',
804
-                    'class'  => $this->menu_class,
805
-                ],
806
-            ]
807
-        );
808
-
809
-        $settings_admin_url = admin_url('admin.php?page=espresso_general_settings');
810
-
811
-        $font_sizes = [
812
-            'tiny'    => AdminFontSize::FONT_SIZE_TINY,
813
-            'smaller' => AdminFontSize::FONT_SIZE_SMALLER,
814
-            'small'   => AdminFontSize::FONT_SIZE_SMALL,
815
-            'default' => AdminFontSize::FONT_SIZE_DEFAULT,
816
-            'big'     => AdminFontSize::FONT_SIZE_BIG,
817
-            'bigger'  => AdminFontSize::FONT_SIZE_BIGGER,
818
-        ];
819
-
820
-        foreach ($font_sizes as $font_size => $value) {
821
-            $this->admin_bar->add_menu(
822
-                [
823
-                    'id'     => "espresso-toolbar-set-font-size-$font_size",
824
-                    'parent' => 'espresso-toolbar-font-size',
825
-                    'title'  => '<span class="ee-toolbar-icon"></span>'
826
-                                . sprintf(
827
-                                    /* translators: Font Size Small */
828
-                                    esc_html__('Font Size %1$s', 'event_espresso'),
829
-                                    ucwords($font_size)
830
-                                ),
831
-                    'href'   => EEH_URL::add_query_args_and_nonce(
832
-                        ['action' => 'set_font_size', 'font_size' => $value],
833
-                        $settings_admin_url
834
-                    ),
835
-                    'meta'   => [
836
-                        'title'  => esc_html__('increases or decreases the Event Espresso admin font size', 'event_espresso'),
837
-                        'target' => '',
838
-                        'class'  => $this->menu_class,
839
-                    ],
840
-                ]
841
-            );
842
-        }
843
-    }
23
+	private ?WP_Admin_Bar $admin_bar        = null;
24
+
25
+	private EE_Capabilities $capabilities;
26
+
27
+	private string $events_admin_url = '';
28
+
29
+	private string $menu_class       = 'espresso_menu_item_class';
30
+
31
+	private string $reg_admin_url    = '';
32
+
33
+
34
+	/**
35
+	 * AdminToolBar constructor.
36
+	 *
37
+	 * @param EE_Capabilities $capabilities
38
+	 */
39
+	public function __construct(EE_Capabilities $capabilities)
40
+	{
41
+		$this->capabilities = $capabilities;
42
+		add_action('admin_bar_menu', [$this, 'espressoToolbarItems'], 100);
43
+		$this->enqueueAssets();
44
+	}
45
+
46
+
47
+	/**
48
+	 *    espresso_toolbar_items
49
+	 *
50
+	 * @access public
51
+	 * @param WP_Admin_Bar $admin_bar
52
+	 * @return void
53
+	 */
54
+	public function espressoToolbarItems(WP_Admin_Bar $admin_bar)
55
+	{
56
+		// if it's an AJAX request, or user is NOT an admin, or in full M-Mode
57
+		if (
58
+			(defined('DOING_AJAX') && DOING_AJAX)
59
+			|| ! $this->capabilities->current_user_can('ee_read_ee', 'ee_admin_bar_menu_top_level')
60
+			|| MaintenanceStatus::isFullSite()
61
+		) {
62
+			return;
63
+		}
64
+		$this->admin_bar = $admin_bar;
65
+		// we don't use the constants EVENTS_ADMIN_URL or REG_ADMIN_URL
66
+		// because they're only defined in each of their respective constructors
67
+		// and this might be a frontend request, in which case they aren't available
68
+		$this->events_admin_url = admin_url('admin.php?page=espresso_events');
69
+		$this->reg_admin_url    = admin_url('admin.php?page=espresso_registrations');
70
+		// now let's add all the menu items
71
+		$this->addTopLevelMenu();
72
+		$this->addEventsSubMenu();
73
+		$this->addEventsAddEditHeader();
74
+		$this->addEventsAddNew();
75
+		$this->addEventsEditCurrentEvent();
76
+		$this->addEventsViewHeader();
77
+		$this->addEventsViewAll();
78
+		$this->addEventsViewToday();
79
+		$this->addEventsViewThisMonth();
80
+		$this->addRegistrationSubMenu();
81
+		$this->addRegistrationOverviewToday();
82
+		$this->addRegistrationOverviewTodayApproved();
83
+		$this->addRegistrationOverviewTodayPendingPayment();
84
+		$this->addRegistrationOverviewTodayNotApproved();
85
+		$this->addRegistrationOverviewTodayCancelled();
86
+		$this->addRegistrationOverviewThisMonth();
87
+		$this->addRegistrationOverviewThisMonthApproved();
88
+		$this->addRegistrationOverviewThisMonthPending();
89
+		$this->addRegistrationOverviewThisMonthNotApproved();
90
+		$this->addRegistrationOverviewThisMonthCancelled();
91
+		$this->addExtensionsAndServices();
92
+		$this->addFontSizeSubMenu();
93
+	}
94
+
95
+
96
+	/**
97
+	 * @return void
98
+	 */
99
+	private function enqueueAssets()
100
+	{
101
+		wp_register_style(
102
+			'espresso-admin-toolbar',
103
+			EE_GLOBAL_ASSETS_URL . 'css/espresso-admin-toolbar.css',
104
+			['dashicons'],
105
+			EVENT_ESPRESSO_VERSION
106
+		);
107
+		wp_enqueue_style('espresso-admin-toolbar');
108
+	}
109
+
110
+
111
+	/**
112
+	 * @return void
113
+	 */
114
+	private function addTopLevelMenu()
115
+	{
116
+		$this->admin_bar->add_menu(
117
+			[
118
+				'id'    => 'espresso-toolbar',
119
+				'title' => '<span class="ab-icon ee-icon ee-icon-ee-cup-thick ee-icon-size-20"></span><span class="ab-label">'
120
+						   . esc_html_x('Event Espresso', 'admin bar menu group label', 'event_espresso')
121
+						   . '</span>',
122
+				'href'  => $this->events_admin_url,
123
+				'meta'  => [
124
+					'title' => esc_html__('Event Espresso', 'event_espresso'),
125
+					'class' => $this->menu_class . 'first',
126
+				],
127
+			]
128
+		);
129
+	}
130
+
131
+
132
+	/**
133
+	 * @return void
134
+	 */
135
+	private function addEventsSubMenu()
136
+	{
137
+		if (
138
+			$this->capabilities->current_user_can(
139
+				'ee_read_events',
140
+				'ee_admin_bar_menu_espresso-toolbar-events'
141
+			)
142
+		) {
143
+			$this->admin_bar->add_menu(
144
+				[
145
+					'id'     => 'espresso-toolbar-events',
146
+					'parent' => 'espresso-toolbar',
147
+					'title'  => '<span class="ee-toolbar-icon"></span>'
148
+								. esc_html__('Events', 'event_espresso'),
149
+					'href'   => $this->events_admin_url,
150
+					'meta'   => [
151
+						'title'  => esc_html__('Events', 'event_espresso'),
152
+						'target' => '',
153
+						'class'  => $this->menu_class,
154
+					],
155
+				]
156
+			);
157
+		}
158
+	}
159
+
160
+
161
+	/**
162
+	 * @return void
163
+	 */
164
+	private function addEventsAddEditHeader()
165
+	{
166
+		if (
167
+			$this->capabilities->current_user_can(
168
+				'ee_read_events',
169
+				'ee_admin_bar_menu_espresso-toolbar-events-view'
170
+			)
171
+		) {
172
+			$this->admin_bar->add_menu(
173
+				[
174
+					'id'     => 'espresso-toolbar-events-add-edit',
175
+					'parent' => 'espresso-toolbar-events',
176
+					'title'  => esc_html__('Add / Edit', 'event_espresso'),
177
+					'href'   => '',
178
+				]
179
+			);
180
+		}
181
+	}
182
+
183
+
184
+	/**
185
+	 * @return void
186
+	 */
187
+	private function addEventsAddNew()
188
+	{
189
+		if (
190
+			$this->capabilities->current_user_can(
191
+				'ee_edit_events',
192
+				'ee_admin_bar_menu_espresso-toolbar-events-new'
193
+			)
194
+		) {
195
+			$this->admin_bar->add_menu(
196
+				[
197
+					'id'     => 'espresso-toolbar-events-new',
198
+					'parent' => 'espresso-toolbar-events',
199
+					'title'  => '<span class="ee-toolbar-icon"></span>'
200
+								. esc_html__('Add New', 'event_espresso'),
201
+					'href'   => EEH_URL::add_query_args_and_nonce(
202
+						['action' => 'create_new'],
203
+						$this->events_admin_url
204
+					),
205
+					'meta'   => [
206
+						'title'  => esc_html__('Add New', 'event_espresso'),
207
+						'target' => '',
208
+						'class'  => $this->menu_class,
209
+					],
210
+				]
211
+			);
212
+		}
213
+	}
214
+
215
+
216
+	/**
217
+	 * @return void
218
+	 */
219
+	private function addEventsEditCurrentEvent()
220
+	{
221
+		if (is_single() && (get_post_type() === EspressoPostType::EVENTS)) {
222
+			// Current post
223
+			global $post;
224
+			if (
225
+				$this->capabilities->current_user_can(
226
+					'ee_edit_event',
227
+					'ee_admin_bar_menu_espresso-toolbar-events-edit',
228
+					$post->ID
229
+				)
230
+			) {
231
+				$this->admin_bar->add_menu(
232
+					[
233
+						'id'     => 'espresso-toolbar-events-edit',
234
+						'parent' => 'espresso-toolbar-events',
235
+						'title'  => '<span class="ee-toolbar-icon"></span>'
236
+									. esc_html__('Edit Event', 'event_espresso'),
237
+						'href'   => EEH_URL::add_query_args_and_nonce(
238
+							[
239
+								'action' => 'edit',
240
+								'post'   => $post->ID,
241
+							],
242
+							$this->events_admin_url
243
+						),
244
+						'meta'   => [
245
+							'title'  => esc_html__('Edit Event', 'event_espresso'),
246
+							'target' => '',
247
+							'class'  => $this->menu_class,
248
+						],
249
+					]
250
+				);
251
+			}
252
+		}
253
+	}
254
+
255
+
256
+	/**
257
+	 * @return void
258
+	 */
259
+	private function addEventsViewHeader()
260
+	{
261
+		if (
262
+			$this->capabilities->current_user_can(
263
+				'ee_read_events',
264
+				'ee_admin_bar_menu_espresso-toolbar-events-view'
265
+			)
266
+		) {
267
+			$this->admin_bar->add_menu(
268
+				[
269
+					'id'     => 'espresso-toolbar-events-view',
270
+					'parent' => 'espresso-toolbar-events',
271
+					'title'  => esc_html__('View', 'event_espresso'),
272
+					'href'   => '',
273
+				]
274
+			);
275
+		}
276
+	}
277
+
278
+
279
+	/**
280
+	 * @return void
281
+	 */
282
+	private function addEventsViewAll()
283
+	{
284
+		if (
285
+			$this->capabilities->current_user_can(
286
+				'ee_read_events',
287
+				'ee_admin_bar_menu_espresso-toolbar-events-all'
288
+			)
289
+		) {
290
+			$this->admin_bar->add_menu(
291
+				[
292
+					'id'     => 'espresso-toolbar-events-all',
293
+					'parent' => 'espresso-toolbar-events',
294
+					'title'  => '<span class="ee-toolbar-icon"></span>'
295
+								. esc_html__('All', 'event_espresso'),
296
+					'href'   => $this->events_admin_url,
297
+					'meta'   => [
298
+						'title'  => esc_html__('All', 'event_espresso'),
299
+						'target' => '',
300
+						'class'  => $this->menu_class,
301
+					],
302
+				]
303
+			);
304
+		}
305
+	}
306
+
307
+
308
+	/**
309
+	 * @return void
310
+	 */
311
+	private function addEventsViewToday()
312
+	{
313
+		if (
314
+			$this->capabilities->current_user_can(
315
+				'ee_read_events',
316
+				'ee_admin_bar_menu_espresso-toolbar-events-today'
317
+			)
318
+		) {
319
+			$this->admin_bar->add_menu(
320
+				[
321
+					'id'     => 'espresso-toolbar-events-today',
322
+					'parent' => 'espresso-toolbar-events',
323
+					'title'  => '<span class="ee-toolbar-icon"></span>'
324
+								. esc_html__('Today', 'event_espresso'),
325
+					'href'   => EEH_URL::add_query_args_and_nonce(
326
+						[
327
+							'action' => 'default',
328
+							'status' => 'today',
329
+						],
330
+						$this->events_admin_url
331
+					),
332
+					'meta'   => [
333
+						'title'  => esc_html__('Today', 'event_espresso'),
334
+						'target' => '',
335
+						'class'  => $this->menu_class,
336
+					],
337
+				]
338
+			);
339
+		}
340
+	}
341
+
342
+
343
+	/**
344
+	 * @return void
345
+	 */
346
+	private function addEventsViewThisMonth()
347
+	{
348
+		if (
349
+			$this->capabilities->current_user_can(
350
+				'ee_read_events',
351
+				'ee_admin_bar_menu_espresso-toolbar-events-month'
352
+			)
353
+		) {
354
+			$this->admin_bar->add_menu(
355
+				[
356
+					'id'     => 'espresso-toolbar-events-month',
357
+					'parent' => 'espresso-toolbar-events',
358
+					'title'  => '<span class="ee-toolbar-icon"></span>'
359
+								. esc_html__('This Month', 'event_espresso'),
360
+					'href'   => EEH_URL::add_query_args_and_nonce(
361
+						[
362
+							'action' => 'default',
363
+							'status' => 'month',
364
+						],
365
+						$this->events_admin_url
366
+					),
367
+					'meta'   => [
368
+						'title'  => esc_html__('This Month', 'event_espresso'),
369
+						'target' => '',
370
+						'class'  => $this->menu_class,
371
+					],
372
+				]
373
+			);
374
+		}
375
+	}
376
+
377
+
378
+	/**
379
+	 * @return void
380
+	 */
381
+	private function addRegistrationSubMenu()
382
+	{
383
+		if (
384
+			$this->capabilities->current_user_can(
385
+				'ee_read_registrations',
386
+				'ee_admin_bar_menu_espresso-toolbar-registrations'
387
+			)
388
+		) {
389
+			$this->admin_bar->add_menu(
390
+				[
391
+					'id'     => 'espresso-toolbar-registrations',
392
+					'parent' => 'espresso-toolbar',
393
+					'title'  => '<span class="ee-toolbar-icon"></span>'
394
+								. esc_html__('Registrations', 'event_espresso'),
395
+					'href'   => $this->reg_admin_url,
396
+					'meta'   => [
397
+						'title'  => esc_html__('Registrations', 'event_espresso'),
398
+						'target' => '',
399
+						'class'  => $this->menu_class,
400
+					],
401
+				]
402
+			);
403
+		}
404
+	}
405
+
406
+
407
+	/**
408
+	 * @return void
409
+	 */
410
+	private function addRegistrationOverviewToday()
411
+	{
412
+		if (
413
+			$this->capabilities->current_user_can(
414
+				'ee_read_registrations',
415
+				'ee_admin_bar_menu_espresso-toolbar-registrations-today'
416
+			)
417
+		) {
418
+			$this->admin_bar->add_menu(
419
+				[
420
+					'id'     => 'espresso-toolbar-registrations-today',
421
+					'parent' => 'espresso-toolbar-registrations',
422
+					'title'  => esc_html__('Today', 'event_espresso'),
423
+					'href'   => '',
424
+					'meta'   => [
425
+						'title'  => esc_html__('Today', 'event_espresso'),
426
+						'target' => '',
427
+						'class'  => $this->menu_class,
428
+					],
429
+				]
430
+			);
431
+		}
432
+	}
433
+
434
+
435
+	/**
436
+	 * @return void
437
+	 */
438
+	private function addRegistrationOverviewTodayApproved()
439
+	{
440
+		if (
441
+			$this->capabilities->current_user_can(
442
+				'ee_read_registrations',
443
+				'ee_admin_bar_menu_espresso-toolbar-registrations-today-approved'
444
+			)
445
+		) {
446
+			$this->admin_bar->add_menu(
447
+				[
448
+					'id'     => 'espresso-toolbar-registrations-today-approved',
449
+					'parent' => 'espresso-toolbar-registrations',
450
+					'title'  => '<span class="ee-toolbar-icon"></span>'
451
+								. esc_html__('Approved', 'event_espresso'),
452
+					'href'   => EEH_URL::add_query_args_and_nonce(
453
+						[
454
+							'action'      => 'default',
455
+							'status'      => 'today',
456
+							'_reg_status' => RegStatus::APPROVED,
457
+						],
458
+						$this->reg_admin_url
459
+					),
460
+					'meta'   => [
461
+						'title'  => esc_html__('Approved', 'event_espresso'),
462
+						'target' => '',
463
+						'class'  => $this->menu_class . ' ee-toolbar-icon-approved',
464
+					],
465
+				]
466
+			);
467
+		}
468
+	}
469
+
470
+
471
+	/**
472
+	 * @return void
473
+	 */
474
+	private function addRegistrationOverviewTodayPendingPayment()
475
+	{
476
+		if (
477
+			$this->capabilities->current_user_can(
478
+				'ee_read_registrations',
479
+				'ee_admin_bar_menu_espresso-toolbar-registrations-today-pending'
480
+			)
481
+		) {
482
+			$this->admin_bar->add_menu(
483
+				[
484
+					'id'     => 'espresso-toolbar-registrations-today-pending',
485
+					'parent' => 'espresso-toolbar-registrations',
486
+					'title'  => '<span class="ee-toolbar-icon"></span>'
487
+								. esc_html__('Pending', 'event_espresso'),
488
+					'href'   => EEH_URL::add_query_args_and_nonce(
489
+						[
490
+							'action'      => 'default',
491
+							'status'      => 'today',
492
+							'_reg_status' => RegStatus::PENDING_PAYMENT,
493
+						],
494
+						$this->reg_admin_url
495
+					),
496
+					'meta'   => [
497
+						'title'  => esc_html__('Pending Payment', 'event_espresso'),
498
+						'target' => '',
499
+						'class'  => $this->menu_class . ' ee-toolbar-icon-pending',
500
+					],
501
+				]
502
+			);
503
+		}
504
+	}
505
+
506
+
507
+	/**
508
+	 * @return void
509
+	 */
510
+	private function addRegistrationOverviewTodayNotApproved()
511
+	{
512
+		if (
513
+			$this->capabilities->current_user_can(
514
+				'ee_read_registrations',
515
+				'ee_admin_bar_menu_espresso-toolbar-registrations-today-not-approved'
516
+			)
517
+		) {
518
+			$this->admin_bar->add_menu(
519
+				[
520
+					'id'     => 'espresso-toolbar-registrations-today-not-approved',
521
+					'parent' => 'espresso-toolbar-registrations',
522
+					'title'  => '<span class="ee-toolbar-icon"></span>'
523
+								. esc_html__('Not Approved / Awaiting Review', 'event_espresso'),
524
+					'href'   => EEH_URL::add_query_args_and_nonce(
525
+						[
526
+							'action'      => 'default',
527
+							'status'      => 'today',
528
+							'_reg_status' => RegStatus::AWAITING_REVIEW,
529
+						],
530
+						$this->reg_admin_url
531
+					),
532
+					'meta'   => [
533
+						'title'  => esc_html__('Not Approved / Awaiting Review', 'event_espresso'),
534
+						'target' => '',
535
+						'class'  => $this->menu_class . ' ee-toolbar-icon-not-approved',
536
+					],
537
+				]
538
+			);
539
+		}
540
+	}
541
+
542
+
543
+	/**
544
+	 * @return void
545
+	 */
546
+	private function addRegistrationOverviewTodayCancelled()
547
+	{
548
+		if (
549
+			$this->capabilities->current_user_can(
550
+				'ee_read_registrations',
551
+				'ee_admin_bar_menu_espresso-toolbar-registrations-today-cancelled'
552
+			)
553
+		) {
554
+			$this->admin_bar->add_menu(
555
+				[
556
+					'id'     => 'espresso-toolbar-registrations-today-cancelled',
557
+					'parent' => 'espresso-toolbar-registrations',
558
+					'title'  => '<span class="ee-toolbar-icon"></span>'
559
+								. esc_html__('Cancelled', 'event_espresso'),
560
+					'href'   => EEH_URL::add_query_args_and_nonce(
561
+						[
562
+							'action'      => 'default',
563
+							'status'      => 'today',
564
+							'_reg_status' => RegStatus::CANCELLED,
565
+						],
566
+						$this->reg_admin_url
567
+					),
568
+					'meta'   => [
569
+						'title'  => esc_html__('Cancelled', 'event_espresso'),
570
+						'target' => '',
571
+						'class'  => $this->menu_class . ' ee-toolbar-icon-cancelled',
572
+					],
573
+				]
574
+			);
575
+		}
576
+	}
577
+
578
+
579
+	/**
580
+	 * @return void
581
+	 */
582
+	private function addRegistrationOverviewThisMonth()
583
+	{
584
+		if (
585
+			$this->capabilities->current_user_can(
586
+				'ee_read_registrations',
587
+				'ee_admin_bar_menu_espresso-toolbar-registrations-month'
588
+			)
589
+		) {
590
+			$this->admin_bar->add_menu(
591
+				[
592
+					'id'     => 'espresso-toolbar-registrations-month',
593
+					'parent' => 'espresso-toolbar-registrations',
594
+					'title'  => esc_html__('This Month', 'event_espresso'),
595
+					'href'   => '', // EEH_URL::add_query_args_and_nonce(
596
+					//     array(
597
+					//         'action' => 'default',
598
+					//         'status' => 'month'
599
+					//     ),
600
+					//     $this->reg_admin_url
601
+					// ),
602
+					'meta'   => [
603
+						'title'  => esc_html__('This Month', 'event_espresso'),
604
+						'target' => '',
605
+						'class'  => $this->menu_class,
606
+					],
607
+				]
608
+			);
609
+		}
610
+	}
611
+
612
+
613
+	/**
614
+	 * @return void
615
+	 */
616
+	private function addRegistrationOverviewThisMonthApproved()
617
+	{
618
+		if (
619
+			$this->capabilities->current_user_can(
620
+				'ee_read_registrations',
621
+				'ee_admin_bar_menu_espresso-toolbar-registrations-month-approved'
622
+			)
623
+		) {
624
+			$this->admin_bar->add_menu(
625
+				[
626
+					'id'     => 'espresso-toolbar-registrations-month-approved',
627
+					'parent' => 'espresso-toolbar-registrations',
628
+					'title'  => '<span class="ee-toolbar-icon"></span>'
629
+								. esc_html__('Approved', 'event_espresso'),
630
+					'href'   => EEH_URL::add_query_args_and_nonce(
631
+						[
632
+							'action'      => 'default',
633
+							'status'      => 'month',
634
+							'_reg_status' => RegStatus::APPROVED,
635
+						],
636
+						$this->reg_admin_url
637
+					),
638
+					'meta'   => [
639
+						'title'  => esc_html__('Approved', 'event_espresso'),
640
+						'target' => '',
641
+						'class'  => $this->menu_class . ' ee-toolbar-icon-approved',
642
+					],
643
+				]
644
+			);
645
+		}
646
+	}
647
+
648
+
649
+	/**
650
+	 * @return void
651
+	 */
652
+	private function addRegistrationOverviewThisMonthPending()
653
+	{
654
+		if (
655
+			$this->capabilities->current_user_can(
656
+				'ee_read_registrations',
657
+				'ee_admin_bar_menu_espresso-toolbar-registrations-month-pending'
658
+			)
659
+		) {
660
+			$this->admin_bar->add_menu(
661
+				[
662
+					'id'     => 'espresso-toolbar-registrations-month-pending',
663
+					'parent' => 'espresso-toolbar-registrations',
664
+					'title'  => '<span class="ee-toolbar-icon"></span>'
665
+								. esc_html__('Pending', 'event_espresso'),
666
+					'href'   => EEH_URL::add_query_args_and_nonce(
667
+						[
668
+							'action'      => 'default',
669
+							'status'      => 'month',
670
+							'_reg_status' => RegStatus::PENDING_PAYMENT,
671
+						],
672
+						$this->reg_admin_url
673
+					),
674
+					'meta'   => [
675
+						'title'  => esc_html__('Pending', 'event_espresso'),
676
+						'target' => '',
677
+						'class'  => $this->menu_class . ' ee-toolbar-icon-pending',
678
+					],
679
+				]
680
+			);
681
+		}
682
+	}
683
+
684
+
685
+	/**
686
+	 * @return void
687
+	 */
688
+	private function addRegistrationOverviewThisMonthNotApproved()
689
+	{
690
+		if (
691
+			$this->capabilities->current_user_can(
692
+				'ee_read_registrations',
693
+				'ee_admin_bar_menu_espresso-toolbar-registrations-month-not-approved'
694
+			)
695
+		) {
696
+			$this->admin_bar->add_menu(
697
+				[
698
+					'id'     => 'espresso-toolbar-registrations-month-not-approved',
699
+					'parent' => 'espresso-toolbar-registrations',
700
+					'title'  => '<span class="ee-toolbar-icon"></span>'
701
+								. esc_html__('Not Approved / Awaiting Review', 'event_espresso'),
702
+					'href'   => EEH_URL::add_query_args_and_nonce(
703
+						[
704
+							'action'      => 'default',
705
+							'status'      => 'month',
706
+							'_reg_status' => RegStatus::AWAITING_REVIEW,
707
+						],
708
+						$this->reg_admin_url
709
+					),
710
+					'meta'   => [
711
+						'title'  => esc_html__('Not Approved / Awaiting Review', 'event_espresso'),
712
+						'target' => '',
713
+						'class'  => $this->menu_class . ' ee-toolbar-icon-not-approved',
714
+					],
715
+				]
716
+			);
717
+		}
718
+	}
719
+
720
+
721
+	/**
722
+	 * @return void
723
+	 */
724
+	private function addRegistrationOverviewThisMonthCancelled()
725
+	{
726
+		if (
727
+			$this->capabilities->current_user_can(
728
+				'ee_read_registrations',
729
+				'ee_admin_bar_menu_espresso-toolbar-registrations-month-cancelled'
730
+			)
731
+		) {
732
+			$this->admin_bar->add_menu(
733
+				[
734
+					'id'     => 'espresso-toolbar-registrations-month-cancelled',
735
+					'parent' => 'espresso-toolbar-registrations',
736
+					'title'  => '<span class="ee-toolbar-icon"></span>'
737
+								. esc_html__('Cancelled', 'event_espresso'),
738
+					'href'   => EEH_URL::add_query_args_and_nonce(
739
+						[
740
+							'action'      => 'default',
741
+							'status'      => 'month',
742
+							'_reg_status' => RegStatus::CANCELLED,
743
+						],
744
+						$this->reg_admin_url
745
+					),
746
+					'meta'   => [
747
+						'title'  => esc_html__('Cancelled', 'event_espresso'),
748
+						'target' => '',
749
+						'class'  => $this->menu_class . ' ee-toolbar-icon-cancelled',
750
+					],
751
+				]
752
+			);
753
+		}
754
+	}
755
+
756
+
757
+	/**
758
+	 * @return void
759
+	 */
760
+	private function addExtensionsAndServices()
761
+	{
762
+		if (
763
+			$this->capabilities->current_user_can(
764
+				'ee_read_ee',
765
+				'ee_admin_bar_menu_espresso-toolbar-extensions-and-services'
766
+			)
767
+		) {
768
+			$this->admin_bar->add_menu(
769
+				[
770
+					'id'     => 'espresso-toolbar-extensions-and-services',
771
+					'parent' => 'espresso-toolbar',
772
+					'title'  => '<span class="ee-toolbar-icon"></span>'
773
+								. esc_html__('Extensions & Services', 'event_espresso'),
774
+					'href'   => admin_url('admin.php?page=espresso_packages'),
775
+					'meta'   => [
776
+						'title'  => esc_html__('Extensions & Services', 'event_espresso'),
777
+						'target' => '',
778
+						'class'  => $this->menu_class,
779
+					],
780
+				]
781
+			);
782
+		}
783
+	}
784
+
785
+
786
+	/**
787
+	 * @return void
788
+	 */
789
+	private function addFontSizeSubMenu()
790
+	{
791
+		if (! is_admin()) {
792
+			return;
793
+		}
794
+		$this->admin_bar->add_menu(
795
+			[
796
+				'id'     => 'espresso-toolbar-font-size',
797
+				'parent' => 'espresso-toolbar',
798
+				'title'  => '<span class="ee-toolbar-icon"></span>'
799
+							. esc_html__('Set Font Size', 'event_espresso'),
800
+				'href'   => '',
801
+				'meta'   => [
802
+					'title'  => esc_html__('Set Font Size', 'event_espresso'),
803
+					'target' => '',
804
+					'class'  => $this->menu_class,
805
+				],
806
+			]
807
+		);
808
+
809
+		$settings_admin_url = admin_url('admin.php?page=espresso_general_settings');
810
+
811
+		$font_sizes = [
812
+			'tiny'    => AdminFontSize::FONT_SIZE_TINY,
813
+			'smaller' => AdminFontSize::FONT_SIZE_SMALLER,
814
+			'small'   => AdminFontSize::FONT_SIZE_SMALL,
815
+			'default' => AdminFontSize::FONT_SIZE_DEFAULT,
816
+			'big'     => AdminFontSize::FONT_SIZE_BIG,
817
+			'bigger'  => AdminFontSize::FONT_SIZE_BIGGER,
818
+		];
819
+
820
+		foreach ($font_sizes as $font_size => $value) {
821
+			$this->admin_bar->add_menu(
822
+				[
823
+					'id'     => "espresso-toolbar-set-font-size-$font_size",
824
+					'parent' => 'espresso-toolbar-font-size',
825
+					'title'  => '<span class="ee-toolbar-icon"></span>'
826
+								. sprintf(
827
+									/* translators: Font Size Small */
828
+									esc_html__('Font Size %1$s', 'event_espresso'),
829
+									ucwords($font_size)
830
+								),
831
+					'href'   => EEH_URL::add_query_args_and_nonce(
832
+						['action' => 'set_font_size', 'font_size' => $value],
833
+						$settings_admin_url
834
+					),
835
+					'meta'   => [
836
+						'title'  => esc_html__('increases or decreases the Event Espresso admin font size', 'event_espresso'),
837
+						'target' => '',
838
+						'class'  => $this->menu_class,
839
+					],
840
+				]
841
+			);
842
+		}
843
+	}
844 844
 }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
  */
21 21
 class AdminToolBar
22 22
 {
23
-    private ?WP_Admin_Bar $admin_bar        = null;
23
+    private ?WP_Admin_Bar $admin_bar = null;
24 24
 
25 25
     private EE_Capabilities $capabilities;
26 26
 
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
     {
101 101
         wp_register_style(
102 102
             'espresso-admin-toolbar',
103
-            EE_GLOBAL_ASSETS_URL . 'css/espresso-admin-toolbar.css',
103
+            EE_GLOBAL_ASSETS_URL.'css/espresso-admin-toolbar.css',
104 104
             ['dashicons'],
105 105
             EVENT_ESPRESSO_VERSION
106 106
         );
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
                 'href'  => $this->events_admin_url,
123 123
                 'meta'  => [
124 124
                     'title' => esc_html__('Event Espresso', 'event_espresso'),
125
-                    'class' => $this->menu_class . 'first',
125
+                    'class' => $this->menu_class.'first',
126 126
                 ],
127 127
             ]
128 128
         );
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
                     'meta'   => [
461 461
                         'title'  => esc_html__('Approved', 'event_espresso'),
462 462
                         'target' => '',
463
-                        'class'  => $this->menu_class . ' ee-toolbar-icon-approved',
463
+                        'class'  => $this->menu_class.' ee-toolbar-icon-approved',
464 464
                     ],
465 465
                 ]
466 466
             );
@@ -496,7 +496,7 @@  discard block
 block discarded – undo
496 496
                     'meta'   => [
497 497
                         'title'  => esc_html__('Pending Payment', 'event_espresso'),
498 498
                         'target' => '',
499
-                        'class'  => $this->menu_class . ' ee-toolbar-icon-pending',
499
+                        'class'  => $this->menu_class.' ee-toolbar-icon-pending',
500 500
                     ],
501 501
                 ]
502 502
             );
@@ -532,7 +532,7 @@  discard block
 block discarded – undo
532 532
                     'meta'   => [
533 533
                         'title'  => esc_html__('Not Approved / Awaiting Review', 'event_espresso'),
534 534
                         'target' => '',
535
-                        'class'  => $this->menu_class . ' ee-toolbar-icon-not-approved',
535
+                        'class'  => $this->menu_class.' ee-toolbar-icon-not-approved',
536 536
                     ],
537 537
                 ]
538 538
             );
@@ -568,7 +568,7 @@  discard block
 block discarded – undo
568 568
                     'meta'   => [
569 569
                         'title'  => esc_html__('Cancelled', 'event_espresso'),
570 570
                         'target' => '',
571
-                        'class'  => $this->menu_class . ' ee-toolbar-icon-cancelled',
571
+                        'class'  => $this->menu_class.' ee-toolbar-icon-cancelled',
572 572
                     ],
573 573
                 ]
574 574
             );
@@ -638,7 +638,7 @@  discard block
 block discarded – undo
638 638
                     'meta'   => [
639 639
                         'title'  => esc_html__('Approved', 'event_espresso'),
640 640
                         'target' => '',
641
-                        'class'  => $this->menu_class . ' ee-toolbar-icon-approved',
641
+                        'class'  => $this->menu_class.' ee-toolbar-icon-approved',
642 642
                     ],
643 643
                 ]
644 644
             );
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
                     'meta'   => [
675 675
                         'title'  => esc_html__('Pending', 'event_espresso'),
676 676
                         'target' => '',
677
-                        'class'  => $this->menu_class . ' ee-toolbar-icon-pending',
677
+                        'class'  => $this->menu_class.' ee-toolbar-icon-pending',
678 678
                     ],
679 679
                 ]
680 680
             );
@@ -710,7 +710,7 @@  discard block
 block discarded – undo
710 710
                     'meta'   => [
711 711
                         'title'  => esc_html__('Not Approved / Awaiting Review', 'event_espresso'),
712 712
                         'target' => '',
713
-                        'class'  => $this->menu_class . ' ee-toolbar-icon-not-approved',
713
+                        'class'  => $this->menu_class.' ee-toolbar-icon-not-approved',
714 714
                     ],
715 715
                 ]
716 716
             );
@@ -746,7 +746,7 @@  discard block
 block discarded – undo
746 746
                     'meta'   => [
747 747
                         'title'  => esc_html__('Cancelled', 'event_espresso'),
748 748
                         'target' => '',
749
-                        'class'  => $this->menu_class . ' ee-toolbar-icon-cancelled',
749
+                        'class'  => $this->menu_class.' ee-toolbar-icon-cancelled',
750 750
                     ],
751 751
                 ]
752 752
             );
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
      */
789 789
     private function addFontSizeSubMenu()
790 790
     {
791
-        if (! is_admin()) {
791
+        if ( ! is_admin()) {
792 792
             return;
793 793
         }
794 794
         $this->admin_bar->add_menu(
Please login to merge, or discard this patch.